Merge "Don't show starred mailbox, if account has no starred" into honeycomb
This commit is contained in:
commit
e5d9691ec5
@ -350,6 +350,7 @@ import android.widget.TextView;
|
||||
private static class MailboxesLoader extends ThrottlingCursorLoader {
|
||||
private final Context mContext;
|
||||
private final int mMode;
|
||||
private final long mAccountId;
|
||||
|
||||
private static String getSelection(int mode) {
|
||||
if (mode == MODE_MOVE_TO_TARGET) {
|
||||
@ -365,6 +366,7 @@ import android.widget.TextView;
|
||||
new String[] { String.valueOf(accountId) }, MAILBOX_ORDER_BY);
|
||||
mContext = context;
|
||||
mMode = mode;
|
||||
mAccountId = accountId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -381,10 +383,10 @@ import android.widget.TextView;
|
||||
return Utility.CloseTraceCursorWrapper.get(mailboxesCursor);
|
||||
}
|
||||
|
||||
// Add "Starred".
|
||||
// Add "Starred", only if the account has at least one starred message.
|
||||
// TODO It's currently "combined starred", but the plan is to make it per-account
|
||||
// starred.
|
||||
final int starredCount = Message.getFavoriteMessageCount(mContext);
|
||||
final int starredCount = Message.getFavoriteMessageCount(mContext, mAccountId);
|
||||
if (starredCount == 0) {
|
||||
return Utility.CloseTraceCursorWrapper.get(mailboxesCursor); // no starred message
|
||||
}
|
||||
|
@ -544,6 +544,9 @@ public abstract class EmailContent {
|
||||
private static final String FAVORITE_COUNT_SELECTION =
|
||||
MessageColumns.FLAG_FAVORITE + "= 1";
|
||||
|
||||
private static final String ACCOUNT_FAVORITE_COUNT_SELECTION =
|
||||
MessageColumns.FLAG_FAVORITE + "= 1 AND " + MessageColumns.ACCOUNT_KEY + "=?";
|
||||
|
||||
private static final String ACCOUNT_KEY_SELECTION =
|
||||
MessageColumns.ACCOUNT_KEY + "=?";
|
||||
|
||||
@ -858,6 +861,14 @@ public abstract class EmailContent {
|
||||
return count(context, Message.CONTENT_URI, FAVORITE_COUNT_SELECTION, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of favorite (starred) messages for an account
|
||||
*/
|
||||
public static int getFavoriteMessageCount(Context context, long accountId) {
|
||||
return count(context, Message.CONTENT_URI, ACCOUNT_FAVORITE_COUNT_SELECTION,
|
||||
new String[]{Long.toString(accountId)});
|
||||
}
|
||||
|
||||
public static long getKeyColumnLong(Context context, long messageId, String column) {
|
||||
String[] columns =
|
||||
Utility.getRowColumns(context, Message.CONTENT_URI, messageId, column);
|
||||
|
@ -1914,6 +1914,7 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
* - {@link Mailbox#getUnreadCountByAccountAndMailboxType(Context, long, int)}
|
||||
* - {@link Mailbox#getUnreadCountByMailboxType(Context, int)}
|
||||
* - {@link Message#getFavoriteMessageCount(Context)}
|
||||
* - {@link Message#getFavoriteMessageCount(Context, long)}
|
||||
*/
|
||||
public void testMessageCount() {
|
||||
final Context c = mMockContext;
|
||||
@ -1936,6 +1937,8 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
assertEquals(0, getMessageCount(b4.mId));
|
||||
|
||||
assertEquals(0, Message.getFavoriteMessageCount(c));
|
||||
assertEquals(0, Message.getFavoriteMessageCount(c, a1.mId));
|
||||
assertEquals(0, Message.getFavoriteMessageCount(c, a2.mId));
|
||||
assertEquals(0, Mailbox.getUnreadCountByMailboxType(c, Mailbox.TYPE_INBOX));
|
||||
assertEquals(0, Mailbox.getUnreadCountByMailboxType(c, Mailbox.TYPE_OUTBOX));
|
||||
assertEquals(0, Mailbox.getMessageCountByMailboxType(c, Mailbox.TYPE_INBOX));
|
||||
@ -1953,14 +1956,14 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
// 1. Test for insert triggers.
|
||||
|
||||
// Create some messages
|
||||
// b1 (account 1, inbox): 1 message
|
||||
// b1 (account 1, inbox): 1 message, including 1 starred
|
||||
Message m11 = createMessage(c, b1, true, false);
|
||||
|
||||
// b2 (account 1, outbox): 2 message
|
||||
// b2 (account 1, outbox): 2 message, including 1 starred
|
||||
Message m21 = createMessage(c, b2, false, false);
|
||||
Message m22 = createMessage(c, b2, true, true);
|
||||
|
||||
// b3 (account 2, inbox): 3 message
|
||||
// b3 (account 2, inbox): 3 message, including 1 starred
|
||||
Message m31 = createMessage(c, b3, false, false);
|
||||
Message m32 = createMessage(c, b3, false, false);
|
||||
Message m33 = createMessage(c, b3, true, true);
|
||||
@ -1975,6 +1978,8 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
|
||||
// Check the simple counting methods.
|
||||
assertEquals(3, Message.getFavoriteMessageCount(c));
|
||||
assertEquals(2, Message.getFavoriteMessageCount(c, a1.mId));
|
||||
assertEquals(1, Message.getFavoriteMessageCount(c, a2.mId));
|
||||
assertEquals(3, Mailbox.getUnreadCountByMailboxType(c, Mailbox.TYPE_INBOX));
|
||||
assertEquals(1, Mailbox.getUnreadCountByMailboxType(c, Mailbox.TYPE_OUTBOX));
|
||||
assertEquals(4, Mailbox.getMessageCountByMailboxType(c, Mailbox.TYPE_INBOX));
|
||||
|
Loading…
Reference in New Issue
Block a user