package overthrewic.dirtyic.coneic

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.easy.clean.BuildConfig
import tooic.fatalityic.GlobalConfig.URL_PRIVACY
import tooic.fatalityic.Runawayic.cleanedSize
import tooic.fatalityic.jittersic.Peteric
import com.easy.clean.databinding.SayicBinding
import tooic.fatalityic.redic.speckledic.hankeringic.Curableic.toFormatSize
import androidx.core.net.toUri
import androidx.core.view.updatePadding
import com.easy.clean.R
import tooic.fatalityic.Runawayic.fcmToken
import tooic.fatalityic.corroborateic.indexic.Jewishic
import autonomyic.polemicalic.congestionic.Unwindic
import rememberic.Subsequentic
import tooic.fatalityic.redic.speckledic.hankeringic.Insistentic.copyText
import tooic.fatalityic.redic.speckledic.hankeringic.Alongic.toast
import com.google.gson.GsonBuilder


class Curbic : Peteric<SayicBinding>(SayicBinding::inflate) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        if (requireActivity() is Aerodynamicsic) {
            (requireActivity() as Aerodynamicsic).insetsCallBack = {
                binding.overseeric.updatePadding(0, it.top, 0, 0)
            }
        }
    }

    @SuppressLint("SetTextI18n")
    override fun initView() {
        super.initView()

        binding.somebodyic.text = cleanedSize.toFormatSize()
        binding.billionaireic.text = "v${BuildConfig.VERSION_NAME}"
        Unwindic.showNative(binding.protectic, R.layout.explanatoryic)

        if (BuildConfig.DEBUG) {
            binding.spadeic.visibility = View.VISIBLE
            binding.spadeic.text = fcmToken
            binding.spadeic.setOnClickListener {
                requireContext().copyText("token", fcmToken)
                requireContext().toast("copy token")
            }

            binding.urbanic.setOnClickListener {
                val configBean = Jewishic.configBean
                val gson = GsonBuilder().setPrettyPrinting().create()
                val json = gson.toJson(configBean)
                requireContext().copyText("json", json)
                requireContext().toast("copy json")
            }
        }
    }

    override fun initListener() {
        super.initListener()
        binding.shockingic.setOnClickListener {
            startActivity(Intent(Intent.ACTION_VIEW, URL_PRIVACY.toUri()))
        }
        binding.hearseic.setOnClickListener {
            val dialog = Subsequentic(requireActivity())
            dialog.showDialog(true)
        }
//        binding.telecommutingic.setOnClickListener {
//            (requireActivity() as Aerodynamicsic).onBackPressedDispatcher.onBackPressed()
//        }
    }

    override fun onResume() {
        super.onResume()
        binding.somebodyic.text = cleanedSize.toFormatSize()
    }
}