Merge "Decouple SD card from ADVANCED storage toggle."

This commit is contained in:
Steve McKay
2016-02-02 17:29:04 +00:00
committed by Android (Google) Code Review
9 changed files with 50 additions and 14 deletions

View File

@@ -438,8 +438,11 @@ public class VolumeInfo implements Parcelable {
final Intent intent = new Intent(DocumentsContract.ACTION_BROWSE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(uri);
// note that docsui treats this as *force* show advanced. So sending
// false permits advanced to be shown based on user preferences.
intent.putExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, isPrimary());
intent.putExtra(DocumentsContract.EXTRA_SHOW_FILESIZE, true);
intent.putExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, true);
return intent;
}

View File

@@ -0,0 +1,24 @@
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M18 2h-8L4.02 8 4 20c0 1.1.9 2 2 2h12c1.1 0 2,-.9 2,-2V4c0,-1.1,-.9,-2,-2,-2zm-6 6h-2V4h2v4zm3 0h-2V4h2v4zm3 0h-2V4h2v4z"/>
</vector>

View File

@@ -88,5 +88,6 @@
<item
android:id="@+id/menu_settings"
android:title="@string/menu_settings"
android:showAsAction="never" />
android:showAsAction="never"
android:visible="false" />
</menu>

View File

@@ -39,8 +39,8 @@
<string name="menu_sort">Sort by</string>
<!-- Menu item that enters a mode to search for documents [CHAR LIMIT=24] -->
<string name="menu_search">Search</string>
<!-- Menu item that enters activity to change settings [CHAR LIMIT=24] -->
<string name="menu_settings">Settings</string>
<!-- Menu item that enters activity to change settings for current root [CHAR LIMIT=24] -->
<string name="menu_settings">Storage settings</string>
<!-- Menu item title that opens the selected documents [CHAR LIMIT=24] -->
<string name="menu_open">Open</string>

View File

@@ -150,7 +150,6 @@ public abstract class BaseActivity extends Activity implements SearchManagerList
final MenuItem list = menu.findItem(R.id.menu_list);
final MenuItem advanced = menu.findItem(R.id.menu_advanced);
final MenuItem fileSize = menu.findItem(R.id.menu_file_size);
final MenuItem settings = menu.findItem(R.id.menu_settings);
final MenuItem search = menu.findItem(R.id.menu_search);
// I'm thinkin' this isn't necesary here. If it is...'cuz of a bug....
@@ -167,7 +166,6 @@ public abstract class BaseActivity extends Activity implements SearchManagerList
sortSize.setVisible(mState.showSize); // Only sort by size when visible
fileSize.setVisible(!mState.forceSize);
advanced.setVisible(!mState.forceAdvanced);
settings.setVisible((root.flags & Root.FLAG_HAS_SETTINGS) != 0);
search.setVisible(canSearchRoot());
advanced.setTitle(LocalPreferences.getDisplayAdvancedDevices(this)

View File

@@ -297,7 +297,6 @@ public class DocumentsActivity extends BaseActivity {
final MenuItem grid = menu.findItem(R.id.menu_grid);
final MenuItem list = menu.findItem(R.id.menu_list);
final MenuItem fileSize = menu.findItem(R.id.menu_file_size);
final MenuItem settings = menu.findItem(R.id.menu_settings);
boolean recents = cwd == null;
boolean picking = mState.action == ACTION_CREATE
@@ -314,7 +313,6 @@ public class DocumentsActivity extends BaseActivity {
}
fileSize.setVisible(fileSize.isVisible() && !picking);
settings.setVisible(false);
if (mState.action == ACTION_CREATE) {
final FragmentManager fm = getFragmentManager();

View File

@@ -245,16 +245,21 @@ public class FilesActivity extends BaseActivity {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
final RootInfo root = getCurrentRoot();
final MenuItem createDir = menu.findItem(R.id.menu_create_dir);
final MenuItem newWindow = menu.findItem(R.id.menu_new_window);
final MenuItem pasteFromCb = menu.findItem(R.id.menu_paste_from_clipboard);
final MenuItem settings = menu.findItem(R.id.menu_settings);
createDir.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
createDir.setVisible(true);
createDir.setEnabled(canCreateDirectory());
pasteFromCb.setEnabled(mClipper.hasItemsToPaste());
settings.setVisible(root.hasSettings());
// TODO: For some reason menu is ignoring this being set
// to never in activity.xml. File a bug.
settings.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
Menus.disableHiddenItems(menu, pasteFromCb);
return true;

View File

@@ -176,6 +176,7 @@ public class RootInfo implements Durable, Parcelable {
} else if (isExternalStorage()) {
derivedIcon = R.drawable.ic_root_smartphone;
derivedType = TYPE_LOCAL;
// TODO: Apply SD card icon to SD devices.
} else if (isDownloads()) {
derivedIcon = R.drawable.ic_root_download;
derivedType = TYPE_DOWNLOADS;
@@ -244,6 +245,10 @@ public class RootInfo implements Durable, Parcelable {
|| derivedType == TYPE_RECENTS || derivedType == TYPE_DOWNLOADS;
}
public boolean hasSettings() {
return (flags & Root.FLAG_HAS_SETTINGS) != 0;
}
public Drawable loadIcon(Context context) {
if (derivedIcon != 0) {
return context.getDrawable(derivedIcon);

View File

@@ -134,9 +134,6 @@ public class ExternalStorageProvider extends DocumentsProvider {
final String rootId;
final String title;
if (volume.getType() == VolumeInfo.TYPE_EMULATED) {
// save off the primary volume for subsequent "Home" dir initialization.
primaryVolume = volume;
// We currently only support a single emulated volume mounted at
// a time, and it's always considered the primary
rootId = ROOT_ID_PRIMARY_EMULATED;
@@ -167,9 +164,14 @@ public class ExternalStorageProvider extends DocumentsProvider {
mRoots.put(rootId, root);
root.rootId = rootId;
root.flags = Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED
root.flags = Root.FLAG_LOCAL_ONLY
| Root.FLAG_SUPPORTS_SEARCH | Root.FLAG_SUPPORTS_IS_CHILD;
if (volume.isPrimary()) {
// save off the primary volume for subsequent "Home" dir initialization.
primaryVolume = volume;
root.flags |= Root.FLAG_ADVANCED;
}
// Dunno when this would NOT be the case, but never hurts to be correct.
if (volume.isMountedWritable()) {
root.flags |= Root.FLAG_SUPPORTS_CREATE;