From 9c93f8b7421de668c43505e25b45eedd34aff6a5 Mon Sep 17 00:00:00 2001 From: miroyong Date: Wed, 12 Aug 2026 11:45:52 -0300 Subject: [PATCH] Reserve bottom inset so system IME bar doesn't cover bottom row The keyboard fills its full window height, so the bottom row of keys sits flush against the bottom of the screen, underneath the system IME bar (arrow-to-hide + language globe). Reserve the system's bottom window inset in KeyboardLayoutView so the bottom row stays visible above that bar. --- .../layout/ui/KeyboardLayoutView.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/gazlaws/codeboard/layout/ui/KeyboardLayoutView.java b/app/src/main/java/com/gazlaws/codeboard/layout/ui/KeyboardLayoutView.java index 141e06bb..b400677c 100644 --- a/app/src/main/java/com/gazlaws/codeboard/layout/ui/KeyboardLayoutView.java +++ b/app/src/main/java/com/gazlaws/codeboard/layout/ui/KeyboardLayoutView.java @@ -7,12 +7,16 @@ import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; +import android.view.WindowInsets; import com.gazlaws.codeboard.theme.UiTheme; public class KeyboardLayoutView extends ViewGroup { private final UiTheme uiTheme; + // Height of the system IME bar (arrow-to-hide + language globe) at the + // bottom of the screen. Reserving it keeps the bottom row of keys visible. + private int bottomInset = 0; public KeyboardLayoutView(Context context, UiTheme uiTheme) { super(context); @@ -35,12 +39,36 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension(availableWidth, (int)(availableHeight * keyboardSize)); } + @Override + public WindowInsets onApplyWindowInsets(WindowInsets insets) { + updateBottomInset(insets.getSystemWindowInsetBottom()); + return insets; + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (getRootWindowInsets() != null) { + updateBottomInset(getRootWindowInsets().getSystemWindowInsetBottom()); + } + } + + private void updateBottomInset(int inset) { + if (inset != bottomInset) { + bottomInset = inset; + requestLayout(); + } + } + @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { + // Reserve the system IME bar height at the bottom so the bottom row of + // keys is not hidden underneath the arrow-to-hide / language globe bar. + int contentBottom = b - bottomInset; final int count = getChildCount(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); - child.layout(l,t,r,b); + child.layout(l, t, r, contentBottom); } }