package com.zxhyis.toolss.ad

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.View
import android.widget.TextView
import com.blankj.utilcode.util.AppUtils
import com.blankj.utilcode.util.SPUtils
import com.trustlook.sdk.data.AppInfo
import com.zxhyis.toolss.R
import com.zxhyis.toolss.ui.page.SpeakCleaningActivity
import com.zxhyis.toolss.ui.page.SplashActivity


object ConfigHelper {
    var isOpenNotification = false
    var ifAppLock = false
        get() {
            return SPUtils.getInstance().getBoolean("ifAppLock", field)
        }
        set(value) {
            field = value
            SPUtils.getInstance().put("ifAppLock", value, true)
        }
    var junkSizeClean = 0L
        get() {
            return SPUtils.getInstance().getLong("junkSizeClean", field)
        }
        set(value) {
            field = value
            SPUtils.getInstance().put("junkSizeClean", value)
        }
    var warmReminder = false
        get() {
            return SPUtils.getInstance().getBoolean("warmReminder", field)
        }
        set(value) {
            field = value
            SPUtils.getInstance().put("warmReminder", value, true)
        }
    var ifAgreePrivacy = false
        get() {
            return SPUtils.getInstance().getBoolean("ifAgreePrivacy", field)
        }
        set(value) {
            field = value
            SPUtils.getInstance().put("ifAgreePrivacy", value, true)
        }
    var gid = ""
    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 eventUrl = "https://rp.abdozeid369.xyz"
    const val apiUrl = "https://api.abdozeid369.xyz"

    // 正式包名
    const val packageName = "com.zc.master.picture.cleaner"


    //    // 继承自 BaseSplashActivity 的类
//    val splashActivity = SplashActivity::class.java
//
    val noLoadingActivities = listOf(
        "full", // 过滤全屏广告
        "adActivity",
        SplashActivity::class.java.simpleName,
        SpeakCleaningActivity::class.java.simpleName,

        // 返回前台时不跳转启动页的 activity
    )

    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_sure)?.setOnClickListener {
            onClick?.invoke(true)
            dialog.dismiss()

        }
        dialog.show()
    }

    var appList: List<AppUtils.AppInfo>? = null
    var riskAppList: List<AppInfo>? = null
}