Add recent header if there are zero recent items

For the one pane view, it's possible that an account has zero items in the
recent list (this is only possible for accounts that do not have neither
a "drafts" nor a "sent" folder). In such situations, we will still want to
have some header to distinguish between the accounts and the "show all
folders" item.

Change-Id: Ic5d6368b88ba4a28904c3b78a6489d06345a901e
diff --git a/src/com/android/email/activity/AccountSelectorAdapter.java b/src/com/android/email/activity/AccountSelectorAdapter.java
index e2d88bc..4607678 100644
--- a/src/com/android/email/activity/AccountSelectorAdapter.java
+++ b/src/com/android/email/activity/AccountSelectorAdapter.java
@@ -162,7 +162,9 @@
                 emailAddressView.setText(emailAddress);
             }
 
-            if (isAccountItem(position) || getAccountId(c) != Mailbox.NO_MAILBOX) {
+            boolean isAccount = isAccountItem(position);
+            long id = getAccountId(c);
+            if (isAccount || id != Mailbox.NO_MAILBOX) {
                 unreadCountView.setVisibility(View.VISIBLE);
                 unreadCountView.setText(UiUtilities.getMessageCountForUi(mContext,
                         getAccountUnreadCount(position), false));
@@ -350,8 +352,9 @@
                 // Do not display recent mailboxes in the account spinner for the two pane view
                 recentMailboxes = mailboxManager.getMostRecent(mAccountId, useTwoPane);
             }
-            if (recentMailboxes != null && recentMailboxes.size() > 0) {
-                matrixCursor.mRecentCount = recentMailboxes.size();
+            int recentCount = (recentMailboxes == null) ? 0 : recentMailboxes.size();
+            matrixCursor.mRecentCount = recentCount;
+            if (recentCount > 0) {
                 String mailboxHeader = mContext.getString(
                     R.string.mailbox_list_account_selector_mailbox_header_fmt, emailAddress);
                 addRow(matrixCursor, ROW_TYPE_HEADER, 0L, mailboxHeader, null, 0, UNKNOWN_POSITION);
@@ -363,6 +366,11 @@
                     addRow(matrixCursor, ROW_TYPE_MAILBOX, mailboxId, mailbox.mDisplayName, null,
                             unread, accountPosition);
                 }
+            } else if (!useTwoPane) {
+                // Add the header for 'show all folders'
+                String mailboxHeader = mContext.getString(
+                    R.string.mailbox_list_account_selector_mailbox_header_fmt, emailAddress);
+                addRow(matrixCursor, ROW_TYPE_HEADER, 0L, mailboxHeader, null, 0, UNKNOWN_POSITION);
             }
             if (!useTwoPane) {
                 String name = mContext.getString(