Display full pathname in move-to dialog
With the recent changes to hierarchical folders, the move-to dialog is quite unusable if you have multiple child folders with the same name. While waiting for UX to decide on the exact display, make a few quick changes to display the fully-qualified pathname instead of just the child folder name. Change-Id: Id5c1cc98364fbf7a82a05ac30e944507c7d16320
This commit is contained in:
parent
1f1a056c6d
commit
27cf8b5ffe
|
@ -2315,9 +2315,6 @@ public abstract class EmailContent {
|
|||
private static final String WHERE_TYPE_AND_ACCOUNT_KEY =
|
||||
MailboxColumns.TYPE + "=? and " + MailboxColumns.ACCOUNT_KEY + "=?";
|
||||
|
||||
public static final String MOVE_TO_TARGET_MAILBOX_SELECTION =
|
||||
MailboxColumns.TYPE + " NOT IN (" + Mailbox.TYPE_DRAFTS + "," +
|
||||
Mailbox.TYPE_OUTBOX + "," + Mailbox.TYPE_SENT + "," + Mailbox.TYPE_TRASH + ")";
|
||||
public static final Integer[] INVALID_DROP_TARGETS = new Integer[] {Mailbox.TYPE_DRAFTS,
|
||||
Mailbox.TYPE_OUTBOX, Mailbox.TYPE_SENT};
|
||||
|
||||
|
|
|
@ -17,35 +17,69 @@
|
|||
package com.android.email.activity;
|
||||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.FolderProperties;
|
||||
import com.android.email.data.ThrottlingCursorLoader;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Mailbox;
|
||||
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Loader;
|
||||
import android.database.Cursor;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CursorAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* Cursor adapter for the "move to mailbox" dialog.
|
||||
* TODO We've detached this class from {@link MailboxesAdapter} and {@link MailboxFragmentAdapter}.
|
||||
* Depending upon the UX for the dialog and nested folders, we may want to bring these three
|
||||
* adapter classes back into alignment.
|
||||
*/
|
||||
/*package*/ class MailboxMoveToAdapter extends MailboxesAdapter {
|
||||
private static final String MAILBOX_SELECTION_MOVE_TO_FOLDER =
|
||||
ALL_MAILBOX_SELECTION + " AND " + Mailbox.MOVE_TO_TARGET_MAILBOX_SELECTION;
|
||||
class MailboxMoveToAdapter extends CursorAdapter {
|
||||
private static final String ALL_MAILBOX_SELECTION = MailboxColumns.ACCOUNT_KEY + "=?" +
|
||||
" AND " + Mailbox.USER_VISIBLE_MAILBOX_SELECTION;
|
||||
private static final String MOVE_TO_TARGET_MAILBOX_SELECTION =
|
||||
MailboxColumns.TYPE + " NOT IN (" + Mailbox.TYPE_DRAFTS + "," +
|
||||
Mailbox.TYPE_OUTBOX + "," + Mailbox.TYPE_SENT + "," + Mailbox.TYPE_TRASH + ")";
|
||||
/** The main selection to populate the "move to" dialog */
|
||||
private static final String MOVE_TO_SELECTION =
|
||||
ALL_MAILBOX_SELECTION + " AND " + MOVE_TO_TARGET_MAILBOX_SELECTION;
|
||||
/** Field projection for the "move to" dialog */
|
||||
private static final String[] MOVE_TO_PROJECTION = new String[] { MailboxColumns.ID,
|
||||
MailboxColumns.ID + " AS org_mailbox_id",
|
||||
MailboxColumns.SERVER_ID,
|
||||
MailboxColumns.TYPE,
|
||||
};
|
||||
private static final String MOVE_TO_ORDER_BY = "CASE " + MailboxColumns.TYPE +
|
||||
" WHEN " + Mailbox.TYPE_INBOX + " THEN 0" +
|
||||
" WHEN " + Mailbox.TYPE_JUNK + " THEN 1" +
|
||||
// All other mailboxes are shown in alphabetical order.
|
||||
" ELSE 10 END" +
|
||||
" ," + MailboxColumns.DISPLAY_NAME;
|
||||
|
||||
public MailboxMoveToAdapter(Context context, Callback callback) {
|
||||
super(context, callback);
|
||||
// Column 0 is only for ListView; we don't use it in our code.
|
||||
private static final int COLUMN_ID = 1;
|
||||
private static final int COLUMN_SERVER_ID = 2;
|
||||
private static final int COLUMN_TYPE = 3;
|
||||
|
||||
/** Cached layout inflater */
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
public MailboxMoveToAdapter(Context context) {
|
||||
super(context, null, 0 /* flags; no content observer */);
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(View view, Context context, Cursor cursor) {
|
||||
TextView t = (TextView) view;
|
||||
t.setText(getDisplayName(context, cursor));
|
||||
t.setText(getDisplayText(context, cursor));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +87,7 @@ import android.widget.TextView;
|
|||
return mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
|
||||
}
|
||||
|
||||
public static Loader<Cursor> createLoader(Context context, long accountId) {
|
||||
static Loader<Cursor> createLoader(Context context, long accountId) {
|
||||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
Log.d(Logging.LOG_TAG, "MailboxDialogAdapter#createLoader accountId=" + accountId);
|
||||
}
|
||||
|
@ -61,20 +95,26 @@ import android.widget.TextView;
|
|||
}
|
||||
|
||||
/**
|
||||
* Loader for the "move to mailbox" dialog.
|
||||
* Returns the mailbox name to display in the dialog list. If the mailbox is of
|
||||
* certain, well known, types, use a predefined name. Otherwise, use the server
|
||||
* provided name.
|
||||
*/
|
||||
private static String getDisplayText(Context context, Cursor cursor) {
|
||||
final int type = cursor.getInt(COLUMN_TYPE);
|
||||
final long mailboxId = cursor.getLong(COLUMN_ID);
|
||||
String name = FolderProperties.getInstance(context).getDisplayName(type, mailboxId);
|
||||
if (name == null) {
|
||||
name = cursor.getString(COLUMN_SERVER_ID);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/** Loader for the "move to mailbox" dialog. */
|
||||
private static class MailboxMoveToLoader extends ThrottlingCursorLoader {
|
||||
public MailboxMoveToLoader(Context context, long accountId) {
|
||||
super(context, EmailContent.Mailbox.CONTENT_URI,
|
||||
MailboxesAdapter.PROJECTION, MAILBOX_SELECTION_MOVE_TO_FOLDER,
|
||||
new String[] { String.valueOf(accountId) }, MAILBOX_ORDER_BY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContentChanged() {
|
||||
if (sEnableUpdate) {
|
||||
super.onContentChanged();
|
||||
}
|
||||
MOVE_TO_PROJECTION, MOVE_TO_SELECTION,
|
||||
new String[] { String.valueOf(accountId) }, MOVE_TO_ORDER_BY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public class MoveMessageToDialog extends DialogFragment implements DialogInterfa
|
|||
|
||||
/** Message IDs passed to {@link #newInstance} */
|
||||
private long[] mMessageIds;
|
||||
private MailboxesAdapter mAdapter;
|
||||
private MailboxMoveToAdapter mAdapter;
|
||||
|
||||
/** Account ID is restored by {@link MailboxesLoaderCallbacks} */
|
||||
private long mAccountId;
|
||||
|
@ -107,7 +107,7 @@ public class MoveMessageToDialog extends DialogFragment implements DialogInterfa
|
|||
AlertDialog.Builder builder = new AlertDialog.Builder(activity)
|
||||
.setTitle(activity.getResources().getString(R.string.move_to_folder_dialog_title));
|
||||
|
||||
mAdapter = new MailboxMoveToAdapter(builder.getContext(), null);
|
||||
mAdapter = new MailboxMoveToAdapter(builder.getContext());
|
||||
builder.setSingleChoiceItems(mAdapter, -1, this);
|
||||
|
||||
getLoaderManager().initLoader(
|
||||
|
|
Loading…
Reference in New Issue