Skip to content

Commit

Permalink
Get default long press delay value from Android settings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
syphyr committed Mar 14, 2024
1 parent 7058fb7 commit 63bd137
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values/config-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
<bool name="config_default_vibration_enabled">false</bool>
<integer name="config_max_vibration_duration">100</integer>

<integer name="config_default_longpress_key_timeout">300</integer>
<integer name="config_max_longpress_timeout">700</integer>
<integer name="config_max_longpress_timeout">1500</integer>
<integer name="config_min_longpress_timeout">100</integer>
<integer name="config_longpress_timeout_step">10</integer>
<integer name="config_accessibility_long_press_key_timeout">3000</integer>
Expand Down

0 comments on commit 63bd137

Please sign in to comment.