1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 18:27:43 +00:00

POP3 multiple select

This commit is contained in:
M66B 2019-02-11 20:40:02 +00:00
parent 53cf0f98f1
commit 82e7ddd8c3
2 changed files with 71 additions and 45 deletions

View file

@ -445,6 +445,7 @@ public class FragmentMessages extends FragmentBase {
new ItemTouchHelper(touchHelper).attachToRecyclerView(rvMessage);
selectionPredicate = new SelectionPredicateMessage(rvMessage);
selectionPredicate.setFolder(viewType == AdapterMessage.ViewType.FOLDER);
selectionTracker = new SelectionTracker.Builder<>(
"messages-selection",
@ -929,6 +930,18 @@ public class FragmentMessages extends FragmentBase {
if (message == null)
continue;
EntityAccount account = db.account().getAccount(message.account);
if (account.pop) {
if (message.ui_seen)
result.seen = true;
else
result.unseen = true;
result.isTrash = true;
continue;
}
if (!fids.contains(message.folder))
fids.add(message.folder);
@ -971,6 +984,9 @@ public class FragmentMessages extends FragmentBase {
if (result.hasTrash == null) result.hasTrash = false;
if (result.hasJunk == null) result.hasJunk = false;
if (fids.size() == 0) // POP
return result;
result.accounts = db.account().getAccounts(true);
final Collator collator = Collator.getInstance(Locale.getDefault());
@ -985,7 +1001,8 @@ public class FragmentMessages extends FragmentBase {
}
});
for (EntityAccount account : result.accounts) {
for (EntityAccount account : result.accounts)
if (!account.pop) {
List<EntityFolder> targets = new ArrayList<>();
List<EntityFolder> folders = db.folder().getFolders(account.id);
for (EntityFolder target : folders)
@ -1013,9 +1030,9 @@ public class FragmentMessages extends FragmentBase {
popupMenu.getMenu().add(Menu.NONE, action_snooze, 3, R.string.title_snooze);
if (result.unflagged)
if (result.unflagged != null && result.unflagged)
popupMenu.getMenu().add(Menu.NONE, action_flag, 4, R.string.title_flag);
if (result.flagged)
if (result.flagged != null && result.flagged)
popupMenu.getMenu().add(Menu.NONE, action_unflag, 5, R.string.title_unflag);
if (result.hasArchive && !result.isArchive) // has archive and not is archive/drafts
@ -1031,7 +1048,9 @@ public class FragmentMessages extends FragmentBase {
popupMenu.getMenu().add(Menu.NONE, action_junk, 9, R.string.title_spam);
int order = 11;
for (EntityAccount account : result.accounts) {
if (result.accounts != null)
for (EntityAccount account : result.accounts)
if (!account.pop) {
SubMenu smenu = popupMenu.getMenu()
.addSubMenu(Menu.NONE, 0, order++, getString(R.string.title_move_to, account.name));
int sorder = 1;
@ -1275,7 +1294,6 @@ public class FragmentMessages extends FragmentBase {
List<EntityMessage> messages = db.message().getMessageByThread(
message.account, message.thread, threading ? null : id, message.folder);
for (EntityMessage threaded : messages)
if (threaded.uid != null)
EntityOperation.queue(context, db, threaded, EntityOperation.DELETE);
}
}
@ -2131,8 +2149,7 @@ public class FragmentMessages extends FragmentBase {
boolean trashable = false;
boolean archivable = false;
for (EntityMessage message : messages)
if (message.uid != null) {
for (EntityMessage message : messages) {
EntityFolder folder = db.folder().getFolder(message.folder);
if (!EntityFolder.DRAFTS.equals(folder.type) &&
!EntityFolder.OUTBOX.equals(folder.type) &&
@ -2515,8 +2532,8 @@ public class FragmentMessages extends FragmentBase {
private class MoreResult {
boolean seen;
boolean unseen;
boolean flagged;
boolean unflagged;
Boolean flagged;
Boolean unflagged;
Boolean hasArchive;
Boolean hasTrash;
Boolean hasJunk;

View file

@ -25,6 +25,7 @@ import androidx.recyclerview.widget.RecyclerView;
public class SelectionPredicateMessage extends SelectionTracker.SelectionPredicate<Long> {
private boolean enabled;
private boolean folder;
private RecyclerView recyclerView;
SelectionPredicateMessage(RecyclerView recyclerView) {
@ -36,6 +37,10 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica
this.enabled = enabled;
}
void setFolder(boolean folder) {
this.folder = folder;
}
@Override
public boolean canSetStateForKey(@NonNull Long key, boolean nextState) {
if (!enabled)
@ -43,8 +48,10 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica
AdapterMessage adapter = (AdapterMessage) recyclerView.getAdapter();
TupleMessageEx message = adapter.getItemForKey(key);
if (message == null)
return false;
if (message != null && message.uid != null)
if (message.uid != null || (folder && message.accountPop))
return true;
return false;
@ -57,8 +64,10 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica
AdapterMessage adapter = (AdapterMessage) recyclerView.getAdapter();
TupleMessageEx message = adapter.getItemAtPosition(position);
if (message == null)
return false;
if (message != null && message.uid != null)
if (message.uid != null || (folder && message.accountPop))
return true;
return false;