diff options
| author | Jules Aguillon | 2022-02-13 15:58:30 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2022-02-13 15:58:30 +0100 |
| commit | c05fdea76554a8e95a8c63f5bb72ca9e0003a382 (patch) | |
| tree | 059e544418dcf68c137bbb432e33b96866245e74 /srcs/juloo.keyboard2 | |
| parent | 4e98ab7515e58a1166acb36dc852166e3876fa56 (diff) | |
| download | unexpected-keyboard-c05fdea76554a8e95a8c63f5bb72ca9e0003a382.tar.gz unexpected-keyboard-c05fdea76554a8e95a8c63f5bb72ca9e0003a382.zip | |
Define the height of the keyboard relative to the screen size
Depending on the pixel density isn't ideal for a keyboard, which would
render differently depending on the "scaling" accessibility option.
Landscape mode needs a special values. At the same time, increase the
horizontal margin when landscape.
Diffstat (limited to 'srcs/juloo.keyboard2')
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 66b9239..2a2be30 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -81,6 +81,21 @@ final class Config SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Resources res = context.getResources(); DisplayMetrics dm = res.getDisplayMetrics(); + // The height of the keyboard is relative to the height of the screen. This + // is not the actual size of the keyboard, which will be bigger if the + // layout has a fifth row. + int keyboardHeightPercent; + float extra_horizontal_margin; + if (res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) // Landscape mode + { + keyboardHeightPercent = 55; + extra_horizontal_margin = res.getDimension(R.dimen.landscape_extra_horizontal_margin); + } + else + { + keyboardHeightPercent = prefs.getInt("keyboard_height", 35); + extra_horizontal_margin = 0.f; + } layout = layoutId_of_string(prefs.getString("layout", "system")); swipe_dist_dp = Float.valueOf(prefs.getString("swipe_dist", "15")); swipe_dist_px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, swipe_dist_dp, dm); @@ -91,10 +106,10 @@ final class Config marginBottom = getDipPref(dm, prefs, "margin_bottom", marginBottom); keyVerticalInterval = getDipPref(dm, prefs, "key_vertical_space", keyVerticalInterval); keyHorizontalInterval = getDipPref(dm, prefs, "key_horizontal_space", keyHorizontalInterval); - // Add keyVerticalInterval to keyHeight because the space between the keys - // is removed from the keys during rendering - keyHeight = getDipPref(dm, prefs, "key_height", keyHeight) + keyVerticalInterval; - horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin); + // Do not substract keyVerticalInterval from keyHeight because this is done + // during rendered. + keyHeight = dm.heightPixels * keyboardHeightPercent / 100 / 4; + horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin) + extra_horizontal_margin; preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat); characterSize = prefs.getFloat("character_size", characterSize); accents = Integer.valueOf(prefs.getString("accents", "1")); |
