diff --git a/app/src/main/java/com/wmods/wppenhacer/ui/fragments/HomeFragment.java b/app/src/main/java/com/wmods/wppenhacer/ui/fragments/HomeFragment.java index d7355bfa..6a8ada49 100644 --- a/app/src/main/java/com/wmods/wppenhacer/ui/fragments/HomeFragment.java +++ b/app/src/main/java/com/wmods/wppenhacer/ui/fragments/HomeFragment.java @@ -31,6 +31,7 @@ import java.util.Arrays; import java.util.HashSet; +import java.util.stream.Collectors; import rikka.core.util.IOUtils; @@ -151,7 +152,8 @@ private void importConfigs(Context context) { if (value instanceof String stringValue) { if (stringValue.startsWith("[") && stringValue.endsWith("]")) { if (stringValue.length() > 2) { - prefs.edit().putStringSet(keyName, new HashSet<>(Arrays.asList(stringValue.substring(1, stringValue.length() - 1).split(",")))).apply(); + var arr = Arrays.stream(stringValue.substring(1, stringValue.length() - 1).split(",")).map(String::trim).collect(Collectors.toList()); + prefs.edit().putStringSet(keyName, new HashSet<>(arr)).apply(); } } else { prefs.edit().putString(keyName, value.toString()).apply(); diff --git a/app/src/main/java/com/wmods/wppenhacer/utils/DrawableColors.java b/app/src/main/java/com/wmods/wppenhacer/utils/DrawableColors.java index 27da2a6d..ac1474a9 100644 --- a/app/src/main/java/com/wmods/wppenhacer/utils/DrawableColors.java +++ b/app/src/main/java/com/wmods/wppenhacer/utils/DrawableColors.java @@ -77,9 +77,6 @@ public static void replaceColor(Drawable drawable, HashMap color var color = getNinePatchDrawableColor(ninePatchDrawable); var sColor = IColors.toString(color); var newColor = colors.get(sColor); - if (newColor != null && newColor.contains("121212")){ - XposedBridge.log(new Throwable()); - } if (newColor != null) { ninePatchDrawable.setTintList(ColorStateList.valueOf(parseColor(newColor))); } @@ -88,9 +85,6 @@ public static void replaceColor(Drawable drawable, HashMap color var color = getColor(drawable); var sColor = IColors.toString(color); var newColor = colors.get(sColor); - if (newColor != null && newColor.contains("121212")){ - XposedBridge.log(new Throwable()); - } if (newColor != null) { drawable.setColorFilter(new PorterDuffColorFilter(parseColor(newColor), PorterDuff.Mode.SRC_IN)); } else { diff --git a/app/src/main/java/com/wmods/wppenhacer/views/WallpaperView.java b/app/src/main/java/com/wmods/wppenhacer/views/WallpaperView.java index 65605090..bc6aa542 100644 --- a/app/src/main/java/com/wmods/wppenhacer/views/WallpaperView.java +++ b/app/src/main/java/com/wmods/wppenhacer/views/WallpaperView.java @@ -41,9 +41,4 @@ private void init(Context context) { } } - @Override - public void addView(View child) { - super.addView(child); - } - } \ No newline at end of file diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/core/Unobfuscator.java b/app/src/main/java/com/wmods/wppenhacer/xposed/core/Unobfuscator.java index 28cda67e..0f7f40d8 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/core/Unobfuscator.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/core/Unobfuscator.java @@ -156,6 +156,15 @@ public static boolean isCalledFromString(String contains) { return text.contains(contains); } + public static boolean isCalledFromStrings(String... contains) { + var trace = Thread.currentThread().getStackTrace(); + var text = Arrays.toString(trace); + for (String s : contains) { + if (text.contains(s)) return true; + } + return false; + } + // TODO: Classes and Methods for FreezeSeen public static Method loadFreezeSeenMethod(ClassLoader classLoader) throws Exception { @@ -196,6 +205,17 @@ public static Method loadReceiptMethod2(ClassLoader classLoader) throws Exceptio }); } + public static Method loadReceiptMethod3(ClassLoader classLoader) throws Exception { + return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> { + var method = loadReceiptMethod(classLoader); + var classList = dexkit.findClass(new FindClass().matcher(new ClassMatcher().addUsingString("callCreatorJid"))); + if (classList.isEmpty()) throw new Exception("Receipt method not found"); + var methodDataList = dexkit.findMethod(new FindMethod().searchInClass(classList).matcher(new MethodMatcher().addInvoke(DexSignUtil.getMethodDescriptor(method)))); + if (methodDataList.isEmpty()) throw new Exception("Receipt method not found"); + return methodDataList.get(0).getMethodInstance(classLoader); + }); + } + // TODO: Classes and Methods for HideForward public static Method loadForwardTagMethod(ClassLoader classLoader) throws Exception { diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomTheme.java b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomTheme.java index ea183b51..3afe6fd0 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomTheme.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomTheme.java @@ -1,5 +1,7 @@ package com.wmods.wppenhacer.xposed.features.customization; +import static com.wmods.wppenhacer.utils.ColorReplacement.replaceColors; +import static com.wmods.wppenhacer.utils.DrawableColors.replaceColor; import static de.robv.android.xposed.XposedHelpers.findAndHookMethod; import android.Manifest; @@ -15,6 +17,7 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.os.Bundle; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -23,15 +26,22 @@ import androidx.core.content.ContextCompat; import com.wmods.wppenhacer.utils.IColors; +import com.wmods.wppenhacer.views.WallpaperView; +import com.wmods.wppenhacer.xposed.core.DesignUtils; import com.wmods.wppenhacer.xposed.core.Feature; import com.wmods.wppenhacer.xposed.core.Unobfuscator; +import com.wmods.wppenhacer.xposed.features.general.ShowEditMessage; +import org.xmlpull.v1.XmlPullParser; + +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Objects; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XSharedPreferences; +import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedHelpers; public class CustomTheme extends Feature { @@ -127,16 +137,16 @@ private void hookColors() throws Exception { } isWallpaper = prefs.getBoolean("wallpaper", false); -// findAndHookMethod(Activity.class.getName(), loader, "onCreate", Bundle.class, new XC_MethodHook() { -// @Override -// protected void afterHookedMethod(MethodHookParam param) throws Throwable { -// super.afterHookedMethod(param); -// var colors = getAlpha(); -// var activity = (Activity) param.thisObject; -// var view = activity.findViewById(android.R.id.content).getRootView(); -// replaceColors(view,colors); -// } -// }); + findAndHookMethod(Activity.class.getName(), loader, "onCreate", Bundle.class, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + super.afterHookedMethod(param); + var colors = getAlpha(); + var activity = (Activity) param.thisObject; + var view = activity.findViewById(android.R.id.content).getRootView(); + replaceColors(view, colors); + } + }); var intBgHook = new IntBgColorHook(); findAndHookMethod(Paint.class.getName(), loader, "setColor", int.class, intBgHook); @@ -159,11 +169,11 @@ private void hookColors() throws Exception { findAndHookMethod(customDrawable3, "setTintList", ColorStateList.class, colorStateListHook); -// var inflaterHook = (XC_MethodHook) new LayoutInflaterHook(); -// findAndHookMethod(LayoutInflater.class.getName(), loader, "inflate", int.class, ViewGroup.class, inflaterHook); -// findAndHookMethod(LayoutInflater.class.getName(), loader, "inflate", XmlPullParser.class, ViewGroup.class, inflaterHook); -// findAndHookMethod(LayoutInflater.class.getName(), loader, "inflate", int.class, ViewGroup.class, boolean.class, inflaterHook); -// findAndHookMethod(LayoutInflater.class.getName(), loader, "inflate", XmlPullParser.class, ViewGroup.class, boolean.class, inflaterHook); + var inflaterHook = (XC_MethodHook) new LayoutInflaterHook(); + findAndHookMethod(LayoutInflater.class.getName(), loader, "inflate", int.class, ViewGroup.class, inflaterHook); + findAndHookMethod(LayoutInflater.class.getName(), loader, "inflate", XmlPullParser.class, ViewGroup.class, inflaterHook); + findAndHookMethod(LayoutInflater.class.getName(), loader, "inflate", int.class, ViewGroup.class, boolean.class, inflaterHook); + findAndHookMethod(LayoutInflater.class.getName(), loader, "inflate", XmlPullParser.class, ViewGroup.class, boolean.class, inflaterHook); // findAndHookMethod(View.class.getName(), loader, "setBackground", Drawable.class, new XC_MethodHook() { // @Override @@ -179,25 +189,28 @@ private HashMap getAlpha() { if (!isWallpaper) return IColors.colors; // if (!Unobfuscator.isCalledFromString("HomeActivity.onCreate")) return IColors.colors; if (Unobfuscator.isCalledFromClass(Window.class)) return IColors.colors; - if (Unobfuscator.isCalledFromString("setStatusBarColor")) return IColors.colors; - if (Unobfuscator.isCalledFromString("WDSToolbar")) return IColors.colors; - if (Unobfuscator.isCalledFromString("WDSFab")) return IColors.colors; - if (Unobfuscator.isCalledFromString("onPreparePanel")) return IColors.colors; - if (Unobfuscator.isCalledFromString("onCreateOptionsMenu")) return IColors.colors; - if (Unobfuscator.isCalledFromString("onLongClick")) return IColors.colors; + if (Unobfuscator.isCalledFromStrings( + "setStatusBarColor", "WDSToolbar", "WDSFab", "onPreparePanel" + , "onCreateOptionsMenu", "onLongClick", "PhoneWindow", "Image")) + return IColors.colors; + if (Unobfuscator.isCalledFromClass(ShowEditMessage.class)) return IColors.colors; + if (Unobfuscator.isCalledFromClass(DesignUtils.class)) return IColors.colors; return newColors; } private void injectWallpaper(View view) { var content = (ViewGroup) view; - var context = content.getContext(); - try { - Bitmap bitmap = BitmapFactory.decodeFile(prefs.getString("wallpaper_file", "")); - Drawable drawable = new BitmapDrawable(context.getResources(), bitmap); - content.setBackground(drawable); - } catch (Exception e) { - log(e.toString()); + var rootView = (ViewGroup) content.getChildAt(0); + var views = new ArrayList(); + while (rootView.getChildCount() > 0) { + views.add(rootView.getChildAt(0)); + rootView.removeView(rootView.getChildAt(0)); } + var frameLayout = new WallpaperView(rootView.getContext(), prefs); + for (var v : views) { + frameLayout.addView(v); + } + rootView.addView(frameLayout); } @NonNull @@ -206,15 +219,15 @@ public String getPluginName() { return "Change Colors"; } -// public class LayoutInflaterHook extends XC_MethodHook { -// @Override -// protected void afterHookedMethod(MethodHookParam param) throws Throwable { -// var colors = getAlpha(); -// var view = (View) param.getResult(); -// if (view == null) return; -// replaceColors(view, colors); -// } -// } + public class LayoutInflaterHook extends XC_MethodHook { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + var colors = getAlpha(); + var view = (View) param.getResult(); + if (view == null) return; + replaceColors(view, colors); + } + } public class ColorStateListHook extends XC_MethodHook { @Override diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/features/privacy/HideReceipt.java b/app/src/main/java/com/wmods/wppenhacer/xposed/features/privacy/HideReceipt.java index c83cceae..111042c5 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/features/privacy/HideReceipt.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/features/privacy/HideReceipt.java @@ -20,12 +20,13 @@ public HideReceipt(ClassLoader loader, XSharedPreferences preferences) { public void doHook() throws Exception { var method = Unobfuscator.loadReceiptMethod(loader); var method2 = Unobfuscator.loadReceiptMethod2(loader); + var method3 = Unobfuscator.loadReceiptMethod3(loader); logDebug(Unobfuscator.getMethodDescriptor(method)); XposedBridge.hookMethod(method, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (!prefs.getBoolean("hidereceipt", false)) return; - if (!Unobfuscator.isCalledFromMethod(method2)) return; + if (!Unobfuscator.isCalledFromMethod(method2) && !Unobfuscator.isCalledFromMethod(method3)) return; var jid = WppCore.getRawString(param.args[0]); if ((jid == null || jid.contains("@lid")) && param.args[4] != "sender") { param.args[4] = "inactive";