File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
app/src/main/java/com/osfans/trime Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import com.osfans.trime.data.opencc.OpenCCDictManager
9
9
import com.osfans.trime.data.prefs.AppPrefs
10
10
import com.osfans.trime.data.schema.SchemaManager
11
11
import com.osfans.trime.util.appContext
12
+ import com.osfans.trime.util.isAsciiPrintable
12
13
import com.osfans.trime.util.isStorageAvailable
13
14
import kotlinx.coroutines.channels.BufferOverflow
14
15
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -214,15 +215,9 @@ class Rime : RimeApi, RimeLifecycleOwner {
214
215
}
215
216
}
216
217
217
- private fun isValidText (text : CharSequence? ): Boolean {
218
- if (text.isNullOrEmpty()) return false
219
- val ch = text.toString().codePointAt(0 )
220
- return ch in 0x20 .. 0x7f
221
- }
222
-
223
218
@JvmStatic
224
219
fun simulateKeySequence (sequence : CharSequence ): Boolean {
225
- if (! isValidText( sequence)) return false
220
+ if (! sequence.first().isAsciiPrintable( )) return false
226
221
Timber .d(" simulateKeySequence: $sequence " )
227
222
return simulateRimeKeySequence(
228
223
sequence.toString().replace(" {}" , " {braceleft}{braceright}" ),
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ import com.osfans.trime.ui.main.settings.ColorPickerDialog
35
35
import com.osfans.trime.ui.main.settings.KeySoundEffectPickerDialog
36
36
import com.osfans.trime.ui.main.settings.ThemePickerDialog
37
37
import com.osfans.trime.util.ShortcutUtils
38
- import com.osfans.trime.util.startsWithAsciiChar
38
+ import com.osfans.trime.util.isAsciiPrintable
39
39
import kotlinx.coroutines.Job
40
40
import kotlinx.coroutines.flow.launchIn
41
41
import kotlinx.coroutines.flow.onEach
@@ -461,7 +461,7 @@ class TextInputManager(
461
461
462
462
override fun onText (text : CharSequence? ) {
463
463
text ? : return
464
- if (! text.startsWithAsciiChar () && Rime .isComposing) {
464
+ if (! text.first().isAsciiPrintable () && Rime .isComposing) {
465
465
Rime .commitComposition()
466
466
trime.commitRimeText()
467
467
}
Original file line number Diff line number Diff line change
1
+ package com.osfans.trime.util
2
+
3
+ @Suppress(" NOTHING_TO_INLINE" )
4
+ inline fun Char.isAsciiPrintable (): Boolean = code in 32 until 127
You can’t perform that action at this time.
0 commit comments