package com.example.defenseapplication.liveVideo

import android.content.Intent
import android.os.Bundle
import com.example.defenseapplication.R
import com.example.defenseapplication.base.BaseActivity
import com.example.defenseapplication.databinding.SettingsActivityBinding
import com.example.defenseapplication.utils.LanguageUtil
import com.example.defenseapplication.view.CustomDialogFragmentText
import com.example.defenseapplication.view.LanguageDialog
import com.example.defenseapplication.view.RecognitionModeDialog
import com.gyf.immersionbar.ImmersionBar
//设置页面
class SettingsActivity : BaseActivity() {

    private lateinit var binding: SettingsActivityBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = SettingsActivityBinding.inflate(layoutInflater)
        setContentView(binding.root)
        // ImmersionBar核心调用,沉浸式
        ImmersionBar.with(this)
            .statusBarDarkFont(true)
            .titleBar(binding.topBar)
            .init()
        binding.itemVoiceSetting.setOnClickListener {
            val intent = Intent(this, VoiceSettingsActivity::class.java)
            startActivity(intent)
        }
        binding.ivBack.setOnClickListener {
            finish()
        }

        binding.itemRecognitionMode.setOnClickListener {
            val dialog = RecognitionModeDialog(this)
            dialog.setOnConfirmListener { mode ->
                binding.tvRecognitionMode.text = mode
            }
            dialog.show()
        }

        binding.itemDeviceName.setOnClickListener {
            val dialog = CustomDialogFragmentText()
                .setTitle(getString(R.string.device_name))
                .setInputText(binding.tvDeviceName.text.toString())
            dialog.setOnConfirmListener { name ->
                binding.tvDeviceName.text = name
            }
            dialog.show(supportFragmentManager, "CustomDialogFragment")
        }

        binding.itemUnbindDevice.setOnClickListener {
            val dialog = CustomDialogFragmentText()
                .setTitle(getString(R.string.tip))
                .setMessage(getString(R.string.logout_confirm))
                .setNegativeText(getString(R.string.cancel))
                .setPositiveText(getString(R.string.confirm))
                .setShowInput(false)
            dialog.setOnConfirmListener {
                finish()
            }
            dialog.show(supportFragmentManager, "CustomDialogFragment")
        }
        binding.itemWaterGunSetting.setOnClickListener {
            val intent = Intent(this, WaterGunSettingsActivity::class.java)
            startActivity(intent)
        }
        binding.itemAutoMode.setOnClickListener {
            val intent = Intent(this, AutoModeActivity::class.java)
            startActivity(intent)
        }
        binding.itemDeviceInfo.setOnClickListener {
            val intent = Intent(this, DeviceInfoActivity::class.java)
            startActivity(intent)
        }
        // 关联用户
        binding.itemRelatedUsers.setOnClickListener {
            val intent = Intent(this, LinkedUserActivity::class.java)
            intent.putExtra(LinkedUserActivity.EXTRA_MODE, LinkedUserActivity.MODE_SETTINGS)
            startActivity( intent)
        }
        binding.itemWifiManage.setOnClickListener {
            val intent = Intent(this, WiFiManagementActivity::class.java)
            startActivity(intent)
        }
    }

}
