use of com.fsck.k9.Account in project k-9 by k9mail.
the class MessagingController method setFlagForThreadsInCache.
private void setFlagForThreadsInCache(final Account account, final List<Long> threadRootIds, final Flag flag, final boolean newState) {
EmailProviderCache cache = EmailProviderCache.getCache(account.getUuid(), context);
String columnName = LocalStore.getColumnNameForFlag(flag);
String value = Integer.toString((newState) ? 1 : 0);
cache.setValueForThreads(threadRootIds, columnName, value);
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class MessagingController method processPendingEmptyTrash.
void processPendingEmptyTrash(Account account) throws MessagingException {
Store remoteStore = account.getRemoteStore();
Folder remoteFolder = remoteStore.getFolder(account.getTrashFolderName());
try {
if (remoteFolder.exists()) {
remoteFolder.open(Folder.OPEN_MODE_RW);
remoteFolder.setFlags(Collections.singleton(Flag.DELETED), true);
if (Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
remoteFolder.expunge();
}
// When we empty trash, we need to actually synchronize the folder
// or local deletes will never get cleaned up
synchronizeFolder(account, remoteFolder, true, 0, null);
compact(account, null);
}
} finally {
closeFolder(remoteFolder);
}
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class MlfUtils method getOpenFolder.
static LocalFolder getOpenFolder(String folderName, Account account) throws MessagingException {
LocalStore localStore = account.getLocalStore();
LocalFolder localFolder = localStore.getFolder(folderName);
localFolder.open(Folder.OPEN_MODE_RO);
return localFolder;
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class MessageListFragment method changeSort.
/**
* Change the sort type and sort order used for the message list.
*
* @param sortType
* Specifies which field to use for sorting the message list.
* @param sortAscending
* Specifies the sort order. If this argument is {@code null} the default search order
* for the sort type is used.
*/
// FIXME: Don't save the changes in the UI thread
private void changeSort(SortType sortType, Boolean sortAscending) {
this.sortType = sortType;
Account account = this.account;
if (account != null) {
account.setSortType(this.sortType);
if (sortAscending == null) {
this.sortAscending = account.isSortAscending(this.sortType);
} else {
this.sortAscending = sortAscending;
}
account.setSortAscending(this.sortType, this.sortAscending);
sortDateAscending = account.isSortAscending(SortType.SORT_DATE);
account.save(preferences);
} else {
K9.setSortType(this.sortType);
if (sortAscending == null) {
this.sortAscending = K9.isSortAscending(this.sortType);
} else {
this.sortAscending = sortAscending;
}
K9.setSortAscending(this.sortType, this.sortAscending);
sortDateAscending = K9.isSortAscending(SortType.SORT_DATE);
StorageEditor editor = preferences.getStorage().edit();
K9.save(editor);
editor.commit();
}
reSort();
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class MessageListFragment method groupMessagesByAccount.
private Map<Account, List<MessageReference>> groupMessagesByAccount(final List<MessageReference> messages) {
Map<Account, List<MessageReference>> messagesByAccount = new HashMap<>();
for (MessageReference message : messages) {
Account account = preferences.getAccount(message.getAccountUuid());
List<MessageReference> msgList = messagesByAccount.get(account);
if (msgList == null) {
msgList = new ArrayList<>();
messagesByAccount.put(account, msgList);
}
msgList.add(message);
}
return messagesByAccount;
}
Aggregations