Search in sources :

Example 1 with MessageReference

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

the class DeviceNotifications method addMarkAsReadAction.

private void addMarkAsReadAction(Builder builder, NotificationContent content, int notificationId) {
    int icon = getMarkAsReadActionIcon();
    String title = context.getString(R.string.notification_action_mark_as_read);
    MessageReference messageReference = content.messageReference;
    PendingIntent action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId);
    builder.addAction(icon, title, action);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference)

Example 2 with MessageReference

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

the class DeviceNotifications method createInboxStyleSummaryNotification.

private NotificationCompat.Builder createInboxStyleSummaryNotification(Account account, NotificationData notificationData, int unreadMessageCount) {
    NotificationHolder latestNotification = notificationData.getHolderForLatestNotification();
    int newMessagesCount = notificationData.getNewMessagesCount();
    String accountName = controller.getAccountName(account);
    String title = context.getResources().getQuantityString(R.plurals.notification_new_messages_title, newMessagesCount, newMessagesCount);
    String summary = (notificationData.hasSummaryOverflowMessages()) ? context.getString(R.string.notification_additional_messages, notificationData.getSummaryOverflowMessagesCount(), accountName) : accountName;
    String groupKey = NotificationGroupKeys.getGroupKey(account);
    NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account).setNumber(unreadMessageCount).setTicker(latestNotification.content.summary).setGroup(groupKey).setGroupSummary(true).setContentTitle(title).setSubText(accountName);
    NotificationCompat.InboxStyle style = createInboxStyle(builder).setBigContentTitle(title).setSummaryText(summary);
    for (NotificationContent content : notificationData.getContentForSummaryNotification()) {
        style.addLine(content.summary);
    }
    builder.setStyle(style);
    addMarkAllAsReadAction(builder, notificationData);
    addDeleteAllAction(builder, notificationData);
    wearNotifications.addSummaryActions(builder, notificationData);
    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    List<MessageReference> messageReferences = notificationData.getAllMessageReferences();
    PendingIntent contentIntent = actionCreator.createViewMessagesPendingIntent(account, messageReferences, notificationId);
    builder.setContentIntent(contentIntent);
    return builder;
}
Also used : Builder(android.support.v4.app.NotificationCompat.Builder) NotificationCompat(android.support.v4.app.NotificationCompat) InboxStyle(android.support.v4.app.NotificationCompat.InboxStyle) PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference)

Example 3 with MessageReference

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

the class DeviceNotifications method addDeleteAllAction.

private void addDeleteAllAction(Builder builder, NotificationData notificationData) {
    if (K9.getNotificationQuickDeleteBehaviour() != NotificationQuickDelete.ALWAYS) {
        return;
    }
    int icon = getDeleteActionIcon();
    String title = context.getString(R.string.notification_action_delete);
    Account account = notificationData.getAccount();
    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
    PendingIntent action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId);
    builder.addAction(icon, title, action);
}
Also used : Account(com.fsck.k9.Account) PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference)

Example 4 with MessageReference

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

the class DeviceNotifications method addMarkAllAsReadAction.

private void addMarkAllAsReadAction(Builder builder, NotificationData notificationData) {
    int icon = getMarkAsReadActionIcon();
    String title = context.getString(R.string.notification_action_mark_as_read);
    Account account = notificationData.getAccount();
    ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    PendingIntent markAllAsReadPendingIntent = actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences, notificationId);
    builder.addAction(icon, title, markAllAsReadPendingIntent);
}
Also used : Account(com.fsck.k9.Account) PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference)

Example 5 with MessageReference

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

the class NotificationActionCreator method buildMessageViewBackStack.

private TaskStackBuilder buildMessageViewBackStack(MessageReference message) {
    Account account = Preferences.getPreferences(context).getAccount(message.getAccountUuid());
    String folderName = message.getFolderName();
    TaskStackBuilder stack = buildMessageListBackStack(account, folderName);
    Intent intent = MessageList.actionDisplayMessageIntent(context, message);
    stack.addNextIntent(intent);
    return stack;
}
Also used : Account(com.fsck.k9.Account) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder)

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