package com.xyzshell.myphoneinfo.dashboard

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.xyzshell.myphoneinfo.R
import com.xyzshell.myphoneinfo.databinding.ActivityTestBinding

class TestActivity : AppCompatActivity() {
    private lateinit var binding: ActivityTestBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityTestBinding.inflate(layoutInflater)
        setContentView(binding.root)
        initView()
        initClick()
    }

    private fun initClick() {
        binding.backBtn.setOnClickListener { finish() }
        binding.toolItem1.root.setOnClickListener {
            intent = Intent(this, TestOtherActivity::class.java)
            intent.putExtra(TestOtherActivity.TYPE_KEY, getString(R.string.flashlight))
            startActivity(intent)
        }
        binding.toolItem2.root.setOnClickListener {
            intent = Intent(this, TestOtherActivity::class.java)
            intent.putExtra(TestOtherActivity.TYPE_KEY, getString(R.string.vibration))
            startActivity(intent)
        }
        binding.toolItem3.root.setOnClickListener {
            intent = Intent(this, TestOtherActivity::class.java)
            intent.putExtra(TestOtherActivity.TYPE_KEY, getString(R.string.buttons))
            startActivity(intent)
        }
        binding.toolItem4.root.setOnClickListener {
            intent = Intent(this, TouchActivity::class.java)
            startActivity(intent)
        }
        binding.toolItem5.root.setOnClickListener {
            intent = Intent(this, ColorsActivity::class.java)
            startActivity(intent)
        }
        binding.toolItem6.root.setOnClickListener {
            intent = Intent(this, TestOtherActivity::class.java)
            intent.putExtra(TestOtherActivity.TYPE_KEY, getString(R.string.backlight))
            startActivity(intent)
        }
        binding.toolItem7.root.setOnClickListener {
            intent = Intent(this, TestOtherActivity::class.java)
            intent.putExtra(TestOtherActivity.TYPE_KEY, getString(R.string.light_sensor))
            startActivity(intent)
        }
        binding.toolItem8.root.setOnClickListener {
            intent = Intent(this, TestOtherActivity::class.java)
            intent.putExtra(TestOtherActivity.TYPE_KEY, getString(R.string.proximity))
            startActivity(intent)
        }
        binding.toolItem9.root.setOnClickListener {
            intent = Intent(this, TestOtherActivity::class.java)
            intent.putExtra(TestOtherActivity.TYPE_KEY, getString(R.string.accelerometer))
            startActivity(intent)
        }
    }

    private fun initView() {
        binding.toolItem1.ivIcon.setImageResource(R.mipmap.flash)
        binding.toolItem1.tvLabel.text = getString(R.string.flashlight)
        binding.toolItem1.ivEnd.setImageResource(R.mipmap.vector)

        binding.toolItem2.ivIcon.setImageResource(R.mipmap.vibration)
        binding.toolItem2.tvLabel.text = getString(R.string.vibration)
        binding.toolItem2.ivEnd.setImageResource(R.mipmap.vector)

        binding.toolItem3.ivIcon.setImageResource(R.mipmap.button)
        binding.toolItem3.tvLabel.text = getString(R.string.buttons)
        binding.toolItem3.ivEnd.setImageResource(R.mipmap.vector)

        binding.toolItem4.ivIcon.setImageResource(R.mipmap.multi)
        binding.toolItem4.tvLabel.text = getString(R.string.multitouch)
        binding.toolItem4.ivEnd.setImageResource(R.mipmap.vector)

        binding.toolItem5.ivIcon.setImageResource(R.mipmap.display)
        binding.toolItem5.tvLabel.text = getString(R.string.displays)
        binding.toolItem5.ivEnd.setImageResource(R.mipmap.vector)

        binding.toolItem6.ivIcon.setImageResource(R.mipmap.back)
        binding.toolItem6.tvLabel.text = getString(R.string.backlight)
        binding.toolItem6.ivEnd.setImageResource(R.mipmap.vector)

        binding.toolItem7.ivIcon.setImageResource(R.mipmap.light)
        binding.toolItem7.tvLabel.text = getString(R.string.light_sensor)
        binding.toolItem7.ivEnd.setImageResource(R.mipmap.vector)

        binding.toolItem8.ivIcon.setImageResource(R.mipmap.proxi)
        binding.toolItem8.tvLabel.text = getString(R.string.proximity)
        binding.toolItem8.ivEnd.setImageResource(R.mipmap.vector)

        binding.toolItem9.ivIcon.setImageResource(R.mipmap.acceler)
        binding.toolItem9.tvLabel.text = getString(R.string.accelerometer)
        binding.toolItem9.ivEnd.setImageResource(R.mipmap.vector)
    }
}