Merge "Don't show color chips when there's only one account"

This commit is contained in:
Makoto Onuki 2010-11-24 10:48:10 -08:00 committed by Android (Google) Code Review
commit 2e1c3eaaf1
2 changed files with 11 additions and 3 deletions

View File

@ -121,6 +121,7 @@ public class MessageListFragment extends ListFragment
private Mailbox mMailbox;
private boolean mIsEasAccount;
private boolean mIsRefreshable;
private int mCountTotalAccounts;
// Controller access
private Controller mController;
@ -1033,6 +1034,7 @@ public class MessageListFragment extends ListFragment
mMailbox = result.mMailbox;
mIsEasAccount = result.mIsEasAccount;
mIsRefreshable = result.mIsRefreshable;
mCountTotalAccounts = result.mCountTotalAccounts;
getLoaderManager().initLoader(LOADER_ID_MESSAGES_LOADER, null,
new MessagesLoaderCallback(mMailboxChanging));
@ -1089,7 +1091,8 @@ public class MessageListFragment extends ListFragment
// Update the list
mListAdapter.changeCursor(cursor);
mListAdapter.setShowColorChips(mMailboxId < 0); // Show chips if combined view
// Show chips if combined view.
mListAdapter.setShowColorChips(mMailboxId < 0 && mCountTotalAccounts > 1);
setListAdapter(mListAdapter);
setListShown(true);

View File

@ -16,6 +16,7 @@
package com.android.email.data;
import com.android.email.provider.EmailContent;
import com.android.email.provider.EmailContent.Account;
import com.android.email.provider.EmailContent.Mailbox;
@ -35,14 +36,16 @@ public class MailboxAccountLoader extends AsyncTaskLoader<MailboxAccountLoader.R
public final Mailbox mMailbox;
public final boolean mIsEasAccount;
public final boolean mIsRefreshable;
public final int mCountTotalAccounts;
private Result(boolean found, Account account, Mailbox mailbox, boolean isEasAccount,
boolean isRefreshable) {
boolean isRefreshable, int countTotalAccounts) {
mIsFound = found;
mAccount = account;
mMailbox = mailbox;
mIsEasAccount = isEasAccount;
mIsRefreshable = isRefreshable;
mCountTotalAccounts = countTotalAccounts;
}
}
@ -82,7 +85,9 @@ public class MailboxAccountLoader extends AsyncTaskLoader<MailboxAccountLoader.R
}
}
}
Result result = new Result(found, account, mailbox, isEasAccount, isRefreshable);
final int countAccounts = EmailContent.count(mContext, Account.CONTENT_URI);
Result result = new Result(found, account, mailbox, isEasAccount, isRefreshable,
countAccounts);
return result;
}