fix: android input do not handle composing (#9790)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
f86c88b3d8
commit
4c12b83068
@ -59,7 +59,6 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
final TextEditingController _textController =
|
final TextEditingController _textController =
|
||||||
TextEditingController(text: initText);
|
TextEditingController(text: initText);
|
||||||
bool _lastComposingChangeValid = false;
|
|
||||||
|
|
||||||
_RemotePageState(String id) {
|
_RemotePageState(String id) {
|
||||||
initSharedStates(id);
|
initSharedStates(id);
|
||||||
@ -99,9 +98,6 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
showToast(translate('Automatically record outgoing sessions'));
|
showToast(translate('Automatically record outgoing sessions'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (isAndroid) {
|
|
||||||
_textController.addListener(textAndroidListener);
|
|
||||||
}
|
|
||||||
WidgetsBinding.instance.addObserver(this);
|
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.
|
// The inner logic of `on_voice_call_closed` will check if the voice call is active.
|
||||||
// Only one client is considered here for now.
|
// Only one client is considered here for now.
|
||||||
gFFI.chatModel.onVoiceCallClosed("End connetion");
|
gFFI.chatModel.onVoiceCallClosed("End connetion");
|
||||||
if (isAndroid) {
|
|
||||||
_textController.removeListener(textAndroidListener);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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.
|
// 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.
|
// 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.
|
// 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) {
|
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;
|
var oldValue = _value;
|
||||||
_value = newValue;
|
_value = newValue;
|
||||||
if (oldValue.isNotEmpty &&
|
if (oldValue.isNotEmpty &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user