From 2585b089a463e0f5ba0054ddc8a332467fccd73c Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 4 Apr 2019 17:54:05 +0200 Subject: [PATCH] Added message resync --- FAQ.md | 2 + .../eu/faircode/email/AdapterMessage.java | 40 +++++++++++++++++++ app/src/main/res/menu/menu_message.xml | 4 ++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 47 insertions(+) diff --git a/FAQ.md b/FAQ.md index 4f5cb9562a..0ca71dd790 100644 --- a/FAQ.md +++ b/FAQ.md @@ -355,6 +355,8 @@ You can enable *Encrypt by default* in the identity settings. Encryption is [Autocrypt](https://autocrypt.org/) compatible. For security reasons received messages are not decrypted automatically. +The decrypted message text and decrypted attachments are stored. If you want to undo this, you can use the *resync* message 'more' menu. + Inline PGP in received messages is supported, but inline PGP in outgoing messages is not supported, see [here](https://josefsson.org/inline-openpgp-considered-harmful.html) about why not. diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 966051679e..f0d3b11850 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -2149,6 +2149,41 @@ public class AdapterMessage extends RecyclerView.Adapter() { + @Override + protected Void onExecute(Context context, Bundle args) { + long id = args.getLong("id"); + + DB db = DB.getInstance(context); + try { + db.beginTransaction(); + + EntityMessage message = db.message().getMessage(id); + if (message == null || message.uid == null) + return null; + db.message().deleteMessage(id); + + EntityOperation.sync(context, message.folder, true); + + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + + return null; + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Helper.unexpectedError(context, owner, ex); + } + }.execute(context, owner, args, "message:share"); + } + private void onMenuCreateRule(ActionData data) { Intent rule = new Intent(ActivityView.ACTION_EDIT_RULE); rule.putExtra("account", data.message.account); @@ -2535,6 +2570,8 @@ public class AdapterMessage extends RecyclerView.Adapter 0); + popupMenu.getMenu().findItem(R.id.menu_resync).setEnabled(data.message.uid != null); + popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem target) { @@ -2561,6 +2598,9 @@ public class AdapterMessage extends RecyclerView.Adapter + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3f0947da57..31aae847bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -422,6 +422,7 @@ Encrypt Decrypt + Resync OpenKeychain not found Message is not encrypted