Add "Combined view".

- Don't show combined mailboxes with regular mailboxes in the mailbox list.
- Add "Combined view" to the account selector instead.
- "Combined view" has all the combined mailboxes and accounts.
- Renambed these combined boxes.  (e.g. "Combined inbox" -> "Inbox")
- Regular account view still has "Starred" mailbox, but it's actually
  "combined" and not per-account.
- Re-order special mailboxes per latest wireframe.

Bug 3138004

Change-Id: I4c5860c6774b10c55ba0ca599373e51105432cf8
This commit is contained in:
Makoto Onuki 2010-10-25 17:51:56 -07:00
parent 7c09f04810
commit 730cc6724a
9 changed files with 224 additions and 74 deletions

View File

@ -244,21 +244,24 @@
<!-- The text in the small separator between smart folders and the accounts --> <!-- The text in the small separator between smart folders and the accounts -->
<string name="account_folder_list_separator_accounts">Accounts</string> <string name="account_folder_list_separator_accounts">Accounts</string>
<!-- The summary section entry in the AccountFolder list to display all inboxes --> <!-- The summary section entry in the AccountFolder list to display all inboxes -->
<string name="account_folder_list_summary_inbox">Combined Inbox</string> <string name="account_folder_list_summary_inbox">Inbox</string>
<!-- The summary section entry in the AccountFolder list to display all starred <!-- The summary section entry in the AccountFolder list to display all starred
[CHAR LIMIT=200dip] --> [CHAR LIMIT=200dip] -->
<string name="account_folder_list_summary_starred">All Starred</string> <string name="account_folder_list_summary_starred">Starred</string>
<!-- The summary section entry in the AccountFolder list to display all drafts <!-- The summary section entry in the AccountFolder list to display all drafts
[CHAR LIMIT=200dip] --> [CHAR LIMIT=200dip] -->
<string name="account_folder_list_summary_drafts">All Drafts</string> <string name="account_folder_list_summary_drafts">Drafts</string>
<!-- The summary section entry in the AccountFolder list to display all outboxes <!-- The summary section entry in the AccountFolder list to display all outboxes
[CHAR LIMIT=200dip] --> [CHAR LIMIT=200dip] -->
<string name="account_folder_list_summary_outbox">Combined Outbox</string> <string name="account_folder_list_summary_outbox">Outbox</string>
<!-- Toast that appears when you select "Refresh" menu option --> <!-- Toast that appears when you select "Refresh" menu option -->
<string name="account_folder_list_refresh_toast">Please longpress an account to refresh it</string> <string name="account_folder_list_refresh_toast">Please longpress an account to refresh it</string>
<!-- Title of the screen that shows a list of mailboxes for an account --> <!-- Title of the screen that shows a list of mailboxes for an account -->
<string name="mailbox_list_title">Mailbox</string> <string name="mailbox_list_title">Mailbox</string>
<!-- Label shown in the account selector to select "Combined view", which contains
Combined Inbox, Combined Outbox, etc. [CHAR LIMIT=30] -->
<string name="mailbox_list_account_selector_combined_view">Combined view</string>
<!-- Appears at the bottom of list of messages; user selects to load more messages from that folder. --> <!-- Appears at the bottom of list of messages; user selects to load more messages from that folder. -->
<string name="message_list_load_more_messages_action">Load more messages</string> <string name="message_list_load_more_messages_action">Load more messages</string>

View File

@ -16,13 +16,17 @@
package com.android.email.activity; package com.android.email.activity;
import com.android.email.R;
import com.android.email.data.ThrottlingCursorLoader; import com.android.email.data.ThrottlingCursorLoader;
import com.android.email.provider.EmailContent; import com.android.email.provider.EmailContent;
import com.android.email.provider.EmailContent.Account;
import android.content.Context; import android.content.Context;
import android.content.Loader; import android.content.Loader;
import android.database.Cursor; import android.database.Cursor;
import android.text.TextUtils; import android.database.MatrixCursor;
import android.database.MatrixCursor.RowBuilder;
import android.database.MergeCursor;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -53,8 +57,7 @@ public class AccountSelectorAdapter extends CursorAdapter {
private final LayoutInflater mInflater; private final LayoutInflater mInflater;
public static Loader<Cursor> createLoader(Context context) { public static Loader<Cursor> createLoader(Context context) {
return new ThrottlingCursorLoader(context, EmailContent.Account.CONTENT_URI, PROJECTION, return new AccountsLoader(context);
null, null, ORDER_BY);
} }
public AccountSelectorAdapter(Context context, Cursor c) { public AccountSelectorAdapter(Context context, Cursor c) {
@ -95,4 +98,33 @@ public class AccountSelectorAdapter extends CursorAdapter {
public static String getAccountDisplayName(Cursor cursor) { public static String getAccountDisplayName(Cursor cursor) {
return cursor.getString(DISPLAY_NAME_COLUMN); return cursor.getString(DISPLAY_NAME_COLUMN);
} }
/**
* Load the account list. Also add the "Combined view" row if there's more than one account.
*/
private static class AccountsLoader extends ThrottlingCursorLoader {
private final Context mContext;
public AccountsLoader(Context context) {
super(context, EmailContent.Account.CONTENT_URI, PROJECTION, null, null, ORDER_BY);
mContext = context;
}
@Override
public Cursor loadInBackground() {
final Cursor accountsCursor = super.loadInBackground();
if (accountsCursor.getCount() <= 1) {
return accountsCursor;
}
// If more than 1 account, add "Combined view".
final MatrixCursor combinedViewRow = new MatrixCursor(PROJECTION);
RowBuilder rb = combinedViewRow.newRow();
// Add ID and display name
rb.add(Account.ACCOUNT_ID_COMBINED_VIEW);
rb.add(mContext.getResources().getString(
R.string.mailbox_list_account_selector_combined_view));
return new MergeCursor(new Cursor[] {accountsCursor, combinedViewRow});
}
}
} }

View File

@ -202,10 +202,19 @@ public class MailboxList extends Activity implements MailboxListFragment.Callbac
/** /**
* Implements MailboxFragment.Callback * Implements MailboxFragment.Callback
*/ */
@Override
public void onMailboxSelected(long accountId, long mailboxId) { public void onMailboxSelected(long accountId, long mailboxId) {
onOpenMailbox(mailboxId); onOpenMailbox(mailboxId);
} }
/**
* Implements MailboxFragment.Callback
*/
@Override
public void onAccountSelected(long accountId) {
// Only used on the Combined view, which isn't used on the phone UI.
}
/** /**
* Refresh the mailbox list * Refresh the mailbox list
*/ */

View File

@ -19,6 +19,7 @@ package com.android.email.activity;
import com.android.email.Email; import com.android.email.Email;
import com.android.email.RefreshManager; import com.android.email.RefreshManager;
import com.android.email.Utility; import com.android.email.Utility;
import com.android.email.provider.EmailContent.Account;
import android.app.Activity; import android.app.Activity;
import android.app.ListFragment; import android.app.ListFragment;
@ -72,14 +73,17 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
* Callback interface that owning activities must implement * Callback interface that owning activities must implement
*/ */
public interface Callback { public interface Callback {
/** Called when a mailbox (including combined mailbox) is selected. */
public void onMailboxSelected(long accountId, long mailboxId); public void onMailboxSelected(long accountId, long mailboxId);
/** Called when an account is selected on the combined view. */
public void onAccountSelected(long accountId);
} }
private static class EmptyCallback implements Callback { private static class EmptyCallback implements Callback {
public static final Callback INSTANCE = new EmptyCallback(); public static final Callback INSTANCE = new EmptyCallback();
@Override @Override public void onMailboxSelected(long accountId, long mailboxId) { }
public void onMailboxSelected(long accountId, long mailboxId) { @Override public void onAccountSelected(long accountId) { }
}
} }
/** /**
@ -307,9 +311,14 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
} }
} }
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position,
// Don't use the id parameter. See MailboxesAdapter. long idDontUseIt /* see MailboxesAdapter */ ) {
mCallback.onMailboxSelected(mAccountId, mListAdapter.getMailboxId(position)); final long id = mListAdapter.getId(position);
if (mListAdapter.isAccountRow(position)) {
mCallback.onAccountSelected(id);
} else {
mCallback.onMailboxSelected(mAccountId, id);
}
} }
public void onRefresh() { public void onRefresh() {
@ -335,7 +344,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
} }
final int count = mListView.getCount(); final int count = mListView.getCount();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
if (mListAdapter.getMailboxId(i) != mSelectedMailboxId) { if (mListAdapter.getId(i) != mSelectedMailboxId) {
continue; continue;
} }
mListView.setItemChecked(i, true); mListView.setItemChecked(i, true);

View File

@ -22,6 +22,7 @@ import com.android.email.Utility;
import com.android.email.data.ThrottlingCursorLoader; import com.android.email.data.ThrottlingCursorLoader;
import com.android.email.provider.EmailContent; import com.android.email.provider.EmailContent;
import com.android.email.provider.EmailContent.Account; import com.android.email.provider.EmailContent.Account;
import com.android.email.provider.EmailContent.AccountColumns;
import com.android.email.provider.EmailContent.Mailbox; import com.android.email.provider.EmailContent.Mailbox;
import com.android.email.provider.EmailContent.MailboxColumns; import com.android.email.provider.EmailContent.MailboxColumns;
import com.android.email.provider.EmailContent.Message; import com.android.email.provider.EmailContent.Message;
@ -51,13 +52,21 @@ import java.security.InvalidParameterException;
* *
* TODO New UI will probably not distinguish unread counts from # of messages. * TODO New UI will probably not distinguish unread counts from # of messages.
* i.e. we won't need two different viewes for them. * i.e. we won't need two different viewes for them.
* TODO Show "Starred" per account? (Right now we have only "All Starred") * TODO Show "Starred" per account
* TODO Unit test, when UI is settled. * TODO Unit test, when UI is settled.
*/ */
/* package */ class MailboxesAdapter extends CursorAdapter { /* package */ class MailboxesAdapter extends CursorAdapter {
public static final int MODE_NORMAL = 0; public static final int MODE_NORMAL = 0;
public static final int MODE_MOVE_TO_TARGET = 1; public static final int MODE_MOVE_TO_TARGET = 1;
/**
* Row type, used in the "row_type" in {@link PROJECTION}.
* {@link #ROW_TYPE_MAILBOX} for regular mailboxes and combined mailboxes.
* {@link #ROW_TYPE_ACCOUNT} for account row in the combined view.
*/
private static final int ROW_TYPE_MAILBOX = 0;
private static final int ROW_TYPE_ACCOUNT = 1;
/* /*
* 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
* values to be negative. The second one is the actual mailbox ID, which we use in the rest * values to be negative. The second one is the actual mailbox ID, which we use in the rest
@ -70,13 +79,14 @@ import java.security.InvalidParameterException;
/* package */ static final String[] PROJECTION = new String[] { MailboxColumns.ID, /* package */ static final String[] PROJECTION = new String[] { MailboxColumns.ID,
MailboxColumns.ID + " AS org_mailbox_id", MailboxColumns.ID + " AS org_mailbox_id",
MailboxColumns.DISPLAY_NAME, MailboxColumns.TYPE, MailboxColumns.UNREAD_COUNT, MailboxColumns.DISPLAY_NAME, MailboxColumns.TYPE, MailboxColumns.UNREAD_COUNT,
MailboxColumns.MESSAGE_COUNT}; MailboxColumns.MESSAGE_COUNT, ROW_TYPE_MAILBOX + " AS row_type"};
// Column 0 is only for ListView; we don't use it in our code. // Column 0 is only for ListView; we don't use it in our code.
private static final int COLUMN_ID = 1; private static final int COLUMN_ID = 1;
private static final int COLUMN_DISPLAY_NAME = 2; private static final int COLUMN_DISPLAY_NAME = 2;
private static final int COLUMN_TYPE = 3; private static final int COLUMN_TYPE = 3;
private static final int COLUMN_UNREAD_COUNT = 4; private static final int COLUMN_UNREAD_COUNT = 4;
private static final int COLUMN_MESSAGE_COUNT = 5; private static final int COLUMN_MESSAGE_COUNT = 5;
private static final int COLUMN_ROW_TYPE = 6;
private static final String MAILBOX_SELECTION = MailboxColumns.ACCOUNT_KEY + "=?" + private static final String MAILBOX_SELECTION = MailboxColumns.ACCOUNT_KEY + "=?" +
" AND " + MailboxColumns.TYPE + "<" + Mailbox.TYPE_NOT_EMAIL + " AND " + MailboxColumns.TYPE + "<" + Mailbox.TYPE_NOT_EMAIL +
@ -88,11 +98,12 @@ import java.security.InvalidParameterException;
private static final String MAILBOX_ORDER_BY = "CASE " + MailboxColumns.TYPE + private static final String MAILBOX_ORDER_BY = "CASE " + MailboxColumns.TYPE +
" WHEN " + Mailbox.TYPE_INBOX + " THEN 0" + " WHEN " + Mailbox.TYPE_INBOX + " THEN 0" +
" WHEN " + Mailbox.TYPE_DRAFTS + " THEN 1" + " WHEN " + Mailbox.TYPE_DRAFTS + " THEN 1" +
" WHEN " + Mailbox.TYPE_SENT + " THEN 2" + " WHEN " + Mailbox.TYPE_OUTBOX + " THEN 2" +
" WHEN " + Mailbox.TYPE_OUTBOX + " THEN 3" + " WHEN " + Mailbox.TYPE_SENT + " THEN 3" +
" WHEN " + Mailbox.TYPE_TRASH + " THEN 20" + // After standard mailboxes " WHEN " + Mailbox.TYPE_TRASH + " THEN 4" +
" WHEN " + Mailbox.TYPE_JUNK + " THEN 21" + // After standard mailboxes " WHEN " + Mailbox.TYPE_JUNK + " THEN 5" +
" ELSE 10 END" + // for Mailbox.TYPE_MAIL, standard mailboxes // Other mailboxes (i.e. of Mailbox.TYPE_MAIL) are shown in alphabetical order.
" ELSE 10 END" +
" ," + MailboxColumns.DISPLAY_NAME; " ," + MailboxColumns.DISPLAY_NAME;
private final LayoutInflater mInflater; private final LayoutInflater mInflater;
@ -105,7 +116,19 @@ import java.security.InvalidParameterException;
mMode = mode; mMode = mode;
} }
public long getMailboxId(int position) { /**
* @return true if the specified row is of an account in the combined view.
*/
public boolean isAccountRow(int position) {
Cursor c = (Cursor) getItem(position);
return c.getInt(COLUMN_ROW_TYPE) == ROW_TYPE_ACCOUNT;
}
/**
* @return ID of the mailbox (or account, if {@link #isAccountRow} == true) of the specified
* row.
*/
public long getId(int position) {
Cursor c = (Cursor) getItem(position); Cursor c = (Cursor) getItem(position);
return c.getLong(COLUMN_ID); return c.getLong(COLUMN_ID);
} }
@ -134,15 +157,20 @@ import java.security.InvalidParameterException;
throw new IllegalStateException(); throw new IllegalStateException();
} }
private static String getMailboxName(Context context, Cursor cursor) { private static String getDisplayName(Context context, Cursor cursor) {
final int type = cursor.getInt(COLUMN_TYPE); String name = null;
final long mailboxId = cursor.getLong(COLUMN_ID); if (cursor.getInt(COLUMN_ROW_TYPE) == ROW_TYPE_MAILBOX) {
String mailboxName = Utility.FolderProperties.getInstance(context) // If it's a mailbox (as opposed to account row in combined view), and of certain types,
.getDisplayName(type, mailboxId); // we use the predefined names.
if (mailboxName == null) { final int type = cursor.getInt(COLUMN_TYPE);
mailboxName = cursor.getString(COLUMN_DISPLAY_NAME); final long mailboxId = cursor.getLong(COLUMN_ID);
name = Utility.FolderProperties.getInstance(context)
.getDisplayName(type, mailboxId);
} }
return mailboxName; if (name == null) {
name = cursor.getString(COLUMN_DISPLAY_NAME);
}
return name;
} }
private void bindViewNormalMode(View view, Context context, Cursor cursor) { private void bindViewNormalMode(View view, Context context, Cursor cursor) {
@ -151,7 +179,7 @@ import java.security.InvalidParameterException;
// 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(getMailboxName(context, cursor)); nameView.setText(getDisplayName(context, cursor));
// Set count // Set count
boolean useTotalCount = false; boolean useTotalCount = false;
@ -197,7 +225,7 @@ import java.security.InvalidParameterException;
private void bindViewMoveToTargetMode(View view, Context context, Cursor cursor) { private void bindViewMoveToTargetMode(View view, Context context, Cursor cursor) {
TextView t = (TextView) view; TextView t = (TextView) view;
t.setText(getMailboxName(context, cursor)); t.setText(getDisplayName(context, cursor));
} }
private View newViewMoveToTargetMode(Context context, Cursor cursor, ViewGroup parent) { private View newViewMoveToTargetMode(Context context, Cursor cursor, ViewGroup parent) {
@ -212,12 +240,15 @@ import java.security.InvalidParameterException;
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) { if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Email.LOG_TAG, "MailboxesAdapter createLoader accountId=" + accountId); Log.d(Email.LOG_TAG, "MailboxesAdapter createLoader accountId=" + accountId);
} }
return new MailboxesLoader(context, accountId, mode); if (accountId != Account.ACCOUNT_ID_COMBINED_VIEW) {
return new MailboxesLoader(context, accountId, mode);
} else {
return new CombinedMailboxesLoader(context);
}
} }
/** /**
* Loader for mailboxes. If there's more than 1 account set up, the result will also include * Loader for mailboxes of an account.
* special mailboxes. (e.g. combined inbox, etc)
*/ */
private static class MailboxesLoader extends ThrottlingCursorLoader { private static class MailboxesLoader extends ThrottlingCursorLoader {
private final Context mContext; private final Context mContext;
@ -241,51 +272,94 @@ import java.security.InvalidParameterException;
@Override @Override
public Cursor loadInBackground() { public Cursor loadInBackground() {
final Cursor mailboxes = super.loadInBackground(); final Cursor mailboxesCursor = super.loadInBackground();
if (mMode == MODE_MOVE_TO_TARGET) { if (mMode == MODE_MOVE_TO_TARGET) {
return mailboxes; return mailboxesCursor;
}
if (mailboxes.getCount() == 0) {
// If there's no mailboxes, don't merge special mailboxes. Just return 0 row
// cursor.
// If there's no row, this means the account has just been set up or recovered and
// we're fetching mailboxes. In this case, the mailbox list shouldn't just show
// special mailboxes. It should show something to indicate it's still loading the
// list, which MailboxListFragment will do if it returns an empty cursor.
return mailboxes;
} }
final int numAccounts = EmailContent.count(mContext, Account.CONTENT_URI); // Add "Starred".
return new MergeCursor( // TODO It's currently "combined starred", but the plan is to make it per-account
new Cursor[] {getSpecialMailboxesCursor(mContext, numAccounts > 1), mailboxes}); // starred.
final int starredCount = Message.getFavoriteMessageCount(mContext);
if (starredCount == 0) {
return mailboxesCursor; // no starred message
}
final MatrixCursor starredCursor = new MatrixCursor(getProjection());
addSummaryMailboxRow(mContext, starredCursor,
Mailbox.QUERY_ALL_FAVORITES, Mailbox.TYPE_MAIL, starredCount, true);
return new MergeCursor(new Cursor[] {starredCursor, mailboxesCursor});
} }
} }
/* package */ static Cursor getSpecialMailboxesCursor(Context context, boolean mShowCombined) { /**
MatrixCursor cursor = new MatrixCursor(PROJECTION); * Loader for mailboxes in "Combined view".
if (mShowCombined) { */
// Combined inbox -- show unread count private static class CombinedMailboxesLoader extends ThrottlingCursorLoader {
addSummaryMailboxRow(context, cursor, private static final String[] ACCOUNT_PROJECTION = new String[] {
Mailbox.QUERY_ALL_INBOXES, Mailbox.TYPE_INBOX, EmailContent.RECORD_ID, AccountColumns.DISPLAY_NAME,
Mailbox.getUnreadCountByMailboxType(context, Mailbox.TYPE_INBOX), true); };
private static final int COLUMN_ACCOUND_ID = 0;
private static final int COLUMN_ACCOUNT_DISPLAY_NAME = 1;
private final Context mContext;
public CombinedMailboxesLoader(Context context) {
// Tell the super class to load accounts.
// But we don't directly return that...
super(context, Account.CONTENT_URI, ACCOUNT_PROJECTION, null, null, null);
mContext = context;
} }
@Override
public Cursor loadInBackground() {
final MatrixCursor combinedWithAccounts = getSpecialMailboxesCursor(mContext);
final Cursor accounts = super.loadInBackground();
try {
accounts.moveToPosition(-1);
while (accounts.moveToNext()) {
RowBuilder row = combinedWithAccounts.newRow();
final long accountId = accounts.getLong(COLUMN_ACCOUND_ID);
row.add(accountId);
row.add(accountId);
row.add(accounts.getString(COLUMN_ACCOUNT_DISPLAY_NAME));
row.add(-1); // No mailbox type. Shouldn't really be used.
final int unreadCount = 0; // TODO get inbox's unread count
row.add(unreadCount);
row.add(unreadCount);
row.add(ROW_TYPE_ACCOUNT);
}
} finally {
accounts.close();
}
return combinedWithAccounts;
}
}
/* package */ static MatrixCursor getSpecialMailboxesCursor(Context context) {
MatrixCursor cursor = new MatrixCursor(PROJECTION);
// Combined inbox -- show unread count
addSummaryMailboxRow(context, cursor,
Mailbox.QUERY_ALL_INBOXES, Mailbox.TYPE_INBOX,
Mailbox.getUnreadCountByMailboxType(context, Mailbox.TYPE_INBOX), true);
// Favorite (starred) -- show # of favorites // Favorite (starred) -- show # of favorites
addSummaryMailboxRow(context, cursor, addSummaryMailboxRow(context, cursor,
Mailbox.QUERY_ALL_FAVORITES, Mailbox.TYPE_MAIL, Mailbox.QUERY_ALL_FAVORITES, Mailbox.TYPE_MAIL,
Message.getFavoriteMessageCount(context), false); Message.getFavoriteMessageCount(context), false);
if (mShowCombined) { // Drafts -- show # of drafts
// Drafts -- show # of drafts addSummaryMailboxRow(context, cursor,
addSummaryMailboxRow(context, cursor, Mailbox.QUERY_ALL_DRAFTS, Mailbox.TYPE_DRAFTS,
Mailbox.QUERY_ALL_DRAFTS, Mailbox.TYPE_DRAFTS, Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_DRAFTS), false);
Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_DRAFTS), false);
// Outbox -- # of sent messages // Outbox -- # of sent messages
addSummaryMailboxRow(context, cursor, addSummaryMailboxRow(context, cursor,
Mailbox.QUERY_ALL_OUTBOX, Mailbox.TYPE_OUTBOX, Mailbox.QUERY_ALL_OUTBOX, Mailbox.TYPE_OUTBOX,
Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_OUTBOX), false); Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_OUTBOX), false);
}
return cursor; return cursor;
} }
@ -303,6 +377,7 @@ import java.security.InvalidParameterException;
row.add(type); row.add(type);
row.add(count); row.add(count);
row.add(count); row.add(count);
row.add(ROW_TYPE_MAILBOX);
} }
} }

View File

@ -339,6 +339,12 @@ public class MessageListXL extends Activity implements
public void onMailboxSelected(long accountId, long mailboxId) { public void onMailboxSelected(long accountId, long mailboxId) {
mFragmentManager.selectMailbox(mailboxId, true); mFragmentManager.selectMailbox(mailboxId, true);
} }
@Override
public void onAccountSelected(long accountId) {
mFragmentManager.selectAccount(accountId, -1, true);
loadAccounts(); // This will update the account spinner, and select the account.
}
} }
private class MessageListFragmentCallback implements MessageListFragment.Callback { private class MessageListFragmentCallback implements MessageListFragment.Callback {
@ -464,6 +470,13 @@ public class MessageListXL extends Activity implements
updateProgressIcon(); updateProgressIcon();
} }
/**
* Load account list for the action bar.
*
* If there's only one account configured, show the account name in the action bar.
* If more than one account are configured, show a spinner in the action bar, and select the
* current account.
*/
private void loadAccounts() { private void loadAccounts() {
getLoaderManager().initLoader(LOADER_ID_ACCOUNT_LIST, null, new LoaderCallbacks<Cursor>() { getLoaderManager().initLoader(LOADER_ID_ACCOUNT_LIST, null, new LoaderCallbacks<Cursor>() {
@Override @Override
@ -511,10 +524,8 @@ public class MessageListXL extends Activity implements
// Update the dropdown list. // Update the dropdown list.
mAccountsSelectorAdapter.changeCursor(accountsCursor); mAccountsSelectorAdapter.changeCursor(accountsCursor);
if (ab.getNavigationMode() != ActionBar.NAVIGATION_MODE_DROPDOWN_LIST) { ab.setDropdownNavigationMode(mAccountsSelectorAdapter,
ab.setDropdownNavigationMode(mAccountsSelectorAdapter, mActionBarNavigationCallback, defaultSelection);
mActionBarNavigationCallback, defaultSelection);
}
} }
private class ActionBarNavigationCallback implements ActionBar.NavigationCallback { private class ActionBarNavigationCallback implements ActionBar.NavigationCallback {

View File

@ -18,6 +18,7 @@ package com.android.email.activity;
import com.android.email.Email; import com.android.email.Email;
import com.android.email.R; import com.android.email.R;
import com.android.email.provider.EmailContent.Account;
import com.android.email.provider.EmailContent.Mailbox; import com.android.email.provider.EmailContent.Mailbox;
import android.app.Fragment; import android.app.Fragment;
@ -289,7 +290,10 @@ class MessageListXLFragmentManager {
mMessageListFragment.clearContent(); mMessageListFragment.clearContent();
hideMessageView(); hideMessageView();
if (mailboxId == -1) { if ((accountId == Account.ACCOUNT_ID_COMBINED_VIEW) && (mailboxId == -1)) {
// When opening the Combined view, the right pane will be "combined inbox".
selectMailbox(Mailbox.QUERY_ALL_INBOXES, false);
} else if (mailboxId == -1) {
startInboxLookup(); startInboxLookup();
} else { } else {
selectMailbox(mailboxId, byExplicitUserAction); selectMailbox(mailboxId, byExplicitUserAction);

View File

@ -825,8 +825,6 @@ public abstract class EmailContent {
/** /**
* @return number of favorite (starred) messages throughout all accounts. * @return number of favorite (starred) messages throughout all accounts.
*
* TODO Add trigger to keep track. (index isn't efficient in this case.)
*/ */
public static int getFavoriteMessageCount(Context context) { public static int getFavoriteMessageCount(Context context) {
return count(context, Message.CONTENT_URI, FAVORITE_COUNT_SELECTION, null); return count(context, Message.CONTENT_URI, FAVORITE_COUNT_SELECTION, null);
@ -910,6 +908,15 @@ public abstract class EmailContent {
public static final Uri RESET_NEW_MESSAGE_COUNT_URI = public static final Uri RESET_NEW_MESSAGE_COUNT_URI =
Uri.parse(EmailContent.CONTENT_URI + "/resetNewMessageCount"); Uri.parse(EmailContent.CONTENT_URI + "/resetNewMessageCount");
/**
* Value used by UI to represent "combined view".
*
* NOTE: This must be used only by UI, and mustn't be stored in the database.
*
* This is defined here to avoid conflict with other pseudo account IDs, if any.
*/
public static final long ACCOUNT_ID_COMBINED_VIEW = 0x1000000000000000L;
public final static int FLAGS_NOTIFY_NEW_MAIL = 1; public final static int FLAGS_NOTIFY_NEW_MAIL = 1;
public final static int FLAGS_VIBRATE_ALWAYS = 2; public final static int FLAGS_VIBRATE_ALWAYS = 2;
public static final int FLAGS_DELETE_POLICY_MASK = 4+8; public static final int FLAGS_DELETE_POLICY_MASK = 4+8;

View File

@ -69,7 +69,7 @@ public class MailboxesAdapterTest extends ProviderTestCase2<EmailProvider> {
createMessage(c, b2d, false, true); createMessage(c, b2d, false, true);
// Kick the method // Kick the method
Cursor cursor = MailboxesAdapter.getSpecialMailboxesCursor(c, true); Cursor cursor = MailboxesAdapter.getSpecialMailboxesCursor(c);
// Check the result // Check the result
assertEquals(4, cursor.getCount()); assertEquals(4, cursor.getCount());