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();
}
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations