Skip to content

Commit b731bac

Browse files
committed
Fix bug in text composer WA 2.25.5.72
Signed-off-by: Dev4Mod <[email protected]>
1 parent fbcfaf5 commit b731bac

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/Unobfuscator.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,19 +1591,7 @@ public synchronized static Class loadListChannelItemClass(ClassLoader classLoade
15911591
}
15921592

15931593
public synchronized static Method loadTextStatusComposer(ClassLoader classLoader) throws Exception {
1594-
var methods = dexkit.findMethod(FindMethod.create().matcher(MethodMatcher.create().addUsingString("background_color_key", StringMatchType.Equals)));
1595-
for (MethodData method : methods) {
1596-
var targetMethod = method.getDeclaredClass().findMethod(
1597-
FindMethod.create().matcher(
1598-
MethodMatcher.create().returnType(int.class).paramCount(1)
1599-
)
1600-
);
1601-
1602-
if (!targetMethod.isEmpty()) {
1603-
return targetMethod.single().getMethodInstance(classLoader);
1604-
}
1605-
}
1606-
return null;
1594+
return findFirstMethodUsingStrings(classLoader, StringMatchType.Contains, "Can't put value with type");
16071595
}
16081596

16091597
public synchronized static Method loadTextStatusComposer2(ClassLoader classLoader) throws Exception {
@@ -1814,11 +1802,18 @@ public static Class<?> loadFragmentClass(ClassLoader classLoader) throws Excepti
18141802

18151803
public static Method loadMediaQualitySelectionMethod(ClassLoader classLoader) throws Exception {
18161804
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
1817-
var classData = dexkit.getClassData("com.whatsapp.mediacomposer.MediaComposerActivity");
1818-
var methodData = Objects.requireNonNull(classData).findMethod(FindMethod.create().matcher(
1819-
MethodMatcher.create().addUsingNumber(6033).
1805+
var methodData = dexkit.findMethod(FindMethod.create().matcher(
1806+
MethodMatcher.create().addUsingString("enable_media_quality_tool").
18201807
returnType(boolean.class)
18211808
));
1809+
1810+
if (methodData.isEmpty()) {
1811+
methodData = dexkit.findMethod(FindMethod.create().matcher(
1812+
MethodMatcher.create().addUsingString("show_media_quality_toggle").
1813+
returnType(boolean.class)
1814+
));
1815+
}
1816+
18221817
if (methodData.isEmpty())
18231818
throw new RuntimeException("MediaQualitySelection method not found");
18241819
return methodData.single().getMethodInstance(classLoader);

app/src/main/java/com/wmods/wppenhacer/xposed/features/others/TextStatusComposer.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ public void doHook() throws Throwable {
3838
var setColorTextComposer = Unobfuscator.loadTextStatusComposer(classLoader);
3939
log("setColorTextComposer: " + Unobfuscator.getMethodDescriptor(setColorTextComposer));
4040

41-
if (setColorTextComposer != null) {
42-
XposedBridge.hookAllConstructors(setColorTextComposer.getDeclaringClass(), new XC_MethodHook() {
41+
var textModelClass = XposedHelpers.findClassIfExists("com.whatsapp.statuscomposer.composer.TextStatusComposerViewModel", classLoader);
42+
43+
if (textModelClass != null) {
44+
XposedBridge.hookAllConstructors(textModelClass, new XC_MethodHook() {
4345
@Override
4446
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
4547
textComposerModel.set(param.thisObject);
4648
}
4749
});
48-
var arrMethod = ReflectionUtils.findMethodUsingFilter(setColorTextComposer.getDeclaringClass(), method -> method.getParameterCount() == 1 && method.getParameterTypes()[0] == int.class && method.getReturnType() == int.class);
50+
var arrMethod = ReflectionUtils.findMethodUsingFilter(textModelClass, method -> method.getParameterCount() == 1 && method.getParameterTypes()[0] == int.class && method.getReturnType() == int.class);
4951
XposedBridge.hookMethod(arrMethod, new XC_MethodHook() {
5052
@Override
5153
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
@@ -73,9 +75,11 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
7375
pickerColor.setOnLongClickListener(v -> {
7476
var dialog = new SimpleColorPickerDialog(activity, color -> {
7577
try {
76-
if (setColorTextComposer != null) {
77-
var mInstance = textComposerModel.get();
78-
ReflectionUtils.callMethod(setColorTextComposer, mInstance, color);
78+
if (textModelClass != null) {
79+
var textModel = textComposerModel.get();
80+
var mField = ReflectionUtils.getFieldsByType(textModel.getClass(), setColorTextComposer.getDeclaringClass()).get(0);
81+
var auxInstance = ReflectionUtils.getObjectField(mField, textModel);
82+
ReflectionUtils.callMethod(setColorTextComposer, auxInstance, "background_color_key", color);
7983
} else {
8084
Field fieldInt = ReflectionUtils.getFieldByType(param.thisObject.getClass(), int.class);
8185
fieldInt.setInt(param.thisObject, color);

0 commit comments

Comments
 (0)