Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});

XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", loader, "onCreate", Bundle.class, new XC_MethodHook() {
XposedHelpers.findAndHookMethod(WppCore.getHomeActivityClass(loader), "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/com/wmods/wppenhacer/xposed/core/WppCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ public static Activity getCurrentActivity() {
return mCurrentActivity;
}

public synchronized static Class getHomeActivityClass(@NonNull ClassLoader loader) {
Class oldHomeClass = XposedHelpers.findClassIfExists("com.whatsapp.HomeActivity", loader);

return oldHomeClass != null
? oldHomeClass
: XposedHelpers.findClass("com.whatsapp.home.ui.HomeActivity", loader);
}

public synchronized static Class getTabsPagerClass(@NonNull ClassLoader loader) {
Class oldHomeClass = XposedHelpers.findClassIfExists("com.whatsapp.TabsPager", loader);

return oldHomeClass != null
? oldHomeClass
: XposedHelpers.findClass("com.whatsapp.home.ui.TabsPager", loader);
}

// public static Activity getActivityBySimpleName(String name) {
// for (var activity : activities) {
// if (activity.getClass().getSimpleName().equals(name)) {
Expand Down Expand Up @@ -386,7 +402,7 @@ public static Activity getCurrentConversation() {

// for tablet UI, they're using HomeActivity instead of Conversation
// TODO: Add more checks for ConversationFragment
Class<?> home = XposedHelpers.findClass("com.whatsapp.HomeActivity", mCurrentActivity.getClassLoader());
Class<?> home = getHomeActivityClass(mCurrentActivity.getClassLoader());
if (mCurrentActivity.getResources().getConfiguration().smallestScreenWidthDp >= 600 && home.isInstance(mCurrentActivity))
return mCurrentActivity;
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.widget.FrameLayout;
import android.widget.TextView;

import com.wmods.wppenhacer.xposed.core.WppCore;
import com.wmods.wppenhacer.xposed.utils.ReflectionUtils;
import com.wmods.wppenhacer.xposed.utils.Utils;

Expand Down Expand Up @@ -1860,7 +1861,7 @@ public static Method loadChangeTitleLogoMethod(ClassLoader classLoader) throws E
public static Field loadChangeTitleLogoField(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getField(classLoader, () -> {
var methodData = dexkit.getMethodData(loadChangeTitleLogoMethod(classLoader));
var clazz = XposedHelpers.findClass("com.whatsapp.HomeActivity", classLoader);
var clazz = WppCore.getHomeActivityClass(classLoader);
var usingFields = methodData.getUsingFields();
for (var uField : usingFields) {
var field = uField.getField().getFieldInstance(classLoader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ private void hookWallpaper() throws Exception {
replaceTransparency(toolbarAlpha, (100 - wallpaperToolbarAlpha) / 100.0f);
}

var clazz = XposedHelpers.findClass("com.whatsapp.HomeActivity", classLoader);
XposedHelpers.findAndHookMethod(clazz, "onCreate", Bundle.class, new XC_MethodHook() {
var homeActivityClass = WppCore.getHomeActivityClass(classLoader);
XposedHelpers.findAndHookMethod(homeActivityClass, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var activity = (Activity) param.thisObject;
Expand All @@ -125,10 +125,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {

var revertWallAlpha = revertColors(wallAlpha);

var homeClass = XposedHelpers.findClass("com.whatsapp.HomeActivity", classLoader);

WppCore.addListenerActivity((activity, type) -> {
var isHome = homeClass.isInstance(activity);
var isHome = homeActivityClass.isInstance(activity);
if (WppCore.ActivityChangeState.ChangeType.RESUMED == type && isHome) {
mMainContainer = activity.findViewById(android.R.id.content);
if (mMainContainer != null) {
Expand Down Expand Up @@ -275,7 +273,7 @@ private void injectWallpaper(View view) {
}

private boolean checkNotHomeActivity() {
var homeClass = XposedHelpers.findClass("com.whatsapp.HomeActivity", classLoader);
var homeClass = WppCore.getHomeActivityClass(classLoader);
var currentActivity = WppCore.getCurrentActivity();
return (currentActivity == null || !homeClass.isInstance(currentActivity));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void doHook() throws Exception {
var typeArchive = prefs.getString("typearchive", "0");
onMenuItemSelected = Unobfuscator.loadOnMenuItemSelected(classLoader);
var methodHook = new MethodHook(showName, showBio, typeArchive);
XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onCreate", Bundle.class, methodHook);
XposedHelpers.findAndHookMethod(WppCore.getHomeActivityClass(classLoader), "onCreate", Bundle.class, methodHook);
expirationAboutInfo();
Others.propsBoolean.put(6481, false);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var name = WppCore.getMyName();
var bio = WppCore.getMyBio();
var window = (ViewGroup) homeActivity.getWindow().getDecorView();
var clazz = XposedHelpers.findClass("com.whatsapp.TabsPager", homeActivity.getClassLoader());
var clazz = WppCore.getTabsPagerClass(homeActivity.getClassLoader());
var fieldTab = ReflectionUtils.getFieldByType(homeActivity.getClass(), clazz);
var mTabInstance = fieldTab.get(homeActivity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import androidx.annotation.NonNull;

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.ReflectionUtils;

Expand Down Expand Up @@ -37,7 +38,7 @@ public void doHook() throws Throwable {
if (hidetabs == null || hidetabs.isEmpty())
return;

var home = XposedHelpers.findClass("com.whatsapp.HomeActivity", classLoader);
var home = WppCore.getHomeActivityClass(classLoader);

var hideTabsList = hidetabs.stream().map(Integer::valueOf).collect(Collectors.toList());

Expand Down Expand Up @@ -93,10 +94,10 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});

XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
XposedHelpers.findAndHookMethod(WppCore.getHomeActivityClass(classLoader), "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Class<?> TabsPagerClass = classLoader.loadClass("com.whatsapp.TabsPager");
Class<?> TabsPagerClass = WppCore.getTabsPagerClass(classLoader);
var tabsField = ReflectionUtils.getFieldByType(param.thisObject.getClass(), TabsPagerClass);
mTabPagerInstance = tabsField.get(param.thisObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import androidx.annotation.NonNull;

import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.WppCore;
import com.wmods.wppenhacer.xposed.core.db.MessageStore;
import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator;
import com.wmods.wppenhacer.xposed.core.devkit.UnobfuscatorCache;
Expand Down Expand Up @@ -47,7 +48,7 @@ public SeparateGroup(ClassLoader loader, XSharedPreferences preferences) {
public void doHook() throws Exception {

var cFragClass = XposedHelpers.findClass("com.whatsapp.conversationslist.ConversationsFragment", classLoader);
var homeActivityClass = XposedHelpers.findClass("com.whatsapp.HomeActivity", classLoader);
var homeActivityClass = WppCore.getHomeActivityClass(classLoader);

if (!prefs.getBoolean("separategroups", false)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import androidx.annotation.NonNull;

import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.WppCore;
import com.wmods.wppenhacer.xposed.core.db.MessageStore;
import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator;
import com.wmods.wppenhacer.xposed.utils.ReflectionUtils;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void doHook() throws Throwable {

var epUpdateMethod = Unobfuscator.loadEphemeralInsertdb(classLoader);

XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
XposedHelpers.findAndHookMethod(WppCore.getHomeActivityClass(classLoader), "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (antiDisappearing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void doHook() throws Throwable {

menuItems.add(this::InsertDownloadFolderButton);

XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
XposedHelpers.findAndHookMethod(WppCore.getHomeActivityClass(classLoader), "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var activity = (Activity) param.thisObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import androidx.annotation.NonNull;

import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.WppCore;
import com.wmods.wppenhacer.xposed.core.components.AlertDialogWpp;
import com.wmods.wppenhacer.xposed.utils.DesignUtils;
import com.wmods.wppenhacer.xposed.utils.ResId;
Expand All @@ -31,7 +32,7 @@ public NewChat(@NonNull ClassLoader loader, @NonNull XSharedPreferences preferen

@Override
public void doHook() {
var homeActivity = findClass("com.whatsapp.HomeActivity", classLoader);
var homeActivity = WppCore.getHomeActivityClass(classLoader);
var action = prefs.getBoolean("buttonaction", true);
if (!prefs.getBoolean("newchat", true)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}

private void hookMenuOptions(String filterChats) {
XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onPrepareOptionsMenu", Menu.class, new XC_MethodHook() {
XposedHelpers.findAndHookMethod(WppCore.getHomeActivityClass(classLoader), "onPrepareOptionsMenu", Menu.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var menu = (Menu) param.args[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import androidx.annotation.NonNull;

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.ReflectionUtils;
import com.wmods.wppenhacer.xposed.utils.Utils;
Expand Down Expand Up @@ -74,7 +75,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
});

if (channels) {
XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onPrepareOptionsMenu", Menu.class, new XC_MethodHook() {
XposedHelpers.findAndHookMethod(WppCore.getHomeActivityClass(classLoader), "onPrepareOptionsMenu", Menu.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
var menu = (Menu) param.args[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private void InsertFreezeLastSeenOption(Menu menu, Activity activity, boolean ne
}

private void hookMenu() {
XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onCreateOptionsMenu", Menu.class, new XC_MethodHook() {
XposedHelpers.findAndHookMethod(WppCore.getHomeActivityClass(classLoader), "onCreateOptionsMenu", Menu.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var menu = (Menu) param.args[0];
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,15 @@
<item>2.25.3.xx</item>
<item>2.25.4.xx</item>
<item>2.25.5.xx</item>
<item>2.25.6.xx</item>
</string-array>
<string-array name="supported_versions_business">
<item>2.25.1.xx</item>
<item>2.25.2.xx</item>
<item>2.25.3.xx</item>
<item>2.25.4.xx</item>
<item>2.25.5.xx</item>
<item>2.25.6.xx</item>
</string-array>
<string-array name="image_picker">
<item>image/*</item>
Expand Down