From 098f6aaa3d2033efb0a4bebf673dd63b30d45f24 Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Fri, 3 Feb 2023 05:37:05 +0800 Subject: [PATCH] Added I18nWarnTool in MainActivity --- .../miui/notify/ui/activity/MainActivity.kt | 2 + .../miui/notify/utils/tool/I18nWarnTool.kt | 55 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 app/src/main/java/com/fankes/miui/notify/utils/tool/I18nWarnTool.kt diff --git a/app/src/main/java/com/fankes/miui/notify/ui/activity/MainActivity.kt b/app/src/main/java/com/fankes/miui/notify/ui/activity/MainActivity.kt index af7194c..900eb70 100644 --- a/app/src/main/java/com/fankes/miui/notify/ui/activity/MainActivity.kt +++ b/app/src/main/java/com/fankes/miui/notify/ui/activity/MainActivity.kt @@ -37,6 +37,7 @@ import com.fankes.miui.notify.params.IconPackParams import com.fankes.miui.notify.ui.activity.base.BaseActivity import com.fankes.miui.notify.utils.factory.* import com.fankes.miui.notify.utils.tool.GithubReleaseTool +import com.fankes.miui.notify.utils.tool.I18nWarnTool import com.fankes.miui.notify.utils.tool.SystemUITool import com.fankes.miui.notify.utils.tool.YukiPromoteTool import com.highcapable.yukihookapi.YukiHookAPI @@ -154,6 +155,7 @@ class MainActivity : BaseActivity() { noCancelable() } } + I18nWarnTool.checkingOrShowing(context = this) binding.mainTextVersion.text = "模块版本:$moduleVersion $pendingFlag" binding.mainTextMiuiVersion.text = "系统版本:[$androidVersionCodeName] $miuiFullVersion" binding.warnSCountDisTip.isGone = miuiVersionCode > 12.5 diff --git a/app/src/main/java/com/fankes/miui/notify/utils/tool/I18nWarnTool.kt b/app/src/main/java/com/fankes/miui/notify/utils/tool/I18nWarnTool.kt new file mode 100644 index 0000000..b17f065 --- /dev/null +++ b/app/src/main/java/com/fankes/miui/notify/utils/tool/I18nWarnTool.kt @@ -0,0 +1,55 @@ +/* + * MIUINativeNotifyIcon - Fix the native notification bar icon function abandoned by the MIUI development team. + * Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com) + * https://github.com/fankes/MIUINativeNotifyIcon + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + *

+ * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * + * This file is Created by fankes on 2023/2/3. + */ +package com.fankes.miui.notify.utils.tool + +import android.content.Context +import com.fankes.miui.notify.utils.factory.showDialog +import com.highcapable.yukihookapi.hook.factory.modulePrefs +import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData +import java.util.* + +/** + * I18n 适配警告提示工具类 + */ +object I18nWarnTool { + + /** 推广已读存储键值 */ + private val LOCALE_WARN_READED = PrefsData("locale_warn_readed", false) + + /** + * 检查并显示 I18n 适配警告对话框 + * @param context 实例 + */ + fun checkingOrShowing(context: Context) { + fun saveReaded() = context.modulePrefs.put(LOCALE_WARN_READED, value = true) + if (Locale.getDefault().language.startsWith("zh").not() && context.modulePrefs.get(LOCALE_WARN_READED).not()) + context.showDialog { + title = "Notice of I18n Support" + msg = "This Xposed Module is only for Chinese and the Chinese region.\n\n" + + "Currently, there will be no internationalization adaptation.\n\n" + + "There may be plans for internationalization adaptation in the future, so stay tuned." + confirmButton(text = "Got It") { saveReaded() } + noCancelable() + } + } +} \ No newline at end of file