Skip to content

Commit

Permalink
Merge branch 'Dev4Mod:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
masbentoooredoo authored Jun 11, 2024
2 parents 2ad852b + 7288ae9 commit 9bf04c8
Show file tree
Hide file tree
Showing 41 changed files with 266 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static com.wmods.wppenhacer.utils.DrawableColors.replaceColor;
import static com.wmods.wppenhacer.utils.IColors.parseColor;
import static com.wmods.wppenhacer.xposed.features.customization.CustomTheme.classLoader;
import static com.wmods.wppenhacer.xposed.features.customization.CustomTheme.loader1;
import static de.robv.android.xposed.XposedHelpers.callMethod;
import static de.robv.android.xposed.XposedHelpers.findClass;

Expand All @@ -27,7 +27,7 @@ public static void replaceColors(View view, HashMap<String, String> colors) {
Group.replace(viewGroup,colors);
} else if (view instanceof ViewStub viewStub) {
replaceColor(viewStub.getBackground(), colors);
} else if (view.getClass().equals(findClass("com.whatsapp.CircularProgressBar", classLoader))) {
} else if (view.getClass().equals(findClass("com.whatsapp.CircularProgressBar", loader1))) {
CircularProgressBar.replace(view,colors);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.wmods.wppenhacer.utils;

import static com.wmods.wppenhacer.utils.IColors.parseColor;
import static com.wmods.wppenhacer.xposed.features.customization.CustomTheme.classLoader;
import static com.wmods.wppenhacer.xposed.features.customization.CustomTheme.loader1;

import android.content.res.ColorStateList;
import android.graphics.Bitmap;
Expand Down Expand Up @@ -165,7 +165,7 @@ public static int getNinePatchDrawableColor(NinePatchDrawable ninePatchDrawable)

private static int getRippleDrawableColor(RippleDrawable rippleDrawable) {
var state = rippleDrawable.getConstantState();
var rippleStateClass = XposedHelpers.findClass("android.graphics.drawable.RippleDrawable.RippleState", classLoader);
var rippleStateClass = XposedHelpers.findClass("android.graphics.drawable.RippleDrawable.RippleState", loader1);
try {
return XposedHelpers.getIntField(state, "mColor");
} catch (IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

import androidx.annotation.NonNull;


import com.wmods.wppenhacer.BuildConfig;

import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;

public abstract class Feature {

public final ClassLoader loader;
public final ClassLoader classLoader;
public final XSharedPreferences prefs;
public static boolean DEBUG = false;

public Feature(@NonNull ClassLoader loader, @NonNull XSharedPreferences preferences) {
this.loader = loader;
public Feature(@NonNull ClassLoader classLoader, @NonNull XSharedPreferences preferences) {
this.classLoader = classLoader;
this.prefs = preferences;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ public class WppCore {
private static SharedPreferences privPrefs;
private static Object mStartUpConfig;

public static void addMenuItem(Class<?> aClass, OnMenuCreate listener) {
public static void addMenuItemClass(Class<?> aClass, OnMenuCreate listener) {
var list = listenerMenu.computeIfAbsent(aClass, k -> new ArrayList<>());
list.add(listener);
}

public static void addMenuItemString(String className, OnMenuCreate listener) {
var classLoader = Utils.getApplication().getClassLoader();
var aClass = XposedHelpers.findClass(className, classLoader);
var list = listenerMenu.computeIfAbsent(aClass, k -> new ArrayList<>());
list.add(listener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ public class MessageStore {
public static String getMessageById(long id) {
String message = "";
try {
Cursor cursor = database.getReadableDatabase().rawQuery("SELECT docid, c0content FROM message_ftsv2_content WHERE docid=\"" + id + "\"", null);
cursor.moveToFirst();
XposedBridge.log("Count: " + cursor.getCount());
if (cursor.getCount() <= 0) {
cursor.close();
return "";
String[] columns = new String[]{"c0content"};
String selection = "docid=?";
String[] selectionArgs = new String[]{String.valueOf(id)};

Cursor cursor = database.getReadableDatabase().query("message_ftsv2_content", columns, selection, selectionArgs, null, null, null);
if (cursor.moveToFirst()) {
message = cursor.getString(cursor.getColumnIndexOrThrow("c0content"));
}
message = cursor.getString(1);
cursor.close();
} catch (Exception ignored) {
XposedBridge.log(ignored);
} catch (Exception e) {
XposedBridge.log(e);
}
return message;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam, XS
XC_MethodHook hookDowngrade = new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
var pkg = (String) XposedHelpers.getObjectField(param.thisObject, "mPackageName");
var pkg = (String) XposedHelpers.callMethod(param.args[0], "getPackageName");
if (Objects.equals(pkg, MainFeatures.PACKAGE_WPP) || Objects.equals(pkg, MainFeatures.PACKAGE_BUSINESS))
param.setResult(null);
}
Expand All @@ -32,7 +32,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XC_MethodHook hookDowngrade2 = new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
var pkg = (String) XposedHelpers.getObjectField(param.thisObject, "mPackageName");
var pkg = (String) XposedHelpers.callMethod(param.args[0], "getPackageName");
if (Objects.equals(pkg, MainFeatures.PACKAGE_WPP) || Objects.equals(pkg, MainFeatures.PACKAGE_BUSINESS))
param.setResult(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void doHook() throws Exception {
}


var methods = Unobfuscator.loadNineDrawableMethods(loader);
var methods = Unobfuscator.loadNineDrawableMethods(classLoader);
for (var method : methods) {
XposedBridge.hookMethod(method, new XC_MethodHook() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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.core.Utils;
Expand All @@ -40,19 +39,18 @@

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 {

public static ClassLoader classLoader;
public static ClassLoader loader1;
private HashMap<String, String> wallAlpha;
private HashMap<String, String> navAlpha;
private HashMap<String, String> toolbarAlpha;

public CustomTheme(ClassLoader loader, XSharedPreferences preferences) {
super(loader, preferences);
classLoader = loader;
loader1 = loader;
}

@Override
Expand All @@ -64,7 +62,7 @@ public void doHook() throws Exception {
private void hookWallpaper() throws Exception {
if (!prefs.getBoolean("wallpaper", false)) return;

var clazz = XposedHelpers.findClass("com.whatsapp.HomeActivity", loader);
var clazz = XposedHelpers.findClass("com.whatsapp.HomeActivity", classLoader);
XposedHelpers.findAndHookMethod(clazz.getSuperclass(), "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Expand All @@ -75,7 +73,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});

XposedHelpers.findAndHookMethod("androidx.viewpager.widget.ViewPager", classLoader, "onMeasure", int.class, int.class, new XC_MethodHook() {
XposedHelpers.findAndHookMethod("androidx.viewpager.widget.ViewPager", loader1, "onMeasure", int.class, int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var viewGroup = (ViewGroup) param.thisObject;
Expand All @@ -84,7 +82,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
});


var loadTabFrameClass = Unobfuscator.loadTabFrameClass(loader);
var loadTabFrameClass = Unobfuscator.loadTabFrameClass(classLoader);
XposedHelpers.findAndHookMethod(FrameLayout.class, "onMeasure", int.class, int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Expand All @@ -109,11 +107,11 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}

private void hookColors() throws Exception {
var customDrawable1 = Unobfuscator.loadExpandableWidgetClass(loader);
var customDrawable1 = Unobfuscator.loadExpandableWidgetClass(classLoader);
logDebug("customDrawable1: " + customDrawable1.getName());
var customDrawable2 = Unobfuscator.loadMaterialShapeDrawableClass(loader);
var customDrawable2 = Unobfuscator.loadMaterialShapeDrawableClass(classLoader);
logDebug("customDrawable2: " + customDrawable2.getName());
var customDrawable3 = Unobfuscator.loadCustomDrawableClass(loader);
var customDrawable3 = Unobfuscator.loadCustomDrawableClass(classLoader);
logDebug("customDrawable3: " + customDrawable3.getName());

var primaryColorInt = prefs.getInt("primary_color", 0);
Expand Down Expand Up @@ -172,7 +170,7 @@ private void hookColors() throws Exception {
}


findAndHookMethod(Activity.class.getName(), loader, "onCreate", Bundle.class, new XC_MethodHook() {
findAndHookMethod(Activity.class.getName(), classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Expand All @@ -184,18 +182,18 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
});

var intBgHook = new IntBgColorHook();
findAndHookMethod(TextView.class.getName(), loader, "setTextColor", int.class, intBgHook);
findAndHookMethod(Paint.class.getName(), loader, "setColor", int.class, intBgHook);
findAndHookMethod(View.class.getName(), loader, "setBackgroundColor", int.class, intBgHook);
findAndHookMethod(GradientDrawable.class.getName(), loader, "setColor", int.class, intBgHook);
findAndHookMethod(ColorDrawable.class.getName(), loader, "setColor", int.class, intBgHook);
findAndHookMethod(Notification.Builder.class.getName(), loader, "setColor", int.class, intBgHook);
findAndHookMethod(Drawable.class.getName(), loader, "setTint", int.class, intBgHook);
findAndHookMethod("com.whatsapp.CircularProgressBar", loader, "setProgressBarColor", int.class, intBgHook);
findAndHookMethod("com.whatsapp.CircularProgressBar", loader, "setProgressBarBackgroundColor", int.class, intBgHook);
findAndHookMethod(TextView.class.getName(), classLoader, "setTextColor", int.class, intBgHook);
findAndHookMethod(Paint.class.getName(), classLoader, "setColor", int.class, intBgHook);
findAndHookMethod(View.class.getName(), classLoader, "setBackgroundColor", int.class, intBgHook);
findAndHookMethod(GradientDrawable.class.getName(), classLoader, "setColor", int.class, intBgHook);
findAndHookMethod(ColorDrawable.class.getName(), classLoader, "setColor", int.class, intBgHook);
findAndHookMethod(Notification.Builder.class.getName(), classLoader, "setColor", int.class, intBgHook);
findAndHookMethod(Drawable.class.getName(), classLoader, "setTint", int.class, intBgHook);
findAndHookMethod("com.whatsapp.CircularProgressBar", classLoader, "setProgressBarColor", int.class, intBgHook);
findAndHookMethod("com.whatsapp.CircularProgressBar", classLoader, "setProgressBarBackgroundColor", int.class, intBgHook);

var colorStateListHook = new ColorStateListHook();
findAndHookMethod(Drawable.class.getName(), loader, "setTintList", ColorStateList.class, colorStateListHook);
findAndHookMethod(Drawable.class.getName(), classLoader, "setTintList", ColorStateList.class, colorStateListHook);
findAndHookMethod(customDrawable1, "setBackgroundTintList", ColorStateList.class, colorStateListHook);
findAndHookMethod(customDrawable1, "setRippleColor", ColorStateList.class, colorStateListHook);
findAndHookMethod(customDrawable1, "setSupportImageTintList", ColorStateList.class, colorStateListHook);
Expand All @@ -206,12 +204,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
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);
findAndHookMethod(LayoutInflater.class.getName(), classLoader, "inflate", int.class, ViewGroup.class, inflaterHook);
findAndHookMethod(LayoutInflater.class.getName(), classLoader, "inflate", XmlPullParser.class, ViewGroup.class, inflaterHook);
findAndHookMethod(LayoutInflater.class.getName(), classLoader, "inflate", int.class, ViewGroup.class, boolean.class, inflaterHook);
findAndHookMethod(LayoutInflater.class.getName(), classLoader, "inflate", XmlPullParser.class, ViewGroup.class, boolean.class, inflaterHook);

findAndHookMethod(View.class.getName(), loader, "setBackground", Drawable.class, new XC_MethodHook() {
findAndHookMethod(View.class.getName(), classLoader, "setBackground", Drawable.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
var colors = IColors.colors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import androidx.annotation.NonNull;

import com.wmods.wppenhacer.xposed.core.Unobfuscator;
import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.Unobfuscator;

import java.text.SimpleDateFormat;
import java.util.Date;
Expand All @@ -23,7 +23,7 @@ public CustomTime(ClassLoader loader, XSharedPreferences preferences) {
public void doHook() throws Exception {
var secondsToTime = prefs.getBoolean("segundos", false);
var ampm = prefs.getBoolean("ampm", false);
var secondsToTimeMethod = Unobfuscator.loadTimeToSecondsMethod(loader);
var secondsToTimeMethod = Unobfuscator.loadTimeToSecondsMethod(classLoader);
logDebug(Unobfuscator.getMethodDescriptor(secondsToTimeMethod));

XposedBridge.hookMethod(secondsToTimeMethod, new XC_MethodHook() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import androidx.annotation.NonNull;

import com.wmods.wppenhacer.xposed.core.DesignUtils;
import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.Utils;
import com.wmods.wppenhacer.xposed.core.WppCore;
import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.features.privacy.HideArchive;

import java.lang.reflect.Method;
Expand All @@ -33,7 +33,7 @@ public void doHook() {
var showName = prefs.getBoolean("shownamehome", false);
var showBio = prefs.getBoolean("showbiohome", false);
var methodHook = new MethodHook(showName, showBio);
XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", loader, "onCreate", Bundle.class, methodHook);
XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onCreate", Bundle.class, methodHook);
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void registerCssRules(Activity activity, ViewGroup currenView, StyleShee
String name;
if ((className = item.getClassName()) != null) {
className = className.replaceAll("_", ".").trim();
var clazz = XposedHelpers.findClass(className, loader);
var clazz = XposedHelpers.findClass(className, classLoader);
if (clazz == null || !clazz.isInstance(activity)) continue;
name = selectorItem.get(1).getIDName().trim();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView; // Added for displaying last seen time
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.Unobfuscator;
import com.wmods.wppenhacer.xposed.core.UnobfuscatorCache;
import com.wmods.wppenhacer.xposed.core.Utils;
import com.wmods.wppenhacer.xposed.core.WppCore;
import com.wmods.wppenhacer.xposed.core.Feature;

import java.util.HashMap;

Expand All @@ -47,7 +47,7 @@ public void doHook() throws Throwable {
var showOnlineIcon = prefs.getBoolean("dotonline", false);
if (!showOnlineText && !showOnlineIcon) return;

var classViewHolder = XposedHelpers.findClass("com.whatsapp.conversationslist.ViewHolder", loader);
var classViewHolder = XposedHelpers.findClass("com.whatsapp.conversationslist.ViewHolder", classLoader);
XposedBridge.hookAllConstructors(classViewHolder, new XC_MethodHook() {
@SuppressLint("ResourceType")
@Override
Expand Down Expand Up @@ -104,13 +104,13 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});

var onChangeStatus = Unobfuscator.loadOnChangeStatus(loader);
var onChangeStatus = Unobfuscator.loadOnChangeStatus(classLoader);
logDebug(Unobfuscator.getMethodDescriptor(onChangeStatus));
var field1 = Unobfuscator.loadViewHolderField1(loader);
var field1 = Unobfuscator.loadViewHolderField1(classLoader);
logDebug(Unobfuscator.getFieldDescriptor(field1));
var getStatusUser = Unobfuscator.loadGetStatusUserMethod(loader);
var getStatusUser = Unobfuscator.loadGetStatusUserMethod(classLoader);
logDebug(Unobfuscator.getMethodDescriptor(getStatusUser));
var sendPresenceMethod = Unobfuscator.loadSendPresenceMethod(loader);
var sendPresenceMethod = Unobfuscator.loadSendPresenceMethod(classLoader);
logDebug(Unobfuscator.getMethodDescriptor(sendPresenceMethod));


Expand Down Expand Up @@ -143,7 +143,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (showOnlineText) {
lastSeenText.setVisibility(View.INVISIBLE); // Hide last seen time initially
}
var jidFiled = Unobfuscator.getFieldByExtendType(object.getClass(), XposedHelpers.findClass("com.whatsapp.jid.Jid", loader));
var jidFiled = Unobfuscator.getFieldByExtendType(object.getClass(), XposedHelpers.findClass("com.whatsapp.jid.Jid", classLoader));
var jidObject = jidFiled.get(object);
var jid = WppCore.getRawString(jidObject);
if (WppCore.isGroup(jid)) return;
Expand Down
Loading

0 comments on commit 9bf04c8

Please sign in to comment.