From 1f234a812f5508e815eb44dd43d188395cb9c3a0 Mon Sep 17 00:00:00 2001 From: Dev4Mod Date: Thu, 16 May 2024 15:56:58 -0300 Subject: [PATCH] Improve Message Error. --- .../wmods/wppenhacer/xposed/core/MainFeatures.java | 14 ++++++++------ .../com/wmods/wppenhacer/xposed/core/ResId.java | 5 +++++ .../com/wmods/wppenhacer/xposed/core/Utils.java | 1 - app/src/main/res/values/strings.xml | 5 +++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/core/MainFeatures.java b/app/src/main/java/com/wmods/wppenhacer/xposed/core/MainFeatures.java index a10d1c9e..e177c3f8 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/core/MainFeatures.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/core/MainFeatures.java @@ -19,6 +19,7 @@ import androidx.core.content.ContextCompat; import com.wmods.wppenhacer.BuildConfig; +import com.wmods.wppenhacer.R; import com.wmods.wppenhacer.xposed.core.components.AlertDialogWpp; import com.wmods.wppenhacer.xposed.features.customization.CustomToolbar; import com.wmods.wppenhacer.xposed.features.customization.BubbleColors; @@ -102,14 +103,15 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { protected void afterHookedMethod(MethodHookParam param) throws Throwable { super.afterHookedMethod(param); if (!list.isEmpty()) { - new AlertDialogWpp((Activity) param.thisObject) - .setTitle("Error detected") - .setMessage("The following options aren't working:\n\n" + String.join("\n", list.stream().map(ErrorItem::getPluginName).toArray(String[]::new))) - .setPositiveButton("Copy to clipboard", (dialog, which) -> { + var activity = (Activity) param.thisObject; + new AlertDialogWpp(activity) + .setTitle(activity.getString(ResId.string.error_detected)) + .setMessage(activity.getString(ResId.string.version_error) + String.join("\n", list.stream().map(ErrorItem::getPluginName).toArray(String[]::new))) + .setPositiveButton(activity.getString(ResId.string.copy_to_clipboard), (dialog, which) -> { var clipboard = (ClipboardManager) mApp.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("text", String.join("\n", list.stream().map(ErrorItem::toString).toArray(String[]::new))); clipboard.setPrimaryClip(clip); - Toast.makeText(mApp, "Copied to clipboard", Toast.LENGTH_SHORT).show(); + Toast.makeText(mApp, ResId.string.copied_to_clipboard, Toast.LENGTH_SHORT).show(); dialog.dismiss(); }) .show(); @@ -129,7 +131,7 @@ private static void registerReceivers() { public void onReceive(Context context, Intent intent) { if (context.getPackageName().equals(intent.getStringExtra("PKG"))) { var appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo()); - Toast.makeText(context, "Rebooting " + appName + "...", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, context.getString(ResId.string.rebooting) + " " + appName + "...", Toast.LENGTH_SHORT).show(); if (!Utils.doRestart(context)) Toast.makeText(context, "Unable to rebooting " + appName, Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java b/app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java index a5228b2c..81b89bb8 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java @@ -34,6 +34,11 @@ public static class string { public static int phone_call; public static int yes; public static int no; + public static int version_error; + public static int copy_to_clipboard; + public static int copied_to_clipboard; + public static int error_detected; + public static int rebooting; } } diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/core/Utils.java b/app/src/main/java/com/wmods/wppenhacer/xposed/core/Utils.java index 8f6958f8..fffc371c 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/core/Utils.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/core/Utils.java @@ -29,7 +29,6 @@ public static boolean doRestart(Context context) { Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName()); if (intent == null) return false; - ComponentName componentName = intent.getComponent(); Intent mainIntent = Intent.makeRestartActivityTask(componentName); mainIntent.setPackage(context.getPackageName()); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 12fa6259..62caa80a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -253,4 +253,9 @@ Backup Settings Import Export + The version of Whatsapp you are using is not compatible and is throwing an error in the following features:\n\n + Copy to clipboard + Copied to clipboard + Error detected + Rebooting