Search in sources :

Example 51 with MessageReference

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

the class WearNotifications method addDeviceDeleteAction.

private void addDeviceDeleteAction(Builder builder, NotificationHolder holder) {
    if (!isDeleteActionEnabled()) {
        return;
    }
    int icon = R.drawable.notification_action_delete;
    String title = context.getString(R.string.notification_action_delete);
    NotificationContent content = holder.content;
    int notificationId = holder.notificationId;
    MessageReference messageReference = content.messageReference;
    PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId);
    builder.addAction(icon, title, action);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference)

Example 52 with MessageReference

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

the class NotificationContentCreator method createFromMessage.

public NotificationContent createFromMessage(Account account, LocalMessage message) {
    MessageReference messageReference = message.makeMessageReference();
    String sender = getMessageSender(account, message);
    String displaySender = getMessageSenderForDisplay(sender);
    String subject = getMessageSubject(message);
    CharSequence preview = getMessagePreview(message);
    CharSequence summary = buildMessageSummary(sender, subject);
    boolean starred = message.isSet(Flag.FLAGGED);
    return new NotificationContent(messageReference, displaySender, subject, preview, summary, starred);
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference)

Example 53 with MessageReference

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

the class NotificationActionCreator method getFolderNameOfAllMessages.

private String getFolderNameOfAllMessages(List<MessageReference> messageReferences) {
    MessageReference firstMessage = messageReferences.get(0);
    String folderName = firstMessage.getFolderName();
    for (MessageReference messageReference : messageReferences) {
        if (!TextUtils.equals(folderName, messageReference.getFolderName())) {
            return null;
        }
    }
    return folderName;
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference)

Example 54 with MessageReference

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

the class NotificationActionService method markMessagesAsRead.

private void markMessagesAsRead(Intent intent, Account account, MessagingController controller) {
    Timber.i("NotificationActionService marking messages as read");
    List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES);
    List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings);
    for (MessageReference messageReference : messageReferences) {
        String folderName = messageReference.getFolderName();
        String uid = messageReference.getUid();
        controller.setFlag(account, folderName, uid, Flag.SEEN, true);
    }
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference)

Example 55 with MessageReference

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

the class NotificationActionService method archiveMessages.

private void archiveMessages(Intent intent, Account account, MessagingController controller) {
    Timber.i("NotificationActionService archiving messages");
    String archiveFolderName = account.getArchiveFolderName();
    if (archiveFolderName == null || (archiveFolderName.equals(account.getSpamFolderName()) && K9.confirmSpam()) || !isMovePossible(controller, account, archiveFolderName)) {
        Timber.w("Can not archive messages");
        return;
    }
    List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES);
    List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings);
    for (MessageReference messageReference : messageReferences) {
        if (controller.isMoveCapable(messageReference)) {
            String sourceFolderName = messageReference.getFolderName();
            controller.moveMessage(account, sourceFolderName, messageReference, archiveFolderName);
        }
    }
}
Also used : 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