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

Commit 88288e08 authored by Sam Mortimer's avatar Sam Mortimer
Browse files

LineageParts: Add support for customising navbar app switch long press action

*) Also fixes bug where we weren't initializing app switch long press
   setting to config_longPressOnAppSwitchBehavior (even for hardware keys).
   I've verified that the config is set to split screen in lineage-sdk.

Change-Id: I3af7bcf6402cecbb6843d50f7a1000af84e9e53d
parent 9a6ac45a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -247,6 +247,7 @@
    <string name="navigation_bar_arrow_keys_summary">Display left and right cursor buttons while typing. Overrides IME switcher.</string>
    <string name="navigation_bar_home_long_press_title">Home long press action</string>
    <string name="navigation_bar_home_double_tap_title">Home double tap action</string>
    <string name="navigation_bar_app_switch_long_press_title">Recents long press action</string>

    <!-- Power menu -->
    <string name="power_menu_title">Power menu</string>
+8 −0
Original line number Diff line number Diff line
@@ -63,6 +63,14 @@
            android:entryValues="@array/hardware_keys_action_values"
            android:persistent="false" />

        <ListPreference
            android:key="navigation_app_switch_long_press"
            android:dialogTitle="@string/navigation_bar_app_switch_long_press_title"
            android:title="@string/navigation_bar_app_switch_long_press_title"
            android:entries="@array/hardware_keys_action_entries"
            android:entryValues="@array/hardware_keys_action_values"
            android:persistent="false" />

    </PreferenceCategory>

    <PreferenceCategory
+18 −5
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    private static final String DISABLE_NAV_KEYS = "disable_nav_keys";
    private static final String KEY_NAVIGATION_HOME_LONG_PRESS = "navigation_home_long_press";
    private static final String KEY_NAVIGATION_HOME_DOUBLE_TAP = "navigation_home_double_tap";
    private static final String KEY_NAVIGATION_APP_SWITCH_LONG_PRESS =
            "navigation_app_switch_long_press";
    private static final String KEY_POWER_END_CALL = "power_end_call";
    private static final String KEY_HOME_ANSWER_CALL = "home_answer_call";
    private static final String KEY_VOLUME_MUSIC_CONTROLS = "volbtn_music_controls";
@@ -110,6 +112,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    private SwitchPreference mDisableNavigationKeys;
    private ListPreference mNavigationHomeLongPressAction;
    private ListPreference mNavigationHomeDoubleTapAction;
    private ListPreference mNavigationAppSwitchLongPressAction;
    private SwitchPreference mPowerEndCall;
    private SwitchPreference mHomeAnswerCall;
    private SwitchPreference mTorchLongPressPowerGesture;
@@ -194,12 +197,17 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                org.lineageos.platform.internal.R.integer.config_longPressOnHomeBehavior));
        Action defaultHomeDoubleTapAction = Action.fromIntSafe(res.getInteger(
                org.lineageos.platform.internal.R.integer.config_doubleTapOnHomeBehavior));
        Action defaultAppSwitchLongPressAction = Action.fromIntSafe(res.getInteger(
                org.lineageos.platform.internal.R.integer.config_longPressOnAppSwitchBehavior));
        Action homeLongPressAction = Action.fromSettings(resolver,
                LineageSettings.System.KEY_HOME_LONG_PRESS_ACTION,
                defaultHomeLongPressAction);
        Action homeDoubleTapAction = Action.fromSettings(resolver,
                LineageSettings.System.KEY_HOME_DOUBLE_TAP_ACTION,
                defaultHomeDoubleTapAction);
        Action appSwitchLongPressAction = Action.fromSettings(resolver,
                LineageSettings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION,
                defaultAppSwitchLongPressAction);

        // Navigation bar home long press
        mNavigationHomeLongPressAction = initList(KEY_NAVIGATION_HOME_LONG_PRESS,
@@ -209,6 +217,10 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
        mNavigationHomeDoubleTapAction = initList(KEY_NAVIGATION_HOME_DOUBLE_TAP,
                homeDoubleTapAction);

        // Navigation bar app switch long press
        mNavigationAppSwitchLongPressAction = initList(KEY_NAVIGATION_APP_SWITCH_LONG_PRESS,
                appSwitchLongPressAction);

        final LineageHardwareManager hardware = LineageHardwareManager.getInstance(getActivity());

        // Only visible on devices that does not have a navigation bar already,
@@ -324,9 +336,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                    LineageSettings.System.KEY_APP_SWITCH_ACTION, Action.APP_SWITCH);
            mAppSwitchPressAction = initList(KEY_APP_SWITCH_PRESS, pressAction);

            Action longPressAction = Action.fromSettings(resolver,
                    LineageSettings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION, Action.SPLIT_SCREEN);
            mAppSwitchLongPressAction = initList(KEY_APP_SWITCH_LONG_PRESS, longPressAction);
            mAppSwitchLongPressAction = initList(KEY_APP_SWITCH_LONG_PRESS, appSwitchLongPressAction);

            hasAnyBindableKey = true;
        } else {
@@ -501,8 +511,9 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
            handleListChange(mAppSwitchPressAction, newValue,
                    LineageSettings.System.KEY_APP_SWITCH_ACTION);
            return true;
        } else if (preference == mAppSwitchLongPressAction) {
            handleListChange(mAppSwitchLongPressAction, newValue,
        } else if (preference == mAppSwitchLongPressAction ||
                preference == mNavigationAppSwitchLongPressAction) {
            handleListChange((ListPreference) preference, newValue,
                    LineageSettings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION);
            return true;
        } else if (preference == mVolumeKeyCursorControl) {
@@ -558,9 +569,11 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
            if (navbarEnabled) {
                mNavigationPreferencesCat.addPreference(mNavigationHomeLongPressAction);
                mNavigationPreferencesCat.addPreference(mNavigationHomeDoubleTapAction);
                mNavigationPreferencesCat.addPreference(mNavigationAppSwitchLongPressAction);
            } else {
                mNavigationPreferencesCat.removePreference(mNavigationHomeLongPressAction);
                mNavigationPreferencesCat.removePreference(mNavigationHomeDoubleTapAction);
                mNavigationPreferencesCat.removePreference(mNavigationAppSwitchLongPressAction);
            }
        }
        if (homeCategory != null) {