Improved target folder selection

pull/147/head
M66B 6 years ago
parent 740559d531
commit c29adbd894

@ -827,12 +827,6 @@ public class FragmentMessages extends FragmentBase {
if (!fids.contains(message.folder)) if (!fids.contains(message.folder))
fids.add(message.folder); fids.add(message.folder);
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) if (message.ui_seen)
result.seen = true; result.seen = true;
else else
@ -843,14 +837,35 @@ public class FragmentMessages extends FragmentBase {
else else
result.unflagged = true; result.unflagged = true;
result.hasArchive = (result.hasArchive && EntityFolder folder = db.folder().getFolder(message.folder);
db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE) != null); boolean isArchive = EntityFolder.ARCHIVE.equals(folder.type);
result.hasTrash = (result.hasTrash && boolean isTrash = EntityFolder.TRASH.equals(folder.type);
db.folder().getFolderByType(message.account, EntityFolder.TRASH) != null); boolean isJunk = EntityFolder.JUNK.equals(folder.type);
result.hasJunk = (result.hasJunk && boolean isDrafts = EntityFolder.DRAFTS.equals(folder.type);
db.folder().getFolderByType(message.account, EntityFolder.JUNK) != null);
result.isArchive = (result.isArchive == null ? isArchive : result.isArchive && isArchive);
result.isTrash = (result.isTrash == null ? isTrash : result.isTrash && isArchive);
result.isJunk = (result.isJunk == null ? isJunk : result.isJunk && isArchive);
result.isDrafts = (result.isDrafts == null ? isDrafts : result.isDrafts && isArchive);
boolean hasArchive = (db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE) != null);
boolean hasTrash = (db.folder().getFolderByType(message.account, EntityFolder.TRASH) != null);
boolean hasJunk = (db.folder().getFolderByType(message.account, EntityFolder.JUNK) != null);
result.hasArchive = (result.hasArchive == null ? hasArchive : result.hasArchive && hasArchive);
result.hasTrash = (result.hasTrash == null ? hasTrash : result.hasTrash && hasTrash);
result.hasJunk = (result.hasJunk == null ? hasJunk : result.hasJunk && hasJunk);
} }
if (result.isArchive == null) result.isArchive = false;
if (result.isTrash == null) result.isTrash = false;
if (result.isJunk == null) result.isJunk = false;
if (result.isDrafts == null) result.isDrafts = false;
if (result.hasArchive == null) result.hasArchive = false;
if (result.hasTrash == null) result.hasTrash = false;
if (result.hasJunk == null) result.hasJunk = false;
result.accounts = db.account().getAccounts(true); result.accounts = db.account().getAccounts(true);
final Collator collator = Collator.getInstance(Locale.getDefault()); final Collator collator = Collator.getInstance(Locale.getDefault());
@ -2254,13 +2269,13 @@ public class FragmentMessages extends FragmentBase {
boolean unseen; boolean unseen;
boolean flagged; boolean flagged;
boolean unflagged; boolean unflagged;
boolean hasArchive = true; Boolean hasArchive;
boolean hasTrash = true; Boolean hasTrash;
boolean hasJunk = true; Boolean hasJunk;
boolean isArchive; Boolean isArchive;
boolean isTrash; Boolean isTrash;
boolean isJunk; Boolean isJunk;
boolean isDrafts; Boolean isDrafts;
List<EntityAccount> accounts; List<EntityAccount> accounts;
Map<EntityAccount, List<EntityFolder>> targets = new HashMap<>(); Map<EntityAccount, List<EntityFolder>> targets = new HashMap<>();
} }

Loading…
Cancel
Save