Search in sources :

Example 6 with MessageReference

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

the class NotificationActionService method markMessageAsSpam.

private void markMessageAsSpam(Intent intent, Account account, MessagingController controller) {
    Timber.i("NotificationActionService moving messages to spam");
    String messageReferenceString = intent.getStringExtra(EXTRA_MESSAGE_REFERENCE);
    MessageReference messageReference = MessageReference.parse(messageReferenceString);
    if (messageReference == null) {
        Timber.w("Invalid message reference: %s", messageReferenceString);
        return;
    }
    String spamFolderName = account.getSpamFolderName();
    if (spamFolderName != null && !K9.confirmSpam() && isMovePossible(controller, account, spamFolderName)) {
        String sourceFolderName = messageReference.getFolderName();
        controller.moveMessage(account, sourceFolderName, messageReference, spamFolderName);
    }
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference)

Example 7 with MessageReference

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

the class MessagingController method actOnMessageGroup.

private void actOnMessageGroup(Account account, String folderName, List<MessageReference> messageReferences, MessageActor actor) {
    try {
        LocalFolder messageFolder = account.getLocalStore().getFolder(folderName);
        List<LocalMessage> localMessages = messageFolder.getMessagesByReference(messageReferences);
        actor.act(account, messageFolder, localMessages);
    } catch (MessagingException e) {
        Timber.e(e, "Error loading account?!");
    }
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) LocalMessage(com.fsck.k9.mailstore.LocalMessage) MessagingException(com.fsck.k9.mail.MessagingException)

Example 8 with MessageReference

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

the class MessageListFragment method onArchive.

private void onArchive(final List<MessageReference> messages) {
    Map<Account, List<MessageReference>> messagesByAccount = groupMessagesByAccount(messages);
    for (Entry<Account, List<MessageReference>> entry : messagesByAccount.entrySet()) {
        Account account = entry.getKey();
        String archiveFolder = account.getArchiveFolderName();
        if (!K9.FOLDER_NONE.equals(archiveFolder)) {
            move(entry.getValue(), archiveFolder);
        }
    }
}
Also used : Account(com.fsck.k9.Account) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with MessageReference

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

the class MessageListFragment method getCheckedMessages.

private List<MessageReference> getCheckedMessages() {
    List<MessageReference> messages = new ArrayList<>(selected.size());
    for (int position = 0, end = adapter.getCount(); position < end; position++) {
        Cursor cursor = (Cursor) adapter.getItem(position);
        long uniqueId = cursor.getLong(uniqueIdColumn);
        if (selected.contains(uniqueId)) {
            MessageReference message = getMessageAtPosition(position);
            if (message != null) {
                messages.add(message);
            }
        }
    }
    return messages;
}
Also used : ArrayList(java.util.ArrayList) MessageReference(com.fsck.k9.activity.MessageReference) Cursor(android.database.Cursor)

Example 10 with MessageReference

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

the class MessageListFragment method getReferenceForPosition.

private MessageReference getReferenceForPosition(int position) {
    Cursor cursor = (Cursor) adapter.getItem(position);
    String accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
    String folderName = cursor.getString(FOLDER_NAME_COLUMN);
    String messageUid = cursor.getString(UID_COLUMN);
    return new MessageReference(accountUuid, folderName, messageUid, null);
}
Also used : Cursor(android.database.Cursor) 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