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

Can't type numbers with some keyboards #844

Closed
jonnyandrew opened this issue Oct 15, 2023 · 2 comments
Closed

Can't type numbers with some keyboards #844

jonnyandrew opened this issue Oct 15, 2023 · 2 comments

Comments

@jonnyandrew
Copy link
Contributor

See element-hq/element-x-android#1415

@jonnyandrew
Copy link
Contributor Author

jonnyandrew commented Nov 6, 2023

For anyone wanting to help with this issue, here are some observations from when I looked at it:

The problem seems to be related to the custom InputConnection and/or how it's used by the input method. The input connection expects the input method to call a combination of setComposingText(), commitText() and possibly others to update the current 'composition' (which is usually a word).

IIRC, the issue happens when there is a number (let's say "1") being composed. After pressing space with certain keyboards, the keyboard will call commitText(" ") rather than commitText("1 "), causing the number to be replaced by a space.

The class uses an unusual mixture of inheritance and delegation which makes the problem difficult to debug but also may be related to the issue itself.

internal class InterceptInputConnection(
private val baseInputConnection: InputConnection,
private val editorEditText: TextView,
private val viewModel: EditorViewModel,
) : BaseInputConnection(editorEditText, true) {

override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection {
val baseInputConnection = requireNotNull(super.onCreateInputConnection(outAttrs))
val inputConnection =
InterceptInputConnection(baseInputConnection, this, viewModel)
this.inputConnection = inputConnection
return inputConnection
}

@jonnyandrew
Copy link
Contributor Author

Fixed in #878

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant