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

Commit 2078b07f authored by Michael Bestas's avatar Michael Bestas Committed by Steve Kondik
Browse files

Forward port 'Swap volume buttons' (3/3)

Change-Id: I44a2b37b95848fff24c53c4c3561a3c000c487a1
parent aa1757a6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -185,6 +185,8 @@
    <string name="volbtn_cursor_control_off">Disabled</string>
    <string name="volbtn_cursor_control_on">Volume up/down moves cursor left/right</string>
    <string name="volbtn_cursor_control_on_reverse">Volume up/down moves cursor right/left</string>
    <string name="swap_volume_buttons_title">Reorient</string>
    <string name="swap_volume_buttons_summary">Swap volume buttons when the screen is rotated</string>
    <string name="power_end_call_title">End call</string>
    <string name="power_end_call_summary">Pressing the power button will end the current call</string>
    <string name="button_wake_title">Wake up device</string>
+4 −0
Original line number Diff line number Diff line
@@ -169,6 +169,10 @@
            android:entryValues="@array/volbtn_cursor_control_values"
            android:persistent="false" />

        <SwitchPreference
            android:key="swap_volume_buttons"
            android:title="@string/swap_volume_buttons_title"
            android:summary="@string/swap_volume_buttons_summary" />
    </PreferenceCategory>

</PreferenceScreen>
+14 −1
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    private static final String KEY_APP_SWITCH_PRESS = "hardware_keys_app_switch_press";
    private static final String KEY_APP_SWITCH_LONG_PRESS = "hardware_keys_app_switch_long_press";
    private static final String KEY_VOLUME_KEY_CURSOR_CONTROL = "volume_key_cursor_control";
    private static final String KEY_SWAP_VOLUME_BUTTONS = "swap_volume_buttons";
    private static final String DISABLE_NAV_KEYS = "disable_nav_keys";
    private static final String KEY_NAVIGATION_BAR_LEFT = "navigation_bar_left";
    private static final String KEY_POWER_END_CALL = "power_end_call";
@@ -103,6 +104,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    private ListPreference mAppSwitchPressAction;
    private ListPreference mAppSwitchLongPressAction;
    private ListPreference mVolumeKeyCursorControl;
    private SwitchPreference mSwapVolumeButtons;
    private SwitchPreference mDisableNavigationKeys;
    private SwitchPreference mNavigationBarLeftPref;
    private SwitchPreference mPowerEndCall;
@@ -289,6 +291,12 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                    Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0);
            mVolumeKeyCursorControl = initActionList(KEY_VOLUME_KEY_CURSOR_CONTROL,
                    cursorControlAction);

            int swapVolumeKeys = Settings.System.getInt(getContentResolver(),
                    Settings.System.SWAP_VOLUME_KEYS_ON_ROTATION, 0);
            mSwapVolumeButtons = (SwitchPreference)
                    prefScreen.findPreference(KEY_SWAP_VOLUME_BUTTONS);
            mSwapVolumeButtons.setChecked(swapVolumeKeys > 0);
        } else {
            prefScreen.removePreference(volumeCategory);
        }
@@ -483,7 +491,12 @@ public class ButtonSettings extends SettingsPreferenceFragment implements

    @Override
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        if (preference == mDisableNavigationKeys) {
        if (preference == mSwapVolumeButtons) {
            int value = mSwapVolumeButtons.isChecked()
                    ? (Utils.isTablet(getActivity()) ? 2 : 1) : 0;
            Settings.System.putInt(getActivity().getContentResolver(),
                    Settings.System.SWAP_VOLUME_KEYS_ON_ROTATION, value);
        } else if (preference == mDisableNavigationKeys) {
            mDisableNavigationKeys.setEnabled(false);
            writeDisableNavkeysOption(getActivity(), mDisableNavigationKeys.isChecked());
            updateDisableNavkeysOption();