Not sure TextEditingController.addListener() can handle all composing changes. https://github.com/rustdesk/rustdesk/issues/7727#issuecomment-2445721499 Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
ce7867c1c0
commit
0f5f9f6524
@ -57,7 +57,9 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
|
|
||||||
final TextEditingController _textController =
|
final TextEditingController _textController =
|
||||||
TextEditingController(text: initText);
|
TextEditingController(text: initText);
|
||||||
bool _lastComposingChangeValid = false;
|
// This timer is used to check the composing status of the soft keyboard.
|
||||||
|
// It is used for Android, Korean(and other similar) input method.
|
||||||
|
Timer? _composingTimer;
|
||||||
|
|
||||||
_RemotePageState(String id) {
|
_RemotePageState(String id) {
|
||||||
initSharedStates(id);
|
initSharedStates(id);
|
||||||
@ -97,9 +99,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
showToast(translate('Automatically record outgoing sessions'));
|
showToast(translate('Automatically record outgoing sessions'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (isAndroid) {
|
|
||||||
_textController.addListener(textAndroidListener);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -115,6 +114,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
_physicalFocusNode.dispose();
|
_physicalFocusNode.dispose();
|
||||||
await gFFI.close();
|
await gFFI.close();
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
|
_composingTimer?.cancel();
|
||||||
gFFI.dialogManager.dismissAll();
|
gFFI.dialogManager.dismissAll();
|
||||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||||
overlays: SystemUiOverlay.values);
|
overlays: SystemUiOverlay.values);
|
||||||
@ -127,16 +127,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
||||||
@ -160,6 +150,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
gFFI.ffiModel.pi.version.isNotEmpty) {
|
gFFI.ffiModel.pi.version.isNotEmpty) {
|
||||||
gFFI.invokeMethod("enable_soft_keyboard", false);
|
gFFI.invokeMethod("enable_soft_keyboard", false);
|
||||||
}
|
}
|
||||||
|
_composingTimer?.cancel();
|
||||||
} else {
|
} else {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timer = Timer(kMobileDelaySoftKeyboardFocus, () {
|
_timer = Timer(kMobileDelaySoftKeyboardFocus, () {
|
||||||
@ -223,8 +214,11 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleNonIOSSoftKeyboardInput(String newValue) {
|
void _handleNonIOSSoftKeyboardInput(String newValue) {
|
||||||
_lastComposingChangeValid = _textController.value.isComposingRangeValid;
|
_composingTimer?.cancel();
|
||||||
if (_lastComposingChangeValid) {
|
if (_textController.value.isComposingRangeValid) {
|
||||||
|
_composingTimer = Timer(Duration(milliseconds: 25), () {
|
||||||
|
_handleNonIOSSoftKeyboardInput(_textController.value.text);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var oldValue = _value;
|
var oldValue = _value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user