package com.test.basd.onecleanmaster.helps

import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.view.View
import android.widget.TextView
import com.blankj.utilcode.util.AppUtils
import com.blankj.utilcode.util.SPUtils
import com.test.basd.onecleanmaster.R
import com.test.basd.onecleanmaster.activity.splash.NewSplashActivity
//import com.trustlook.sdk.data.AppInfo

object ConfigHelper {
    var gid = ""
    var isOpenNotification = false
//    var riskAppList: List<AppInfo>? = null
    var appList: List<AppUtils.AppInfo>? = null
    var virusReminder = false
        get() {
            return SPUtils.getInstance().getBoolean("virusReminder", field)
        }
        set(value) {
            field = value
            SPUtils.getInstance().put("virusReminder", value, true)
        }

    // 域名
    const val eventUrl = "https://rp.plantbasedsweetsbylotusllc.xyz/"
    const val apiUrl = "https://api.plantbasedsweetsbylotusllc.xyz/"

    // admob广告id
    const val openAdmobId = "/6499/example/app-open"
    const val interAdmobId = "ca-app-pub-3940256099942544/1033173712"
    const val nativeAdmobId = "ca-app-pub-3940256099942544/2247696110"

    // 正式包名
    const val packageName = "com.kkzxkk.cleaner.quick"

    val noLoadingActivities = listOf(
        "full", // 过滤全屏广告
        "adActivity",
        NewSplashActivity::class.java.simpleName
        // 返回前台时不跳转启动页的 activity
    )
    var junkSizeClean = 0L
        get() {
            return SPUtils.getInstance().getLong("junkSizeClean", field)
        }
        set(value) {
            field = value
            SPUtils.getInstance().put("junkSizeClean", value)
        }

    fun showWarmReminder(context: Context, onClick: ((Boolean) -> Unit)? = null) {
        val dialog = Dialog(context)
        val view: View = View.inflate(context, R.layout.layout_warm_reminder, null)
        dialog.requestWindowFeature(1)
        dialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        dialog.window!!.setLayout(-1, -1)
        dialog.setCanceledOnTouchOutside(false)
        dialog.setCancelable(false)
        dialog.setContentView(view)
        dialog.findViewById<TextView>(R.id.id_tv_cancel)?.setOnClickListener {
            dialog.dismiss()
            onClick?.invoke(false)
        }
        dialog.findViewById<TextView>(R.id.id_tv_url)?.setOnClickListener {
            val intent = Intent(
                Intent.ACTION_VIEW,
                Uri.parse("https://www.trustlook.com/privacy-policy")
            )
            context.startActivity(intent)
        }
        dialog.findViewById<TextView>(R.id.id_tv_sure)?.setOnClickListener {
            onClick?.invoke(true)
            dialog.dismiss()

        }
        dialog.show()
    }

    var ifAgreePrivacy = false
        get() {
            return SPUtils.getInstance().getBoolean("ifAgreePrivacy", field)
        }
        set(value) {
            field = value
            SPUtils.getInstance().put("ifAgreePrivacy", value, true)
        }
    var ifGuest = false
        get() {
            return SPUtils.getInstance().getBoolean("ifGuest", field)
        }
        set(value) {
            field = value
            SPUtils.getInstance().put("ifGuest", value, true)
        }


}