Merge "Move resources spec to overlay." into arc-apps
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f6fef1b..e1bec54 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -84,7 +84,12 @@
<data android:mimeType="vnd.android.document/root" />
</intent-filter>
<intent-filter>
- <action android:name="android.provider.action.BROWSE" />
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="vnd.android.document/root" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.document/directory" />
</intent-filter>
diff --git a/res/xml/shortcuts.xml b/res/xml/shortcuts.xml
index 294a43b..1901140 100644
--- a/res/xml/shortcuts.xml
+++ b/res/xml/shortcuts.xml
@@ -21,7 +21,7 @@
android:icon="@drawable/ic_downloads_shortcut"
android:shortcutShortLabel="@string/downloads_shortcut_label" >
<intent
- android:action="android.provider.action.BROWSE"
+ android:action="android.intent.action.VIEW"
android:data="content://com.android.providers.downloads.documents/root/downloads" />
</shortcut>
</shortcuts>
\ No newline at end of file
diff --git a/src/com/android/documentsui/files/ActionHandler.java b/src/com/android/documentsui/files/ActionHandler.java
index 9938cc0..e9fffac 100644
--- a/src/com/android/documentsui/files/ActionHandler.java
+++ b/src/com/android/documentsui/files/ActionHandler.java
@@ -399,7 +399,8 @@
}
private boolean launchToRoot(Intent intent) {
- if (DocumentsContract.ACTION_BROWSE.equals(intent.getAction())) {
+ String action = intent.getAction();
+ if (Intent.ACTION_VIEW.equals(action) || DocumentsContract.ACTION_BROWSE.equals(action)) {
Uri uri = intent.getData();
if (DocumentsContract.isRootUri(mActivity, uri)) {
if (DEBUG) Log.d(TAG, "Launching with root URI.");
@@ -413,7 +414,7 @@
}
private boolean launchToDocument(Intent intent) {
- if (DocumentsContract.ACTION_BROWSE.equals(intent.getAction())) {
+ if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
if (DocumentsContract.isDocumentUri(mActivity, uri)) {
return launchToDocument(intent.getData());
diff --git a/src/com/android/documentsui/services/Job.java b/src/com/android/documentsui/services/Job.java
index 6596014..61f1c38 100644
--- a/src/com/android/documentsui/services/Job.java
+++ b/src/com/android/documentsui/services/Job.java
@@ -316,9 +316,9 @@
* Creates an intent for navigating back to the destination directory.
*/
Intent buildNavigateIntent(String tag) {
+ // TODO (b/35721285): Reuse an existing task rather than creating a new one every time.
Intent intent = new Intent(service, FilesActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setAction(DocumentsContract.ACTION_BROWSE);
intent.setData(getDataUriForIntent(tag));
intent.putExtra(Shared.EXTRA_STACK, (Parcelable) stack);
return intent;
diff --git a/src/com/android/documentsui/sidebar/RootsFragment.java b/src/com/android/documentsui/sidebar/RootsFragment.java
index e913857..0debf72 100644
--- a/src/com/android/documentsui/sidebar/RootsFragment.java
+++ b/src/com/android/documentsui/sidebar/RootsFragment.java
@@ -51,6 +51,7 @@
import com.android.documentsui.BaseActivity;
import com.android.documentsui.DocumentsApplication;
import com.android.documentsui.DragAndDropHelper;
+import com.android.documentsui.DragShadowBuilder;
import com.android.documentsui.Injector;
import com.android.documentsui.Injector.Injected;
import com.android.documentsui.ItemDragListener;
@@ -378,13 +379,24 @@
final RootItem rootItem = (RootItem) item;
getRootDocument(rootItem, (DocumentInfo doc) -> {
- rootItem.docInfo = doc;
- getBaseActivity().getShadowBuilder().setAppearDroppable(
- doc.isCreateSupported() && DragAndDropHelper.canCopyTo(localState, doc));
- v.updateDragShadow(getBaseActivity().getShadowBuilder());
+ updateDropShadow(v, localState, rootItem, doc);
});
}
+ private void updateDropShadow(
+ View v, Object localState, RootItem rootItem, DocumentInfo rootDoc) {
+ final DragShadowBuilder shadowBuilder = getBaseActivity().getShadowBuilder();
+ if (rootDoc == null) {
+ Log.e(TAG, "Root DocumentInfo is null. Defaulting to appear not droppable.");
+ shadowBuilder.setAppearDroppable(false);
+ } else {
+ rootItem.docInfo = rootDoc;
+ shadowBuilder.setAppearDroppable(rootDoc.isCreateSupported()
+ && DragAndDropHelper.canCopyTo(localState, rootDoc));
+ }
+ v.updateDragShadow(shadowBuilder);
+ }
+
// In RootsFragment we always reset the drag shadow as it exits a RootItemView.
@Override
public void onDragExited(View v, Object localState) {
diff --git a/tests/functional/com/android/documentsui/ActivityTest.java b/tests/functional/com/android/documentsui/ActivityTest.java
index 026aab4..c4ab018 100644
--- a/tests/functional/com/android/documentsui/ActivityTest.java
+++ b/tests/functional/com/android/documentsui/ActivityTest.java
@@ -138,8 +138,8 @@
UiBot.TARGET_PKG);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
if (getInitialRoot() != null) {
- intent.setAction(DocumentsContract.ACTION_BROWSE);
- intent.setData(getInitialRoot().getUri());
+ intent.setAction(Intent.ACTION_VIEW);
+ intent.setDataAndType(getInitialRoot().getUri(), DocumentsContract.Root.MIME_TYPE_ITEM);
}
setActivityIntent(intent);
getActivity(); // Launch the activity.
diff --git a/tests/unit/com/android/documentsui/files/ActionHandlerTest.java b/tests/unit/com/android/documentsui/files/ActionHandlerTest.java
index c439b6f..df4a319 100644
--- a/tests/unit/com/android/documentsui/files/ActionHandlerTest.java
+++ b/tests/unit/com/android/documentsui/files/ActionHandlerTest.java
@@ -338,7 +338,7 @@
@Test
public void testInitLocation_BrowseRoot() throws Exception {
Intent intent = mActivity.getIntent();
- intent.setAction(DocumentsContract.ACTION_BROWSE);
+ intent.setAction(Intent.ACTION_VIEW);
intent.setData(TestRootsAccess.PICKLES.getUri());
mHandler.initLocation(intent);
@@ -352,15 +352,14 @@
TestRootsAccess.HOME.rootId,
Arrays.asList(
TestEnv.FOLDER_0.documentId,
- TestEnv.FOLDER_1.documentId,
- TestEnv.FILE_GIF.documentId));
+ TestEnv.FOLDER_1.documentId));
mEnv.docs.nextDocuments =
- Arrays.asList(TestEnv.FOLDER_0, TestEnv.FOLDER_1, TestEnv.FILE_GIF);
+ Arrays.asList(TestEnv.FOLDER_0, TestEnv.FOLDER_1);
mActivity.refreshCurrentRootAndDirectory.assertNotCalled();
Intent intent = mActivity.getIntent();
- intent.setAction(DocumentsContract.ACTION_BROWSE);
- intent.setData(TestEnv.FILE_GIF.derivedUri);
+ intent.setAction(Intent.ACTION_VIEW);
+ intent.setData(TestEnv.FOLDER_1.derivedUri);
mHandler.initLocation(intent);
mEnv.beforeAsserts();