|
4 | 4 | import android.os.BaseBundle; |
5 | 5 | import android.os.Message; |
6 | 6 | import android.text.TextUtils; |
7 | | -import android.view.GestureDetector; |
8 | 7 | import android.view.Menu; |
9 | 8 | import android.view.View; |
10 | 9 | import android.view.ViewGroup; |
|
13 | 12 |
|
14 | 13 | import androidx.annotation.NonNull; |
15 | 14 |
|
16 | | -import com.wmods.wppenhacer.listeners.DoubleTapListener; |
17 | 15 | import com.wmods.wppenhacer.xposed.core.Feature; |
18 | 16 | import com.wmods.wppenhacer.xposed.core.WppCore; |
19 | 17 | import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator; |
@@ -185,21 +183,46 @@ private void doubleTapReaction() throws Exception { |
185 | 183 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
186 | 184 | var viewGroup = (View) param.thisObject; |
187 | 185 | if (viewGroup == null) return; |
188 | | - var gestureDetector = new GestureDetector(viewGroup.getContext(), new DoubleTapListener(() -> { |
189 | | - var reactionView = (ViewGroup) viewGroup.findViewById(Utils.getID("reactions_bubble_layout", "id")); |
190 | | - if (reactionView != null && reactionView.getVisibility() == View.VISIBLE) { |
191 | | - for (int i = 0; i < reactionView.getChildCount(); i++) { |
192 | | - if (reactionView.getChildAt(i) instanceof TextView textView) { |
193 | | - if (textView.getText().toString().contains(emoji)) { |
194 | | - WppCore.sendReaction("", param.args[2]); |
195 | | - return; |
| 186 | + |
| 187 | + var gestureDetector = new Object() { |
| 188 | + |
| 189 | + public void doubleClick(View view, Object objMessage) { |
| 190 | + var reactionView = (ViewGroup) view.findViewById(Utils.getID("reactions_bubble_layout", "id")); |
| 191 | + if (reactionView != null && reactionView.getVisibility() == View.VISIBLE) { |
| 192 | + for (int i = 0; i < reactionView.getChildCount(); i++) { |
| 193 | + if (reactionView.getChildAt(i) instanceof TextView textView) { |
| 194 | + if (textView.getText().toString().contains(emoji)) { |
| 195 | + WppCore.sendReaction("", objMessage); |
| 196 | + Utils.showToast(emoji, 1); |
| 197 | + return; |
| 198 | + } |
196 | 199 | } |
197 | 200 | } |
198 | 201 | } |
| 202 | + WppCore.sendReaction(emoji, param.args[2]); |
| 203 | + } |
| 204 | + }; |
| 205 | + |
| 206 | + var auxClick = new Object() { |
| 207 | + long lastClick = 0; |
| 208 | + long clicks = 0; |
| 209 | + }; |
| 210 | + |
| 211 | + viewGroup.setOnClickListener(v -> { |
| 212 | + if (auxClick.lastClick == 0 || System.currentTimeMillis() - auxClick.lastClick < 1000) { |
| 213 | + auxClick.lastClick = System.currentTimeMillis(); |
| 214 | + auxClick.clicks++; |
| 215 | + } else { |
| 216 | + auxClick.lastClick = 0; |
| 217 | + auxClick.clicks = 0; |
| 218 | + } |
| 219 | + if (auxClick.clicks > 1) { |
| 220 | + Utils.showToast("Tap", 1); |
| 221 | + auxClick.clicks = 0; |
| 222 | + auxClick.lastClick = 0; |
| 223 | + gestureDetector.doubleClick(v, param.args[2]); |
199 | 224 | } |
200 | | - WppCore.sendReaction(emoji, param.args[2]); |
201 | | - })); |
202 | | - viewGroup.setOnTouchListener((v, event) -> gestureDetector.onTouchEvent(event)); |
| 225 | + }); |
203 | 226 | } |
204 | 227 | }); |
205 | 228 | } |
|
0 commit comments