From 9a42fa4dca4eea0cca77841d361fe8256597aa55 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 6 Jun 2022 01:02:30 +0200 Subject: [PATCH] Don't add extra keys to the numeric pane --- res/xml/numeric.xml | 2 +- srcs/juloo.keyboard2/KeyboardData.java | 32 +++++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/res/xml/numeric.xml b/res/xml/numeric.xml index e19d3d9..477f7d7 100644 --- a/res/xml/numeric.xml +++ b/res/xml/numeric.xml @@ -1,5 +1,5 @@ - + diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index 83b1548..1449b7c 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -12,17 +12,19 @@ import java.util.Map; class KeyboardData { public final List rows; - /* Total width of the keyboard. Unit is abstract. */ + /** Total width of the keyboard. */ public final float keysWidth; - /* Total height of the keyboard. Unit is abstract. */ + /** Total height of the keyboard. */ public final float keysHeight; + /** Whether to add extra keys. */ + public final boolean extra_keys; public KeyboardData mapKeys(MapKey f) { ArrayList rows_ = new ArrayList(); for (Row r : rows) rows_.add(r.mapKeys(f)); - return new KeyboardData(rows_, keysWidth); + return new KeyboardData(rows_, keysWidth, extra_keys); } /** Add keys from the given iterator into the keyboard. Extra keys are added @@ -31,12 +33,14 @@ class KeyboardData * third row. */ public KeyboardData addExtraKeys(Iterator k) { + if (!extra_keys) + return this; ArrayList rows = new ArrayList(this.rows); addExtraKeys_to_row(rows, k, 1, 4); addExtraKeys_to_row(rows, k, 1, 3); addExtraKeys_to_row(rows, k, 2, 2); addExtraKeys_to_row(rows, k, 2, 1); - return new KeyboardData(rows, keysWidth); + return new KeyboardData(rows, keysWidth, extra_keys); } private static void addExtraKeys_to_row(ArrayList rows, final Iterator extra_keys, int row_i, final int d) @@ -81,13 +85,14 @@ class KeyboardData if (!expect_tag(parser, "keyboard")) throw new Exception("Empty layout file"); boolean bottom_row = parser.getAttributeBooleanValue(null, "bottom_row", true); + boolean extra_keys = parser.getAttributeBooleanValue(null, "extra_keys", true); ArrayList rows = new ArrayList(); while (expect_tag(parser, "row")) rows.add(Row.parse(parser)); float kw = compute_max_width(rows); if (bottom_row) rows.add(_bottomRow.updateWidth(kw)); - return new KeyboardData(rows, kw); + return new KeyboardData(rows, kw, extra_keys); } private static float compute_max_width(List rows) @@ -105,7 +110,7 @@ class KeyboardData return Row.parse(parser); } - protected KeyboardData(List rows_, float kw) + protected KeyboardData(List rows_, float kw, boolean xk) { float kh = 0.f; for (Row r : rows_) @@ -113,16 +118,17 @@ class KeyboardData rows = rows_; keysWidth = kw; keysHeight = kh; + extra_keys = xk; } public static class Row { public final List keys; - /* Height of the row, without 'shift'. Unit is abstract. */ + /** Height of the row, without 'shift'. */ public final float height; - /* Extra empty space on the top. */ + /** Extra empty space on the top. */ public final float shift; - /* Total width of the row. Unit is abstract. */ + /** Total width of the row. */ private final float keysWidth; protected Row(List keys_, float h, float s) @@ -177,11 +183,11 @@ class KeyboardData public final KeyValue key3; public final KeyValue key4; - /* Key width in relative unit. */ + /** Key width in relative unit. */ public final float width; - /* Extra empty space on the left of the key. */ + /** Extra empty space on the left of the key. */ public final float shift; - /* Put keys 1 to 4 on the edges instead of the corners. */ + /** Put keys 1 to 4 on the edges instead of the corners. */ public final boolean edgekeys; protected Key(KeyValue k0, KeyValue k1, KeyValue k2, KeyValue k3, KeyValue k4, float w, float s, boolean e) @@ -244,7 +250,7 @@ class KeyboardData return new Key(k0, k1, k2, k3, k4, width, shift, edgekeys); } - /* + /** * See Pointers.onTouchMove() for the represented direction. */ public KeyValue getAtDirection(int direction)