use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class MessagingController method downloadPartial.
private void downloadPartial(Folder remoteFolder, LocalFolder localFolder, Message message) throws MessagingException {
/*
* We have a structure to deal with, from which
* we can pull down the parts we want to actually store.
* Build a list of parts we are interested in. Text parts will be downloaded
* right now, attachments will be left for later.
*/
Set<Part> viewables = MessageExtractor.collectTextParts(message);
/*
* Now download the parts we're interested in storing.
*/
for (Part part : viewables) {
remoteFolder.fetchPart(message, part, null);
}
// Store the updated message locally
localFolder.appendMessages(Collections.singletonList(message));
Message localMessage = localFolder.getMessage(message.getUid());
// Set a flag indicating this message has been fully downloaded and can be
// viewed.
localMessage.setFlag(Flag.X_DOWNLOADED_PARTIAL, true);
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class MessagingController method isMessageSuppressed.
private boolean isMessageSuppressed(LocalMessage message) {
long messageId = message.getId();
long folderId = message.getFolder().getId();
EmailProviderCache cache = EmailProviderCache.getCache(message.getFolder().getAccountUuid(), context);
return cache.isMessageHidden(messageId, folderId);
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class NewMailNotificationsTest method testRemoveNewMailNotification.
@Test
public void testRemoveNewMailNotification() throws Exception {
enablePrivacyMode();
MessageReference messageReference = createMessageReference(1);
int notificationIndex = 0;
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
LocalMessage message = createLocalMessage();
NotificationContent content = createNotificationContent();
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
addToNotificationContentCreator(message, content);
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
Notification summaryNotification = createNotification();
addToDeviceNotifications(summaryNotification);
newMailNotifications.addNewMailNotification(account, message, 23);
whenRemovingContentReturn(messageReference, RemoveNotificationResult.cancelNotification(notificationId));
newMailNotifications.removeNewMailNotification(account, messageReference);
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
verify(notificationManager).cancel(notificationId);
verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification);
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class NewMailNotificationsTest method testAddNewMailNotificationWithCancelingExistingNotification.
@Test
public void testAddNewMailNotificationWithCancelingExistingNotification() throws Exception {
int notificationIndex = 0;
LocalMessage message = createLocalMessage();
NotificationContent content = createNotificationContent();
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
addToNotificationContentCreator(message, content);
whenAddingContentReturn(content, AddNotificationResult.replaceNotification(holder));
Notification wearNotification = createNotification();
Notification summaryNotification = createNotification();
addToWearNotifications(holder, wearNotification);
addToDeviceNotifications(summaryNotification);
newMailNotifications.addNewMailNotification(account, message, 42);
int wearNotificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
verify(notificationManager).notify(wearNotificationId, wearNotification);
verify(notificationManager).cancel(wearNotificationId);
verify(notificationManager).notify(summaryNotificationId, summaryNotification);
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class NotificationContentCreatorTest method createFakeLocalMessage.
private LocalMessage createFakeLocalMessage(MessageReference messageReference) throws Exception {
LocalMessage message = mock(LocalMessage.class);
when(message.makeMessageReference()).thenReturn(messageReference);
when(message.getPreviewType()).thenReturn(PreviewType.TEXT);
when(message.getPreview()).thenReturn(PREVIEW);
when(message.getSubject()).thenReturn(SUBJECT);
when(message.getFrom()).thenReturn(new Address[] { new Address(SENDER_ADDRESS, SENDER_NAME) });
when(message.getRecipients(RecipientType.TO)).thenReturn(new Address[] { new Address(RECIPIENT_ADDRESS, RECIPIENT_NAME) });
return message;
}
Aggregations