From aaafa4275ae07187cced0afb533ac9020de83807 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 25 Jan 2019 07:09:03 +0000 Subject: [PATCH] Better target folder evaluation --- .../eu/faircode/email/FragmentMessages.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 2f3c7eba34..7c10ff407e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -788,48 +788,48 @@ public class FragmentMessages extends FragmentBase { private void onMore() { Bundle args = new Bundle(); - args.putLong("folder", folder); args.putLongArray("ids", getSelection()); new SimpleTask() { - @Override protected MoreResult onExecute(Context context, Bundle args) { - long fid = args.getLong("folder"); long[] ids = args.getLongArray("ids"); MoreResult result = new MoreResult(); DB db = DB.getInstance(context); + List fids = new ArrayList<>(); for (long id : ids) { EntityMessage message = db.message().getMessage(id); - if (message != null) { - if (message.ui_seen) - result.seen = true; - else - result.unseen = true; + if (message == null) + continue; - if (message.ui_flagged) - result.flagged = true; - else - result.unflagged = true; - - result.hasArchive = (result.hasArchive && - db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE) != null); - result.hasTrash = (result.hasTrash && - db.folder().getFolderByType(message.account, EntityFolder.TRASH) != null); - result.hasJunk = (result.hasJunk && - db.folder().getFolderByType(message.account, EntityFolder.JUNK) != null); - } - } + if (!fids.contains(message.folder)) + fids.add(message.folder); - EntityFolder folder = db.folder().getFolder(fid); - if (folder != null) { + EntityFolder folder = db.folder().getFolder(message.folder); result.isArchive = EntityFolder.ARCHIVE.equals(folder.type); result.isTrash = EntityFolder.TRASH.equals(folder.type); result.isJunk = EntityFolder.JUNK.equals(folder.type); result.isDrafts = EntityFolder.DRAFTS.equals(folder.type); + + if (message.ui_seen) + result.seen = true; + else + result.unseen = true; + + if (message.ui_flagged) + result.flagged = true; + else + result.unflagged = true; + + result.hasArchive = (result.hasArchive && + db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE) != null); + result.hasTrash = (result.hasTrash && + db.folder().getFolderByType(message.account, EntityFolder.TRASH) != null); + result.hasJunk = (result.hasJunk && + db.folder().getFolderByType(message.account, EntityFolder.JUNK) != null); } result.accounts = db.account().getAccounts(true); @@ -854,7 +854,7 @@ public class FragmentMessages extends FragmentBase { !EntityFolder.ARCHIVE.equals(target.type) && !EntityFolder.TRASH.equals(target.type) && !EntityFolder.JUNK.equals(target.type) && - !target.id.equals(fid)) + (fids.size() != 1 || !fids.contains(target.id))) targets.add(target); EntityFolder.sort(context, targets); result.targets.put(account, targets);