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

Commit 2670ca29 authored by Roman Birg's avatar Roman Birg
Browse files

Settings: remove Expanded Desktop from Power Menu if unavailable



Instead of disabling the option when it is disabled, let's remove the
Expanded Desktop option in Power Menu Settings.

When the user toggles Expanded Desktop to ON, it will automatically add
the option to the power menu. The user can then remove it if they wish,
and all the states are properly kept.

Change-Id: I23b6a44da86c1cd74e3f73a8edc714ceeb47af4d
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent f282a90c
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.ContentResolver;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
import android.provider.Settings;

import com.android.settings.R;
@@ -35,8 +36,14 @@ public class PowerMenu extends SettingsPreferenceFragment {
        final ContentResolver resolver = getContentResolver();

        // Only enable expanded desktop item if expanded desktop support is also enabled
        findPreference(Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED).setEnabled(
                Settings.System.getInt(resolver, Settings.System.EXPANDED_DESKTOP_STYLE, 0) != 0);
        Preference expandedDesktopPref = findPreference(Settings.System.
                POWER_MENU_EXPANDED_DESKTOP_ENABLED);

        if (Settings.System.getInt(getContentResolver(),
                Settings.System.EXPANDED_DESKTOP_STYLE, 0) == 0) {
            // expanded desktop is disabled, remove preference
            getPreferenceScreen().removePreference(expandedDesktopPref);
        }

        // Only enable profiles item if System Profiles are also enabled
        findPreference(Settings.System.POWER_MENU_PROFILES_ENABLED).setEnabled(