mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-11 03:24:52 +02:00
Refactoring
This commit is contained in:
@@ -35,9 +35,6 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.bugsnag.android.BreadcrumbType;
|
||||
import com.bugsnag.android.Bugsnag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -102,7 +99,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||
crumb.put("name", this.getClass().getName());
|
||||
crumb.put("before", Integer.toString(before));
|
||||
crumb.put("after", Integer.toString(after));
|
||||
Bugsnag.leaveBreadcrumb("onSaveInstanceState", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("onSaveInstanceState", crumb);
|
||||
|
||||
for (String key : outState.keySet())
|
||||
Log.i("Saved " + this + " " + key + "=" + outState.get(key));
|
||||
|
||||
@@ -37,8 +37,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.bugsnag.android.BreadcrumbType;
|
||||
import com.bugsnag.android.Bugsnag;
|
||||
import com.sun.mail.iap.BadCommandException;
|
||||
import com.sun.mail.iap.CommandFailedException;
|
||||
import com.sun.mail.iap.ConnectionException;
|
||||
@@ -149,7 +147,7 @@ class Core {
|
||||
if (op.message != null)
|
||||
crumb.put("message", Long.toString(op.message));
|
||||
crumb.put("free", Integer.toString(Log.getFreeMemMb()));
|
||||
Bugsnag.leaveBreadcrumb("operation", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("operation", crumb);
|
||||
|
||||
// Fetch most recent copy of message
|
||||
EntityMessage message = null;
|
||||
@@ -1238,7 +1236,7 @@ class Core {
|
||||
crumb.put("start", Integer.toString(from));
|
||||
crumb.put("end", Integer.toString(i));
|
||||
crumb.put("free", Integer.toString(free));
|
||||
Bugsnag.leaveBreadcrumb("sync", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("sync", crumb);
|
||||
Log.i("Sync " + from + ".." + i + " free=" + free);
|
||||
|
||||
for (int j = isub.length - 1; j >= 0 && state.running() && state.recoverable(); j--)
|
||||
@@ -1317,7 +1315,7 @@ class Core {
|
||||
crumb.put("start", Integer.toString(from));
|
||||
crumb.put("end", Integer.toString(i));
|
||||
crumb.put("free", Integer.toString(free));
|
||||
Bugsnag.leaveBreadcrumb("download", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("download", crumb);
|
||||
Log.i("Download " + from + ".." + i + " free=" + free);
|
||||
|
||||
for (int j = isub.length - 1; j >= 0 && state.running() && state.recoverable(); j--)
|
||||
|
||||
@@ -34,9 +34,6 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
|
||||
import com.bugsnag.android.BreadcrumbType;
|
||||
import com.bugsnag.android.Bugsnag;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -91,7 +88,7 @@ public class FragmentBase extends Fragment {
|
||||
Object value = outState.get(key);
|
||||
crumb.put(key, value == null ? "" : value.getClass().getName());
|
||||
}
|
||||
Bugsnag.leaveBreadcrumb("onSaveInstanceState", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("onSaveInstanceState", crumb);
|
||||
|
||||
for (String key : outState.keySet())
|
||||
Log.i("Saved " + this + " " + key + "=" + outState.get(key));
|
||||
|
||||
@@ -104,8 +104,6 @@ import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bugsnag.android.BreadcrumbType;
|
||||
import com.bugsnag.android.Bugsnag;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
@@ -1956,7 +1954,7 @@ public class FragmentCompose extends FragmentBase {
|
||||
crumb.put("draft", Long.toString(id));
|
||||
crumb.put("reference", Long.toString(reference));
|
||||
crumb.put("action", action);
|
||||
Bugsnag.leaveBreadcrumb("compose", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("compose", crumb);
|
||||
|
||||
EntityMessage draft;
|
||||
|
||||
@@ -2528,7 +2526,7 @@ public class FragmentCompose extends FragmentBase {
|
||||
crumb.put("content", Boolean.toString(draft.content));
|
||||
crumb.put("file", Boolean.toString(draft.getFile(context).exists()));
|
||||
crumb.put("action", getActionName(action));
|
||||
Bugsnag.leaveBreadcrumb("compose", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("compose", crumb);
|
||||
|
||||
List<EntityAttachment> attachments = db.attachment().getAttachments(draft.id);
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import android.view.WindowManager;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.bugsnag.android.BreadcrumbType;
|
||||
import com.bugsnag.android.Bugsnag;
|
||||
import com.bugsnag.android.Severity;
|
||||
|
||||
@@ -117,6 +118,10 @@ public class Log {
|
||||
return android.util.Log.e(TAG, prefix + " " + ex + "\n" + android.util.Log.getStackTraceString(ex));
|
||||
}
|
||||
|
||||
static void breadcrumb(String name, Map<String, String> crumb) {
|
||||
Bugsnag.leaveBreadcrumb("operation", BreadcrumbType.LOG, crumb);
|
||||
}
|
||||
|
||||
static void logExtras(Intent intent) {
|
||||
if (intent != null)
|
||||
logBundle(intent.getExtras());
|
||||
|
||||
@@ -2,8 +2,6 @@ package eu.faircode.email;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.bugsnag.android.BreadcrumbType;
|
||||
import com.bugsnag.android.Bugsnag;
|
||||
import com.sun.mail.imap.IMAPStore;
|
||||
import com.sun.mail.smtp.SMTPTransport;
|
||||
import com.sun.mail.util.MailConnectException;
|
||||
@@ -185,7 +183,7 @@ public class MailService implements AutoCloseable {
|
||||
crumb.put(key, sid.get(key));
|
||||
EntityLog.log(context, "Server " + key + "=" + sid.get(key));
|
||||
}
|
||||
Bugsnag.leaveBreadcrumb("server", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("server", crumb);
|
||||
}
|
||||
} catch (MessagingException ex) {
|
||||
Log.w(ex);
|
||||
|
||||
@@ -24,9 +24,6 @@ import android.os.Bundle;
|
||||
|
||||
import androidx.lifecycle.LifecycleService;
|
||||
|
||||
import com.bugsnag.android.BreadcrumbType;
|
||||
import com.bugsnag.android.Bugsnag;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -35,7 +32,7 @@ abstract class ServiceBase extends LifecycleService {
|
||||
public void onCreate() {
|
||||
Map<String, String> crumb = new HashMap<>();
|
||||
crumb.put("state", "create");
|
||||
Bugsnag.leaveBreadcrumb(this.getClass().getSimpleName(), BreadcrumbType.STATE, crumb);
|
||||
Log.breadcrumb(this.getClass().getSimpleName(), crumb);
|
||||
|
||||
super.onCreate();
|
||||
}
|
||||
@@ -52,7 +49,7 @@ abstract class ServiceBase extends LifecycleService {
|
||||
crumb.put(key, value == null ? null : value.toString());
|
||||
}
|
||||
}
|
||||
Bugsnag.leaveBreadcrumb(this.getClass().getSimpleName(), BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb(this.getClass().getSimpleName(), crumb);
|
||||
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
@@ -61,7 +58,7 @@ abstract class ServiceBase extends LifecycleService {
|
||||
public void onDestroy() {
|
||||
Map<String, String> crumb = new HashMap<>();
|
||||
crumb.put("state", "destroy");
|
||||
Bugsnag.leaveBreadcrumb(this.getClass().getSimpleName(), BreadcrumbType.STATE, crumb);
|
||||
Log.breadcrumb(this.getClass().getSimpleName(), crumb);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -36,9 +36,6 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.bugsnag.android.BreadcrumbType;
|
||||
import com.bugsnag.android.Bugsnag;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -144,7 +141,7 @@ public class ServiceSend extends ServiceBase {
|
||||
if (op.message != null)
|
||||
crumb.put("message", Long.toString(op.message));
|
||||
crumb.put("free", Integer.toString(Log.getFreeMemMb()));
|
||||
Bugsnag.leaveBreadcrumb("operation", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("operation", crumb);
|
||||
|
||||
switch (op.name) {
|
||||
case EntityOperation.SYNC:
|
||||
|
||||
@@ -42,8 +42,6 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.bugsnag.android.BreadcrumbType;
|
||||
import com.bugsnag.android.Bugsnag;
|
||||
import com.sun.mail.imap.IMAPFolder;
|
||||
import com.sun.mail.imap.IMAPMessage;
|
||||
|
||||
@@ -445,7 +443,7 @@ public class ServiceSynchronize extends ServiceBase {
|
||||
crumb.put("unmetered", Boolean.toString(networkState.isUnmetered()));
|
||||
crumb.put("roaming", Boolean.toString(networkState.isRoaming()));
|
||||
crumb.put("lastLost", new Date(lastLost).toString());
|
||||
Bugsnag.leaveBreadcrumb("reload", BreadcrumbType.LOG, crumb);
|
||||
Log.breadcrumb("reload", crumb);
|
||||
|
||||
if (doStop)
|
||||
stop();
|
||||
|
||||
Reference in New Issue
Block a user