mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #2689 from deltachat/fix-webxdc-fast-tapping
no more than one webxdc start within 500ms
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user