From a981e6fe08958584b342d9c1046aca20b37de083 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 24 Aug 2018 12:32:11 +0000 Subject: [PATCH] Restored compose logic --- .../eu/faircode/email/FragmentCompose.java | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 6f118c2f38..04ccfe57f0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -872,37 +872,39 @@ public class FragmentCompose extends FragmentEx { String subject = args.getString("subject"); String body = args.getString("body"); - // Get draft & selected identity + EntityMessage draft; + DB db = DB.getInstance(context); - EntityMessage draft = db.message().getMessage(id); - EntityIdentity identity = db.identity().getIdentity(iid); - - // Draft deleted by server - if (draft == null) - throw new MessageRemovedException("Draft for action was deleted"); - - Log.i(Helper.TAG, "Load action id=" + draft.id + " action=" + action); - - // Convert data - Address afrom[] = (identity == null ? null : new Address[]{new InternetAddress(identity.email, identity.name)}); - Address ato[] = (TextUtils.isEmpty(to) ? null : InternetAddress.parse(to)); - Address acc[] = (TextUtils.isEmpty(cc) ? null : InternetAddress.parse(cc)); - Address abcc[] = (TextUtils.isEmpty(bcc) ? null : InternetAddress.parse(bcc)); - - // Update draft - draft.identity = (identity == null ? null : identity.id); - draft.from = afrom; - draft.to = ato; - draft.cc = acc; - draft.bcc = abcc; - draft.subject = subject; - draft.received = new Date().getTime(); - - String pbody = "
" + body.replaceAll("\\r?\\n", "
") + "
"; - try { db.beginTransaction(); + // Get draft & selected identity + draft = db.message().getMessage(id); + EntityIdentity identity = db.identity().getIdentity(iid); + + // Draft deleted by server + if (draft == null) + throw new MessageRemovedException("Draft for action was deleted"); + + Log.i(Helper.TAG, "Load action id=" + draft.id + " action=" + action); + + // Convert data + Address afrom[] = (identity == null ? null : new Address[]{new InternetAddress(identity.email, identity.name)}); + Address ato[] = (TextUtils.isEmpty(to) ? null : InternetAddress.parse(to)); + Address acc[] = (TextUtils.isEmpty(cc) ? null : InternetAddress.parse(cc)); + Address abcc[] = (TextUtils.isEmpty(bcc) ? null : InternetAddress.parse(bcc)); + + // Update draft + draft.identity = (identity == null ? null : identity.id); + draft.from = afrom; + draft.to = ato; + draft.cc = acc; + draft.bcc = abcc; + draft.subject = subject; + draft.received = new Date().getTime(); + + String pbody = "
" + body.replaceAll("\\r?\\n", "
") + "
"; + // Execute action if (action == R.id.action_trash) { draft.ui_seen = true; @@ -932,13 +934,11 @@ public class FragmentCompose extends FragmentEx { draft.write(context, pbody); // Check data - if (action == R.id.action_send) { - if (draft.identity == null) - throw new IllegalArgumentException(context.getString(R.string.title_from_missing)); + if (draft.identity == null) + throw new IllegalArgumentException(context.getString(R.string.title_from_missing)); - if (draft.to == null && draft.cc == null && draft.bcc == null) - throw new IllegalArgumentException(context.getString(R.string.title_to_missing)); - } + if (draft.to == null && draft.cc == null && draft.bcc == null) + throw new IllegalArgumentException(context.getString(R.string.title_to_missing)); // Save message ID String msgid = draft.msgid;