Implement new nested folder mocks

Change-Id: I7c0c1d41b7a40d83e1237ba31d5f7949945c7e1e
This commit is contained in:
Todd Kennedy 2011-05-04 12:07:08 -07:00
parent f456fa88bc
commit 075feb4556
10 changed files with 108 additions and 62 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 633 B

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 B

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

View File

@ -33,7 +33,6 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/mailbox_list_count_margin_left" android:layout_marginLeft="@dimen/mailbox_list_count_margin_left"
android:layout_marginRight="@dimen/mailbox_list_padding_right" android:layout_marginRight="@dimen/mailbox_list_padding_right"
android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:textSize="14dip" android:textSize="14dip"
android:textColor="@color/text_secondary_color" android:textColor="@color/text_secondary_color"
@ -44,6 +43,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/mailbox_list_padding_left" android:layout_marginLeft="@dimen/mailbox_list_padding_left"
android:layout_toLeftOf="@id/message_count"
> >
<ImageView <ImageView
android:id="@+id/folder_icon" android:id="@+id/folder_icon"
@ -52,21 +52,11 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginRight="8dip" android:layout_marginRight="8dip"
/> />
<ImageView
android:id="@+id/folder_expanded_icon"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_toRightOf="@id/folder_icon"
android:layout_centerVertical="true"
android:layout_marginRight="8dip"
android:visibility="gone"
/>
<TextView <TextView
android:id="@+id/mailbox_name" android:id="@+id/mailbox_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toRightOf="@id/folder_expanded_icon" android:layout_toRightOf="@id/folder_icon"
android:layout_toLeftOf="@id/message_count"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
@ -84,4 +74,12 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:visibility="gone" android:visibility="gone"
/> />
<ImageView
android:id="@+id/folder_expanded_icon"
android:layout_width="16dip"
android:layout_height="16dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:visibility="gone"
/>
</com.android.email.activity.MailboxListItem> </com.android.email.activity.MailboxListItem>

View File

@ -66,6 +66,8 @@
<string name="exception_updated"/> <string name="exception_updated"/>
<!-- Do Not Translate. Unused string. --> <!-- Do Not Translate. Unused string. -->
<string name="notification_exchange_calendar_added"/> <string name="notification_exchange_calendar_added"/>
<!-- Do Not Translate. Unused string. -->
<string name="mailbox_name_go_back"></string>
<!-- Name of application on Home screen --> <!-- Name of application on Home screen -->
<string name="app_name">Email</string> <string name="app_name">Email</string>
@ -238,8 +240,6 @@
<string name="mailbox_name_display_sent">Sent</string> <string name="mailbox_name_display_sent">Sent</string>
<!-- In the UI, the junk will be displayed with this name --> <!-- In the UI, the junk will be displayed with this name -->
<string name="mailbox_name_display_junk">Junk</string> <string name="mailbox_name_display_junk">Junk</string>
<!-- Folder name displayed to go back to the top-level mailbox view [CHAR_LIMIT=20] -->
<string name="mailbox_name_go_back">All Folders</string>
<!-- Version number, shown only on debug screen --> <!-- Version number, shown only on debug screen -->
<string name="debug_version_fmt">Version: <xliff:g id="version">%s</xliff:g></string> <string name="debug_version_fmt">Version: <xliff:g id="version">%s</xliff:g></string>

View File

@ -21,7 +21,6 @@ import com.android.email.ControllerResultUiThreadWrapper;
import com.android.email.Email; import com.android.email.Email;
import com.android.email.MessagingExceptionStrings; import com.android.email.MessagingExceptionStrings;
import com.android.email.R; import com.android.email.R;
import com.android.email.RefreshManager;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException; import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Account; import com.android.emailcommon.provider.EmailContent.Account;
@ -344,14 +343,14 @@ public class EmailActivity extends Activity implements View.OnClickListener {
public boolean onSearchRequested() { public boolean onSearchRequested() {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putLong(EXTRA_ACCOUNT_ID, mUIController.getActualAccountId()); bundle.putLong(EXTRA_ACCOUNT_ID, mUIController.getActualAccountId());
bundle.putLong(EXTRA_MAILBOX_ID, mUIController.getMailboxId()); bundle.putLong(EXTRA_MAILBOX_ID, mUIController.getMessageListMailboxId());
startSearch(null, false, bundle, false); startSearch(null, false, bundle, false);
return true; return true;
} }
// STOPSHIP Set column from user options // STOPSHIP Set column from user options
private void setMailboxColumn(String column, String value) { private void setMailboxColumn(String column, String value) {
final long mailboxId = mUIController.getMailboxId(); final long mailboxId = mUIController.getMessageListMailboxId();
if (mailboxId > 0) { if (mailboxId > 0) {
ContentValues cv = new ContentValues(); ContentValues cv = new ContentValues();
cv.put(column, value); cv.put(column, value);
@ -391,8 +390,10 @@ public class EmailActivity extends Activity implements View.OnClickListener {
// STOPSHIP Temporary mailbox settings UI // STOPSHIP Temporary mailbox settings UI
@Override @Override
@Deprecated
protected Dialog onCreateDialog(int id, Bundle args) { protected Dialog onCreateDialog(int id, Bundle args) {
Mailbox mailbox = Mailbox.restoreMailboxWithId(this, mUIController.getMailboxId()); Mailbox mailbox
= Mailbox.restoreMailboxWithId(this, mUIController.getMessageListMailboxId());
if (mailbox == null) return null; if (mailbox == null) return null;
switch (id) { switch (id) {
case MAILBOX_SYNC_FREQUENCY_DIALOG: case MAILBOX_SYNC_FREQUENCY_DIALOG:
@ -439,6 +440,7 @@ public class EmailActivity extends Activity implements View.OnClickListener {
} }
@Override @Override
@SuppressWarnings("deprecation")
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (mUIController.onOptionsItemSelected(item)) { if (mUIController.onOptionsItemSelected(item)) {
return true; return true;

View File

@ -76,10 +76,10 @@ import android.widget.TextView;
MailboxListItem listItem = (MailboxListItem)view; MailboxListItem listItem = (MailboxListItem)view;
listItem.mMailboxId = id; listItem.mMailboxId = id;
listItem.mMailboxType = type; listItem.mMailboxType = type;
listItem.mIsValidDropTarget = (id >= 0 || rowType == ROW_TYPE_ALLMAILBOX) listItem.mIsValidDropTarget = (id >= 0)
&& !Utility.arrayContains(Mailbox.INVALID_DROP_TARGETS, type) && !Utility.arrayContains(Mailbox.INVALID_DROP_TARGETS, type)
&& (flags & Mailbox.FLAG_ACCEPTS_MOVED_MAIL) != 0; && (flags & Mailbox.FLAG_ACCEPTS_MOVED_MAIL) != 0;
listItem.mIsNavigable = hasVisibleChildren || rowType == ROW_TYPE_ALLMAILBOX; listItem.mIsNavigable = hasVisibleChildren;
listItem.mAdapter = this; listItem.mAdapter = this;
// Set the background depending on whether we're in drag mode, the mailbox is a valid // Set the background depending on whether we're in drag mode, the mailbox is a valid
@ -89,7 +89,6 @@ import android.widget.TextView;
// Set mailbox name // Set mailbox name
final TextView nameView = (TextView) view.findViewById(R.id.mailbox_name); final TextView nameView = (TextView) view.findViewById(R.id.mailbox_name);
nameView.setText(getDisplayName(context, cursor)); nameView.setText(getDisplayName(context, cursor));
// Set count // Set count
final int count; final int count;
switch (getCountTypeForMailboxType(cursor)) { switch (getCountTypeForMailboxType(cursor)) {
@ -113,11 +112,6 @@ import android.widget.TextView;
final ImageView mailboxExpandedIcon = final ImageView mailboxExpandedIcon =
(ImageView) view.findViewById(R.id.folder_expanded_icon); (ImageView) view.findViewById(R.id.folder_expanded_icon);
switch (cursor.getInt(COLUMN_ROW_TYPE)) { switch (cursor.getInt(COLUMN_ROW_TYPE)) {
case ROW_TYPE_ALLMAILBOX:
mailboxExpandedIcon.setVisibility(View.VISIBLE);
mailboxExpandedIcon.setImageResource(R.drawable.ic_mailbox_expanded_holo_light);
folderIcon.setVisibility(View.INVISIBLE);
break;
case ROW_TYPE_SUBMAILBOX: case ROW_TYPE_SUBMAILBOX:
if (hasVisibleChildren) { if (hasVisibleChildren) {
mailboxExpandedIcon.setVisibility(View.VISIBLE); mailboxExpandedIcon.setVisibility(View.VISIBLE);
@ -135,19 +129,15 @@ import android.widget.TextView;
folderIcon.setVisibility(View.GONE); folderIcon.setVisibility(View.GONE);
break; break;
case ROW_TYPE_MAILBOX: case ROW_TYPE_MAILBOX:
// If we have children and no special icon; show the collapsed folder icon default:
if (hasVisibleChildren && folderIcon.getDrawable() == null) { if (hasVisibleChildren) {
mailboxExpandedIcon.setVisibility(View.VISIBLE); mailboxExpandedIcon.setVisibility(View.VISIBLE);
mailboxExpandedIcon.setImageResource( mailboxExpandedIcon.setImageResource(
R.drawable.ic_mailbox_collapsed_holo_light); R.drawable.ic_mailbox_collapsed_holo_light);
folderIcon.setVisibility(View.GONE); } else {
break; mailboxExpandedIcon.setVisibility(View.GONE);
mailboxExpandedIcon.setImageDrawable(null);
} }
// No children; handle normally
//$FALL-THROUGH$
default:
mailboxExpandedIcon.setVisibility(View.GONE);
mailboxExpandedIcon.setImageDrawable(null);
folderIcon.setVisibility(View.VISIBLE); folderIcon.setVisibility(View.VISIBLE);
break; break;
} }
@ -285,9 +275,6 @@ import android.widget.TextView;
new String[] { Long.toString(mAccountId), Long.toString(mParentKey) }, new String[] { Long.toString(mAccountId), Long.toString(mParentKey) },
null); null);
final MatrixCursor extraCursor = new MatrixCursor(getProjection()); final MatrixCursor extraCursor = new MatrixCursor(getProjection());
String label = mContext.getResources().getString(R.string.mailbox_name_go_back);
addMailboxRow(extraCursor, superParentKey, label, Mailbox.TYPE_MAIL, 0, 0,
ROW_TYPE_ALLMAILBOX, 0);
return Utility.CloseTraceCursorWrapper.get(new MergeCursor( return Utility.CloseTraceCursorWrapper.get(new MergeCursor(
new Cursor[] { extraCursor, parentCursor, childMailboxCursor })); new Cursor[] { extraCursor, parentCursor, childMailboxCursor }));
} }

View File

@ -57,17 +57,15 @@ import android.widget.CursorAdapter;
* <code>row_type</code> specified in {@link #PROJECTION} and {@link #SUBMAILBOX_PROJECTION}. * <code>row_type</code> specified in {@link #PROJECTION} and {@link #SUBMAILBOX_PROJECTION}.
*/ */
/** Both regular and combined mailboxes */ /** Both regular and combined mailboxes */
/*package*/ static final int ROW_TYPE_MAILBOX = 0; static final int ROW_TYPE_MAILBOX = 0;
/** Account "mailboxes" in the combined view */ /** Account "mailboxes" in the combined view */
/*package*/ static final int ROW_TYPE_ACCOUNT = 1; static final int ROW_TYPE_ACCOUNT = 1;
// STOPSHIP Need to determine if these types are sufficient for nested folders // STOPSHIP Need to determine if these types are sufficient for nested folders
// The following types are used when drilling into a mailbox // The following types are used when drilling into a mailbox
/** The current mailbox */ /** The current mailbox */
/*package*/ static final int ROW_TYPE_CURMAILBOX = 2; static final int ROW_TYPE_CURMAILBOX = 2;
/** Sub mailboxes */ /** Sub mailboxes */
/*package*/ static final int ROW_TYPE_SUBMAILBOX = 3; static final int ROW_TYPE_SUBMAILBOX = 3;
/** The "All Folders" mailbox */
/*package*/ static final int ROW_TYPE_ALLMAILBOX = 4;
/** /**
* Note here we have two ID columns. The first one is for ListView, which doesn't like ID * Note here we have two ID columns. The first one is for ListView, which doesn't like ID

View File

@ -27,8 +27,10 @@ import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.Account; import com.android.emailcommon.provider.EmailContent.Account;
import com.android.emailcommon.provider.EmailContent.Mailbox; import com.android.emailcommon.provider.EmailContent.Mailbox;
import com.android.emailcommon.utility.EmailAsyncTask; import com.android.emailcommon.utility.EmailAsyncTask;
import com.android.emailcommon.utility.Utility;
import android.app.ActionBar; import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
@ -48,6 +50,7 @@ import android.widget.TextView;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Set; import java.util.Set;
import java.util.Stack;
/** /**
* UI Controller for x-large devices. Supports a multi-pane layout. * UI Controller for x-large devices. Supports a multi-pane layout.
@ -69,6 +72,8 @@ class UIControllerTwoPane implements
private static final String BUNDLE_KEY_ACCOUNT_ID = "UIControllerTwoPane.state.account_id"; private static final String BUNDLE_KEY_ACCOUNT_ID = "UIControllerTwoPane.state.account_id";
private static final String BUNDLE_KEY_MAILBOX_ID = "UIControllerTwoPane.state.mailbox_id"; private static final String BUNDLE_KEY_MAILBOX_ID = "UIControllerTwoPane.state.mailbox_id";
private static final String BUNDLE_KEY_MESSAGE_ID = "UIControllerTwoPane.state.message_id"; private static final String BUNDLE_KEY_MESSAGE_ID = "UIControllerTwoPane.state.message_id";
private static final String BUNDLE_KEY_MAILBOX_STACK
= "UIControllerTwoPane.state.mailbox_stack";
/* package */ static final int MAILBOX_REFRESH_MIN_INTERVAL = 30 * 1000; // in milliseconds /* package */ static final int MAILBOX_REFRESH_MIN_INTERVAL = 30 * 1000; // in milliseconds
/* package */ static final int INBOX_AUTO_REFRESH_MIN_INTERVAL = 10 * 1000; // in milliseconds /* package */ static final int INBOX_AUTO_REFRESH_MIN_INTERVAL = 10 * 1000; // in milliseconds
@ -85,8 +90,14 @@ class UIControllerTwoPane implements
/** Current account id */ /** Current account id */
private long mAccountId = NO_ACCOUNT; private long mAccountId = NO_ACCOUNT;
/** Current mailbox id */ // TODO Remove this instance variable and replace it with a call to mMessageListFragment to
private long mMailboxId = NO_MAILBOX; // retrieve it's mailbox ID. There's no reason we should be duplicating data
/**
* The id of the currently viewed mailbox in the mailbox list fragment.
* IMPORTANT: Do not confuse this with the value returned by {@link #getMessageListMailboxId()}
* which is the mailbox id associated with the message list fragment. The two may be different.
*/
private long mMailboxListMailboxId = NO_MAILBOX;
/** Current message id */ /** Current message id */
private long mMessageId = NO_MESSAGE; private long mMessageId = NO_MESSAGE;
@ -126,6 +137,8 @@ class UIControllerTwoPane implements
private MessageOrderManager mOrderManager; private MessageOrderManager mOrderManager;
private final MessageOrderManagerCallback mMessageOrderManagerCallback = private final MessageOrderManagerCallback mMessageOrderManagerCallback =
new MessageOrderManagerCallback(); new MessageOrderManagerCallback();
/** Mailbox IDs that the user has navigated away from; used to provide "back" functionality */
private final Stack<Long> mMailboxStack = new Stack<Long>();
/** /**
* List of fragments that are restored by the framework while the activity is being re-created * List of fragments that are restored by the framework while the activity is being re-created
@ -227,7 +240,8 @@ class UIControllerTwoPane implements
// If the left pane (mailbox list pane) is hidden, the back action on action bar will be // If the left pane (mailbox list pane) is hidden, the back action on action bar will be
// enabled, and we also show the current mailbox name. // enabled, and we also show the current mailbox name.
final boolean leftPaneHidden = ((visiblePanes & ThreePaneLayout.PANE_LEFT) == 0); final boolean leftPaneHidden = ((visiblePanes & ThreePaneLayout.PANE_LEFT) == 0);
mActionBar.setDisplayOptions(leftPaneHidden ? ActionBar.DISPLAY_HOME_AS_UP : 0, boolean displayUp = leftPaneHidden || !mMailboxStack.isEmpty();
mActionBar.setDisplayOptions(displayUp ? ActionBar.DISPLAY_HOME_AS_UP : 0,
ActionBar.DISPLAY_HOME_AS_UP); ActionBar.DISPLAY_HOME_AS_UP);
mActionBarMailboxNameView.setVisibility(leftPaneHidden ? View.VISIBLE : View.GONE); mActionBarMailboxNameView.setVisibility(leftPaneHidden ? View.VISIBLE : View.GONE);
} }
@ -247,8 +261,11 @@ class UIControllerTwoPane implements
// reload the top-level message list. Always implies navigate. // reload the top-level message list. Always implies navigate.
openAccount(accountId); openAccount(accountId);
} else if (navigate) { } else if (navigate) {
updateMailboxList(accountId, mailboxId, true, true); if (mMailboxStack.isEmpty() || mailboxId != mMailboxListMailboxId) {
updateMessageList(mailboxId, true, true); // Don't navigate to the same mailbox id twice in a row
mMailboxStack.push(mMailboxListMailboxId);
openMailbox(accountId, mailboxId);
}
} else { } else {
updateMessageList(mailboxId, true, true); updateMessageList(mailboxId, true, true);
} }
@ -464,8 +481,13 @@ class UIControllerTwoPane implements
return mAccountId == Account.ACCOUNT_ID_COMBINED_VIEW ? NO_ACCOUNT : mAccountId; return mAccountId == Account.ACCOUNT_ID_COMBINED_VIEW ? NO_ACCOUNT : mAccountId;
} }
public long getMailboxId() { /**
return mMailboxId; * Returns the id of the mailbox used for the message list fragment.
* IMPORTANT: Do not confuse this with {@link #mMailboxListMailboxId} which is the id used
* for the mailbox list. The two may be different.
*/
public long getMessageListMailboxId() {
return mMessageListFragment.getMailboxId();
} }
public long getMessageId() { public long getMessageId() {
@ -480,7 +502,7 @@ class UIControllerTwoPane implements
} }
public boolean isMailboxSelected() { public boolean isMailboxSelected() {
return getMailboxId() != NO_MAILBOX; return getMessageListMailboxId() != NO_MAILBOX;
} }
public boolean isMessageSelected() { public boolean isMessageSelected() {
@ -491,7 +513,9 @@ class UIControllerTwoPane implements
* @return true if refresh is in progress for the current mailbox. * @return true if refresh is in progress for the current mailbox.
*/ */
public boolean isRefreshInProgress() { public boolean isRefreshInProgress() {
return (mMailboxId >= 0) && mRefreshManager.isMessageListRefreshing(mMailboxId); long messageListMailboxId = getMessageListMailboxId();
return (messageListMailboxId >= 0)
&& mRefreshManager.isMessageListRefreshing(messageListMailboxId);
} }
/** /**
@ -586,8 +610,13 @@ class UIControllerTwoPane implements
Log.d(Logging.LOG_TAG, "" + this + " onSaveInstanceState"); Log.d(Logging.LOG_TAG, "" + this + " onSaveInstanceState");
} }
outState.putLong(BUNDLE_KEY_ACCOUNT_ID, mAccountId); outState.putLong(BUNDLE_KEY_ACCOUNT_ID, mAccountId);
outState.putLong(BUNDLE_KEY_MAILBOX_ID, mMailboxId); outState.putLong(BUNDLE_KEY_MAILBOX_ID, mMailboxListMailboxId);
outState.putLong(BUNDLE_KEY_MESSAGE_ID, mMessageId); outState.putLong(BUNDLE_KEY_MESSAGE_ID, mMessageId);
if (!mMailboxStack.isEmpty()) {
// Save the mailbox stack
long[] mailboxIds = Utility.toPrimitiveLongArray(mMailboxStack);
outState.putLongArray(BUNDLE_KEY_MAILBOX_STACK, mailboxIds);
}
} }
public void restoreInstanceState(Bundle savedInstanceState) { public void restoreInstanceState(Bundle savedInstanceState) {
@ -595,8 +624,16 @@ class UIControllerTwoPane implements
Log.d(Logging.LOG_TAG, "" + this + " restoreInstanceState"); Log.d(Logging.LOG_TAG, "" + this + " restoreInstanceState");
} }
mAccountId = savedInstanceState.getLong(BUNDLE_KEY_ACCOUNT_ID, NO_ACCOUNT); mAccountId = savedInstanceState.getLong(BUNDLE_KEY_ACCOUNT_ID, NO_ACCOUNT);
mMailboxId = savedInstanceState.getLong(BUNDLE_KEY_MAILBOX_ID, NO_MAILBOX); mMailboxListMailboxId = savedInstanceState.getLong(BUNDLE_KEY_MAILBOX_ID, NO_MAILBOX);
mMessageId = savedInstanceState.getLong(BUNDLE_KEY_MESSAGE_ID, NO_MESSAGE); mMessageId = savedInstanceState.getLong(BUNDLE_KEY_MESSAGE_ID, NO_MESSAGE);
long[] mailboxIds = savedInstanceState.getLongArray(BUNDLE_KEY_MAILBOX_STACK);
if (mailboxIds != null) {
// Restore the mailbox stack; ugly hack to get around 'Long' versus 'long'
mMailboxStack.clear();
for (long id : mailboxIds) {
mMailboxStack.push(id);
}
}
// STOPSHIP If MailboxFinder is still running, it needs restarting after loadState(). // STOPSHIP If MailboxFinder is still running, it needs restarting after loadState().
// This probably means we need to start MailboxFinder if mMailboxId == -1. // This probably means we need to start MailboxFinder if mMailboxId == -1.
@ -658,9 +695,24 @@ class UIControllerTwoPane implements
* Must never be {@link #NO_ACCOUNT}. * Must never be {@link #NO_ACCOUNT}.
*/ */
public void openAccount(long accountId) { public void openAccount(long accountId) {
mMailboxStack.clear();
updateActionBar();
open(accountId, NO_MAILBOX, NO_MESSAGE); open(accountId, NO_MAILBOX, NO_MESSAGE);
} }
/**
* Opens the given mailbox. on two-pane, this will update both the mailbox list and the
* message list.
*
* NOTE: It's assumed that the mailbox is associated with the specified account. If the
* mailbox is not associated with the account, the behaviour is undefined.
*/
private void openMailbox(long accountId, long mailboxId) {
updateActionBar();
updateMailboxList(accountId, mailboxId, true, true);
updateMessageList(mailboxId, true, true);
}
/** /**
* Loads the given account and optionally selects the given mailbox and message. Used to open * Loads the given account and optionally selects the given mailbox and message. Used to open
* a particular view at a request from outside of the activity, such as the widget. * a particular view at a request from outside of the activity, such as the widget.
@ -692,11 +744,11 @@ class UIControllerTwoPane implements
} }
} else if (messageId == NO_MESSAGE) { } else if (messageId == NO_MESSAGE) {
// STOPSHIP Use the appropriate parent mailbox ID // STOPSHIP Use the appropriate parent mailbox ID
updateMailboxList(accountId, NO_MAILBOX, true, true); updateMailboxList(accountId, mailboxId, true, true);
updateMessageList(mailboxId, true, true); updateMessageList(mailboxId, true, true);
} else { } else {
// STOPSHIP Use the appropriate parent mailbox ID // STOPSHIP Use the appropriate parent mailbox ID
updateMailboxList(accountId, NO_MAILBOX, false, true); updateMailboxList(accountId, mailboxId, false, true);
updateMessageList(mailboxId, false, true); updateMessageList(mailboxId, false, true);
updateMessageView(messageId); updateMessageView(messageId);
} }
@ -748,13 +800,13 @@ class UIControllerTwoPane implements
// then return. // then return.
mAccountId = accountId; mAccountId = accountId;
mMailboxListMailboxId = parentMailboxId;
// Open mailbox list, remove message list / message view // Open mailbox list, remove message list / message view
final FragmentManager fm = mActivity.getFragmentManager(); final FragmentManager fm = mActivity.getFragmentManager();
final FragmentTransaction ft = fm.beginTransaction(); final FragmentTransaction ft = fm.beginTransaction();
uninstallMailboxListFragment(ft); uninstallMailboxListFragment(ft);
if (clearDependentPane) { if (clearDependentPane) {
mMailboxId = NO_MAILBOX;
mMessageId = NO_MESSAGE; mMessageId = NO_MESSAGE;
uninstallMessageListFragment(ft); uninstallMessageListFragment(ft);
uninstallMessageViewFragment(ft); uninstallMessageViewFragment(ft);
@ -802,8 +854,6 @@ class UIControllerTwoPane implements
// TODO Check if the current fragment has been initialized with the same parameters, and // TODO Check if the current fragment has been initialized with the same parameters, and
// then return. // then return.
mMailboxId = mailboxId;
final FragmentManager fm = mActivity.getFragmentManager(); final FragmentManager fm = mActivity.getFragmentManager();
final FragmentTransaction ft = fm.beginTransaction(); final FragmentTransaction ft = fm.beginTransaction();
uninstallMessageListFragment(ft); uninstallMessageListFragment(ft);
@ -818,6 +868,8 @@ class UIControllerTwoPane implements
mThreePane.showLeftPane(); mThreePane.showLeftPane();
} }
// TODO We shouldn't select the mailbox when we're updating the message list. These two
// functions should be done separately. Find a better location for this call to be done.
mMailboxListFragment.setSelectedMailbox(mailboxId); mMailboxListFragment.setSelectedMailbox(mailboxId);
updateRefreshProgress(); updateRefreshProgress();
} }
@ -894,7 +946,7 @@ class UIControllerTwoPane implements
if (!isMailboxSelected()) { if (!isMailboxSelected()) {
return; return;
} }
final long mailboxId = getMailboxId(); final long mailboxId = getMessageListMailboxId();
if (mOrderManager == null || mOrderManager.getMailboxId() != mailboxId) { if (mOrderManager == null || mOrderManager.getMailboxId() != mailboxId) {
stopMessageOrderManager(); stopMessageOrderManager();
mOrderManager = mOrderManager =
@ -1098,6 +1150,15 @@ class UIControllerTwoPane implements
public boolean onBackPressed(boolean isSystemBackKey) { public boolean onBackPressed(boolean isSystemBackKey) {
if (mThreePane.onBackPressed(isSystemBackKey)) { if (mThreePane.onBackPressed(isSystemBackKey)) {
return true; return true;
} else if (!mMailboxStack.isEmpty()) {
long mailboxId = mMailboxStack.pop();
if (mailboxId == NO_MAILBOX) {
// No mailbox; reload the top-level message list
openAccount(mAccountId);
} else {
openMailbox(mAccountId, mailboxId);
}
return true;
} }
return false; return false;
} }
@ -1128,7 +1189,7 @@ class UIControllerTwoPane implements
public void onRefresh() { public void onRefresh() {
// Cancel previously running instance if any. // Cancel previously running instance if any.
new RefreshTask(mTaskTracker, mActivity, getActualAccountId(), new RefreshTask(mTaskTracker, mActivity, getActualAccountId(),
getMailboxId()).cancelPreviousAndExecuteParallel(); getMessageListMailboxId()).cancelPreviousAndExecuteParallel();
} }
/** /**