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:
@@ -438,6 +438,10 @@ 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);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,9 @@ public final class DocumentsContract {
|
||||
/** {@hide} */
|
||||
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} */
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -562,7 +574,7 @@ public final class DocumentsContract {
|
||||
* @see DocumentsContract#ACTION_DOCUMENT_ROOT_SETTINGS
|
||||
* @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.
|
||||
@@ -570,7 +582,7 @@ public final class DocumentsContract {
|
||||
* @see #COLUMN_FLAGS
|
||||
* @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.
|
||||
@@ -578,7 +590,7 @@ public final class DocumentsContract {
|
||||
* @see #COLUMN_FLAGS
|
||||
* @hide
|
||||
*/
|
||||
public static final int FLAG_REMOVABLE_USB = 1 << 19;
|
||||
public static final int FLAG_REMOVABLE_USB = 1 << 20;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,5 +24,6 @@
|
||||
<!-- Indicates if the home directory should be hidden in the roots list, that is presented
|
||||
in the drawer/left side panel ) -->
|
||||
<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>
|
||||
|
||||
@@ -320,6 +320,8 @@ public class RootsFragment extends Fragment {
|
||||
|
||||
if (root.isHome() && isHomeRootHidden(context)) {
|
||||
continue;
|
||||
} else if (root.isAdvanced() && areAdvancedRootsHidden(context)) {
|
||||
continue;
|
||||
} else if (root.isLibrary()) {
|
||||
if (DEBUG) Log.d(TAG, "Adding " + root + " as library.");
|
||||
libraries.add(item);
|
||||
@@ -377,6 +379,13 @@ public class RootsFragment extends Fragment {
|
||||
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
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
final Item item = getItem(position);
|
||||
|
||||
@@ -298,6 +298,10 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
|
||||
return (flags & Root.FLAG_SUPPORTS_SEARCH) != 0;
|
||||
}
|
||||
|
||||
public boolean isAdvanced() {
|
||||
return (flags & Root.FLAG_ADVANCED) != 0;
|
||||
}
|
||||
|
||||
public boolean isLocalOnly() {
|
||||
return (flags & Root.FLAG_LOCAL_ONLY) != 0;
|
||||
}
|
||||
|
||||
@@ -196,6 +196,7 @@ public class ExternalStorageProvider extends DocumentsProvider {
|
||||
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()) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BugreportStorageProvider extends DocumentsProvider {
|
||||
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
|
||||
final RowBuilder row = result.newRow();
|
||||
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_TITLE, getContext().getString(R.string.bugreport_storage_title));
|
||||
row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
|
||||
|
||||
Reference in New Issue
Block a user