mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
0dd29abd06
commit
c70e693f24
|
@ -136,6 +136,32 @@ public class ApplicationEx extends Application
|
|||
" process=" + android.os.Process.myPid());
|
||||
Log.logMemory(this, "App");
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final boolean crash_reports = prefs.getBoolean("crash_reports", false);
|
||||
final boolean leak_canary = prefs.getBoolean("leak_canary", false);
|
||||
final boolean load_emoji = prefs.getBoolean("load_emoji", true);
|
||||
|
||||
prev = Thread.getDefaultUncaughtExceptionHandler();
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(@NonNull Thread thread, @NonNull Throwable ex) {
|
||||
if (!crash_reports && Log.isOwnFault(ex)) {
|
||||
Log.e(ex);
|
||||
|
||||
if (BuildConfig.BETA_RELEASE ||
|
||||
!Helper.isPlayStoreInstall())
|
||||
Log.writeCrashLog(ApplicationEx.this, ex);
|
||||
|
||||
if (prev != null)
|
||||
prev.uncaughtException(thread, ex);
|
||||
} else {
|
||||
Log.w(ex);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ConnectionHelper.setupProxy(this);
|
||||
|
||||
if (BuildConfig.DEBUG)
|
||||
|
@ -155,16 +181,17 @@ public class ApplicationEx extends Application
|
|||
}
|
||||
|
||||
private void log(boolean foreground) {
|
||||
Log.i("App foreground=" + foreground);
|
||||
Log.breadcrumb("app", "foreground", Boolean.toString(foreground));
|
||||
}
|
||||
});
|
||||
|
||||
registerActivityLifecycleCallbacks(lifecycleCallbacks);
|
||||
|
||||
if (BuildConfig.DEBUG)
|
||||
getMainLooper().setMessageLogging(new Printer() {
|
||||
@Override
|
||||
public void println(String msg) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d("Loop: " + msg);
|
||||
}
|
||||
});
|
||||
|
@ -205,32 +232,6 @@ public class ApplicationEx extends Application
|
|||
StrictMode.setVmPolicy(policy);
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final boolean crash_reports = prefs.getBoolean("crash_reports", false);
|
||||
final boolean leak_canary = prefs.getBoolean("leak_canary", false);
|
||||
final boolean load_emoji = prefs.getBoolean("load_emoji", true);
|
||||
|
||||
prev = Thread.getDefaultUncaughtExceptionHandler();
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(@NonNull Thread thread, @NonNull Throwable ex) {
|
||||
if (!crash_reports && Log.isOwnFault(ex)) {
|
||||
Log.e(ex);
|
||||
|
||||
if (BuildConfig.BETA_RELEASE ||
|
||||
!Helper.isPlayStoreInstall())
|
||||
Log.writeCrashLog(ApplicationEx.this, ex);
|
||||
|
||||
if (prev != null)
|
||||
prev.uncaughtException(thread, ex);
|
||||
} else {
|
||||
Log.w(ex);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Log.setup(this);
|
||||
CoalMine.setup(leak_canary);
|
||||
|
||||
|
|
Loading…
Reference in New Issue