Merge "Always show intern storage." into nyc-dev

am: b4672ef6df

* commit 'b4672ef6dfbaf416981539d515ad1489d7d0bc87':
  Always show intern storage.
This commit is contained in:
Steve McKay
2016-03-02 19:02:19 +00:00
committed by android-build-merger
12 changed files with 3 additions and 82 deletions

View File

@@ -438,10 +438,6 @@ 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;
}

View File

@@ -92,9 +92,6 @@ 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";
@@ -563,15 +560,6 @@ 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.
*
@@ -579,7 +567,7 @@ public final class DocumentsContract {
* @see DocumentsContract#ACTION_DOCUMENT_ROOT_SETTINGS
* @hide
*/
public static final int FLAG_HAS_SETTINGS = 1 << 18;
public static final int FLAG_HAS_SETTINGS = 1 << 17;
}
/**

View File

@@ -83,10 +83,6 @@
android:id="@+id/menu_file_size"
android:showAsAction="never"
android:visible="false" />
<item
android:id="@+id/menu_advanced"
android:showAsAction="never"
android:visible="false" />
<item
android:id="@+id/menu_settings"
android:title="@string/menu_settings"

View File

@@ -151,7 +151,6 @@ public abstract class BaseActivity extends Activity
final MenuItem sortSize = menu.findItem(R.id.menu_sort_size);
final MenuItem grid = menu.findItem(R.id.menu_grid);
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);
// Search uses backend ranking; no sorting, recents doesn't support sort.
@@ -163,9 +162,6 @@ public abstract class BaseActivity extends Activity
grid.setVisible(mState.derivedMode != State.MODE_GRID);
list.setVisible(mState.derivedMode != State.MODE_LIST);
advanced.setVisible(!mState.forceAdvanced);
advanced.setTitle(LocalPreferences.getDisplayAdvancedDevices(this)
? R.string.menu_advanced_hide : R.string.menu_advanced_show);
fileSize.setTitle(LocalPreferences.getDisplayFileSize(this)
? R.string.menu_file_size_hide : R.string.menu_file_size_show);
@@ -201,10 +197,6 @@ public abstract class BaseActivity extends Activity
state.forceSize = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_FILESIZE, false);
state.showSize = state.forceSize || LocalPreferences.getDisplayFileSize(this);
state.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
state.showAdvanced = state.forceAdvanced
|| LocalPreferences.getDisplayAdvancedDevices(this);
state.initAcceptMimes(intent);
state.excludedAuthorities = getExcludedAuthorities();
@@ -280,10 +272,6 @@ public abstract class BaseActivity extends Activity
}
return true;
case R.id.menu_advanced:
setDisplayAdvancedDevices(!LocalPreferences.getDisplayAdvancedDevices(this));
return true;
case R.id.menu_file_size:
setDisplayFileSize(!LocalPreferences.getDisplayFileSize(this));
return true;
@@ -435,13 +423,6 @@ public abstract class BaseActivity extends Activity
return mState;
}
void setDisplayAdvancedDevices(boolean display) {
LocalPreferences.setDisplayAdvancedDevices(this, display);
mState.showAdvanced = mState.forceAdvanced | display;
RootsFragment.get(getFragmentManager()).onDisplayStateChanged();
invalidateOptionsMenu();
}
void setDisplayFileSize(boolean display) {
LocalPreferences.setDisplayFileSize(this, display);
mState.showSize = display;

View File

@@ -98,12 +98,10 @@ public class DownloadsActivity extends BaseActivity {
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
final MenuItem advanced = menu.findItem(R.id.menu_advanced);
final MenuItem createDir = menu.findItem(R.id.menu_create_dir);
final MenuItem pasteFromCb = menu.findItem(R.id.menu_paste_from_clipboard);
final MenuItem fileSize = menu.findItem(R.id.menu_file_size);
advanced.setVisible(false);
createDir.setVisible(false);
pasteFromCb.setEnabled(false);
fileSize.setVisible(false);

View File

@@ -25,17 +25,9 @@ import com.android.documentsui.State.ViewMode;
import com.android.documentsui.model.RootInfo;
public class LocalPreferences {
private static final String KEY_ADVANCED_DEVICES = "advancedDevices";
private static final String KEY_FILE_SIZE = "fileSize";
private static final String ROOT_VIEW_MODE_PREFIX = "rootViewMode-";
public static boolean getDisplayAdvancedDevices(Context context) {
boolean defaultAdvanced = context.getResources()
.getBoolean(R.bool.config_defaultAdvancedDevices);
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(KEY_ADVANCED_DEVICES, defaultAdvanced);
}
public static boolean getDisplayFileSize(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(KEY_FILE_SIZE, false);
@@ -47,11 +39,6 @@ public class LocalPreferences {
.getInt(createKey(root), fallback);
}
public static void setDisplayAdvancedDevices(Context context, boolean display) {
PreferenceManager.getDefaultSharedPreferences(context).edit()
.putBoolean(KEY_ADVANCED_DEVICES, display).apply();
}
public static void setDisplayFileSize(Context context, boolean display) {
PreferenceManager.getDefaultSharedPreferences(context).edit()
.putBoolean(KEY_FILE_SIZE, display).apply();

View File

@@ -439,39 +439,27 @@ public class RootsCache {
continue;
}
if (!state.showAdvanced && root.isAdvanced()) {
if (DEBUG) Log.d(TAG, "Excluding root because: unwanted advanced device.");
continue;
}
// Exclude non-local devices when local only
if (state.localOnly && !root.isLocalOnly()) {
if (DEBUG) Log.d(TAG, "Excluding root because: unwanted non-local device.");
continue;
}
// Exclude downloads roots as it doesn't support directory creation (actually
// we just don't show them).
// TODO: Add flag to check the root supports directory creation.
if (state.directoryCopy && root.isDownloads()) {
if (DEBUG) Log.d(
TAG, "Excluding downloads root because: unsupported directory copy.");
continue;
}
// Only show empty roots when creating, or in browse mode.
if (state.action == State.ACTION_OPEN && root.isEmpty()) {
if (DEBUG) Log.d(TAG, "Excluding empty root because: ACTION_OPEN.");
continue;
}
// Only show empty roots when creating, or in browse mode.
if (state.action == State.ACTION_GET_CONTENT && root.isEmpty()) {
if (DEBUG) Log.d(TAG, "Excluding empty root because: ACTION_GET_CONTENT.");
continue;
}
// Only include roots that serve requested content
final boolean overlap =
MimePredicate.mimeMatches(root.derivedMimeTypes, state.acceptMimes) ||
MimePredicate.mimeMatches(state.acceptMimes, root.derivedMimeTypes);
@@ -482,9 +470,8 @@ public class RootsCache {
continue;
}
// Exclude roots from the calling package.
if (state.excludedAuthorities.contains(root.authority)) {
if (DEBUG) Log.d(TAG, "Excluding root because: calling package.");
if (DEBUG) Log.d(TAG, "Excluding root because: owned by calling package.");
continue;
}

View File

@@ -82,8 +82,6 @@ public class State implements android.os.Parcelable {
public boolean forceSize;
public boolean showSize;
public boolean localOnly;
public boolean forceAdvanced;
public boolean showAdvanced;
public boolean restored;
// Indicates that a copy operation (or move) includes a directory.
@@ -181,8 +179,6 @@ public class State implements android.os.Parcelable {
out.writeInt(forceSize ? 1 : 0);
out.writeInt(showSize ? 1 : 0);
out.writeInt(localOnly ? 1 : 0);
out.writeInt(forceAdvanced ? 1 : 0);
out.writeInt(showAdvanced ? 1 : 0);
out.writeInt(restored ? 1 : 0);
DurableUtils.writeToParcel(out, stack);
out.writeMap(dirState);
@@ -211,8 +207,6 @@ public class State implements android.os.Parcelable {
state.forceSize = in.readInt() != 0;
state.showSize = in.readInt() != 0;
state.localOnly = in.readInt() != 0;
state.forceAdvanced = in.readInt() != 0;
state.showAdvanced = in.readInt() != 0;
state.restored = in.readInt() != 0;
DurableUtils.readFromParcel(in, state.stack);
in.readMap(state.dirState, loader);

View File

@@ -283,10 +283,6 @@ 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;
}

View File

@@ -55,7 +55,6 @@ public class RootsCacheTest extends AndroidTestCase {
mState = new State();
mState.action = State.ACTION_OPEN;
mState.showAdvanced = true;
mState.localOnly = false;
}

View File

@@ -170,7 +170,6 @@ 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()) {

View File

@@ -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 | Root.FLAG_ADVANCED);
row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY);
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);