package importantedto.appliededto.surgeonedto.promiseedto.dialectedto

import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.text.SpannableString
import android.text.Spanned
import android.text.style.UnderlineSpan
import com.base.datarecovery.databinding.KeepedtoBinding
import importantedto.Exhibitionedto
import importantedto.admireedto.sweptedto.Differenceedto
import importantedto.afteredto.constitutionaledto.Neckedto
import importantedto.concreteedto.cameedto.Hateedto.ifAgreePrivacy


class Policyedto(
    private val binding: KeepedtoBinding,
    private val context: Activity,
    private val listener: OnUserPrivacyAgreementListener
) {


    init {
        initView()
    }


    private fun initView() {


        val spannableString = SpannableString("Privacy Policy")
        spannableString.setSpan(
            UnderlineSpan(),
            0,
            spannableString.length,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
        )
        binding.quoteedto.text = spannableString

        binding.quoteedto.setOnClickListener {
            val intent = Intent(
                Intent.ACTION_VIEW,
                Uri.parse(Neckedto.privacyPolicy)
            )
            context.startActivity(intent)
        }

        var clicked = false
        binding.theateredto.setOnClickListener {
            if (clicked) {
                return@setOnClickListener
            }
            clicked = true
            ifAgreePrivacy = true
            (context.application as Exhibitionedto).initApp()
            Differenceedto.preloadAd(context)
            listener.onAgreePrivacy()
        }
    }

    interface OnUserPrivacyAgreementListener {
        fun onAgreePrivacy()
    }

}