From bfdacd96983094796aedbee1cb9985bfa9557dcf Mon Sep 17 00:00:00 2001 From: Bing ZHEUNG Date: Wed, 30 Oct 2024 15:51:50 +0800 Subject: [PATCH] tiny fixes --- app/src/main/AndroidManifest.xml | 1 - .../jyutping/jyutping/JyutpingInputMethodService.kt | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9b3937c..629e061 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,7 +15,6 @@ android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher" - android:roundIcon="@mipmap/ic_launcher_round" android:label="@string/app_name" android:localeConfig="@xml/locales_config" android:supportsRtl="true" diff --git a/app/src/main/java/org/jyutping/jyutping/JyutpingInputMethodService.kt b/app/src/main/java/org/jyutping/jyutping/JyutpingInputMethodService.kt index 690d319..355ce9b 100644 --- a/app/src/main/java/org/jyutping/jyutping/JyutpingInputMethodService.kt +++ b/app/src/main/java/org/jyutping/jyutping/JyutpingInputMethodService.kt @@ -81,6 +81,7 @@ class JyutpingInputMethodService: LifecycleInputMethodService(), } override fun onStartInput(attribute: EditorInfo?, restarting: Boolean) { super.onStartInput(attribute, restarting) + inputClientMonitorJob?.cancel() val isNightMode = (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES window?.window?.navigationBarColor = if (isNightMode) PresetColor.keyboardDarkBackground.toArgb() else PresetColor.keyboardLightBackground.toArgb() isDarkMode.value = isNightMode @@ -89,10 +90,9 @@ class JyutpingInputMethodService: LifecycleInputMethodService(), qwertyForm.value = QwertyForm.Jyutping updateSpaceKeyForm() updateReturnKeyForm() - inputClientMonitorJob?.cancel() inputClientMonitorJob = CoroutineScope(Dispatchers.Main).launch { while (isActive) { - delay(1500L) // 1.5s + delay(500L) // 0.5s monitorInputClient() } } @@ -392,12 +392,13 @@ class JyutpingInputMethodService: LifecycleInputMethodService(), currentInputConnection.setComposingText(value, value.length) currentInputConnection.finishComposingText() if (isBuffering.value) { - isBuffering.value = false if (isInputMemoryOn.value && selectedCandidates.isNotEmpty()) { userDB.process(selectedCandidates) } selectedCandidates.clear() + isBuffering.value = false } + candidates.value = emptyList() if (keyboardForm.value == KeyboardForm.CandidateBoard) { transformTo(KeyboardForm.Alphabetic) } @@ -406,6 +407,7 @@ class JyutpingInputMethodService: LifecycleInputMethodService(), 'r' -> { if (value.length < 2) { currentInputConnection.setComposingText(value, value.length) + candidates.value = emptyList() } else { val text = value.drop(1) val segmentation = PinyinSegmentor.segment(text, db) @@ -437,6 +439,7 @@ class JyutpingInputMethodService: LifecycleInputMethodService(), updateQwertyForm(QwertyForm.Cangjie) if (value.length < 2) { currentInputConnection.setComposingText(value, value.length) + candidates.value = emptyList() } else { val text = value.drop(1) val converted = text.mapNotNull { ShapeKeyMap.cangjieCode(it) } @@ -459,6 +462,7 @@ class JyutpingInputMethodService: LifecycleInputMethodService(), updateQwertyForm(QwertyForm.Stroke) if (value.length < 2) { currentInputConnection.setComposingText(value, value.length) + candidates.value = emptyList() } else { val text = value.drop(1) val transformed = ShapeKeyMap.strokeTransform(text) @@ -481,6 +485,7 @@ class JyutpingInputMethodService: LifecycleInputMethodService(), 'q' -> { if (value.length < 2) { currentInputConnection.setComposingText(value, value.length) + candidates.value = emptyList() } else { val text = value.drop(1) val segmentation = Segmentor.segment(text, db)