From 712f7553f3244b96959f573188b607e243320f7f Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 17 Apr 2022 14:29:48 +0200 Subject: [PATCH] Small behavior improvement --- .../java/eu/faircode/email/ActivitySetup.java | 11 +++++---- .../java/eu/faircode/email/ActivityView.java | 24 ++++++++++++------- .../java/eu/faircode/email/NavMenuItem.java | 11 ++++----- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index 347c5f5f6a..1ee8ab8ada 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -103,6 +103,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.concurrent.Callable; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -269,11 +270,12 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac drawerLayout.closeDrawer(drawerContainer); onMenuFAQ(); } - }, new Runnable() { + }, new Callable() { @Override - public void run() { + public Boolean call() { drawerLayout.closeDrawer(drawerContainer); onDebugInfo(); + return true; } }).setExternal(true)); @@ -299,10 +301,11 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac drawerLayout.closeDrawer(drawerContainer); onMenuAbout(); } - }, new Runnable() { + }, new Callable() { @Override - public void run() { + public Boolean call() { startActivity(new Intent(ActivitySetup.this, ActivityBilling.class)); + return true; } }).setSubtitle(BuildConfig.VERSION_NAME)); diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index c1d20e6ef8..95102856b5 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -92,6 +92,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Objects; +import java.util.concurrent.Callable; import javax.net.ssl.HttpsURLConnection; @@ -797,9 +798,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB drawerLayout.closeDrawer(drawerContainer); onMenuSetup(); } - }, new Runnable() { + }, new Callable() { @Override - public void run() { + public Boolean call() { if (BuildConfig.DEBUG) try { DnsBlockList.clearCache(); @@ -808,6 +809,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB } catch (Throwable ex) { Log.unexpectedError(getSupportFragmentManager(), ex); } + return BuildConfig.DEBUG; } })); @@ -833,12 +835,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB drawerLayout.closeDrawer(drawerContainer); onMenuFAQ(); } - }, new Runnable() { + }, new Callable() { @Override - public void run() { + public Boolean call() { if (!drawerLayout.isLocked(drawerContainer)) drawerLayout.closeDrawer(drawerContainer); onDebugInfo(); + return true; } }).setExternal(true)); @@ -849,12 +852,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB drawerLayout.closeDrawer(drawerContainer); onMenuIssue(); } - }, new Runnable() { + }, new Callable() { @Override - public void run() { + public Boolean call() { Intent canary = CoalMine.getIntent(); if (canary != null) startActivity(canary); + return (canary != null); } }).setExternal(true)); @@ -891,14 +895,16 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB public void run() { onMenuAbout(); } - }, new Runnable() { + }, new Callable() { @Override - public void run() { - if (!Helper.isPlayStoreInstall()) { + public Boolean call() { + boolean play = Helper.isPlayStoreInstall(); + if (!play) { if (!drawerLayout.isLocked(drawerContainer)) drawerLayout.closeDrawer(drawerContainer); checkUpdate(true); } + return !play; } }).setSeparated().setSubtitle(BuildConfig.VERSION_NAME)); diff --git a/app/src/main/java/eu/faircode/email/NavMenuItem.java b/app/src/main/java/eu/faircode/email/NavMenuItem.java index ed864d1865..58fd746c12 100644 --- a/app/src/main/java/eu/faircode/email/NavMenuItem.java +++ b/app/src/main/java/eu/faircode/email/NavMenuItem.java @@ -20,6 +20,7 @@ package eu.faircode.email; */ import java.util.Objects; +import java.util.concurrent.Callable; public class NavMenuItem { private int icon; @@ -31,7 +32,7 @@ public class NavMenuItem { private boolean warning = false; private boolean separated = false; private Runnable click; - private Runnable longClick; + private Callable longClick; NavMenuItem(int icon, int title, Runnable click) { this.icon = icon; @@ -39,7 +40,7 @@ public class NavMenuItem { this.click = click; } - NavMenuItem(int icon, int title, Runnable click, Runnable longClick) { + NavMenuItem(int icon, int title, Runnable click, Callable longClick) { this.icon = icon; this.title = title; this.click = click; @@ -124,13 +125,11 @@ public class NavMenuItem { boolean onLongClick() { try { - if (longClick != null) - longClick.run(); - return (longClick != null); + return longClick.call(); } catch (Throwable ex) { Log.e(ex); - return false; } + return false; } @Override