From 002ff209f097c9f8db359b8c624b537f688c6c94 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 26 Sep 2018 12:53:04 +0000 Subject: [PATCH] Workaround crash --- app/src/main/java/eu/faircode/email/DaoMessage.java | 2 +- .../main/java/eu/faircode/email/FragmentCompose.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index e1882499c4..732826e106 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -192,7 +192,7 @@ public interface DaoMessage { long insertMessage(EntityMessage message); @Update - void updateMessage(EntityMessage message); + int updateMessage(EntityMessage message); @Query("UPDATE message SET uid = :uid WHERE id = :id") int setMessageUid(long id, Long uid); diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index d6287a9cab..01414dd6ea 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1181,11 +1181,15 @@ public class FragmentCompose extends FragmentEx { draft.write(context, body); // Check data - if (draft.identity == null) + if (draft.identity == null) { + db.setTransactionSuccessful(); throw new IllegalArgumentException(context.getString(R.string.title_from_missing)); + } - if (draft.to == null && draft.cc == null && draft.bcc == null) + if (draft.to == null && draft.cc == null && draft.bcc == null) { + db.setTransactionSuccessful(); throw new IllegalArgumentException(context.getString(R.string.title_to_missing)); + } // Save message ID String msgid = draft.msgid; @@ -1193,8 +1197,10 @@ public class FragmentCompose extends FragmentEx { // Save attachments List attachments = db.attachment().getAttachments(draft.id); for (EntityAttachment attachment : attachments) - if (!attachment.available) + if (!attachment.available) { + db.setTransactionSuccessful(); throw new IllegalArgumentException(context.getString(R.string.title_attachments_missing)); + } // Delete draft (cannot move to outbox) draft.msgid = null;