Android: Fix text update issues with fullscreen virtual keyboard

In commit 1f6d7cbb341bd79826d3f6d69e1f1a427ebb8f1b, we introduced
support for the full-screen software keyboard.

However, this revealed issues with text not updating correctly in the
view, particularly with composing text.

This commit addresses the problem by adding calls of [0]restartInput()
in three methods: setComposingText, deleteSurroundingText and
setSelection.

These calls help synchronize the editable state with the input method
and ensure the displayed text remains consistent and up-to-date.

There is one more issue that needs to be solved: QTBUG-136229

[0]https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#restartInput(android.view.View)

Pick-to: 6.8
Fixes: QTBUG-135376
Fixes: QTBUG-128745
Fixes: QTBUG-130058
Change-Id: I3f905dd02cb3bfe5046b01164412f328160b7a8b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit ab98013efc16766bb7a538f86b0b9de8db6634ff)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Bartlomiej Moskal 2025-04-24 20:39:07 +02:00 committed by Qt Cherry-pick Bot
parent 7872575437
commit 066d99bb2b

View File

@ -167,15 +167,18 @@ class QtInputConnection extends BaseInputConnection
public boolean commitText(CharSequence text, int newCursorPosition)
{
setClosing(false);
boolean result = QtNativeInputConnection.commitText(text.toString(), newCursorPosition);
restartImmInput();
return QtNativeInputConnection.commitText(text.toString(), newCursorPosition);
return result;
}
@Override
public boolean deleteSurroundingText(int leftLength, int rightLength)
{
setClosing(false);
return QtNativeInputConnection.deleteSurroundingText(leftLength, rightLength);
boolean result = QtNativeInputConnection.deleteSurroundingText(leftLength, rightLength);
restartImmInput();
return result;
}
@Override
@ -308,7 +311,9 @@ class QtInputConnection extends BaseInputConnection
public boolean setComposingText(CharSequence text, int newCursorPosition)
{
setClosing(false);
return QtNativeInputConnection.setComposingText(text.toString(), newCursorPosition);
boolean result = QtNativeInputConnection.setComposingText(text.toString(), newCursorPosition);
restartImmInput();
return result;
}
@TargetApi(33)
@ -351,6 +356,8 @@ class QtInputConnection extends BaseInputConnection
public boolean setSelection(int start, int end)
{
setClosing(false);
return QtNativeInputConnection.setSelection(start, end);
boolean result = QtNativeInputConnection.setSelection(start, end);
restartImmInput();
return result;
}
}