From 3164215879a8374e9333801e0cc2ef56c627b4b6 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 6 Jul 2024 23:09:51 +0200 Subject: [PATCH] Add locale_extra_keys keyboard attribute This attribute can be used to disable adding the extra keys from method.xml. --- doc/Custom-layouts.md | 1 + srcs/juloo.keyboard2/Config.java | 2 +- srcs/juloo.keyboard2/KeyboardData.java | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/Custom-layouts.md b/doc/Custom-layouts.md index 5b18968..226a892 100644 --- a/doc/Custom-layouts.md +++ b/doc/Custom-layouts.md @@ -39,6 +39,7 @@ The ``...`` pair follows the declaration tag and encloses t * `script`: The (main) writing system that the keyboard supports. The possible values are `arabic`, `armenian`, `bengali`, `cyrillic`, `devanagari`, `gujarati`, `hangul`, `hebrew`, `latin`, `persian`, `shavian`, and `urdu`. It defaults to `latin`. * `numpad_script`: The script to use for the numpad. This is useful for scripts where a different, non-ASCII set of numerals is used, like Devanagari and Arabic. It defaults to the same as `script`. * `bottom_row`: Whether or not to show the common bottom row. It accepts `true` or `false`, and defaults to `true`. If your custom layout defines the bottom row, then specify `bottom_row=false` to disable the built-in bottom row. +* `locale_extra_keys`: Whether language-dependent extra keys from [method.xml](../res/xml/method.xml) should be added to this layout. It accepts `true` or `false`, and defaults to `true`. ## Row The ``...`` pair encloses one row on the keyboard. It has only one optional property: diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 2afe5ef..f605381 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -234,7 +234,7 @@ public final class Config extra_keys.put(KeyValue.getKeyByName("config"), KeyboardData.PreferredPos.ANYWHERE); extra_keys.putAll(extra_keys_param); extra_keys.putAll(extra_keys_custom); - if (extra_keys_subtype != null) + if (extra_keys_subtype != null && kw.locale_extra_keys) { Set present = new HashSet(); present.addAll(kw.getKeys().keySet()); diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index 68ebd10..aaff31d 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -31,6 +31,8 @@ public final class KeyboardData public final String name; /** Whether the bottom row should be added. */ public final boolean bottom_row; + /** Whether extra keys from [method.xml] should be added to this layout. */ + public final boolean locale_extra_keys; /** Position of every keys on the layout, see [getKeys()]. */ private Map _key_pos = null; @@ -234,6 +236,7 @@ public final class KeyboardData if (!expect_tag(parser, "keyboard")) throw error(parser, "Expected tag "); boolean bottom_row = attribute_bool(parser, "bottom_row", true); + boolean locale_extra_keys = attribute_bool(parser, "locale_extra_keys", true); float specified_kw = attribute_float(parser, "width", 0f); String script = parser.getAttributeValue(null, "script"); if (script != null && script.equals("")) @@ -263,7 +266,7 @@ public final class KeyboardData } } float kw = (specified_kw != 0f) ? specified_kw : compute_max_width(rows); - return new KeyboardData(rows, kw, modmap, script, numpad_script, name, bottom_row); + return new KeyboardData(rows, kw, modmap, script, numpad_script, name, bottom_row, locale_extra_keys); } private static float compute_max_width(List rows) @@ -282,7 +285,7 @@ public final class KeyboardData } protected KeyboardData(List rows_, float kw, Modmap mm, String sc, - String npsc, String name_, boolean bottom_row_) + String npsc, String name_, boolean bottom_row_, boolean locale_extra_keys_) { float kh = 0.f; for (Row r : rows_) @@ -295,13 +298,14 @@ public final class KeyboardData keysWidth = Math.max(kw, 1f); keysHeight = kh; bottom_row = bottom_row_; + locale_extra_keys = locale_extra_keys_; } - /** Copies the fields of an other keyboard, with rows changed. */ + /** Copies the fields of a keyboard, with rows changed. */ protected KeyboardData(KeyboardData src, List rows) { this(rows, compute_max_width(rows), src.modmap, src.script, - src.numpad_script, src.name, src.bottom_row); + src.numpad_script, src.name, src.bottom_row, src.locale_extra_keys); } public static class Row