abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorJules Aguillon2022-12-31 14:00:38 +0100
committerJules Aguillon2022-12-31 14:00:38 +0100
commitc5f5a23d75183823db8a8e02049c5c72f504a77c (patch)
tree2184fc85d7570f67dd3a0b62ca45713de06dc63d
parent73ef7c67652ab05bac07fcb3fb178a24cae29d60 (diff)
downloadunexpected-keyboard-c5f5a23d75183823db8a8e02049c5c72f504a77c.tar.gz
unexpected-keyboard-c5f5a23d75183823db8a8e02049c5c72f504a77c.zip
Fix dimensions going off after rotation
Values like 'characterSize' and 'horizontalMargin' can't be fed back into the default value because they are not of the same unit. To avoid this happening again, change the way the default value is defined for every options. The 'key_height' dimension was no longer used.
-rw-r--r--res/values/values.xml1
-rw-r--r--srcs/juloo.keyboard2/Config.java37
2 files changed, 13 insertions, 25 deletions
diff --git a/res/values/values.xml b/res/values/values.xml
index 07fb654..05e10c1 100644
--- a/res/values/values.xml
+++ b/res/values/values.xml
@@ -6,7 +6,6 @@
<dimen name="key_padding">2dp</dimen>
<dimen name="key_vertical_interval">2dp</dimen>
<dimen name="key_horizontal_interval">2dp</dimen>
- <dimen name="key_height">51dp</dimen>
<dimen name="emoji_type_button_height">56dp</dimen>
<dimen name="emoji_grid_height">250dp</dimen>
<dimen name="emoji_text_size">28dp</dimen>
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index aa053b5..9557a00 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -67,21 +67,6 @@ final class Config
keyPadding = res.getDimension(R.dimen.key_padding);
labelTextSize = 0.33f;
sublabelTextSize = 0.22f;
- // default values
- layout = null;
- second_layout = null;
- custom_layout = null;
- vibrateEnabled = true;
- longPressTimeout = 600;
- longPressInterval = 65;
- marginBottom = res.getDimension(R.dimen.margin_bottom);
- keyHeight = res.getDimension(R.dimen.key_height);
- horizontalMargin = res.getDimension(R.dimen.horizontal_margin);
- keyVerticalInterval = res.getDimension(R.dimen.key_vertical_interval);
- keyHorizontalInterval = res.getDimension(R.dimen.key_horizontal_interval);
- preciseRepeat = true;
- characterSize = 1.f;
- accents = 1;
// from prefs
refresh(res);
// initialized later
@@ -132,13 +117,16 @@ final class Config
float swipe_scaling = Math.min(dm.widthPixels, dm.heightPixels) / 10.f * dpi_ratio;
float swipe_dist_value = Float.valueOf(_prefs.getString("swipe_dist", "15"));
swipe_dist_px = swipe_dist_value / 25.f * swipe_scaling;
- vibrateEnabled = _prefs.getBoolean("vibrate_enabled", vibrateEnabled);
- longPressTimeout = _prefs.getInt("longpress_timeout", (int)longPressTimeout);
- longPressInterval = _prefs.getInt("longpress_interval", (int)longPressInterval);
- marginBottom = getDipPref(dm, _prefs, "margin_bottom", marginBottom);
- keyVerticalInterval = getDipPref(dm, _prefs, "key_vertical_space", keyVerticalInterval);
+ vibrateEnabled = _prefs.getBoolean("vibrate_enabled", true);
+ longPressTimeout = _prefs.getInt("longpress_timeout", 600);
+ longPressInterval = _prefs.getInt("longpress_interval", 65);
+ marginBottom = getDipPref(dm, _prefs, "margin_bottom",
+ res.getDimension(R.dimen.margin_bottom));
+ keyVerticalInterval = getDipPref(dm, _prefs, "key_vertical_space",
+ res.getDimension(R.dimen.key_vertical_interval));
keyHorizontalInterval =
- getDipPref(dm, _prefs, "key_horizontal_space", keyHorizontalInterval)
+ getDipPref(dm, _prefs, "key_horizontal_space",
+ res.getDimension(R.dimen.key_horizontal_interval))
* horizontalIntervalScale;
// Label brightness is used as the alpha channel
labelBrightness = _prefs.getInt("label_brightness", 100) * 255 / 100;
@@ -150,12 +138,13 @@ final class Config
// during rendered.
keyHeight = dm.heightPixels * keyboardHeightPercent / 100 / 4;
horizontalMargin =
- getDipPref(dm, _prefs, "horizontal_margin", horizontalMargin)
+ getDipPref(dm, _prefs, "horizontal_margin",
+ res.getDimension(R.dimen.horizontal_margin))
+ res.getDimension(R.dimen.extra_horizontal_margin);
- preciseRepeat = _prefs.getBoolean("precise_repeat", preciseRepeat);
+ preciseRepeat = _prefs.getBoolean("precise_repeat", true);
double_tap_lock_shift = _prefs.getBoolean("lock_double_tap", false);
characterSize =
- _prefs.getFloat("character_size", characterSize)
+ _prefs.getFloat("character_size", 1.f)
* characterSizeScale;
accents = Integer.valueOf(_prefs.getString("accents", "1"));
theme = getThemeId(res, _prefs.getString("theme", ""));