From 0cb75c28af7e4b99f072197ecb39984e6cb75a34 Mon Sep 17 00:00:00 2001 From: Bartlomiej Moskal Date: Wed, 30 Oct 2024 13:44:13 +0100 Subject: [PATCH] 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 Reviewed-by: Rami Potinkara (cherry picked from commit 34d184911eac07c97f44e87de27f7e37a4ebda81) Reviewed-by: Qt Cherry-pick Bot --- .../jar/src/org/qtproject/qt/android/QtInputConnection.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/android/jar/src/org/qtproject/qt/android/QtInputConnection.java b/src/android/jar/src/org/qtproject/qt/android/QtInputConnection.java index f445810ee62..54798223ab6 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtInputConnection.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtInputConnection.java @@ -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()); } }