Android: Do not use hardcoded value for Keyboard check

This part of code seems to be really old.
Unfortunately in newer device the Navigation Bar is bigger than 100.
So when Navigation Bar is visible - we assumed that keyboard is visible.
That is why this part of code is "dead" for devices with higer resolution.

To make this solution more flexible, we need to rely on the screen size.

Task-number: QTBUG-130000
Change-Id: I387fe58b4c6d22de83394cc8f51c75e7a55e72a1
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
(cherry picked from commit 34d184911eac07c97f44e87de27f7e37a4ebda81)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Bartlomiej Moskal 2024-10-30 13:44:13 +01:00 committed by Qt Cherry-pick Bot
parent 490b2b4c90
commit 0cb75c28af

View File

@ -66,6 +66,9 @@ class QtInputConnection extends BaseInputConnection
private static final int ID_COPY_URL = android.R.id.copyUrl;
private static final int ID_SWITCH_INPUT_METHOD = android.R.id.switchInputMethod;
private static final int ID_ADD_TO_DICTIONARY = android.R.id.addToDictionary;
// We can't rely on a hardcoded value, because screens have different resolutions.
// That is why we assume that the keyboard should be higher than 0.15 of the screen.
private static final float KEYBOARD_TO_SCREEN_RATIO = 0.15f;
private static final String QtTAG = "QtInputConnection";
@ -98,7 +101,7 @@ class QtInputConnection extends BaseInputConnection
screenHeight = maximumWindowMetrics.getBounds().height();
}
final int kbHeight = screenHeight - r.bottom;
if (kbHeight < 100)
if (kbHeight < screenHeight * KEYBOARD_TO_SCREEN_RATIO)
m_qtInputConnectionListener.onHideKeyboardRunnableDone(false, System.nanoTime());
}
}