An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
fix: use seq for translate mode and use commitText
mcfansdd33c0e58288
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.ktindex 9df9b1a48..76c1ead6d 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@@ -21,10 +21,12 @@ import android.accessibilityservice.AccessibilityServiceInfoimport android.accessibilityservice.AccessibilityServiceInfo.FLAG_INPUT_METHOD_EDITORimport androidx.annotation.RequiresApiimport java.util.*+import java.lang.Characterimport kotlin.math.absimport kotlin.math.max-import hbb.MessageOuterClass.KeyEvent;-import hbb.KeyEventConverter;+import hbb.MessageOuterClass.KeyEvent+import hbb.MessageOuterClass.KeyboardMode+import hbb.KeyEventConverterconst val LIFT_DOWN = 9const val LIFT_MOVE = 8@@ -265,12 +267,39 @@ class InputService : AccessibilityService() {@RequiresApi(Build.VERSION_CODES.N)fun onKeyEvent(data: ByteArray) {- val keyEvent = KeyEvent.parseFrom(data);+ val keyEvent = KeyEvent.parseFrom(data)+ val down = keyEvent.getDown()+ val keyboardMode = keyEvent.getMode()++ var textToCommit: String? = null++ if (keyboardMode == KeyboardMode.Legacy) {+ if (keyEvent.hasChr() && keyEvent.getDown()) {+ val chr = keyEvent.getChr()+ if (chr != null) {+ textToCommit = String(Character.toChars(chr))+ }+ }+ } else if (keyboardMode == KeyboardMode.Translate) {+ if (keyEvent.hasSeq() && keyEvent.getDown()) {+ val seq = keyEvent.getSeq()+ if (seq != null) {+ textToCommit = seq+ }+ }+ }+if (Build.VERSION.SDK_INT >= 33) {getInputMethod()?.let { inputMethod ->inputMethod.getCurrentInputConnection()?.let { inputConnection ->- KeyEventConverter.toAndroidKeyEvent(keyEvent).let { event ->- inputConnection.sendKeyEvent(event)+ if (textToCommit != null) {+ textToCommit?.let { text ->+ inputConnection.commitText(text, 1, null)+ }+ } else {+ KeyEventConverter.toAndroidKeyEvent(keyEvent).let { event ->+ inputConnection.sendKeyEvent(event)+ }}}}@@ -296,26 +325,24 @@ class InputService : AccessibilityService() {}}- if (keyEvent.hasSeq()) {- val seq = keyEvent.getSeq()-+ if (textToCommit != null) {var newText = ""if ((textSelectionStart == -1) || (textSelectionEnd == -1)) {- newText = seq- } else {+ newText = textToCommit+ } else if (text != null) {+ Log.d(logTag, "text selection start $textSelectionStart $textSelectionEnd")newText = text.let {- it.substring(0, textSelectionStart) + seq + it.substring(textSelectionStart)+ it.substring(0, textSelectionStart) + textToCommit + it.substring(textSelectionStart)}}val arguments = Bundle()arguments.putCharSequence(- AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,- newText+ AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,+ newText)node.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments)-} else {KeyEventConverter.toAndroidKeyEvent(keyEvent).let { event ->if (isShowingHint) {@@ -332,7 +359,6 @@ class InputService : AccessibilityService() {this.fakeEditTextForTextStateCalculation?.dispatchKeyEvent(event)this.fakeEditTextForTextStateCalculation?.getText()?.let { newText ->- Log.d(logTag, "event $event text $text newText $newText")val arguments = Bundle()arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,