fix: android, Korean input (#9667)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-10-18 08:55:18 +08:00 committed by GitHub
parent 53d11e99d7
commit 0d3243e6dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -57,6 +57,9 @@ class _RemotePageState extends State<RemotePage> {
final TextEditingController _textController = final TextEditingController _textController =
TextEditingController(text: initText); TextEditingController(text: initText);
// 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);
@ -104,6 +107,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);
@ -139,6 +143,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, () {
@ -202,6 +207,13 @@ class _RemotePageState extends State<RemotePage> {
} }
void _handleNonIOSSoftKeyboardInput(String newValue) { void _handleNonIOSSoftKeyboardInput(String newValue) {
_composingTimer?.cancel();
if (_textController.value.isComposingRangeValid) {
_composingTimer = Timer(Duration(milliseconds: 25), () {
_handleNonIOSSoftKeyboardInput(_textController.value.text);
});
return;
}
var oldValue = _value; var oldValue = _value;
_value = newValue; _value = newValue;
if (oldValue.isNotEmpty && if (oldValue.isNotEmpty &&