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 @@ Hide accents Typing Precision - Distance of corner values (%spx) + Distance of corner values (%sdp) Long press timeout Long press interval Vibration 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)