Skip to content
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
4 changes: 4 additions & 0 deletions java/res/values/strings-uix.xml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@
<string name="morekey_settings_show_hints_tags">additional characters, alt keys, symbols, popup keys</string>
<string name="morekey_settings_duration">Long Press Duration</string>
<string name="morekey_settings_duration_subtitle">How long a key needs to be pressed to be considered a long-press</string>
<string name="morekey_settings_flick_threshold">Flick sensitivity</string>
<string name="morekey_settings_flick_threshold_subtitle">Adjust how far you need to swipe to trigger a flick action. Lower values make flick easier to trigger.</string>
<string name="morekey_settings_flick_threshold_default">Default</string>
<string name="morekey_settings_flick_threshold_tags">flick, swipe, gesture, sensitivity, threshold, distance</string>

<string name="morekey_settings_backspace_title">Backspace</string>
<string name="morekey_settings_backspace_hold_delete_words">Hold to delete words</string>
Expand Down
6 changes: 5 additions & 1 deletion java/src/org/futo/inputmethod/keyboard/Key.kt
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ data class Key(
val dirs = computeDirectionsFromDeltaPos(
dx = dx.toDouble(),
dy = dy.toDouble(),
threshold = (width / 3).toDouble()
threshold = (width * flickThresholdRatio).toDouble()
)
dirs.firstOrNull { flickKeys.contains(it) }
}
Expand All @@ -569,6 +569,10 @@ data class Key(
get() = mFlickDirection

companion object {
@Volatile
@JvmStatic
var flickThresholdRatio: Float = 1.0f / 3.0f

@JvmStatic
fun removeRedundantMoreKeys(
key: Key,
Expand Down
13 changes: 13 additions & 0 deletions java/src/org/futo/inputmethod/latin/LatinIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import org.futo.inputmethod.accessibility.AccessibilityUtils
import org.futo.inputmethod.engine.ExpandableSuggestionBarConfiguration
import org.futo.inputmethod.engine.IMEManager
import org.futo.inputmethod.engine.general.WordLearner
import org.futo.inputmethod.keyboard.Key
import org.futo.inputmethod.latin.SuggestedWords.SuggestedWordInfo
import org.futo.inputmethod.latin.common.Constants
import org.futo.inputmethod.latin.settings.Settings
Expand Down Expand Up @@ -86,6 +87,8 @@ import org.futo.inputmethod.latin.uix.getSettingFlow
import org.futo.inputmethod.latin.uix.isDirectBootUnlocked
import org.futo.inputmethod.latin.uix.safeKeyboardPadding
import org.futo.inputmethod.latin.uix.setSetting
import org.futo.inputmethod.latin.uix.settings.pages.FLICK_THRESHOLD_DEFAULT
import org.futo.inputmethod.latin.uix.settings.pages.flickThresholdSetting
import org.futo.inputmethod.latin.uix.theme.ThemeOption
import org.futo.inputmethod.latin.uix.theme.applyWindowColors
import org.futo.inputmethod.latin.uix.theme.getThemeOption
Expand Down Expand Up @@ -440,6 +443,16 @@ class LatinIME : InputMethodServiceCompose(), LatinIMELegacy.SuggestionStripCont
}
}

val toFlickThresholdRatio: (Int) -> Float = {
if(it < 0) FLICK_THRESHOLD_DEFAULT else it / 100.0f
}
Key.flickThresholdRatio = toFlickThresholdRatio(getSettingBlocking(flickThresholdSetting))
launchJob {
getSettingFlow(flickThresholdSetting).collect {
Key.flickThresholdRatio = toFlickThresholdRatio(it)
}
}

launchJob {
val onNewSubtype: suspend (String) -> Unit = {
val activeSubtype = it.ifEmpty {
Expand Down
32 changes: 32 additions & 0 deletions java/src/org/futo/inputmethod/latin/uix/settings/pages/Typing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ val keySoundVolumeSetting = SettingsKey(
0.0f
)

// Percentage of the key width a swipe has to cover to trigger a flick.
// -1 means "use the built-in default", see FLICK_THRESHOLD_DEFAULT.
val flickThresholdSetting = SettingsKey(
intPreferencesKey("flick_threshold_percent"),
-1
)

const val FLICK_THRESHOLD_DEFAULT = 1.0f / 3.0f

val ActionBarDisplayedSetting = SettingsKey(
booleanPreferencesKey("enable_action_bar"),
true
Expand Down Expand Up @@ -663,6 +672,29 @@ val LongPressMenu = UserSettingsMenu(
steps = 23
)
},

UserSetting(
name = R.string.morekey_settings_flick_threshold,
subtitle = R.string.morekey_settings_flick_threshold_subtitle,
searchTags = R.string.morekey_settings_flick_threshold_tags,
) {
val resources = LocalResources.current
SettingSlider(
title = stringResource(R.string.morekey_settings_flick_threshold),
subtitle = stringResource(R.string.morekey_settings_flick_threshold_subtitle),
setting = flickThresholdSetting,
range = -1.0f .. 100.0f,
hardRange = -1.0f .. 100.0f,
transform = { if(it < 1.0f) -1 else it.roundToInt() },
indicator = {
if(it < 0) {
resources.getString(R.string.morekey_settings_flick_threshold_default)
} else {
"$it%"
}
}
)
},
)
)

Expand Down