lineage-sdk: Import device keys custom rebinding configs and add helpers
* Used to "live" in fw/b since ever, but will be here from now on. * This also brings AOSP configs (config_longPressOnHomeBehavior and config_doubleTapOnHomeBehavior) to the SDK since those are being extended, putting everything in one place. * Long pressing home button will now default to launch assistant and menu button to open recent apps, leaving the past behind. Change-Id: I0ca2b2cf9a565a334c3edf19a978fa6d2c4d2ea3
This commit is contained in:
@@ -168,4 +168,68 @@
|
||||
For example, a device with Home, Back and Menu keys would set this
|
||||
config to 7. -->
|
||||
<integer name="config_deviceHardwareWakeKeys">79</integer>
|
||||
|
||||
<!-- Control the behavior when the user long presses the home button.
|
||||
0 - Nothing
|
||||
1 - Menu key
|
||||
2 - Recent apps view in SystemUI
|
||||
3 - Launch assist intent
|
||||
4 - Voice Search
|
||||
5 - In-app Search
|
||||
6 - Launch camera
|
||||
7 - Sleep
|
||||
8 - Last app
|
||||
9 - Toggle split screen
|
||||
This needs to match the enums in
|
||||
sdk/src/java/org/lineageos/internal/util/DeviceKeysConstants.java.
|
||||
-->
|
||||
<integer name="config_longPressOnHomeBehavior">3</integer>
|
||||
|
||||
<!-- Control the behavior when the user double-taps the home button.
|
||||
0 - Nothing
|
||||
1 - Menu key
|
||||
2 - Recent apps view in SystemUI
|
||||
3 - Launch assist intent
|
||||
4 - Voice Search
|
||||
5 - In-app Search
|
||||
6 - Launch camera
|
||||
7 - Sleep
|
||||
8 - Last app
|
||||
9 - Toggle split screen
|
||||
This needs to match the enums in
|
||||
sdk/src/java/org/lineageos/internal/util/DeviceKeysConstants.java.
|
||||
-->
|
||||
<integer name="config_doubleTapOnHomeBehavior">0</integer>
|
||||
|
||||
<!-- Control the behavior when the user long presses the menu button.
|
||||
0 - Nothing
|
||||
1 - Menu key
|
||||
2 - Recent apps view in SystemUI
|
||||
3 - Launch assist intent
|
||||
4 - Voice Search
|
||||
5 - In-app Search
|
||||
6 - Launch camera
|
||||
7 - Sleep
|
||||
8 - Last app
|
||||
9 - Toggle split screen
|
||||
This needs to match the enums in
|
||||
sdk/src/java/org/lineageos/internal/util/DeviceKeysConstants.java.
|
||||
-->
|
||||
<integer name="config_longPressOnMenuBehavior">2</integer>
|
||||
|
||||
<!-- Control the behavior when the user long presses the app switch button.
|
||||
0 - Nothing
|
||||
1 - Menu key
|
||||
2 - Recent apps view in SystemUI
|
||||
3 - Launch assist intent
|
||||
4 - Voice Search
|
||||
5 - In-app Search
|
||||
6 - Launch camera
|
||||
7 - Sleep
|
||||
8 - Last app
|
||||
9 - Toggle split screen
|
||||
This needs to match the enums in
|
||||
sdk/src/java/org/lineageos/internal/util/DeviceKeysConstants.java.
|
||||
-->
|
||||
<integer name="config_longPressOnAppSwitchBehavior">9</integer>
|
||||
</resources>
|
||||
|
||||
@@ -120,6 +120,12 @@
|
||||
<java-symbol type="integer" name="config_deviceHardwareKeys" />
|
||||
<java-symbol type="integer" name="config_deviceHardwareWakeKeys" />
|
||||
|
||||
<!-- Device keys user-customisable behavior -->
|
||||
<java-symbol type="integer" name="config_longPressOnHomeBehavior" />
|
||||
<java-symbol type="integer" name="config_doubleTapOnHomeBehavior" />
|
||||
<java-symbol type="integer" name="config_longPressOnMenuBehavior" />
|
||||
<java-symbol type="integer" name="config_longPressOnAppSwitchBehavior" />
|
||||
|
||||
<!-- BurnIn protection -->
|
||||
<java-symbol type="bool" name="config_enableBurnInProtection" />
|
||||
|
||||
|
||||
@@ -16,7 +16,42 @@
|
||||
|
||||
package org.lineageos.internal.util;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import lineageos.providers.LineageSettings;
|
||||
|
||||
public class DeviceKeysConstants {
|
||||
// Available custom actions to perform on a key press.
|
||||
// Must match values for KEY_HOME_LONG_PRESS_ACTION in:
|
||||
// sdk/src/java/lineageos/providers/LineageSettings.java
|
||||
public enum Action {
|
||||
NOTHING,
|
||||
MENU,
|
||||
APP_SWITCH,
|
||||
SEARCH,
|
||||
VOICE_SEARCH,
|
||||
IN_APP_SEARCH,
|
||||
LAUNCH_CAMERA,
|
||||
SLEEP,
|
||||
LAST_APP,
|
||||
SPLIT_SCREEN,
|
||||
SINGLE_HAND_LEFT,
|
||||
SINGLE_HAND_RIGHT;
|
||||
|
||||
public static Action fromIntSafe(int id) {
|
||||
if (id < NOTHING.ordinal() || id > Action.values().length) {
|
||||
return NOTHING;
|
||||
}
|
||||
return Action.values()[id];
|
||||
}
|
||||
|
||||
public static Action fromSettings(ContentResolver cr, String setting, Action def) {
|
||||
return fromIntSafe(LineageSettings.System.getIntForUser(cr,
|
||||
setting, def.ordinal(), UserHandle.USER_CURRENT));
|
||||
}
|
||||
}
|
||||
|
||||
// Masks for checking presence of hardware keys.
|
||||
// Must match values in:
|
||||
// lineage/res/res/values/config.xml
|
||||
|
||||
Reference in New Issue
Block a user