Fix keyboard drawing behind nav bar on Android 15

Bug added in 038f693.
This commit is contained in:
Jules Aguillon 2024-12-24 01:10:41 +01:00
parent 2e9f69d58c
commit c13e7608fa

View File

@ -42,6 +42,7 @@ public class Keyboard2View extends View
private Config _config; private Config _config;
private float _keyWidth; private float _keyWidth;
private float _bottomMargin;
private Theme _theme; private Theme _theme;
@ -257,9 +258,7 @@ public class Keyboard2View extends View
{ {
DisplayMetrics dm = getContext().getResources().getDisplayMetrics(); DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
int width = dm.widthPixels; int width = dm.widthPixels;
int height = _bottomMargin = _config.margin_bottom;
(int)(_config.keyHeight * _keyboard.keysHeight
+ _config.marginTop + _config.margin_bottom);
// Compatibility with display cutouts and navigation on the right // Compatibility with display cutouts and navigation on the right
if (VERSION.SDK_INT >= 30) if (VERSION.SDK_INT >= 30)
{ {
@ -270,7 +269,13 @@ public class Keyboard2View extends View
WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars() WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()
| WindowInsets.Type.displayCutout()); | WindowInsets.Type.displayCutout());
width = metrics.getBounds().width() - insets.right - insets.left; width = metrics.getBounds().width() - insets.right - insets.left;
// Starting in API 34, keyboard window has LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
if (VERSION.SDK_INT >= 34)
_bottomMargin += insets.bottom;
} }
int height =
(int)(_config.keyHeight * _keyboard.keysHeight
+ _config.marginTop + _bottomMargin);
setMeasuredDimension(width, height); setMeasuredDimension(width, height);
_keyWidth = (width - (_config.horizontal_margin * 2)) / _keyboard.keysWidth; _keyWidth = (width - (_config.horizontal_margin * 2)) / _keyboard.keysWidth;
} }
@ -287,7 +292,7 @@ public class Keyboard2View extends View
left + (int)_config.horizontal_margin, left + (int)_config.horizontal_margin,
top + (int)_config.marginTop, top + (int)_config.marginTop,
right - (int)_config.horizontal_margin, right - (int)_config.horizontal_margin,
bottom - (int)_config.margin_bottom); bottom - (int)_bottomMargin);
setSystemGestureExclusionRects(Arrays.asList(keyboard_area)); setSystemGestureExclusionRects(Arrays.asList(keyboard_area));
} }
} }