Skip to content

Commit

Permalink
Improve Message Error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev4Mod committed May 16, 2024
1 parent a8f699c commit 1f234a8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,9 @@
<string name="backup_settings">Backup Settings</string>
<string name="import_settings">Import</string>
<string name="export_settings">Export</string>
<string name="version_error">The version of Whatsapp you are using is not compatible and is throwing an error in the following features:\n\n</string>
<string name="copy_to_clipboard">Copy to clipboard</string>
<string name="copied_to_clipboard">Copied to clipboard</string>
<string name="error_detected">Error detected</string>
<string name="rebooting">Rebooting</string>
</resources>

0 comments on commit 1f234a8

Please sign in to comment.