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

Commit e9e4e819 authored by DvTonder's avatar DvTonder
Browse files

Framework: Forward port Power menu config

Change-Id: I4836ddf43e82e254aefa3933a1e30fd652f08f90
parent b2569394
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -2917,6 +2917,36 @@ public final class Settings {
         */
        public static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled";

        /**
         * Whether the power menu reboot menu is enabled
         * @hide
         */
        public static final String POWER_MENU_REBOOT_ENABLED = "power_menu_reboot_enabled";

        /**
         * Whether power menu screenshot is enabled
         * @hide
         */
        public static final String POWER_MENU_SCREENSHOT_ENABLED = "power_menu_screenshot_enabled";

        /**
         * Whether power menu profiles switcher is enabled
         * @hide
         */
        public static final String POWER_MENU_PROFILES_ENABLED = "power_menu_profiles_enabled";

        /**
         * Whether power menu airplane toggle is enabled
         * @hide
         */
        public static final String POWER_MENU_AIRPLANE_ENABLED = "power_menu_airplane_enabled";

        /**
         * Whether power menu silent mode is enabled
         * @hide
         */
        public static final String POWER_MENU_SILENT_ENABLED = "power_menu_silent_enabled";

        /**
         * Settings to backup. This is here so that it's in the same place as the settings
         * keys and easy to update.
@@ -2994,6 +3024,12 @@ public final class Settings {
            QUIET_HOURS_MUTE,
            QUIET_HOURS_STILL,
            QUIET_HOURS_DIM,
            SYSTEM_PROFILES_ENABLED,
            POWER_MENU_SCREENSHOT_ENABLED,
            POWER_MENU_REBOOT_ENABLED,
            POWER_MENU_PROFILES_ENABLED,
            POWER_MENU_AIRPLANE_ENABLED,
            POWER_MENU_SILENT_ENABLED,
        };

        // Settings moved to Settings.Secure
+55 −40
Original line number Diff line number Diff line
@@ -120,11 +120,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
    private boolean mIsWaitingForEcmExit = false;
    private boolean mHasTelephony;
    private boolean mHasVibrator;

    private Profile mChosenProfile;

    private static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled";

    /**
     * @param context everything needs a context :(
     */
@@ -283,6 +280,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
            });

        // next: reboot
        // only shown if enabled, enabled by default
        if (Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.POWER_MENU_REBOOT_ENABLED, 1) == 1) {
            mItems.add(
                new SinglePressAction(R.drawable.ic_lock_reboot, R.string.global_action_reboot) {
                    public void onPress() {
@@ -302,9 +302,14 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
                        return true;
                    }
                });
        }

        // next: profile - only shown if enabled, which is true by default
        if (Settings.System.getInt(mContext.getContentResolver(), SYSTEM_PROFILES_ENABLED, 1) == 1) {
        // next: profile
        // only shown if both system profiles and the menu item is enabled, enabled by default
        if ((Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.SYSTEM_PROFILES_ENABLED, 1) == 1) &&
                (Settings.System.getInt(mContext.getContentResolver(),
                        Settings.System.POWER_MENU_PROFILES_ENABLED, 1) == 1)) {
            mItems.add(
                new ProfileChooseAction() {
                    public void onPress() {
@@ -326,6 +331,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
        }

        // next: screenshot
        // only shown if enabled, disabled by default
        if (Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.POWER_MENU_SCREENSHOT_ENABLED, 0) == 1) {
            mItems.add(
                new SinglePressAction(R.drawable.ic_lock_screenshot, R.string.global_action_screenshot) {
                    public void onPress() {
@@ -340,9 +348,13 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
                        return true;
                    }
                });
        }

        // next: airplane mode
        if (Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.POWER_MENU_AIRPLANE_ENABLED, 1) == 1) {
            mItems.add(mAirplaneModeOn);
        }

        // next: bug report, if enabled
        if (Settings.Secure.getInt(mContext.getContentResolver(),
@@ -393,16 +405,18 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
                });
        }

        // last: silent mode
        if (SHOW_SILENT_TOGGLE) {
            mItems.add(mSilentModeAction);
        }

        // one more thing: optionally add a list of users to switch to
        // next: optionally add a list of users to switch to
        if (SystemProperties.getBoolean("fw.power_user_switcher", false)) {
            addUsersToMenu(mItems);
        }

        // last: silent mode
        if ((Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.POWER_MENU_SILENT_ENABLED, 1) == 1) &&
                (SHOW_SILENT_TOGGLE)) {
            mItems.add(mSilentModeAction);
        }

        mAdapter = new MyAdapter();

        AlertParams params = new AlertParams(getUiContext());
@@ -423,6 +437,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
                        return mAdapter.getItem(position).onLongPress();
                    }
        });

        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);

        dialog.setOnDismissListener(this);