From 907bce40ddf4c4ff31b3b55de64f843eaee6faec Mon Sep 17 00:00:00 2001 From: Cosmin Tanislav Date: Wed, 11 Jun 2025 22:44:49 +0300 Subject: [PATCH] lineage-sdk: use single validator for hardware keys Change-Id: Ifbc2c275e4b2270c87894a782a7b92cc84479788 --- .../lineageos/providers/LineageSettings.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sdk/src/java/lineageos/providers/LineageSettings.java b/sdk/src/java/lineageos/providers/LineageSettings.java index 358a811b..269d7112 100644 --- a/sdk/src/java/lineageos/providers/LineageSettings.java +++ b/sdk/src/java/lineageos/providers/LineageSettings.java @@ -371,6 +371,9 @@ public final class LineageSettings { private static final Validator sSecondsFromMidnightValidator = new InclusiveIntegerRangeValidator(0, 86400); + private static final Validator sHardwareKeyActionvalidator = + new InclusiveIntegerRangeValidator(0, 10); + private static final Validator sAlwaysTrueValidator = new Validator() { @Override public boolean validate(String value) { @@ -1087,7 +1090,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_HOME_LONG_PRESS_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Action to perform when the home key is double-tapped. @@ -1098,7 +1101,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_HOME_DOUBLE_TAP_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Action to perform when the back key is long-pressed. @@ -1109,7 +1112,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_BACK_LONG_PRESS_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Whether to wake the screen with the back key, the value is boolean. @@ -1169,7 +1172,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_MENU_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Action to perform when the menu key is long-pressed. @@ -1180,7 +1183,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_MENU_LONG_PRESS_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Action to perform when the assistant (search) key is pressed. (Default is 3) @@ -1190,7 +1193,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_ASSIST_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Action to perform when the assistant (search) key is long-pressed. (Default is 4) @@ -1200,7 +1203,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_ASSIST_LONG_PRESS_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Action to perform when the app switch key is pressed. (Default is 2) @@ -1210,7 +1213,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_APP_SWITCH_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Action to perform when the app switch key is long-pressed. (Default is 0) @@ -1220,7 +1223,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_APP_SWITCH_LONG_PRESS_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Action to perform when the screen edge is long-swiped. (Default is 0) @@ -1230,7 +1233,7 @@ public final class LineageSettings { /** @hide */ public static final Validator KEY_EDGE_LONG_SWIPE_ACTION_VALIDATOR = - new InclusiveIntegerRangeValidator(0, 10); + sHardwareKeyActionvalidator; /** * Whether to wake the screen with the home key, the value is boolean.