mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 06:31:17 +00:00
Check if system folders selectable
This commit is contained in:
parent
0f32aa66a8
commit
96335e38b2
2 changed files with 31 additions and 14 deletions
|
@ -1623,17 +1623,21 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
boolean gmail = args.getBoolean("gmail");
|
boolean gmail = args.getBoolean("gmail");
|
||||||
|
|
||||||
|
boolean hasInbox = false;
|
||||||
boolean hasArchive = false;
|
boolean hasArchive = false;
|
||||||
boolean hasTrash = false;
|
boolean hasTrash = false;
|
||||||
boolean hasJunk = false;
|
boolean hasJunk = false;
|
||||||
if (folders != null)
|
if (folders != null)
|
||||||
for (EntityFolder folder : folders)
|
for (EntityFolder folder : folders)
|
||||||
if (EntityFolder.ARCHIVE.equals(folder.type))
|
if (folder.selectable)
|
||||||
hasArchive = true;
|
if (EntityFolder.INBOX.equals(folder.type))
|
||||||
else if (EntityFolder.TRASH.equals(folder.type))
|
hasInbox = true;
|
||||||
hasTrash = true;
|
else if (EntityFolder.ARCHIVE.equals(folder.type))
|
||||||
else if (EntityFolder.JUNK.equals(folder.type))
|
hasArchive = true;
|
||||||
hasJunk = true;
|
else if (EntityFolder.TRASH.equals(folder.type))
|
||||||
|
hasTrash = true;
|
||||||
|
else if (EntityFolder.JUNK.equals(folder.type))
|
||||||
|
hasJunk = true;
|
||||||
|
|
||||||
boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType);
|
boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType);
|
||||||
boolean inSent = EntityFolder.SENT.equals(message.folderType);
|
boolean inSent = EntityFolder.SENT.equals(message.folderType);
|
||||||
|
@ -1648,7 +1652,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
boolean trash = (move || outbox || debug ||
|
boolean trash = (move || outbox || debug ||
|
||||||
message.accountProtocol == EntityAccount.TYPE_POP);
|
message.accountProtocol == EntityAccount.TYPE_POP);
|
||||||
boolean junk = (move && hasJunk);
|
boolean junk = (move && hasJunk);
|
||||||
boolean inbox = (move && (inArchive || inTrash || inJunk));
|
boolean inbox = (move && hasInbox && (inArchive || inTrash || inJunk));
|
||||||
boolean keywords = (!message.folderReadOnly && message.uid != null &&
|
boolean keywords = (!message.folderReadOnly && message.uid != null &&
|
||||||
message.accountProtocol == EntityAccount.TYPE_IMAP);
|
message.accountProtocol == EntityAccount.TYPE_IMAP);
|
||||||
boolean labels = (gmail && move && !inTrash && !inJunk && !outbox);
|
boolean labels = (gmail && move && !inTrash && !inJunk && !outbox);
|
||||||
|
|
|
@ -2752,13 +2752,24 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EntityAccount account : accounts.values()) {
|
for (EntityAccount account : accounts.values()) {
|
||||||
boolean hasArchive = (account.protocol == EntityAccount.TYPE_IMAP &&
|
boolean hasInbox = false;
|
||||||
db.folder().getFolderByType(account.id, EntityFolder.ARCHIVE) != null);
|
boolean hasArchive = false;
|
||||||
boolean hasTrash = (account.protocol == EntityAccount.TYPE_IMAP &&
|
boolean hasTrash = false;
|
||||||
db.folder().getFolderByType(account.id, EntityFolder.TRASH) != null);
|
boolean hasJunk = false;
|
||||||
boolean hasJunk = (account.protocol == EntityAccount.TYPE_IMAP &&
|
|
||||||
db.folder().getFolderByType(account.id, EntityFolder.JUNK) != null);
|
|
||||||
|
|
||||||
|
if (account.protocol == EntityAccount.TYPE_IMAP) {
|
||||||
|
EntityFolder inbox = db.folder().getFolderByType(account.id, EntityFolder.INBOX);
|
||||||
|
EntityFolder archive = db.folder().getFolderByType(account.id, EntityFolder.ARCHIVE);
|
||||||
|
EntityFolder trash = db.folder().getFolderByType(account.id, EntityFolder.TRASH);
|
||||||
|
EntityFolder junk = db.folder().getFolderByType(account.id, EntityFolder.JUNK);
|
||||||
|
|
||||||
|
hasInbox = (inbox != null && inbox.selectable);
|
||||||
|
hasArchive = (archive != null && archive.selectable);
|
||||||
|
hasTrash = (trash != null && trash.selectable);
|
||||||
|
hasJunk = (junk != null && junk.selectable);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.hasInbox = (result.hasInbox == null ? hasInbox : result.hasInbox && hasInbox);
|
||||||
result.hasArchive = (result.hasArchive == null ? hasArchive : result.hasArchive && hasArchive);
|
result.hasArchive = (result.hasArchive == null ? hasArchive : result.hasArchive && hasArchive);
|
||||||
result.hasTrash = (result.hasTrash == null ? hasTrash : result.hasTrash && hasTrash);
|
result.hasTrash = (result.hasTrash == null ? hasTrash : result.hasTrash && hasTrash);
|
||||||
result.hasJunk = (result.hasJunk == null ? hasJunk : result.hasJunk && hasJunk);
|
result.hasJunk = (result.hasJunk == null ? hasJunk : result.hasJunk && hasJunk);
|
||||||
|
@ -2773,6 +2784,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
if (result.isJunk == null) result.isJunk = false;
|
if (result.isJunk == null) result.isJunk = false;
|
||||||
if (result.isDrafts == null) result.isDrafts = false;
|
if (result.isDrafts == null) result.isDrafts = false;
|
||||||
|
|
||||||
|
if (result.hasInbox == null) result.hasInbox = false;
|
||||||
if (result.hasArchive == null) result.hasArchive = false;
|
if (result.hasArchive == null) result.hasArchive = false;
|
||||||
if (result.hasTrash == null) result.hasTrash = false;
|
if (result.hasTrash == null) result.hasTrash = false;
|
||||||
if (result.hasJunk == null) result.hasJunk = false;
|
if (result.hasJunk == null) result.hasJunk = false;
|
||||||
|
@ -2823,7 +2835,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
importance.add(Menu.NONE, R.string.title_importance_low, 3, R.string.title_importance_low)
|
importance.add(Menu.NONE, R.string.title_importance_low, 3, R.string.title_importance_low)
|
||||||
.setEnabled(!EntityMessage.PRIORITIY_LOW.equals(result.importance));
|
.setEnabled(!EntityMessage.PRIORITIY_LOW.equals(result.importance));
|
||||||
|
|
||||||
if (!result.isInbox) // not is inbox
|
if (result.hasInbox && !result.isInbox) // not is inbox
|
||||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_folder_inbox, order++, R.string.title_folder_inbox);
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_folder_inbox, order++, R.string.title_folder_inbox);
|
||||||
|
|
||||||
if (result.hasArchive && !result.isArchive) // has archive and not is archive
|
if (result.hasArchive && !result.isArchive) // has archive and not is archive
|
||||||
|
@ -7631,6 +7643,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
boolean flagged;
|
boolean flagged;
|
||||||
boolean unflagged;
|
boolean unflagged;
|
||||||
Integer importance;
|
Integer importance;
|
||||||
|
Boolean hasInbox;
|
||||||
Boolean hasArchive;
|
Boolean hasArchive;
|
||||||
Boolean hasTrash;
|
Boolean hasTrash;
|
||||||
Boolean hasJunk;
|
Boolean hasJunk;
|
||||||
|
|
Loading…
Reference in a new issue