Search in sources :

Example 26 with MessageReference

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

the class MessageList method openMessage.

@Override
public void openMessage(MessageReference messageReference) {
    Preferences prefs = Preferences.getPreferences(getApplicationContext());
    Account account = prefs.getAccount(messageReference.getAccountUuid());
    String folderName = messageReference.getFolderName();
    if (folderName.equals(account.getDraftsFolderName())) {
        MessageActions.actionEditDraft(this, messageReference);
    } else {
        mMessageViewContainer.removeView(mMessageViewPlaceHolder);
        if (mMessageListFragment != null) {
            mMessageListFragment.setActiveMessage(messageReference);
        }
        MessageViewFragment fragment = MessageViewFragment.newInstance(messageReference);
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.message_view_container, fragment);
        mMessageViewFragment = fragment;
        ft.commit();
        if (mDisplayMode != DisplayMode.SPLIT_VIEW) {
            showMessageView();
        }
    }
}
Also used : SearchAccount(com.fsck.k9.search.SearchAccount) Account(com.fsck.k9.Account) FragmentTransaction(android.app.FragmentTransaction) MessageViewFragment(com.fsck.k9.ui.messageview.MessageViewFragment) Preferences(com.fsck.k9.Preferences)

Example 27 with MessageReference

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

the class MessageReference method parse.

@Nullable
public static MessageReference parse(String identity) {
    if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) {
        return null;
    }
    StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false);
    if (tokens.countTokens() < 3) {
        return null;
    }
    String accountUuid = Base64.decode(tokens.nextToken());
    String folderName = Base64.decode(tokens.nextToken());
    String uid = Base64.decode(tokens.nextToken());
    if (!tokens.hasMoreTokens()) {
        return new MessageReference(accountUuid, folderName, uid, null);
    }
    Flag flag;
    try {
        flag = Flag.valueOf(tokens.nextToken());
    } catch (IllegalArgumentException e) {
        return null;
    }
    return new MessageReference(accountUuid, folderName, uid, flag);
}
Also used : StringTokenizer(java.util.StringTokenizer) Flag(com.fsck.k9.mail.Flag) Nullable(android.support.annotation.Nullable)

Example 28 with MessageReference

use of com.fsck.k9.activity.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.activity.MessageReference)

Example 29 with MessageReference

use of com.fsck.k9.activity.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 30 with MessageReference

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

the class MessageListFragment method openMessageAtPosition.

private void openMessageAtPosition(int position) {
    // Scroll message into view if necessary
    int listViewPosition = adapterToListViewPosition(position);
    if (listViewPosition != AdapterView.INVALID_POSITION && (listViewPosition < listView.getFirstVisiblePosition() || listViewPosition > listView.getLastVisiblePosition())) {
        listView.setSelection(listViewPosition);
    }
    MessageReference ref = getReferenceForPosition(position);
    // For some reason the listView.setSelection() above won't do anything when we call
    // onOpenMessage() (and consequently adapter.notifyDataSetChanged()) right away. So we
    // defer the call using MessageListHandler.
    handler.openMessage(ref);
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference)

Aggregations

MessageReference (com.fsck.k9.activity.MessageReference)54 PendingIntent (android.app.PendingIntent)25 Account (com.fsck.k9.Account)18 Test (org.junit.Test)14 NotificationCompat (android.support.v4.app.NotificationCompat)9 ArrayList (java.util.ArrayList)9 Notification (android.app.Notification)8 LocalMessage (com.fsck.k9.mailstore.LocalMessage)8 List (java.util.List)7 HashMap (java.util.HashMap)5 SearchAccount (com.fsck.k9.search.SearchAccount)4 Cursor (android.database.Cursor)3 Preferences (com.fsck.k9.Preferences)3 MessagingException (com.fsck.k9.mail.MessagingException)3 LocalFolder (com.fsck.k9.mailstore.LocalFolder)3 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 Message (com.fsck.k9.mail.Message)2