Android: Hide the keyboard when the height is less than 0

When swiping on a device to do the back gesture then there is no back
key pressed sent so we still need to catch when the keyboard is hidden.
So we can listen for the geometry change and if the height is less than
0 then it is safe to say it is hidden so we update the internal setting
on this.

Fixes: QTBUG-96560
Pick-to: 6.2 5.15
Change-Id: Iec0560935ef914d2cebcb7641a72ab4f71877d23
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Andy Shaw 2021-10-04 16:23:18 +02:00
parent 5c436365f5
commit d0d29a944a

View File

@ -848,6 +848,10 @@ public class QtActivityDelegate
DisplayMetrics metrics = new DisplayMetrics();
m_activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
final int kbHeight = metrics.heightPixels - r.bottom;
if (kbHeight < 0) {
setKeyboardVisibility(false, System.nanoTime());
return true;
}
final int[] location = new int[2];
m_layout.getLocationOnScreen(location);
QtNative.keyboardGeometryChanged(location[0], r.bottom - location[1],