Allow enabling debug messages

pull/178/head
M66B 6 years ago
parent 8eb38aefef
commit dc7271b5c1

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

@ -259,6 +259,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("debug", checked).apply(); prefs.edit().putBoolean("debug", checked).apply();
Log.setDebug(checked);
grpDebug.setVisibility(checked || BuildConfig.DEBUG ? View.VISIBLE : View.GONE); grpDebug.setVisibility(checked || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
} }
}); });

@ -105,11 +105,16 @@ import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLPeerUnverifiedException;
public class Log { public class Log {
private static boolean debug = false;
private static final int MAX_CRASH_REPORTS = 5; private static final int MAX_CRASH_REPORTS = 5;
private static final String TAG = "fairemail"; private static final String TAG = "fairemail";
public static void setDebug(boolean value) {
debug = value;
}
public static int d(String msg) { public static int d(String msg) {
if (BuildConfig.DEBUG && false) if (debug)
return android.util.Log.d(TAG, msg); return android.util.Log.d(TAG, msg);
else else
return 0; 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/ // https://docs.bugsnag.com/platforms/android/sdk/
com.bugsnag.android.Configuration config = com.bugsnag.android.Configuration config =
new com.bugsnag.android.Configuration("9d2d57476a0614974449a3ec33f2604a"); new com.bugsnag.android.Configuration("9d2d57476a0614974449a3ec33f2604a");

Loading…
Cancel
Save