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

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

Merge "Make includeDeviceRoot configurable" into arc-apps

parents 03cd3b69 3a9effcb
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -51,4 +51,7 @@
    <bool name="feature_inspector">false</bool>
    <bool name="feature_debug_mode">false</bool>

    <!-- Indicates if internal storage is shown as default or not. -->
    <bool name="config_defaultIncludeDeviceRoot">false</bool>

</resources>
+9 −3
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;

import com.android.documentsui.R;

/**
 * Provides an interface (and runtime implementation) for preferences that are
 * scoped (presumably to an activity). This eliminates the need to pass
@@ -39,25 +41,29 @@ public interface ScopedPreferences {
     *        for prefs that are set using this object.
     */
    public static ScopedPreferences create(Context context, String scope) {
        return new RuntimeScopedPreferences(
        return new RuntimeScopedPreferences(context,
                PreferenceManager.getDefaultSharedPreferences(context), scope);
    }

    static final class RuntimeScopedPreferences implements ScopedPreferences {

        private boolean defaultIncludeDeviceRoot;
        private SharedPreferences mSharedPrefs;
        private String mScope;

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

            defaultIncludeDeviceRoot = context.getResources()
                .getBoolean(R.bool.config_defaultIncludeDeviceRoot);
            mSharedPrefs = sharedPrefs;
            mScope = scope;
        }

        @Override
        public boolean getShowDeviceRoot() {
            return mSharedPrefs.getBoolean(INCLUDE_DEVICE_ROOT, false);
            return mSharedPrefs.getBoolean(INCLUDE_DEVICE_ROOT, defaultIncludeDeviceRoot);
        }

        @Override