Allow multiple selection of read-only messages, with limitations

This commit is contained in:
M66B 2021-11-29 19:30:18 +01:00
parent ed08936b62
commit d56068c650
2 changed files with 36 additions and 31 deletions

View File

@ -3042,6 +3042,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
folder = db.folder().getFolder(message.folder);
if (folder == null)
continue;
if (folder.read_only)
result.read_only = true;
folders.put(folder.id, folder);
}
@ -3213,43 +3215,45 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
popupMenu.getMenu().add(Menu.NONE, R.string.title_raw_send, order++, R.string.title_raw_send)
.setIcon(R.drawable.twotone_attachment_24);
if (result.hasInbox && !result.isInbox) // not is inbox
popupMenu.getMenu().add(Menu.FIRST, R.string.title_folder_inbox, order++, R.string.title_folder_inbox)
.setIcon(R.drawable.twotone_move_to_inbox_24);
if (!result.read_only) {
if (result.hasInbox && !result.isInbox) // not is inbox
popupMenu.getMenu().add(Menu.FIRST, R.string.title_folder_inbox, order++, R.string.title_folder_inbox)
.setIcon(R.drawable.twotone_move_to_inbox_24);
if (result.hasArchive && !result.isArchive) // has archive and not is archive
popupMenu.getMenu().add(Menu.FIRST, R.string.title_archive, order++, R.string.title_archive)
.setIcon(R.drawable.twotone_archive_24);
if (result.hasArchive && !result.isArchive) // has archive and not is archive
popupMenu.getMenu().add(Menu.FIRST, R.string.title_archive, order++, R.string.title_archive)
.setIcon(R.drawable.twotone_archive_24);
if (result.hasJunk && !result.isJunk && !result.isDrafts) // has junk and not junk/drafts
popupMenu.getMenu().add(Menu.FIRST, R.string.title_spam, order++, R.string.title_spam)
.setIcon(R.drawable.twotone_report_24);
if (result.hasJunk && !result.isJunk && !result.isDrafts) // has junk and not junk/drafts
popupMenu.getMenu().add(Menu.FIRST, R.string.title_spam, order++, R.string.title_spam)
.setIcon(R.drawable.twotone_report_24);
if (!result.isTrash && result.hasTrash && !result.isJunk) // not trash and has trash and not is junk
popupMenu.getMenu().add(Menu.FIRST, R.string.title_trash, order++, R.string.title_trash)
.setIcon(R.drawable.twotone_delete_24);
if (!result.isTrash && result.hasTrash && !result.isJunk) // not trash and has trash and not is junk
popupMenu.getMenu().add(Menu.FIRST, R.string.title_trash, order++, R.string.title_trash)
.setIcon(R.drawable.twotone_delete_24);
if (result.isTrash || !result.hasTrash || result.isJunk || true) // is trash or no trash or is junk
popupMenu.getMenu().add(Menu.FIRST, R.string.title_delete_permanently, order++, R.string.title_delete_permanently)
.setIcon(R.drawable.twotone_delete_forever_24);
if (result.isTrash || !result.hasTrash || result.isJunk || true) // is trash or no trash or is junk
popupMenu.getMenu().add(Menu.FIRST, R.string.title_delete_permanently, order++, R.string.title_delete_permanently)
.setIcon(R.drawable.twotone_delete_forever_24);
for (EntityAccount account : result.accounts) {
String title = getString(R.string.title_move_to_account, account.name);
SpannableString ss = new SpannableString(title);
if (account.name != null && account.color != null) {
int i = title.indexOf(account.name);
int first = title.codePointAt(i);
int count = Character.charCount(first);
ss.setSpan(new ForegroundColorSpan(account.color), i, i + count, 0);
for (EntityAccount account : result.accounts) {
String title = getString(R.string.title_move_to_account, account.name);
SpannableString ss = new SpannableString(title);
if (account.name != null && account.color != null) {
int i = title.indexOf(account.name);
int first = title.codePointAt(i);
int count = Character.charCount(first);
ss.setSpan(new ForegroundColorSpan(account.color), i, i + count, 0);
}
MenuItem item = popupMenu.getMenu().add(Menu.FIRST, R.string.title_move_to_account, order++, ss)
.setIcon(R.drawable.twotone_drive_file_move_24);
item.setIntent(new Intent().putExtra("account", account.id));
}
MenuItem item = popupMenu.getMenu().add(Menu.FIRST, R.string.title_move_to_account, order++, ss)
.setIcon(R.drawable.twotone_drive_file_move_24);
item.setIntent(new Intent().putExtra("account", account.id));
}
if (result.copyto != null)
popupMenu.getMenu().add(Menu.FIRST, R.string.title_copy_to, order++, R.string.title_copy_to)
.setIcon(R.drawable.twotone_file_copy_24);
if (result.copyto != null)
popupMenu.getMenu().add(Menu.FIRST, R.string.title_copy_to, order++, R.string.title_copy_to)
.setIcon(R.drawable.twotone_file_copy_24);
}
popupMenu.insertIcons(context);
@ -8824,6 +8828,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
boolean hasImap;
boolean hasPop;
Boolean leave_deleted;
boolean read_only;
List<Long> folders;
List<EntityAccount> accounts;
EntityAccount copyto;

View File

@ -49,7 +49,7 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica
if (message.accountProtocol != EntityAccount.TYPE_IMAP)
return true;
if (message.uid != null && !message.folderReadOnly)
if (message.uid != null)
return true;
return false;