diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java index 2878e7c8d3..ff881344c9 100644 --- a/app/src/main/java/eu/faircode/email/ApplicationEx.java +++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java @@ -101,7 +101,7 @@ public class ApplicationEx extends Application { } }); - Log.setupBugsnag(this); + Log.setup(this); upgrade(this); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 3682168396..5c8a03c346 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -259,6 +259,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("debug", checked).apply(); + Log.setDebug(checked); grpDebug.setVisibility(checked || BuildConfig.DEBUG ? View.VISIBLE : View.GONE); } }); diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java index 2dfd785baf..c2e2e0dfeb 100644 --- a/app/src/main/java/eu/faircode/email/Log.java +++ b/app/src/main/java/eu/faircode/email/Log.java @@ -105,11 +105,16 @@ import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLPeerUnverifiedException; public class Log { + private static boolean debug = false; private static final int MAX_CRASH_REPORTS = 5; private static final String TAG = "fairemail"; + public static void setDebug(boolean value) { + debug = value; + } + public static int d(String msg) { - if (BuildConfig.DEBUG && false) + if (debug) return android.util.Log.d(TAG, msg); else return 0; @@ -206,7 +211,14 @@ public class Log { } } - static void setupBugsnag(Context context) { + static void setup(Context context) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + debug = prefs.getBoolean("debug", false); + + setupBugsnag(context); + } + + private static void setupBugsnag(Context context) { // https://docs.bugsnag.com/platforms/android/sdk/ com.bugsnag.android.Configuration config = new com.bugsnag.android.Configuration("9d2d57476a0614974449a3ec33f2604a");