diff options
| author | Jules Aguillon | 2021-12-30 21:59:48 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2021-12-30 21:59:48 +0100 |
| commit | 8bef0728ae61e70291d3ea8f2e583e9fc94aff0d (patch) | |
| tree | 515c11bde850f251773da88f7cf39cc099215147 | |
| parent | b05f6e84475d2c6fcc2d400efbc5882b9fcc38e2 (diff) | |
| download | unexpected-keyboard-8bef0728ae61e70291d3ea8f2e583e9fc94aff0d.tar.gz unexpected-keyboard-8bef0728ae61e70291d3ea8f2e583e9fc94aff0d.zip | |
Turn the "precision" option to dp instead of px
| -rw-r--r-- | res/values/strings.xml | 2 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 18 |
2 files changed, 14 insertions, 6 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index b41fdc5..ca31dca 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12,7 +12,7 @@ <string name="pref_accents_e_none">Hide accents</string> <string name="pref_category_typing">Typing</string> <string name="pref_preci_title">Precision</string> - <string name="pref_preci_summary">Distance of corner values (%spx)</string> + <string name="pref_preci_summary">Distance of corner values (%sdp)</string> <string name="pref_long_timeout_title">Long press timeout</string> <string name="pref_long_interval_title">Long press interval</string> <string name="pref_category_vibrate">Vibration</string> diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 254f57c..7123043 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -73,21 +73,21 @@ final class Config SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); DisplayMetrics dm = context.getResources().getDisplayMetrics(); layout = layoutId_of_string(prefs.getString("layout", "system")); - subValueDist = prefs.getFloat("sub_value_dist", subValueDist); + subValueDist = getDipPrefFloat(dm, prefs, "sub_value_dist", subValueDist); vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled); vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration); longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout); longPressInterval = prefs.getInt("longpress_interval", (int)longPressInterval); - marginBottom = getDipPref(dm, prefs, "margin_bottom", marginBottom); - keyHeight = getDipPref(dm, prefs, "key_height", keyHeight); - horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin); + marginBottom = getDipPrefInt(dm, prefs, "margin_bottom", marginBottom); + keyHeight = getDipPrefInt(dm, prefs, "key_height", keyHeight); + horizontalMargin = getDipPrefInt(dm, prefs, "horizontal_margin", horizontalMargin); preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat); characterSize = prefs.getFloat("character_size", characterSize); accents = Integer.valueOf(prefs.getString("accents", "1")); theme = themeId_of_string(prefs.getString("theme", "")); } - private float getDipPref(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def) + private float getDipPrefInt(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def) { int value = prefs.getInt(pref_name, -1); if (value < 0) @@ -95,6 +95,14 @@ final class Config return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, dm)); } + private float getDipPrefFloat(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def) + { + float value = prefs.getFloat(pref_name, -1.f); + if (value < 0.f) + return (def); + return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, dm)); + } + public static int layoutId_of_string(String name) { switch (name) |
