Added POP3 multiple select

This commit is contained in:
M66B 2019-11-11 14:44:55 +01:00
parent 88d2dcaff4
commit 6bb85cc2c2
4 changed files with 27 additions and 8 deletions

View File

@ -241,13 +241,14 @@ public interface DaoMessage {
" ORDER BY message.received DESC")
List<Long> getMessageWithContent();
@Query("SELECT *" +
@Query("SELECT message.*" +
" FROM message" +
" JOIN account ON account.id = message.account" +
" WHERE account = :account" +
" AND thread = :thread" +
" AND (:id IS NULL OR message.id = :id)" +
" AND (:folder IS NULL OR message.folder = :folder)" +
" AND NOT uid IS NULL" +
" AND (NOT uid IS NULL OR account.pop)" +
" AND NOT ui_hide")
List<EntityMessage> getMessagesByThread(long account, String thread, Long id, Long folder);

View File

@ -1761,12 +1761,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
DB db = DB.getInstance(context);
boolean pop = false;
result.folders = new ArrayList<>();
for (long id : ids) {
EntityMessage message = db.message().getMessage(id);
if (message == null)
continue;
EntityAccount account = db.account().getAccount(message.account);
if (account == null)
continue;
if (account.pop)
pop = true;
if (!result.folders.contains(message.folder))
result.folders.add(message.folder);
@ -1792,7 +1799,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
EntityFolder folder = db.folder().getFolder(message.folder);
boolean isArchive = EntityFolder.ARCHIVE.equals(folder.type);
boolean isTrash = EntityFolder.TRASH.equals(folder.type);
boolean isTrash = (EntityFolder.TRASH.equals(folder.type) || account.pop);
boolean isJunk = EntityFolder.JUNK.equals(folder.type);
boolean isDrafts = EntityFolder.DRAFTS.equals(folder.type);
@ -1820,9 +1827,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (result.hasJunk == null) result.hasJunk = false;
result.accounts = new ArrayList<>();
for (EntityAccount account : db.account().getSynchronizingAccounts())
if (!account.pop)
result.accounts.add(account);
if (!pop)
for (EntityAccount account : db.account().getSynchronizingAccounts())
if (!account.pop)
result.accounts.add(account);
return result;
}
@ -2150,10 +2158,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (message == null)
continue;
EntityAccount account = db.account().getAccount(message.account);
if (account == null)
continue;
List<EntityMessage> messages = db.message().getMessagesByThread(
message.account, message.thread, threading ? null : id, message.folder);
for (EntityMessage threaded : messages)
if (message.uid != null)
if (message.uid != null || account.pop)
ids.add(threaded.id);
}

View File

@ -46,6 +46,9 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica
if (message == null) // happens when restoring state
return true;
if (message.accountPop)
return true;
if (message.uid != null && !message.folderReadOnly)
return true;
@ -62,6 +65,9 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica
if (message == null) // happens when restoring state
return true;
if (message.accountPop)
return true;
if (message.uid != null && !message.folderReadOnly)
return true;

View File

@ -277,7 +277,7 @@ public class ViewModelMessages extends ViewModel {
int count = ds.countItems();
for (int i = 0; i < count; i += 100)
for (TupleMessageEx message : ds.loadRange(i, Math.min(100, count - i)))
if (message.uid != null && !message.folderReadOnly)
if ((message.uid != null && !message.folderReadOnly) || message.accountPop)
ids.add(message.id);
Log.i("Loaded messages #" + ids.size());