mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 13:49:13 +00:00
Option to customize start lag for gestures during fast typing (#894)
fixes #882
This commit is contained in:
parent
4aac81391e
commit
efd7d53ca1
8 changed files with 72 additions and 3 deletions
|
@ -40,7 +40,7 @@ public final class GestureStrokeRecognitionParams {
|
|||
|
||||
private GestureStrokeRecognitionParams() {
|
||||
// These parameter values are default and intended for testing.
|
||||
mStaticTimeThresholdAfterFastTyping = 350; // msec
|
||||
mStaticTimeThresholdAfterFastTyping = 500; // msec
|
||||
mDetectFastMoveSpeedThreshold = 1.5f; // keyWidth/sec
|
||||
mDynamicThresholdDecayDuration = 450; // msec
|
||||
mDynamicTimeThresholdFrom = 300; // msec
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
package helium314.keyboard.keyboard.internal;
|
||||
|
||||
import helium314.keyboard.latin.settings.Settings;
|
||||
import helium314.keyboard.latin.utils.Log;
|
||||
|
||||
import helium314.keyboard.latin.common.Constants;
|
||||
|
@ -104,7 +105,7 @@ public final class GestureStrokeRecognitionPoints {
|
|||
public void addDownEventPoint(final int x, final int y, final int elapsedTimeSinceFirstDown,
|
||||
final int elapsedTimeSinceLastTyping) {
|
||||
reset();
|
||||
if (elapsedTimeSinceLastTyping < mRecognitionParams.mStaticTimeThresholdAfterFastTyping) {
|
||||
if (elapsedTimeSinceLastTyping < Settings.getInstance().getCurrent().mGestureFastTypingCooldown) {
|
||||
mAfterFastTyping = true;
|
||||
}
|
||||
if (DEBUG) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package helium314.keyboard.latin.settings;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
||||
import helium314.keyboard.latin.R;
|
||||
|
@ -25,6 +26,7 @@ public final class GestureSettingsFragment extends SubScreenFragment {
|
|||
public void onCreate(final Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
addPreferencesFromResource(R.xml.prefs_screen_gesture);
|
||||
setupGestureFastTypingCooldownPref();
|
||||
refreshSettingsEnablement();
|
||||
}
|
||||
|
||||
|
@ -38,5 +40,46 @@ public final class GestureSettingsFragment extends SubScreenFragment {
|
|||
setPreferenceVisible(Settings.PREF_GESTURE_PREVIEW_TRAIL, Settings.readGestureInputEnabled(prefs));
|
||||
setPreferenceVisible(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, Settings.readGestureInputEnabled(prefs));
|
||||
setPreferenceVisible(Settings.PREF_GESTURE_SPACE_AWARE, Settings.readGestureInputEnabled(prefs));
|
||||
setPreferenceVisible(Settings.PREF_GESTURE_FAST_TYPING_COOLDOWN, Settings.readGestureInputEnabled(prefs));
|
||||
}
|
||||
|
||||
private void setupGestureFastTypingCooldownPref() {
|
||||
final SeekBarDialogPreference pref = findPreference(
|
||||
Settings.PREF_GESTURE_FAST_TYPING_COOLDOWN);
|
||||
if (pref == null) return;
|
||||
final SharedPreferences prefs = getSharedPreferences();
|
||||
final Resources res = getResources();
|
||||
pref.setInterface(new SeekBarDialogPreference.ValueProxy() {
|
||||
@Override
|
||||
public void writeValue(final int value, final String key) {
|
||||
prefs.edit().putInt(key, value).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDefaultValue(final String key) {
|
||||
prefs.edit().remove(key).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readValue(final String key) {
|
||||
return Settings.readGestureFastTypingCooldown(prefs, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readDefaultValue(final String key) {
|
||||
return Settings.readDefaultGestureFastTypingCooldown(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValueText(final int value) {
|
||||
if (value == 0) {
|
||||
return res.getString(R.string.gesture_fast_typing_cooldown_instant);
|
||||
}
|
||||
return res.getString(R.string.abbreviation_unit_milliseconds, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void feedbackValue(final int value) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
public static final String PREF_GESTURE_PREVIEW_TRAIL = "gesture_preview_trail";
|
||||
public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = "gesture_floating_preview_text";
|
||||
public static final String PREF_GESTURE_SPACE_AWARE = "gesture_space_aware";
|
||||
public static final String PREF_GESTURE_FAST_TYPING_COOLDOWN = "gesture_fast_typing_cooldown";
|
||||
public static final String PREF_SHOW_SETUP_WIZARD_ICON = "show_setup_wizard_icon";
|
||||
public static final String PREF_USE_CONTACTS = "use_contacts";
|
||||
public static final String PREFS_LONG_PRESS_SYMBOLS_FOR_NUMPAD = "long_press_symbols_for_numpad";
|
||||
|
@ -364,6 +365,17 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
return res.getInteger(R.integer.config_clipboard_history_retention_time);
|
||||
}
|
||||
|
||||
public static int readGestureFastTypingCooldown(final SharedPreferences prefs, final Resources res) {
|
||||
final int milliseconds = prefs.getInt(
|
||||
PREF_GESTURE_FAST_TYPING_COOLDOWN, UNDEFINED_PREFERENCE_VALUE_INT);
|
||||
return (milliseconds != UNDEFINED_PREFERENCE_VALUE_INT) ? milliseconds
|
||||
: readDefaultGestureFastTypingCooldown(res);
|
||||
}
|
||||
|
||||
public static int readDefaultGestureFastTypingCooldown(final Resources res) {
|
||||
return res.getInteger(R.integer.config_gesture_static_time_threshold_after_fast_typing);
|
||||
}
|
||||
|
||||
public static int readHorizontalSpaceSwipe(final SharedPreferences prefs) {
|
||||
return switch (prefs.getString(PREF_SPACE_HORIZONTAL_SWIPE, "none")) {
|
||||
case "move_cursor" -> KeyboardActionListener.SWIPE_MOVE_CURSOR;
|
||||
|
|
|
@ -95,6 +95,7 @@ public class SettingsValues {
|
|||
public final boolean mGestureInputEnabled;
|
||||
public final boolean mGestureTrailEnabled;
|
||||
public final boolean mGestureFloatingPreviewTextEnabled;
|
||||
public final int mGestureFastTypingCooldown;
|
||||
public final boolean mSlidingKeyInputPreviewEnabled;
|
||||
public final int mKeyLongpressTimeout;
|
||||
public final boolean mEnableEmojiAltPhysicalKey;
|
||||
|
@ -199,6 +200,7 @@ public class SettingsValues {
|
|||
mAccount = null; // remove? or can it be useful somewhere?
|
||||
mGestureFloatingPreviewTextEnabled = !mInputAttributes.mDisableGestureFloatingPreviewText
|
||||
&& prefs.getBoolean(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true);
|
||||
mGestureFastTypingCooldown = Settings.readGestureFastTypingCooldown(prefs, res);
|
||||
mOverrideShowingSuggestions = mInputAttributes.mMayOverrideShowingSuggestions && readSuggestionsOverrideEnabled(prefs);
|
||||
mSuggestionsEnabledPerUserSettings = (mInputAttributes.mShouldShowSuggestions && readSuggestionsEnabled(prefs))
|
||||
|| mOverrideShowingSuggestions;
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
<integer name="config_gesture_trail_update_interval">20</integer>
|
||||
<!-- Static threshold for gesture after fast typing (msec) -->
|
||||
<integer name="config_gesture_static_time_threshold_after_fast_typing">500</integer>
|
||||
<integer name="config_gesture_fast_typing_cooldown_step">10</integer>
|
||||
<!-- Static threshold for starting gesture detection (keyWidth%/sec) -->
|
||||
<fraction name="config_gesture_detect_fast_move_speed_threshold">150%</fraction>
|
||||
<!-- Dynamic threshold for gesture after fast typing (msec) -->
|
||||
|
|
|
@ -146,8 +146,12 @@
|
|||
<string name="gesture_floating_preview_text_summary">See the suggested word while gesturing</string>
|
||||
<!-- Option to enable space aware gesture input. The user can input multiple words by gliding through the space key during a gesture input. [CHAR LIMIT=30]-->
|
||||
<string name="gesture_space_aware">Phrase gesture</string>
|
||||
<!-- Description for "gesture_space_aware" option. The user can input multiple words by gliding through the space key during a gesture input.[CHAR LIMIT=65]-->
|
||||
<!-- Description for "gesture_space_aware" option. The user can input multiple words by gliding through the space key during a gesture input. [CHAR LIMIT=65]-->
|
||||
<string name="gesture_space_aware_summary">Input spaces during gestures by gliding to the space key</string>
|
||||
<!-- Title of the setting to adjust the fast-typing gesture cooldown [CHAR LIMIT=35]-->
|
||||
<string name="gesture_fast_typing_cooldown">Rapid typing cooldown</string>
|
||||
<!-- The text that represents no cooldown [CHAR LIMIT=25]-->
|
||||
<string name="gesture_fast_typing_cooldown_instant">Always start instantly</string>
|
||||
<!-- Preferences item for enabling clipboard history -->
|
||||
<string name="enable_clipboard_history">Enable clipboard history</string>
|
||||
<!-- Description for enabling/disabling clipboard history mentioning that if disabled, clipboard content is pasted -->
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:latin="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/settings_screen_gesture"
|
||||
android:key="screen_gesture">
|
||||
<SwitchPreference
|
||||
|
@ -31,4 +32,9 @@
|
|||
android:summary="@string/gesture_space_aware_summary"
|
||||
android:defaultValue="false"
|
||||
android:persistent="true" />
|
||||
<helium314.keyboard.latin.settings.SeekBarDialogPreference
|
||||
android:key="gesture_fast_typing_cooldown"
|
||||
android:title="@string/gesture_fast_typing_cooldown"
|
||||
latin:maxValue="@integer/config_gesture_static_time_threshold_after_fast_typing"
|
||||
latin:stepValue="@integer/config_gesture_fast_typing_cooldown_step" />
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Add table
Reference in a new issue