Search in sources :

Example 56 with MessageReference

use of com.fsck.k9.controller.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);
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) MessageReference(com.fsck.k9.activity.MessageReference) Notification(android.app.Notification) Test(org.junit.Test)

Example 57 with MessageReference

use of com.fsck.k9.controller.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());
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference) Test(org.junit.Test)

Example 58 with MessageReference

use of com.fsck.k9.controller.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;
}
Also used : Account(com.fsck.k9.Account) Intent(android.content.Intent)

Example 59 with MessageReference

use of com.fsck.k9.controller.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);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference) Test(org.junit.Test)

Example 60 with MessageReference

use of com.fsck.k9.controller.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);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference) Test(org.junit.Test)

Aggregations

MessageReference (com.fsck.k9.activity.MessageReference)49 PendingIntent (android.app.PendingIntent)25 Account (com.fsck.k9.Account)22 Test (org.junit.Test)14 LocalMessage (com.fsck.k9.mailstore.LocalMessage)13 MessageReference (com.fsck.k9.controller.MessageReference)12 NotificationCompat (android.support.v4.app.NotificationCompat)9 ArrayList (java.util.ArrayList)9 Notification (android.app.Notification)8 List (java.util.List)7 MessagingException (com.fsck.k9.mail.MessagingException)6 LocalFolder (com.fsck.k9.mailstore.LocalFolder)5 SearchAccount (com.fsck.k9.search.SearchAccount)5 HashMap (java.util.HashMap)5 Cursor (android.database.Cursor)3 Message (com.fsck.k9.mail.Message)3 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2