From bb076198632699ca6eb82b2a37a33d7559fd4326 Mon Sep 17 00:00:00 2001 From: Dev4Mod Date: Tue, 25 Jun 2024 20:05:33 -0300 Subject: [PATCH] fix bug in channels --- .../xposed/core/devkit/Unobfuscator.java | 54 +++++++++++++------ .../features/customization/CustomView.java | 4 -- .../xposed/features/others/Channels.java | 20 +++++++ changelog.txt | 21 +------- 4 files changed, 60 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/Unobfuscator.java b/app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/Unobfuscator.java index 17937971..de1a3384 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/Unobfuscator.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/Unobfuscator.java @@ -1584,26 +1584,50 @@ public static Method loadPlaybackSpeed(ClassLoader classLoader) throws Exception }); } - public static Method loadArchiveCheckLockedChatsMethod(ClassLoader classLoader) throws Exception { - var method = findFirstMethodUsingStrings(classLoader, StringMatchType.Contains, "conversationsfragment/verticalswipetorevealbehavior"); - if (method == null) throw new RuntimeException("ArchiveCheckLockedChats method not found"); - return method; - } +// public static Method loadArchiveCheckLockedChatsMethod(ClassLoader classLoader) throws Exception { +// var method = findFirstMethodUsingStrings(classLoader, StringMatchType.Contains, "conversationsfragment/verticalswipetorevealbehavior"); +// if (method == null) throw new RuntimeException("ArchiveCheckLockedChats method not found"); +// return method; +// } +// +// public static Method loadArchiveCheckLockedChatsMethod2(ClassLoader classLoader) throws Exception { +// var methods = findAllMethodUsingStrings(classLoader, StringMatchType.Contains, "registration_device_id"); +// if (methods.length == 0) +// throw new RuntimeException("ArchiveCheckLockedChats method not found"); +// return Arrays.stream(methods).filter(m -> m.getReturnType().equals(boolean.class) && m.getParameterTypes().length == 0).findFirst().orElse(null); +// } +// +// public static Class loadArchiveLockedChatClass(ClassLoader classLoader) throws Exception { +// return UnobfuscatorCache.getInstance().getClass(classLoader, () -> { +// var clazzList = dexkit.findClass(new FindClass().matcher(new ClassMatcher().addMethod(new MethodMatcher().name("setLockedRowVisibility")).addMethod(new MethodMatcher().name("setEnableStateForChatLock")))); +// if (clazzList.isEmpty()) +// throw new RuntimeException("ArchiveLockedChatFrame class not found"); +// return clazzList.get(0).getInstance(classLoader); +// }); +// } - public static Method loadArchiveCheckLockedChatsMethod2(ClassLoader classLoader) throws Exception { - var methods = findAllMethodUsingStrings(classLoader, StringMatchType.Contains, "registration_device_id"); - if (methods.length == 0) - throw new RuntimeException("ArchiveCheckLockedChats method not found"); - return Arrays.stream(methods).filter(m -> m.getReturnType().equals(boolean.class) && m.getParameterTypes().length == 0).findFirst().orElse(null); + public static Constructor loadListUpdateItemsConstructor(ClassLoader classLoader) throws Exception { + return UnobfuscatorCache.getInstance().getConstructor(classLoader, () -> { + var method = dexkit.findMethod(new FindMethod().matcher(new MethodMatcher().paramCount(1).returnType(void.class).addParamType(Object.class).addUsingNumber(8686))); + if (method.isEmpty()) + throw new RuntimeException("ListUpdateItems method not found"); + return method.get(0).getClassInstance(classLoader).getConstructors()[0]; + }); } - public static Class loadArchiveLockedChatClass(ClassLoader classLoader) throws Exception { + public static Class loadHeaderChannelItemClass(ClassLoader classLoader) throws Exception { return UnobfuscatorCache.getInstance().getClass(classLoader, () -> { - var clazzList = dexkit.findClass(new FindClass().matcher(new ClassMatcher().addMethod(new MethodMatcher().name("setLockedRowVisibility")).addMethod(new MethodMatcher().name("setEnableStateForChatLock")))); - if (clazzList.isEmpty()) - throw new RuntimeException("ArchiveLockedChatFrame class not found"); - return clazzList.get(0).getInstance(classLoader); + var clazz = findFirstClassUsingStrings(classLoader, StringMatchType.Contains, "NewsletterHeaderDataItem"); + if (clazz == null) throw new RuntimeException("HeaderChannelItem class not found"); + return clazz; }); } + public static Class loadListChannelItemClass(ClassLoader classLoader) throws Exception { + return UnobfuscatorCache.getInstance().getClass(classLoader, () -> { + var clazz = findFirstClassUsingStrings(classLoader, StringMatchType.Contains, "NewsletterDataItem", "isMuteIndicatorEnabled"); + if (clazz == null) throw new RuntimeException("HeaderChannelItem class not found"); + return clazz; + }); + } } diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomView.java b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomView.java index 390fbac6..aa59bcda 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomView.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomView.java @@ -76,10 +76,6 @@ public CustomView(@NonNull ClassLoader loader, @NonNull XSharedPreferences prefe @Override public void doHook() throws Throwable { var filter_itens = prefs.getString("css_theme", ""); - var channels = prefs.getBoolean("channels", false); - if (channels) { - filter_itens = "#updates_list RelativeLayout,#updates_list ViewGroup:nth-child(4){display:none}\n" + filter_itens; - } if (TextUtils.isEmpty(filter_itens)) return; cacheImages = new DrawableCache(Utils.getApplication(), 100 * 1024 * 1024); chacheDrawables = new HashMap<>(); diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/features/others/Channels.java b/app/src/main/java/com/wmods/wppenhacer/xposed/features/others/Channels.java index b635b924..88b15441 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/features/others/Channels.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/features/others/Channels.java @@ -5,6 +5,9 @@ import com.wmods.wppenhacer.xposed.core.Feature; import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator; +import org.luckypray.dexkit.util.DexSignUtil; + +import java.util.ArrayList; import java.util.List; import de.robv.android.xposed.XC_MethodHook; @@ -20,6 +23,23 @@ public Channels(ClassLoader loader, XSharedPreferences preferences) { public void doHook() throws Throwable { var channels = prefs.getBoolean("channels", false); var removechannelRec = prefs.getBoolean("removechannel_rec", false); + if (channels) { + var headerChannelItem = Unobfuscator.loadHeaderChannelItemClass(classLoader); + log("HeaderChannelItem: " + headerChannelItem); + var listChannelItem = Unobfuscator.loadListChannelItemClass(classLoader); + log("ListChannelItem: " + listChannelItem); + var listUpdateItems = Unobfuscator.loadListUpdateItemsConstructor(classLoader); + log("ListUpdateItems: " + DexSignUtil.getConstructorSign(listUpdateItems)); + XposedBridge.hookMethod(listUpdateItems, + new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (param.args[0] instanceof ArrayList list) { + list.removeIf((e) -> headerChannelItem.isInstance(e) || listChannelItem.isInstance(e)); + } + } + }); + } if (removechannelRec || channels) { var removeChannelRecClass = Unobfuscator.loadRemoveChannelRecClass(classLoader); XposedBridge.hookAllConstructors(removeChannelRecClass, new XC_MethodHook() { diff --git a/changelog.txt b/changelog.txt index ea52a26d..c15717be 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,25 +1,6 @@ -[FUNCTIONS] -* Enabled the option to show all statuses (Go to the updates tab and check the options menu), on this screen it is possible to filter and search for statuses by name, viewed, muted, and others -* Added the function to show the old UI statuses (NOTE: This causes interface lag when switching tabs by sliding), This function automatically deactivates the channels. - [CHANNELS] -* The option to deactivate channels was changed to hide channels and is now compatible with IG Status and maintains the current structure of statuses - -[WALLPAPER ON HOMESCREEN] -* The way images are loaded was changed because if the image was too large it caused lag and now it will be resized and saved for quick use - -[CUSTOM CSS] -* All images are resized to the size of the View and saved in cache to save RAM and avoid lags - -[SEPARATE GROUPS] -* Fixed unread message count for blocked chats - -[REMOVE LIMIT FORWARD] -* Fixed a bug in groups and added a note warning of ban for spam in cases of abuse, use with caution +* Fixed bug where statuses disappeared. -[WA ENHANCER] -* Added the option to force English -* Updated translations