package rallyedto.finishedto

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import androidx.activity.addCallback
import com.base.datarecovery.databinding.BottomedtoBinding
import rallyedto.GlobalConfig
import rallyedto.aluminiumedto.scanedto.Pleadedto
import rallyedto.aluminiumedto.scanedto.Pleadedto.Companion.startJob
import rallyedto.battleedto.acresedto.Lemonedto
import rallyedto.epicalyxedto.rodedto.trunkedto.Scholaredto.subscribeToTopic
import rallyedto.epicalyxedto.rodedto.trunkedto.Scholaredto.unsubscribeFromTopic
import rallyedto.farewelledto.Hutedto.showRateStarPopDialog
import rallyedto.policeedto.huntedto.Snuggleedto.fcmNotification
import rallyedto.policeedto.huntedto.Snuggleedto.stayNotification
import rallyedto.talledto.blewedto.Islandedto

class Miracleedto : Lemonedto<BottomedtoBinding>() {

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

    override fun initView() {
        Islandedto.setStatusBarLightMode(this, true)
        Islandedto.setStatusBarColor(this, Color.TRANSPARENT)

        binding.bomberedto.isChecked = stayNotification
        binding.caveedto.isChecked = fcmNotification
    }

    override fun initListener() {
        onBackPressedDispatcher.addCallback {
            finishToMain()
        }
        binding.gooseedto.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }

        binding.bomberedto.setOnCheckedChangeListener { buttonView, isChecked ->
            stayNotification = isChecked
            if (isChecked) {
//                startStayNotification()
                startJob()
            } else {
//                val serviceIntent = Intent(this, Retireeedto::class.java)
//                stopService(serviceIntent)
                Pleadedto.isCancel = true
            }
        }
        binding.caveedto.setOnCheckedChangeListener { buttonView, isChecked ->
            fcmNotification = isChecked
            val topic = "${GlobalConfig.PACKAGE_NAME}_push"
            if (isChecked) {
                subscribeToTopic(topic)
            } else {
                unsubscribeFromTopic(topic)
            }
        }

        binding.constitutionaledto.setOnClickListener {
            val intent = Intent(
                Intent.ACTION_VIEW,
                Uri.parse(GlobalConfig.URL_PRIVACY)
            )
            startActivity(intent)
          //  Obscureedto.sendNotification(this, actionId = ID_WEATHER,"weather")
        }

        binding.knotedto.setOnClickListener {
            showRateStarPopDialog(mustShow = true)
           // Obscureedto.sendNotification(this, actionId = ID_XINGZUO,"xingzuo")
        }
//        binding.fabricateedto.text= Pianoedto.getInstance().getString("token","")
//        binding.cooledto.setOnClickListener {
//            copyText(this,binding.fabricateedto.text.toString())
//        }
    }
    fun copyText(context: Context, text: String?) {
        val clipboardManager: ClipboardManager =
            context.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
        val clip = ClipData.newPlainText("simple text", text)
        clipboardManager.setPrimaryClip(clip)
    }
}