From 04e1bf69768bcda9f0ba74e21e7c35bb6335a5dc Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 1 Mar 2013 22:38:09 +0100 Subject: [PATCH] Restore code to remember the last direction messages were displayed in --- src/com/fsck/k9/activity/MessageList.java | 29 ++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index d755c0537..0af2918cd 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -83,6 +83,10 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme private static final String STATE_DISPLAY_MODE = "displayMode"; private static final String STATE_MESSAGE_LIST_WAS_DISPLAYED = "messageListWasDisplayed"; + // Used for navigating to next/previous message + private static final int PREVIOUS = 1; + private static final int NEXT = 2; + public static void actionDisplaySearch(Context context, SearchSpecification search, boolean noThreading, boolean newTask) { actionDisplaySearch(context, search, noThreading, newTask, true); @@ -168,6 +172,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme private ProgressBar mActionBarProgress; private MenuItem mMenuButtonCheckMail; private View mActionButtonIndeterminateProgress; + private int mLastDirection = (K9.messageViewShowNext()) ? NEXT : PREVIOUS; /** * {@code true} if the message list should be displayed as flat list (i.e. no threading) @@ -1356,7 +1361,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme @Override public void showNextMessageOrReturn() { - if (K9.messageViewReturnToList() || !showNextMessage()) { + if (K9.messageViewReturnToList() || !showLogicalNextMessage()) { if (mDisplayMode == DisplayMode.SPLIT_VIEW) { showMessageViewPlaceHolder(); } else { @@ -1365,6 +1370,26 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme } } + /** + * Shows the next message in the direction the user was displaying messages. + * + * @return {@code true} + */ + private boolean showLogicalNextMessage() { + boolean result = false; + if (mLastDirection == NEXT) { + result = showNextMessage(); + } else if (mLastDirection == PREVIOUS) { + result = showPreviousMessage(); + } + + if (!result) { + result = showNextMessage() || showPreviousMessage(); + } + + return result; + } + @Override public void setProgress(boolean enable) { setSupportProgressBarIndeterminateVisibility(enable); @@ -1379,6 +1404,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme MessageReference ref = mMessageViewFragment.getMessageReference(); if (ref != null) { if (mMessageListFragment.openNext(ref)) { + mLastDirection = NEXT; return true; } } @@ -1389,6 +1415,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme MessageReference ref = mMessageViewFragment.getMessageReference(); if (ref != null) { if (mMessageListFragment.openPrevious(ref)) { + mLastDirection = PREVIOUS; return true; } }