|
3 | 3 | import android.view.View; |
4 | 4 | import android.view.ViewGroup; |
5 | 5 | import android.widget.ImageView; |
| 6 | +import android.widget.TextView; |
6 | 7 |
|
7 | 8 | import androidx.annotation.NonNull; |
8 | 9 |
|
9 | 10 | import com.wmods.wppenhacer.xposed.core.Feature; |
10 | 11 | import com.wmods.wppenhacer.xposed.core.components.FMessageWpp; |
11 | 12 | import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator; |
| 13 | +import com.wmods.wppenhacer.xposed.utils.DesignUtils; |
12 | 14 | import com.wmods.wppenhacer.xposed.utils.ReflectionUtils; |
13 | 15 | import com.wmods.wppenhacer.xposed.utils.Utils; |
14 | 16 |
|
15 | 17 | import java.lang.reflect.Method; |
16 | 18 |
|
17 | 19 | import de.robv.android.xposed.XC_MethodHook; |
18 | | -import de.robv.android.xposed.XC_MethodReplacement; |
19 | 20 | import de.robv.android.xposed.XSharedPreferences; |
20 | 21 | import de.robv.android.xposed.XposedBridge; |
21 | | -import de.robv.android.xposed.XposedHelpers; |
22 | 22 |
|
23 | 23 | public class TagMessage extends Feature { |
24 | 24 | public TagMessage(ClassLoader loader, XSharedPreferences preferences) { |
@@ -52,43 +52,31 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
52 | 52 | } |
53 | 53 |
|
54 | 54 | private void hookBroadcastView() throws Exception { |
55 | | - Method method1 = Unobfuscator.loadBroadcastTagMethod(classLoader); |
56 | 55 |
|
57 | | - XposedBridge.hookMethod(method1, new XC_MethodHook() { |
58 | | - private FMessageWpp.Key keyObj; |
59 | | - private Unhook hooked; |
| 56 | + var bubbleMethod = Unobfuscator.loadAntiRevokeBubbleMethod(classLoader); |
| 57 | + logDebug(Unobfuscator.getMethodDescriptor(bubbleMethod)); |
60 | 58 |
|
| 59 | + XposedBridge.hookMethod(bubbleMethod, new XC_MethodHook() { |
61 | 60 | @Override |
62 | | - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
63 | | - keyObj = null; |
64 | | - var fmessageObj = ReflectionUtils.getArg(param.args, FMessageWpp.TYPE, 0); |
65 | | - var fmessage = new FMessageWpp(fmessageObj); |
| 61 | + protected void afterHookedMethod(MethodHookParam param) { |
| 62 | + var objMessage = param.args[2]; |
| 63 | + var dateTextView = (TextView) param.args[1]; |
| 64 | + if (dateTextView == null) return; |
| 65 | + var fmessage = new FMessageWpp(objMessage); |
66 | 66 | var key = fmessage.getKey(); |
67 | | - if (!key.isFromMe && fmessage.isBroadcast()) { |
68 | | - var view = (ViewGroup) (param.thisObject instanceof ViewGroup ? param.thisObject : param.args[0]); |
69 | | - int id = Utils.getID("broadcast_icon", "id"); |
70 | | - View res = view.findViewById(id); |
71 | | - if (res == null) { |
72 | | - var dateWrapper = (ViewGroup) view.findViewById(Utils.getID("date_wrapper", "id")); |
73 | | - var broadcast = new ImageView(view.getContext()); |
| 67 | + var dateWrapper = (ViewGroup) dateTextView.getParent(); |
| 68 | + int id = Utils.getID("broadcast_icon", "id"); |
| 69 | + View res = dateWrapper.findViewById(id); |
| 70 | + if (!key.isFromMe) |
| 71 | + if (fmessage.isBroadcast() && res == null) { |
| 72 | + var broadcast = new ImageView(dateWrapper.getContext()); |
74 | 73 | broadcast.setId(id); |
| 74 | + broadcast.setImageDrawable(DesignUtils.getDrawableByName("broadcast_status_icon")); |
75 | 75 | dateWrapper.addView(broadcast, 0); |
| 76 | + } else if (res != null) { |
| 77 | + dateWrapper.removeView(res); |
76 | 78 | } |
77 | | - key.setIsFromMe(true); |
78 | | - keyObj = key; |
79 | | - hooked = XposedHelpers.findAndHookMethod(key.remoteJid.getClass(), "getType", XC_MethodReplacement.returnConstant(0)); |
80 | | - } |
81 | 79 | } |
82 | | - |
83 | | - protected void afterHookedMethod(MethodHookParam param) throws Throwable { |
84 | | - if (keyObj != null) { |
85 | | - keyObj.setIsFromMe(false); |
86 | | - } |
87 | | - if (hooked != null) { |
88 | | - hooked.unhook(); |
89 | | - } |
90 | | - } |
91 | | - |
92 | 80 | }); |
93 | 81 | } |
94 | 82 |
|
|
0 commit comments