From f38b18d7f25d5ed3058ef014a60febf2c1301961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=80=E6=BC=93=E4=B8=A8Sevtinge?= <89193494+Sevtinge@users.noreply.github.com> Date: Sun, 7 Apr 2024 17:56:36 +0800 Subject: [PATCH] opt: auto safe mode textview desc --- .../java/com/sevtinge/hyperceiler/module/app/Demo.java | 3 ++- .../sevtinge/hyperceiler/safe/CrashReportActivity.java | 3 ++- .../java/com/sevtinge/hyperceiler/ui/MainActivity.java | 8 ++++---- .../java/com/sevtinge/hyperceiler/utils/DialogHelper.java | 6 +++--- app/src/main/res/layout/crash_report_dialog.xml | 3 ++- app/src/main/res/values-zh-rCN/strings.xml | 8 ++++++++ app/src/main/res/values/strings.xml | 7 +++++++ 7 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/Demo.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/Demo.java index 145ff365cb..bff5322eb6 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/Demo.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/Demo.java @@ -2,13 +2,14 @@ import com.sevtinge.hyperceiler.module.base.BaseModule; import com.sevtinge.hyperceiler.module.hook.demo.ColorTest; +import com.sevtinge.hyperceiler.module.hook.demo.CrashDemo; import com.sevtinge.hyperceiler.module.hook.demo.ToastTest; public class Demo extends BaseModule { @Override public void handleLoadPackage() { initHook(new ToastTest(), true); - // initHook(new CrashDemo(), true); + initHook(new CrashDemo(), true); initHook(new ColorTest(), true); } } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/safe/CrashReportActivity.java b/app/src/main/java/com/sevtinge/hyperceiler/safe/CrashReportActivity.java index e4a3530f8a..5d1fa28296 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/safe/CrashReportActivity.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/safe/CrashReportActivity.java @@ -6,6 +6,7 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; +import android.widget.Button; import android.widget.TextView; import androidx.annotation.Nullable; @@ -41,7 +42,7 @@ public void onCreate(@Nullable Bundle bundle) { String pkg = getReportCrashPkg(code); View view = LayoutInflater.from(this).inflate(R.layout.crash_report_dialog, null); mMessageTv = view.findViewById(R.id.tv_message); - mMessageTv.setText("作用域: " + "\n\"" + pkg + "\"\n已进入安全模式,点击确定解除,点击取消稍后处理。"); + mMessageTv.setText(pkg + " " + getString(R.string.safe_mode_desc)); mCrashRecordTv = view.findViewById(R.id.tv_record); mCrashRecordTv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);// 下划线并加清晰 mCrashRecordTv.getPaint().setAntiAlias(true); diff --git a/app/src/main/java/com/sevtinge/hyperceiler/ui/MainActivity.java b/app/src/main/java/com/sevtinge/hyperceiler/ui/MainActivity.java index 05488a1f06..d20d3df566 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/ui/MainActivity.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/ui/MainActivity.java @@ -70,16 +70,16 @@ public void onCreate(Bundle savedInstanceState) { (ProjectApi.isRelease() ? def : ProjectApi.isCanary() ? (def == 0 ? 3 : 4) : def)); if (haveCrashReport()) { new AlertDialog.Builder(this) - .setTitle("提示") - .setMessage("存在处于安全模式的作用域: \n" + appCrash.toString() + " \n请选择是否解除?") + .setTitle(R.string.safe_mode_later_title) + .setMessage(appCrash.toString() + " " + getString(R.string.safe_mode_later_desc)) .setHapticFeedbackEnabled(true) .setCancelable(false) - .setPositiveButton(android.R.string.ok, (dialog, which) -> { + .setPositiveButton(R.string.safe_mode_cancel, (dialog, which) -> { ShellInit.getShell().run("setprop persist.hyperceiler.crash.report \"\"").sync(); ShellInit.getShell().run("settings put system hyperceiler_crash_report \"[]\"").sync(); dialog.dismiss(); }) - .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss()) + .setNegativeButton(R.string.safe_mode_ok, (dialog, which) -> dialog.dismiss()) .show(); } } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/utils/DialogHelper.java b/app/src/main/java/com/sevtinge/hyperceiler/utils/DialogHelper.java index 4df6ed046e..0d321f1c37 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/utils/DialogHelper.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/utils/DialogHelper.java @@ -81,16 +81,16 @@ public static void showRestartDialog(Context context) { public static void showCrashReportDialog(Activity activity, View view) { new AlertDialog.Builder(activity) .setCancelable(false) - .setTitle("警告") + .setTitle(R.string.safe_mode_title) .setView(view) .setHapticFeedbackEnabled(true) - .setPositiveButton(android.R.string.ok, (dialog, which) -> { + .setPositiveButton(R.string.safe_mode_cancel, (dialog, which) -> { ShellExec shellExec = ShellInit.getShell(); shellExec.run("setprop persist.hyperceiler.crash.report \"\"").sync(); shellExec.run("settings put system hyperceiler_crash_report \"[]\"").sync(); activity.finish(); }) - .setNegativeButton(android.R.string.cancel, (dialog, which) -> activity.finish()) + .setNegativeButton(R.string.safe_mode_ok, (dialog, which) -> activity.finish()) .show(); } diff --git a/app/src/main/res/layout/crash_report_dialog.xml b/app/src/main/res/layout/crash_report_dialog.xml index 4a0d1ae864..e7eaa185a6 100644 --- a/app/src/main/res/layout/crash_report_dialog.xml +++ b/app/src/main/res/layout/crash_report_dialog.xml @@ -7,6 +7,7 @@ @@ -14,7 +15,7 @@ 禁用推荐 启用推荐 + 警告 + 由于多次崩溃,已进入安全模式,HyperCeiler 功能已暂时停用。\n点击确定解除,点击取消稍后处理。 + 查看异常记录 + 解除 + 稍后处理 + 提示 + 仍处于安全模式中,HyperCeiler对其的功能已停用。\n是否解除安全模式? + Tip: 这里是默认 tip ~ 如果你能看见我,就说明 HyperCeiler 出现了问题,请及时且有效的反馈给开发者。 您正在使用的 ROM 来源可能并不是 Xiaomi 官方,部分功能可能会失效,详情请咨询您正在使用 ROM 的提供者。 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 24adb9a685..ca4a1f4612 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1648,6 +1648,13 @@ You can still find this page in \"Settings - Set up the homepage entry\". Reboot app to apply. The source of the ROM you are using may not be official from Xiaomi, and some functions may not work, please contact the provider you are using for details. The signature verification failed, and the current version you are using may not be from the official version of Re.chronoRain, and may contain malicious code. + Warning + has entered safe mode due to multiple crashes and HyperCeiler functionality has been temporarily disabled. \nClick OK to cancel, click Cancel to process later. + View exception records + Disable safe mode + Deal with it later + Tip + is still in safe mode and HyperCeiler functionality has been disabled. Disable safe mode? Tip: Here is the default tip. If you can see me, it means that there is a problem with HyperCeiler, please report it to the developer in a timely and effective manner. Looking for something else?