fix: set text before update accessibility node

This commit is contained in:
mcfans 2023-11-03 10:47:46 +08:00
parent 0a94b7473d
commit c49853e7b4

View File

@ -452,12 +452,12 @@ class InputService : AccessibilityService() {
Log.d(logTag, "existing text:$text textToCommit:$textToCommit textSelectionStart:$textSelectionStart textSelectionEnd:$textSelectionEnd")
if (textToCommit != null) {
var newText = ""
if ((textSelectionStart == -1) || (textSelectionEnd == -1)) {
newText = textToCommit
val newText = textToCommit
this.fakeEditTextForTextStateCalculation?.setText(newText)
success = updateTextForAccessibilityNode(node)
} else if (text != null) {
this.fakeEditTextForTextStateCalculation?.setText(text)
this.fakeEditTextForTextStateCalculation?.text?.insert(textSelectionStart, textToCommit)
success = updateTextAndSelectionForAccessibiltyNode(node)
}