Open the destination dir when a copy notification is tapped.
- Cleanup: rename the "open copy destination" action to "pick copy destination", which better reflects what it does. - Move DocumentsIntent from BaseActivity to Shared. - Rename ACTION_BROWSE_DOCUMENT_ROOT to ACTION_BROWSE for general browsing. - Use the new ACTION_BROWSE to open the copy destination when copy notifications are tapped. BUG=23137963 Change-Id: I10480b45a16ce716febac5453cb5015d26bb0062
This commit is contained in:
@@ -435,7 +435,7 @@ public class VolumeInfo implements Parcelable {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Intent intent = new Intent(DocumentsContract.ACTION_BROWSE_DOCUMENT_ROOT);
|
||||
final Intent intent = new Intent(DocumentsContract.ACTION_BROWSE);
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
intent.setData(uri);
|
||||
intent.putExtra(DocumentsContract.EXTRA_SHOW_FILESIZE, true);
|
||||
|
||||
@@ -125,8 +125,7 @@ public final class DocumentsContract {
|
||||
public static final String ACTION_MANAGE_DOCUMENT = "android.provider.action.MANAGE_DOCUMENT";
|
||||
|
||||
/** {@hide} */
|
||||
public static final String
|
||||
ACTION_BROWSE_DOCUMENT_ROOT = "android.provider.action.BROWSE_DOCUMENT_ROOT";
|
||||
public static final String ACTION_BROWSE = "android.provider.action.BROWSE";
|
||||
|
||||
/** {@hide} */
|
||||
public static final String
|
||||
|
||||
@@ -358,18 +358,6 @@ public abstract class BaseActivity extends Activity {
|
||||
return mState;
|
||||
}
|
||||
|
||||
public static abstract class DocumentsIntent {
|
||||
/** Intent action name to open copy destination. */
|
||||
public static String ACTION_OPEN_COPY_DESTINATION =
|
||||
"com.android.documentsui.OPEN_COPY_DESTINATION";
|
||||
|
||||
/**
|
||||
* Extra boolean flag for ACTION_OPEN_COPY_DESTINATION_STRING, which
|
||||
* specifies if the destination directory needs to create new directory or not.
|
||||
*/
|
||||
public static String EXTRA_DIRECTORY_COPY = "com.android.documentsui.DIRECTORY_COPY";
|
||||
}
|
||||
|
||||
void setDisplayAdvancedDevices(boolean display) {
|
||||
LocalPreferences.setDisplayAdvancedDevices(this, display);
|
||||
mState.showAdvanced = mState.forceAdvanced | display;
|
||||
|
||||
@@ -179,8 +179,7 @@ public class CopyService extends IntentService {
|
||||
if (mFailedFiles.size() > 0) {
|
||||
Log.e(TAG, mFailedFiles.size() + " files failed to copy");
|
||||
final Context context = getApplicationContext();
|
||||
final Intent navigateIntent = new Intent(context, FilesActivity.class);
|
||||
navigateIntent.putExtra(Shared.EXTRA_STACK, (Parcelable) stack);
|
||||
final Intent navigateIntent = buildNavigateIntent(context, stack);
|
||||
navigateIntent.putExtra(EXTRA_FAILURE, FAILURE_COPY);
|
||||
navigateIntent.putExtra(EXTRA_TRANSFER_MODE, transferMode);
|
||||
navigateIntent.putParcelableArrayListExtra(EXTRA_SRC_LIST, mFailedFiles);
|
||||
@@ -228,8 +227,7 @@ public class CopyService extends IntentService {
|
||||
mIsCancelled = false;
|
||||
|
||||
final Context context = getApplicationContext();
|
||||
final Intent navigateIntent = new Intent(context, FilesActivity.class);
|
||||
navigateIntent.putExtra(Shared.EXTRA_STACK, (Parcelable) stack);
|
||||
final Intent navigateIntent = buildNavigateIntent(context, stack);
|
||||
|
||||
final String contentTitle = getString(copying ? R.string.copy_notification_title
|
||||
: R.string.move_notification_title);
|
||||
@@ -592,4 +590,14 @@ public class CopyService extends IntentService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an intent for navigating back to the destination directory.
|
||||
*/
|
||||
private Intent buildNavigateIntent(Context context, DocumentStack stack) {
|
||||
Intent intent = new Intent(context, FilesActivity.class);
|
||||
intent.setAction(DocumentsContract.ACTION_BROWSE);
|
||||
intent.putExtra(Shared.EXTRA_STACK, (Parcelable) stack);
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.android.documentsui;
|
||||
import static com.android.documentsui.State.ACTION_CREATE;
|
||||
import static com.android.documentsui.State.ACTION_GET_CONTENT;
|
||||
import static com.android.documentsui.State.ACTION_OPEN;
|
||||
import static com.android.documentsui.State.ACTION_OPEN_COPY_DESTINATION;
|
||||
import static com.android.documentsui.State.ACTION_PICK_COPY_DESTINATION;
|
||||
import static com.android.documentsui.State.ACTION_OPEN_TREE;
|
||||
import static com.android.documentsui.dirlist.DirectoryFragment.ANIM_NONE;
|
||||
|
||||
@@ -123,7 +123,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
final String title = getIntent().getStringExtra(Intent.EXTRA_TITLE);
|
||||
SaveFragment.show(getFragmentManager(), mimeType, title);
|
||||
} else if (mState.action == ACTION_OPEN_TREE ||
|
||||
mState.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
mState.action == ACTION_PICK_COPY_DESTINATION) {
|
||||
PickFragment.show(getFragmentManager());
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
} else if (mState.action == ACTION_OPEN ||
|
||||
mState.action == ACTION_CREATE ||
|
||||
mState.action == ACTION_OPEN_TREE ||
|
||||
mState.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
mState.action == ACTION_PICK_COPY_DESTINATION) {
|
||||
RootsFragment.show(getFragmentManager(), null);
|
||||
}
|
||||
|
||||
@@ -163,8 +163,8 @@ public class DocumentsActivity extends BaseActivity {
|
||||
state.action = ACTION_GET_CONTENT;
|
||||
} else if (Intent.ACTION_OPEN_DOCUMENT_TREE.equals(action)) {
|
||||
state.action = ACTION_OPEN_TREE;
|
||||
} else if (DocumentsIntent.ACTION_OPEN_COPY_DESTINATION.equals(action)) {
|
||||
state.action = ACTION_OPEN_COPY_DESTINATION;
|
||||
} else if (Shared.ACTION_PICK_COPY_DESTINATION.equals(action)) {
|
||||
state.action = ACTION_PICK_COPY_DESTINATION;
|
||||
}
|
||||
|
||||
if (state.action == ACTION_OPEN || state.action == ACTION_GET_CONTENT) {
|
||||
@@ -172,9 +172,9 @@ public class DocumentsActivity extends BaseActivity {
|
||||
Intent.EXTRA_ALLOW_MULTIPLE, false);
|
||||
}
|
||||
|
||||
if (state.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
if (state.action == ACTION_PICK_COPY_DESTINATION) {
|
||||
state.directoryCopy = intent.getBooleanExtra(
|
||||
BaseActivity.DocumentsIntent.EXTRA_DIRECTORY_COPY, false);
|
||||
Shared.EXTRA_DIRECTORY_COPY, false);
|
||||
state.transferMode = intent.getIntExtra(CopyService.EXTRA_TRANSFER_MODE,
|
||||
CopyService.TRANSFER_MODE_COPY);
|
||||
}
|
||||
@@ -257,7 +257,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
mState.action == ACTION_OPEN_TREE) {
|
||||
mRootsToolbar.setTitle(R.string.title_open);
|
||||
} else if (mState.action == ACTION_CREATE ||
|
||||
mState.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
mState.action == ACTION_PICK_COPY_DESTINATION) {
|
||||
mRootsToolbar.setTitle(R.string.title_save);
|
||||
}
|
||||
}
|
||||
@@ -324,7 +324,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
boolean recents = cwd == null;
|
||||
boolean picking = mState.action == ACTION_CREATE
|
||||
|| mState.action == ACTION_OPEN_TREE
|
||||
|| mState.action == ACTION_OPEN_COPY_DESTINATION;
|
||||
|| mState.action == ACTION_PICK_COPY_DESTINATION;
|
||||
|
||||
createDir.setVisible(picking && !recents && cwd.isCreateSupported());
|
||||
mSearchManager.showMenu(!picking);
|
||||
@@ -361,7 +361,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
// No directory means recents
|
||||
if (mState.action == ACTION_CREATE ||
|
||||
mState.action == ACTION_OPEN_TREE ||
|
||||
mState.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
mState.action == ACTION_PICK_COPY_DESTINATION) {
|
||||
RecentsCreateFragment.show(fm);
|
||||
} else {
|
||||
DirectoryFragment.showRecentsOpen(fm, anim);
|
||||
@@ -391,7 +391,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
if (mState.action == ACTION_OPEN_TREE ||
|
||||
mState.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
mState.action == ACTION_PICK_COPY_DESTINATION) {
|
||||
final PickFragment pick = PickFragment.get(fm);
|
||||
if (pick != null) {
|
||||
pick.setPickTarget(mState.action, mState.transferMode, cwd);
|
||||
@@ -444,7 +444,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
if (mState.action == ACTION_OPEN_TREE) {
|
||||
result = DocumentsContract.buildTreeDocumentUri(
|
||||
pickTarget.authority, pickTarget.documentId);
|
||||
} else if (mState.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
} else if (mState.action == ACTION_PICK_COPY_DESTINATION) {
|
||||
result = pickTarget.derivedUri;
|
||||
} else {
|
||||
// Should not be reached.
|
||||
@@ -461,7 +461,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
final byte[] rawStack = DurableUtils.writeToArrayOrNull(mState.stack);
|
||||
if (mState.action == ACTION_CREATE ||
|
||||
mState.action == ACTION_OPEN_TREE ||
|
||||
mState.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
mState.action == ACTION_PICK_COPY_DESTINATION) {
|
||||
// Remember stack for last create
|
||||
values.clear();
|
||||
values.put(RecentColumns.KEY, mState.stack.buildKey());
|
||||
@@ -500,7 +500,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
|
||||
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
|
||||
} else if (mState.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
} else if (mState.action == ACTION_PICK_COPY_DESTINATION) {
|
||||
// Picking a copy destination is only used internally by us, so we
|
||||
// don't need to extend permissions to the caller.
|
||||
intent.putExtra(Shared.EXTRA_STACK, (Parcelable) mState.stack);
|
||||
|
||||
@@ -110,7 +110,7 @@ public class PickFragment extends Fragment {
|
||||
mPick.setText(R.string.button_select);
|
||||
mCancel.setVisibility(View.GONE);
|
||||
break;
|
||||
case State.ACTION_OPEN_COPY_DESTINATION:
|
||||
case State.ACTION_PICK_COPY_DESTINATION:
|
||||
mPick.setText(R.string.button_copy);
|
||||
mCancel.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
|
||||
@@ -360,7 +360,7 @@ public class RootsCache {
|
||||
|
||||
// Exclude read-only devices when creating
|
||||
if (state.action == State.ACTION_CREATE && !supportsCreate) continue;
|
||||
if (state.action == State.ACTION_OPEN_COPY_DESTINATION && !supportsCreate) continue;
|
||||
if (state.action == State.ACTION_PICK_COPY_DESTINATION && !supportsCreate) continue;
|
||||
// Exclude roots that don't support directory picking
|
||||
if (state.action == State.ACTION_OPEN_TREE && !supportsIsChild) continue;
|
||||
// Exclude advanced devices when not requested
|
||||
|
||||
@@ -20,6 +20,16 @@ import android.content.Context;
|
||||
|
||||
/** @hide */
|
||||
public final class Shared {
|
||||
/** Intent action name to pick a copy destination. */
|
||||
public static final String ACTION_PICK_COPY_DESTINATION =
|
||||
"com.android.documentsui.PICK_COPY_DESTINATION";
|
||||
|
||||
/**
|
||||
* Extra boolean flag for {@link ACTION_PICK_COPY_DESTINATION}, which
|
||||
* specifies if the destination directory needs to create new directory or not.
|
||||
*/
|
||||
public static final String EXTRA_DIRECTORY_COPY = "com.android.documentsui.DIRECTORY_COPY";
|
||||
|
||||
public static final boolean DEBUG = true;
|
||||
public static final String TAG = "Documents";
|
||||
public static final String EXTRA_STACK = "com.android.documentsui.STACK";
|
||||
|
||||
@@ -75,7 +75,7 @@ public class State implements android.os.Parcelable {
|
||||
public static final int ACTION_OPEN_TREE = 4;
|
||||
public static final int ACTION_MANAGE = 5;
|
||||
public static final int ACTION_BROWSE = 6;
|
||||
public static final int ACTION_OPEN_COPY_DESTINATION = 8;
|
||||
public static final int ACTION_PICK_COPY_DESTINATION = 8;
|
||||
|
||||
public static final int MODE_UNKNOWN = 0;
|
||||
public static final int MODE_LIST = 1;
|
||||
@@ -150,4 +150,4 @@ public class State implements android.os.Parcelable {
|
||||
return new State[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ import com.android.documentsui.Snackbars;
|
||||
import com.android.documentsui.State;
|
||||
import com.android.documentsui.ThumbnailCache;
|
||||
import com.android.documentsui.BaseActivity.DocumentContext;
|
||||
import com.android.documentsui.BaseActivity.DocumentsIntent;
|
||||
import com.android.documentsui.ProviderExecutor.Preemptable;
|
||||
import com.android.documentsui.Shared;
|
||||
import com.android.documentsui.RecentsProvider.StateColumns;
|
||||
import com.android.documentsui.dirlist.MultiSelectManager.Callback;
|
||||
import com.android.documentsui.dirlist.MultiSelectManager.Selection;
|
||||
@@ -897,7 +897,7 @@ public class DirectoryFragment extends Fragment {
|
||||
// Pop up a dialog to pick a destination. This is inadequate but works for now.
|
||||
// TODO: Implement a picker that is to spec.
|
||||
final Intent intent = new Intent(
|
||||
BaseActivity.DocumentsIntent.ACTION_OPEN_COPY_DESTINATION,
|
||||
Shared.ACTION_PICK_COPY_DESTINATION,
|
||||
Uri.EMPTY,
|
||||
getActivity(),
|
||||
DocumentsActivity.class);
|
||||
@@ -914,7 +914,7 @@ public class DirectoryFragment extends Fragment {
|
||||
break;
|
||||
}
|
||||
}
|
||||
intent.putExtra(BaseActivity.DocumentsIntent.EXTRA_DIRECTORY_COPY, directoryCopy);
|
||||
intent.putExtra(Shared.EXTRA_DIRECTORY_COPY, directoryCopy);
|
||||
intent.putExtra(CopyService.EXTRA_TRANSFER_MODE, mode);
|
||||
startActivityForResult(intent, REQUEST_COPY_DESTINATION);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user