Compare commits

...

4 Commits

Author SHA1 Message Date
Patrick Goldinger
64040f0407 Release v0.3.12 2021-05-10 15:47:05 +02:00
Patrick Goldinger
0c1abdd507 Merge pull request #850 from X-yl/master
Stop glide suggestions disappearing and remove the redundant first suggestion
2021-05-10 15:28:21 +02:00
Patrick Goldinger
53594e3343 Fix glide logic not triggering when shift/caps is active (#847) 2021-05-10 15:22:45 +02:00
X-yl
c6c06b87c5 Stop glide suggestions disappearing and remove redundant first option 2021-05-10 16:52:50 +04:00
5 changed files with 27 additions and 12 deletions

View File

@@ -24,8 +24,8 @@ android {
applicationId = "dev.patrickgold.florisboard"
minSdkVersion(23)
targetSdkVersion(30)
versionCode(42)
versionName("0.3.11")
versionCode(43)
versionName("0.3.12")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -444,7 +444,7 @@ class TextInputManager private constructor() : CoroutineScope by MainScope(), In
}
smartbarView?.updateSmartbarState()
flogInfo(LogTopic.IMS_EVENTS) { "current word: ${activeEditorInstance.cachedInput.currentWord.text}" }
if (activeEditorInstance.isComposingEnabled && !inputEventDispatcher.isPressed(KeyCode.DELETE)) {
if (activeEditorInstance.isComposingEnabled && !inputEventDispatcher.isPressed(KeyCode.DELETE) && !isGlidePostEffect) {
if (activeEditorInstance.shouldReevaluateComposingSuggestions) {
activeEditorInstance.shouldReevaluateComposingSuggestions = false
activeDictionary?.let {

View File

@@ -10,6 +10,7 @@ import dev.patrickgold.florisboard.ime.text.TextInputManager
import dev.patrickgold.florisboard.ime.text.keyboard.TextKey
import kotlinx.coroutines.*
import org.json.JSONObject
import kotlin.math.min
/**
* Handles the [GlideTypingClassifier]. Basically responsible for linking [GlideTypingGesture.Detector]
@@ -62,6 +63,7 @@ class GlideTypingManager : GlideTypingGesture.Listener, CoroutineScope by MainSc
}
private val wordDataCache = hashMapOf<String, Int>()
/**
* Set the word data for the internal gesture classifier
*/
@@ -70,7 +72,8 @@ class GlideTypingManager : GlideTypingGesture.Listener, CoroutineScope by MainSc
if (wordDataCache.isEmpty()) {
// FIXME: get this info from dictionary.
val data =
AssetManager.default().loadTextAsset(AssetRef(AssetSource.Assets, "ime/dict/data.json")).getOrThrow()
AssetManager.default().loadTextAsset(AssetRef(AssetSource.Assets, "ime/dict/data.json"))
.getOrThrow()
val json = JSONObject(data)
wordDataCache.putAll(json.keys().asSequence().map { Pair(it, json.getInt(it)) })
}
@@ -102,7 +105,10 @@ class GlideTypingManager : GlideTypingGesture.Listener, CoroutineScope by MainSc
textInputManager.isGlidePostEffect = true
textInputManager.smartbarView?.setCandidateSuggestionWords(
time,
suggestions.take(maxSuggestionsToShow).map { textInputManager.fixCase(it) }
suggestions.subList(
1.coerceAtMost(min(commit.compareTo(false), suggestions.size)),
maxSuggestionsToShow.coerceAtMost(suggestions.size)
).map { textInputManager.fixCase(it) }
)
textInputManager.smartbarView?.updateCandidateSuggestionCapsState()
if (commit && suggestions.isNotEmpty()) {

View File

@@ -4,14 +4,18 @@ import android.util.SparseArray
import androidx.collection.LruCache
import androidx.core.util.set
import dev.patrickgold.florisboard.ime.core.Subtype
import dev.patrickgold.florisboard.ime.keyboard.Key
import dev.patrickgold.florisboard.ime.text.key.KeyCode
import dev.patrickgold.florisboard.ime.text.keyboard.TextKey
import dev.patrickgold.florisboard.ime.text.keyboard.TextKeyData
import java.text.Normalizer
import java.util.*
import kotlin.collections.HashMap
import kotlin.math.*
private fun TextKey.baseCode(): Int {
return (data as? TextKeyData)?.code ?: KeyCode.UNSPECIFIED
}
/**
* Classifies gestures by comparing them with an "ideal gesture".
*
@@ -95,7 +99,7 @@ class StatisticalGlideTypingClassifier : GlideTypingClassifier {
keysByCharacter.clear()
keys.clear()
keyViews.forEach {
keysByCharacter[it.computedData.code] = it
keysByCharacter[it.baseCode()] = it
keys.add(it)
}
layoutSubtype = subtype
@@ -271,7 +275,7 @@ class StatisticalGlideTypingClassifier : GlideTypingClassifier {
* @return A list of likely words.
*/
fun pruneByExtremities(
userGesture: Gesture, keys: Iterable<Key>
userGesture: Gesture, keys: Iterable<TextKey>
): ArrayList<String> {
val remainingWords = ArrayList<String>()
val startX = userGesture.getFirstX()
@@ -338,7 +342,7 @@ class StatisticalGlideTypingClassifier : GlideTypingClassifier {
else -> {
val firstKey = keysByCharacter[firstBaseChar.code]
val lastKey = keysByCharacter[lastBaseChar.code]
Pair(firstKey.computedData.code, lastKey.computedData.code)
Pair(firstKey.baseCode(), lastKey.baseCode())
}
}
}
@@ -353,16 +357,16 @@ class StatisticalGlideTypingClassifier : GlideTypingClassifier {
* @return A list of the n closest keys.
*/
private fun findNClosestKeys(
x: Float, y: Float, n: Int, keys: Iterable<Key>
x: Float, y: Float, n: Int, keys: Iterable<TextKey>
): Iterable<Int> {
val keyDistances = HashMap<Key, Float>()
val keyDistances = HashMap<TextKey, Float>()
for (key in keys) {
val distance = Gesture.distance(key.visibleBounds.centerX().toFloat(), key.visibleBounds.centerY().toFloat(), x, y)
keyDistances[key] = distance
}
return keyDistances.entries.sortedWith { c1, c2 -> c1.value.compareTo(c2.value) }.take(n)
.map { (it.key as? TextKey)?.computedData?.code ?: KeyCode.UNSPECIFIED }
.map { it.key.baseCode() }
}
}

View File

@@ -0,0 +1,5 @@
This version is a hotfix release which makes glide typing
fully usable again (in v0.3.11 you couldn't glide while shift
or caps was active).
Detailed changelog: https://github.com/florisboard/florisboard/releases/tag/v0.3.12