Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get default long press delay value from Android settings #559

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Helium314 marked this conversation as resolved.
Show resolved Hide resolved
<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