mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2025-02-22 20:41:10 +01:00
Improve the "precision" option
Now named "swiping distance". Changed to a dropdown.
This commit is contained in:
parent
8bef0728ae
commit
9c82c9cfdc
@ -32,4 +32,18 @@
|
||||
<item>light</item>
|
||||
<item>black</item>
|
||||
</string-array>
|
||||
<string-array name="pref_swipe_dist_entries">
|
||||
<item>@string/pref_swipe_dist_e_very_short</item>
|
||||
<item>@string/pref_swipe_dist_e_short</item>
|
||||
<item>@string/pref_swipe_dist_e_default</item>
|
||||
<item>@string/pref_swipe_dist_e_far</item>
|
||||
<item>@string/pref_swipe_dist_e_very_far</item>
|
||||
</string-array>
|
||||
<string-array name="pref_swipe_dist_values">
|
||||
<item>5</item>
|
||||
<item>7.5</item>
|
||||
<item>15</item>
|
||||
<item>25</item>
|
||||
<item>35</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -11,8 +11,8 @@
|
||||
<string name="pref_accents_e_all">Show every accents</string>
|
||||
<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 (%sdp)</string>
|
||||
<string name="pref_swipe_dist_title">Swiping distance</string>
|
||||
<string name="pref_swipe_dist_summary">Distance of characters in the corners of the keys (%s)</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>
|
||||
@ -31,4 +31,9 @@
|
||||
<string name="pref_theme_e_dark">Dark</string>
|
||||
<string name="pref_theme_e_light">Light</string>
|
||||
<string name="pref_theme_e_black">Black</string>
|
||||
<string name="pref_swipe_dist_e_very_short">Very short</string>
|
||||
<string name="pref_swipe_dist_e_short">Short</string>
|
||||
<string name="pref_swipe_dist_e_default">Normal</string>
|
||||
<string name="pref_swipe_dist_e_far">Far</string>
|
||||
<string name="pref_swipe_dist_e_very_far">Very far</string>
|
||||
</resources>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<ListPreference android:key="accents" android:title="@string/pref_accents_title" android:summary="%s" android:defaultValue="1" android:entries="@array/pref_accents_entries" android:entryValues="@array/pref_accents_values"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_category_typing">
|
||||
<juloo.common.SlideBarPreference android:key="sub_value_dist" android:title="@string/pref_preci_title" android:summary="@string/pref_preci_summary" android:defaultValue="10.0" min="5.0" max="25.0"/>
|
||||
<ListPreference android:key="swipe_dist" android:title="@string/pref_swipe_dist_title" android:summary="@string/pref_swipe_dist_summary" android:defaultValue="15" android:entries="@array/pref_swipe_dist_entries" android:entryValues="@array/pref_swipe_dist_values"/>
|
||||
<juloo.common.IntSlideBarPreference android:key="longpress_timeout" android:title="@string/pref_long_timeout_title" android:summary="%sms" android:defaultValue="600" min="50" max="2000"/>
|
||||
<juloo.common.IntSlideBarPreference android:key="longpress_interval" android:title="@string/pref_long_interval_title" android:summary="%sms" android:defaultValue="25" min="5" max="100"/>
|
||||
<CheckBoxPreference android:key="precise_repeat" android:title="@string/pref_precise_repeat_title" android:summary="@string/pref_precise_repeat_summary" android:defaultValue="true"/>
|
||||
|
@ -17,7 +17,8 @@ final class Config
|
||||
|
||||
// From preferences
|
||||
public int layout; // Or '-1' for the system defaults
|
||||
public float subValueDist;
|
||||
private float swipe_dist_dp;
|
||||
public float swipe_dist_px;
|
||||
public boolean vibrateEnabled;
|
||||
public long vibrateDuration;
|
||||
public long longPressTimeout;
|
||||
@ -46,7 +47,6 @@ final class Config
|
||||
keyHorizontalInterval = res.getDimension(R.dimen.key_horizontal_interval);
|
||||
// default values
|
||||
layout = -1;
|
||||
subValueDist = 10f;
|
||||
vibrateEnabled = true;
|
||||
vibrateDuration = 20;
|
||||
longPressTimeout = 600;
|
||||
@ -73,21 +73,22 @@ final class Config
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
layout = layoutId_of_string(prefs.getString("layout", "system"));
|
||||
subValueDist = getDipPrefFloat(dm, prefs, "sub_value_dist", subValueDist);
|
||||
swipe_dist_dp = Float.valueOf(prefs.getString("swipe_dist", "15"));
|
||||
swipe_dist_px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, swipe_dist_dp, dm);
|
||||
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 = getDipPrefInt(dm, prefs, "margin_bottom", marginBottom);
|
||||
keyHeight = getDipPrefInt(dm, prefs, "key_height", keyHeight);
|
||||
horizontalMargin = getDipPrefInt(dm, prefs, "horizontal_margin", horizontalMargin);
|
||||
marginBottom = getDipPref(dm, prefs, "margin_bottom", marginBottom);
|
||||
keyHeight = getDipPref(dm, prefs, "key_height", keyHeight);
|
||||
horizontalMargin = getDipPref(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 getDipPrefInt(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def)
|
||||
private float getDipPref(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def)
|
||||
{
|
||||
int value = prefs.getInt(pref_name, -1);
|
||||
if (value < 0)
|
||||
@ -95,14 +96,6 @@ 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)
|
||||
|
@ -145,7 +145,7 @@ public class Keyboard2View extends View
|
||||
moveY -= key.downY;
|
||||
float absDist = Math.abs(moveX) + Math.abs(moveY);
|
||||
key.ptrDist = absDist;
|
||||
if (absDist < _config.subValueDist)
|
||||
if (absDist < _config.swipe_dist_px)
|
||||
newValue = key.key.key0;
|
||||
else if (moveX < 0)
|
||||
newValue = (moveY < 0) ? key.key.key1 : key.key.key3;
|
||||
@ -313,7 +313,7 @@ public class Keyboard2View extends View
|
||||
if (_config.preciseRepeat && (key.flags & KeyValue.FLAG_PRECISE_REPEAT) != 0)
|
||||
{
|
||||
// Modulate repeat interval depending on the distance of the pointer
|
||||
float accel = Math.min(4.f, Math.max(0.3f, key.ptrDist / (_config.subValueDist * 15.f)));
|
||||
float accel = Math.min(4.f, Math.max(0.3f, key.ptrDist / (_config.swipe_dist_px * 15.f)));
|
||||
nextInterval = (long)((float)nextInterval / accel);
|
||||
}
|
||||
_handler.sendEmptyMessageDelayed(msg.what, nextInterval);
|
||||
|
Loading…
Reference in New Issue
Block a user