Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit b092080

Browse files
committed
Try to keep Trime working and fix Swiftkey not being able to delete the last character in a word
1 parent b503482 commit b092080

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

platforms/android/library/src/main/java/io/element/android/wysiwyg/inputhandlers/InterceptInputConnection.kt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ internal class InterceptInputConnection(
121121
// Called when started typing
122122
override fun setComposingText(text: CharSequence, newCursorPosition: Int): Boolean {
123123
val (start, end) = getCurrentCompositionOrSelection()
124-
// Some Chinese keyboards send empty text when the user is typing English characters
125-
if (text.isEmpty() && Selection.getSelectionStart(editable) == Selection.getSelectionEnd(editable)) {
126-
finishComposingText()
127-
return false
128-
}
129124
val result = processTextEntry(text, start, end, null)
130125

131126
return if (result != null) {
@@ -284,13 +279,10 @@ internal class InterceptInputConnection(
284279
// append to the current composition with the hardware keyboard.
285280
finishComposingText()
286281

287-
return if (newChars.isDigitsOnly()) {
288-
// Digits should be sent using `commitText`, as that's the default behaviour in the IME
289-
commitText(newChars, 1)
290-
} else {
291-
// Any other printable character can be sent using `setComposingText`
292-
setComposingText(newChars, 1)
293-
}
282+
// We previously tried to have hardware keys behave as composing text, but it's not
283+
// possible, we run into issues where existing keyboards (i.e. Trime) send empty composing
284+
// text and that breaks the input. So we need to use `commitText` instead.
285+
return commitText(newChars, 1)
294286
}
295287

296288
override fun deleteSurroundingText(beforeLength: Int, afterLength: Int): Boolean {

0 commit comments

Comments
 (0)