package com.xyzshell.myphoneinfo.dashboard

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.xyzshell.myphoneinfo.R
import com.xyzshell.myphoneinfo.databinding.ActivityToolsBinding
import androidx.core.view.isVisible

class ToolsActivity : AppCompatActivity() {
    private lateinit var binding: ActivityToolsBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityToolsBinding.inflate(layoutInflater)
        setContentView(binding.root)
        binding.toolItem1.ivIcon.setImageResource(R.mipmap.key)
        binding.toolItem1.tvLabel.text=getString(R.string.root_check)
        binding.noDevice.visibility=View.GONE

        binding.toolItem2.ivIcon.setImageResource(R.mipmap.blue_tooth)
        binding.toolItem2.tvLabel.text=getString(R.string.bluetooth)
        binding.llBlue.visibility=View.GONE


        binding.toolItem3.ivIcon.setImageResource(R.mipmap.cpu)
        binding.toolItem3.tvLabel.text=getString(R.string.cpu_analysis)
        initView()
    }

    private fun initView() {
        binding.toolItem1.root.setOnClickListener {
            var isExpand = binding.noDevice.isVisible
            if(isExpand){
                binding.noDevice.visibility=View.GONE
            }else{
                binding.noDevice.visibility=View.VISIBLE
            }
        }
        binding.toolItem2.root.setOnClickListener {
            var isExpand = binding.llBlue.isVisible
            if(isExpand){
                binding.llBlue.visibility=View.GONE
            }else{
                binding.llBlue.visibility=View.VISIBLE
            }
        }
        binding.llPair.setOnClickListener {
            intent=Intent(this, BlueToothActivity::class.java)
            intent.putExtra(BlueToothActivity.TITLE_KEY, getString(R.string.paired_devices))
            startActivity(intent)
        }
        binding.llNear.setOnClickListener {
            intent=Intent(this, BlueToothActivity::class.java)
            intent.putExtra(BlueToothActivity.TITLE_KEY, getString(R.string.nearby_devices))
            startActivity(intent)
        }
        binding.tool3.setOnClickListener {
            intent=Intent(this, AnalysisActivity::class.java)
            startActivity(intent)
        }
        binding.ivBack.setOnClickListener {
            finish()
        }
    }
}