Search in sources :

Example 26 with MessageReference

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

the class MessageViewFragment method refileMessage.

private void refileMessage(String dstFolder) {
    String srcFolder = mMessageReference.getFolderName();
    MessageReference messageToMove = mMessageReference;
    mFragmentListener.showNextMessageOrReturn();
    mController.moveMessage(mAccount, srcFolder, messageToMove, dstFolder);
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference)

Example 27 with MessageReference

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

the class RawMessageProvider method openFile.

@Override
public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException {
    List<String> segments = uri.getPathSegments();
    String messageReferenceString = segments.get(0);
    MessageReference messageReference = MessageReference.parse(messageReferenceString);
    ParcelFileDescriptor parcelFileDescriptor = openMessage(messageReference);
    if (parcelFileDescriptor == null) {
        throw new FileNotFoundException("Message missing or cannot be opened!");
    }
    return parcelFileDescriptor;
}
Also used : ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) MessageReference(com.fsck.k9.controller.MessageReference)

Example 28 with MessageReference

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

the class RawMessageProvider method loadMessage.

private LocalMessage loadMessage(MessageReference messageReference) {
    String accountUuid = messageReference.getAccountUuid();
    long folderId = messageReference.getFolderId();
    String uid = messageReference.getUid();
    Account account = Preferences.getPreferences(getContext()).getAccount(accountUuid);
    if (account == null) {
        Timber.w("Account not found: %s", accountUuid);
        return null;
    }
    try {
        LocalStore localStore = DI.get(LocalStoreProvider.class).getInstance(account);
        LocalFolder localFolder = localStore.getFolder(folderId);
        localFolder.open();
        LocalMessage message = localFolder.getMessage(uid);
        if (message == null || message.getDatabaseId() == 0) {
            Timber.w("Message not found: folder=%s, uid=%s", folderId, uid);
            return null;
        }
        FetchProfile fetchProfile = new FetchProfile();
        fetchProfile.add(FetchProfile.Item.BODY);
        localFolder.fetch(Collections.singletonList(message), fetchProfile, null);
        return message;
    } catch (MessagingException e) {
        Timber.e(e, "Error loading message: folder=%d, uid=%s", folderId, uid);
        return null;
    }
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) Account(com.fsck.k9.Account) LocalMessage(com.fsck.k9.mailstore.LocalMessage) FetchProfile(com.fsck.k9.mail.FetchProfile) MessagingException(com.fsck.k9.mail.MessagingException) LocalStore(com.fsck.k9.mailstore.LocalStore) LocalStoreProvider(com.fsck.k9.mailstore.LocalStoreProvider)

Example 29 with MessageReference

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

the class MessageViewFragment method onMoveToDrafts.

public void onMoveToDrafts() {
    Account account = mAccount;
    long folderId = mMessageReference.getFolderId();
    List<MessageReference> messages = Collections.singletonList(mMessageReference);
    mFragmentListener.showNextMessageOrReturn();
    mController.moveToDraftsFolder(account, folderId, messages);
}
Also used : Account(com.fsck.k9.Account) MessageReference(com.fsck.k9.controller.MessageReference)

Example 30 with MessageReference

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

the class MlfUtils method setLastSelectedFolder.

static void setLastSelectedFolder(Preferences preferences, List<MessageReference> messages, long folderId) {
    MessageReference firstMsg = messages.get(0);
    Account account = preferences.getAccount(firstMsg.getAccountUuid());
    account.setLastSelectedFolderId(folderId);
}
Also used : Account(com.fsck.k9.Account) MessageReference(com.fsck.k9.controller.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