Merge "Fixup auto advance policy handling."

This commit is contained in:
Ben Komalo 2011-04-18 10:46:21 -07:00 committed by Android (Google) Code Review
commit 058eb3984f
2 changed files with 32 additions and 15 deletions

View File

@ -37,8 +37,6 @@ import java.util.Set;
* A class manages what are showing on {@link MessageListXL} (i.e. account id, mailbox id, and
* message id), and show/hide fragments accordingly.
*
* TODO Highlight selected message on message list
*
* TODO: Test it. It's testable if we implement MockFragmentTransaction, which may be too early
* to do so at this point. (API may not be stable enough yet.)
*
@ -152,7 +150,14 @@ class MessageListXLFragmentManager implements
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Logging.LOG_TAG, "MessageListXLFragmentManager#onMailboxNotFound()");
}
// Shouldn't happen
// TODO: handle more gracefully.
Log.e(Logging.LOG_TAG, "unable to find mailbox for account " + accountId);
}
@Override
public void onMailboxNotFound() {
// TODO: handle more gracefully.
Log.e(Logging.LOG_TAG, "unable to find mailbox");
}
// MoveMessageToDialog$Callback
@ -209,11 +214,6 @@ class MessageListXLFragmentManager implements
}
}
@Override
public void onMailboxNotFound() {
// TODO: What to do??
}
@Override
public void onEnterSelectionMode(boolean enter) {
}
@ -652,11 +652,9 @@ class MessageListXLFragmentManager implements
switch (Preferences.getPreferences(mActivity).getAutoAdvanceDirection()) {
case Preferences.AUTO_ADVANCE_NEWER:
if (moveToNewer()) return;
if (moveToOlder()) return;
break;
case Preferences.AUTO_ADVANCE_OLDER:
if (moveToOlder()) return;
if (moveToNewer()) return;
break;
}
// Last message in the box or AUTO_ADVANCE_MESSAGE_LIST. Go back to message list.

View File

@ -17,6 +17,7 @@
package com.android.email.activity;
import com.android.email.Email;
import com.android.email.Preferences;
import com.android.email.R;
import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Mailbox;
@ -169,7 +170,8 @@ public class MessageView extends MessageViewBase implements View.OnClickListener
// the delete triggers mCursorObserver in MessageOrderManager.
// first move to older/newer before the actual delete
long messageIdToDelete = mMessageId;
boolean moved = moveToOlder() || moveToNewer(); // TODO use "auto-advance" preference
boolean moved = autoAdvance();
ActivityHelper.deleteMessage(this, messageIdToDelete);
if (!moved) {
// this generates a benign warning "Duplicate finish request" because
@ -179,6 +181,22 @@ public class MessageView extends MessageViewBase implements View.OnClickListener
}
}
/**
* Auto-advances the message being shown according to the auto-advance policy set in preferences
* @return Whether or not a new message was selected. This will return false either if there are
* no appropriate messages to advance to, or if the preferences indicate we should not
* auto-advance
*/
private boolean autoAdvance() {
switch (Preferences.getPreferences(this).getAutoAdvanceDirection()) {
case Preferences.AUTO_ADVANCE_NEWER:
return moveToNewer();
case Preferences.AUTO_ADVANCE_OLDER:
return moveToOlder();
}
return false;
}
private boolean moveToOlder() {
if (mOrderManager != null && mOrderManager.moveToOlder()) {
mMessageId = mOrderManager.getCurrentMessageId();
@ -258,7 +276,9 @@ public class MessageView extends MessageViewBase implements View.OnClickListener
@Override
public void onMessageSetUnread() {
finish();
if (!autoAdvance()) {
finish();
}
}
private void enableForwardReply(boolean enabled) {
@ -319,9 +339,8 @@ public class MessageView extends MessageViewBase implements View.OnClickListener
@Override
public void onRespondedToInvite(int response) {
// TODO use "auto-advance" preference
if (!moveToOlder()) {
finish(); // if this is the last message, move up to message-list.
if (!autoAdvance()) {
finish();
}
}