From 4050350a0e92811dec518b05d159ff5d3f6d4b3e Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 13 Aug 2018 06:00:59 +0000 Subject: [PATCH] Fixed debug/crash info --- .../main/java/eu/faircode/email/ActivityView.java | 13 ++++++++++--- .../main/java/eu/faircode/email/FragmentAbout.java | 13 ++++++++++--- .../java/eu/faircode/email/FragmentMessage.java | 1 - 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 57bfd30245..19b52c9efa 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -202,15 +202,18 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack file.delete(); + EntityMessage draft = null; + DB db = DB.getInstance(context); try { db.beginTransaction(); EntityFolder drafts = db.folder().getPrimaryDrafts(); if (drafts != null) { - EntityMessage draft = new EntityMessage(); + draft = new EntityMessage(); draft.account = drafts.account; draft.folder = drafts.id; + draft.msgid = draft.generateMessageId(); draft.to = new Address[]{to}; draft.subject = context.getString(R.string.app_name) + " crash log"; draft.body = "
" + sb.toString().replaceAll("\\r?\\n", "
") + "
"; @@ -219,14 +222,18 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack draft.ui_seen = false; draft.ui_hide = false; draft.id = db.message().insertMessage(draft); - - return draft.id; } + EntityOperation.queue(db, draft, EntityOperation.ADD); + db.setTransactionSuccessful(); } finally { db.endTransaction(); } + + EntityOperation.process(context); + + return (draft == null ? null : draft.id); } return null; diff --git a/app/src/main/java/eu/faircode/email/FragmentAbout.java b/app/src/main/java/eu/faircode/email/FragmentAbout.java index bdbd963418..b3ec1b7551 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAbout.java +++ b/app/src/main/java/eu/faircode/email/FragmentAbout.java @@ -63,6 +63,8 @@ public class FragmentAbout extends FragmentEx { Address to = new InternetAddress("marcel+email@faircode.eu", "FairCode"); + EntityMessage draft; + DB db = DB.getInstance(context); try { db.beginTransaction(); @@ -71,9 +73,10 @@ public class FragmentAbout extends FragmentEx { if (drafts == null) throw new IllegalArgumentException(context.getString(R.string.title_no_drafts)); - EntityMessage draft = new EntityMessage(); + draft = new EntityMessage(); draft.account = drafts.account; draft.folder = drafts.id; + draft.msgid = draft.generateMessageId(); draft.to = new Address[]{to}; draft.subject = BuildConfig.APPLICATION_ID + " debug info"; draft.body = "
" + info.toString().replaceAll("\\r?\\n", "
") + "
"; @@ -83,12 +86,16 @@ public class FragmentAbout extends FragmentEx { draft.ui_hide = false; draft.id = db.message().insertMessage(draft); - db.setTransactionSuccessful(); + EntityOperation.queue(db, draft, EntityOperation.ADD); - return draft.id; + db.setTransactionSuccessful(); } finally { db.endTransaction(); } + + EntityOperation.process(context); + + return draft.id; } @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index 45b6202ee7..619cb2df24 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -468,7 +468,6 @@ public class FragmentMessage extends FragmentEx { EntityOperation.queue(db, draft, EntityOperation.ADD); db.setTransactionSuccessful(); - } finally { db.endTransaction(); }