From c1199c93e0a2fa66ffeb725ae6740cd868fc1465 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 1 Dec 2021 19:33:29 +0100 Subject: [PATCH] Refactoring --- app/src/main/java/eu/faircode/email/Log.java | 7 +++++-- .../main/java/eu/faircode/email/ServiceAuthenticator.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java index f8977ddcb5..5973c128e6 100644 --- a/app/src/main/java/eu/faircode/email/Log.java +++ b/app/src/main/java/eu/faircode/email/Log.java @@ -144,6 +144,9 @@ public class Log { private static final int MAX_CRASH_REPORTS = 5; private static final String TAG = "fairemail"; + static final String TOKEN_REFRESH_REQUIRED = + "Token refresh required. Is there a VPN based app running?"; + public static void setLevel(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean debug = prefs.getBoolean("debug", false); @@ -471,7 +474,7 @@ public class Log { if (ex instanceof IllegalStateException && (no_internet.equals(ex.getMessage()) || - "Token refreshed".equals(ex.getMessage()) || + TOKEN_REFRESH_REQUIRED.equals(ex.getMessage()) || "Not connected".equals(ex.getMessage()) || "This operation is not allowed on a closed folder".equals(ex.getMessage()))) return false; @@ -1505,7 +1508,7 @@ public class Log { return null; if (ex instanceof IllegalStateException && - ("Token refreshed".equals(ex.getMessage()) || + (TOKEN_REFRESH_REQUIRED.equals(ex.getMessage()) || "Not connected".equals(ex.getMessage()) || "This operation is not allowed on a closed folder".equals(ex.getMessage()))) return null; diff --git a/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java b/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java index fcf41dc332..2383c461ed 100644 --- a/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java +++ b/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java @@ -137,7 +137,7 @@ public class ServiceAuthenticator extends Authenticator { } if (expiration != null && expiration - keep_alive < new Date().getTime()) - throw new IllegalStateException("Token refresh required. Is there a VPN based app running?"); + throw new IllegalStateException(Log.TOKEN_REFRESH_REQUIRED); } interface IAuthenticated {