use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class NewMailNotificationsTest method testRemoveNewMailNotificationClearingAllNotifications.
@Test
public void testRemoveNewMailNotificationClearingAllNotifications() throws Exception {
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));
when(newMailNotifications.notificationData.getNewMessagesCount()).thenReturn(0);
setActiveNotificationIds();
newMailNotifications.removeNewMailNotification(account, messageReference);
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
verify(notificationManager).cancel(notificationId);
verify(notificationManager).cancel(summaryNotificationId);
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class NotificationDataTest method testOverflowNotifications.
@Test
public void testOverflowNotifications() {
MessageReference messageReference0 = createMessageReference("1");
MessageReference messageReference1 = createMessageReference("2");
MessageReference messageReference2 = createMessageReference("3");
MessageReference messageReference3 = createMessageReference("4");
MessageReference messageReference4 = createMessageReference("5");
MessageReference messageReference5 = createMessageReference("6");
MessageReference messageReference6 = createMessageReference("7");
MessageReference messageReference7 = createMessageReference("8");
MessageReference messageReference8 = createMessageReference("9");
notificationData.addNotificationContent(createNotificationContent(messageReference8));
notificationData.addNotificationContent(createNotificationContent(messageReference7));
notificationData.addNotificationContent(createNotificationContent(messageReference6));
notificationData.addNotificationContent(createNotificationContent(messageReference5));
notificationData.addNotificationContent(createNotificationContent(messageReference4));
notificationData.addNotificationContent(createNotificationContent(messageReference3));
notificationData.addNotificationContent(createNotificationContent(messageReference2));
notificationData.addNotificationContent(createNotificationContent(messageReference1));
notificationData.addNotificationContent(createNotificationContent(messageReference0));
assertTrue(notificationData.hasSummaryOverflowMessages());
assertEquals(4, notificationData.getSummaryOverflowMessagesCount());
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class NotificationDeleteConfirmation method extractExtras.
private void extractExtras() {
Intent intent = getIntent();
String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT_UUID);
List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES);
List<MessageReference> messagesToDelete = toMessageReferenceList(messageReferenceStrings);
if (accountUuid == null) {
throw new IllegalArgumentException(EXTRA_ACCOUNT_UUID + " can't be null");
}
if (messagesToDelete == null) {
throw new IllegalArgumentException(EXTRA_MESSAGE_REFERENCES + " can't be null");
}
if (messagesToDelete.isEmpty()) {
throw new IllegalArgumentException(EXTRA_MESSAGE_REFERENCES + " can't be empty");
}
Account account = getAccountFromUuid(accountUuid);
if (account == null) {
throw new IllegalStateException(EXTRA_ACCOUNT_UUID + " couldn't be resolved to an account");
}
this.account = account;
this.messagesToDelete = messagesToDelete;
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class WearNotificationsTest method testAddSummaryActionsWithDeleteAllActionEnabled.
@Test
public void testAddSummaryActionsWithDeleteAllActionEnabled() throws Exception {
enableDeleteAction();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
ArrayList<MessageReference> messageReferences = createMessageReferenceList();
NotificationData notificationData = createNotificationData(messageReferences);
PendingIntent deletePendingIntent = createFakePendingIntent(1);
when(actionCreator.getDeleteAllPendingIntent(account, messageReferences, notificationId)).thenReturn(deletePendingIntent);
wearNotifications.addSummaryActions(builder, notificationData);
verifyExtendWasOnlyCalledOnce();
verifyAddAction(R.drawable.ic_action_delete_dark, "Delete All", deletePendingIntent);
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class WearNotificationsTest method testAddSummaryActionsWithArchiveAllActionEnabled.
@Test
public void testAddSummaryActionsWithArchiveAllActionEnabled() throws Exception {
enableArchiveAction();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
ArrayList<MessageReference> messageReferences = createMessageReferenceList();
NotificationData notificationData = createNotificationData(messageReferences);
PendingIntent archivePendingIntent = createFakePendingIntent(1);
when(actionCreator.createArchiveAllPendingIntent(account, messageReferences, notificationId)).thenReturn(archivePendingIntent);
wearNotifications.addSummaryActions(builder, notificationData);
verifyExtendWasOnlyCalledOnce();
verifyAddAction(R.drawable.ic_action_archive_dark, "Archive All", archivePendingIntent);
}
Aggregations