diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-04-12 23:10:15 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-12 23:10:16 +0000 |
commit | 9e3cb0461ce56146e2ed67082431c052dc4fee1d (patch) | |
tree | a5c449624502e1cd8a38f19c59f6ff8237b70a4a /packages/DocumentsUI/src | |
parent | d4ea01b4aca807cc914a96addefcc2c64ce1a6f5 (diff) | |
parent | 59d577a518333f4b4514315b6d10e8dba160abcd (diff) | |
download | frameworks_base-9e3cb0461ce56146e2ed67082431c052dc4fee1d.zip frameworks_base-9e3cb0461ce56146e2ed67082431c052dc4fee1d.tar.gz frameworks_base-9e3cb0461ce56146e2ed67082431c052dc4fee1d.tar.bz2 |
Merge "Browse mode for DocumentsUI, removed volume state."
Diffstat (limited to 'packages/DocumentsUI/src')
4 files changed, 45 insertions, 25 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java index a8a0c1d..bf3a940 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java @@ -88,7 +88,8 @@ abstract class BaseActivity extends Activity { public static final int ACTION_GET_CONTENT = 3; public static final int ACTION_OPEN_TREE = 4; public static final int ACTION_MANAGE = 5; - public static final int ACTION_MANAGE_ALL = 6; + public static final int ACTION_BROWSE = 6; + public static final int ACTION_BROWSE_ALL = 7; public static final int MODE_UNKNOWN = 0; public static final int MODE_LIST = 1; diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java index 0e3016d..9ffdd33 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java @@ -16,13 +16,15 @@ package com.android.documentsui; -import static com.android.documentsui.DocumentsActivity.TAG; +import static com.android.documentsui.BaseActivity.State.ACTION_BROWSE; +import static com.android.documentsui.BaseActivity.State.ACTION_BROWSE_ALL; import static com.android.documentsui.BaseActivity.State.ACTION_CREATE; import static com.android.documentsui.BaseActivity.State.ACTION_MANAGE; import static com.android.documentsui.BaseActivity.State.MODE_GRID; import static com.android.documentsui.BaseActivity.State.MODE_LIST; import static com.android.documentsui.BaseActivity.State.MODE_UNKNOWN; import static com.android.documentsui.BaseActivity.State.SORT_ORDER_UNKNOWN; +import static com.android.documentsui.DocumentsActivity.TAG; import static com.android.documentsui.model.DocumentInfo.getCursorInt; import static com.android.documentsui.model.DocumentInfo.getCursorLong; import static com.android.documentsui.model.DocumentInfo.getCursorString; @@ -79,7 +81,6 @@ import android.widget.TextView; import android.widget.Toast; import com.android.documentsui.BaseActivity.State; -import com.android.documentsui.CopyService; import com.android.documentsui.ProviderExecutor.Preemptable; import com.android.documentsui.RecentsProvider.StateColumns; import com.android.documentsui.model.DocumentInfo; @@ -507,13 +508,15 @@ public class DirectoryFragment extends Fragment { final MenuItem delete = menu.findItem(R.id.menu_delete); final MenuItem copy = menu.findItem(R.id.menu_copy); - final boolean manageMode = state.action == ACTION_MANAGE; - open.setVisible(!manageMode); - share.setVisible(manageMode); - delete.setVisible(manageMode); - // Hide the copy menu item in the recents folder. For now, also hide it by default - // unless the debug flag is enabled. - copy.setVisible((mType != TYPE_RECENT_OPEN) && + final boolean manageOrBrowse = (state.action == ACTION_MANAGE + || state.action == ACTION_BROWSE || state.action == ACTION_BROWSE_ALL); + + open.setVisible(!manageOrBrowse); + share.setVisible(manageOrBrowse); + delete.setVisible(manageOrBrowse); + + // TODO: unhide copying when ready + copy.setVisible(manageOrBrowse && SystemProperties.getBoolean("debug.documentsui.enable_copy", false)); return true; diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java index 2245b16..d3db44a 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java @@ -16,10 +16,7 @@ package com.android.documentsui; -import static com.android.documentsui.DirectoryFragment.ANIM_DOWN; -import static com.android.documentsui.DirectoryFragment.ANIM_NONE; -import static com.android.documentsui.DirectoryFragment.ANIM_SIDE; -import static com.android.documentsui.DirectoryFragment.ANIM_UP; +import static com.android.documentsui.BaseActivity.State.ACTION_BROWSE; import static com.android.documentsui.BaseActivity.State.ACTION_CREATE; import static com.android.documentsui.BaseActivity.State.ACTION_GET_CONTENT; import static com.android.documentsui.BaseActivity.State.ACTION_MANAGE; @@ -27,8 +24,12 @@ import static com.android.documentsui.BaseActivity.State.ACTION_OPEN; import static com.android.documentsui.BaseActivity.State.ACTION_OPEN_TREE; import static com.android.documentsui.BaseActivity.State.MODE_GRID; import static com.android.documentsui.BaseActivity.State.MODE_LIST; +import static com.android.documentsui.DirectoryFragment.ANIM_DOWN; +import static com.android.documentsui.DirectoryFragment.ANIM_NONE; +import static com.android.documentsui.DirectoryFragment.ANIM_SIDE; +import static com.android.documentsui.DirectoryFragment.ANIM_UP; + import android.app.Activity; -import android.app.Fragment; import android.app.FragmentManager; import android.content.ActivityNotFoundException; import android.content.ClipData; @@ -69,6 +70,8 @@ import android.widget.TextView; import android.widget.Toast; import android.widget.Toolbar; +import libcore.io.IoUtils; + import com.android.documentsui.RecentsProvider.RecentColumns; import com.android.documentsui.RecentsProvider.ResumeColumns; import com.android.documentsui.model.DocumentInfo; @@ -76,8 +79,6 @@ import com.android.documentsui.model.DocumentStack; import com.android.documentsui.model.DurableUtils; import com.android.documentsui.model.RootInfo; -import libcore.io.IoUtils; - import java.io.FileNotFoundException; import java.io.IOException; import java.util.Arrays; @@ -176,7 +177,7 @@ public class DocumentsActivity extends BaseActivity { setActionBar(mToolbar); // Hide roots when we're managing a specific root - if (mState.action == ACTION_MANAGE) { + if (mState.action == ACTION_MANAGE || mState.action == ACTION_BROWSE) { if (mShowAsDialog) { findViewById(R.id.container_roots).setVisibility(View.GONE); } else { @@ -203,7 +204,7 @@ public class DocumentsActivity extends BaseActivity { } if (!mState.restored) { - if (mState.action == ACTION_MANAGE) { + if (mState.action == ACTION_MANAGE || mState.action == ACTION_BROWSE) { final Uri rootUri = getIntent().getData(); new RestoreRootTask(rootUri).executeOnExecutor(getCurrentExecutor()); } else { @@ -229,6 +230,8 @@ public class DocumentsActivity extends BaseActivity { mState.action = ACTION_OPEN_TREE; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { mState.action = ACTION_MANAGE; + } else if (DocumentsContract.ACTION_BROWSE_ROOT.equals(action)) { + mState.action = ACTION_BROWSE; } if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { @@ -236,7 +239,7 @@ public class DocumentsActivity extends BaseActivity { Intent.EXTRA_ALLOW_MULTIPLE, false); } - if (mState.action == ACTION_MANAGE) { + if (mState.action == ACTION_MANAGE || mState.action == ACTION_BROWSE) { mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) { @@ -250,7 +253,7 @@ public class DocumentsActivity extends BaseActivity { mState.showAdvanced = mState.forceAdvanced | LocalPreferences.getDisplayAdvancedDevices(this); - if (mState.action == ACTION_MANAGE) { + if (mState.action == ACTION_MANAGE || mState.action == ACTION_BROWSE) { mState.showSize = true; } else { mState.showSize = LocalPreferences.getDisplayFileSize(this); @@ -413,7 +416,8 @@ public class DocumentsActivity extends BaseActivity { } final RootInfo root = getCurrentRoot(); - final boolean showRootIcon = mShowAsDialog || (mState.action == ACTION_MANAGE); + final boolean showRootIcon = mShowAsDialog + || (mState.action == ACTION_MANAGE || mState.action == ACTION_BROWSE); if (showRootIcon) { mToolbar.setNavigationIcon( root != null ? root.loadToolbarIcon(mToolbar.getContext()) : null); @@ -571,7 +575,8 @@ public class DocumentsActivity extends BaseActivity { sortSize.setVisible(mState.showSize); boolean searchVisible; - boolean fileSizeVisible = mState.action != ACTION_MANAGE; + boolean fileSizeVisible = !(mState.action == ACTION_MANAGE + || mState.action == ACTION_BROWSE); if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) { createDir.setVisible(cwd != null && cwd.isCreateSupported()); searchVisible = false; @@ -601,7 +606,7 @@ public class DocumentsActivity extends BaseActivity { fileSize.setTitle(LocalPreferences.getDisplayFileSize(this) ? R.string.menu_file_size_hide : R.string.menu_file_size_show); - advanced.setVisible(mState.action != ACTION_MANAGE); + advanced.setVisible(!(mState.action == ACTION_MANAGE || mState.action == ACTION_BROWSE)); fileSize.setVisible(fileSizeVisible); return true; @@ -1018,6 +1023,17 @@ public class DocumentsActivity extends BaseActivity { Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show(); } } + } else if (mState.action == ACTION_BROWSE) { + // Go straight to viewing + final Intent view = new Intent(Intent.ACTION_VIEW); + view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + view.setData(doc.derivedUri); + + try { + startActivity(view); + } catch (ActivityNotFoundException ex) { + Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show(); + } } } diff --git a/packages/DocumentsUI/src/com/android/documentsui/StandaloneActivity.java b/packages/DocumentsUI/src/com/android/documentsui/StandaloneActivity.java index e01328d..cc30150 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/StandaloneActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/StandaloneActivity.java @@ -162,7 +162,7 @@ public class StandaloneActivity extends BaseActivity { mState = new State(); final Intent intent = getIntent(); - mState.action = State.ACTION_MANAGE_ALL; + mState.action = State.ACTION_BROWSE_ALL; mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; mState.acceptMimes = new String[] { intent.getType() }; |