Search in sources :

Example 16 with MessageReference

use of com.fsck.k9.controller.MessageReference 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;
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) Address(com.fsck.k9.mail.Address)

Example 17 with MessageReference

use of com.fsck.k9.controller.MessageReference in project k-9 by k9mail.

the class NotificationDataTest method testGetAllMessageReferences.

@Test
public void testGetAllMessageReferences() throws Exception {
    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));
    List<MessageReference> messageReferences = notificationData.getAllMessageReferences();
    assertEquals(9, messageReferences.size());
    assertEquals(messageReference0, messageReferences.get(0));
    assertEquals(messageReference1, messageReferences.get(1));
    assertEquals(messageReference2, messageReferences.get(2));
    assertEquals(messageReference3, messageReferences.get(3));
    assertEquals(messageReference4, messageReferences.get(4));
    assertEquals(messageReference5, messageReferences.get(5));
    assertEquals(messageReference6, messageReferences.get(6));
    assertEquals(messageReference7, messageReferences.get(7));
    assertEquals(messageReference8, messageReferences.get(8));
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference) Test(org.junit.Test)

Example 18 with MessageReference

use of com.fsck.k9.controller.MessageReference in project k-9 by k9mail.

the class WearNotificationsTest method testAddSummaryActions.

@Test
public void testAddSummaryActions() throws Exception {
    disableOptionalSummaryActions();
    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    ArrayList<MessageReference> messageReferences = createMessageReferenceList();
    NotificationData notificationData = createNotificationData(messageReferences);
    PendingIntent markAllAsReadPendingIntent = createFakePendingIntent(1);
    when(actionCreator.getMarkAllAsReadPendingIntent(account, messageReferences, notificationId)).thenReturn(markAllAsReadPendingIntent);
    wearNotifications.addSummaryActions(builder, notificationData);
    verifyExtendWasOnlyCalledOnce();
    verifyAddAction(R.drawable.ic_action_mark_as_read_dark, "Mark All Read", markAllAsReadPendingIntent);
    verifyNumberOfActions(1);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference) Test(org.junit.Test)

Example 19 with MessageReference

use of com.fsck.k9.controller.MessageReference in project k-9 by k9mail.

the class WearNotifications method addArchiveAction.

private void addArchiveAction(WearableExtender wearableExtender, NotificationHolder holder) {
    int icon = R.drawable.ic_action_archive_dark;
    String title = context.getString(R.string.notification_action_archive);
    MessageReference messageReference = holder.content.messageReference;
    int notificationId = holder.notificationId;
    PendingIntent action = actionCreator.createArchiveMessagePendingIntent(messageReference, notificationId);
    NotificationCompat.Action archiveAction = new NotificationCompat.Action.Builder(icon, title, action).build();
    wearableExtender.addAction(archiveAction);
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference)

Example 20 with MessageReference

use of com.fsck.k9.controller.MessageReference in project k-9 by k9mail.

the class WearNotifications method addDeleteAction.

private void addDeleteAction(WearableExtender wearableExtender, NotificationHolder holder) {
    int icon = R.drawable.ic_action_delete_dark;
    String title = context.getString(R.string.notification_action_delete);
    MessageReference messageReference = holder.content.messageReference;
    int notificationId = holder.notificationId;
    PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId);
    NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon, title, action).build();
    wearableExtender.addAction(deleteAction);
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference)

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