Merge "Fix a bug that when user pastes a doc, the breadcrumb adds a doc to it." into nyc-andromeda-dev
diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java
index 6d08c43..96b6832 100644
--- a/src/com/android/documentsui/BaseActivity.java
+++ b/src/com/android/documentsui/BaseActivity.java
@@ -303,7 +303,7 @@
Shared.mustShowDeviceRoot(intent) || getScopedPreferences().getShowDeviceRoot();
// Only show the toggle if advanced isn't forced enabled.
- state.showAdvancedOption = !Shared.mustShowDeviceRoot(intent);
+ state.showDeviceStorageOption = !Shared.mustShowDeviceRoot(intent);
if (DEBUG) Log.d(mTag, "Created new state object: " + state);
diff --git a/src/com/android/documentsui/MenuManager.java b/src/com/android/documentsui/MenuManager.java
index e261c9f..55d2b0e 100644
--- a/src/com/android/documentsui/MenuManager.java
+++ b/src/com/android/documentsui/MenuManager.java
@@ -203,8 +203,8 @@
}
protected void updateAdvanced(MenuItem advanced) {
- advanced.setVisible(mState.showAdvancedOption);
- advanced.setTitle(mState.showAdvancedOption && mState.showAdvanced
+ advanced.setVisible(mState.showDeviceStorageOption);
+ advanced.setTitle(mState.showDeviceStorageOption && mState.showAdvanced
? R.string.menu_advanced_hide : R.string.menu_advanced_show);
}
diff --git a/src/com/android/documentsui/base/ScopedPreferences.java b/src/com/android/documentsui/base/ScopedPreferences.java
index e933ad0..92cca49 100644
--- a/src/com/android/documentsui/base/ScopedPreferences.java
+++ b/src/com/android/documentsui/base/ScopedPreferences.java
@@ -18,12 +18,23 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
+import android.text.TextUtils;
+/**
+ * Provides an interface (and runtime implementation) for preferences that are
+ * scoped (presumably to an activity). This eliminates the need to pass
+ * scoping values into {@link LocalPreferences}, as well as eliminates
+ * the static-coupling to {@link LocalPreferences} increasing testability.
+ */
public interface ScopedPreferences {
boolean getShowDeviceRoot();
void setShowDeviceRoot(boolean display);
+ /**
+ * @param scope An arbitrary string representitive of the scope
+ * for prefs that are set using this object.
+ */
public static ScopedPreferences create(Context context, String scope) {
return new RuntimeScopedPreferences(
PreferenceManager.getDefaultSharedPreferences(context), scope);
@@ -37,6 +48,8 @@
private String mScope;
private RuntimeScopedPreferences(SharedPreferences sharedPrefs, String scope) {
+ assert(!TextUtils.isEmpty(scope));
+
mSharedPrefs = sharedPrefs;
mScope = scope;
}
diff --git a/src/com/android/documentsui/base/Shared.java b/src/com/android/documentsui/base/Shared.java
index 14bb081..3fab225 100644
--- a/src/com/android/documentsui/base/Shared.java
+++ b/src/com/android/documentsui/base/Shared.java
@@ -249,7 +249,8 @@
}
/*
- * Returns true if device root should be shown.
+ * Returns true if the local/device storage root must be visible (this also hides
+ * the option to toggle visibility in the menu.)
*/
public static boolean mustShowDeviceRoot(Intent intent) {
return intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
diff --git a/src/com/android/documentsui/base/State.java b/src/com/android/documentsui/base/State.java
index fff50c9..32d3cc2 100644
--- a/src/com/android/documentsui/base/State.java
+++ b/src/com/android/documentsui/base/State.java
@@ -77,7 +77,7 @@
public boolean allowMultiple;
public boolean localOnly;
- public boolean showAdvancedOption;
+ public boolean showDeviceStorageOption;
public boolean showAdvanced;
public boolean restored;
/*
@@ -127,7 +127,7 @@
out.writeStringArray(acceptMimes);
out.writeInt(allowMultiple ? 1 : 0);
out.writeInt(localOnly ? 1 : 0);
- out.writeInt(showAdvancedOption ? 1 : 0);
+ out.writeInt(showDeviceStorageOption ? 1 : 0);
out.writeInt(showAdvanced ? 1 : 0);
out.writeInt(restored ? 1 : 0);
out.writeInt(external ? 1 : 0);
@@ -151,7 +151,7 @@
state.acceptMimes = in.readStringArray();
state.allowMultiple = in.readInt() != 0;
state.localOnly = in.readInt() != 0;
- state.showAdvancedOption = in.readInt() != 0;
+ state.showDeviceStorageOption = in.readInt() != 0;
state.showAdvanced = in.readInt() != 0;
state.restored = in.readInt() != 0;
state.external = in.readInt() != 0;
diff --git a/tests/unit/com/android/documentsui/files/MenuManagerTest.java b/tests/unit/com/android/documentsui/files/MenuManagerTest.java
index 5d1fb7d..bad3e66 100644
--- a/tests/unit/com/android/documentsui/files/MenuManagerTest.java
+++ b/tests/unit/com/android/documentsui/files/MenuManagerTest.java
@@ -173,7 +173,7 @@
@Test
public void testOptionMenu_showAdvanced() {
state.showAdvanced = true;
- state.showAdvancedOption = true;
+ state.showDeviceStorageOption = true;
mgr.updateOptionMenu(testMenu);
advanced.assertVisible();
diff --git a/tests/unit/com/android/documentsui/picker/MenuManagerTest.java b/tests/unit/com/android/documentsui/picker/MenuManagerTest.java
index f282bd7..0e6a53a 100644
--- a/tests/unit/com/android/documentsui/picker/MenuManagerTest.java
+++ b/tests/unit/com/android/documentsui/picker/MenuManagerTest.java
@@ -164,7 +164,7 @@
@Test
public void testOptionMenu_showAdvanced() {
state.showAdvanced = true;
- state.showAdvancedOption = true;
+ state.showDeviceStorageOption = true;
mgr.updateOptionMenu(testMenu);
advanced.assertVisible();