Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20b84e01 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Followups to ag/1553792/" into nyc-andromeda-dev

parents a951bd29 01996bc2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);

+2 −2
Original line number Diff line number Diff line
@@ -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);
    }

+13 −0
Original line number Diff line number Diff line
@@ -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);
@@ -37,6 +48,8 @@ public interface ScopedPreferences {
        private String mScope;

        private RuntimeScopedPreferences(SharedPreferences sharedPrefs, String scope)  {
            assert(!TextUtils.isEmpty(scope));

            mSharedPrefs = sharedPrefs;
            mScope = scope;
        }
+2 −1
Original line number Diff line number Diff line
@@ -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);
+3 −3
Original line number Diff line number Diff line
@@ -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;
    /*
@@ -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);
@@ -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