From c05fdea76554a8e95a8c63f5bb72ca9e0003a382 Mon Sep 17 00:00:00 2001
From: Jules Aguillon
Date: Sun, 13 Feb 2022 15:58:30 +0100
Subject: 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.
---
res/values-fr/strings.xml | 2 +-
res/values-lv/strings.xml | 2 +-
res/values/dimens.xml | 1 +
res/values/strings.xml | 2 +-
res/xml/settings.xml | 2 +-
srcs/juloo.keyboard2/Config.java | 23 +++++++++++++++++++----
6 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index 5588d5d..506b2ad 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -23,7 +23,7 @@
Modifier la vitesse de répétition en bougeant le doigt
Style
Marge du bas
- Hauteur des touches
+ Hauteur du clavier
Marge des côtés
Taille des labels
Taille des caractères affichés sur les touches (%.2fx)
diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml
index 48fccda..0e1c5cd 100644
--- a/res/values-lv/strings.xml
+++ b/res/values-lv/strings.xml
@@ -23,7 +23,7 @@
Mainīt taustiņa atkārtošanās ātrumu ar pavilkšanas attālumu
Izskata pielāgojumi
Apakšējā apmale
- Taustiņa augstums
+ Tastatūras augstums
Līmeniskā apmale
Iezīmes izmērs
Tastatūrā attēloto rakstzīmju izmērs (%.2fx)
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index fce808b..59dbfef 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -12,4 +12,5 @@
56dp
250dp
28dp
+ 20dp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 46754d7..3d68d1f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -23,7 +23,7 @@
Modulate key repeat speed by swiping more or less
Style
Margin bottom
- Key height
+ Keyboard height
Horizontal margin
Label size
Size of characters displayed on the keyboard (%.2fx)
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index 22ec3d0..7ae8542 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -17,7 +17,7 @@
-
+
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"));
--
cgit v1.2.3