Loading src/com/android/documentsui/BaseActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -303,7 +303,7 @@ public abstract class BaseActivity<T extends ActionHandler> 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); Loading src/com/android/documentsui/MenuManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -203,8 +203,8 @@ public abstract class MenuManager { } 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); } Loading src/com/android/documentsui/base/ScopedPreferences.java +13 −0 Original line number Diff line number Diff line Loading @@ -18,12 +18,23 @@ package com.android.documentsui.base; 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); Loading @@ -37,6 +48,8 @@ public interface ScopedPreferences { private String mScope; private RuntimeScopedPreferences(SharedPreferences sharedPrefs, String scope) { assert(!TextUtils.isEmpty(scope)); mSharedPrefs = sharedPrefs; mScope = scope; } Loading src/com/android/documentsui/base/Shared.java +2 −1 Original line number Diff line number Diff line Loading @@ -249,7 +249,8 @@ public final class Shared { } /* * 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); Loading src/com/android/documentsui/base/State.java +3 −3 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class State implements android.os.Parcelable { public boolean allowMultiple; public boolean localOnly; public boolean showAdvancedOption; public boolean showDeviceStorageOption; public boolean showAdvanced; public boolean restored; /* Loading Loading @@ -127,7 +127,7 @@ public class State implements android.os.Parcelable { 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); Loading @@ -151,7 +151,7 @@ public class State implements android.os.Parcelable { 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; Loading Loading
src/com/android/documentsui/BaseActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -303,7 +303,7 @@ public abstract class BaseActivity<T extends ActionHandler> 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); Loading
src/com/android/documentsui/MenuManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -203,8 +203,8 @@ public abstract class MenuManager { } 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); } Loading
src/com/android/documentsui/base/ScopedPreferences.java +13 −0 Original line number Diff line number Diff line Loading @@ -18,12 +18,23 @@ package com.android.documentsui.base; 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); Loading @@ -37,6 +48,8 @@ public interface ScopedPreferences { private String mScope; private RuntimeScopedPreferences(SharedPreferences sharedPrefs, String scope) { assert(!TextUtils.isEmpty(scope)); mSharedPrefs = sharedPrefs; mScope = scope; } Loading
src/com/android/documentsui/base/Shared.java +2 −1 Original line number Diff line number Diff line Loading @@ -249,7 +249,8 @@ public final class Shared { } /* * 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); Loading
src/com/android/documentsui/base/State.java +3 −3 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class State implements android.os.Parcelable { public boolean allowMultiple; public boolean localOnly; public boolean showAdvancedOption; public boolean showDeviceStorageOption; public boolean showAdvanced; public boolean restored; /* Loading Loading @@ -127,7 +127,7 @@ public class State implements android.os.Parcelable { 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); Loading @@ -151,7 +151,7 @@ public class State implements android.os.Parcelable { 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; Loading