Skip to content

Commit 8d4a4f0

Browse files
committed
Fix Double click
1 parent 2ced559 commit 8d4a4f0

File tree

2 files changed

+47
-13
lines changed

2 files changed

+47
-13
lines changed

.idea/other.xml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/wmods/wppenhacer/xposed/features/general/Others.java

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import android.os.BaseBundle;
55
import android.os.Message;
66
import android.text.TextUtils;
7-
import android.view.GestureDetector;
87
import android.view.Menu;
98
import android.view.View;
109
import android.view.ViewGroup;
@@ -13,7 +12,6 @@
1312

1413
import androidx.annotation.NonNull;
1514

16-
import com.wmods.wppenhacer.listeners.DoubleTapListener;
1715
import com.wmods.wppenhacer.xposed.core.Feature;
1816
import com.wmods.wppenhacer.xposed.core.WppCore;
1917
import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator;
@@ -185,21 +183,46 @@ private void doubleTapReaction() throws Exception {
185183
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
186184
var viewGroup = (View) param.thisObject;
187185
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+
}
196199
}
197200
}
198201
}
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]);
199224
}
200-
WppCore.sendReaction(emoji, param.args[2]);
201-
}));
202-
viewGroup.setOnTouchListener((v, event) -> gestureDetector.onTouchEvent(event));
225+
});
203226
}
204227
});
205228
}

0 commit comments

Comments
 (0)