Search in sources :

Example 31 with MessageReference

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

the class MessageViewFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Bundle arguments = getArguments();
    String messageReferenceString = arguments.getString(ARG_REFERENCE);
    MessageReference messageReference = MessageReference.parse(messageReferenceString);
    displayMessage(messageReference);
}
Also used : Bundle(android.os.Bundle) MessageReference(com.fsck.k9.controller.MessageReference)

Example 32 with MessageReference

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

the class MessageViewFragment method refileMessage.

private void refileMessage(long dstFolderId) {
    long srcFolderId = mMessageReference.getFolderId();
    MessageReference messageToMove = mMessageReference;
    mFragmentListener.showNextMessageOrReturn();
    mController.moveMessage(mAccount, srcFolderId, messageToMove, dstFolderId);
}
Also used : MessageReference(com.fsck.k9.controller.MessageReference)

Example 33 with MessageReference

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

the class MessageListHandler method handleMessage.

@Override
public void handleMessage(android.os.Message msg) {
    MessageListFragment fragment = mFragment.get();
    if (fragment == null) {
        return;
    }
    // The following messages don't need an attached activity.
    switch(msg.what) {
        case ACTION_REMOTE_SEARCH_FINISHED:
            {
                fragment.remoteSearchFinished();
                return;
            }
    }
    // Discard messages if the fragment isn't attached to an activity anymore.
    Activity activity = fragment.getActivity();
    if (activity == null) {
        return;
    }
    switch(msg.what) {
        case ACTION_FOLDER_LOADING:
            {
                long folderId = (Long) msg.obj;
                boolean loading = (msg.arg1 == 1);
                fragment.folderLoading(folderId, loading);
                break;
            }
        case ACTION_REFRESH_TITLE:
            {
                fragment.updateTitle();
                break;
            }
        case ACTION_PROGRESS:
            {
                boolean progress = (msg.arg1 == 1);
                fragment.progress(progress);
                break;
            }
        case ACTION_GO_BACK:
            {
                fragment.goBack();
                break;
            }
        case ACTION_RESTORE_LIST_POSITION:
            {
                Parcelable savedListState = (Parcelable) msg.obj;
                fragment.restoreListState(savedListState);
                break;
            }
        case ACTION_OPEN_MESSAGE:
            {
                MessageReference messageReference = (MessageReference) msg.obj;
                fragment.openMessage(messageReference);
                break;
            }
    }
}
Also used : Activity(android.app.Activity) Parcelable(android.os.Parcelable) MessageReference(com.fsck.k9.controller.MessageReference)

Example 34 with MessageReference

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

the class MessagingController method actOnMessagesGroupedByAccountAndFolder.

private void actOnMessagesGroupedByAccountAndFolder(List<MessageReference> messages, MessageActor actor) {
    Map<String, Map<Long, List<MessageReference>>> accountMap = groupMessagesByAccountAndFolder(messages);
    for (Map.Entry<String, Map<Long, List<MessageReference>>> entry : accountMap.entrySet()) {
        String accountUuid = entry.getKey();
        Account account = preferences.getAccount(accountUuid);
        Map<Long, List<MessageReference>> folderMap = entry.getValue();
        for (Map.Entry<Long, List<MessageReference>> folderEntry : folderMap.entrySet()) {
            long folderId = folderEntry.getKey();
            List<MessageReference> messageList = folderEntry.getValue();
            actOnMessageGroup(account, folderId, messageList, actor);
        }
    }
}
Also used : SearchAccount(com.fsck.k9.search.SearchAccount) Account(com.fsck.k9.Account) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 35 with MessageReference

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

the class MessagingController method moveToDraftsFolderInBackground.

private void moveToDraftsFolderInBackground(Account account, long folderId, List<MessageReference> messages) {
    for (MessageReference messageReference : messages) {
        try {
            Message message = loadMessage(account, folderId, messageReference.getUid());
            Long draftMessageId = saveDraft(account, message, null, message.getSubject());
            boolean draftSavedSuccessfully = draftMessageId != null;
            if (draftSavedSuccessfully) {
                message.destroy();
            }
            for (MessagingListener listener : getListeners()) {
                listener.folderStatusChanged(account, folderId);
            }
        } catch (MessagingException e) {
            Timber.e(e, "Error loading message. Draft was not saved.");
        }
    }
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) ExceptionHelper.getRootCauseMessage(com.fsck.k9.helper.ExceptionHelper.getRootCauseMessage) Message(com.fsck.k9.mail.Message) MessagingException(com.fsck.k9.mail.MessagingException)

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