diff options
author | Jeff Sharkey <jsharkey@android.com> | 2014-06-04 16:42:47 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2014-06-09 17:07:58 -0700 |
commit | b9fbb7290b02de1ce621deaa2d28a5e42f2e0937 (patch) | |
tree | 059bb4d64dc433b7a8bd2180ed6a0157e840be0b /packages/DocumentsUI/src/com | |
parent | 19dba9a37d5885503ab08be873d1e3e3e8f93c9c (diff) | |
download | frameworks_base-b9fbb7290b02de1ce621deaa2d28a5e42f2e0937.zip frameworks_base-b9fbb7290b02de1ce621deaa2d28a5e42f2e0937.tar.gz frameworks_base-b9fbb7290b02de1ce621deaa2d28a5e42f2e0937.tar.bz2 |
Refactor directory API to "opening document tree."
Cleans up API so it consistently refers to opening or working with a
subtree of documents. Also separates isChildDocument() support from
the concept of directory tree selection.
Bug: 15429194
Change-Id: Ice66a751ff4bd0cc4d34c44c5da13a0dc4186dc9
Diffstat (limited to 'packages/DocumentsUI/src/com')
3 files changed, 25 insertions, 23 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java index 9f76991..d0b6a1d 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java @@ -24,7 +24,7 @@ import static com.android.documentsui.DocumentsActivity.State.ACTION_CREATE; import static com.android.documentsui.DocumentsActivity.State.ACTION_GET_CONTENT; import static com.android.documentsui.DocumentsActivity.State.ACTION_MANAGE; import static com.android.documentsui.DocumentsActivity.State.ACTION_OPEN; -import static com.android.documentsui.DocumentsActivity.State.ACTION_PICK_DIRECTORY; +import static com.android.documentsui.DocumentsActivity.State.ACTION_OPEN_TREE; import static com.android.documentsui.DocumentsActivity.State.MODE_GRID; import static com.android.documentsui.DocumentsActivity.State.MODE_LIST; @@ -203,7 +203,7 @@ public class DocumentsActivity extends Activity { final String mimeType = getIntent().getType(); final String title = getIntent().getStringExtra(Intent.EXTRA_TITLE); SaveFragment.show(getFragmentManager(), mimeType, title); - } else if (mState.action == ACTION_PICK_DIRECTORY) { + } else if (mState.action == ACTION_OPEN_TREE) { PickFragment.show(getFragmentManager()); } @@ -213,7 +213,7 @@ public class DocumentsActivity extends Activity { moreApps.setPackage(null); RootsFragment.show(getFragmentManager(), moreApps); } else if (mState.action == ACTION_OPEN || mState.action == ACTION_CREATE - || mState.action == ACTION_PICK_DIRECTORY) { + || mState.action == ACTION_OPEN_TREE) { RootsFragment.show(getFragmentManager(), null); } @@ -240,8 +240,8 @@ public class DocumentsActivity extends Activity { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; - } else if (Intent.ACTION_PICK_DIRECTORY.equals(action)) { - mState.action = ACTION_PICK_DIRECTORY; + } else if (Intent.ACTION_OPEN_DOCUMENT_TREE.equals(action)) { + mState.action = ACTION_OPEN_TREE; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { mState.action = ACTION_MANAGE; } @@ -441,7 +441,7 @@ public class DocumentsActivity extends Activity { actionBar.setIcon(new ColorDrawable()); if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT - || mState.action == ACTION_PICK_DIRECTORY) { + || mState.action == ACTION_OPEN_TREE) { actionBar.setTitle(R.string.title_open); } else if (mState.action == ACTION_CREATE) { actionBar.setTitle(R.string.title_save); @@ -583,7 +583,7 @@ public class DocumentsActivity extends Activity { sortSize.setVisible(mState.showSize); final boolean searchVisible; - if (mState.action == ACTION_CREATE || mState.action == ACTION_PICK_DIRECTORY) { + if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) { createDir.setVisible(cwd != null && cwd.isCreateSupported()); searchVisible = false; @@ -828,7 +828,7 @@ public class DocumentsActivity extends Activity { if (cwd == null) { // No directory means recents - if (mState.action == ACTION_CREATE || mState.action == ACTION_PICK_DIRECTORY) { + if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) { RecentsCreateFragment.show(fm); } else { DirectoryFragment.showRecentsOpen(fm, anim); @@ -857,7 +857,7 @@ public class DocumentsActivity extends Activity { } } - if (mState.action == ACTION_PICK_DIRECTORY) { + if (mState.action == ACTION_OPEN_TREE) { final PickFragment pick = PickFragment.get(fm); if (pick != null) { final CharSequence displayName = (mState.stack.size() <= 1) ? root.title @@ -1021,7 +1021,7 @@ public class DocumentsActivity extends Activity { } public void onPickRequested(DocumentInfo pickTarget) { - final Uri viaUri = DocumentsContract.buildViaUri(pickTarget.authority, + final Uri viaUri = DocumentsContract.buildTreeDocumentUri(pickTarget.authority, pickTarget.documentId); new PickFinishTask(viaUri).executeOnExecutor(getCurrentExecutor()); } @@ -1031,7 +1031,7 @@ public class DocumentsActivity extends Activity { final ContentValues values = new ContentValues(); final byte[] rawStack = DurableUtils.writeToArrayOrNull(mState.stack); - if (mState.action == ACTION_CREATE || mState.action == ACTION_PICK_DIRECTORY) { + if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) { // Remember stack for last create values.clear(); values.put(RecentColumns.KEY, mState.stack.buildKey()); @@ -1064,7 +1064,7 @@ public class DocumentsActivity extends Activity { if (mState.action == ACTION_GET_CONTENT) { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - } else if (mState.action == ACTION_PICK_DIRECTORY) { + } else if (mState.action == ACTION_OPEN_TREE) { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION @@ -1202,7 +1202,7 @@ public class DocumentsActivity extends Activity { public static final int ACTION_OPEN = 1; public static final int ACTION_CREATE = 2; public static final int ACTION_GET_CONTENT = 3; - public static final int ACTION_PICK_DIRECTORY = 4; + public static final int ACTION_OPEN_TREE = 4; public static final int ACTION_MANAGE = 5; public static final int MODE_UNKNOWN = 0; diff --git a/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java b/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java index a9e488a1..5112c92 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java @@ -77,13 +77,15 @@ public class PickFragment extends Fragment { public void setPickTarget(DocumentInfo pickTarget, CharSequence displayName) { mPickTarget = pickTarget; - if (mPickTarget != null) { - mContainer.setVisibility(View.VISIBLE); - final Locale locale = getResources().getConfiguration().locale; - final String raw = getString(R.string.menu_select).toUpperCase(locale); - mPick.setText(TextUtils.expandTemplate(raw, displayName)); - } else { - mContainer.setVisibility(View.GONE); + if (mContainer != null) { + if (mPickTarget != null) { + mContainer.setVisibility(View.VISIBLE); + final Locale locale = getResources().getConfiguration().locale; + final String raw = getString(R.string.menu_select).toUpperCase(locale); + mPick.setText(TextUtils.expandTemplate(raw, displayName)); + } else { + mContainer.setVisibility(View.GONE); + } } } } diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java index 933dbe0..caa7581 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java @@ -105,7 +105,7 @@ public class RootsCache { mRecentsRoot.rootId = null; mRecentsRoot.icon = R.drawable.ic_root_recent; mRecentsRoot.flags = Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE - | Root.FLAG_SUPPORTS_DIR_SELECTION; + | Root.FLAG_SUPPORTS_IS_CHILD; mRecentsRoot.title = mContext.getString(R.string.root_recent); mRecentsRoot.availableBytes = -1; @@ -350,7 +350,7 @@ public class RootsCache { final List<RootInfo> matching = Lists.newArrayList(); for (RootInfo root : roots) { final boolean supportsCreate = (root.flags & Root.FLAG_SUPPORTS_CREATE) != 0; - final boolean supportsDir = (root.flags & Root.FLAG_SUPPORTS_DIR_SELECTION) != 0; + final boolean supportsIsChild = (root.flags & Root.FLAG_SUPPORTS_IS_CHILD) != 0; final boolean advanced = (root.flags & Root.FLAG_ADVANCED) != 0; final boolean localOnly = (root.flags & Root.FLAG_LOCAL_ONLY) != 0; final boolean empty = (root.flags & Root.FLAG_EMPTY) != 0; @@ -358,7 +358,7 @@ public class RootsCache { // Exclude read-only devices when creating if (state.action == State.ACTION_CREATE && !supportsCreate) continue; // Exclude roots that don't support directory picking - if (state.action == State.ACTION_PICK_DIRECTORY && !supportsDir) continue; + if (state.action == State.ACTION_OPEN_TREE && !supportsIsChild) continue; // Exclude advanced devices when not requested if (!state.showAdvanced && advanced) continue; // Exclude non-local devices when local only |