From 9630e31bac9232528ab9a25d7fcc96fda647f165 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Thu, 30 Jun 2011 18:00:11 -0700 Subject: [PATCH] Fix bug 4901592 Do not drill-in to inbox by default If the initial mailbox has child mailboxes, we should show the drilled-in view by default, EXCEPT if the initial mailbox is inbox, in which case we want to show the root view. (And we drill-in if the user taps Inbox.) Bug 4901592 Change-Id: Idc1462030cf8d971dd4dcbba647ac3a64cab6819 --- .../email/activity/MailboxListFragment.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/com/android/email/activity/MailboxListFragment.java b/src/com/android/email/activity/MailboxListFragment.java index 22fb44256..a7b828db0 100644 --- a/src/com/android/email/activity/MailboxListFragment.java +++ b/src/com/android/email/activity/MailboxListFragment.java @@ -391,17 +391,28 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList * Set {@link #mParentMailboxId} and {@link #mHighlightedMailboxId} from the fragment arguments. */ private void setInitialParentAndHighlight() { + final long initialMailboxId = getInitialCurrentMailboxId(); if (getAccountId() == Account.ACCOUNT_ID_COMBINED_VIEW) { // For the combined view, always show the top-level, but highlight the "current". mParentMailboxId = Mailbox.NO_MAILBOX; } else { - // Otherwise, try using the "current" as the "parent" (and also highlight it). - // If it has no children, we go up in onLoadFinished(). - mParentMailboxId = getInitialCurrentMailboxId(); + // Inbox needs special care. + // Note we can't get the mailbox type on the UI thread but this method *can* be used... + final long inboxId = Mailbox.findMailboxOfType(getActivity(), getAccountId(), + Mailbox.TYPE_INBOX); + if (initialMailboxId == inboxId) { + // If Inbox is set as the initial current, we show the top level mailboxes + // with inbox highlighted. + mParentMailboxId = Mailbox.NO_MAILBOX; + } else { + // Otherwise, try using the "current" as the "parent" (and also highlight it). + // If it has no children, we go up in onLoadFinished(). + mParentMailboxId = initialMailboxId; + } } // Highlight the mailbox of interest if (getEnableHighlight()) { - mHighlightedMailboxId = getInitialCurrentMailboxId(); + mHighlightedMailboxId = initialMailboxId; } }