From 31e891d3670bf234373411d51a8d8cdc8aacbcbc Mon Sep 17 00:00:00 2001 From: frknkrc44 Date: Wed, 27 Nov 2024 01:44:21 +0300 Subject: [PATCH 1/3] feat: Fix FilterGroups for 24.xx --- .../xposed/features/customization/FilterGroups.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java index 78218489..8ad7c80f 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java @@ -29,6 +29,7 @@ import java.lang.reflect.Method; import java.util.List; import java.util.Objects; +import java.util.concurrent.CopyOnWriteArrayList; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XSharedPreferences; @@ -195,6 +196,11 @@ private void setFilter(int position) { if (mFilterInstance == null) return; var listField = ReflectionUtils.getFieldByType(mFilterInstance.getClass(), List.class); var list = (List) ReflectionUtils.getObjectField(listField, mFilterInstance); + // for 24.xx, it is CopyOnWriteArrayList instead of List + if (list == null) { + listField = ReflectionUtils.getFieldByType(mFilterInstance.getClass(), CopyOnWriteArrayList.class); + list = (List) ReflectionUtils.getObjectField(listField, mFilterInstance); + } if (list == null) return; var name = position == 0 ? "CONTACTS_FILTER" : "GROUP_FILTER"; Object result = null; From 860a6e4a2e8137af2880f42af75400b94bb910f1 Mon Sep 17 00:00:00 2001 From: Dev4Mod Date: Tue, 26 Nov 2024 20:16:27 -0300 Subject: [PATCH 2/3] Update FilterGroups.java --- .../features/customization/FilterGroups.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java index 8ad7c80f..fd1d5a5c 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java @@ -194,32 +194,25 @@ private void setFilter(int position) { try { ReflectionUtils.callMethod(methodInitFilter, null, mConversationFragment); if (mFilterInstance == null) return; - var listField = ReflectionUtils.getFieldByType(mFilterInstance.getClass(), List.class); - var list = (List) ReflectionUtils.getObjectField(listField, mFilterInstance); - // for 24.xx, it is CopyOnWriteArrayList instead of List - if (list == null) { - listField = ReflectionUtils.getFieldByType(mFilterInstance.getClass(), CopyOnWriteArrayList.class); - list = (List) ReflectionUtils.getObjectField(listField, mFilterInstance); - } + var listField = ReflectionUtils.getFieldByExtendType(mFilterInstance.getClass(), List.class); + var list = (List) ReflectionUtils.getObjectField(listField, mFilterInstance); if (list == null) return; var name = position == 0 ? "CONTACTS_FILTER" : "GROUP_FILTER"; - Object result = null; + int index = -1; for (var item : list) { - for (var field : item.getClass().getFields()) { - if (Objects.equals(XposedHelpers.getObjectField(item, field.getName()), name)) { - result = item; - break; - } + if (item == null) continue; + if (item.toString().contains(name)) { + index = list.indexOf(item); + break; } } - if (result == null) return; - var index = list.indexOf(result); + if (index == -1) return; ReflectionUtils.callMethod(methodSetFilter, mFilterInstance, index); } catch (Exception e) { logDebug(e); } } - + @NonNull @Override public String getPluginName() { From 99c55dfbfab9b04fc0550692290b1961503da7e6 Mon Sep 17 00:00:00 2001 From: frknkrc44 Date: Wed, 27 Nov 2024 02:42:16 +0300 Subject: [PATCH 3/3] perf: Optimize imports --- .../wppenhacer/xposed/features/customization/FilterGroups.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java index fd1d5a5c..100f1a5b 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/FilterGroups.java @@ -28,8 +28,6 @@ import java.lang.reflect.Method; import java.util.List; -import java.util.Objects; -import java.util.concurrent.CopyOnWriteArrayList; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XSharedPreferences;