Skip to content

Commit

Permalink
add pre-support to version 2.2.24.13.xx
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev4Mod committed Jul 1, 2024
1 parent e494878 commit 533b889
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,22 @@ public static Class<?> loadStatusDownloadMediaClass(ClassLoader classLoader) thr

public static Class loadMenuStatusClass(ClassLoader loader) throws Exception {
return UnobfuscatorCache.getInstance().getClass(loader, () -> {
var classList = dexkit.findClass(new FindClass().matcher(new ClassMatcher().addMethod(new MethodMatcher().addUsingString("chatSettingsStore", StringMatchType.Equals).name("onClick"))));
var id = Utils.getID("menuitem_conversations_message_contact", "id");
var classList = dexkit.findClass(new FindClass().matcher(new ClassMatcher().addMethod(new MethodMatcher().addUsingNumber(id))));
if (classList.isEmpty()) throw new Exception("MenuStatus class not found");
return classList.get(0).getInstance(loader);
});
}

public static Method loadMenuStatusMethod(ClassLoader loader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(loader, () -> {
var id = Utils.getID("menuitem_conversations_message_contact", "id");
var methods = dexkit.findMethod(new FindMethod().matcher(new MethodMatcher().addUsingNumber(id)));
if (methods.isEmpty()) throw new Exception("MenuStatus method not found");
return methods.get(0).getMethodInstance(loader);
});
}

public static Field loadStatusDownloadFileField(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getField(classLoader, () -> {
var clazz = loadStatusDownloadMediaClass(classLoader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
});
}

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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void doHook() throws Throwable {
var onCreateTabList = Unobfuscator.loadTabListMethod(classLoader);
logDebug(Unobfuscator.getMethodDescriptor(onCreateTabList));
var ListField = Unobfuscator.getFieldByType(home, List.class);

XposedBridge.hookMethod(onCreateTabList, new XC_MethodHook() {
@Override
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ public void doHook() throws Throwable {
var item = new MenuStatus.MenuItemStatus() {

@Override
public MenuItem addMenu(Menu menu) {
public MenuItem addMenu(Menu menu, FMessageWpp fMessage) {
if (menu.findItem(ResId.string.delete_for_me) != null) return null;
if (fMessage.getKey().isFromMe) return null;
return menu.add(0, ResId.string.delete_for_me, 0, ResId.string.delete_for_me);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.NonNull;

Expand All @@ -17,6 +16,7 @@

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 MenuStatus extends Feature {
Expand All @@ -32,8 +32,9 @@ public void doHook() throws Throwable {

var mediaClass = Unobfuscator.loadStatusDownloadMediaClass(classLoader);
logDebug("Media class: " + mediaClass.getName());
var menuStatusClass = Unobfuscator.loadMenuStatusClass(classLoader);
logDebug("MenuStatus class: " + menuStatusClass.getName());
// var menuStatusClass = Unobfuscator.loadMenuStatusClass(classLoader);
var menuStatusMethod = Unobfuscator.loadMenuStatusMethod(classLoader);
logDebug("MenuStatus method: " + menuStatusMethod.getName());
var fieldFile = Unobfuscator.loadStatusDownloadFileField(classLoader);
logDebug("File field: " + fieldFile.getName());
var clazzSubMenu = Unobfuscator.loadStatusDownloadSubMenuClass(classLoader);
Expand All @@ -47,24 +48,33 @@ public void doHook() throws Throwable {
Class<?> StatusPlaybackContactFragmentClass = classLoader.loadClass("com.whatsapp.status.playback.fragment.StatusPlaybackContactFragment");
var listStatusField = ReflectionUtils.getFieldsByExtendType(StatusPlaybackContactFragmentClass, List.class).get(0);

XposedHelpers.findAndHookMethod(menuStatusClass, "onClick", View.class, new XC_MethodHook() {
XposedBridge.hookMethod(menuStatusMethod, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var clazz = param.thisObject.getClass();
Field subMenuField = ReflectionUtils.findFieldUsingFilter(clazz, f -> f.getType() == Object.class && clazzSubMenu.isInstance(ReflectionUtils.getField(f, param.thisObject)));
Object subMenu = ReflectionUtils.getField(subMenuField, param.thisObject);
var fragment = ReflectionUtils.findFieldUsingFilter(clazz, f -> StatusPlaybackBaseFragmentClass.isInstance(ReflectionUtils.getField(f, param.thisObject)));
if (fragment == null) {
logDebug("Fragment not found");
return;
Object fragmentInstance;
Menu menu;
if (param.args[0] instanceof Menu) {
menu = (Menu) param.args[0];
fragmentInstance = param.thisObject;
} else {
var clazz = param.thisObject.getClass();
Field subMenuField = ReflectionUtils.findFieldUsingFilter(clazz, f -> f.getType() == Object.class && clazzSubMenu.isInstance(ReflectionUtils.getField(f, param.thisObject)));
Object subMenu = ReflectionUtils.getField(subMenuField, param.thisObject);
menu = (Menu) ReflectionUtils.getField(menuField, subMenu);
var fragment = ReflectionUtils.findFieldUsingFilter(clazz, f -> StatusPlaybackBaseFragmentClass.isInstance(ReflectionUtils.getField(f, param.thisObject)));
if (fragment == null) {
logDebug("Fragment not found");
return;
}
fragmentInstance = fragment.get(param.thisObject);
}
var fragmentInstance = fragment.get(param.thisObject);

var index = (int) XposedHelpers.getObjectField(fragmentInstance, "A00");
var listStatus = (List) listStatusField.get(fragmentInstance);
var fMessage = new FMessageWpp(listStatus.get(index));
var menu = (Menu) ReflectionUtils.getField(menuField, subMenu);

for (MenuItemStatus menuStatus : menuStatuses) {
var menuItem = menuStatus.addMenu(menu);
var menuItem = menuStatus.addMenu(menu, fMessage);
if (menuItem == null) continue;
menuItem.setOnMenuItemClickListener(item -> {
menuStatus.onClick(item, fragmentInstance, fMessage);
Expand All @@ -83,7 +93,7 @@ public String getPluginName() {

public abstract static class MenuItemStatus {

public abstract MenuItem addMenu(Menu menu);
public abstract MenuItem addMenu(Menu menu, FMessageWpp fMessage);

public abstract void onClick(MenuItem item, Object fragmentInstance, FMessageWpp fMessageWpp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public void doHook() throws Exception {
var downloadStatus = new MenuStatus.MenuItemStatus() {

@Override
public MenuItem addMenu(Menu menu) {
public MenuItem addMenu(Menu menu, FMessageWpp fMessage) {
if (menu.findItem(ResId.string.download) != null) return null;
if (fMessage.getKey().isFromMe) return null;
return menu.add(0, ResId.string.download, 0, ResId.string.download);
}

Expand All @@ -67,7 +68,8 @@ public void onClick(MenuItem item, Object fragmentInstance, FMessageWpp fMessage
var sharedMenu = new MenuStatus.MenuItemStatus() {

@Override
public MenuItem addMenu(Menu menu) {
public MenuItem addMenu(Menu menu, FMessageWpp fMessage) {
if (fMessage.getKey().isFromMe) return null;
if (menu.findItem(ResId.string.share_as_status) != null) return null;
return menu.add(0, ResId.string.share_as_status, 0, ResId.string.share_as_status);
}
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@
<item>2.24.12.71</item>
<item>2.24.12.73</item>
<item>2.24.12.78</item>
<item>2.24.13.71</item>
<item>2.24.13.72</item>
<item>2.24.13.73</item>
<item>2.24.13.74</item>
<item>2.24.13.75</item>
</string-array>
<string-array name="supported_versions_business">
<item>2.24.11.83</item>
Expand All @@ -141,6 +146,5 @@
<item>@string/audio_note</item>
<item>@string/voice_note</item>
</string-array>
<string name="click_times">Click 5 times on the WhatsApp title</string>
<string name="hold_title">Hold on WhatsApp title</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,4 +304,6 @@
<string name="select_a_color">Select a color</string>
<string name="custom_appearance">Custom Appearance</string>
<string name="custom_filters_sum">Activate filters by ID and Custom CSS</string>
<string name="click_times">Click 5 times on the WhatsApp title</string>
<string name="hold_title">Hold on WhatsApp title</string>
</resources>

0 comments on commit 533b889

Please sign in to comment.