package com.gh.gamecenter.setting.view

import android.annotation.SuppressLint
import android.app.AlertDialog
import android.app.Application
import android.app.Dialog
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.text.TextUtils
import android.view.Gravity
import android.view.View
import android.widget.EditText
import android.widget.LinearLayout
import android.widget.TextView
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModelProvider
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.gamecenter.common.BuildConfig
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
import com.gh.gamecenter.common.constant.Config
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.entity.WechatConfigEntity
import com.gh.gamecenter.common.eventbus.EBReuse
import com.gh.gamecenter.common.retrofit.ApiResponse
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.provider.*
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.core.utils.GsonUtils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.login.entity.UserInfoEntity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.login.user.UserRepository
import com.gh.gamecenter.login.user.UserViewModel
import com.gh.gamecenter.login.utils.LoginUtils
import com.gh.gamecenter.setting.R
import com.gh.gamecenter.setting.databinding.FragmentSettingBinding
import com.gh.gamecenter.setting.view.security.SecurityActivity
import com.gh.gid.GidHelper
import com.lightgame.download.FileUtils
import com.lightgame.utils.Utils
import io.reactivex.Observable
import io.reactivex.ObservableEmitter
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import org.greenrobot.eventbus.EventBus
import java.io.File

class SettingsFragment : ToolbarFragment() {

    private lateinit var mBinding: FragmentSettingBinding
    private var checkSizeIndex = 0
    private var mIsUpdate = false
    private var loadingDialog: Dialog? = null
    private var mUsageStatus = false

    private val mViewModel: SettingViewModel by lazy { viewModelProvider() }

    override fun getLayoutId() = 0

    override fun getInflatedLayout() = FragmentSettingBinding.inflate(layoutInflater).apply { mBinding = this }.root

    @SuppressLint("SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initView()
        if (arguments != null) {
            mIsUpdate = requireArguments().getBoolean(EntranceConsts.KEY_VERSION_UPDATE, false)
            if (mIsUpdate) {
                mBinding.aboutItem.contentTv.text = getString(R.string.personal_update_hint)
                mBinding.aboutItem.contentTv.setTextColor(Color.WHITE)
                mBinding.aboutItem.contentTv.setBackgroundResource(R.drawable.message_unread_hint)
            } else {
                // Jenkins 打的包附带个打包时间在版本后面
                val packageUtils = ARouter.getInstance().build(RouteConsts.provider.packageUtils)
                    .navigation() as? IPackageUtilsProvider
                if (BuildConfig.BUILD_TIME == 0L) {
                    mBinding.aboutItem.contentTv.text = "V" + packageUtils?.getGhVersionName()
                } else {
                    mBinding.aboutItem.contentTv.text =
                        "V" + packageUtils?.getGhVersionName() + " " + BuildConfig.BUILD_TIME
                }
                if (PackageFlavorHelper.IS_TEST_FLAVOR == true) {
                    var channel = SPUtils.getString(Constants.SP_TEST_FLAVOR_CHANNEL)
                    if (channel == null || TextUtils.isEmpty(channel)) {
                        val appProvider =
                            ARouter.getInstance().build(RouteConsts.provider.app).navigation() as? IAppProvider
                        channel = appProvider?.getChannel() ?: ""
                    }
                    mBinding.aboutItem.contentTv.text = "($channel)"
                }
            }
        }

        val factory = UserViewModel.Factory(requireActivity().application)
        val mUserViewModel = ViewModelProvider(this, factory).get(
            UserViewModel::class.java
        )

        // 未打开下载按钮，显示修复下载按钮
        if (Config.isExistHideFunction()) {
            mBinding.settingCvFix.visibility = View.VISIBLE
            mBinding.settingCvFix.setOnClickListener {
                Config.fixHideFunction()
                toast("修复成功")
                EventBus.getDefault().post(EBReuse("Refresh"))
                val mainActivity =
                    ARouter.getInstance().build(RouteConsts.provider.mainActivity).navigation() as? IMainProvider
                mainActivity?.skipToMainActivity(requireContext(), 0)
            }
        }

        mViewModel.cacheSizeLiveData.observe(this) {
            mBinding.cacheItem.contentTv.text = it
        }

        mViewModel.getCacheSize()

        mBinding.personalRecommendItem.switchLottie.setSwitchAnimation(
            SPUtils.getBoolean(
                Constants.SP_PERSONAL_RECOMMEND,
                true
            )
        )

        checkSizeIndex = SPUtils.getInt(Constants.SP_FONT_SIZE, 1)
        if (checkSizeIndex == 0) {
            checkSizeIndex = 1
        }

        mUserViewModel.loginObsUserinfo.observe(this) { response: ApiResponse<UserInfoEntity?>? ->
            if (response != null && response.data != null) {
                val wechatBindHelper = ARouter.getInstance().build(RouteConsts.provider.wechatHelper)
                    .navigation() as? IWechatBindHelperProvider
                wechatBindHelper?.getWechatConfig {
                    initWechatBindStatus()
                }
            } else {
                initWechatBindStatus()
            }
        }

        initLoginStatus()

        initUsageStats()
    }

    private fun initWechatBindStatus() {
        if (UserManager.getInstance().isLoggedIn) {
            val json = SPUtils.getString(Constants.SP_WECHAT_CONFIG)
            val (_, _, notice) = GsonUtils.fromJson(
                json,
                WechatConfigEntity::class.java
            )
            mBinding.wechatRemindItem.textMoreTv.text = if (notice) "已开启" else "已关闭"
        } else {
            mBinding.wechatRemindItem.textMoreTv.text = ""
        }
    }

    private fun initLoginStatus() {
        val loginToken = UserManager.getInstance().loginTokenEntity
        if (loginToken != null) {
            mBinding.settingLogout.visibility = View.VISIBLE
        } else {
            mBinding.settingLogout.visibility = View.GONE
        }
    }

    private fun initUsageStats() {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
            return
        }
        val usageStatsHelper = ARouter.getInstance().build(RouteConsts.provider.usageStatsHelper)
            .navigation() as? IUsageStatsHelperProvider
        if (usageStatsHelper?.checkForPermission() == true && SPUtils.getBoolean(Constants.SP_USAGE_STATUS, true)) {
            mUsageStatus = true
            val energyTaskHelper =
                ARouter.getInstance().build(RouteConsts.provider.energyTask).navigation() as? IEnergyTaskProvider
            energyTaskHelper?.postEnergyTask("open_game_time")
        } else {
            mUsageStatus = false
        }
        mBinding.usageStatsItem.switchLottie.setSwitchAnimation(mUsageStatus)
    }

    private fun initView() {
        mBinding.securityItem.run {
            titleTv.text = getString(R.string.setting_security)
            textMoreTv.visibility = View.VISIBLE
            root.setOnClickListener {
                ifLogin("设置-账号与安全-请先登录") {
                    startActivityForResult(
                        SecurityActivity.getIntent(
                            requireContext(),
                            mEntrance,
                            false
                        ), INSERT_MOBILE_CODE
                    )
                }
            }
        }
        mBinding.systemDarkModeItem.run {
            val config = ARouter.getInstance().build(RouteConsts.provider.config).navigation() as? IConfigProvider
            root.goneIf(!(config?.getNightModeSetting() ?: false)) {
                titleTv.text = getString(R.string.setting_system_dark_mode)
                switchLottie.visibility = View.VISIBLE
                switchLottie.setSwitchAnimation(DarkModeUtils.isFollowSystemDarkModeFromSp())
                root.setOnClickListener {
                    val status = DarkModeUtils.isFollowSystemDarkModeFromSp()
                    NewFlatLogUtils.logHaloSelfNightModeOsSwitch(!status)
                    switchLottie.setSwitchAnimation(status)
                    switchLottie.playAnimation()
                    DarkModeUtils.updateFollowSystemDarkModeToSp(!status)
                    DarkModeUtils.updateAppDarkModeStatusToSp(mIsDarkModeOn)
                    DarkModeUtils.initDarkMode()
                }
            }
        }

        mBinding.videoItem.run {
            titleTv.text = getString(R.string.setting_video)
            textMoreTv.visibility = View.VISIBLE
            root.setOnClickListener {
                startActivity(VideoSettingActivity.getIntent(requireContext(), "设置"))
            }
        }
        mBinding.gameDownloadItem.run {
            titleTv.text = getString(R.string.setting_game_download)
            textMoreTv.visibility = View.VISIBLE
            root.setOnClickListener {
                startActivity(GameDownloadSettingActivity.getIntent(requireContext(), "设置"))
            }
        }
        mBinding.gameSubmissionItem.run {
            titleTv.text = getString(R.string.setting_game_submission)
            textMoreTv.visibility = View.VISIBLE
            root.setOnClickListener {
                ifLogin("设置-游戏投稿-请先登录") {
                    PermissionHelper.checkStoragePermissionBeforeAction(
                        requireContext(),
                        object : EmptyCallback {
                            override fun onCallback() {
                                ARouter.getInstance().build(RouteConsts.activity.gameSubmissionActivity)
                                    .withString(
                                        EntranceConsts.KEY_ENTRANCE,
                                        BaseActivity.mergeEntranceAndPath(mEntrance, "游戏上传")
                                    )
                                    .navigation()
                            }
                        })
                }
            }
        }
        mBinding.installMethodItem.run {
            titleTv.text = getString(R.string.setting_install_method)
            textMoreTv.visibility = View.VISIBLE
        }
        mBinding.usageStatsItem.run {
            titleTv.text = getString(R.string.setting_usage_stats)
            switchLottie.visibility = View.VISIBLE
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                root.setOnClickListener {
                    val usageStatsHelper = ARouter.getInstance().build(RouteConsts.provider.usageStatsHelper)
                        .navigation() as? IUsageStatsHelperProvider
                    if (usageStatsHelper?.checkForPermission() == true) {
                        DialogHelper.showDialog(
                            requireContext(), "提示",
                            "关闭后将无法统计游戏时长，确定要关闭吗？",
                            "确定关闭",
                            "暂不关闭",
                            {
                                usageStatsHelper.skipToUsageStats(
                                    requireContext(),
                                    USAGE_STATUS_REQUEST_CODE
                                )
                            }, {}, DialogHelper.Config(centerContent = true, centerTitle = true)
                        )
                    } else {
                        val dialogUtils = ARouter.getInstance().build(RouteConsts.provider.dialogUtils)
                            .navigation() as? IDialogUtilsProvider
                        dialogUtils?.showUsageStatsDialog(
                            requireContext(), {
                                usageStatsHelper?.skipToUsageStats(
                                    requireContext(),
                                    USAGE_STATUS_REQUEST_CODE
                                )
                            }, {}
                        )
                    }
                }
            }
        }
        mBinding.wechatRemindItem.run {
            titleTv.text = getString(R.string.setting_wechat_remind)
            textMoreTv.visibility = View.VISIBLE
            root.setOnClickListener {
                if (UserManager.getInstance().isLoggedIn) {
                    val json = SPUtils.getString(Constants.SP_WECHAT_CONFIG)
                    val entity = GsonUtils.fromJson(json, WechatConfigEntity::class.java)
                    if (entity != null) {
                        NewLogUtils.logWechatRemindConfigClick(entity.bind, entity.follow, entity.notice)
                    }
                    val webActivity =
                        ARouter.getInstance().build(RouteConsts.provider.webActivity).navigation() as? IWebProvider
                    requireContext().startActivity(webActivity?.getBindWechatIntent(requireContext()))
                } else {
                    ifLogin("我的光环_设置") {}
                }
            }
        }
        mBinding.notificationAuthorityItem.run {
            titleTv.text = getString(R.string.setting_notification_authority)
            tipsTv.text = getString(R.string.setting_notification_authority_hint)
            switchLottie.visibility = View.VISIBLE
            tipsTv.visibility = View.VISIBLE
            root.setOnClickListener {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    //这种方案适用于 API 26, 即8.0（含8.0）以上可以用
                    val notifyIntent = Intent()
                    notifyIntent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
                    val buildConfig = ARouter.getInstance().build(RouteConsts.provider.buildConfig)
                        .navigation() as? IBuildConfigProvider
                    notifyIntent.putExtra(Settings.EXTRA_APP_PACKAGE, buildConfig?.getApplicationId())
                    startActivity(notifyIntent)
                } else {
                    PermissionHelper.toPermissionSetting(requireActivity())
                }
            }
        }
        mBinding.personalRecommendItem.run {
            titleTv.text = getString(R.string.setting_personal_recommend)
            tipsTv.text = getString(R.string.setting_personal_recommend_hint)
            tipsTv.visibility = View.VISIBLE
            switchLottie.visibility = View.VISIBLE
            root.setOnClickListener {
                if (switchLottie.isAnimating) return@setOnClickListener
                val status = SPUtils.getBoolean(Constants.SP_PERSONAL_RECOMMEND, true)
                switchLottie.setSwitchAnimation(status)
                switchLottie.playAnimation()
                SPUtils.setBoolean(Constants.SP_PERSONAL_RECOMMEND, !status)
            }
        }
        mBinding.aboutItem.run {
            titleTv.text = getString(R.string.setting_about)
            contentTv.visibility = View.VISIBLE
            contentTv.setPadding(8F.dip2px(), 2F.dip2px(), 8F.dip2px(), 2F.dip2px())
            root.setOnClickListener {
                startActivity(AboutActivity.getIntent(requireContext(), mIsUpdate))
            }
            if (PackageFlavorHelper.IS_TEST_FLAVOR == true) {
                titleTv.text = getString(R.string.setting_about_channel)
                root.setOnLongClickListener({
                    showChangeChannelDialog()
                    return@setOnLongClickListener true
                })

            }

        }
        mBinding.cacheItem.run {
            titleTv.text = getString(R.string.setting_clear_cache)
            contentTv.visibility = View.VISIBLE
            root.setOnClickListener {
                DialogHelper.showCenterWarningDialog(requireContext(), "清除缓存", "确定要清除缓存吗？",
                    object : EmptyCallback {
                        override fun onCallback() {
                            val dialogUtils = ARouter.getInstance().build(RouteConsts.provider.dialogUtils)
                                .navigation() as? IDialogUtilsProvider
                            loadingDialog = dialogUtils?.showWaitDialog(requireContext(), "清除缓存中...")
                            val historyHelper = ARouter.getInstance().build(RouteConsts.provider.historyHelper)
                                .navigation() as? IHistoryHelperProvider
                            historyHelper?.emptyDatabase()
                            clearCache()
                        }
                    })
            }
            if (PackageFlavorHelper.IS_TEST_FLAVOR) {
                titleTv.text = getString(R.string.setting_clear_cache) + "(长按可清除gid)"
                root.setOnLongClickListener {
                    GidHelper.getInstance().clearSavedGid()
                    Utils.toast(context, "gid已清除")
                    return@setOnLongClickListener true
                }

            }
        }
        mBinding.networkDiagnosisItem.run {
            titleTv.text = "网络诊断"
            root.setOnClickListener {
                startActivity(Intent(requireContext(), NetworkDiagnosisActivity::class.java))
            }
        }
        mBinding.settingLogout.setOnClickListener {
            val dialogUtils =
                ARouter.getInstance().build(RouteConsts.provider.dialogUtils).navigation() as? IDialogUtilsProvider
            DialogHelper.showDialog(
                requireContext(),
                R.string.logout_dialog_title.toResString(),
                R.string.logout_dialog_content.toResString(),
                R.string.logout_dialog_confirm.toResString(),
                R.string.cancel.toResString(),
                {
                    loadingDialog = dialogUtils?.showWaitDialog(requireContext(), "退出登录中...")
                    LoginUtils.logout {
                        UserRepository.getInstance().logout()
                        if (loadingDialog != null) loadingDialog!!.dismiss()
                        if (activity != null) requireActivity().finish()
                    }
                },
                extraConfig = DialogHelper.Config(
                    centerTitle = true,
                    centerContent = true
                ),
                uiModificationCallback = {
                    it.confirmTv.setTextColor(R.color.theme_red.toColor(requireContext()))
                }
            )
        }
    }

    private fun showChangeChannelDialog() {

        var layout = LinearLayout(context).apply {
            layoutParams = LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT
            )
            gravity = Gravity.CENTER
            setPadding(0, DisplayUtils.dip2px(16f), 0, 0)
        }

        val editText = EditText(context)
        var channel = SPUtils.getString(Constants.SP_TEST_FLAVOR_CHANNEL)
        if (channel == null || TextUtils.isEmpty(channel)) {
            val appProvider = ARouter.getInstance().build(RouteConsts.provider.app).navigation() as? IAppProvider
            channel = appProvider?.getChannel() ?: ""
            SPUtils.setString(Constants.SP_TEST_FLAVOR_CHANNEL, channel)
        }
        editText.setText(channel, TextView.BufferType.EDITABLE)
        editText.layoutParams = LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT
        ).apply {
            leftMargin = DisplayUtils.dip2px(16f)
            rightMargin = DisplayUtils.dip2px(16f)

        }
        layout.addView(editText)
        val inputDialog: AlertDialog.Builder = AlertDialog.Builder(requireActivity())
        inputDialog.setTitle("请输入渠道：").setView(layout)
        inputDialog.setPositiveButton("确定") { _, _ ->
            if (!TextUtils.isEmpty(editText.text)) {
                SPUtils.setString(Constants.SP_TEST_FLAVOR_CHANNEL, editText.text.toString())
                val appProvider = ARouter.getInstance().build(RouteConsts.provider.app).navigation() as? IAppProvider
                appProvider?.setChannel(editText.text.toString())
            }
        }.show()
    }

    // 清除缓存
    private fun clearCache() {
        Observable.create { emitter: ObservableEmitter<Any?> ->
            val start = System.currentTimeMillis()
            FileUtils.deleteFolder(requireContext().cacheDir)
            FileUtils.deleteFolder(requireContext().externalCacheDir)
            val time = System.currentTimeMillis() - start
            if (time < 1000) {
                try {
                    Thread.sleep(1000 - time)
                } catch (e: InterruptedException) {
                    e.printStackTrace()
                }
            }

//                Fresco.getImagePipeline().clearCaches(); // 清空图片缓存
            emitter.onComplete()
        }.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Observer<Any?> {
                override fun onComplete() {
                    if (loadingDialog != null) {
                        loadingDialog!!.dismiss()
                    }
                    mViewModel.getCacheSize()
                    Utils.toast(context, "缓存清除成功")
                }

                override fun onError(e: Throwable) {}
                override fun onSubscribe(d: Disposable) {}
                override fun onNext(t: Any) {}
            })
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == USAGE_STATUS_REQUEST_CODE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            val usageStatsHelper = ARouter.getInstance().build(RouteConsts.provider.usageStatsHelper)
                .navigation() as? IUsageStatsHelperProvider
            if (usageStatsHelper?.checkForPermission() == true) {
                val energyTaskHelper =
                    ARouter.getInstance().build(RouteConsts.provider.energyTask).navigation() as? IEnergyTaskProvider
                energyTaskHelper?.postEnergyTask("open_game_time")
            }
            SPUtils.setBoolean(Constants.SP_USAGE_STATUS, usageStatsHelper?.checkForPermission() == true)
            initUsageStats()
        }

        // 当前登录方式为手机号登录，更换手机号后，回到该界面更新"退出账号"的手机号
        if (requestCode == INSERT_MOBILE_CODE) {
            initLoginStatus()
        }
    }

    override fun onPause() {
        super.onPause()
        saveCurrentSetting()
    }

    private fun saveCurrentSetting() = SPUtils.setInt(Constants.SP_FONT_SIZE, checkSizeIndex)

    override fun onResume() {
        super.onResume()
        setNavigationTitle(getString(R.string.title_settings))

        mBinding.notificationAuthorityItem.switchLottie.setSwitchAnimation(NotificationHelper.notificationIsEnable())

        val browserInstallHelper = ARouter.getInstance().build(RouteConsts.provider.browserInstallHelper)
            .navigation() as? IBrowserInstallHelperProvider
        if (browserInstallHelper?.isUseBrowserToInstallEnabled() == true) {
            if (browserInstallHelper.shouldUseBrowserToInstall()) {
                mBinding.installMethodItem.textMoreTv.text = "浏览器安装"
            } else {
                mBinding.installMethodItem.textMoreTv.text = "助手安装"
            }
            mBinding.installMethodContainer.visibility = View.VISIBLE
            mBinding.installMethodItem.root.setOnClickListener {
                val shellActivity =
                    ARouter.getInstance().build(RouteConsts.provider.shellActivity).navigation() as? IShellProvider
                val intent = shellActivity?.getSwitchInstallMethodIntent(requireContext(), null)
                requireContext().startActivity(intent)
                browserInstallHelper.logSwitchInstallSettingEvent()
            }
        }
    }

    override fun onStop() {
        saveCurrentSetting()
        super.onStop()
    }

    class SettingViewModel(application: Application) : AndroidViewModel(application) {
        val cacheSizeLiveData = MutableLiveData<String>()

        // 获取缓存大小
        fun getCacheSize() {
            runOnIoThread {
                val ecDir = getApplication<Application>().externalCacheDir
                var cacheLength: Long = getFolderSize(getApplication<Application>().cacheDir)
                if (ecDir != null) {
                    cacheLength += getFolderSize(ecDir)
                }
                cacheSizeLiveData.postValue(long2Size(cacheLength))
            }
        }

        private fun long2Size(length: Long): String {
            val m = length / 1024f / 1024f
            var str = m.toString()
            val index = str.lastIndexOf(".")
            if (index != -1 && str.length > index + 3) {
                str = str.substring(0, index + 3)
            }
            return str + "M"
        }

        private fun getFolderSize(folder: File): Long {
            var size: Long = 0
            //忽略视频缓存
            if (folder.name == "video-cache" || folder.name == "exo") return size
            size += folder.length()
            if (folder.isDirectory) {
                val files = folder.listFiles()
                if (files == null || files.isEmpty()) return size
                for (file in files) {
                    size += if (file.isDirectory) {
                        getFolderSize(file)
                    } else {
                        file.length()
                    }
                }
            }
            return size
        }

    }

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        mBinding.root.setBackgroundColor(R.color.background.toColor(requireContext()))
        mBinding.personalRecommendItem.switchLottie.setSwitchAnimation(
            SPUtils.getBoolean(
                Constants.SP_PERSONAL_RECOMMEND,
                true
            )
        )
        mBinding.usageStatsItem.switchLottie.setSwitchAnimation(mUsageStatus)
        mBinding.notificationAuthorityItem.switchLottie.setSwitchAnimation(NotificationHelper.notificationIsEnable())
    }

    companion object {
        const val INSERT_MOBILE_CODE = 411
        const val USAGE_STATUS_REQUEST_CODE = 233
    }
}