mirror of
https://github.com/florisboard/florisboard.git
synced 2024-09-19 19:42:20 +02:00
Fix Smartbar suggestion UI not updating correctly
This commit is contained in:
parent
9d78661ecb
commit
60221743f6
@ -338,18 +338,6 @@ class FlorisImeService : LifecycleInputMethodService() {
|
||||
nlpManager.clearInlineSuggestions()
|
||||
}
|
||||
|
||||
//override fun onWordHistoryChanged(
|
||||
// currentWord: EditorInstance.Region?,
|
||||
// wordsBeforeCurrent: List<EditorInstance.Region>,
|
||||
// wordsAfterCurrent: List<EditorInstance.Region>,
|
||||
//) {
|
||||
// if (currentWord == null || !currentWord.isValid || !activeState.isComposingEnabled) {
|
||||
// nlpManager.clearSuggestions()
|
||||
// return
|
||||
// }
|
||||
// nlpManager.suggest(currentWord.text, listOf())
|
||||
//}
|
||||
|
||||
override fun onWindowShown() {
|
||||
super.onWindowShown()
|
||||
if (isWindowShown) {
|
||||
|
@ -59,6 +59,7 @@ import dev.patrickgold.florisboard.lib.devtools.flogError
|
||||
import dev.patrickgold.florisboard.lib.ext.ExtensionComponentName
|
||||
import dev.patrickgold.florisboard.lib.observeAsNonNullState
|
||||
import dev.patrickgold.florisboard.lib.util.InputMethodUtils
|
||||
import dev.patrickgold.florisboard.nlpManager
|
||||
import dev.patrickgold.florisboard.subtypeManager
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -66,6 +67,7 @@ import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
data class RenderInfo(
|
||||
val version: Int = 0,
|
||||
@ -84,6 +86,7 @@ class KeyboardManager(context: Context) : InputKeyEventReceiver {
|
||||
private val editorInstance by context.editorInstance()
|
||||
private val extensionManager by context.extensionManager()
|
||||
private val glideTypingManager by context.glideTypingManager()
|
||||
private val nlpManager by context.nlpManager()
|
||||
private val subtypeManager by context.subtypeManager()
|
||||
|
||||
private val scope = CoroutineScope(Dispatchers.Default + SupervisorJob())
|
||||
@ -149,6 +152,18 @@ class KeyboardManager(context: Context) : InputKeyEventReceiver {
|
||||
clipboardManager.primaryClip.observeForever {
|
||||
updateRenderInfo()
|
||||
}
|
||||
scope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
nlpManager.clearSuggestions()
|
||||
}
|
||||
editorInstance.activeContentFlow.collect { content ->
|
||||
if (content.composing.isNotValid || !activeState.isComposingEnabled) {
|
||||
nlpManager.clearSuggestions()
|
||||
return@collect
|
||||
}
|
||||
nlpManager.suggest(content.composingText, listOf())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateRenderInfo(action: () -> Unit = { }) = scope.launch {
|
||||
|
Loading…
Reference in New Issue
Block a user