From 157b37144de33e4cad6f176b4dc697e68bb572da Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 21 Oct 2018 14:53:39 +0000 Subject: [PATCH] Folder checks --- .../eu/faircode/email/AdapterMessage.java | 35 +++++++++++++++---- .../eu/faircode/email/FragmentCompose.java | 2 +- .../eu/faircode/email/FragmentMessages.java | 17 +++++---- app/src/main/res/values/strings.xml | 1 + 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 4c137e21..59a70237 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -394,13 +394,16 @@ public class AdapterMessage extends PagedListAdapter folders) { if (bnvActions.hasTransientState()) { + boolean hasJunk = false; boolean hasTrash = false; boolean hasArchive = false; boolean hasUser = false; if (folders != null) for (EntityFolder folder : folders) { - if (EntityFolder.TRASH.equals(folder.type)) + 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; @@ -414,6 +417,7 @@ public class AdapterMessage extends PagedListAdapter= 0 && direction == ItemTouchHelper.RIGHT) - target = db.folder().getFolder(swipeTarget); - - if (target == null || !target.account.equals((message.account))) { + if (swipeTarget < 0 || direction == ItemTouchHelper.LEFT) { if (EntityFolder.ARCHIVE.equals(folder.type) || EntityFolder.TRASH.equals(folder.type)) target = db.folder().getFolderByType(message.account, EntityFolder.INBOX); else { if (direction == ItemTouchHelper.RIGHT) target = db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE); - if (direction == ItemTouchHelper.LEFT || target == null) + else if (direction == ItemTouchHelper.LEFT) target = db.folder().getFolderByType(message.account, EntityFolder.TRASH); - if (target == null) - target = db.folder().getFolderByType(message.account, EntityFolder.INBOX); } - } + } else + target = db.folder().getFolder(swipeTarget); + + if (target == null || !target.account.equals((message.account))) + throw new IllegalArgumentException(getString(R.string.title_no_target)); result.target = target.name; result.display = (target.display == null ? target.name : target.display); @@ -816,7 +815,7 @@ public class FragmentMessages extends FragmentEx { folders.add(0, sent); EntityFolder inbox = db.folder().getFolderByType(folder.account, EntityFolder.INBOX); - if (!inbox.id.equals(fid)) + if (inbox != null && !inbox.id.equals(fid)) folders.add(0, inbox); return folders; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a8aed39a..1c9a911d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -126,6 +126,7 @@ Password missing No primary account or no drafts folder No primary account or no archive folder + Target folder not set or missing This provider does not support push messages. Reception of new messages can be delayed. IMAP UIDPLUS not supported, see the FAQ Delete this account permanently?