From c49853e7b4b4d41521e4a3579d7bb205069f2e3d Mon Sep 17 00:00:00 2001 From: mcfans Date: Fri, 3 Nov 2023 10:47:46 +0800 Subject: [PATCH] fix: set text before update accessibility node --- .../src/main/kotlin/com/carriez/flutter_hbb/InputService.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt index 598139567..adb888695 100644 --- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt +++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt @@ -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) }