Add a setting for precise repeat

This commit is contained in:
Jules Aguillon 2021-04-20 00:34:21 +02:00
parent 83b3212d3d
commit 5dec9c1215
4 changed files with 12 additions and 1 deletions

View File

@ -23,6 +23,8 @@
<string name="pref_vibrate_summary">Enable/Disable vibrations on key down</string>
<string name="pref_vibrate_duration_title">Duration</string>
<string name="pref_vibrate_duration_summary">%sms</string>
<string name="pref_precise_repeat_title">Precise cursor movements</string>
<string name="pref_precise_repeat_summary">Modulate the speed of movements by swiping more or less</string>
<string name="pref_category_style">Style</string>
<string name="pref_margin_bottom_title">Margin bottom</string>

View File

@ -33,6 +33,12 @@
min="5"
max="100"
/>
<CheckBoxPreference
android:key="precise_repeat"
android:title="@string/pref_precise_repeat_title"
android:summary="@string/pref_precise_repeat_summary"
android:defaultValue="true"
/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_vibrate">
<CheckBoxPreference

View File

@ -23,6 +23,7 @@ class Config
public float keyHeight;
public float horizontalMargin;
public boolean disableAccentKeys;
public boolean preciseRepeat;
public boolean shouldOfferSwitchingToNextInputMethod;
@ -46,6 +47,7 @@ class Config
keyHeight = res.getDimension(R.dimen.key_height);
horizontalMargin = res.getDimension(R.dimen.horizontal_margin);
disableAccentKeys = false;
preciseRepeat = true;
// from prefs
refresh();
// initialized later
@ -68,6 +70,7 @@ class Config
keyHeight = getDipPref(prefs, "key_height", keyHeight);
horizontalMargin = getDipPref(prefs, "horizontal_margin", horizontalMargin);
disableAccentKeys = prefs.getBoolean("disable_accent_keys", disableAccentKeys);
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
}
private float getDipPref(SharedPreferences prefs, String pref_name, float def)

View File

@ -310,7 +310,7 @@ public class Keyboard2View extends View
{
long nextInterval = _config.longPressInterval;
boolean doVibrate = true;
if ((key.flags & KeyValue.FLAG_PRECISE_REPEAT) != 0)
if (_config.preciseRepeat && (key.flags & KeyValue.FLAG_PRECISE_REPEAT) != 0)
{
// Modulate repeat interval depending on the distance of the pointer
float accel = Math.min(4.f, Math.max(0.3f, key.ptrDist / (_config.subValueDist * 15.f)));