mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-11-25 08:43:24 +01:00
Turn the "precision" option to dp instead of px
This commit is contained in:
parent
b05f6e8447
commit
8bef0728ae
@ -12,7 +12,7 @@
|
|||||||
<string name="pref_accents_e_none">Hide accents</string>
|
<string name="pref_accents_e_none">Hide accents</string>
|
||||||
<string name="pref_category_typing">Typing</string>
|
<string name="pref_category_typing">Typing</string>
|
||||||
<string name="pref_preci_title">Precision</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_timeout_title">Long press timeout</string>
|
||||||
<string name="pref_long_interval_title">Long press interval</string>
|
<string name="pref_long_interval_title">Long press interval</string>
|
||||||
<string name="pref_category_vibrate">Vibration</string>
|
<string name="pref_category_vibrate">Vibration</string>
|
||||||
|
@ -73,21 +73,21 @@ final class Config
|
|||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||||
layout = layoutId_of_string(prefs.getString("layout", "system"));
|
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);
|
vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled);
|
||||||
vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration);
|
vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration);
|
||||||
longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout);
|
longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout);
|
||||||
longPressInterval = prefs.getInt("longpress_interval", (int)longPressInterval);
|
longPressInterval = prefs.getInt("longpress_interval", (int)longPressInterval);
|
||||||
marginBottom = getDipPref(dm, prefs, "margin_bottom", marginBottom);
|
marginBottom = getDipPrefInt(dm, prefs, "margin_bottom", marginBottom);
|
||||||
keyHeight = getDipPref(dm, prefs, "key_height", keyHeight);
|
keyHeight = getDipPrefInt(dm, prefs, "key_height", keyHeight);
|
||||||
horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin);
|
horizontalMargin = getDipPrefInt(dm, prefs, "horizontal_margin", horizontalMargin);
|
||||||
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
|
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
|
||||||
characterSize = prefs.getFloat("character_size", characterSize);
|
characterSize = prefs.getFloat("character_size", characterSize);
|
||||||
accents = Integer.valueOf(prefs.getString("accents", "1"));
|
accents = Integer.valueOf(prefs.getString("accents", "1"));
|
||||||
theme = themeId_of_string(prefs.getString("theme", ""));
|
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);
|
int value = prefs.getInt(pref_name, -1);
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
@ -95,6 +95,14 @@ final class Config
|
|||||||
return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, dm));
|
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)
|
public static int layoutId_of_string(String name)
|
||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
|
Loading…
Reference in New Issue
Block a user