From 2a50a4a129f96784af15f82c0a5d9b09d780dd61 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Fri, 30 May 2025 00:08:59 +0200 Subject: Fix high keyboard height making it overflows The calculation for the size of each rows now avoid making the keyboard bigger than the screen if the Keyboard Height option is unusually high. The height calculation with the default settings is changed slightly, it is now assuming that a layout is 3.95 rows high instead of 4. This is because the bottom row is usually 0.95% the size of other rows. --- srcs/juloo.keyboard2/Theme.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'srcs/juloo.keyboard2/Theme.java') diff --git a/srcs/juloo.keyboard2/Theme.java b/srcs/juloo.keyboard2/Theme.java index c5f3e20..9af0d01 100644 --- a/srcs/juloo.keyboard2/Theme.java +++ b/srcs/juloo.keyboard2/Theme.java @@ -94,14 +94,23 @@ public class Theme public final float horizontal_margin; public final float margin_top; public final float margin_left; + public final float row_height; public final Paint indication_paint; public final Key key; public final Key key_activated; - public Computed(Theme theme, Config config, float keyWidth) + public Computed(Theme theme, Config config, float keyWidth, KeyboardData layout) { - vertical_margin = config.key_vertical_margin * config.keyHeight; + // Rows height is proportional to the keyboard height, meaning it doesn't + // change for layouts with more or less rows. 3.95 is the usual height of + // a layout in KeyboardData unit. The keyboard will be higher if the + // layout has more rows and smaller if it has less because rows stay the + // same height. + row_height = Math.min( + config.screenHeightPixels * config.keyboardHeightPercent / 100 / 3.95f, + config.screenHeightPixels / layout.keysHeight); + vertical_margin = config.key_vertical_margin * row_height; horizontal_margin = config.key_horizontal_margin * keyWidth; // Add half of the key margin on the left and on the top as it's also // added on the right and on the bottom of every keys. -- cgit v1.2.3