package pxds.etmo

import android.content.Intent
import android.net.Uri
import com.test.basd.supercleanermax.R
import com.test.basd.supercleanermax.databinding.MeuvxpBinding
import pxds.iqiv.ioih.gxph.Dngu
import pxds.iqiv.ioih.gxph.rrax.Gnup.Companion.initJob
import pxds.iqiv.ioih.gxph.rrax.Mqmn
import pxds.lmmd.zmwf.Bpfw
import pxds.lmmd.zmwf.Khko.setTrackedOnClickListener
import pxds.lmmd.zmwf.Khko.string
import pxds.lmmd.zmwf.Uawv.allNotification
import pxds.lmmd.zmwf.Uawv.remainNotification

class Uknt : Bpfw<MeuvxpBinding>() {

    override val binding: MeuvxpBinding by lazy {
        MeuvxpBinding.inflate(layoutInflater)
    }

    override fun initListener() {
        binding.kgxhrze.setTrackedOnClickListener {

            finishToMain()

        }
        binding.wzsjbdx.setOnCheckedChangeListener { buttonView, isChecked ->
            remainNotification = isChecked
            if (isChecked) {
                initJob()
            } else {
                val serviceIntent = Intent(this, Dngu::class.java)
                stopService(serviceIntent)
            }
        }
        binding.tkrzaji.setOnCheckedChangeListener { buttonView, isChecked ->
            allNotification = isChecked
            switchFcm(isChecked)
        }
        binding.izgqmzp.setTrackedOnClickListener {
            val intent = Intent(
                Intent.ACTION_VIEW, Uri.parse(R.string.ވޤޥޚހ_D.string())
            )
            startActivity(intent)
        }
    }

    override fun initView() {
        binding.wzsjbdx.isChecked = remainNotification
        binding.tkrzaji.isChecked = allNotification
    }

    private fun switchFcm(checked: Boolean) {
        if (checked) {
            Mqmn.subscribeToTopic()
        } else {
            Mqmn.unSubscribeToTopic()
        }
    }
}