Android: fix for isSoftwareKeyboard method

isSoftwareKeyboard() method will rely on visibility flag from
activityDelegate. In such case it also need to consider that keyboard is
during the hiding.

Fix the regression related with commit:
e6ca200a3a

Before this change Software Keyboard is not showing after changing the
focus. It is happening when Keyboard is already visible and focus is
changed to widget that also need the keyboard. In such case keyboard is
hiding (and NOT showing again).

Pick-to: 5.15
Fixes: QTBUG-92051
Change-Id: I6a5d07b25442429fda6e715d09ea104432c5ef50
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
This commit is contained in:
Bartlomiej Moskal 2021-03-23 10:08:20 +01:00
parent 3e65d0408b
commit e402e1103b
2 changed files with 15 additions and 8 deletions

View File

@ -209,6 +209,11 @@ public class QtActivityDelegate
}
}
public boolean isKeyboardVisible()
{
return m_keyboardIsVisible;
}
// input method hints - must be kept in sync with QTDIR/src/corelib/global/qnamespace.h
private final int ImhHiddenText = 0x1;
private final int ImhSensitiveData = 0x2;
@ -260,7 +265,7 @@ public class QtActivityDelegate
if (m_keyboardIsVisible == visibility)
return false;
m_keyboardIsVisible = visibility;
QtNative.keyboardVisibilityChanged(m_keyboardIsVisible);
QtNative.keyboardVisibilityUpdated(m_keyboardIsVisible);
if (visibility == false)
updateFullScreen(); // Hiding the keyboard clears the immersive mode, so we need to set it again.

View File

@ -99,6 +99,7 @@ public class QtNative
public static final String QtTAG = "Qt JAVA"; // string used for Log.x
private static ArrayList<Runnable> m_lostActions = new ArrayList<Runnable>(); // a list containing all actions which could not be performed (e.g. the main activity is destroyed, etc.)
private static boolean m_started = false;
private static boolean m_isKeyboardHiding = false;
private static int m_displayMetricsScreenWidthPixels = 0;
private static int m_displayMetricsScreenHeightPixels = 0;
private static int m_displayMetricsAvailableLeftPixels = 0;
@ -930,6 +931,7 @@ public class QtNative
private static void hideSoftwareKeyboard()
{
m_isKeyboardHiding = true;
runAction(new Runnable() {
@Override
public void run() {
@ -954,13 +956,7 @@ public class QtNative
public static boolean isSoftwareKeyboardVisible()
{
Activity activity = QtNative.activity();
Rect r = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
final int kbHeight = metrics.heightPixels - r.bottom;
return (kbHeight >= KEYBOARD_HEIGHT_THRESHOLD);
return m_activityDelegate.isKeyboardVisible() && !m_isKeyboardHiding;
}
private static void notifyAccessibilityLocationChange()
@ -1327,6 +1323,12 @@ public class QtNative
});
}
public static void keyboardVisibilityUpdated(boolean visibility)
{
m_isKeyboardHiding = false;
keyboardVisibilityChanged(visibility);
}
private static String[] listAssetContent(android.content.res.AssetManager asset, String path) {
String [] list;
ArrayList<String> res = new ArrayList<String>();