package com.xyzshell.myphoneinfo.dashboard

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.xyzshell.myphoneinfo.R
import com.xyzshell.myphoneinfo.databinding.FragmentHardWareBinding
import com.xyzshell.myphoneinfo.dialog.DialogBlueTooth
import com.xyzshell.myphoneinfo.dialog.DialogDiskPart
import com.xyzshell.myphoneinfo.dialog.DialogExtension
import com.xyzshell.myphoneinfo.dialog.DialogInput

class HardWareFragment : Fragment() {
 private lateinit var binding: FragmentHardWareBinding
 private var dialogBlueTooth: DialogBlueTooth? = null
 private var dialogInput: DialogInput? = null
 private var dialogExtension: DialogExtension? = null
 private var dialogDiskPart: DialogDiskPart? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentHardWareBinding.inflate(inflater, container, false)
        binding.cpuBtn.setOnClickListener {
            var intent=Intent(requireContext(), AnalysisActivity::class.java)
            startActivity(intent)
        }
        binding.pair1.setOnClickListener {
            dialogBlueTooth= dialogBlueTooth?: DialogBlueTooth()
            dialogBlueTooth?.show(childFragmentManager, "BlueTooth1")
        }
        binding.pair2.setOnClickListener {
            dialogBlueTooth= dialogBlueTooth?: DialogBlueTooth()
            dialogBlueTooth?.show(childFragmentManager, "BlueTooth2")
        }
        binding.othertext.setOnClickListener {
            dialogInput=dialogInput?: DialogInput()
            dialogInput?.show(childFragmentManager, "Input")
        }
        binding.extensionShow.setOnClickListener {
            dialogExtension=dialogExtension?: DialogExtension()
            dialogExtension?.show(childFragmentManager, "Extention")
        }
        binding.disktext.setOnClickListener {
            dialogDiskPart=dialogDiskPart?: DialogDiskPart()
            dialogDiskPart?.show(childFragmentManager, "DiskPart")
        }
        initText()
        return binding.root
    }

    private fun initText() {
        //processor
        binding.text1.textTitle.text = getString(R.string.vendor)
        binding.text1.textContent.text=getString(R.string.apps)
        binding.text2.textTitle.text = getString(R.string.hardware)
        binding.text3.textTitle.text = getString(R.string.cores)
        binding.text4.textTitle.text = getString(R.string.CPU)
        binding.text5.textTitle.text = getString(R.string.process)
        binding.text6.textTitle.text = getString(R.string.architecture)
        binding.text7.textTitle.text = getString(R.string.ABI)
        binding.text8.textTitle.text = getString(R.string.supported_ABls)
        binding.text9.textTitle.text = getString(R.string.frequencies)

        //gpu
        binding.cpuText1.textTitle.text = getString(R.string.vendor)
        binding.cpuText1.textContent.text=getString(R.string.apps)
        binding.cpuText2.textTitle.text = getString(R.string.gpu)
        binding.cpuText3.textTitle.text=getString(R.string.max_frequency)
        binding.cpuText4.textTitle.text=getString(R.string.architecture)
        binding.cpuText5.textTitle.text=getString(R.string.cores)
        binding.cpuText6.textTitle.text=getString(R.string.total_l2)
        binding.cpuText7.textTitle.text=getString(R.string.bus_width)
        binding.cpuText8.textTitle.text=getString(R.string.vulkan_support)
        binding.cpuText9.textTitle.text=getString(R.string.vulkan_API)

        //display
        binding.disText1.textTitle.text=getString(R.string.resolution)
        binding.disText2.textTitle.text=getString(R.string.screen_density)
        binding.disText3.textTitle.text=getString(R.string.screen_density_d)
        binding.disText4.textTitle.text=getString(R.string.screen_size_e)
        binding.disText5.textTitle.text=getString(R.string.aspect_ratio)
        binding.disText6.textTitle.text=getString(R.string.refresh_rate)
        binding.disText7.textTitle.text=getString(R.string.wide_color_gamut)
        binding.disText8.textTitle.text=getString(R.string.hdr_support)

        //memory
        binding.memText1.textTitle.text=getString(R.string.ram_size)

        //storage
        binding.storText1.textTitle.text=getString(R.string.filesystem)
        binding.storText2.textTitle.text=getString(R.string.block_size)

        //Audio
        binding.check1.content.text=getString(R.string.low_audio)
        binding.check2.content.text=getString(R.string.pro_audio)
        binding.check3.content.text=getString(R.string.midl)



    }

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

                }
            }
    }
}