Skip to content

Commit

Permalink
tiny fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bingzheung committed Oct 30, 2024
1 parent 5995d18 commit bfdacd9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down Expand Up @@ -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) }
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit bfdacd9

Please sign in to comment.