use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class MessageListFragment method getReferenceForPosition.
private MessageReference getReferenceForPosition(int position) {
Cursor cursor = (Cursor) adapter.getItem(position);
String accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
String folderName = cursor.getString(FOLDER_NAME_COLUMN);
String messageUid = cursor.getString(UID_COLUMN);
return new MessageReference(accountUuid, folderName, messageUid, null);
}
use of com.fsck.k9.activity.MessageReference 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;
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class MessagingController method refreshLocalMessageFlags.
private void refreshLocalMessageFlags(final Account account, final Folder remoteFolder, final LocalFolder localFolder, List<Message> syncFlagMessages, final AtomicInteger progress, final int todo) throws MessagingException {
final String folder = remoteFolder.getName();
if (remoteFolder.supportsFetchingFlags()) {
Timber.d("SYNC: About to sync flags for %d remote messages for folder %s", syncFlagMessages.size(), folder);
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.FLAGS);
List<Message> undeletedMessages = new LinkedList<>();
for (Message message : syncFlagMessages) {
if (!message.isSet(Flag.DELETED)) {
undeletedMessages.add(message);
}
}
remoteFolder.fetch(undeletedMessages, fp, null);
for (Message remoteMessage : syncFlagMessages) {
LocalMessage localMessage = localFolder.getMessage(remoteMessage.getUid());
boolean messageChanged = syncFlags(localMessage, remoteMessage);
if (messageChanged) {
boolean shouldBeNotifiedOf = false;
if (localMessage.isSet(Flag.DELETED) || isMessageSuppressed(localMessage)) {
for (MessagingListener l : getListeners()) {
l.synchronizeMailboxRemovedMessage(account, folder, localMessage);
}
} else {
if (shouldNotifyForMessage(account, localFolder, localMessage)) {
shouldBeNotifiedOf = true;
}
}
// we're only interested in messages that need removing
if (!shouldBeNotifiedOf) {
MessageReference messageReference = localMessage.makeMessageReference();
notificationController.removeNewMailNotification(account, messageReference);
}
}
progress.incrementAndGet();
for (MessagingListener l : getListeners()) {
l.synchronizeMailboxProgress(account, folder, progress.get(), todo);
}
}
}
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class MessagingController method groupMessagesByAccountAndFolder.
@NonNull
private Map<String, Map<String, List<MessageReference>>> groupMessagesByAccountAndFolder(List<MessageReference> messages) {
Map<String, Map<String, List<MessageReference>>> accountMap = new HashMap<>();
for (MessageReference message : messages) {
if (message == null) {
continue;
}
String accountUuid = message.getAccountUuid();
String folderName = message.getFolderName();
Map<String, List<MessageReference>> folderMap = accountMap.get(accountUuid);
if (folderMap == null) {
folderMap = new HashMap<>();
accountMap.put(accountUuid, folderMap);
}
List<MessageReference> messageList = folderMap.get(folderName);
if (messageList == null) {
messageList = new LinkedList<>();
folderMap.put(folderName, messageList);
}
messageList.add(message);
}
return accountMap;
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class NewMailNotificationsTest method testRemoveNewMailNotificationWithoutNotificationData.
@Test
public void testRemoveNewMailNotificationWithoutNotificationData() throws Exception {
MessageReference messageReference = createMessageReference(1);
newMailNotifications.removeNewMailNotification(account, messageReference);
verify(notificationManager, never()).cancel(anyInt());
}
Aggregations