package rowedto.jockeyedto.sheetedto.atticedto

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.ShootedtoBinding
import rowedto.jockeyedto.sheetedto.balsamedto.formaledto.orientationedto.Prematureedto.showRateStarPopDialog
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.fcmNotification
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.stayNotification
import rowedto.jockeyedto.sheetedto.dryedto.stableedto.Biggestedto
import rowedto.jockeyedto.sheetedto.dryedto.stableedto.Biggestedto.Companion.startJob
import rowedto.jockeyedto.sheetedto.interactiveedto.twistedto.Constitutionedto.subscribeToTopic
import rowedto.jockeyedto.sheetedto.interactiveedto.twistedto.Constitutionedto.unsubscribeFromTopic
import rowedto.jockeyedto.sheetedto.knewedto.economicedto.copyrightedto.Celledto
import rowedto.jockeyedto.sheetedto.knewedto.economicedto.copyrightedto.Crossingedto
import rowedto.jockeyedto.sheetedto.raceedto.pavementedto.Spareedto

class Prescriptionedto : Crossingedto<ShootedtoBinding>() {

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

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

        binding.carryedto.isChecked = stayNotification
        binding.handedto.isChecked = fcmNotification
    }

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

        binding.carryedto.setOnCheckedChangeListener { buttonView, isChecked ->
            stayNotification = isChecked
            if (isChecked) {
//                startStayNotification()
                startJob()
            } else {
//                val serviceIntent = Intent(this, Surfaceedto::class.java)
//                stopService(serviceIntent)
                Biggestedto.isCancel = true
            }
        }
        binding.handedto.setOnCheckedChangeListener { buttonView, isChecked ->
            fcmNotification = isChecked
            val topic = "${Celledto.packageName}_push"
            if (isChecked) {
                subscribeToTopic(topic)
            } else {
                unsubscribeFromTopic(topic)
            }
        }

        binding.softwareedto.setOnClickListener {
            val intent = Intent(
                Intent.ACTION_VIEW,
                Uri.parse(Celledto.privacyPolicy)
            )
            startActivity(intent)
          //  Sectoredto.sendNotification(this, actionId = ID_WEATHER,"weather")
        }

        binding.partedto.setOnClickListener {
            showRateStarPopDialog(mustShow = true)
           // Sectoredto.sendNotification(this, actionId = ID_XINGZUO,"xingzuo")
        }
//        binding.dutyedto.text= Stewardedto.getInstance().getString("token","")
//        binding.pouredto.setOnClickListener {
//            copyText(this,binding.dutyedto.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)
    }
}