Skip to content

Commit

Permalink
Merge branch 'Dev4Mod:master' into theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Strange-IPmart authored Jan 14, 2025
2 parents 826f972 + 362c580 commit ee06a3e
Show file tree
Hide file tree
Showing 27 changed files with 457 additions and 301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ private boolean checkStoragePermission(Object newValue) {

@SuppressLint("ApplySharedPref")
private void chanceStates(String key) {

var update_check = mPrefs.getBoolean("update_check", true);
setPreferenceState("update_check", update_check);

var lite_mode = mPrefs.getBoolean("lite_mode", false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import com.wmods.wppenhacer.xposed.features.privacy.HideChat;
import com.wmods.wppenhacer.xposed.features.privacy.HideReceipt;
import com.wmods.wppenhacer.xposed.features.privacy.HideSeen;
import com.wmods.wppenhacer.xposed.features.privacy.HideTagForward;
import com.wmods.wppenhacer.xposed.features.privacy.TagMessage;
import com.wmods.wppenhacer.xposed.features.privacy.TypingPrivacy;
import com.wmods.wppenhacer.xposed.features.privacy.ViewOnce;
import com.wmods.wppenhacer.xposed.utils.DesignUtils;
Expand Down Expand Up @@ -282,7 +282,7 @@ private static void plugins(@NonNull ClassLoader loader, @NonNull XSharedPrefere
HideChat.class,
HideReceipt.class,
HideSeen.class,
HideTagForward.class,
TagMessage.class,
HideTabs.class,
IGStatus.class,
LiteMode.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class FMessageWpp {
private static Field mediaTypeField;
private static Method getOriginalMessageKey;
private static Class abstractMediaMessageClass;
private static Field broadcastField;
private final Object fmessage;

public FMessageWpp(Object fMessage) {
Expand Down Expand Up @@ -51,6 +52,7 @@ public static void init(ClassLoader classLoader) throws Exception {
mediaTypeField = Unobfuscator.loadMediaTypeField(classLoader);
getOriginalMessageKey = Unobfuscator.loadOriginalMessageKey(classLoader);
abstractMediaMessageClass = Unobfuscator.loadAbstractMediaMessageClass(classLoader);
broadcastField = Unobfuscator.loadBroadcastTagField(classLoader);
}

public Object getUserJid() {
Expand Down Expand Up @@ -99,6 +101,15 @@ public Key getOriginalKey() {
return null;
}

public boolean isBroadcast() {
try {
return (boolean) broadcastField.get(fmessage);
} catch (Exception e) {
XposedBridge.log(e);
}
return false;
}

public Object getObject() {
return fmessage;
}
Expand Down Expand Up @@ -152,10 +163,10 @@ public int getMediaType() {
public static class Key {
public static Class<?> TYPE;

public final Object thisObject;
public final String messageID;
public final boolean isFromMe;
public final Object remoteJid;
public Object thisObject;
public String messageID;
public boolean isFromMe;
public Object remoteJid;

public Key(Object key) {
this.thisObject = key;
Expand All @@ -164,6 +175,20 @@ public Key(Object key) {
this.remoteJid = XposedHelpers.getObjectField(key, "A00");
}

public void setIsFromMe(boolean value) {
XposedHelpers.setBooleanField(thisObject, "A02", value);
this.isFromMe = value;
}

public void setRemoteJid(Object value) {
XposedHelpers.setObjectField(thisObject, "A00", value);
this.remoteJid = value;
}

public void setMessageID(String messageID) {
XposedHelpers.setObjectField(thisObject, "A01", messageID);
this.messageID = messageID;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.Log;
Expand Down Expand Up @@ -223,6 +224,39 @@ public synchronized static Method loadForwardTagMethod(ClassLoader classLoader)
});
}

public synchronized static Field loadBroadcastTagField(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getField(classLoader, () -> {
var fmessage = loadFMessageClass(classLoader);
var clazzData = dexkit.findClass(FindClass.create().matcher(ClassMatcher.create().addUsingString("UPDATE_MESSAGE_MAIN_BROADCAST_SCAN_SQL")));
if (clazzData.isEmpty()) return new Exception("BroadcastTag class not found");
var methodData = dexkit.findMethod(FindMethod.create().searchInClass(clazzData).matcher(MethodMatcher.create().usingStrings("participant_hash", "view_mode", "broadcast")));
if (methodData.isEmpty()) throw new Exception("BroadcastTag method support not found");
var usingFields = methodData.get(0).getUsingFields();
for (var ufield : usingFields) {
var field = ufield.getField();
if (field.getDeclaredClass().getName().equals(fmessage.getName()) &&
field.getType().getName().equals(boolean.class.getName())
) {
return field.getFieldInstance(classLoader);
}
}
throw new Exception("BroadcastTag field not found");
});
}

public synchronized static Method loadBroadcastTagMethod(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
var field = loadBroadcastTagField(classLoader);
var clazzData = dexkit.findClass(FindClass.create().matcher(ClassMatcher.create().addUsingString("ConversationRow/setUpUserNameInGroupView")));
if (clazzData.isEmpty())
throw new Exception("BroadcastTag: ConversationRow Class not found");
var method = dexkit.findMethod(FindMethod.create().searchInClass(clazzData).matcher(MethodMatcher.create().addUsingField(DexSignUtil.getFieldDescriptor(field))));
if (method.isEmpty())
throw new Exception("BroadcastTag: ConversationRow Method not found");
return method.get(0).getMethodInstance(classLoader);
});
}

public synchronized static Class<?> loadForwardClassMethod(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getClass(classLoader, () -> findFirstClassUsingStrings(classLoader, StringMatchType.Contains, "UserActions/userActionForwardMessage"));
}
Expand Down Expand Up @@ -779,7 +813,7 @@ public synchronized static Method[] loadArchiveHideViewMethod(ClassLoader loader

public synchronized static Method loadAntiRevokeOnCallReceivedMethod(ClassLoader loader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(loader, () -> {
var method = findFirstMethodUsingStrings(loader, StringMatchType.Contains, "VoiceService:callStateChangedOnUiThread");
var method = findFirstMethodUsingStrings(loader, StringMatchType.Contains, "voip/callStateChangedOnUIThread");
if (method == null) throw new Exception("OnCallReceiver method not found");
return method;
});
Expand Down Expand Up @@ -1656,11 +1690,23 @@ public synchronized static Method loadBubbleDrawableMethod(ClassLoader classLoad
});
}

public synchronized static Method loadDateWrapper(ClassLoader classLoader) throws Exception {
public synchronized static Method loadBallonDateDrawable(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
var methodData = dexkit.findMethod(FindMethod.create().matcher(MethodMatcher.create().name("getDateWrapperBackground")));
var methodData = dexkit.findMethod(FindMethod.create().matcher(MethodMatcher.create().addUsingString("Unreachable code: direction=").returnType(Rect.class)));
if (methodData.isEmpty()) throw new Exception("LoadDateWrapper method not found");
return methodData.get(0).getMethodInstance(classLoader);
var clazz = methodData.get(0).getMethodInstance(classLoader).getDeclaringClass();
var method = ReflectionUtils.findMethodUsingFilterIfExists(clazz, m -> List.of(1, 2).contains(m.getParameterCount()) && m.getParameterTypes()[0].equals(int.class) && m.getReturnType().equals(Drawable.class));
if (method == null) throw new RuntimeException("DateWrapper method not found");
return method;
});
}

public synchronized static Method loadBallonBorderDrawable(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
var clazz = loadBallonDateDrawable(classLoader).getDeclaringClass();
var method = ReflectionUtils.findMethodUsingFilterIfExists(clazz, m -> m.getParameterCount() == 3 && m.getReturnType().equals(Drawable.class));
if (method == null) throw new RuntimeException("Ballon Border method not found");
return method;
});
}

Expand Down Expand Up @@ -1754,4 +1800,20 @@ public static Method loadMediaQualitySelectionMethod(ClassLoader classLoader) th
return methodData.get(0).getMethodInstance(classLoader);
});
}

public static Field loadFmessageTimestampField(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getField(classLoader, () -> {
var fmessageClass = loadFMessageClass(classLoader);
var chatLimitDelete2Method = Unobfuscator.loadChatLimitDelete2Method(classLoader);
var usingFields = dexkit.getMethodData(chatLimitDelete2Method).getUsingFields();
for (var uField : usingFields) {
var field = uField.getField();
if (field.getDeclaredClass().getName().equals(fmessageClass.getName())
&& field.getType().getName().equals(long.class.getName())) {
return field.getFieldInstance(classLoader);
}
}
throw new RuntimeException("FMessage Timestamp method not found");
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import androidx.annotation.NonNull;

import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.components.FMessageWpp;
import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator;
import com.wmods.wppenhacer.xposed.utils.DesignUtils;
import com.wmods.wppenhacer.xposed.utils.Utils;
Expand All @@ -21,7 +20,6 @@
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 BubbleColors extends Feature {
public BubbleColors(ClassLoader loader, XSharedPreferences preferences) {
Expand Down Expand Up @@ -90,25 +88,40 @@ public void doHook() throws Exception {
}
}

var dateWrapper = Unobfuscator.loadDateWrapper(classLoader);
var dateWrapper = Unobfuscator.loadBallonDateDrawable(classLoader);

XposedBridge.hookMethod(dateWrapper, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var fmessageObject = XposedHelpers.callMethod(param.thisObject, "getFMessage");
if (fmessageObject == null) return;
var view = (Drawable) param.getResult();
var fmessage = new FMessageWpp(fmessageObject);
if (fmessage.getKey().isFromMe) {
var drawable = (Drawable) param.getResult();
var position = (int) param.args[0];
if (position == 3) {
if (bubbleRightColor == 0) return;
view.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
drawable.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
} else {
if (bubbleLeftColor == 0) return;
view.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
drawable.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
}
}
});

var babblon = Unobfuscator.loadBallonBorderDrawable(classLoader);
XposedBridge.hookMethod(babblon, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var drawable = (Drawable) param.getResult();
var position = (int) param.args[1];
if (position == 3) {
if (bubbleRightColor == 0) return;
drawable.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
} else {
if (bubbleLeftColor == 0) return;
drawable.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
}
}
});


var bubbleDrawableMethod = Unobfuscator.loadBubbleDrawableMethod(classLoader);

XposedBridge.hookMethod(bubbleDrawableMethod, new XC_MethodHook() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
Expand All @@ -16,7 +14,7 @@
import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.WppCore;
import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator;
import com.wmods.wppenhacer.xposed.utils.DesignUtils;
import com.wmods.wppenhacer.xposed.features.general.Others;
import com.wmods.wppenhacer.xposed.utils.ReflectionUtils;
import com.wmods.wppenhacer.xposed.utils.ResId;
import com.wmods.wppenhacer.xposed.utils.Utils;
Expand Down Expand Up @@ -48,6 +46,8 @@ public void doHook() throws Exception {
var typeArchive = prefs.getString("typearchive", "0");
var methodHook = new MethodHook(showName, showBio, typeArchive);
XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onCreate", Bundle.class, methodHook);
Others.propsBoolean.put(6481, false);
Others.propsBoolean.put(5353, true);
expirationAboutInfo();
}

Expand Down Expand Up @@ -104,7 +104,7 @@ public MethodHook(boolean showName, boolean showBio, String typeArchive) {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var homeActivity = (Activity) param.thisObject;
var actionbar = XposedHelpers.callMethod(homeActivity, "getSupportActionBar");
var toolbar = homeActivity.findViewById(Utils.getID("toolbar", "id"));
var toolbar = (ViewGroup) homeActivity.findViewById(Utils.getID("toolbar", "id"));
var logo = toolbar.findViewById(Utils.getID("toolbar_logo", "id"));
var name = WppCore.getMyName();
var bio = WppCore.getMyBio();
Expand Down Expand Up @@ -132,47 +132,37 @@ public void onMultiClick(View v) {

if (!showBio && !showName) return;

if (!(logo.getParent() instanceof LinearLayout parent)) {
var methods = Arrays.stream(actionbar.getClass().getDeclaredMethods()).filter(m -> m.getParameterCount() == 1 && m.getParameterTypes()[0] == CharSequence.class).toArray(Method[]::new);
var methods = Arrays.stream(actionbar.getClass().getDeclaredMethods()).filter(m -> m.getParameterCount() == 1 && m.getParameterTypes()[0] == CharSequence.class).toArray(Method[]::new);

if (showName) {
methods[1].invoke(actionbar, name);
}

if (showBio) {
methods[0].invoke(actionbar, bio);
}
XposedBridge.hookMethod(methods[1], new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (showName) {
param.args[0] = name;
}
}
});
return;
if (showName) {
methods[1].invoke(actionbar, name);
}
var mTitle = new TextView(homeActivity);
mTitle.setText(showName ? name : "WhatsApp");
mTitle.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT, 1f));
mTitle.setTextSize(20f);
mTitle.setTextColor(DesignUtils.getPrimaryTextColor());
parent.addView(mTitle);

if (showBio) {
TextView mSubtitle = new TextView(homeActivity);
mSubtitle.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
mSubtitle.setText(bio);
mSubtitle.setTextSize(12f);
mSubtitle.setTextColor(DesignUtils.getPrimaryTextColor());
mSubtitle.setMarqueeRepeatLimit(-1);
mSubtitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
mSubtitle.setSingleLine();
mSubtitle.setSelected(true);
parent.addView(mSubtitle);
} else {
mTitle.setGravity(Gravity.CENTER);
methods[0].invoke(actionbar, bio);
}
parent.removeView(logo);

XposedBridge.hookMethod(methods[1], new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
var name = WppCore.getMyName();
var bio = WppCore.getMyBio();
if (showBio && (param.args[0] == "" || param.args[0] == "WhatsApp")) {
ReflectionUtils.callMethod(methods[0], param.thisObject, bio);
} else {
ReflectionUtils.callMethod(methods[0], param.thisObject, "");
}
if (showName && (param.args[0] == "" || param.args[0] == "WhatsApp")) {
param.args[0] = name;
}

var layoutParams = logo.getLayoutParams();
layoutParams.width = 1;
layoutParams.height = 1;
logo.setLayoutParams(layoutParams);

}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,14 @@ public boolean addAll(@NonNull Collection c) {
}

private boolean checkGroup(Object chat) {
var requiredServer = isGroup ? "g.us" : "s.whatsapp.net";
var jid = getObjectField(chat, "A00");
if (jid == null) jid = getObjectField(chat, "A01");
if (jid == null) return true;
if (XposedHelpers.findMethodExactIfExists(jid.getClass(), "getServer") != null) {
var server = (String) callMethod(jid, "getServer");
return server.equals(requiredServer);
if (isGroup)
return server.equals("broadcast") || server.equals("g.us");
return server.equals("s.whatsapp.net");
}
return true;
}
Expand Down
Loading

0 comments on commit ee06a3e

Please sign in to comment.