From 72d76a486c3e0a21c9cd7ce088d195a61e3365f9 Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Fri, 13 Oct 2023 18:49:15 +0800 Subject: [PATCH] refactor: migrate i18ns generation to FlexiLocale plugin --- .../sweet-dependency-config.yaml | 3 + module-app/build.gradle.kts | 1 + .../application/AppErrorsApplication.kt | 11 +- .../bean/AppErrorsInfoBean.kt | 16 +- .../apperrorstracking/hook/HookEntry.kt | 7 +- .../hook/entity/FrameworkHooker.kt | 10 +- .../apperrorstracking/locale/LocaleFactory.kt | 29 + .../apperrorstracking/locale/LocaleString.kt | 577 ------------------ .../ui/activity/debug/LoggerActivity.kt | 12 +- .../errors/AppErrorsDetailActivity.kt | 26 +- .../errors/AppErrorsDisplayActivity.kt | 8 +- .../activity/errors/AppErrorsMutedActivity.kt | 10 +- .../errors/AppErrorsRecordActivity.kt | 38 +- .../ui/activity/main/ConfigureActivity.kt | 32 +- .../ui/activity/main/MainActivity.kt | 32 +- .../utils/factory/DialogBuilderFactory.kt | 8 +- .../utils/factory/FunctionFactory.kt | 4 +- .../utils/tool/FrameworkTool.kt | 18 +- .../utils/tool/GithubReleaseTool.kt | 8 +- 19 files changed, 154 insertions(+), 696 deletions(-) create mode 100644 module-app/src/main/java/com/fankes/apperrorstracking/locale/LocaleFactory.kt delete mode 100644 module-app/src/main/java/com/fankes/apperrorstracking/locale/LocaleString.kt diff --git a/gradle/sweet-dependency/sweet-dependency-config.yaml b/gradle/sweet-dependency/sweet-dependency-config.yaml index ec58ea8..911bf02 100644 --- a/gradle/sweet-dependency/sweet-dependency-config.yaml +++ b/gradle/sweet-dependency/sweet-dependency-config.yaml @@ -26,6 +26,9 @@ plugins: org.jetbrains.kotlin.android: alias: kotlin-android version: 1.9.10 + com.highcapable.flexilocale: + alias: flexi-locale + version: 1.0.0 com.google.devtools.ksp: alias: kotlin-ksp version: 1.9.10-1.0.13 diff --git a/module-app/build.gradle.kts b/module-app/build.gradle.kts index 2c42572..f09350f 100644 --- a/module-app/build.gradle.kts +++ b/module-app/build.gradle.kts @@ -2,6 +2,7 @@ plugins { autowire(libs.plugins.android.application) autowire(libs.plugins.kotlin.android) autowire(libs.plugins.kotlin.ksp) + autowire(libs.plugins.flexi.locale) } android { diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/application/AppErrorsApplication.kt b/module-app/src/main/java/com/fankes/apperrorstracking/application/AppErrorsApplication.kt index 38daeb4..c9928bd 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/application/AppErrorsApplication.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/application/AppErrorsApplication.kt @@ -23,7 +23,8 @@ package com.fankes.apperrorstracking.application import androidx.appcompat.app.AppCompatDelegate import com.fankes.apperrorstracking.data.ConfigData -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.generated.locale.ModuleAppLocale +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.utils.tool.AppAnalyticsTool import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication @@ -31,13 +32,13 @@ class AppErrorsApplication : ModuleApplication() { override fun onCreate() { super.onCreate() + /** 绑定 I18n */ + locale = ModuleAppLocale.attach(this) /** 跟随系统夜间模式 */ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) - /** 绑定 I18n */ - LocaleString.bind(instance = this) /** 装载存储控制类 */ - ConfigData.init(instance = this) + ConfigData.init(this) /** 装载 App Center */ - AppAnalyticsTool.init(instance = this) + AppAnalyticsTool.init(this) } } \ No newline at end of file diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/bean/AppErrorsInfoBean.kt b/module-app/src/main/java/com/fankes/apperrorstracking/bean/AppErrorsInfoBean.kt index f56b861..cbc728f 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/bean/AppErrorsInfoBean.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/bean/AppErrorsInfoBean.kt @@ -24,7 +24,7 @@ package com.fankes.apperrorstracking.bean import android.app.ApplicationErrorReport import android.content.Context import android.os.Build -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.utils.factory.appCpuAbiOf import com.fankes.apperrorstracking.utils.factory.appVersionCodeOf import com.fankes.apperrorstracking.utils.factory.appVersionNameOf @@ -155,13 +155,13 @@ data class AppErrorsInfoBean( */ val crossTime get() = timestamp.difference( - now = LocaleString.momentAgo, - second = LocaleString.secondAgo, - minute = LocaleString.minuteAgo, - hour = LocaleString.hourAgo, - day = LocaleString.dayAgo, - month = LocaleString.monthAgo, - year = LocaleString.yearAgo + now = locale.momentAgo, + second = locale.secondAgo, + minute = locale.minuteAgo, + hour = locale.hourAgo, + day = locale.dayAgo, + month = locale.monthAgo, + year = locale.yearAgo ) /** diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/hook/HookEntry.kt b/module-app/src/main/java/com/fankes/apperrorstracking/hook/HookEntry.kt index a3bcf4d..69321ed 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/hook/HookEntry.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/hook/HookEntry.kt @@ -22,8 +22,9 @@ package com.fankes.apperrorstracking.hook import com.fankes.apperrorstracking.data.ConfigData +import com.fankes.apperrorstracking.generated.locale.ModuleAppLocale import com.fankes.apperrorstracking.hook.entity.FrameworkHooker -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed import com.highcapable.yukihookapi.hook.factory.configs import com.highcapable.yukihookapi.hook.factory.encase @@ -42,8 +43,8 @@ object HookEntry : IYukiHookXposedInit { override fun onHook() = encase { loadSystem { - LocaleString.bind(instance = this) - ConfigData.init(instance = this) + locale = ModuleAppLocale.attach { moduleAppResources } + ConfigData.init(this) loadHooker(FrameworkHooker) } } diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/hook/entity/FrameworkHooker.kt b/module-app/src/main/java/com/fankes/apperrorstracking/hook/entity/FrameworkHooker.kt index dfa798e..7880d8f 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/hook/entity/FrameworkHooker.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/hook/entity/FrameworkHooker.kt @@ -45,7 +45,7 @@ import com.fankes.apperrorstracking.data.AppErrorsConfigData import com.fankes.apperrorstracking.data.AppErrorsRecordData import com.fankes.apperrorstracking.data.ConfigData import com.fankes.apperrorstracking.data.enum.AppErrorsConfigType -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.ui.activity.errors.AppErrorsDisplayActivity import com.fankes.apperrorstracking.ui.activity.errors.AppErrorsRecordActivity import com.fankes.apperrorstracking.utils.factory.appNameOf @@ -288,18 +288,18 @@ object FrameworkHooker : YukiBaseHooker() { val appName = appInfo?.let { context.appNameOf(it.packageName).ifBlank { it.packageName } } ?: packageName /** 当前 APP 名称 (包含用户 ID) */ - val appNameWithUserId = if (userId != 0) "$appName (${LocaleString.userId(userId)})" else appName + val appNameWithUserId = if (userId != 0) "$appName (${locale.userId(userId)})" else appName /** 崩溃标题 */ - val errorTitle = if (isRepeatingCrash) LocaleString.aerrRepeatedTitle(appNameWithUserId) else LocaleString.aerrTitle(appNameWithUserId) + val errorTitle = if (isRepeatingCrash) locale.aerrRepeatedTitle(appNameWithUserId) else locale.aerrTitle(appNameWithUserId) /** 使用通知推送异常信息 */ fun showAppErrorsWithNotify() = context.pushNotify( channelId = "APPS_ERRORS", - channelName = LocaleString.appName, + channelName = locale.appName, title = errorTitle, - content = LocaleString.appErrorsTip, + content = locale.appErrorsTip, icon = IconCompat.createWithBitmap(moduleAppResources.drawableOf(R.drawable.ic_notify).toBitmap()), color = 0xFFFF6200.toInt(), intent = AppErrorsRecordActivity.intent() diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/locale/LocaleFactory.kt b/module-app/src/main/java/com/fankes/apperrorstracking/locale/LocaleFactory.kt new file mode 100644 index 0000000..af76ef9 --- /dev/null +++ b/module-app/src/main/java/com/fankes/apperrorstracking/locale/LocaleFactory.kt @@ -0,0 +1,29 @@ +/* + * AppErrorsTracking - Added more features to app's crash dialog, fixed custom rom deleted dialog, the best experience to Android developer. + * Copyright (C) 2017-2023 Fankes Studio(qzmmcn@163.com) + * https://github.com/KitsunePie/AppErrorsTracking + * + * 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/10/13. + */ +@file:Suppress("StaticFieldLeak") + +package com.fankes.apperrorstracking.locale + +import com.fankes.apperrorstracking.generated.locale.ModuleAppLocale + +/** I18ns 实例 */ +lateinit var locale: ModuleAppLocale \ No newline at end of file diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/locale/LocaleString.kt b/module-app/src/main/java/com/fankes/apperrorstracking/locale/LocaleString.kt deleted file mode 100644 index 1fea563..0000000 --- a/module-app/src/main/java/com/fankes/apperrorstracking/locale/LocaleString.kt +++ /dev/null @@ -1,577 +0,0 @@ -/* - * AppErrorsTracking - Added more features to app's crash dialog, fixed custom rom deleted dialog, the best experience to Android developer. - * Copyright (C) 2017-2023 Fankes Studio(qzmmcn@163.com) - * https://github.com/KitsunePie/AppErrorsTracking - * - * 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 2022/5/11. - */ -@file:Suppress("MemberVisibilityCanBePrivate", "StaticFieldLeak", "unused") - -package com.fankes.apperrorstracking.locale - -import android.content.Context -import android.content.res.Resources -import com.fankes.apperrorstracking.R -import com.highcapable.yukihookapi.hook.param.PackageParam - -/** - * I18n 字符串实例 - */ -object LocaleString { - - /** 当前的 [Context] */ - private var baseContext: Context? = null - - /** 当前的 [PackageParam] */ - private var basePackageParam: PackageParam? = null - - /** 当前的 [Resources] */ - private var baseResources: Resources? = null - - /** - * 当前的 [Resources] - * @return [Resources] - * @throws IllegalStateException 如果 [LocaleString] 没有被绑定 - */ - private val resources - get() = baseContext?.resources ?: basePackageParam?.moduleAppResources ?: baseResources - ?: error("LocaleString must bind an instance first") - - /** - * 绑定并初始化 - * @param instance 可以是 [Context]、[PackageParam]、[Resources] - */ - fun bind(instance: Any) { - when (instance) { - is Context -> baseContext = instance - is PackageParam -> basePackageParam = instance - is Resources -> baseResources = instance - else -> error("LocaleString bind an unknown instance") - } - } - - /** - * 根据资源 Id 获取字符串 - * @param objArrs 格式化实例 - * @return [String] - */ - private fun Int.bind(vararg objArrs: Any) = resources.getString(this, *objArrs) - - /** @string Automatic generated */ - val appName get() = appName() - - /** @string Automatic generated */ - fun appName(vararg objArrs: Any) = R.string.app_name.bind(*objArrs) - - /** @string Automatic generated */ - val copied get() = copied() - - /** @string Automatic generated */ - fun copied(vararg objArrs: Any) = R.string.copied.bind(*objArrs) - - /** @string Automatic generated */ - val copyFail get() = copyFail() - - /** @string Automatic generated */ - fun copyFail(vararg objArrs: Any) = R.string.copy_fail.bind(*objArrs) - - /** @string Automatic generated */ - val printToLogcatSuccess get() = printToLogcatSuccess() - - /** @string Automatic generated */ - fun printToLogcatSuccess(vararg objArrs: Any) = R.string.print_to_logcat_success.bind(*objArrs) - - /** @string Automatic generated */ - val outputStackSuccess get() = outputStackSuccess() - - /** @string Automatic generated */ - fun outputStackSuccess(vararg objArrs: Any) = R.string.output_stack_success.bind(*objArrs) - - /** @string Automatic generated */ - val outputStackFail get() = outputStackFail() - - /** @string Automatic generated */ - fun outputStackFail(vararg objArrs: Any) = R.string.output_stack_fail.bind(*objArrs) - - /** @string Automatic generated */ - val aerrTitle get() = aerrTitle() - - /** @string Automatic generated */ - fun aerrTitle(vararg objArrs: Any) = R.string.aerr_title.bind(*objArrs) - - /** @string Automatic generated */ - val aerrRepeatedTitle get() = aerrRepeatedTitle() - - /** @string Automatic generated */ - fun aerrRepeatedTitle(vararg objArrs: Any) = R.string.aerr_repeated_title.bind(*objArrs) - - /** @string Automatic generated */ - val appInfo get() = appInfo() - - /** @string Automatic generated */ - fun appInfo(vararg objArrs: Any) = R.string.app_info.bind(*objArrs) - - /** @string Automatic generated */ - val closeApp get() = closeApp() - - /** @string Automatic generated */ - fun closeApp(vararg objArrs: Any) = R.string.close_app.bind(*objArrs) - - /** @string Automatic generated */ - val reopenApp get() = reopenApp() - - /** @string Automatic generated */ - fun reopenApp(vararg objArrs: Any) = R.string.reopen_app.bind(*objArrs) - - /** @string Automatic generated */ - val errorDetail get() = errorDetail() - - /** @string Automatic generated */ - fun errorDetail(vararg objArrs: Any) = R.string.error_detail.bind(*objArrs) - - /** @string Automatic generated */ - val muteIfUnlock get() = muteIfUnlock() - - /** @string Automatic generated */ - fun muteIfUnlock(vararg objArrs: Any) = R.string.mute_if_unlock.bind(*objArrs) - - /** @string Automatic generated */ - val muteIfRestart get() = muteIfRestart() - - /** @string Automatic generated */ - fun muteIfRestart(vararg objArrs: Any) = R.string.mute_if_restart.bind(*objArrs) - - /** @string Automatic generated */ - val muteIfUnlockTip get() = muteIfUnlockTip() - - /** @string Automatic generated */ - fun muteIfUnlockTip(vararg objArrs: Any) = R.string.mute_if_unlock_tip.bind(*objArrs) - - /** @string Automatic generated */ - val muteIfRestartTip get() = muteIfRestartTip() - - /** @string Automatic generated */ - fun muteIfRestartTip(vararg objArrs: Any) = R.string.mute_if_restart_tip.bind(*objArrs) - - /** @string Automatic generated */ - val noListData get() = noListData() - - /** @string Automatic generated */ - fun noListData(vararg objArrs: Any) = R.string.no_list_data.bind(*objArrs) - - /** @string Automatic generated */ - val confirm get() = confirm() - - /** @string Automatic generated */ - fun confirm(vararg objArrs: Any) = R.string.confirm.bind(*objArrs) - - /** @string Automatic generated */ - val cancel get() = cancel() - - /** @string Automatic generated */ - fun cancel(vararg objArrs: Any) = R.string.cancel.bind(*objArrs) - - /** @string Automatic generated */ - val more get() = more() - - /** @string Automatic generated */ - fun more(vararg objArrs: Any) = R.string.more.bind(*objArrs) - - /** @string Automatic generated */ - val notice get() = notice() - - /** @string Automatic generated */ - fun notice(vararg objArrs: Any) = R.string.notice.bind(*objArrs) - - /** @string Automatic generated */ - val warning get() = warning() - - /** @string Automatic generated */ - fun warning(vararg objArrs: Any) = R.string.warning.bind(*objArrs) - - /** @string Automatic generated */ - val areYouSureClearErrors get() = areYouSureClearErrors() - - /** @string Automatic generated */ - fun areYouSureClearErrors(vararg objArrs: Any) = R.string.are_you_sure_clear_errors.bind(*objArrs) - - /** @string Automatic generated */ - val allErrorsClearSuccess get() = allErrorsClearSuccess() - - /** @string Automatic generated */ - fun allErrorsClearSuccess(vararg objArrs: Any) = R.string.all_errors_clear_success.bind(*objArrs) - - /** @string Automatic generated */ - val areYouSureExportAllErrors get() = areYouSureExportAllErrors() - - /** @string Automatic generated */ - fun areYouSureExportAllErrors(vararg objArrs: Any) = R.string.are_you_sure_export_all_errors.bind(*objArrs) - - /** @string Automatic generated */ - val exportAllErrorsSuccess get() = exportAllErrorsSuccess() - - /** @string Automatic generated */ - fun exportAllErrorsSuccess(vararg objArrs: Any) = R.string.export_all_errors_success.bind(*objArrs) - - /** @string Automatic generated */ - val exportAllErrorsFail get() = exportAllErrorsFail() - - /** @string Automatic generated */ - fun exportAllErrorsFail(vararg objArrs: Any) = R.string.export_all_errors_fail.bind(*objArrs) - - /** @string Automatic generated */ - val noCpuAbi get() = noCpuAbi() - - /** @string Automatic generated */ - fun noCpuAbi(vararg objArrs: Any) = R.string.no_cpu_abi.bind(*objArrs) - - /** @string Automatic generated */ - val areYouSureRemoveRecord get() = areYouSureRemoveRecord() - - /** @string Automatic generated */ - fun areYouSureRemoveRecord(vararg objArrs: Any) = R.string.are_you_sure_remove_record.bind(*objArrs) - - /** @string Automatic generated */ - val gotIt get() = gotIt() - - /** @string Automatic generated */ - fun gotIt(vararg objArrs: Any) = R.string.got_it.bind(*objArrs) - - /** @string Automatic generated */ - val moduleVersion get() = moduleVersion() - - /** @string Automatic generated */ - fun moduleVersion(vararg objArrs: Any) = R.string.module_version.bind(*objArrs) - - /** @string Automatic generated */ - val systemVersion get() = systemVersion() - - /** @string Automatic generated */ - fun systemVersion(vararg objArrs: Any) = R.string.system_version.bind(*objArrs) - - /** @string Automatic generated */ - val areYouSureRestartSystem get() = areYouSureRestartSystem() - - /** @string Automatic generated */ - fun areYouSureRestartSystem(vararg objArrs: Any) = R.string.are_your_sure_restart_system.bind(*objArrs) - - /** @string Automatic generated */ - val fastRestart get() = fastRestart() - - /** @string Automatic generated */ - fun fastRestart(vararg objArrs: Any) = R.string.fast_restart.bind(*objArrs) - - /** @string Automatic generated */ - val accessRootFail get() = accessRootFail() - - /** @string Automatic generated */ - fun accessRootFail(vararg objArrs: Any) = R.string.access_root_fail.bind(*objArrs) - - /** @string Automatic generated */ - val moduleNotActivated get() = moduleNotActivated() - - /** @string Automatic generated */ - fun moduleNotActivated(vararg objArrs: Any) = R.string.module_not_activated.bind(*objArrs) - - /** @string Automatic generated */ - val moduleIsActivated get() = moduleIsActivated() - - /** @string Automatic generated */ - fun moduleIsActivated(vararg objArrs: Any) = R.string.module_is_activated.bind(*objArrs) - - /** @string Automatic generated */ - val moduleNotFullyActivated get() = moduleNotFullyActivated() - - /** @string Automatic generated */ - fun moduleNotFullyActivated(vararg objArrs: Any) = R.string.module_not_fully_activated.bind(*objArrs) - - /** @string Automatic generated */ - val momentAgo get() = momentAgo() - - /** @string Automatic generated */ - fun momentAgo(vararg objArrs: Any) = R.string.moment_ago.bind(*objArrs) - - /** @string Automatic generated */ - val secondAgo get() = secondAgo() - - /** @string Automatic generated */ - fun secondAgo(vararg objArrs: Any) = R.string.second_ago.bind(*objArrs) - - /** @string Automatic generated */ - val minuteAgo get() = minuteAgo() - - /** @string Automatic generated */ - fun minuteAgo(vararg objArrs: Any) = R.string.minute_ago.bind(*objArrs) - - /** @string Automatic generated */ - val hourAgo get() = hourAgo() - - /** @string Automatic generated */ - fun hourAgo(vararg objArrs: Any) = R.string.hour_ago.bind(*objArrs) - - /** @string Automatic generated */ - val dayAgo get() = dayAgo() - - /** @string Automatic generated */ - fun dayAgo(vararg objArrs: Any) = R.string.day_ago.bind(*objArrs) - - /** @string Automatic generated */ - val monthAgo get() = monthAgo() - - /** @string Automatic generated */ - fun monthAgo(vararg objArrs: Any) = R.string.month_ago.bind(*objArrs) - - /** @string Automatic generated */ - val yearAgo get() = yearAgo() - - /** @string Automatic generated */ - fun yearAgo(vararg objArrs: Any) = R.string.year_ago.bind(*objArrs) - - /** @string Automatic generated */ - val crashProcess get() = crashProcess() - - /** @string Automatic generated */ - fun crashProcess(vararg objArrs: Any) = R.string.crash_process.bind(*objArrs) - - /** @string Automatic generated */ - val shareErrorStack get() = shareErrorStack() - - /** @string Automatic generated */ - fun shareErrorStack(vararg objArrs: Any) = R.string.share_error_stack.bind(*objArrs) - - /** @string Automatic generated */ - val areYouSureUnmuteAll get() = areYouSureUnmuteAll() - - /** @string Automatic generated */ - fun areYouSureUnmuteAll(vararg objArrs: Any) = R.string.are_you_sure_unmute_all.bind(*objArrs) - - /** @string Automatic generated */ - val noListResult get() = noListResult() - - /** @string Automatic generated */ - fun noListResult(vararg objArrs: Any) = R.string.no_list_result.bind(*objArrs) - - /** @string Automatic generated */ - val filterByCondition get() = filterByCondition() - - /** @string Automatic generated */ - fun filterByCondition(vararg objArrs: Any) = R.string.filter_by_condition.bind(*objArrs) - - /** @string Automatic generated */ - val clearFilters get() = clearFilters() - - /** @string Automatic generated */ - fun clearFilters(vararg objArrs: Any) = R.string.clear_filters.bind(*objArrs) - - /** @string Automatic generated */ - val resultCount get() = resultCount() - - /** @string Automatic generated */ - fun resultCount(vararg objArrs: Any) = R.string.result_count.bind(*objArrs) - - /** @string Automatic generated */ - val loading get() = loading() - - /** @string Automatic generated */ - fun loading(vararg objArrs: Any) = R.string.loading.bind(*objArrs) - - /** @string Automatic generated */ - val showErrorsDialog get() = showErrorsDialog() - - /** @string Automatic generated */ - fun showErrorsDialog(vararg objArrs: Any) = R.string.show_errors_dialog.bind(*objArrs) - - /** @string Automatic generated */ - val showErrorsToast get() = showErrorsToast() - - /** @string Automatic generated */ - fun showErrorsToast(vararg objArrs: Any) = R.string.show_errors_toast.bind(*objArrs) - - /** @string Automatic generated */ - val showNothing get() = showNothing() - - /** @string Automatic generated */ - fun showNothing(vararg objArrs: Any) = R.string.show_nothing.bind(*objArrs) - - /** @string Automatic generated */ - val appErrorsStatistics get() = appErrorsStatistics() - - /** @string Automatic generated */ - fun appErrorsStatistics(vararg objArrs: Any) = R.string.app_errors_statistics.bind(*objArrs) - - /** @string Automatic generated */ - val totalErrorsUnit get() = totalErrorsUnit() - - /** @string Automatic generated */ - fun totalErrorsUnit(vararg objArrs: Any) = R.string.total_errors_unit.bind(*objArrs) - - /** @string Automatic generated */ - val totalAppsUnit get() = totalAppsUnit() - - /** @string Automatic generated */ - fun totalAppsUnit(vararg objArrs: Any) = R.string.total_apps_unit.bind(*objArrs) - - /** @string Automatic generated */ - val generatingStatistics get() = generatingStatistics() - - /** @string Automatic generated */ - fun generatingStatistics(vararg objArrs: Any) = R.string.generating_statistics.bind(*objArrs) - - /** @string Automatic generated */ - val moduleNotFullyActivatedTip get() = moduleNotFullyActivatedTip() - - /** @string Automatic generated */ - fun moduleNotFullyActivatedTip(vararg objArrs: Any) = R.string.module_not_fully_activated_tip.bind(*objArrs) - - /** @string Automatic generated */ - val showErrorsNotify get() = showErrorsNotify() - - /** @string Automatic generated */ - fun showErrorsNotify(vararg objArrs: Any) = R.string.show_errors_notify.bind(*objArrs) - - /** @string Automatic generated */ - val appErrorsTip get() = appErrorsTip() - - /** @string Automatic generated */ - fun appErrorsTip(vararg objArrs: Any) = R.string.app_errors_tip.bind(*objArrs) - - /** @string Automatic generated */ - val batchOperations get() = batchOperations() - - /** @string Automatic generated */ - fun batchOperations(vararg objArrs: Any) = R.string.batch_operations.bind(*objArrs) - - /** @string Automatic generated */ - val areYouSureApplySiteApps get() = areYouSureApplySiteApps() - - /** @string Automatic generated */ - fun areYouSureApplySiteApps(vararg objArrs: Any) = R.string.are_you_sure_apply_site_apps.bind(*objArrs) - - /** @string Automatic generated */ - val developerNoticeTip get() = developerNoticeTip() - - /** @string Automatic generated */ - fun developerNoticeTip(vararg objArrs: Any) = R.string.developer_notice_tip.bind(*objArrs) - - /** @string Automatic generated */ - val developerNotice get() = developerNotice() - - /** @string Automatic generated */ - fun developerNotice(vararg objArrs: Any) = R.string.developer_notice.bind(*objArrs) - - /** @string Automatic generated */ - val fastRestartProblem get() = fastRestartProblem() - - /** @string Automatic generated */ - fun fastRestartProblem(vararg objArrs: Any) = R.string.fast_restart_problem.bind(*objArrs) - - /** @string Automatic generated */ - val userId get() = userId() - - /** @string Automatic generated */ - fun userId(vararg objArrs: Any) = R.string.user_id.bind(*objArrs) - - /** @string Automatic generated */ - val unableGetAppErrorsRecordTip get() = unableGetAppErrorsRecordTip() - - /** @string Automatic generated */ - fun unableGetAppErrorsRecordTip(vararg objArrs: Any) = R.string.unable_get_app_errors_record_tip.bind(*objArrs) - - /** @string Automatic generated */ - val exportAllLogsSuccess get() = exportAllLogsSuccess() - - /** @string Automatic generated */ - fun exportAllLogsSuccess(vararg objArrs: Any) = R.string.export_all_logs_success.bind(*objArrs) - - /** @string Automatic generated */ - val exportAllLogsFail get() = exportAllLogsFail() - - /** @string Automatic generated */ - fun exportAllLogsFail(vararg objArrs: Any) = R.string.export_all_logs_fail.bind(*objArrs) - - /** @string Automatic generated */ - val goItNow get() = goItNow() - - /** @string Automatic generated */ - fun goItNow(vararg objArrs: Any) = R.string.go_it_now.bind(*objArrs) - - /** @string Automatic generated */ - val accessRootFailTip get() = accessRootFailTip() - - /** @string Automatic generated */ - fun accessRootFailTip(vararg objArrs: Any) = R.string.access_root_fail_tip.bind(*objArrs) - - /** @string Automatic generated */ - val globalConfig get() = globalConfig() - - /** @string Automatic generated */ - fun globalConfig(vararg objArrs: Any) = R.string.global_config.bind(*objArrs) - - /** @string Automatic generated */ - val followGlobalConfig get() = followGlobalConfig() - - /** @string Automatic generated */ - fun followGlobalConfig(vararg objArrs: Any) = R.string.follow_global_config.bind(*objArrs) - - /** @string Automatic generated */ - val batchOperationsNumber get() = batchOperationsNumber() - - /** @string Automatic generated */ - fun batchOperationsNumber(vararg objArrs: Any) = R.string.batch_operations_number.bind(*objArrs) - - /** @string Automatic generated */ - val clickToUpdate get() = clickToUpdate() - - /** @string Automatic generated */ - fun clickToUpdate(vararg objArrs: Any) = R.string.click_to_update.bind(*objArrs) - - /** @string Automatic generated */ - val latestVersion get() = latestVersion() - - /** @string Automatic generated */ - fun latestVersion(vararg objArrs: Any) = R.string.latest_version.bind(*objArrs) - - /** @string Automatic generated */ - val latestVersionTip get() = latestVersionTip() - - /** @string Automatic generated */ - fun latestVersionTip(vararg objArrs: Any) = R.string.latest_version_tip.bind(*objArrs) - - /** @string Automatic generated */ - val updateNow get() = updateNow() - - /** @string Automatic generated */ - fun updateNow(vararg objArrs: Any) = R.string.update_now.bind(*objArrs) - - /** @string Automatic generated */ - val recordCount get() = recordCount() - - /** @string Automatic generated */ - fun recordCount(vararg objArrs: Any) = R.string.record_count.bind(*objArrs) - - /** @string Automatic generated */ - val ciNoticeDialogTitle get() = ciNoticeDialogTitle() - - /** @string Automatic generated */ - fun ciNoticeDialogTitle(vararg objArrs: Any) = R.string.ci_notice_dialog_title.bind(*objArrs) - - /** @string Automatic generated */ - val ciNoticeDialogContent get() = ciNoticeDialogContent() - - /** @string Automatic generated */ - fun ciNoticeDialogContent(vararg objArrs: Any) = R.string.ci_notice_dialog_content.bind(*objArrs) -} \ No newline at end of file diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/debug/LoggerActivity.kt b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/debug/LoggerActivity.kt index 5ac4395..47d9680 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/debug/LoggerActivity.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/debug/LoggerActivity.kt @@ -35,7 +35,7 @@ import com.fankes.apperrorstracking.const.PackageName import com.fankes.apperrorstracking.databinding.ActivitiyLoggerBinding import com.fankes.apperrorstracking.databinding.AdapterLoggerBinding import com.fankes.apperrorstracking.databinding.DiaLoggerFilterBinding -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.ui.activity.base.BaseActivity import com.fankes.apperrorstracking.utils.factory.bindAdapter import com.fankes.apperrorstracking.utils.factory.copyToClipboard @@ -72,7 +72,7 @@ class LoggerActivity : BaseActivity() { binding.refreshIcon.setOnClickListener { refreshData() } binding.filterIcon.setOnClickListener { showDialog { - title = LocaleString.filterByCondition + title = locale.filterByCondition binding.configCheck0.isChecked = filters.any { it == "D" } binding.configCheck1.isChecked = filters.any { it == "I" } binding.configCheck2.isChecked = filters.any { it == "W" } @@ -136,7 +136,7 @@ class LoggerActivity : BaseActivity() { binding.exportAllIcon.isVisible = listData.isNotEmpty() binding.listView.isVisible = listData.isNotEmpty() binding.listNoDataView.isVisible = listData.isEmpty() - binding.listNoDataView.text = if (filters.size < 4) LocaleString.noListResult else LocaleString.noListData + binding.listNoDataView.text = if (filters.size < 4) locale.noListResult else locale.noListData } } @@ -177,9 +177,9 @@ class LoggerActivity : BaseActivity() { if (requestCode == WRITE_REQUEST_CODE && resultCode == Activity.RESULT_OK) runCatching { data?.data?.let { contentResolver?.openOutputStream(it)?.apply { write(YLog.contents(listData).toByteArray()) }?.close() - toast(LocaleString.exportAllLogsSuccess) - } ?: toast(LocaleString.exportAllLogsFail) - }.onFailure { toast(LocaleString.exportAllLogsFail) } + toast(locale.exportAllLogsSuccess) + } ?: toast(locale.exportAllLogsFail) + }.onFailure { toast(locale.exportAllLogsFail) } } override fun onResume() { diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsDetailActivity.kt b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsDetailActivity.kt index 82e732c..7dcddd8 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsDetailActivity.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsDetailActivity.kt @@ -34,7 +34,7 @@ import com.fankes.apperrorstracking.bean.AppErrorsInfoBean import com.fankes.apperrorstracking.data.ConfigData import com.fankes.apperrorstracking.data.factory.bind import com.fankes.apperrorstracking.databinding.ActivityAppErrorsDetailBinding -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.ui.activity.base.BaseActivity import com.fankes.apperrorstracking.utils.factory.appIconOf import com.fankes.apperrorstracking.utils.factory.appNameOf @@ -101,13 +101,13 @@ class AppErrorsDetailActivity : BaseActivity() { if (appErrorsInfo.isEmpty) { binding.appPanelScrollView.isVisible = false showDialog { - title = LocaleString.notice - msg = LocaleString.unableGetAppErrorsRecordTip - confirmButton(LocaleString.gotIt) { + title = locale.notice + msg = locale.unableGetAppErrorsRecordTip + confirmButton(locale.gotIt) { cancel() finish() } - cancelButton(LocaleString.goItNow) { + cancelButton(locale.goItNow) { cancel() finish() navigate() @@ -119,7 +119,7 @@ class AppErrorsDetailActivity : BaseActivity() { binding.appInfoItem.setOnClickListener { openSelfSetting(appErrorsInfo.packageName) } binding.printIcon.setOnClickListener { loggerE(msg = appErrorsInfo.stackTrace) - toast(LocaleString.printToLogcatSuccess) + toast(locale.printToLogcatSuccess) } binding.copyIcon.setOnClickListener { copyToClipboard(appErrorsInfo.stackOutputShareContent) } binding.exportIcon.setOnClickListener { @@ -136,14 +136,14 @@ class AppErrorsDetailActivity : BaseActivity() { startActivity(Intent.createChooser(Intent(Intent.ACTION_SEND).apply { type = "text/plain" putExtra(Intent.EXTRA_TEXT, appErrorsInfo.stackOutputShareContent) - }, LocaleString.shareErrorStack)) + }, locale.shareErrorStack)) } binding.appIcon.setImageDrawable(appIconOf(appErrorsInfo.packageName)) binding.appNameText.text = appNameOf(appErrorsInfo.packageName).ifBlank { appErrorsInfo.packageName } binding.appVersionText.text = appErrorsInfo.versionBrand binding.appUserIdText.isVisible = appErrorsInfo.userId > 0 - binding.appUserIdText.text = LocaleString.userId(appErrorsInfo.userId) - binding.appCpuAbiText.text = appErrorsInfo.cpuAbi.ifBlank { LocaleString.noCpuAbi } + binding.appUserIdText.text = locale.userId(appErrorsInfo.userId) + binding.appCpuAbiText.text = appErrorsInfo.cpuAbi.ifBlank { locale.noCpuAbi } binding.jvmErrorPanel.isGone = appErrorsInfo.isNativeCrash binding.errorTypeIcon.setImageResource(if (appErrorsInfo.isNativeCrash) R.drawable.ic_cpp else R.drawable.ic_java) binding.errorInfoText.text = appErrorsInfo.exceptionMessage @@ -158,7 +158,7 @@ class AppErrorsDetailActivity : BaseActivity() { binding.appPanelScrollView.setOnScrollChangeListener { _, _, y, _, _ -> binding.detailTitleText.text = if (y >= 30.dp(context = this@AppErrorsDetailActivity)) appNameOf(appErrorsInfo.packageName).ifBlank { appErrorsInfo.packageName } - else LocaleString.appName + else locale.appName } return true } @@ -176,9 +176,9 @@ class AppErrorsDetailActivity : BaseActivity() { if (requestCode == WRITE_REQUEST_CODE && resultCode == Activity.RESULT_OK) runCatching { data?.data?.let { contentResolver?.openOutputStream(it)?.apply { write(stackTrace.toByteArray()) }?.close() - toast(LocaleString.outputStackSuccess) - } ?: toast(LocaleString.outputStackFail) - }.onFailure { toast(LocaleString.outputStackFail) } + toast(locale.outputStackSuccess) + } ?: toast(locale.outputStackFail) + }.onFailure { toast(locale.outputStackFail) } } override fun onBackPressed() { diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsDisplayActivity.kt b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsDisplayActivity.kt index b25b615..336abc4 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsDisplayActivity.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsDisplayActivity.kt @@ -29,7 +29,7 @@ import com.fankes.apperrorstracking.bean.AppErrorsDisplayBean import com.fankes.apperrorstracking.data.ConfigData import com.fankes.apperrorstracking.databinding.ActivityAppErrorsDisplayBinding import com.fankes.apperrorstracking.databinding.DiaAppErrorsDisplayBinding -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.ui.activity.base.BaseActivity import com.fankes.apperrorstracking.utils.factory.colorOf import com.fankes.apperrorstracking.utils.factory.getSerializableExtraCompat @@ -78,7 +78,7 @@ class AppErrorsDisplayActivity : BaseActivity() binding.appInfoItem.isVisible = appErrorsDisplay.isShowAppInfoButton binding.closeAppItem.isVisible = appErrorsDisplay.isShowReopenButton.not() && appErrorsDisplay.isShowCloseAppButton binding.reopenAppItem.isVisible = appErrorsDisplay.isShowReopenButton - binding.processNameText.text = LocaleString.crashProcess(appErrorsDisplay.processName) + binding.processNameText.text = locale.crashProcess(appErrorsDisplay.processName) binding.appInfoItem.setOnClickListener { cancel() openSelfSetting(appErrorsDisplay.packageName) @@ -96,13 +96,13 @@ class AppErrorsDisplayActivity : BaseActivity() } binding.mutedIfUnlockItem.setOnClickListener { FrameworkTool.mutedErrorsIfUnlock(context, appErrorsDisplay.packageName) { - toast(LocaleString.muteIfUnlockTip(appErrorsDisplay.appName)) + toast(locale.muteIfUnlockTip(appErrorsDisplay.appName)) cancel() } } binding.mutedIfRestartItem.setOnClickListener { FrameworkTool.mutedErrorsIfRestart(context, appErrorsDisplay.packageName) { - toast(LocaleString.muteIfRestartTip(appErrorsDisplay.appName)) + toast(locale.muteIfRestartTip(appErrorsDisplay.appName)) cancel() } } diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsMutedActivity.kt b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsMutedActivity.kt index 4ec1ea1..137ddb0 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsMutedActivity.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsMutedActivity.kt @@ -25,7 +25,7 @@ import androidx.core.view.isVisible import com.fankes.apperrorstracking.bean.MutedErrorsAppBean import com.fankes.apperrorstracking.databinding.ActivityAppErrorsMutedBinding import com.fankes.apperrorstracking.databinding.AdapterAppErrorsMutedBinding -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.ui.activity.base.BaseActivity import com.fankes.apperrorstracking.utils.factory.appIconOf import com.fankes.apperrorstracking.utils.factory.appNameOf @@ -45,8 +45,8 @@ class AppErrorsMutedActivity : BaseActivity() { binding.titleBackIcon.setOnClickListener { onBackPressed() } binding.unmuteAllIcon.setOnClickListener { showDialog { - title = LocaleString.notice - msg = LocaleString.areYouSureUnmuteAll + title = locale.notice + msg = locale.areYouSureUnmuteAll confirmButton { FrameworkTool.unmuteAllErrorsApps(context) { refreshData() } } cancelButton() } @@ -59,8 +59,8 @@ class AppErrorsMutedActivity : BaseActivity() { binding.appIcon.setImageDrawable(appIconOf(bean.packageName)) binding.appNameText.text = appNameOf(bean.packageName).ifBlank { bean.packageName } binding.muteTypeText.text = when (bean.type) { - MutedErrorsAppBean.MuteType.UNTIL_UNLOCKS -> LocaleString.muteIfUnlock - MutedErrorsAppBean.MuteType.UNTIL_REBOOTS -> LocaleString.muteIfRestart + MutedErrorsAppBean.MuteType.UNTIL_UNLOCKS -> locale.muteIfUnlock + MutedErrorsAppBean.MuteType.UNTIL_REBOOTS -> locale.muteIfRestart } binding.unmuteButton.setOnClickListener { FrameworkTool.unmuteErrorsApp(context, bean) { refreshData() } } } diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsRecordActivity.kt b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsRecordActivity.kt index 359e61c..174d503 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsRecordActivity.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/errors/AppErrorsRecordActivity.kt @@ -38,7 +38,7 @@ import com.fankes.apperrorstracking.bean.enum.AppFiltersType import com.fankes.apperrorstracking.databinding.ActivityAppErrorsRecordBinding import com.fankes.apperrorstracking.databinding.AdapterAppErrorsRecordBinding import com.fankes.apperrorstracking.databinding.DiaAppErrorsStatisticsBinding -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.ui.activity.base.BaseActivity import com.fankes.apperrorstracking.utils.factory.appIconOf import com.fankes.apperrorstracking.utils.factory.appNameOf @@ -82,8 +82,8 @@ class AppErrorsRecordActivity : BaseActivity() { binding.titleBackIcon.setOnClickListener { onBackPressed() } binding.appErrorSisIcon.setOnClickListener { showDialog { - title = LocaleString.notice - progressContent = LocaleString.generatingStatistics + title = locale.notice + progressContent = locale.generatingStatistics noCancelable() FrameworkTool.fetchAppListData(context, AppFiltersBean(type = AppFiltersType.ALL)) { newThread { @@ -100,14 +100,14 @@ class AppErrorsRecordActivity : BaseActivity() { runOnUiThread { cancel() showDialog { - title = LocaleString.appErrorsStatistics - binding.totalErrorsUnitText.text = LocaleString.totalErrorsUnit(listData.size) - binding.totalAppsUnitText.text = LocaleString.totalAppsUnit(it.size) + title = locale.appErrorsStatistics + binding.totalErrorsUnitText.text = locale.totalErrorsUnit(listData.size) + binding.totalAppsUnitText.text = locale.totalAppsUnit(it.size) binding.mostErrorsAppIcon.setImageDrawable(appIconOf(mostAppPackageName)) binding.mostErrorsAppText.text = appNameOf(mostAppPackageName).ifBlank { mostAppPackageName } binding.mostErrorsTypeText.text = mostErrorsType binding.totalPptOfErrorsText.text = "$pptCount%" - confirmButton(LocaleString.gotIt) + confirmButton(locale.gotIt) } } } @@ -116,12 +116,12 @@ class AppErrorsRecordActivity : BaseActivity() { } binding.clearAllIcon.setOnClickListener { showDialog { - title = LocaleString.notice - msg = LocaleString.areYouSureClearErrors + title = locale.notice + msg = locale.areYouSureClearErrors confirmButton { FrameworkTool.clearAppErrorsInfoData(context) { refreshData() - toast(LocaleString.allErrorsClearSuccess) + toast(locale.allErrorsClearSuccess) } } cancelButton() @@ -129,8 +129,8 @@ class AppErrorsRecordActivity : BaseActivity() { } binding.exportAllIcon.setOnClickListener { showDialog { - title = LocaleString.notice - msg = LocaleString.areYouSureExportAllErrors + title = locale.notice + msg = locale.areYouSureExportAllErrors confirmButton { exportAll() } cancelButton() } @@ -144,7 +144,7 @@ class AppErrorsRecordActivity : BaseActivity() { binding.appIcon.setImageDrawable(appIconOf(bean.packageName)) binding.appNameText.text = appNameOf(bean.packageName).ifBlank { bean.packageName } binding.appUserIdText.isVisible = bean.userId > 0 - binding.appUserIdText.text = LocaleString.userId(bean.userId) + binding.appUserIdText.text = locale.userId(bean.userId) binding.errorsTimeText.text = bean.crossTime binding.errorTypeIcon.setImageResource(if (bean.isNativeCrash) R.drawable.ic_cpp else R.drawable.ic_java) binding.errorTypeText.text = if (bean.isNativeCrash) "Native crash" else bean.exceptionClassName.simpleThwName() @@ -160,7 +160,7 @@ class AppErrorsRecordActivity : BaseActivity() { /** 更新列表数据 */ private fun refreshData() { FrameworkTool.fetchAppErrorsInfoData(context = this) { - binding.titleCountText.text = LocaleString.recordCount(it.size) + binding.titleCountText.text = locale.recordCount(it.size) binding.listProgressView.isVisible = false binding.appErrorSisIcon.isVisible = it.size >= 5 binding.clearAllIcon.isVisible = it.isNotEmpty() @@ -219,8 +219,8 @@ class AppErrorsRecordActivity : BaseActivity() { R.id.aerrors_app_info -> openSelfSetting(listData[it.position].packageName) R.id.aerrors_remove_record -> showDialog { - title = LocaleString.notice - msg = LocaleString.areYouSureRemoveRecord + title = locale.notice + msg = locale.areYouSureRemoveRecord confirmButton { FrameworkTool.removeAppErrorsInfoData(context, listData[it.position]) { refreshData() } } cancelButton() } @@ -235,9 +235,9 @@ class AppErrorsRecordActivity : BaseActivity() { data?.data?.let { contentResolver?.openOutputStream(it)?.apply { write(FileInputStream(outPutFilePath).readBytes()) }?.close() clearAllExportTemp() - toast(LocaleString.exportAllErrorsSuccess) - } ?: toast(LocaleString.exportAllErrorsFail) - }.onFailure { toast(LocaleString.exportAllErrorsFail) } + toast(locale.exportAllErrorsSuccess) + } ?: toast(locale.exportAllErrorsFail) + }.onFailure { toast(locale.exportAllErrorsFail) } } override fun onResume() { diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/main/ConfigureActivity.kt b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/main/ConfigureActivity.kt index 8198c2b..fd96f9c 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/main/ConfigureActivity.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/main/ConfigureActivity.kt @@ -31,7 +31,7 @@ import com.fankes.apperrorstracking.databinding.ActivityConfigBinding import com.fankes.apperrorstracking.databinding.AdapterAppInfoBinding import com.fankes.apperrorstracking.databinding.DiaAppConfigBinding import com.fankes.apperrorstracking.databinding.DiaAppsFilterBinding -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.ui.activity.base.BaseActivity import com.fankes.apperrorstracking.utils.factory.appIconOf import com.fankes.apperrorstracking.utils.factory.bindAdapter @@ -53,16 +53,16 @@ class ConfigureActivity : BaseActivity() { override fun onCreate() { binding.titleBackIcon.setOnClickListener { finish() } binding.globalIcon.setOnClickListener { - showAppConfigDialog(LocaleString.globalConfig, isShowGlobalConfig = false) { type -> + showAppConfigDialog(locale.globalConfig, isShowGlobalConfig = false) { type -> AppErrorsConfigData.putAppShowingType(type) onChanged?.invoke() } } binding.batchIcon.setOnClickListener { - showAppConfigDialog(LocaleString.batchOperationsNumber(listData.size), isNotSetDefaultValue = true) { type -> + showAppConfigDialog(locale.batchOperationsNumber(listData.size), isNotSetDefaultValue = true) { type -> showDialog { - title = LocaleString.notice - msg = LocaleString.areYouSureApplySiteApps(listData.size) + title = locale.notice + msg = locale.areYouSureApplySiteApps(listData.size) confirmButton { listData.takeIf { it.isNotEmpty() }?.forEach { AppErrorsConfigData.putAppShowingType(type, it.packageName) } onChanged?.invoke() @@ -73,7 +73,7 @@ class ConfigureActivity : BaseActivity() { } binding.filterIcon.setOnClickListener { showDialog { - title = LocaleString.filterByCondition + title = locale.filterByCondition binding.filtersRadioUser.isChecked = appFilters.type == AppFiltersType.USER binding.filtersRadioSystem.isChecked = appFilters.type == AppFiltersType.SYSTEM binding.filtersRadioAll.isChecked = appFilters.type == AppFiltersType.ALL @@ -101,7 +101,7 @@ class ConfigureActivity : BaseActivity() { } cancelButton() if (appFilters.name.isNotBlank()) - neutralButton(LocaleString.clearFilters) { + neutralButton(locale.clearFilters) { setAppFiltersType() appFilters.name = "" refreshData() @@ -116,11 +116,11 @@ class ConfigureActivity : BaseActivity() { binding.appIcon.setImageDrawable(bean.icon) binding.appNameText.text = bean.name binding.configTypeText.text = when { - AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.GLOBAL, bean.packageName) -> LocaleString.followGlobalConfig - AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.DIALOG, bean.packageName) -> LocaleString.showErrorsDialog - AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.NOTIFY, bean.packageName) -> LocaleString.showErrorsNotify - AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.TOAST, bean.packageName) -> LocaleString.showErrorsToast - AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.NOTHING, bean.packageName) -> LocaleString.showNothing + AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.GLOBAL, bean.packageName) -> locale.followGlobalConfig + AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.DIALOG, bean.packageName) -> locale.showErrorsDialog + AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.NOTIFY, bean.packageName) -> locale.showErrorsNotify + AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.TOAST, bean.packageName) -> locale.showErrorsToast + AppErrorsConfigData.isAppShowingType(AppErrorsConfigType.NOTHING, bean.packageName) -> locale.showNothing else -> "Unknown type" } } @@ -138,8 +138,8 @@ class ConfigureActivity : BaseActivity() { /** 模块未完全激活将显示警告 */ if (MainActivity.isModuleValied.not()) showDialog { - title = LocaleString.notice - msg = LocaleString.moduleNotFullyActivatedTip + title = locale.notice + msg = locale.moduleNotFullyActivatedTip confirmButton { FrameworkTool.restartSystem(context) } cancelButton() noCancelable() @@ -199,7 +199,7 @@ class ConfigureActivity : BaseActivity() { binding.filterIcon.isVisible = false binding.listView.isVisible = false binding.listNoDataView.isVisible = false - binding.titleCountText.text = LocaleString.loading + binding.titleCountText.text = locale.loading FrameworkTool.fetchAppListData(context = this, appFilters) { /** 设置一个临时变量用于更新列表数据 */ val tempsData = ArrayList() @@ -221,7 +221,7 @@ class ConfigureActivity : BaseActivity() { binding.filterIcon.isVisible = true binding.listView.isVisible = listData.isNotEmpty() binding.listNoDataView.isVisible = listData.isEmpty() - binding.titleCountText.text = LocaleString.resultCount(listData.size) + binding.titleCountText.text = locale.resultCount(listData.size) } else tempsData.clear() } } diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/main/MainActivity.kt b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/main/MainActivity.kt index 401489d..5b4b333 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/main/MainActivity.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/ui/activity/main/MainActivity.kt @@ -30,7 +30,7 @@ import com.fankes.apperrorstracking.const.ModuleVersion import com.fankes.apperrorstracking.data.ConfigData import com.fankes.apperrorstracking.data.factory.bind import com.fankes.apperrorstracking.databinding.ActivityMainBinding -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.ui.activity.base.BaseActivity import com.fankes.apperrorstracking.ui.activity.debug.LoggerActivity import com.fankes.apperrorstracking.ui.activity.errors.AppErrorsMutedActivity @@ -65,7 +65,7 @@ class MainActivity : BaseActivity() { /** 检查更新 */ GithubReleaseTool.checkingForUpdate(context = this, ModuleVersion.NAME) { version, function -> binding.mainTextReleaseVersion.apply { - text = LocaleString.clickToUpdate(version) + text = locale.clickToUpdate(version) isVisible = true setOnClickListener { function() } } @@ -75,9 +75,9 @@ class MainActivity : BaseActivity() { /** 显示开发者提示 */ if (ConfigData.isShowDeveloperNotice) showDialog { - title = LocaleString.developerNotice - msg = LocaleString.developerNoticeTip - confirmButton(LocaleString.gotIt) { ConfigData.isShowDeveloperNotice = false } + title = locale.developerNotice + msg = locale.developerNoticeTip + confirmButton(locale.gotIt) { ConfigData.isShowDeveloperNotice = false } noCancelable() } /** 设置 CI 自动构建标识 */ @@ -87,15 +87,15 @@ class MainActivity : BaseActivity() { isVisible = true setOnClickListener { showDialog { - title = LocaleString.ciNoticeDialogTitle - msg = LocaleString.ciNoticeDialogContent(ModuleVersion.GITHUB_COMMIT_ID) - confirmButton(LocaleString.gotIt) + title = locale.ciNoticeDialogTitle + msg = locale.ciNoticeDialogContent(ModuleVersion.GITHUB_COMMIT_ID) + confirmButton(locale.gotIt) noCancelable() } } } - binding.mainTextVersion.text = LocaleString.moduleVersion(ModuleVersion.NAME) - binding.mainTextSystemVersion.text = LocaleString.systemVersion(systemVersion) + binding.mainTextVersion.text = locale.moduleVersion(ModuleVersion.NAME) + binding.mainTextSystemVersion.text = locale.systemVersion(systemVersion) binding.onlyShowErrorsInFrontSwitch.bind(ConfigData.ENABLE_ONLY_SHOW_ERRORS_IN_FRONT) binding.onlyShowErrorsInMainProcessSwitch.bind(ConfigData.ENABLE_ONLY_SHOW_ERRORS_IN_MAIN) binding.alwaysShowsReopenAppOptionsSwitch.bind(ConfigData.ENABLE_ALWAYS_SHOWS_REOPEN_APP_OPTIONS) @@ -110,9 +110,9 @@ class MainActivity : BaseActivity() { /** 系统版本点击事件 */ binding.mainTextSystemVersion.setOnClickListener { showDialog { - title = LocaleString.notice + title = locale.notice msg = systemVersion - confirmButton(LocaleString.gotIt) + confirmButton(locale.gotIt) } } /** 管理应用配置模板按钮点击事件 */ @@ -155,9 +155,9 @@ class MainActivity : BaseActivity() { } ) binding.mainTextStatus.text = when { - YukiHookAPI.Status.isXposedModuleActive && isModuleValied.not() -> LocaleString.moduleNotFullyActivated - YukiHookAPI.Status.isXposedModuleActive -> LocaleString.moduleIsActivated - else -> LocaleString.moduleNotActivated + YukiHookAPI.Status.isXposedModuleActive && isModuleValied.not() -> locale.moduleNotFullyActivated + YukiHookAPI.Status.isXposedModuleActive -> locale.moduleIsActivated + else -> locale.moduleNotActivated } binding.mainTextApiWay.isVisible = YukiHookAPI.Status.isXposedModuleActive binding.mainTextApiWay.text = "Activated by ${YukiHookAPI.Status.Executor.name} API ${YukiHookAPI.Status.Executor.apiLevel}" @@ -168,7 +168,7 @@ class MainActivity : BaseActivity() { * @param callback 激活后回调 */ private inline fun whenActivated(callback: () -> Unit) { - if (YukiHookAPI.Status.isXposedModuleActive) callback() else toast(LocaleString.moduleNotActivated) + if (YukiHookAPI.Status.isXposedModuleActive) callback() else toast(locale.moduleNotActivated) } override fun onResume() { diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/utils/factory/DialogBuilderFactory.kt b/module-app/src/main/java/com/fankes/apperrorstracking/utils/factory/DialogBuilderFactory.kt index eab0300..945557f 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/utils/factory/DialogBuilderFactory.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/utils/factory/DialogBuilderFactory.kt @@ -33,7 +33,7 @@ import android.widget.LinearLayout import android.widget.TextView import androidx.appcompat.app.AlertDialog import androidx.viewbinding.ViewBinding -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.progressindicator.CircularProgressIndicator import com.google.android.material.shape.MaterialShapeDrawable @@ -149,7 +149,7 @@ class DialogBuilder( * @param text 按钮文本内容 * @param callback 点击事件 */ - fun confirmButton(text: String = LocaleString.confirm, callback: () -> Unit = {}) { + fun confirmButton(text: String = locale.confirm, callback: () -> Unit = {}) { instance?.setPositiveButton(text) { _, _ -> callback() } } @@ -158,7 +158,7 @@ class DialogBuilder( * @param text 按钮文本内容 * @param callback 点击事件 */ - fun cancelButton(text: String = LocaleString.cancel, callback: () -> Unit = {}) { + fun cancelButton(text: String = locale.cancel, callback: () -> Unit = {}) { instance?.setNegativeButton(text) { _, _ -> callback() } } @@ -167,7 +167,7 @@ class DialogBuilder( * @param text 按钮文本内容 * @param callback 点击事件 */ - fun neutralButton(text: String = LocaleString.more, callback: () -> Unit = {}) { + fun neutralButton(text: String = locale.more, callback: () -> Unit = {}) { instance?.setNeutralButton(text) { _, _ -> callback() } } diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/utils/factory/FunctionFactory.kt b/module-app/src/main/java/com/fankes/apperrorstracking/utils/factory/FunctionFactory.kt index 734bac7..5e15b83 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/utils/factory/FunctionFactory.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/utils/factory/FunctionFactory.kt @@ -52,7 +52,7 @@ import androidx.core.content.pm.PackageInfoCompat import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.drawable.IconCompat import com.fankes.apperrorstracking.R -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.wrapper.BuildConfigWrapper import com.google.android.material.snackbar.Snackbar import com.highcapable.yukihookapi.hook.factory.field @@ -338,7 +338,7 @@ fun Context.copyToClipboard(content: String) = runCatching { (getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager).apply { setPrimaryClip(ClipData.newPlainText(null, content)) (primaryClip?.getItemAt(0)?.text ?: "").also { - if (it != content) toast(LocaleString.copyFail) else toast(LocaleString.copied) + if (it != content) toast(locale.copyFail) else toast(locale.copied) } } } diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/utils/tool/FrameworkTool.kt b/module-app/src/main/java/com/fankes/apperrorstracking/utils/tool/FrameworkTool.kt index d7c2ac7..79c2208 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/utils/tool/FrameworkTool.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/utils/tool/FrameworkTool.kt @@ -27,7 +27,7 @@ import com.fankes.apperrorstracking.bean.AppFiltersBean import com.fankes.apperrorstracking.bean.AppInfoBean import com.fankes.apperrorstracking.bean.MutedErrorsAppBean import com.fankes.apperrorstracking.const.PackageName -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.utils.factory.execShell import com.fankes.apperrorstracking.utils.factory.isRootAccess import com.fankes.apperrorstracking.utils.factory.showDialog @@ -211,22 +211,22 @@ object FrameworkTool { /** 当 Root 权限获取失败时显示对话框 */ fun showWhenAccessRootFail() = context.showDialog { - title = LocaleString.accessRootFail - msg = LocaleString.accessRootFailTip - confirmButton(LocaleString.gotIt) + title = locale.accessRootFail + msg = locale.accessRootFailTip + confirmButton(locale.gotIt) } context.showDialog { - title = LocaleString.notice - msg = LocaleString.areYouSureRestartSystem + title = locale.notice + msg = locale.areYourSureRestartSystem confirmButton { if (isRootAccess) execShell(cmd = "reboot") else showWhenAccessRootFail() } - neutralButton(LocaleString.fastRestart) { + neutralButton(locale.fastRestart) { context.showDialog { - title = LocaleString.warning - msg = LocaleString.fastRestartProblem + title = locale.warning + msg = locale.fastRestartProblem confirmButton { if (isRootAccess) execShell(cmd = "killall zygote") diff --git a/module-app/src/main/java/com/fankes/apperrorstracking/utils/tool/GithubReleaseTool.kt b/module-app/src/main/java/com/fankes/apperrorstracking/utils/tool/GithubReleaseTool.kt index 0f8f2fb..b5f57b1 100644 --- a/module-app/src/main/java/com/fankes/apperrorstracking/utils/tool/GithubReleaseTool.kt +++ b/module-app/src/main/java/com/fankes/apperrorstracking/utils/tool/GithubReleaseTool.kt @@ -26,7 +26,7 @@ import android.content.Context import android.icu.text.SimpleDateFormat import android.icu.util.Calendar import android.icu.util.TimeZone -import com.fankes.apperrorstracking.locale.LocaleString +import com.fankes.apperrorstracking.locale.locale import com.fankes.apperrorstracking.utils.factory.openBrowser import com.fankes.apperrorstracking.utils.factory.showDialog import okhttp3.Call @@ -74,9 +74,9 @@ object GithubReleaseTool { date = getString("published_at").localTime() ).apply { fun showUpdate() = context.showDialog { - title = LocaleString.latestVersion(name) - msg = LocaleString.latestVersionTip(date, content) - confirmButton(LocaleString.updateNow) { context.openBrowser(htmlUrl) } + title = locale.latestVersion(name) + msg = locale.latestVersionTip(date, content) + confirmButton(locale.updateNow) { context.openBrowser(htmlUrl) } cancelButton() } if (name != version) (context as? Activity?)?.runOnUiThread {