Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: improve error notification text
Browse files Browse the repository at this point in the history
  • Loading branch information
mkx173 committed Apr 3, 2024
1 parent f2cf1e0 commit ff755a6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ android {
versionCode gitCommitCount
versionName '2.9.6'
buildConfigField "String", "TARGET_VERSION", "\"12.57.5.0\""
buildConfigField "String", "MIN_VERSION", "\"12.53.1.0\""

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
externalNativeBuild {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/gm/tieba/tabswitch/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ object Constants {
" ②本模块不会主动发起网络请求,不会上传任何用户数据,隐私泄露或者账号异常行为与本模块无关。\n" +
" ③本模块主要用于学习和交流技术,任何人不得将本模块用于商业或非法用途。",
"dev_tip" to "提示:您当前安装的是非正式版本,可能含有较多错误,如果您希望得到更稳定的使用体验,建议您安装正式版本。",
"exception_rules_incomplete" to "规则异常,建议您执行反混淆。若执行完后仍出现此对话框则应更新模块或使用推荐贴吧版本%s,若已是最新版本则应向作者反馈。",
"exception_rules_incomplete" to "规则异常,请点击确定并重启应用以重新执行反混淆。若执行反混淆后仍出现此对话框则应尝试更新模块或向作者反馈。",
"version_mismatch" to "规则异常,当前贴吧版本不受支持。请使用受支持的贴吧版本(%s-%s)或尝试更新模块。",
"exception_init_preference" to "初始化设置失败,请尝试更换贴吧版本。",
"regex_hint" to "请输入正则表达式,如.*",
)
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/gm/tieba/tabswitch/XposedInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.app.Instrumentation;
import android.content.Intent;
import android.content.res.XModuleResources;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.WindowManager;
Expand Down Expand Up @@ -221,15 +222,30 @@ protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
final var activity = (Activity) param.thisObject;
final var messages = new ArrayList<String>();
messages.add(String.format(Constants.getStrings().get("exception_rules_incomplete"), BuildConfig.TARGET_VERSION));
messages.add(String.format(Locale.CHINA, "tbversion: %s, module version: %d",

if (DeobfuscationHelper.isTbSatisfyVersionRequirement(BuildConfig.MIN_VERSION, currTbVersion)
&& (!DeobfuscationHelper.isTbSatisfyVersionRequirement(BuildConfig.TARGET_VERSION, currTbVersion) || currTbVersion.equals(BuildConfig.TARGET_VERSION))) {
messages.add(Constants.getStrings().get("exception_rules_incomplete"));
} else {
messages.add(String.format(Locale.CHINA,
Constants.getStrings().get("version_mismatch"),
BuildConfig.MIN_VERSION, BuildConfig.TARGET_VERSION));
}

messages.add(String.format(Locale.CHINA, "贴吧版本:%s, 模块版本:%d",
currTbVersion, BuildConfig.VERSION_CODE));
messages.add(String.format(Locale.CHINA, "%d rule(s) lost: %s", lostList.size(), lostList));
final var message = TextUtils.join("\n", messages);
XposedBridge.log(message);
AlertDialog alert = new AlertDialog.Builder(activity, DisplayUtils.isLightMode(getContext()) ?
android.R.style.Theme_DeviceDefault_Light_Dialog_Alert : android.R.style.Theme_DeviceDefault_Dialog_Alert)
.setTitle("警告").setMessage(message).setCancelable(false)
.setNeutralButton("更新模块", (dialogInterface, i) -> {
final Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setData(Uri.parse("https://github.com/GuhDoy/TiebaTS/releases"));
activity.startActivity(intent);
})
.setNegativeButton(activity.getString(android.R.string.cancel), null)
.setPositiveButton(activity.getString(android.R.string.ok), (dialogInterface, i) -> {
Preferences.putSignature(0);
Expand Down

0 comments on commit ff755a6

Please sign in to comment.