diff options
| author | Jules Aguillon | 2022-01-30 23:55:15 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2022-01-30 23:55:15 +0100 |
| commit | 2d2f0dd51d5d463f4ed592ff26c0c85e2ba8d296 (patch) | |
| tree | 0669ff47dddf10c54f4033e71cd00a23a5d199b5 /srcs | |
| parent | 8631dfb723716e3273e92b2dfd02008d733b86a9 (diff) | |
| download | unexpected-keyboard-2d2f0dd51d5d463f4ed592ff26c0c85e2ba8d296.tar.gz unexpected-keyboard-2d2f0dd51d5d463f4ed592ff26c0c85e2ba8d296.zip | |
Add options for the spacing between the keys
Two options: vertical and horizontal.
Diffstat (limited to 'srcs')
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index fb55955..427028d 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -14,8 +14,6 @@ final class Config // From resources public final float marginTop; public final float keyPadding; - public final float keyVerticalInterval; - public final float keyHorizontalInterval; // From preferences public int layout; // Or '-1' for the system defaults @@ -28,6 +26,8 @@ final class Config public float marginBottom; public float keyHeight; public float horizontalMargin; + public float keyVerticalInterval; + public float keyHorizontalInterval; public boolean preciseRepeat; public float characterSize; // Ratio public int accents; // Values are R.values.pref_accents_v_* @@ -48,8 +48,6 @@ final class Config // static values marginTop = res.getDimension(R.dimen.margin_top); keyPadding = res.getDimension(R.dimen.key_padding); - keyVerticalInterval = res.getDimension(R.dimen.key_vertical_interval); - keyHorizontalInterval = res.getDimension(R.dimen.key_horizontal_interval); // default values layout = -1; vibrateEnabled = true; @@ -59,6 +57,8 @@ final class Config 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; @@ -89,6 +89,8 @@ final class Config 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); + 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; @@ -101,8 +103,10 @@ final class Config private float getDipPref(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def) { - int value = prefs.getInt(pref_name, -1); - if (value < 0) + float value; + try { value = prefs.getInt(pref_name, -1); } + catch (Exception e) { value = prefs.getFloat(pref_name, -1f); } + if (value < 0f) return (def); return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, dm)); } |
