Add an option to toggle accent keys

These keys are not useful at all in English. A new option allows to hide
them, [false] by default.
This commit is contained in:
Jules Aguillon 2021-04-13 02:00:08 +02:00
parent 0b1befcc88
commit eac74d3f22
5 changed files with 35 additions and 1 deletions

View File

@ -34,4 +34,6 @@
<string name="pref_key_height_summary">%sdp</string>
<string name="pref_horizontal_margin_title">Horizontal margin</string>
<string name="pref_horizontal_margin_summary">%sdp</string>
<string name="pref_disable_accent_keys_title">Toggle accent keys</string>
<string name="pref_disable_accent_keys_summary">Whether to remove the accent keys from the keyboard.</string>
</resources>

View File

@ -9,6 +9,12 @@
android:entries="@array/pref_layout_entries"
android:entryValues="@array/pref_layout_values"
/>
<CheckBoxPreference
android:key="disable_accent_keys"
android:title="@string/pref_disable_accent_keys_title"
android:summary="@string/pref_disable_accent_keys_summary"
android:defaultValue="false"
/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_typing">
<juloo.common.SlideBarPreference

View File

@ -9,7 +9,6 @@ class Config
{
private Keyboard2 _context;
public final float marginTop;
public final float keyPadding;
public final float keyBgPadding;
@ -23,6 +22,7 @@ class Config
public float marginBottom;
public float keyHeight;
public float horizontalMargin;
public boolean disableAccentKeys;
public Config(Keyboard2 context)
{
@ -43,6 +43,7 @@ class Config
marginBottom = res.getDimension(R.dimen.margin_bottom);
keyHeight = res.getDimension(R.dimen.key_height);
horizontalMargin = res.getDimension(R.dimen.horizontal_margin);
disableAccentKeys = false;
// from prefs
refresh();
}
@ -62,6 +63,7 @@ class Config
marginBottom = getDipPref(prefs, "margin_bottom", marginBottom);
keyHeight = getDipPref(prefs, "key_height", keyHeight);
horizontalMargin = getDipPref(prefs, "horizontal_margin", horizontalMargin);
disableAccentKeys = prefs.getBoolean("disable_accent_keys", disableAccentKeys);
}
private float getDipPref(SharedPreferences prefs, String pref_name, float def)

View File

@ -33,6 +33,9 @@ class KeyValue
public static final int FLAG_ACCENT5 = (1 << 20);
public static final int FLAG_ACCENT6 = (1 << 21);
public static final int FLAGS_ACCENTS = FLAG_ACCENT1 | FLAG_ACCENT2 |
FLAG_ACCENT3 | FLAG_ACCENT4 | FLAG_ACCENT5 | FLAG_ACCENT6;
private String _name;
private String _symbol;
private char _char;

View File

@ -43,6 +43,27 @@ class KeyboardData
return (_rows);
}
// Remove every keys that has the given flags.
public void removeKeysByFlag(int flags)
{
for (Row r : _rows)
{
for (Key k : r)
{
k.key0 = _removeKeyValueFlag(k.key0, flags);
k.key1 = _removeKeyValueFlag(k.key1, flags);
k.key2 = _removeKeyValueFlag(k.key2, flags);
k.key3 = _removeKeyValueFlag(k.key3, flags);
k.key4 = _removeKeyValueFlag(k.key4, flags);
}
}
}
private KeyValue _removeKeyValueFlag(KeyValue v, int flags)
{
return (v != null && (v.getFlags() & flags) != 0) ? null : v;
}
public class Row extends ArrayList<Key>
{
private float _keysWidth;