package com.xyzshell.myphoneinfo.dashboard

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.xyzshell.andinfo.AndInfo
import com.xyzshell.myphoneinfo.R
import com.xyzshell.myphoneinfo.databinding.ActivityAnalysisBinding
import com.xyzshell.myphoneinfo.dialog.DialogCpuInfo

class AnalysisActivity : AppCompatActivity() {
    private lateinit var binding: ActivityAnalysisBinding
    private var dialogCpuInfo: DialogCpuInfo? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityAnalysisBinding.inflate(layoutInflater)
        setContentView(binding.root)
        binding.timeShow.setOnClickListener {
            startActivity(Intent(this, CpuStatusActivity::class.java))
        }
        binding.backBtn.setOnClickListener { finish() }
        initText()
        initShow()
    }

    private fun initShow() {
        binding.infoShow.setOnClickListener {
            dialogCpuInfo = dialogCpuInfo ?: DialogCpuInfo()
            dialogCpuInfo?.show(supportFragmentManager, "")
        }
    }

    private fun initText() {
        //processor
        binding.proText1.textTitle.text=getString(R.string.hardware)
        binding.proText1.textContent.text=AndInfo.instance.cpu.text()
        println(AndInfo.instance.cpu.text())
        binding.proText2.textTitle.text=getString(R.string.manufacturer)
        binding.proText3.textTitle.text=getString(R.string.marketing_name)
        binding.proText4.textTitle.text=getString(R.string.process)
        binding.proText5.textTitle.text=getString(R.string.cores)
        binding.proText6.textTitle.text=getString(R.string.CPU)
        binding.proText7.textTitle.text=getString(R.string.frequencies)
        binding.proText8.textTitle.text=getString(R.string.architecture)
        binding.proText9.textTitle.text=getString(R.string.ABI)
        binding.proText10.textTitle.text=getString(R.string.supported_ABls)
        binding.proText11.textTitle.text=getString(R.string.features)
        //cluster1
        binding.clu1Text1.textTitle.text=getString(R.string.type)
        binding.clu1Text2.textTitle.text=getString(R.string.vendor)
        binding.clu1Text3.textTitle.text=getString(R.string.cluster)
        binding.clu1Text4.textTitle.text=getString(R.string.max_frequency)
        binding.clu1Text5.textTitle.text=getString(R.string.min_frequency)
    }
}