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:
parent
3e65d0408b
commit
e402e1103b
@ -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
|
// input method hints - must be kept in sync with QTDIR/src/corelib/global/qnamespace.h
|
||||||
private final int ImhHiddenText = 0x1;
|
private final int ImhHiddenText = 0x1;
|
||||||
private final int ImhSensitiveData = 0x2;
|
private final int ImhSensitiveData = 0x2;
|
||||||
@ -260,7 +265,7 @@ public class QtActivityDelegate
|
|||||||
if (m_keyboardIsVisible == visibility)
|
if (m_keyboardIsVisible == visibility)
|
||||||
return false;
|
return false;
|
||||||
m_keyboardIsVisible = visibility;
|
m_keyboardIsVisible = visibility;
|
||||||
QtNative.keyboardVisibilityChanged(m_keyboardIsVisible);
|
QtNative.keyboardVisibilityUpdated(m_keyboardIsVisible);
|
||||||
|
|
||||||
if (visibility == false)
|
if (visibility == false)
|
||||||
updateFullScreen(); // Hiding the keyboard clears the immersive mode, so we need to set it again.
|
updateFullScreen(); // Hiding the keyboard clears the immersive mode, so we need to set it again.
|
||||||
|
@ -99,6 +99,7 @@ public class QtNative
|
|||||||
public static final String QtTAG = "Qt JAVA"; // string used for Log.x
|
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 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_started = false;
|
||||||
|
private static boolean m_isKeyboardHiding = false;
|
||||||
private static int m_displayMetricsScreenWidthPixels = 0;
|
private static int m_displayMetricsScreenWidthPixels = 0;
|
||||||
private static int m_displayMetricsScreenHeightPixels = 0;
|
private static int m_displayMetricsScreenHeightPixels = 0;
|
||||||
private static int m_displayMetricsAvailableLeftPixels = 0;
|
private static int m_displayMetricsAvailableLeftPixels = 0;
|
||||||
@ -930,6 +931,7 @@ public class QtNative
|
|||||||
|
|
||||||
private static void hideSoftwareKeyboard()
|
private static void hideSoftwareKeyboard()
|
||||||
{
|
{
|
||||||
|
m_isKeyboardHiding = true;
|
||||||
runAction(new Runnable() {
|
runAction(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -954,13 +956,7 @@ public class QtNative
|
|||||||
|
|
||||||
public static boolean isSoftwareKeyboardVisible()
|
public static boolean isSoftwareKeyboardVisible()
|
||||||
{
|
{
|
||||||
Activity activity = QtNative.activity();
|
return m_activityDelegate.isKeyboardVisible() && !m_isKeyboardHiding;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void notifyAccessibilityLocationChange()
|
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) {
|
private static String[] listAssetContent(android.content.res.AssetManager asset, String path) {
|
||||||
String [] list;
|
String [] list;
|
||||||
ArrayList<String> res = new ArrayList<String>();
|
ArrayList<String> res = new ArrayList<String>();
|
||||||
|
Loading…
Reference in New Issue
Block a user