Refactoring

pull/214/head
M66B 6 months ago
parent 1177f6d9b6
commit 3bad56345a

@ -481,7 +481,7 @@ public class ApplicationEx extends Application
if (version < BuildConfig.VERSION_CODE)
editor.remove("crash_report_count");
if (!BuildConfig.TEST_RELEASE)
if (!Log.isTestRelease())
editor.remove("test1").remove("test2").remove("test3").remove("test4").remove("test5");
if (version < 468) {

@ -277,7 +277,7 @@ public class DebugHelper {
autostart == null ? "?" : Boolean.toString(autostart == 0)));
boolean reporting = prefs.getBoolean("crash_reports", false);
if (reporting || BuildConfig.TEST_RELEASE) {
if (reporting || Log.isTestRelease()) {
String uuid = prefs.getString("uuid", null);
sb.append(String.format("Bugsnag UUID: %s\r\n", uuid == null ? "-" : uuid));
}

@ -186,7 +186,7 @@ public class EmailService implements AutoCloseable {
long protocol_since = prefs.getLong("protocol_since", 0);
if (protocol_since == 0)
prefs.edit().putLong("protocol_since", now).apply();
else if (protocol_since + PROTOCOL_LOG_DURATION < now && !BuildConfig.TEST_RELEASE)
else if (protocol_since + PROTOCOL_LOG_DURATION < now && !Log.isTestRelease())
prefs.edit().putBoolean("protocol", false).apply();
this.log = prefs.getBoolean("protocol", false);
this.ssl_harden = prefs.getBoolean("ssl_harden", false);

@ -110,7 +110,7 @@ public class EntityLog {
if (context == null)
return;
if (type == Type.Debug &&
!(BuildConfig.DEBUG || BuildConfig.TEST_RELEASE))
!(BuildConfig.DEBUG || Log.isTestRelease()))
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

@ -1971,7 +1971,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
grpBitbucket.setVisibility(View.GONE);
grpAnnouncements.setVisibility(TextUtils.isEmpty(BuildConfig.ANNOUNCEMENT_URI)
? View.GONE : View.VISIBLE);
grpTest.setVisibility(BuildConfig.TEST_RELEASE ? View.VISIBLE : View.GONE);
grpTest.setVisibility(Log.isTestRelease() ? View.VISIBLE : View.GONE);
setLastCleanup(prefs.getLong("last_cleanup", -1));
@ -1986,7 +1986,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
(external == null ? null : external.getAbsolutePath()) + (emulated ? " emulated" : ""));
swExactAlarms.setEnabled(AlarmManagerCompatEx.canScheduleExactAlarms(getContext()));
swTestIab.setVisibility(BuildConfig.DEBUG && BuildConfig.TEST_RELEASE ? View.VISIBLE : View.GONE);
swTestIab.setVisibility(BuildConfig.DEBUG && Log.isTestRelease() ? View.VISIBLE : View.GONE);
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);

@ -1356,7 +1356,7 @@ public class Helper {
html += "Locale: " + Html.escapeHtml(slocale.toString()) + "<br>";
if (language != null)
html += "Language: " + Html.escapeHtml(language) + "<br>";
if ((reporting || BuildConfig.TEST_RELEASE) && uuid != null)
if ((reporting || Log.isTestRelease()) && uuid != null)
html += "UUID: " + Html.escapeHtml(uuid) + "<br>";
html += "</p>";

@ -114,7 +114,7 @@ import javax.net.ssl.TrustManagerFactory;
public class Log {
private static Context ctx;
private static final int MAX_CRASH_REPORTS = (BuildConfig.TEST_RELEASE ? 50 : 5);
private static final int MAX_CRASH_REPORTS = (Log.isTestRelease() ? 50 : 5);
private static final String TAG = "fairemail";
static final String TOKEN_REFRESH_REQUIRED =
@ -386,7 +386,7 @@ public class Log {
}
static int getDefaultLogLevel() {
return (BuildConfig.DEBUG || BuildConfig.TEST_RELEASE ? android.util.Log.INFO : android.util.Log.WARN);
return (BuildConfig.DEBUG || Log.isTestRelease() ? android.util.Log.INFO : android.util.Log.WARN);
}
private static void setupBugsnag(final Context context) {
@ -435,7 +435,7 @@ public class Log {
@Override
public boolean onSession(@NonNull Session session) {
// opt-in
return prefs.getBoolean("crash_reports", false) || BuildConfig.TEST_RELEASE;
return prefs.getBoolean("crash_reports", false) || Log.isTestRelease();
}
});
@ -444,7 +444,7 @@ public class Log {
public boolean onError(@NonNull Event event) {
// opt-in
boolean crash_reports = prefs.getBoolean("crash_reports", false);
if (!crash_reports && !BuildConfig.TEST_RELEASE)
if (!crash_reports && !Log.isTestRelease())
return false;
Throwable ex = event.getOriginalError();
@ -549,7 +549,7 @@ public class Log {
Log.i("uuid=" + uuid);
client.setUser(uuid, null, null);
if (prefs.getBoolean("crash_reports", false) || BuildConfig.TEST_RELEASE)
if (prefs.getBoolean("crash_reports", false) || Log.isTestRelease())
Bugsnag.startSession();
} catch (Throwable ex) {
Log.e(ex);
@ -589,6 +589,10 @@ public class Log {
}
}
static boolean isTestRelease() {
return BuildConfig.TEST_RELEASE;
}
static void logExtras(Intent intent) {
if (intent != null)
logBundle(intent.getExtras());

@ -3810,7 +3810,7 @@ public class MessageHelper {
throw ex;
} catch (Throwable ex) {
Log.e(ex);
if (BuildConfig.TEST_RELEASE)
if (Log.isTestRelease())
warnings.add(ex + "\n" + android.util.Log.getStackTraceString(ex));
else
warnings.add(Log.formatThrowable(ex, false));

@ -168,7 +168,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
this.name = name;
this.started = new Date().getTime();
if (BuildConfig.TEST_RELEASE)
if (Log.isTestRelease())
Log.breadcrumb("SimpleTask", args);
for (String key : args.keySet()) {

Loading…
Cancel
Save