use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class MessageLoaderHelper method startOrResumeDecodeMessage.
// decode message
private void startOrResumeDecodeMessage() {
LocalMessageExtractorLoader loader = (LocalMessageExtractorLoader) loaderManager.<MessageViewInfo>getLoader(DECODE_MESSAGE_LOADER_ID);
boolean isLoaderStale = (loader == null) || !loader.isCreatedFor(localMessage, messageCryptoAnnotations);
if (isLoaderStale) {
Timber.d("Creating new decode message loader");
loaderManager.restartLoader(DECODE_MESSAGE_LOADER_ID, null, decodeMessageLoaderCallback);
} else {
Timber.d("Reusing decode message loader");
loaderManager.initLoader(DECODE_MESSAGE_LOADER_ID, null, decodeMessageLoaderCallback);
}
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class MessageLoaderHelper method startOrResumeLocalMessageLoader.
// load from database
private void startOrResumeLocalMessageLoader() {
LocalMessageLoader loader = (LocalMessageLoader) loaderManager.<LocalMessage>getLoader(LOCAL_MESSAGE_LOADER_ID);
boolean isLoaderStale = (loader == null) || !loader.isCreatedFor(messageReference);
if (isLoaderStale) {
Timber.d("Creating new local message loader");
cancelAndClearCryptoOperation();
cancelAndClearDecodeLoader();
loaderManager.restartLoader(LOCAL_MESSAGE_LOADER_ID, null, localMessageLoaderCallback);
} else {
Timber.d("Reusing local message loader");
loaderManager.initLoader(LOCAL_MESSAGE_LOADER_ID, null, localMessageLoaderCallback);
}
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class NewMailNotificationsTest method testAddNewMailNotificationWithPrivacyModeEnabled.
@Test
public void testAddNewMailNotificationWithPrivacyModeEnabled() throws Exception {
enablePrivacyMode();
int notificationIndex = 0;
LocalMessage message = createLocalMessage();
NotificationContent content = createNotificationContent();
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
addToNotificationContentCreator(message, content);
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
Notification wearNotification = createNotification();
addToDeviceNotifications(wearNotification);
newMailNotifications.addNewMailNotification(account, message, 42);
int wearNotificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
verify(notificationManager, never()).notify(eq(wearNotificationId), any(Notification.class));
verify(notificationManager).notify(summaryNotificationId, wearNotification);
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class NewMailNotificationsTest method testAddNewMailNotificationTwice.
@Test
public void testAddNewMailNotificationTwice() throws Exception {
int notificationIndexOne = 0;
int notificationIndexTwo = 1;
LocalMessage messageOne = createLocalMessage();
LocalMessage messageTwo = createLocalMessage();
NotificationContent contentOne = createNotificationContent();
NotificationContent contentTwo = createNotificationContent();
NotificationHolder holderOne = createNotificationHolder(contentOne, notificationIndexOne);
NotificationHolder holderTwo = createNotificationHolder(contentTwo, notificationIndexTwo);
addToNotificationContentCreator(messageOne, contentOne);
addToNotificationContentCreator(messageTwo, contentTwo);
whenAddingContentReturn(contentOne, AddNotificationResult.newNotification(holderOne));
whenAddingContentReturn(contentTwo, AddNotificationResult.newNotification(holderTwo));
Notification wearNotificationOne = createNotification();
Notification wearNotificationTwo = createNotification();
Notification summaryNotification = createNotification();
addToWearNotifications(holderOne, wearNotificationOne);
addToWearNotifications(holderTwo, wearNotificationTwo);
addToDeviceNotifications(summaryNotification);
newMailNotifications.addNewMailNotification(account, messageOne, 42);
newMailNotifications.addNewMailNotification(account, messageTwo, 42);
int wearNotificationIdOne = NotificationIds.getNewMailStackedNotificationId(account, notificationIndexOne);
int wearNotificationIdTwo = NotificationIds.getNewMailStackedNotificationId(account, notificationIndexTwo);
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
verify(notificationManager).notify(wearNotificationIdOne, wearNotificationOne);
verify(notificationManager).notify(wearNotificationIdTwo, wearNotificationTwo);
verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification);
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class NewMailNotificationsTest method testRemoveNewMailNotificationWithUnknownMessageReference.
@Test
public void testRemoveNewMailNotificationWithUnknownMessageReference() throws Exception {
enablePrivacyMode();
MessageReference messageReference = createMessageReference(1);
int notificationIndex = 0;
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.unknownNotification());
newMailNotifications.removeNewMailNotification(account, messageReference);
verify(notificationManager, never()).cancel(anyInt());
}
Aggregations