Add options for the spacing between the keys

Two options: vertical and horizontal.
This commit is contained in:
Jules Aguillon 2022-01-30 23:55:15 +01:00
parent 8631dfb723
commit 2d2f0dd51d
4 changed files with 16 additions and 6 deletions

View File

@ -37,6 +37,8 @@
<string name="pref_swipe_dist_e_default">Normale</string> <string name="pref_swipe_dist_e_default">Normale</string>
<string name="pref_swipe_dist_e_far">Longue</string> <string name="pref_swipe_dist_e_far">Longue</string>
<string name="pref_swipe_dist_e_very_far">Très longue</string> <string name="pref_swipe_dist_e_very_far">Très longue</string>
<string name="pref_key_horizontal_space">Espacement horizontal entre les touches</string>
<string name="pref_key_vertical_space">Espacement vertical entre les touches</string>
<string name="key_action_next">Suiv.</string> <string name="key_action_next">Suiv.</string>
<string name="key_action_done">Fin</string> <string name="key_action_done">Fin</string>
<string name="key_action_go">Aller</string> <string name="key_action_go">Aller</string>

View File

@ -37,6 +37,8 @@
<string name="pref_swipe_dist_e_default">Normal</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_far">Far</string>
<string name="pref_swipe_dist_e_very_far">Very far</string> <string name="pref_swipe_dist_e_very_far">Very far</string>
<string name="pref_key_horizontal_space">Horizontal spacing between the keys</string>
<string name="pref_key_vertical_space">Vertical spacing between the keys</string>
<string name="key_action_next">Next</string> <string name="key_action_next">Next</string>
<string name="key_action_done">Done</string> <string name="key_action_done">Done</string>
<string name="key_action_go">Go</string> <string name="key_action_go">Go</string>

View File

@ -20,5 +20,7 @@
<juloo.common.IntSlideBarPreference android:key="key_height" android:title="@string/pref_key_height_title" android:summary="%sdp" android:defaultValue="50" min="30" max="90"/> <juloo.common.IntSlideBarPreference android:key="key_height" android:title="@string/pref_key_height_title" android:summary="%sdp" android:defaultValue="50" min="30" max="90"/>
<juloo.common.IntSlideBarPreference android:key="horizontal_margin" android:title="@string/pref_horizontal_margin_title" android:summary="%sdp" android:defaultValue="3" min="0" max="20"/> <juloo.common.IntSlideBarPreference android:key="horizontal_margin" android:title="@string/pref_horizontal_margin_title" android:summary="%sdp" android:defaultValue="3" min="0" max="20"/>
<juloo.common.SlideBarPreference android:key="character_size" android:title="@string/pref_character_size_title" android:summary="@string/pref_character_size_summary" android:defaultValue="1.0" min="0.8" max="1.2"/> <juloo.common.SlideBarPreference android:key="character_size" android:title="@string/pref_character_size_title" android:summary="@string/pref_character_size_summary" android:defaultValue="1.0" min="0.8" max="1.2"/>
<juloo.common.SlideBarPreference android:key="key_vertical_space" android:title="@string/pref_key_vertical_space" android:summary="%sdp" android:defaultValue="2.0" min="0.5" max="6.0"/>
<juloo.common.SlideBarPreference android:key="key_horizontal_space" android:title="@string/pref_key_horizontal_space" android:summary="%sdp" android:defaultValue="2.0" min="0.5" max="6.0"/>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -14,8 +14,6 @@ final class Config
// From resources // From resources
public final float marginTop; public final float marginTop;
public final float keyPadding; public final float keyPadding;
public final float keyVerticalInterval;
public final float keyHorizontalInterval;
// From preferences // From preferences
public int layout; // Or '-1' for the system defaults public int layout; // Or '-1' for the system defaults
@ -28,6 +26,8 @@ final class Config
public float marginBottom; public float marginBottom;
public float keyHeight; public float keyHeight;
public float horizontalMargin; public float horizontalMargin;
public float keyVerticalInterval;
public float keyHorizontalInterval;
public boolean preciseRepeat; public boolean preciseRepeat;
public float characterSize; // Ratio public float characterSize; // Ratio
public int accents; // Values are R.values.pref_accents_v_* public int accents; // Values are R.values.pref_accents_v_*
@ -48,8 +48,6 @@ final class Config
// static values // static values
marginTop = res.getDimension(R.dimen.margin_top); marginTop = res.getDimension(R.dimen.margin_top);
keyPadding = res.getDimension(R.dimen.key_padding); 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 // default values
layout = -1; layout = -1;
vibrateEnabled = true; vibrateEnabled = true;
@ -59,6 +57,8 @@ final class Config
marginBottom = res.getDimension(R.dimen.margin_bottom); marginBottom = res.getDimension(R.dimen.margin_bottom);
keyHeight = res.getDimension(R.dimen.key_height); keyHeight = res.getDimension(R.dimen.key_height);
horizontalMargin = res.getDimension(R.dimen.horizontal_margin); 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; preciseRepeat = true;
characterSize = 1.f; characterSize = 1.f;
accents = 1; accents = 1;
@ -89,6 +89,8 @@ final class Config
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 = 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 // Add keyVerticalInterval to keyHeight because the space between the keys
// is removed from the keys during rendering // is removed from the keys during rendering
keyHeight = getDipPref(dm, prefs, "key_height", keyHeight) + keyVerticalInterval; 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) private float getDipPref(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def)
{ {
int value = prefs.getInt(pref_name, -1); float value;
if (value < 0) try { value = prefs.getInt(pref_name, -1); }
catch (Exception e) { value = prefs.getFloat(pref_name, -1f); }
if (value < 0f)
return (def); return (def);
return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, dm)); return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, dm));
} }