Merge "Remove MailboxListFragment.DEFAULT_MAILBOX_ID"
This commit is contained in:
commit
0ea4f9295a
@ -174,14 +174,7 @@ import android.widget.TextView;
|
|||||||
Log.d(Logging.LOG_TAG, "MailboxFragmentAdapter#createLoader accountId=" + accountId);
|
Log.d(Logging.LOG_TAG, "MailboxFragmentAdapter#createLoader accountId=" + accountId);
|
||||||
}
|
}
|
||||||
if (accountId != Account.ACCOUNT_ID_COMBINED_VIEW) {
|
if (accountId != Account.ACCOUNT_ID_COMBINED_VIEW) {
|
||||||
// STOPSHIP remove test when legacy protocols support folders; the parent key
|
return new MailboxFragmentLoader(context, accountId, parentKey);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return new CombinedMailboxLoader(context);
|
return new CombinedMailboxLoader(context);
|
||||||
}
|
}
|
||||||
@ -226,21 +219,11 @@ import android.widget.TextView;
|
|||||||
private final long mAccountId;
|
private final long mAccountId;
|
||||||
private final long mParentKey;
|
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) {
|
MailboxFragmentLoader(Context context, long accountId, long parentKey) {
|
||||||
super(context, EmailContent.Mailbox.CONTENT_URI,
|
super(context, EmailContent.Mailbox.CONTENT_URI,
|
||||||
(parentKey > 0) ? MailboxesAdapter.SUBMAILBOX_PROJECTION
|
(parentKey != Mailbox.PARENT_KEY_NONE)
|
||||||
: MailboxesAdapter.PROJECTION,
|
? MailboxesAdapter.SUBMAILBOX_PROJECTION
|
||||||
|
: MailboxesAdapter.PROJECTION,
|
||||||
MAILBOX_SELECTION_WITH_PARENT,
|
MAILBOX_SELECTION_WITH_PARENT,
|
||||||
new String[] { Long.toString(accountId), Long.toString(parentKey) },
|
new String[] { Long.toString(accountId), Long.toString(parentKey) },
|
||||||
MAILBOX_ORDER_BY);
|
MAILBOX_ORDER_BY);
|
||||||
@ -260,24 +243,14 @@ import android.widget.TextView;
|
|||||||
public Cursor loadInBackground() {
|
public Cursor loadInBackground() {
|
||||||
final Cursor childMailboxCursor = super.loadInBackground();
|
final Cursor childMailboxCursor = super.loadInBackground();
|
||||||
|
|
||||||
// Add "up" item if we are not viewing the top-level list
|
// If we're not showing the top level mailboxes, add the "parent" mailbox.
|
||||||
if (mParentKey > 0) {
|
if (mParentKey != Mailbox.PARENT_KEY_NONE) {
|
||||||
// STOPSHIP Remove this commented block of code if truly not wanted by UX
|
final Cursor parentCursor = getContext().getContentResolver().query(
|
||||||
// // Find the parent's parent ...
|
Mailbox.CONTENT_URI, CURMAILBOX_PROJECTION, MAILBOX_SELECTION,
|
||||||
// Long superParentKey = Utility.getFirstRowLong(getContext(), Mailbox.CONTENT_URI,
|
new String[] { Long.toString(mAccountId), Long.toString(mParentKey) },
|
||||||
// new String[] { MailboxColumns.PARENT_KEY }, MailboxColumns.ID + "=?",
|
null);
|
||||||
// new String[] { Long.toString(mParentKey) }, null, 0);
|
return Utility.CloseTraceCursorWrapper.get(new MergeCursor(
|
||||||
Long superParentKey = Mailbox.PARENT_KEY_NONE;
|
new Cursor[] { parentCursor, childMailboxCursor }));
|
||||||
|
|
||||||
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 }));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add "Starred", only if the account has at least one starred message.
|
// Add "Starred", only if the account has at least one starred message.
|
||||||
|
@ -82,13 +82,6 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
|
|||||||
private static final String ARG_ACCOUNT_ID = "accountId";
|
private static final String ARG_ACCOUNT_ID = "accountId";
|
||||||
private static final String ARG_PARENT_MAILBOX_ID = "parentMailboxId";
|
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 */
|
/** Timer to auto-expand folder lists during drag-n-drop */
|
||||||
private static final Timer sDragTimer = new Timer();
|
private static final Timer sDragTimer = new Timer();
|
||||||
/** Rectangle used for hit testing children */
|
/** Rectangle used for hit testing children */
|
||||||
@ -110,7 +103,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
|
|||||||
private static Drawable sDropActiveDrawable;
|
private static Drawable sDropActiveDrawable;
|
||||||
|
|
||||||
private long mAccountId = -1;
|
private long mAccountId = -1;
|
||||||
private long mParentMailboxId = DEFAULT_MAILBOX_ID;
|
private long mParentMailboxId = Mailbox.PARENT_KEY_NONE;
|
||||||
private long mSelectedMailboxId = -1;
|
private long mSelectedMailboxId = -1;
|
||||||
|
|
||||||
// True if a drag is currently in progress
|
// 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
|
* The ID of the account for which a mailbox was selected
|
||||||
* @param mailboxId
|
* @param mailboxId
|
||||||
* The ID of the selected mailbox. This may be real mailbox ID [e.g. a number > 0],
|
* The ID of the selected mailbox. This may be real mailbox ID [e.g. a number > 0],
|
||||||
* or a special mailbox ID
|
* or a combined mailbox ID [e.g. {@link Mailbox#QUERY_ALL_INBOXES}].
|
||||||
* [e.g. {@link #ROOT_PARENT_MAILBOX_ID} for "All Folders" to open
|
|
||||||
* the root folders, {@link Mailbox#QUERY_ALL_INBOXES}, etc...].
|
|
||||||
* @param navigate navigate to the mailbox.
|
* @param navigate navigate to the mailbox.
|
||||||
* @param dragDrop true if D&D is in progress.
|
* @param dragDrop true if D&D is in progress.
|
||||||
*/
|
*/
|
||||||
@ -290,10 +281,6 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
|
|||||||
if (accountId == -1) {
|
if (accountId == -1) {
|
||||||
throw new InvalidParameterException();
|
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;
|
mAccountId = accountId;
|
||||||
mParentMailboxId = parentMailboxId;
|
mParentMailboxId = parentMailboxId;
|
||||||
|
@ -110,10 +110,6 @@ import android.widget.CursorAdapter;
|
|||||||
/** All mailboxes for the account */
|
/** All mailboxes for the account */
|
||||||
/*package*/ static final String ALL_MAILBOX_SELECTION = MailboxColumns.ACCOUNT_KEY + "=?" +
|
/*package*/ static final String ALL_MAILBOX_SELECTION = MailboxColumns.ACCOUNT_KEY + "=?" +
|
||||||
" AND " + Mailbox.USER_VISIBLE_MAILBOX_SELECTION;
|
" 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 */
|
/** All mailboxes with the given parent */
|
||||||
/*package*/ static final String MAILBOX_SELECTION_WITH_PARENT = ALL_MAILBOX_SELECTION +
|
/*package*/ static final String MAILBOX_SELECTION_WITH_PARENT = ALL_MAILBOX_SELECTION +
|
||||||
" AND " + MailboxColumns.PARENT_KEY + "=?";
|
" AND " + MailboxColumns.PARENT_KEY + "=?";
|
||||||
|
Loading…
Reference in New Issue
Block a user