diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2013-09-05 17:14:14 -0700 |
|---|---|---|
| committer | Jeff Sharkey <jsharkey@android.com> | 2013-09-06 08:08:18 -0700 |
| commit | a61dc8e03e6e863005b3a4629ca8f3801d33d3c4 (patch) | |
| tree | 4c2570186de8e4119938c7e73ad2331622eee1e1 /packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java | |
| parent | 498a5f5488446e1d5914f5d335ee02572c6201d1 (diff) | |
| download | frameworks_base-a61dc8e03e6e863005b3a4629ca8f3801d33d3c4.zip frameworks_base-a61dc8e03e6e863005b3a4629ca8f3801d33d3c4.tar.gz frameworks_base-a61dc8e03e6e863005b3a4629ca8f3801d33d3c4.tar.bz2 | |
Separate root and document management.
Two hidden intents for managing roots and documents, used to support
Downloads UI. Touching an item tries launching as MANAGE_DOCUMENT
first before falling back to VIEW. Provide MIME type for roots.
Bug: 10446265, 10531347, 10599641
Change-Id: Ia5584bd6ce3e5a9b0048e8caf1447e3053664413
Diffstat (limited to 'packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java')
| -rw-r--r-- | packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java index 4da6567..8715055 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java @@ -145,7 +145,7 @@ public class DocumentsActivity extends Activity { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; - } else if (DocumentsContract.ACTION_MANAGE_DOCUMENTS.equals(action)) { + } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { mState.action = ACTION_MANAGE; } @@ -171,12 +171,13 @@ public class DocumentsActivity extends Activity { } if (mState.action == ACTION_MANAGE) { - final Uri rootUri = intent.getData(); - final RootInfo root = mRoots.findRoot(rootUri); + final Uri uri = intent.getData(); + final String rootId = DocumentsContract.getRootId(uri); + final RootInfo root = mRoots.getRoot(uri.getAuthority(), rootId); if (root != null) { onRootPicked(root, true); } else { - Log.w(TAG, "Failed to find root: " + rootUri); + Log.w(TAG, "Failed to find root: " + uri); finish(); } @@ -626,14 +627,24 @@ public class DocumentsActivity extends Activity { // Replace selected file SaveFragment.get(fm).setReplaceTarget(doc); } else if (mState.action == ACTION_MANAGE) { - // Open the document - final Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - intent.setData(doc.uri); + // First try managing the document; we expect manager to filter + // based on authority, so we don't grant. + final Intent manage = new Intent(DocumentsContract.ACTION_MANAGE_DOCUMENT); + manage.setData(doc.uri); + try { - startActivity(intent); + startActivity(manage); } catch (ActivityNotFoundException ex) { - Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show(); + // Fall back to viewing + final Intent view = new Intent(Intent.ACTION_VIEW); + view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + view.setData(doc.uri); + + try { + startActivity(view); + } catch (ActivityNotFoundException ex2) { + Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show(); + } } } } |
