package com.xyzshell.myphoneinfo.dashboard

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.xyzshell.andinfo.AndInfo
import com.xyzshell.myphoneinfo.R
import com.xyzshell.myphoneinfo.databinding.FragmentSystemShowBinding

class SystemShowFragment : Fragment() {
private lateinit var binding: FragmentSystemShowBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding= FragmentSystemShowBinding.inflate(inflater,container,false)
        initView()
        return binding.root
    }

    private fun initView() {
        binding.phoneName.text=AndInfo.instance.device.brand
        binding.text0.textTitle.text=getString(R.string.model)
        binding.text0.textContent.text=AndInfo.instance.device.model
        binding.text1.textTitle.text=getString(R.string.product)
        binding.text1.textContent.text=AndInfo.instance.device.productName
        binding.text2.textTitle.text=getString(R.string.device)
        binding.text2.textContent.text=AndInfo.instance.device.device
        binding.text3.textTitle.text=getString(R.string.board)
        binding.text3.textContent.text=AndInfo.instance.device.boardName
        binding.text4.textTitle.text=getString(R.string.manufacturer)
        binding.text4.textContent.text=AndInfo.instance.device.manufacturer
        binding.text5.textTitle.text=getString(R.string.baseband)
        binding.text6.textTitle.text=getString(R.string.google_play_services_version)

        //操作系统
        val buildInfo = AndInfo.instance.build
        binding.textOp1.textTitle.text=getString(R.string.android_version)
        binding.textOp1.textContent.text=buildInfo.versionRelease
        binding.textOp2.textTitle.text=getString(R.string.api)
        binding.textOp2.textContent.text=buildInfo.versionSdkInt.toString()
        binding.textOp3.textTitle.text=getString(R.string.emui)

        binding.textOp4.textTitle.text=getString(R.string.security_patch)
        binding.textOp4.textContent.text=buildInfo.securityPatch
        binding.textOp5.textTitle.text=getString(R.string.version)
        binding.textOp5.textContent.text=buildInfo.display
        binding.textOp6.textTitle.text=getString(R.string.baseband)

        binding.textOp7.textTitle.text=getString(R.string.fingerprint)
        binding.textOp7.textContent.text=buildInfo.fingerprint
        binding.textOp8.textTitle.text=getString(R.string.build_time)
        binding.textOp8.textContent.text=buildInfo.buildDate.toString()
        binding.textOp9.textTitle.text=getString(R.string.initial_release)

        binding.textOp10.textTitle.text=getString(R.string.architecture)

        binding.textOp11.textTitle.text=getString(R.string.instruction_sets)

        binding.textOp12.textTitle.text=getString(R.string.treble)
        binding.textOp13.textTitle.text=getString(R.string.root_access)
        binding.textOp14.textTitle.text=getString(R.string.google_play_services)
        binding.textOp15.textTitle.text=getString(R.string.toybox)
        binding.textOp16.textTitle.text=getString(R.string.java_VM)
        binding.textOp16.textContent.text=AndInfo.instance.build.jvmName + " " + AndInfo.instance.build.jvmVersion
        binding.textOp17.textTitle.text=getString(R.string.ssl_version)
        binding.textOp18.textTitle.text=getString(R.string.language)
        binding.textOp19.textTitle.text=getString(R.string.usb_debugging)
        //内核
        binding.textOp20.textTitle.text=getString(R.string.kernel)
        binding.textOp20.textContent.text=AndInfo.instance.build.kernelCompleteVersion


        binding.textclear1.textTitle.text=getString(R.string.vendor)
        binding.textclear2.textTitle.text=getString(R.string.version)


        binding.textwide1.textTitle.text=getString(R.string.vendor)
        binding.textwide2.textTitle.text=getString(R.string.version)
        binding.textwide3.textTitle.text=getString(R.string.algorithm)
        binding.textwide4.textTitle.text=getString(R.string.device_id)
        binding.textwide5.textTitle.text=getString(R.string.security_level)
        binding.textwide6.textTitle.text=getString(R.string.highest_hdcp_level)

    }

    companion object {
        @JvmStatic
        fun newInstance() =
            SystemShowFragment().apply {
                arguments = Bundle().apply {

                }
            }
    }
}