From eb42943327745def9ec1676fb93092af30083421 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 8 May 2022 17:35:24 +0200 Subject: [PATCH] Specify localized keys in each layouts Each layouts can chose which key are localized instead of specifying it globally for each key. Important keys are no longer removed from layouts if the 'extra_keys' mechanism is not working properly. This can happen if language tags specified in method.xml don't match the user's language. Removed some currency symbols from some layouts. They are all in the Fn layer. --- res/xml/azerty.xml | 6 ++--- res/xml/dvorak.xml | 24 ++++++++--------- res/xml/local_bgph1.xml | 16 ++++++------ res/xml/neo2.xml | 22 ++++++++-------- res/xml/qwerty.xml | 20 +++++++-------- res/xml/qwerty_es.xml | 12 ++++----- res/xml/qwerty_ko.xml | 6 ++--- res/xml/qwerty_lv.xml | 6 ++--- res/xml/qwerty_pt.xml | 10 ++++---- res/xml/qwerty_sv_se.xml | 6 ++--- res/xml/qwertz.xml | 2 +- srcs/juloo.keyboard2/KeyValue.java | 41 +++++++++++++++++++----------- 12 files changed, 91 insertions(+), 80 deletions(-) diff --git a/res/xml/azerty.xml b/res/xml/azerty.xml index c081d56..0e3f073 100644 --- a/res/xml/azerty.xml +++ b/res/xml/azerty.xml @@ -14,13 +14,13 @@ - + - + @@ -31,7 +31,7 @@ - + diff --git a/res/xml/dvorak.xml b/res/xml/dvorak.xml index 7f2cbe9..028daa6 100644 --- a/res/xml/dvorak.xml +++ b/res/xml/dvorak.xml @@ -2,32 +2,32 @@ - - - + + + - + - + - - - + + + - + - - + + - + diff --git a/res/xml/local_bgph1.xml b/res/xml/local_bgph1.xml index 0d71527..7ed407a 100644 --- a/res/xml/local_bgph1.xml +++ b/res/xml/local_bgph1.xml @@ -9,28 +9,28 @@ - + - - + + - + - + - - + + - + diff --git a/res/xml/neo2.xml b/res/xml/neo2.xml index 7ff0be7..b3d36d2 100644 --- a/res/xml/neo2.xml +++ b/res/xml/neo2.xml @@ -14,17 +14,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/res/xml/qwerty.xml b/res/xml/qwerty.xml index 4457bec..39df62e 100644 --- a/res/xml/qwerty.xml +++ b/res/xml/qwerty.xml @@ -3,34 +3,34 @@ - + - + - - - - + + + + - - + + - + - + diff --git a/res/xml/qwerty_es.xml b/res/xml/qwerty_es.xml index 3695996..f83bb4a 100644 --- a/res/xml/qwerty_es.xml +++ b/res/xml/qwerty_es.xml @@ -9,17 +9,17 @@ - + - - + + - + - + @@ -28,7 +28,7 @@ - + diff --git a/res/xml/qwerty_ko.xml b/res/xml/qwerty_ko.xml index b945147..482f342 100644 --- a/res/xml/qwerty_ko.xml +++ b/res/xml/qwerty_ko.xml @@ -3,7 +3,7 @@ - + @@ -14,8 +14,8 @@ - - + + diff --git a/res/xml/qwerty_lv.xml b/res/xml/qwerty_lv.xml index e9a1fc2..9d4db25 100644 --- a/res/xml/qwerty_lv.xml +++ b/res/xml/qwerty_lv.xml @@ -14,9 +14,9 @@ - - - + + + diff --git a/res/xml/qwerty_pt.xml b/res/xml/qwerty_pt.xml index 40110da..6e5d28d 100644 --- a/res/xml/qwerty_pt.xml +++ b/res/xml/qwerty_pt.xml @@ -3,10 +3,10 @@ - + - + @@ -14,9 +14,9 @@ - - - + + + diff --git a/res/xml/qwerty_sv_se.xml b/res/xml/qwerty_sv_se.xml index 15aa6ca..fe41134 100644 --- a/res/xml/qwerty_sv_se.xml +++ b/res/xml/qwerty_sv_se.xml @@ -15,9 +15,9 @@ - - - + + + diff --git a/res/xml/qwertz.xml b/res/xml/qwertz.xml index 77d0fc5..ffa8d36 100644 --- a/res/xml/qwertz.xml +++ b/res/xml/qwertz.xml @@ -15,7 +15,7 @@ - + diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 856f387..d88f027 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -106,6 +106,14 @@ class KeyValue flags = f; } + private static String stripPrefix(String s, String prefix) + { + if (s.startsWith(prefix)) + return s.substring(prefix.length()); + else + return null; + } + public static KeyValue getKeyByName(String name) { if (name == null) @@ -113,6 +121,12 @@ class KeyValue KeyValue kv = KeyValue.keys.get(name); if (kv != null) return kv; + String localized = stripPrefix(name, "loc "); + if (localized != null) + { + kv = getKeyByName(localized); + return kv.withFlags(kv.flags | FLAG_LOCALIZED); + } char c = (name.length() == 1) ? name.charAt(0) : CHAR_NONE; return new KeyValue(name, name, c, EVENT_NONE, 0); } @@ -165,18 +179,18 @@ class KeyValue FLAG_SHIFT | FLAG_KEY_FONT | FLAG_SMALLER_FONT); addModifierKey("ctrl", "Ctrl", FLAG_CTRL | FLAG_SMALLER_FONT); addModifierKey("alt", "Alt", FLAG_ALT | FLAG_SMALLER_FONT); - addModifierKey("accent_aigu", "\u0050", FLAG_ACCENT2 | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_caron", "\u0051", FLAG_ACCENT_CARON | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_cedille", "\u0052", FLAG_ACCENT5 | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_circonflexe", "\u0053", FLAG_ACCENT3 | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_grave", "\u0054", FLAG_ACCENT1 | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_macron", "\u0055", FLAG_ACCENT_MACRON | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_ring", "\u0056", FLAG_ACCENT_RING | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_tilde", "\u0057", FLAG_ACCENT4 | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_trema", "\u0058", FLAG_ACCENT6 | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_ogonek", "\u0059", FLAG_ACCENT_OGONEK | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_dot_above", "\u005a", FLAG_ACCENT_DOT_ABOVE | FLAG_KEY_FONT | FLAG_LOCALIZED); - addModifierKey("accent_double_aigu", "\u005b", FLAG_ACCENT_DOUBLE_AIGU | FLAG_KEY_FONT | FLAG_LOCALIZED); + addModifierKey("accent_aigu", "\u0050", FLAG_ACCENT2 | FLAG_KEY_FONT); + addModifierKey("accent_caron", "\u0051", FLAG_ACCENT_CARON | FLAG_KEY_FONT); + addModifierKey("accent_cedille", "\u0052", FLAG_ACCENT5 | FLAG_KEY_FONT); + addModifierKey("accent_circonflexe", "\u0053", FLAG_ACCENT3 | FLAG_KEY_FONT); + addModifierKey("accent_grave", "\u0054", FLAG_ACCENT1 | FLAG_KEY_FONT); + addModifierKey("accent_macron", "\u0055", FLAG_ACCENT_MACRON | FLAG_KEY_FONT); + addModifierKey("accent_ring", "\u0056", FLAG_ACCENT_RING | FLAG_KEY_FONT); + addModifierKey("accent_tilde", "\u0057", FLAG_ACCENT4 | FLAG_KEY_FONT); + addModifierKey("accent_trema", "\u0058", FLAG_ACCENT6 | FLAG_KEY_FONT); + addModifierKey("accent_ogonek", "\u0059", FLAG_ACCENT_OGONEK | FLAG_KEY_FONT); + addModifierKey("accent_dot_above", "\u005a", FLAG_ACCENT_DOT_ABOVE | FLAG_KEY_FONT); + addModifierKey("accent_double_aigu", "\u005b", FLAG_ACCENT_DOUBLE_AIGU | FLAG_KEY_FONT); addModifierKey("superscript", "Sup", FLAG_ACCENT_SUPERSCRIPT | FLAG_SMALLER_FONT); addModifierKey("subscript", "Sub", FLAG_ACCENT_SUBSCRIPT | FLAG_SMALLER_FONT); addModifierKey("ordinal", "Ord", FLAG_ACCENT_ORDINAL | FLAG_SMALLER_FONT); @@ -238,9 +252,6 @@ class KeyValue addCharKey('#', KeyEvent.KEYCODE_POUND); addCharKey('(', KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN); addCharKey(')', KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN); - addCharKey('ß', EVENT_NONE, FLAG_LOCALIZED); - addCharKey('€', EVENT_NONE, FLAG_LOCALIZED); - addCharKey('£', EVENT_NONE, FLAG_LOCALIZED); addSpecialKey("config", "\u0004", EVENT_CONFIG, FLAG_KEY_FONT | FLAG_SMALLER_FONT); addSpecialKey("switch_text", "ABC", EVENT_SWITCH_TEXT, FLAG_SMALLER_FONT);