Skip to content

Commit cff2861

Browse files
committed
[[ Bug 22382 ]] Account for soft button bar on Android
This patch adds a function to calculate the height of the soft button bar on android and uses it when determining if the keyboard is visible.
1 parent d1798a6 commit cff2861

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

docs/notes/bugfix-22382.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix incorrect stack size on Android for fullscreen mode `showAll` when the device has a soft button bar

engine/src/java/com/runrev/android/Engine.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,10 +1484,24 @@ boolean keyboardIsVisible()
14841484
int t_screen_height = ((LiveCodeActivity)getContext()).s_main_layout.getRootView().getHeight();
14851485

14861486
// keyboard height equals (screen height - (user app height + status))
1487-
int t_keyboard_height = t_screen_height - (t_app_rect.height() + t_status_bar_height);
1487+
int t_keyboard_height = t_screen_height - (t_app_rect.height() + t_status_bar_height) - getSoftbuttonsbarHeight();
14881488

14891489
return t_keyboard_height > 0;
14901490
}
1491+
1492+
private int getSoftbuttonsbarHeight() {
1493+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
1494+
return 0;
1495+
}
1496+
1497+
DisplayMetrics t_metrics = new DisplayMetrics();
1498+
getWindowManager().getDefaultDisplay().getMetrics(t_metrics);
1499+
int t_usable_height = t_metrics.heightPixels;
1500+
getWindowManager().getDefaultDisplay().getRealMetrics(t_metrics);
1501+
int t_real_height = t_metrics.heightPixels;
1502+
1503+
return t_real_height > t_usable_height ? t_real_height - t_usable_height : 0;
1504+
}
14911505

14921506
void updateKeyboardVisible()
14931507
{

0 commit comments

Comments
 (0)