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

Commit aa116ed9 authored by Nico's avatar Nico Committed by Bruno Martins
Browse files

Implement edge long swipe gesture [3/3]

Add long swipe action list preference in Button Settings.

Change-Id: I39bd5b9dc779ca4b827fda2673252529333ab05f
parent 554e155a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
	Copyright (C) 2015 The CyanogenMod Project
	Copyright (C) 2017-2019 The LineageOS Project
	              2017-2020 The LineageOS Project

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
@@ -240,6 +240,7 @@
    <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>
    <string name="navigation_bar_edge_long_swipe_title">Edge long swipe action</string>

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

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

    </PreferenceCategory>

    <PreferenceCategory
+18 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The CyanogenMod project
 * Copyright (C) 2017-2018 The LineageOS project
 *               2017-2020 The LineageOS project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -78,6 +78,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    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_EDGE_LONG_SWIPE = "navigation_bar_edge_long_swipe";
    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";
@@ -117,6 +118,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    private ListPreference mNavigationHomeLongPressAction;
    private ListPreference mNavigationHomeDoubleTapAction;
    private ListPreference mNavigationAppSwitchLongPressAction;
    private ListPreference mEdgeLongSwipeAction;
    private SwitchPreference mPowerEndCall;
    private SwitchPreference mHomeAnswerCall;
    private SwitchPreference mTorchLongPressPowerGesture;
@@ -212,6 +214,9 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
        Action appSwitchLongPressAction = Action.fromSettings(resolver,
                LineageSettings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION,
                defaultAppSwitchLongPressAction);
        Action edgeLongSwipeAction = Action.fromSettings(resolver,
                LineageSettings.System.KEY_EDGE_LONG_SWIPE_ACTION,
                Action.NOTHING);

        // Navigation bar home long press
        mNavigationHomeLongPressAction = initList(KEY_NAVIGATION_HOME_LONG_PRESS,
@@ -225,6 +230,9 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
        mNavigationAppSwitchLongPressAction = initList(KEY_NAVIGATION_APP_SWITCH_LONG_PRESS,
                appSwitchLongPressAction);

        // Edge long swipe gesture
        mEdgeLongSwipeAction = initList(KEY_EDGE_LONG_SWIPE, edgeLongSwipeAction);

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

        // Only visible on devices that does not have a navigation bar already
@@ -469,6 +477,9 @@ public class ButtonSettings extends SettingsPreferenceFragment implements

            mNavigationAppSwitchLongPressAction.setEntries(actionEntriesGo);
            mNavigationAppSwitchLongPressAction.setEntryValues(actionValuesGo);

            mEdgeLongSwipeAction.setEntries(actionEntriesGo);
            mEdgeLongSwipeAction.setEntryValues(actionValuesGo);
        }
    }

@@ -569,6 +580,10 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
            handleListChange(mTorchLongPressPowerTimeout, newValue,
                    LineageSettings.System.TORCH_LONG_PRESS_POWER_TIMEOUT);
            return true;
        } else if (preference == mEdgeLongSwipeAction) {
            handleListChange(mEdgeLongSwipeAction, newValue,
                    LineageSettings.System.KEY_EDGE_LONG_SWIPE_ACTION);
            return true;
        }
        return false;
    }
@@ -615,10 +630,12 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                mNavigationPreferencesCat.addPreference(mNavigationHomeLongPressAction);
                mNavigationPreferencesCat.addPreference(mNavigationHomeDoubleTapAction);
                mNavigationPreferencesCat.addPreference(mNavigationAppSwitchLongPressAction);
                mNavigationPreferencesCat.addPreference(mEdgeLongSwipeAction);
            } else {
                mNavigationPreferencesCat.removePreference(mNavigationHomeLongPressAction);
                mNavigationPreferencesCat.removePreference(mNavigationHomeDoubleTapAction);
                mNavigationPreferencesCat.removePreference(mNavigationAppSwitchLongPressAction);
                mNavigationPreferencesCat.removePreference(mEdgeLongSwipeAction);
            }
        }
        if (homeCategory != null) {