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

Commit 3a9effcb authored by Shunta Sato's avatar Shunta Sato Committed by Garfield Tan
Browse files

Make includeDeviceRoot configurable

This patch aims to make "includeDeviceRoot" configurable
via config overlay.
Currently, "internal storage" is hidden as default.

Bug: 62773467
Change-Id: I5adc032401fb8edc95ad34e82190808209e9a530
parent 83392021
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -50,4 +50,7 @@
    <bool name="feature_virtual_files_sharing">true</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