Merge "Add config flag to show/hide internal storage. Hide internal storage by default." into nyc-dev

am: 5f7d673

* commit '5f7d673f3b69019288adcf11325f71aeb2b8af49':
  Add config flag to show/hide internal storage. Hide internal storage by default.
This commit is contained in:
Aga Wronska
2016-03-22 17:09:10 +00:00
committed by android-build-merger
7 changed files with 36 additions and 5 deletions

View File

@@ -438,6 +438,10 @@ public class VolumeInfo implements Parcelable {
final Intent intent = new Intent(DocumentsContract.ACTION_BROWSE); final Intent intent = new Intent(DocumentsContract.ACTION_BROWSE);
intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(uri); 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_FILESIZE, true);
return intent; return intent;
} }

View File

@@ -92,6 +92,9 @@ public final class DocumentsContract {
/** {@hide} */ /** {@hide} */
public static final String EXTRA_PACKAGE_NAME = "android.content.extra.PACKAGE_NAME"; public static final String EXTRA_PACKAGE_NAME = "android.content.extra.PACKAGE_NAME";
/** {@hide} */
public static final String EXTRA_SHOW_ADVANCED = "android.content.extra.SHOW_ADVANCED";
/** {@hide} */ /** {@hide} */
public static final String EXTRA_SHOW_FILESIZE = "android.content.extra.SHOW_FILESIZE"; public static final String EXTRA_SHOW_FILESIZE = "android.content.extra.SHOW_FILESIZE";
@@ -555,6 +558,15 @@ public final class DocumentsContract {
*/ */
public static final int FLAG_EMPTY = 1 << 16; public static final int FLAG_EMPTY = 1 << 16;
/**
* Flag indicating that this root should only be visible to advanced
* users.
*
* @see #COLUMN_FLAGS
* @hide
*/
public static final int FLAG_ADVANCED = 1 << 17;
/** /**
* Flag indicating that this root has settings. * Flag indicating that this root has settings.
* *
@@ -562,7 +574,7 @@ public final class DocumentsContract {
* @see DocumentsContract#ACTION_DOCUMENT_ROOT_SETTINGS * @see DocumentsContract#ACTION_DOCUMENT_ROOT_SETTINGS
* @hide * @hide
*/ */
public static final int FLAG_HAS_SETTINGS = 1 << 17; public static final int FLAG_HAS_SETTINGS = 1 << 18;
/** /**
* Flag indicating that this root is on removable SD card storage. * Flag indicating that this root is on removable SD card storage.
@@ -570,7 +582,7 @@ public final class DocumentsContract {
* @see #COLUMN_FLAGS * @see #COLUMN_FLAGS
* @hide * @hide
*/ */
public static final int FLAG_REMOVABLE_SD = 1 << 18; public static final int FLAG_REMOVABLE_SD = 1 << 19;
/** /**
* Flag indicating that this root is on removable USB storage. * Flag indicating that this root is on removable USB storage.
@@ -578,7 +590,7 @@ public final class DocumentsContract {
* @see #COLUMN_FLAGS * @see #COLUMN_FLAGS
* @hide * @hide
*/ */
public static final int FLAG_REMOVABLE_USB = 1 << 19; public static final int FLAG_REMOVABLE_USB = 1 << 20;
} }
/** /**

View File

@@ -24,5 +24,6 @@
<!-- Indicates if the home directory should be hidden in the roots list, that is presented <!-- Indicates if the home directory should be hidden in the roots list, that is presented
in the drawer/left side panel ) --> in the drawer/left side panel ) -->
<bool name="home_root_hidden">true</bool> <bool name="home_root_hidden">true</bool>
<!-- Indicates if the advanced roots like internal storage should be hidden in the roots list) -->
<bool name="advanced_roots_hidden">true</bool>
</resources> </resources>

View File

@@ -320,6 +320,8 @@ public class RootsFragment extends Fragment {
if (root.isHome() && isHomeRootHidden(context)) { if (root.isHome() && isHomeRootHidden(context)) {
continue; continue;
} else if (root.isAdvanced() && areAdvancedRootsHidden(context)) {
continue;
} else if (root.isLibrary()) { } else if (root.isLibrary()) {
if (DEBUG) Log.d(TAG, "Adding " + root + " as library."); if (DEBUG) Log.d(TAG, "Adding " + root + " as library.");
libraries.add(item); libraries.add(item);
@@ -377,6 +379,13 @@ public class RootsFragment extends Fragment {
return context.getResources().getBoolean(R.bool.home_root_hidden); return context.getResources().getBoolean(R.bool.home_root_hidden);
} }
/*
* Indicates if the advanced roots should be hidden.
*/
private boolean areAdvancedRootsHidden(Context context) {
return context.getResources().getBoolean(R.bool.advanced_roots_hidden);
}
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
final Item item = getItem(position); final Item item = getItem(position);

View File

@@ -298,6 +298,10 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
return (flags & Root.FLAG_SUPPORTS_SEARCH) != 0; return (flags & Root.FLAG_SUPPORTS_SEARCH) != 0;
} }
public boolean isAdvanced() {
return (flags & Root.FLAG_ADVANCED) != 0;
}
public boolean isLocalOnly() { public boolean isLocalOnly() {
return (flags & Root.FLAG_LOCAL_ONLY) != 0; return (flags & Root.FLAG_LOCAL_ONLY) != 0;
} }

View File

@@ -196,6 +196,7 @@ public class ExternalStorageProvider extends DocumentsProvider {
if (volume.isPrimary()) { if (volume.isPrimary()) {
// save off the primary volume for subsequent "Home" dir initialization. // save off the primary volume for subsequent "Home" dir initialization.
primaryVolume = volume; primaryVolume = volume;
root.flags |= Root.FLAG_ADVANCED;
} }
// Dunno when this would NOT be the case, but never hurts to be correct. // Dunno when this would NOT be the case, but never hurts to be correct.
if (volume.isMountedWritable()) { if (volume.isMountedWritable()) {

View File

@@ -56,7 +56,7 @@ public class BugreportStorageProvider extends DocumentsProvider {
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection)); final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
final RowBuilder row = result.newRow(); final RowBuilder row = result.newRow();
row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT); row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT);
row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY); row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED);
row.add(Root.COLUMN_ICON, android.R.mipmap.sym_def_app_icon); row.add(Root.COLUMN_ICON, android.R.mipmap.sym_def_app_icon);
row.add(Root.COLUMN_TITLE, getContext().getString(R.string.bugreport_storage_title)); row.add(Root.COLUMN_TITLE, getContext().getString(R.string.bugreport_storage_title));
row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT); row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);