1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-01 12:44:42 +00:00

Allow enabling debug messages

This commit is contained in:
M66B 2020-04-05 14:10:42 +02:00
parent 8eb38aefef
commit dc7271b5c1
3 changed files with 16 additions and 3 deletions

View file

@ -101,7 +101,7 @@ public class ApplicationEx extends Application {
}
});
Log.setupBugsnag(this);
Log.setup(this);
upgrade(this);

View file

@ -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);
}
});

View file

@ -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");