From cbb1798dc146b21b837115a9a916c7652aebc03d Mon Sep 17 00:00:00 2001 From: Helium314 Date: Fri, 1 Dec 2023 00:08:54 +0100 Subject: [PATCH] fix some issues with layouts compare old and new parsing when debug mode is on --- app/src/main/assets/layouts/georgian.json | 38 +++++----- app/src/main/assets/layouts/kannada.txt | 1 - app/src/main/assets/layouts/khmer.json | 12 ++-- .../assets/layouts/korean_sebeolsik_390.json | 4 +- .../layouts/korean_sebeolsik_final.json | 8 +-- app/src/main/assets/layouts/lao.json | 54 +++++++------- .../assets/layouts/nepali_traditional.json | 26 +++---- app/src/main/assets/layouts/thai.json | 52 +++++++------- app/src/main/assets/layouts/uzbek.json | 2 +- .../openboard/inputmethod/keyboard/Key.java | 14 ++-- .../keyboard/internal/KeyboardBuilder.kt | 72 ++++++++++++++++--- .../keyboard_parser/KeyboardParser.kt | 20 +++--- .../keyboard_parser/SimpleKeyboardParser.kt | 3 +- .../keyboard_parser/floris/TextKeyData.kt | 8 ++- 14 files changed, 188 insertions(+), 126 deletions(-) diff --git a/app/src/main/assets/layouts/georgian.json b/app/src/main/assets/layouts/georgian.json index 91cfb53ca..e04af6b69 100644 --- a/app/src/main/assets/layouts/georgian.json +++ b/app/src/main/assets/layouts/georgian.json @@ -1,7 +1,7 @@ [ [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "q" }, + "manualOrLocked": { "label": "Q" }, "default": { "label": "ქ" } }, { "$": "shift_state_selector", @@ -9,7 +9,7 @@ "default": { "label": "წ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "e" }, + "manualOrLocked": { "label": "E" }, "default": { "label": "ე" } }, { "$": "shift_state_selector", @@ -21,29 +21,29 @@ "default": { "label": "ტ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "y" }, + "manualOrLocked": { "label": "Y" }, "default": { "label": "ყ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "u" }, + "manualOrLocked": { "label": "U" }, "default": { "label": "უ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "i" }, + "manualOrLocked": { "label": "I" }, "default": { "label": "ი" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "o" }, + "manualOrLocked": { "label": "O" }, "default": { "label": "ო" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "p" }, + "manualOrLocked": { "label": "P" }, "default": { "label": "პ" } } ], [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "a" }, + "manualOrLocked": { "label": "A" }, "default": { "label": "ა" } }, { "$": "shift_state_selector", @@ -51,19 +51,19 @@ "default": { "label": "ს" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "d" }, + "manualOrLocked": { "label": "D" }, "default": { "label": "დ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "f" }, + "manualOrLocked": { "label": "F" }, "default": { "label": "ფ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "g" }, + "manualOrLocked": { "label": "G" }, "default": { "label": "გ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "h" }, + "manualOrLocked": { "label": "H" }, "default": { "label": "ჰ" } }, { "$": "shift_state_selector", @@ -71,11 +71,11 @@ "default": { "label": "ჯ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "k" }, + "manualOrLocked": { "label": "K" }, "default": { "label": "კ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "l" }, + "manualOrLocked": { "label": "L" }, "default": { "label": "ლ" } } ], @@ -85,7 +85,7 @@ "default": { "label": "ზ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "x" }, + "manualOrLocked": { "label": "X" }, "default": { "label": "ხ" } }, { "$": "shift_state_selector", @@ -93,19 +93,19 @@ "default": { "label": "ც" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "v" }, + "manualOrLocked": { "label": "V" }, "default": { "label": "ვ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "b" }, + "manualOrLocked": { "label": "B" }, "default": { "label": "ბ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "n" }, + "manualOrLocked": { "label": "N" }, "default": { "label": "ნ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "m" }, + "manualOrLocked": { "label": "M" }, "default": { "label": "მ" } } ] diff --git a/app/src/main/assets/layouts/kannada.txt b/app/src/main/assets/layouts/kannada.txt index ed4879514..d4668e36f 100644 --- a/app/src/main/assets/layouts/kannada.txt +++ b/app/src/main/assets/layouts/kannada.txt @@ -32,4 +32,3 @@ ಋ ಷ ಯ - diff --git a/app/src/main/assets/layouts/khmer.json b/app/src/main/assets/layouts/khmer.json index 40b8a05d6..76a463298 100644 --- a/app/src/main/assets/layouts/khmer.json +++ b/app/src/main/assets/layouts/khmer.json @@ -101,7 +101,7 @@ ], [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "ាំ" }, + "manualOrLocked": { "label": "ាំ", "labelFlags": 128 }, "default": { "label": "ា" } }, { "$": "shift_state_selector", @@ -137,7 +137,7 @@ "default": { "label": "ល" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ោះ" }, + "manualOrLocked": { "label": "ោះ", "labelFlags": 49280 }, "default": { "label": "ើ" } }, { "$": "shift_state_selector", @@ -163,7 +163,7 @@ "default": { "label": "ច" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "េះ" }, + "manualOrLocked": { "label": "េះ", "labelFlags": 128 }, "default": { "label": "វ" } }, { "$": "shift_state_selector", @@ -179,15 +179,15 @@ "default": { "label": "ម" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ុះ" }, - "default": { "label": "ុំ" } + "manualOrLocked": { "label": "ុះ", "labelFlags": 128 }, + "default": { "label": "ុំ", "labelFlags": 128 } }, { "$": "shift_state_selector", "manualOrLocked": { "label": "៕" }, "default": { "label": "។" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "\?" }, + "manualOrLocked": { "label": "\\?" }, "default": { "label": "៊" } } ] diff --git a/app/src/main/assets/layouts/korean_sebeolsik_390.json b/app/src/main/assets/layouts/korean_sebeolsik_390.json index dc75d81a5..1bf28269f 100644 --- a/app/src/main/assets/layouts/korean_sebeolsik_390.json +++ b/app/src/main/assets/layouts/korean_sebeolsik_390.json @@ -155,8 +155,8 @@ "default": { "label": "\u1112", "popup": { "main": { "label": "\u0032" } } } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "\u0032", "popup": { "main": { "label": "\u0022" } } }, - "default": { "label": "\u1110", "popup": { "relevant": [{ "label": "\u0032" }, { "label": "\u0022" }] } } + "manualOrLocked": { "label": "\u0033", "popup": { "main": { "label": "\u0022" } } }, + "default": { "label": "\u1110", "popup": { "relevant": [{ "label": "\u0033" }, { "label": "\u0022" }] } } } ] ] diff --git a/app/src/main/assets/layouts/korean_sebeolsik_final.json b/app/src/main/assets/layouts/korean_sebeolsik_final.json index 6e656edbe..f6a5e1747 100644 --- a/app/src/main/assets/layouts/korean_sebeolsik_final.json +++ b/app/src/main/assets/layouts/korean_sebeolsik_final.json @@ -113,16 +113,16 @@ "default": { "label": "\u110b", "popup": { "main": { "label": "\u0031" } } } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "\u0031" }, - "default": { "label": "\u1100", "popup": { "main": { "label": "\u0031" } } } + "manualOrLocked": { "label": "\u0032" }, + "default": { "label": "\u1100", "popup": { "main": { "label": "\u0032" } } } }, { "$": "shift_state_selector", "manualOrLocked": { "label": "\u0033" }, "default": { "label": "\u110c", "popup": { "main": { "label": "\u0033" } } } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "\u0033" }, - "default": { "label": "\u1107", "popup": { "main": { "label": "\u0033" } } } + "manualOrLocked": { "label": "\u0034" }, + "default": { "label": "\u1107", "popup": { "main": { "label": "\u0034" } } } } ], [ diff --git a/app/src/main/assets/layouts/lao.json b/app/src/main/assets/layouts/lao.json index 79403b829..08f25792b 100644 --- a/app/src/main/assets/layouts/lao.json +++ b/app/src/main/assets/layouts/lao.json @@ -45,13 +45,13 @@ "default": { "label": "ຊ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ໍ່" }, + "manualOrLocked": { "label": "ໍ່", "labelFlags": 128 }, "default": { "label": "ໍ" } } ], [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "ົ້" }, + "manualOrLocked": { "label": "ົ້", "labelFlags": 128 }, "default": { "label": "ົ" } }, { "$": "shift_state_selector", @@ -59,23 +59,23 @@ "default": { "label": "ໄ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ຳ້" }, + "manualOrLocked": { "label": "ຳ້", "labelFlags": 128 }, "default": { "label": "ຳ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "_" }, + "manualOrLocked": { "label": "_", "labelFlags": 48 }, "default": { "label": "ພ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "+" }, + "manualOrLocked": { "label": "+", "labelFlags": 48 }, "default": { "label": "ະ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ິ້" }, + "manualOrLocked": { "label": "ິ້", "labelFlags": 128 }, "default": { "label": "ິ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ີ້" }, + "manualOrLocked": { "label": "ີ້", "labelFlags": 128 }, "default": { "label": "ີ" } }, { "$": "shift_state_selector", @@ -91,33 +91,33 @@ "default": { "label": "ຍ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ຫຼ" }, + "manualOrLocked": { "label": "ຫຼ", "labelFlags": 128 }, "default": { "label": "ບ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "”" }, + "manualOrLocked": { "label": "”", "labelFlags": 48 }, "default": { "label": "ລ" } } ], [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "ັ້" }, + "manualOrLocked": { "label": "ັ້", "labelFlags": 128 }, "default": { "label": "ັ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": ";" }, + "manualOrLocked": { "label": ";", "labelFlags": 48 }, "default": { "label": "ຫ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "." }, + "manualOrLocked": { "label": ".", "labelFlags": 48 }, "default": { "label": "ກ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "," }, + "manualOrLocked": { "label": ",", "labelFlags": 48 }, "default": { "label": "ດ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": ":" }, + "manualOrLocked": { "label": ":", "labelFlags": 48 }, "default": { "label": "ເ" } }, { "$": "shift_state_selector", @@ -129,33 +129,33 @@ "default": { "label": "່" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "!" }, + "manualOrLocked": { "label": "!", "labelFlags": 48 }, "default": { "label": "າ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "\?" }, + "manualOrLocked": { "label": "\\?", "labelFlags": 48 }, "default": { "label": "ສ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "%" }, + "manualOrLocked": { "label": "%", "labelFlags": 48 }, "default": { "label": "ວ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "=" }, + "manualOrLocked": { "label": "=", "labelFlags": 48 }, "default": { "label": "ງ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "“" }, - "default": { "label": "“" } + "manualOrLocked": { "label": "“", "labelFlags": 48 }, + "default": { "label": "“", "labelFlags": 48 } } ], [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "₭" }, + "manualOrLocked": { "label": "₭", "labelFlags": 48 }, "default": { "label": "ຜ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "(" }, + "manualOrLocked": { "label": "(", "labelFlags": 48 }, "default": { "label": "ປ" } }, { "$": "shift_state_selector", @@ -163,15 +163,15 @@ "default": { "label": "ແ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "\@" }, + "manualOrLocked": { "label": "\\@", "labelFlags": 48 }, "default": { "label": "ອ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ຶ້" }, + "manualOrLocked": { "label": "ຶ້", "labelFlags": 128 }, "default": { "label": "ຶ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ື້" }, + "manualOrLocked": { "label": "ື້", "labelFlags": 128 }, "default": { "label": "ື" } }, { "$": "shift_state_selector", @@ -183,11 +183,11 @@ "default": { "label": "ມ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "$" }, + "manualOrLocked": { "label": "$", "labelFlags": 48 }, "default": { "label": "ໃ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": ")" }, + "manualOrLocked": { "label": ")", "labelFlags": 48 }, "default": { "label": "ຝ" } } ] diff --git a/app/src/main/assets/layouts/nepali_traditional.json b/app/src/main/assets/layouts/nepali_traditional.json index 35f5f86c1..5ba62ef19 100644 --- a/app/src/main/assets/layouts/nepali_traditional.json +++ b/app/src/main/assets/layouts/nepali_traditional.json @@ -1,11 +1,11 @@ [ [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "त्त" }, + "manualOrLocked": { "label": "त्त", "labelFlags": 128 }, "default": { "label": "ट" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ड्ढ" }, + "manualOrLocked": { "label": "ड्ढ", "labelFlags": 128 }, "default": { "label": "ध" } }, { "$": "shift_state_selector", @@ -13,15 +13,15 @@ "default": { "label": "भ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "द्व" }, + "manualOrLocked": { "label": "द्व", "labelFlags": 128 }, "default": { "label": "च" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ट्ट" }, + "manualOrLocked": { "label": "ट्ट", "labelFlags": 128 }, "default": { "label": "त" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ठ्ठ" }, + "manualOrLocked": { "label": "ठ्ठ", "labelFlags": 128 }, "default": { "label": "थ" } }, { "$": "shift_state_selector", @@ -29,7 +29,7 @@ "default": { "label": "ग" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "क्ष" }, + "manualOrLocked": { "label": "क्ष", "labelFlags": 128 }, "default": { "label": "ष" } }, { "$": "shift_state_selector", @@ -51,11 +51,11 @@ "default": { "label": "ब" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ङ्" }, + "manualOrLocked": { "label": "ङ्", "labelFlags": 128 }, "default": { "label": "क" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ड्ड" }, + "manualOrLocked": { "label": "ड्ड", "labelFlags": 128 }, "default": { "label": "म" } }, { "$": "shift_state_selector", @@ -63,7 +63,7 @@ "default": { "label": "ा" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "द्द" }, + "manualOrLocked": { "label": "द्द", "labelFlags": 128 }, "default": { "label": "न" } }, { "$": "shift_state_selector", @@ -83,7 +83,7 @@ "default": { "label": "ि" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ट्ठ" }, + "manualOrLocked": { "label": "ट्ठ", "labelFlags": 128 }, "default": { "label": "स" } }, { "$": "shift_state_selector", @@ -93,11 +93,11 @@ ], [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "क्" }, + "manualOrLocked": { "label": "क्", "labelFlags": 128 }, "default": { "label": "श" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "ह्म" }, + "manualOrLocked": { "label": "ह्म", "labelFlags": 128 }, "default": { "label": "ह" } }, { "$": "shift_state_selector", @@ -113,7 +113,7 @@ "default": { "label": "द" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "द्य" }, + "manualOrLocked": { "label": "द्य", "labelFlags": 128 }, "default": { "label": "ल" } }, { "$": "shift_state_selector", diff --git a/app/src/main/assets/layouts/thai.json b/app/src/main/assets/layouts/thai.json index 69fd17eeb..05d3a416e 100644 --- a/app/src/main/assets/layouts/thai.json +++ b/app/src/main/assets/layouts/thai.json @@ -1,16 +1,16 @@ [ [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "+" }, + "manualOrLocked": { "label": "+", "labelFlags": 48 }, "default": { "label": "ๅ" } }, { "$": "shift_state_selector", "manualOrLocked": { "label": "๑" }, - "default": { "label": "/" } + "default": { "label": "/", "labelFlags": 48 } }, { "$": "shift_state_selector", "manualOrLocked": { "label": "๒" }, - "default": { "label": "_" } + "default": { "label": "_", "labelFlags": 48 } }, { "$": "shift_state_selector", "manualOrLocked": { "label": "๓" }, @@ -21,12 +21,12 @@ "default": { "label": "ถ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": " ู|ู" }, - "default": { "label": " ุ|ุ" } + "manualOrLocked": { "label": " ู|ู", "labelFlags": 128 }, + "default": { "label": " ุ|ุ", "labelFlags": 128 } }, { "$": "shift_state_selector", "manualOrLocked": { "label": "฿" }, - "default": { "label": " ึ|ึ" } + "default": { "label": " ึ|ึ", "labelFlags": 128 } }, { "$": "shift_state_selector", "manualOrLocked": { "label": "๕" }, @@ -55,7 +55,7 @@ "default": { "label": "ๆ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "\"" }, + "manualOrLocked": { "label": "\"", "labelFlags": 48 }, "default": { "label": "ไ" } }, { "$": "shift_state_selector", @@ -71,12 +71,12 @@ "default": { "label": "ะ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": " ํ|ํ" }, - "default": { "label": " ั|ั" } + "manualOrLocked": { "label": " ํ|ํ", "labelFlags": 128 }, + "default": { "label": " ั|ั", "labelFlags": 128 } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": " ๊|๊" }, - "default": { "label": " ี|ี" } + "manualOrLocked": { "label": " ๊|๊", "labelFlags": 128 }, + "default": { "label": " ี|ี", "labelFlags": 128 } }, { "$": "shift_state_selector", "manualOrLocked": { "label": "ณ" }, @@ -95,7 +95,7 @@ "default": { "label": "บ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "," }, + "manualOrLocked": { "label": ",", "labelFlags": 48 }, "default": { "label": "ล" } } ], @@ -121,12 +121,12 @@ "default": { "label": "เ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": " ็|็" }, - "default": { "label": " ้|้" } + "manualOrLocked": { "label": " ็|็", "labelFlags": 128 }, + "default": { "label": " ้|้", "labelFlags": 128 } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": " ๋|๋" }, - "default": { "label": " ่|่" } + "manualOrLocked": { "label": " ๋|๋", "labelFlags": 128 }, + "default": { "label": " ่|่", "labelFlags": 128 } }, { "$": "shift_state_selector", "manualOrLocked": { "label": "ษ" }, @@ -141,17 +141,21 @@ "default": { "label": "ว" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "." }, + "manualOrLocked": { "label": ".", "labelFlags": 48 }, "default": { "label": "ง" } + }, + { "$": "shift_state_selector", + "manualOrLocked": { "label": "ฅ" }, + "default": { "label": "ฃ" } } ], [ { "$": "shift_state_selector", - "manualOrLocked": { "label": "(" }, + "manualOrLocked": { "label": "(", "labelFlags": 48 }, "default": { "label": "ผ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": ")" }, + "manualOrLocked": { "label": ")", "labelFlags": 48 }, "default": { "label": "ป" } }, { "$": "shift_state_selector", @@ -163,15 +167,15 @@ "default": { "label": "อ" } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": " ฺ|ฺ" }, - "default": { "label": " ิ|ิ" } + "manualOrLocked": { "label": " ฺ|ฺ", "labelFlags": 128 }, + "default": { "label": " ิ|ิ", "labelFlags": 128 } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": " ์|์" }, - "default": { "label": " ื|ื" } + "manualOrLocked": { "label": " ์|์", "labelFlags": 128 }, + "default": { "label": " ื|ื", "labelFlags": 128 } }, { "$": "shift_state_selector", - "manualOrLocked": { "label": "\?" }, + "manualOrLocked": { "label": "\\?", "labelFlags": 48 }, "default": { "label": "ท" } }, { "$": "shift_state_selector", diff --git a/app/src/main/assets/layouts/uzbek.json b/app/src/main/assets/layouts/uzbek.json index 2b63d97ee..1b67ee5ae 100644 --- a/app/src/main/assets/layouts/uzbek.json +++ b/app/src/main/assets/layouts/uzbek.json @@ -23,7 +23,7 @@ { "label": "k", "popup": { "main": { "label": "(" } } }, { "label": "l", "popup": { "main": { "label": ")" } } }, { "label": "gʻ", "labelFlags": 128 }, - { "label": "'" } + { "label": "ʼ" } ], [ { "label": "z", "popup": { "main": { "label": "*" } } }, diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/Key.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/Key.java index 39b69fc8d..8b8859983 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/Key.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/Key.java @@ -957,15 +957,15 @@ public class Key implements Comparable { // params that remains constant public final int mCode; @Nullable public final String mLabel; - @Nullable final String mHintLabel; - final int mLabelFlags; - final int mIconId; + @Nullable public final String mHintLabel; + public final int mLabelFlags; + public final int mIconId; public final MoreKeySpec[] mMoreKeys; - final int mMoreKeysColumnAndFlags; + public final int mMoreKeysColumnAndFlags; public final int mBackgroundType; - final int mActionFlags; - @Nullable final KeyVisualAttributes mKeyVisualAttributes; - @Nullable final OptionalAttributes mOptionalAttributes; + public final int mActionFlags; + @Nullable public final KeyVisualAttributes mKeyVisualAttributes; + @Nullable public final OptionalAttributes mOptionalAttributes; public final boolean mEnabled; public static KeyParams newSpacer(final TypedArray keyAttr, final KeyStyle keyStyle, diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyboardBuilder.kt b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyboardBuilder.kt index 685324371..58f9781de 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyboardBuilder.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyboardBuilder.kt @@ -64,14 +64,14 @@ open class KeyboardBuilder(protected val mContext: Context, // todo: further plan // migrate other languages/layouts to this style - // missing layouts: nepali_romanized, nepali_traditional - // add a few individual key label flags: khmer, lao, thai, hindi_compact, marathi, nepali (both) - // that has nine letters in first row -> needs 0 extra (check layout) - // moreKeys for bangla and hindi layouts are completely mixed up -> maybe need to use layoutMoreKeys... but that's not nice - // integrated number rows should be removed / ignored when migrating, row will be added differently - // test the zwnj key - // test whether the layouts really are the same (screenshots for everything added, compare old and new parser) - // first try creating the keyParams with both parsers, and compare results, print differences + // add a few individual key label flags: hindi_compact -> dammit... one key and there is need for json, marathi -> same + // thai and lao number rows... they should probably have none, can't do it generically + // so handle it like korean + // languageMoreKeys for bengali and hindi layouts are completely mixed up -> maybe need to use layoutMoreKeys... but that's not nice + // test whether the layouts really are the same + // comparing params with both parsers looks good, see list of detected differences below + // still need to check moreKeys, there will be many more differences that might just be minor + // write down a list of differences, ask users to open issues if they don't like them // some keyboard_layout_set have supportedScript that is enum synced with script id in ScriptUtils // that's one more reason for using language tags... // but currently it's still read from xml outside the keyboard parser, so that's fine for now @@ -84,6 +84,7 @@ open class KeyboardBuilder(protected val mContext: Context, // (later): setting which moreKeys to prefer (default: symbol or important language, always symbol, always language) // (later): setting whether to show duplicate moreKeys (describe properly what it actually does) // and have some setting to enable configuring this per locale (in language settings -> potentially should not be a dialog any more but a fragment?) + // label flags are horrible to "decompile" when viewing a layout // migrate pcqwerty to this style // this will be more complicated... // linked shift keys might be easy @@ -170,11 +171,62 @@ open class KeyboardBuilder(protected val mContext: Context, fun loadFromXml(xmlId: Int, id: KeyboardId): KeyboardBuilder { if (Settings.getInstance().current.mUseNewKeyboardParsing -// && id.mElementId != KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED && id.mElementId != KeyboardId.ELEMENT_SYMBOLS_SHIFTED && this::class == KeyboardBuilder::class // otherwise this will apply to moreKeys and moreSuggestions, and then some parameters are off ) { - if (loadFromAssets(id) != null) + if (loadFromAssets(id) != null) { + if (!DebugFlags.DEBUG_ENABLED) + return this + // comparison of old and new parser below, remove once testing is complete + val keysInRowsFromXml = XmlKeyboardParser(xmlId, mParams, mContext).use { keyboardParser -> + keyboardParser.parseKeyboard() + } + if (keysInRowsFromXml.size != keysInRows.size) { + Log.w(TAG, "different sizes: ${keysInRows.size} vs ${keysInRowsFromXml.size}") + return this + } + keysInRowsFromXml.forEachIndexed { index, xmlRow -> + val row = keysInRows[index].filter { !it.isSpacer } + val xmlRow2 = xmlRow.filter { !it.isSpacer } + if (row.size != xmlRow2.size) { + Log.w(TAG, "different row sizes in row ${index + 1}") + return@forEachIndexed + } + xmlRow2.forEachIndexed { index1, xmlParams -> + // todo: compare moreKeys (and if different, check whether it's just the order) + // also check holo, there might be different default parameters + // and compare tablet layouts (how to best force it for both parsers?) + val keyParams = row[index1] + // bangla (india) has different period & symbols label (should it really be latin?) + // maybe need separate key text files for _IN and _BD + // hindi compact has a key with different label flags (marathi too? maybe i overlooked) + // lao has some sort of split number row, should be considered (how to deal with it?) + // thai also has this, leads to differences in hint labels and moreKeys + if (keyParams.mLabel != xmlParams.mLabel) + // currency keys (shift symbol) arranged differently + // obviously number row differences + Log.w(TAG, "label different: ${keyParams.mLabel} vs ${xmlParams.mLabel}") + if (keyParams.mCode != xmlParams.mCode) + Log.w(TAG, "code different: ${keyParams.mCode} vs ${xmlParams.mCode}") + if (keyParams.mIconId != xmlParams.mIconId) + Log.w(TAG, "icon different: ${keyParams.mIconId} vs ${xmlParams.mIconId}") + if (keyParams.mHintLabel != xmlParams.mHintLabel) + // extra and number keys are the difference so far + // persian has small difference + // khmer has some difference + // urdu has a lot of difference + Log.w(TAG, "hint label different: ${keyParams.mHintLabel} vs ${xmlParams.mHintLabel}") + if (keyParams.mLabelFlags != xmlParams.mLabelFlags && keyParams.mCode != 10) + // in symbol layout + // my version has disableHintLabel for all + // original has LABEL_FLAGS_HAS_POPUP_HINT on < > in shift symbol (but there is no popup) + // armenian, arabic, bangla,... and many with "symbols" original shift and delete have LABEL_FLAGS_FONT_NORMAL, mine not (but my period has) + // malayalam delete also has LABEL_FLAGS_AUTO_X_SCALE, mine not + // tamil & telugu my delete has LABEL_FLAGS_AUTO_X_SCALE, original not + Log.w(TAG, "label flags different for ${keyParams.mLabel} / ${keyParams.mCode}: ${keyParams.mLabelFlags.toString(16)} vs ${xmlParams.mLabelFlags.toString(16)}") + } + } return this + } } mParams.mId = id // loading a keyboard should set default params like mParams.readAttributes(mContext, attrs); diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/KeyboardParser.kt b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/KeyboardParser.kt index 8d50e4e09..11235d328 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/KeyboardParser.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/KeyboardParser.kt @@ -7,8 +7,6 @@ import android.view.inputmethod.EditorInfo import android.widget.Toast import org.dslul.openboard.inputmethod.keyboard.Key import org.dslul.openboard.inputmethod.keyboard.Key.KeyParams -import org.dslul.openboard.inputmethod.keyboard.Key.LABEL_FLAGS_AUTO_X_SCALE -import org.dslul.openboard.inputmethod.keyboard.Key.LABEL_FLAGS_FONT_NORMAL import org.dslul.openboard.inputmethod.keyboard.KeyboardId import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardIconsSet @@ -298,7 +296,10 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co label ?: params.mLocaleKeyTexts.labelPeriod, params, width, - Key.LABEL_FLAGS_HAS_POPUP_HINT or Key.LABEL_FLAGS_HAS_SHIFTED_LETTER_HINT or defaultLabelFlags, // todo (later): check what LABEL_FLAGS_HAS_SHIFTED_LETTER_HINT does, maybe remove the flag here + Key.LABEL_FLAGS_HAS_POPUP_HINT + // todo (later): check what LABEL_FLAGS_HAS_SHIFTED_LETTER_HINT does, maybe remove the flag here + or if (params.mId.isAlphabetKeyboard) Key.LABEL_FLAGS_HAS_SHIFTED_LETTER_HINT else 0 + or defaultLabelFlags, if (label?.first()?.isLetter() == true) Key.BACKGROUND_TYPE_NORMAL else Key.BACKGROUND_TYPE_FUNCTIONAL, moreKeys?.let { getPunctuationMoreKeys() + it } ?: getPunctuationMoreKeys() @@ -319,6 +320,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co or Key.LABEL_FLAGS_AUTO_X_SCALE or Key.LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO or Key.LABEL_FLAGS_FOLLOW_FUNCTIONAL_TEXT_COLOR + or Key.LABEL_FLAGS_HAS_POPUP_HINT or KeyboardTheme.getThemeActionAndEmojiKeyLabelFlags(params.mThemeId), Key.BACKGROUND_TYPE_ACTION, getActionKeyMoreKeys() @@ -335,7 +337,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co "${getShiftLabel()}|!code/key_shift", params, width, - Key.LABEL_FLAGS_PRESERVE_CASE, + Key.LABEL_FLAGS_PRESERVE_CASE or if (!params.mId.isAlphabetKeyboard) Key.LABEL_FLAGS_FOLLOW_FUNCTIONAL_TEXT_COLOR else 0, // todo (later): possibly the whole stickOn/Off stuff can be removed, currently it should only have a very slight effect in holo if (params.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED || params.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED) Key.BACKGROUND_TYPE_STICKY_ON @@ -580,8 +582,8 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co // currently it's spread out everywhere... method.xml, locale_and_extra_value_to_keyboard_layout_set_map, getKeyboardLayoutNameForLocale, ... protected fun getSimpleLayoutName(layoutName: String, params: KeyboardParams) = when (layoutName) { "swiss", "german", "serbian_qwertz" -> "qwertz" - "nordic", "spanish" -> "qwerty" - "south_slavic", "east_slavic" -> params.mId.locale.language // layouts split per language now, much less convoluted + "nordic", "spanish" -> if (params.mId.locale.language == "eo") "eo" else "qwerty" + "south_slavic", "east_slavic" -> params.mId.locale.language // layouts are split per language now, much less convoluted else -> layoutName } @@ -595,8 +597,8 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co val labelFlags = if (!params.mId.isAlphabetKeyboard) 0 else when (name) { "armenian_phonetic", "arabic", "arabic_pc", "bengali", "bengali_akkhor", "bengali_unijoy", "farsi", "hindi", "hindi_compact", "lao", "marathi", "nepali_romanized", "nepali_traditional", - "thai", "urdu" -> LABEL_FLAGS_FONT_NORMAL - "kannada", "khmer", "malayalam", "sinhala", "tamil", "telugu" -> LABEL_FLAGS_FONT_NORMAL or LABEL_FLAGS_AUTO_X_SCALE + "thai", "urdu" -> Key.LABEL_FLAGS_FONT_NORMAL + "kannada", "khmer", "malayalam", "sinhala", "tamil", "telugu" -> Key.LABEL_FLAGS_FONT_NORMAL or Key.LABEL_FLAGS_AUTO_X_SCALE else -> 0 } // only for alphabet, but some exceptions for shift layouts @@ -614,7 +616,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co R.array.touch_position_correction_data_default else R.array.touch_position_correction_data_holo val hasZwnjKey = params.mId.locale.language in listOf("fa", "ne", "kn", "te") // determine from language, user might have custom layout - val hasShiftKey = name !in listOf("hindi_compact", "arabic", "arabic_pc", "hebrew", "kannada", "malayalam", "marathi", "farsi", "tamil", "telugu") + val hasShiftKey = name !in listOf("hindi_compact", "bengali", "arabic", "arabic_pc", "hebrew", "kannada", "malayalam", "marathi", "farsi", "tamil", "telugu") return LayoutInfos(labelFlags, enableProximityCharsCorrection, allowRedundantMoreKeys, touchPositionCorrectionData, hasZwnjKey, hasShiftKey) } } diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/SimpleKeyboardParser.kt b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/SimpleKeyboardParser.kt index 8c591e2a9..d0ea75743 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/SimpleKeyboardParser.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/SimpleKeyboardParser.kt @@ -24,7 +24,8 @@ class SimpleKeyboardParser(private val params: KeyboardParams, private val conte override fun parseCoreLayout(layoutContent: String): MutableList> { val rowStrings = layoutContent.replace("\r\n", "\n").split("\n\n") - return rowStrings.mapIndexedTo(mutableListOf()) { i, row -> + return rowStrings.mapIndexedNotNullTo(mutableListOf()) { i, row -> + if (row.isBlank()) return@mapIndexedNotNullTo null if (addExtraKeys) getExtraKeys(i)?.let { parseRow(row) + it } ?: parseRow(row) else diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/floris/TextKeyData.kt b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/floris/TextKeyData.kt index 54747b60d..b2504c242 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/floris/TextKeyData.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/keyboard_parser/floris/TextKeyData.kt @@ -8,6 +8,7 @@ package org.dslul.openboard.inputmethod.keyboard.internal.keyboard_parser.floris import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.Transient +import org.dslul.openboard.inputmethod.keyboard.Key import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardParams // taken from FlorisBoard, small modifications (see also KeyData) @@ -42,7 +43,9 @@ class TextKeyData( // } // } if (label.startsWith("$$$")) { // currency key - if (label == "$$$") return params.mLocaleKeyTexts.currencyKey.let { it.first.toTextKey(it.second.toList()) } + if (label == "$$$") + return params.mLocaleKeyTexts.currencyKey + .let { it.first.toTextKey(it.second.toList(), labelFlags = Key.LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO) } // the flag is to match old parser, but why for main currency key, but not for others? val n = label.substringAfter("$$$").toIntOrNull() if (n != null && n <= 4) return params.mLocaleKeyTexts.currencyKey.second[n - 1].toTextKey() @@ -141,9 +144,10 @@ class MultiTextKeyData( } } -fun String.toTextKey(moreKeys: Collection? = null): TextKeyData = +fun String.toTextKey(moreKeys: Collection? = null, labelFlags: Int = 0): TextKeyData = TextKeyData( label = this, + labelFlags = labelFlags, popup = moreKeys ?.let { keys -> PopupSet(null, keys.map { it.toTextKey() }) } ?: PopupSet()