fix: android input do not handle composing (#9790)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-10-31 10:20:57 +08:00 committed by GitHub
parent f86c88b3d8
commit 4c12b83068
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,7 +59,6 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
final TextEditingController _textController =
TextEditingController(text: initText);
bool _lastComposingChangeValid = false;
_RemotePageState(String id) {
initSharedStates(id);
@ -99,9 +98,6 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
showToast(translate('Automatically record outgoing sessions'));
}
});
if (isAndroid) {
_textController.addListener(textAndroidListener);
}
WidgetsBinding.instance.addObserver(this);
}
@ -132,9 +128,6 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
// The inner logic of `on_voice_call_closed` will check if the voice call is active.
// Only one client is considered here for now.
gFFI.chatModel.onVoiceCallClosed("End connetion");
if (isAndroid) {
_textController.removeListener(textAndroidListener);
}
}
@override
@ -145,13 +138,6 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
});
}
// This listener is used to handle the composing region changes for Android soft keyboard input.
void textAndroidListener() {
if (_lastComposingChangeValid) {
_handleNonIOSSoftKeyboardInput(_textController.text);
}
}
// to-do: It should be better to use transparent color instead of the bgColor.
// But for now, the transparent color will cause the canvas to be white.
// I'm sure that the white color is caused by the Overlay widget in BlockableOverlay.
@ -236,12 +222,6 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
}
void _handleNonIOSSoftKeyboardInput(String newValue) {
_lastComposingChangeValid = _textController.value.isComposingRangeValid;
if (_lastComposingChangeValid && newValue.length > _value.length) {
// Only early return if is composing new words.
// We need to send `backspace` immediately if is deleting letters.
return;
}
var oldValue = _value;
_value = newValue;
if (oldValue.isNotEmpty &&