Merge pull request #2689 from deltachat/fix-webxdc-fast-tapping

no more than one webxdc start within 500ms
This commit is contained in:
Asiel Díaz Benítez
2023-10-01 11:22:02 -04:00
committed by GitHub
2 changed files with 19 additions and 6 deletions
@@ -62,13 +62,15 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
private boolean internetAccess = false;
public static void openWebxdcActivity(Context context, DcMsg instance) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Prefs.isDeveloperModeEnabled(context)) {
WebView.setWebContentsDebuggingEnabled(true);
if (!Util.isClickedRecently()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Prefs.isDeveloperModeEnabled(context)) {
WebView.setWebContentsDebuggingEnabled(true);
}
context.startActivity(getWebxdcIntent(context, instance.getId()));
} else {
Toast.makeText(context, "At least Android 5.0 (Lollipop) required for Webxdc.", Toast.LENGTH_LONG).show();
}
context.startActivity(getWebxdcIntent(context, instance.getId()));
} else {
Toast.makeText(context, "At least Android 5.0 (Lollipop) required for Webxdc.", Toast.LENGTH_LONG).show();
}
}
@@ -333,4 +333,15 @@ public class Util {
public static int rgbToArgbColor(int rgb) {
return Color.argb(0xFF, Color.red(rgb), Color.green(rgb), Color.blue(rgb));
}
private static long lastClickTime = 0;
public static boolean isClickedRecently() {
long now = System.currentTimeMillis();
if (now - lastClickTime < 500) {
Log.i(TAG, "tap discarded");
return true;
}
lastClickTime = now;
return false;
}
}