diff --git a/src/com/android/email/activity/MailboxFragmentAdapter.java b/src/com/android/email/activity/MailboxFragmentAdapter.java index b6a11c395..ce76983eb 100644 --- a/src/com/android/email/activity/MailboxFragmentAdapter.java +++ b/src/com/android/email/activity/MailboxFragmentAdapter.java @@ -174,14 +174,7 @@ import android.widget.TextView; Log.d(Logging.LOG_TAG, "MailboxFragmentAdapter#createLoader accountId=" + accountId); } if (accountId != Account.ACCOUNT_ID_COMBINED_VIEW) { - // STOPSHIP remove test when legacy protocols support folders; the parent key - // should never equal '0' - if (parentKey == 0) { - // load all mailboxes at the top level - return new MailboxFragmentLoader(context, accountId); - } else { - return new MailboxFragmentLoader(context, accountId, parentKey); - } + return new MailboxFragmentLoader(context, accountId, parentKey); } else { return new CombinedMailboxLoader(context); } @@ -226,21 +219,11 @@ import android.widget.TextView; private final long mAccountId; private final long mParentKey; - // STOPSHIP remove when legacy protocols support folders; parent key must always be set - MailboxFragmentLoader(Context context, long accountId) { - super(context, EmailContent.Mailbox.CONTENT_URI, - MailboxesAdapter.PROJECTION, MAILBOX_SELECTION_NO_PARENT, - new String[] { Long.toString(accountId) }, - MAILBOX_ORDER_BY); - mContext = context; - mAccountId = accountId; - mParentKey = 0; - } - MailboxFragmentLoader(Context context, long accountId, long parentKey) { super(context, EmailContent.Mailbox.CONTENT_URI, - (parentKey > 0) ? MailboxesAdapter.SUBMAILBOX_PROJECTION - : MailboxesAdapter.PROJECTION, + (parentKey != Mailbox.PARENT_KEY_NONE) + ? MailboxesAdapter.SUBMAILBOX_PROJECTION + : MailboxesAdapter.PROJECTION, MAILBOX_SELECTION_WITH_PARENT, new String[] { Long.toString(accountId), Long.toString(parentKey) }, MAILBOX_ORDER_BY); @@ -260,24 +243,14 @@ import android.widget.TextView; public Cursor loadInBackground() { final Cursor childMailboxCursor = super.loadInBackground(); - // Add "up" item if we are not viewing the top-level list - if (mParentKey > 0) { - // STOPSHIP Remove this commented block of code if truly not wanted by UX -// // Find the parent's parent ... -// Long superParentKey = Utility.getFirstRowLong(getContext(), Mailbox.CONTENT_URI, -// new String[] { MailboxColumns.PARENT_KEY }, MailboxColumns.ID + "=?", -// new String[] { Long.toString(mParentKey) }, null, 0); - Long superParentKey = Mailbox.PARENT_KEY_NONE; - - if (superParentKey != null) { - final Cursor parentCursor = getContext().getContentResolver().query( - Mailbox.CONTENT_URI, CURMAILBOX_PROJECTION, MAILBOX_SELECTION, - new String[] { Long.toString(mAccountId), Long.toString(mParentKey) }, - null); - final MatrixCursor extraCursor = new MatrixCursor(getProjection()); - return Utility.CloseTraceCursorWrapper.get(new MergeCursor( - new Cursor[] { extraCursor, parentCursor, childMailboxCursor })); - } + // If we're not showing the top level mailboxes, add the "parent" mailbox. + if (mParentKey != Mailbox.PARENT_KEY_NONE) { + final Cursor parentCursor = getContext().getContentResolver().query( + Mailbox.CONTENT_URI, CURMAILBOX_PROJECTION, MAILBOX_SELECTION, + new String[] { Long.toString(mAccountId), Long.toString(mParentKey) }, + null); + return Utility.CloseTraceCursorWrapper.get(new MergeCursor( + new Cursor[] { parentCursor, childMailboxCursor })); } // Add "Starred", only if the account has at least one starred message. diff --git a/src/com/android/email/activity/MailboxListFragment.java b/src/com/android/email/activity/MailboxListFragment.java index 9a14b9db7..7450e1e29 100644 --- a/src/com/android/email/activity/MailboxListFragment.java +++ b/src/com/android/email/activity/MailboxListFragment.java @@ -82,13 +82,6 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList private static final String ARG_ACCOUNT_ID = "accountId"; private static final String ARG_PARENT_MAILBOX_ID = "parentMailboxId"; - // TODO Clean up usage of mailbox ID. We use both '-1' and '0' to mean "not selected". To - // confuse matters, the database uses '-1' for "no mailbox" and '0' for "invalid mailbox". - // Once legacy accounts properly support nested folders, we need to make sure we're only - // ever using '-1'. - // STOPSHIP Change value to '-1' when legacy protocols support folders - private final static long DEFAULT_MAILBOX_ID = 0; - /** Timer to auto-expand folder lists during drag-n-drop */ private static final Timer sDragTimer = new Timer(); /** Rectangle used for hit testing children */ @@ -110,7 +103,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList private static Drawable sDropActiveDrawable; private long mAccountId = -1; - private long mParentMailboxId = DEFAULT_MAILBOX_ID; + private long mParentMailboxId = Mailbox.PARENT_KEY_NONE; private long mSelectedMailboxId = -1; // True if a drag is currently in progress @@ -154,9 +147,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList * The ID of the account for which a mailbox was selected * @param mailboxId * The ID of the selected mailbox. This may be real mailbox ID [e.g. a number > 0], - * or a special mailbox ID - * [e.g. {@link #ROOT_PARENT_MAILBOX_ID} for "All Folders" to open - * the root folders, {@link Mailbox#QUERY_ALL_INBOXES}, etc...]. + * or a combined mailbox ID [e.g. {@link Mailbox#QUERY_ALL_INBOXES}]. * @param navigate navigate to the mailbox. * @param dragDrop true if D&D is in progress. */ @@ -290,10 +281,6 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList if (accountId == -1) { throw new InvalidParameterException(); } - // Normalize -- STOPSHIP should be removed when DEFAULT_MAILBOX_ID becomes -1. - if (parentMailboxId == Mailbox.PARENT_KEY_NONE) { - parentMailboxId = DEFAULT_MAILBOX_ID; - } mAccountId = accountId; mParentMailboxId = parentMailboxId; diff --git a/src/com/android/email/activity/MailboxesAdapter.java b/src/com/android/email/activity/MailboxesAdapter.java index a910f1b7b..eab72b875 100644 --- a/src/com/android/email/activity/MailboxesAdapter.java +++ b/src/com/android/email/activity/MailboxesAdapter.java @@ -110,10 +110,6 @@ import android.widget.CursorAdapter; /** All mailboxes for the account */ /*package*/ static final String ALL_MAILBOX_SELECTION = MailboxColumns.ACCOUNT_KEY + "=?" + " AND " + Mailbox.USER_VISIBLE_MAILBOX_SELECTION; - // STOPSHIP This can be removed when legacy protocols support folders - /** All top-level mailboxes */ - /*package*/ static final String MAILBOX_SELECTION_NO_PARENT = ALL_MAILBOX_SELECTION + - " AND " + MailboxColumns.PARENT_KEY + "<=0"; /** All mailboxes with the given parent */ /*package*/ static final String MAILBOX_SELECTION_WITH_PARENT = ALL_MAILBOX_SELECTION + " AND " + MailboxColumns.PARENT_KEY + "=?";