package com.xyzshell.myphoneinfo.dialog

import android.graphics.Typeface
import android.os.Bundle
import android.text.SpannableString
import android.text.style.StyleSpan
import android.view.View
import com.xyzshell.myphoneinfo.R
import com.xyzshell.myphoneinfo.base.BaseDialogFragment
import com.xyzshell.myphoneinfo.databinding.DialogCpuInfoBinding

class DialogCpuInfo :BaseDialogFragment<DialogCpuInfoBinding>(DialogCpuInfoBinding::inflate){
    override fun getTitle(): String  = resources.getString(R.string.proc_cpuinfo)

    override fun getIconRes(): Int? =6

    override fun getDoubleBtn(): Boolean? = false

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.cpuTv01.text=setColonBoldText("Processor :AArch64 Processor rev 2(aarch64)")
        binding.cpuTv02.text=setColonBoldText("processor :1")
        binding.cpuTv03.text=setColonBoldText("BogoMIPS :3.84" )
        binding.cpuTv04.text=setColonBoldText("Features :fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid")
        binding.cpuTv05.text=setColonBoldText("CPU implementer :0×41")
        binding.cpuTv06.text=setColonBoldText("CPU architecture :8")
        binding.cpuTv07.text=setColonBoldText("CPU variant :0×0")
        binding.cpuTv08.text=setColonBoldText("CPU part :0×d03")
        binding.cpuTv09.text=setColonBoldText("CPU revision :4")
        binding.hardwareTv.text=setColonBoldText("Hardware :vendor Kirin710")
    }
    fun setColonBoldText( text: String) : SpannableString {
        val colonIndex = text.indexOf(":")
        if (colonIndex != -1) {
            val spannableString = SpannableString(text)
            // 将冒号之前的部分设置为加粗
            spannableString.setSpan(
                StyleSpan(Typeface.BOLD),
                0,
                colonIndex,
                SpannableString.SPAN_INCLUSIVE_INCLUSIVE
            )
            return spannableString
        } else {
            return SpannableString(text)
        }
    }

    override fun onNegativeClick() {
        super.onNegativeClick()

    }

    override fun onPositiveClick() {
        super.onPositiveClick()
    }
}