From 72de959cebbde7540c9981b5a47fa86b9fa0660a Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 17 Feb 2019 16:35:01 +0000 Subject: [PATCH] Bring back store sent --- .../java/eu/faircode/email/DaoMessage.java | 3 +++ .../eu/faircode/email/EntityIdentity.java | 7 ++++++- .../eu/faircode/email/FragmentIdentity.java | 9 ++++++++ .../eu/faircode/email/ServiceSynchronize.java | 20 +++++++++++------- app/src/main/res/layout/fragment_identity.xml | 21 ++++++++++++++++++- app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 53 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 8df9ac97c3..ef685b2ada 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -265,6 +265,9 @@ public interface DaoMessage { @Update int updateMessage(EntityMessage message); + @Query("UPDATE message SET folder = :folder WHERE id = :id") + int setMessageFolder(long id, long folder); + @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/EntityIdentity.java b/app/src/main/java/eu/faircode/email/EntityIdentity.java index eaccef8b31..5b3aef22be 100644 --- a/app/src/main/java/eu/faircode/email/EntityIdentity.java +++ b/app/src/main/java/eu/faircode/email/EntityIdentity.java @@ -82,7 +82,7 @@ public class EntityIdentity { @NonNull public Boolean read_receipt = false; @NonNull - public Boolean store_sent = false; // obsolete + public Boolean store_sent = false; public Long sent_folder = null; // obsolete public Boolean tbd; public String state; @@ -122,6 +122,7 @@ public class EntityIdentity { json.put("plain_only", plain_only); json.put("delivery_receipt", delivery_receipt); json.put("read_receipt", read_receipt); + json.put("store_sent", store_sent); // not state // not error return json; @@ -164,6 +165,9 @@ public class EntityIdentity { if (json.has("read_receipt")) identity.read_receipt = json.getBoolean("read_receipt"); + if (json.has("store_sent")) + identity.store_sent = json.getBoolean("store_sent"); + return identity; } @@ -191,6 +195,7 @@ public class EntityIdentity { (this.bcc == null ? other.bcc == null : this.bcc.equals(other.bcc)) && this.delivery_receipt.equals(other.delivery_receipt) && this.read_receipt.equals(other.read_receipt) && + this.store_sent.equals(other.store_sent) && (this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) && (this.state == null ? other.state == null : this.state.equals(other.state)) && (this.error == null ? other.error == null : this.error.equals(other.error)) && diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index b8d8570591..e6c168f7d0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -102,6 +102,8 @@ public class FragmentIdentity extends FragmentBase { private CheckBox cbDeliveryReceipt; private CheckBox cbReadReceipt; + private CheckBox cbStoreSent; + private Button btnSave; private ContentLoadingProgressBar pbSave; private TextView tvError; @@ -167,6 +169,8 @@ public class FragmentIdentity extends FragmentBase { cbDeliveryReceipt = view.findViewById(R.id.cbDeliveryReceipt); cbReadReceipt = view.findViewById(R.id.cbReadReceipt); + cbStoreSent = view.findViewById(R.id.cbStoreSent); + btnSave = view.findViewById(R.id.btnSave); pbSave = view.findViewById(R.id.pbSave); tvError = view.findViewById(R.id.tvError); @@ -463,6 +467,7 @@ public class FragmentIdentity extends FragmentBase { args.putBoolean("plain_only", cbPlainOnly.isChecked()); args.putBoolean("delivery_receipt", cbDeliveryReceipt.isChecked()); args.putBoolean("read_receipt", cbReadReceipt.isChecked()); + args.putBoolean("store_sent", cbStoreSent.isChecked()); args.putLong("account", account == null ? -1 : account.id); args.putInt("auth_type", auth_type); args.putString("host", etHost.getText().toString()); @@ -522,6 +527,7 @@ public class FragmentIdentity extends FragmentBase { boolean plain_only = args.getBoolean("plain_only"); boolean delivery_receipt = args.getBoolean("delivery_receipt"); boolean read_receipt = args.getBoolean("read_receipt"); + boolean store_sent = args.getBoolean("store_sent"); if (TextUtils.isEmpty(name)) throw new IllegalArgumentException(context.getString(R.string.title_no_name)); @@ -626,6 +632,8 @@ public class FragmentIdentity extends FragmentBase { identity.plain_only = plain_only; identity.delivery_receipt = delivery_receipt; identity.read_receipt = read_receipt; + identity.store_sent = store_sent; + identity.sent_folder = null; identity.error = null; identity.last_connected = last_connected; @@ -726,6 +734,7 @@ public class FragmentIdentity extends FragmentBase { cbPlainOnly.setChecked(identity == null ? false : identity.plain_only); cbDeliveryReceipt.setChecked(identity == null ? false : identity.delivery_receipt); cbReadReceipt.setChecked(identity == null ? false : identity.read_receipt); + cbStoreSent.setChecked(identity == null ? false : identity.store_sent); color = (identity == null || identity.color == null ? Color.TRANSPARENT : identity.color); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 1428a1f2a9..0c35cb7c6b 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1987,7 +1987,13 @@ public class ServiceSynchronize extends LifecycleService { EntityLog.log(this, "Sent via " + ident.host + "/" + ident.user + " to " + TextUtils.join(", ", to)); + // Append replied/forwarded text + StringBuilder sb = new StringBuilder(); + sb.append(Helper.readText(EntityMessage.getFile(this, message.id))); File refFile = EntityMessage.getRefFile(this, message.id); + if (refFile.exists()) + sb.append(Helper.readText(refFile)); + Helper.writeText(EntityMessage.getFile(this, message.id), sb.toString()); try { db.beginTransaction(); @@ -1997,13 +2003,13 @@ public class ServiceSynchronize extends LifecycleService { db.message().setMessageUiSeen(message.id, true); db.message().setMessageError(message.id, null); - // Append replied/forwarded text - StringBuilder sb = new StringBuilder(); - sb.append(Helper.readText(EntityMessage.getFile(this, message.id))); - if (refFile.exists()) - sb.append(Helper.readText(refFile)); - - Helper.writeText(EntityMessage.getFile(this, message.id), sb.toString()); + EntityFolder sent = db.folder().getFolderByType(message.account, EntityFolder.SENT); + if (ident.store_sent && sent != null) { + db.message().setMessageFolder(message.id, sent.id); + message.folder = sent.id; + EntityOperation.queue(this, db, message, EntityOperation.ADD); + } else + db.message().setMessageUiHide(message.id, true); db.setTransactionSuccessful(); } finally { diff --git a/app/src/main/res/layout/fragment_identity.xml b/app/src/main/res/layout/fragment_identity.xml index ee66bc87c8..87122e9594 100644 --- a/app/src/main/res/layout/fragment_identity.xml +++ b/app/src/main/res/layout/fragment_identity.xml @@ -485,6 +485,25 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbReadReceipt" /> + + + +