From eaf9005b62cf40a962290f9c2dd065843a3f7818 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 17 Nov 2018 16:15:03 +0100 Subject: [PATCH] Allow deleting failed outbound messages --- .../eu/faircode/email/AdapterMessage.java | 81 +++++++++---------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index d420a9852c..747e375f73 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -450,46 +450,43 @@ public class AdapterMessage extends PagedListAdapter>() { - @Override - public void onChanged(@Nullable List folders) { - boolean hasJunk = false; - boolean hasTrash = false; - boolean hasArchive = false; + db.folder().liveSystemFolders(message.account).observe(owner, new Observer>() { + @Override + public void onChanged(@Nullable List folders) { + boolean hasJunk = false; + boolean hasTrash = false; + boolean hasArchive = false; - if (folders != null) - for (EntityFolder folder : folders) { - if (EntityFolder.JUNK.equals(folder.type)) - hasJunk = true; - else if (EntityFolder.TRASH.equals(folder.type)) - hasTrash = true; - else if (EntityFolder.ARCHIVE.equals(folder.type)) - hasArchive = true; - } + if (folders != null) + for (EntityFolder folder : folders) { + if (EntityFolder.JUNK.equals(folder.type)) + hasJunk = true; + else if (EntityFolder.TRASH.equals(folder.type)) + hasTrash = true; + else if (EntityFolder.ARCHIVE.equals(folder.type)) + hasArchive = true; + } - boolean inOutbox = EntityFolder.OUTBOX.equals(message.folderType); - boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType); - boolean inTrash = EntityFolder.TRASH.equals(message.folderType); + boolean inOutbox = EntityFolder.OUTBOX.equals(message.folderType); + boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType); + boolean inTrash = EntityFolder.TRASH.equals(message.folderType); - ActionData data = new ActionData(); - data.hasJunk = hasJunk; - data.delete = (inTrash || !hasTrash || inOutbox); - data.message = message; - bnvActions.setTag(data); + ActionData data = new ActionData(); + data.hasJunk = hasJunk; + data.delete = (inTrash || !hasTrash || inOutbox); + data.message = message; + bnvActions.setTag(data); - bnvActions.getMenu().findItem(R.id.action_delete).setVisible((message.uid != null && hasTrash) || (inOutbox && !TextUtils.isEmpty(message.error))); - bnvActions.getMenu().findItem(R.id.action_move).setVisible(message.uid != null); - bnvActions.getMenu().findItem(R.id.action_archive).setVisible(message.uid != null && !inArchive && hasArchive); + bnvActions.getMenu().findItem(R.id.action_delete).setVisible((message.uid != null && hasTrash) || (inOutbox && !TextUtils.isEmpty(message.error))); + bnvActions.getMenu().findItem(R.id.action_move).setVisible(message.uid != null); + bnvActions.getMenu().findItem(R.id.action_archive).setVisible(message.uid != null && !inArchive && hasArchive); + bnvActions.getMenu().findItem(R.id.action_reply).setEnabled(message.content); + bnvActions.getMenu().findItem(R.id.action_reply).setVisible(!inOutbox); - bnvActions.getMenu().findItem(R.id.action_reply).setEnabled(message.content); - bnvActions.getMenu().findItem(R.id.action_reply).setVisible(!inOutbox); - - bnvActions.setVisibility(View.VISIBLE); - vSeparatorBody.setVisibility(View.GONE); - } - }); - } + bnvActions.setVisibility(View.VISIBLE); + vSeparatorBody.setVisibility(View.GONE); + } + }); // Observe attachments db.attachment().liveAttachments(message.id).observe(owner, @@ -1163,30 +1160,24 @@ public class AdapterMessage extends PagedListAdapter