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:
parent
7c09f04810
commit
730cc6724a
|
@ -244,21 +244,24 @@
|
|||
<!-- The text in the small separator between smart folders and the accounts -->
|
||||
<string name="account_folder_list_separator_accounts">Accounts</string>
|
||||
<!-- 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
|
||||
[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
|
||||
[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
|
||||
[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 -->
|
||||
<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 -->
|
||||
<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. -->
|
||||
<string name="message_list_load_more_messages_action">Load more messages</string>
|
||||
|
|
|
@ -16,13 +16,17 @@
|
|||
|
||||
package com.android.email.activity;
|
||||
|
||||
import com.android.email.R;
|
||||
import com.android.email.data.ThrottlingCursorLoader;
|
||||
import com.android.email.provider.EmailContent;
|
||||
import com.android.email.provider.EmailContent.Account;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Loader;
|
||||
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.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -53,8 +57,7 @@ public class AccountSelectorAdapter extends CursorAdapter {
|
|||
private final LayoutInflater mInflater;
|
||||
|
||||
public static Loader<Cursor> createLoader(Context context) {
|
||||
return new ThrottlingCursorLoader(context, EmailContent.Account.CONTENT_URI, PROJECTION,
|
||||
null, null, ORDER_BY);
|
||||
return new AccountsLoader(context);
|
||||
}
|
||||
|
||||
public AccountSelectorAdapter(Context context, Cursor c) {
|
||||
|
@ -95,4 +98,33 @@ public class AccountSelectorAdapter extends CursorAdapter {
|
|||
public static String getAccountDisplayName(Cursor cursor) {
|
||||
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});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,10 +202,19 @@ public class MailboxList extends Activity implements MailboxListFragment.Callbac
|
|||
/**
|
||||
* Implements MailboxFragment.Callback
|
||||
*/
|
||||
@Override
|
||||
public void onMailboxSelected(long accountId, long 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
|
||||
*/
|
||||
|
|
|
@ -19,6 +19,7 @@ package com.android.email.activity;
|
|||
import com.android.email.Email;
|
||||
import com.android.email.RefreshManager;
|
||||
import com.android.email.Utility;
|
||||
import com.android.email.provider.EmailContent.Account;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ListFragment;
|
||||
|
@ -72,14 +73,17 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
|
|||
* Callback interface that owning activities must implement
|
||||
*/
|
||||
public interface Callback {
|
||||
/** Called when a mailbox (including combined mailbox) is selected. */
|
||||
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 {
|
||||
public static final Callback INSTANCE = new EmptyCallback();
|
||||
@Override
|
||||
public void onMailboxSelected(long accountId, long mailboxId) {
|
||||
}
|
||||
@Override 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) {
|
||||
// Don't use the id parameter. See MailboxesAdapter.
|
||||
mCallback.onMailboxSelected(mAccountId, mListAdapter.getMailboxId(position));
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long idDontUseIt /* see MailboxesAdapter */ ) {
|
||||
final long id = mListAdapter.getId(position);
|
||||
if (mListAdapter.isAccountRow(position)) {
|
||||
mCallback.onAccountSelected(id);
|
||||
} else {
|
||||
mCallback.onMailboxSelected(mAccountId, id);
|
||||
}
|
||||
}
|
||||
|
||||
public void onRefresh() {
|
||||
|
@ -335,7 +344,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
|
|||
}
|
||||
final int count = mListView.getCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (mListAdapter.getMailboxId(i) != mSelectedMailboxId) {
|
||||
if (mListAdapter.getId(i) != mSelectedMailboxId) {
|
||||
continue;
|
||||
}
|
||||
mListView.setItemChecked(i, true);
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.android.email.Utility;
|
|||
import com.android.email.data.ThrottlingCursorLoader;
|
||||
import com.android.email.provider.EmailContent;
|
||||
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.MailboxColumns;
|
||||
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.
|
||||
* 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.
|
||||
*/
|
||||
/* package */ class MailboxesAdapter extends CursorAdapter {
|
||||
public static final int MODE_NORMAL = 0;
|
||||
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
|
||||
* 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,
|
||||
MailboxColumns.ID + " AS org_mailbox_id",
|
||||
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.
|
||||
private static final int COLUMN_ID = 1;
|
||||
private static final int COLUMN_DISPLAY_NAME = 2;
|
||||
private static final int COLUMN_TYPE = 3;
|
||||
private static final int COLUMN_UNREAD_COUNT = 4;
|
||||
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 + "=?" +
|
||||
" 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 +
|
||||
" WHEN " + Mailbox.TYPE_INBOX + " THEN 0" +
|
||||
" WHEN " + Mailbox.TYPE_DRAFTS + " THEN 1" +
|
||||
" WHEN " + Mailbox.TYPE_SENT + " THEN 2" +
|
||||
" WHEN " + Mailbox.TYPE_OUTBOX + " THEN 3" +
|
||||
" WHEN " + Mailbox.TYPE_TRASH + " THEN 20" + // After standard mailboxes
|
||||
" WHEN " + Mailbox.TYPE_JUNK + " THEN 21" + // After standard mailboxes
|
||||
" ELSE 10 END" + // for Mailbox.TYPE_MAIL, standard mailboxes
|
||||
" WHEN " + Mailbox.TYPE_OUTBOX + " THEN 2" +
|
||||
" WHEN " + Mailbox.TYPE_SENT + " THEN 3" +
|
||||
" WHEN " + Mailbox.TYPE_TRASH + " THEN 4" +
|
||||
" WHEN " + Mailbox.TYPE_JUNK + " THEN 5" +
|
||||
// Other mailboxes (i.e. of Mailbox.TYPE_MAIL) are shown in alphabetical order.
|
||||
" ELSE 10 END" +
|
||||
" ," + MailboxColumns.DISPLAY_NAME;
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
|
@ -105,7 +116,19 @@ import java.security.InvalidParameterException;
|
|||
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);
|
||||
return c.getLong(COLUMN_ID);
|
||||
}
|
||||
|
@ -134,15 +157,20 @@ import java.security.InvalidParameterException;
|
|||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
private static String getMailboxName(Context context, Cursor cursor) {
|
||||
final int type = cursor.getInt(COLUMN_TYPE);
|
||||
final long mailboxId = cursor.getLong(COLUMN_ID);
|
||||
String mailboxName = Utility.FolderProperties.getInstance(context)
|
||||
.getDisplayName(type, mailboxId);
|
||||
if (mailboxName == null) {
|
||||
mailboxName = cursor.getString(COLUMN_DISPLAY_NAME);
|
||||
private static String getDisplayName(Context context, Cursor cursor) {
|
||||
String name = null;
|
||||
if (cursor.getInt(COLUMN_ROW_TYPE) == ROW_TYPE_MAILBOX) {
|
||||
// If it's a mailbox (as opposed to account row in combined view), and of certain types,
|
||||
// we use the predefined names.
|
||||
final int type = cursor.getInt(COLUMN_TYPE);
|
||||
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) {
|
||||
|
@ -151,7 +179,7 @@ import java.security.InvalidParameterException;
|
|||
|
||||
// Set mailbox name
|
||||
final TextView nameView = (TextView) view.findViewById(R.id.mailbox_name);
|
||||
nameView.setText(getMailboxName(context, cursor));
|
||||
nameView.setText(getDisplayName(context, cursor));
|
||||
|
||||
// Set count
|
||||
boolean useTotalCount = false;
|
||||
|
@ -197,7 +225,7 @@ import java.security.InvalidParameterException;
|
|||
|
||||
private void bindViewMoveToTargetMode(View view, Context context, Cursor cursor) {
|
||||
TextView t = (TextView) view;
|
||||
t.setText(getMailboxName(context, cursor));
|
||||
t.setText(getDisplayName(context, cursor));
|
||||
}
|
||||
|
||||
private View newViewMoveToTargetMode(Context context, Cursor cursor, ViewGroup parent) {
|
||||
|
@ -212,12 +240,15 @@ import java.security.InvalidParameterException;
|
|||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
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
|
||||
* special mailboxes. (e.g. combined inbox, etc)
|
||||
* Loader for mailboxes of an account.
|
||||
*/
|
||||
private static class MailboxesLoader extends ThrottlingCursorLoader {
|
||||
private final Context mContext;
|
||||
|
@ -241,51 +272,94 @@ import java.security.InvalidParameterException;
|
|||
|
||||
@Override
|
||||
public Cursor loadInBackground() {
|
||||
final Cursor mailboxes = super.loadInBackground();
|
||||
final Cursor mailboxesCursor = super.loadInBackground();
|
||||
if (mMode == MODE_MOVE_TO_TARGET) {
|
||||
return mailboxes;
|
||||
}
|
||||
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;
|
||||
return mailboxesCursor;
|
||||
}
|
||||
|
||||
final int numAccounts = EmailContent.count(mContext, Account.CONTENT_URI);
|
||||
return new MergeCursor(
|
||||
new Cursor[] {getSpecialMailboxesCursor(mContext, numAccounts > 1), mailboxes});
|
||||
// Add "Starred".
|
||||
// TODO It's currently "combined starred", but the plan is to make it per-account
|
||||
// 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);
|
||||
if (mShowCombined) {
|
||||
// Combined inbox -- show unread count
|
||||
addSummaryMailboxRow(context, cursor,
|
||||
Mailbox.QUERY_ALL_INBOXES, Mailbox.TYPE_INBOX,
|
||||
Mailbox.getUnreadCountByMailboxType(context, Mailbox.TYPE_INBOX), true);
|
||||
/**
|
||||
* Loader for mailboxes in "Combined view".
|
||||
*/
|
||||
private static class CombinedMailboxesLoader extends ThrottlingCursorLoader {
|
||||
private static final String[] ACCOUNT_PROJECTION = new String[] {
|
||||
EmailContent.RECORD_ID, AccountColumns.DISPLAY_NAME,
|
||||
};
|
||||
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
|
||||
addSummaryMailboxRow(context, cursor,
|
||||
Mailbox.QUERY_ALL_FAVORITES, Mailbox.TYPE_MAIL,
|
||||
Message.getFavoriteMessageCount(context), false);
|
||||
|
||||
if (mShowCombined) {
|
||||
// Drafts -- show # of drafts
|
||||
addSummaryMailboxRow(context, cursor,
|
||||
Mailbox.QUERY_ALL_DRAFTS, Mailbox.TYPE_DRAFTS,
|
||||
Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_DRAFTS), false);
|
||||
// Drafts -- show # of drafts
|
||||
addSummaryMailboxRow(context, cursor,
|
||||
Mailbox.QUERY_ALL_DRAFTS, Mailbox.TYPE_DRAFTS,
|
||||
Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_DRAFTS), false);
|
||||
|
||||
// Outbox -- # of sent messages
|
||||
addSummaryMailboxRow(context, cursor,
|
||||
Mailbox.QUERY_ALL_OUTBOX, Mailbox.TYPE_OUTBOX,
|
||||
Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_OUTBOX), false);
|
||||
}
|
||||
// Outbox -- # of sent messages
|
||||
addSummaryMailboxRow(context, cursor,
|
||||
Mailbox.QUERY_ALL_OUTBOX, Mailbox.TYPE_OUTBOX,
|
||||
Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_OUTBOX), false);
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
@ -303,6 +377,7 @@ import java.security.InvalidParameterException;
|
|||
row.add(type);
|
||||
row.add(count);
|
||||
row.add(count);
|
||||
row.add(ROW_TYPE_MAILBOX);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -339,6 +339,12 @@ public class MessageListXL extends Activity implements
|
|||
public void onMailboxSelected(long accountId, long mailboxId) {
|
||||
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 {
|
||||
|
@ -464,6 +470,13 @@ public class MessageListXL extends Activity implements
|
|||
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() {
|
||||
getLoaderManager().initLoader(LOADER_ID_ACCOUNT_LIST, null, new LoaderCallbacks<Cursor>() {
|
||||
@Override
|
||||
|
@ -511,10 +524,8 @@ public class MessageListXL extends Activity implements
|
|||
|
||||
// Update the dropdown list.
|
||||
mAccountsSelectorAdapter.changeCursor(accountsCursor);
|
||||
if (ab.getNavigationMode() != ActionBar.NAVIGATION_MODE_DROPDOWN_LIST) {
|
||||
ab.setDropdownNavigationMode(mAccountsSelectorAdapter,
|
||||
mActionBarNavigationCallback, defaultSelection);
|
||||
}
|
||||
ab.setDropdownNavigationMode(mAccountsSelectorAdapter,
|
||||
mActionBarNavigationCallback, defaultSelection);
|
||||
}
|
||||
|
||||
private class ActionBarNavigationCallback implements ActionBar.NavigationCallback {
|
||||
|
|
|
@ -18,6 +18,7 @@ package com.android.email.activity;
|
|||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.R;
|
||||
import com.android.email.provider.EmailContent.Account;
|
||||
import com.android.email.provider.EmailContent.Mailbox;
|
||||
|
||||
import android.app.Fragment;
|
||||
|
@ -289,7 +290,10 @@ class MessageListXLFragmentManager {
|
|||
mMessageListFragment.clearContent();
|
||||
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();
|
||||
} else {
|
||||
selectMailbox(mailboxId, byExplicitUserAction);
|
||||
|
|
|
@ -825,8 +825,6 @@ public abstract class EmailContent {
|
|||
|
||||
/**
|
||||
* @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) {
|
||||
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 =
|
||||
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_VIBRATE_ALWAYS = 2;
|
||||
public static final int FLAGS_DELETE_POLICY_MASK = 4+8;
|
||||
|
|
|
@ -69,7 +69,7 @@ public class MailboxesAdapterTest extends ProviderTestCase2<EmailProvider> {
|
|||
createMessage(c, b2d, false, true);
|
||||
|
||||
// Kick the method
|
||||
Cursor cursor = MailboxesAdapter.getSpecialMailboxesCursor(c, true);
|
||||
Cursor cursor = MailboxesAdapter.getSpecialMailboxesCursor(c);
|
||||
|
||||
// Check the result
|
||||
assertEquals(4, cursor.getCount());
|
||||
|
|
Loading…
Reference in New Issue