From 006ba16f60eaff6de59423b06a1880bd4654170d Mon Sep 17 00:00:00 2001 From: Helium314 Date: Thu, 30 Nov 2023 11:25:45 +0100 Subject: [PATCH] fix issues with some hint labels --- .../org/dslul/openboard/inputmethod/keyboard/Key.java | 5 ++--- .../inputmethod/keyboard/internal/KeyboardBuilder.kt | 11 ++++++----- .../internal/keyboard_parser/KeyboardParser.kt | 3 +-- 3 files changed, 9 insertions(+), 10 deletions(-) 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 39070402a..39b69fc8d 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 @@ -1232,11 +1232,10 @@ public class Key implements Comparable { if (hintLabelAlwaysFromFirstLongPressKey) { hintLabel = mMoreKeys == null ? null : mMoreKeys[0].mLabel; } else { - hintLabel = layoutMoreKeys == null ? null : layoutMoreKeys[0]; // note that some entries may have been changed to other string or null + hintLabel = layoutMoreKeys == null ? null : KeySpecParser.getLabel(layoutMoreKeys[0]); // note that some entries may have been changed to other string or null + // todo: this should be adjusted when re-working moreKey stuff... also KeySpecParser.getLabel may throw, which is bad when users do uncommon things if (hintLabel != null && hintLabel.length() > 1 && hintLabel.startsWith("!")) // this is not great, but other than removing com key label this is definitely ok hintLabel = null; - if (hintLabel != null && hintLabel.length() == 2 && hintLabel.startsWith("\\")) - hintLabel = hintLabel.replace("\\", ""); } mHintLabel = needsToUpcase ? StringUtils.toTitleCaseOfKeyLabel(hintLabel, localeForUpcasing) 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 2331f7350..165fc391d 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,19 +64,20 @@ open class KeyboardBuilder(protected val mContext: Context, // todo: further plan // migrate other languages/layouts to this style - // integrated number rows should be removed / ignored when migrating + // 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) - // check all the keyboard_layout_set and kbd_files for things like touchPositionCorrectionData - // some keyboard_layout_set have supportedScript that is enum synced with script id in ScriptUtils - // that's one more reason for using language tags... + // 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 // issues: // armenian bottom row: functional keys should be narrower // rtl parentheses hint label (urdu and more) // urdu and others: no labels because the moreKeys are languageMoreKeys -> need the moreKeys setting soon (at least setting to show first language moreKey if no symbol) - // setting: symbol morekeys(s): layout default, take from symbols, layout default but fill from symbols if empty + // setting: symbol morekey(s): layout default, take from symbols, layout default but fill from symbols if empty // setting: hint label: from symbol morekey only, symbol but language if none, first choice on long press // (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?) // migrate pcqwerty to this style // this will be more complicated... 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 523e62274..ea38991bc 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 @@ -605,7 +605,6 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co params.mId.mElementId == KeyboardId.ELEMENT_ALPHABET else -> true } - // this is weird... val allowRedundantMoreKeys = name != "nordic" && name != "serbian_qwertz" // essentially this is default for 4 row and non-alphabet layouts, maybe this could be determined automatically instead of using a list // todo: check the difference between default (i.e. none) and holo (test behavior on keyboard) @@ -630,7 +629,7 @@ data class LayoutInfos( // disabled by default, but enabled for all alphabet layouts // currently set in keyboardLayoutSet val enableProximityCharsCorrection: Boolean = false, - val allowRedundantMoreKeys: Boolean = true, // only false for nordic and serbian_qwertz, could add a setting when doing the moreKeys customizing + val allowRedundantMoreKeys: Boolean = true, // only false for nordic and serbian_qwertz // there is holo, default and null // null only for moreKeys keyboard // currently read as part of readAttributes, and thus wrong with the new parser