From 8f729bb90a5dcfc4d01a325438ae5815624faac1 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sat, 8 Feb 2025 22:52:41 +0200 Subject: Add embedded_number_row keyboard attribute (#891) --- srcs/juloo.keyboard2/KeyboardData.java | 10 +++++++--- srcs/juloo.keyboard2/LayoutModifier.java | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'srcs/juloo.keyboard2') diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index 0c54291..9450c9e 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 the number row is included in the layout and thus another one shouldn't be added. */ + public final boolean embedded_number_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()]. */ @@ -239,6 +241,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 embedded_number_row = attribute_bool(parser, "embedded_number_row", false); 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"); @@ -269,7 +272,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, locale_extra_keys); + return new KeyboardData(rows, kw, modmap, script, numpad_script, name, bottom_row, embedded_number_row, locale_extra_keys); } private static float compute_max_width(List rows) @@ -288,7 +291,7 @@ public final class KeyboardData } protected KeyboardData(List rows_, float kw, Modmap mm, String sc, - String npsc, String name_, boolean bottom_row_, boolean locale_extra_keys_) + String npsc, String name_, boolean bottom_row_, boolean embedded_number_row_, boolean locale_extra_keys_) { float kh = 0.f; for (Row r : rows_) @@ -301,6 +304,7 @@ public final class KeyboardData keysWidth = Math.max(kw, 1f); keysHeight = kh; bottom_row = bottom_row_; + embedded_number_row = embedded_number_row_; locale_extra_keys = locale_extra_keys_; } @@ -308,7 +312,7 @@ public final class KeyboardData 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.locale_extra_keys); + src.numpad_script, src.name, src.bottom_row, src.embedded_number_row, src.locale_extra_keys); } public static class Row diff --git a/srcs/juloo.keyboard2/LayoutModifier.java b/srcs/juloo.keyboard2/LayoutModifier.java index f37be25..830a50c 100644 --- a/srcs/juloo.keyboard2/LayoutModifier.java +++ b/srcs/juloo.keyboard2/LayoutModifier.java @@ -42,7 +42,7 @@ public final class LayoutModifier added_numpad = modify_numpad(num_pad, kw); remove_keys.addAll(added_numpad.getKeys().keySet()); } - else if (globalConfig.add_number_row) // The numpad removes the number row + else if (globalConfig.add_number_row && !kw.embedded_number_row) // The numpad removes the number row { added_number_row = modify_number_row(number_row, kw); remove_keys.addAll(added_number_row.getKeys(0).keySet()); -- cgit v1.2.3