From 63bd1378501c1fc3e45bf5a60fcd4aa0d6c5ec9e Mon Sep 17 00:00:00 2001 From: syphyr Date: Thu, 14 Mar 2024 21:06:27 +0100 Subject: [PATCH] Get default long press delay value from Android settings The default long press delay value is set within Android's Settings --> Accessibility --> Touch & hold delay, so use that as the default value in Heliboard as well. Also, increase the max long press delay value to 1500 so that it matches the max value in Android's settings. --- .../keyboard/latin/settings/AdvancedSettingsFragment.kt | 2 +- .../java/helium314/keyboard/latin/settings/Settings.java | 8 +++++--- app/src/main/res/values/config-common.xml | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/latin/settings/AdvancedSettingsFragment.kt b/app/src/main/java/helium314/keyboard/latin/settings/AdvancedSettingsFragment.kt index 1512420ff..b7e082aaa 100644 --- a/app/src/main/java/helium314/keyboard/latin/settings/AdvancedSettingsFragment.kt +++ b/app/src/main/java/helium314/keyboard/latin/settings/AdvancedSettingsFragment.kt @@ -486,7 +486,7 @@ class AdvancedSettingsFragment : SubScreenFragment() { override fun readValue(key: String) = Settings.readKeyLongpressTimeout(prefs, resources) - override fun readDefaultValue(key: String) = Settings.readDefaultKeyLongpressTimeout(resources) + override fun readDefaultValue(key: String) = Settings.readDefaultKeyLongpressTimeout() override fun getValueText(value: Int) = resources.getString(R.string.abbreviation_unit_milliseconds, value.toString()) diff --git a/app/src/main/java/helium314/keyboard/latin/settings/Settings.java b/app/src/main/java/helium314/keyboard/latin/settings/Settings.java index f9ab36310..ca02cd606 100644 --- a/app/src/main/java/helium314/keyboard/latin/settings/Settings.java +++ b/app/src/main/java/helium314/keyboard/latin/settings/Settings.java @@ -20,6 +20,7 @@ import android.util.TypedValue; import android.view.ContextThemeWrapper; import android.view.Gravity; +import android.view.ViewConfiguration; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -346,11 +347,12 @@ public static int readKeyLongpressTimeout(final SharedPreferences prefs, final R final int milliseconds = prefs.getInt( PREF_KEY_LONGPRESS_TIMEOUT, UNDEFINED_PREFERENCE_VALUE_INT); return (milliseconds != UNDEFINED_PREFERENCE_VALUE_INT) ? milliseconds - : readDefaultKeyLongpressTimeout(res); + : readDefaultKeyLongpressTimeout(); } - public static int readDefaultKeyLongpressTimeout(final Resources res) { - return res.getInteger(R.integer.config_default_longpress_key_timeout); + public static int readDefaultKeyLongpressTimeout() { + final int default_longpress_key_timeout = ViewConfiguration.getLongPressTimeout(); + return default_longpress_key_timeout; } public static int readKeypressVibrationDuration(final SharedPreferences prefs, final Resources res) { diff --git a/app/src/main/res/values/config-common.xml b/app/src/main/res/values/config-common.xml index f8c4abc2d..1c0b217b9 100644 --- a/app/src/main/res/values/config-common.xml +++ b/app/src/main/res/values/config-common.xml @@ -28,8 +28,7 @@ false 100 - 300 - 700 + 1500 100 10 3000