From 761a825a3de77a27a012ea3506ec3ff5e85e02b1 Mon Sep 17 00:00:00 2001 From: AsafMah Date: Mon, 18 May 2026 07:49:36 +0300 Subject: [PATCH] Fix: show all symbols in letter long-press popup When long-pressing a letter, the popup keyboard now includes all symbols defined at the corresponding position in the symbols layout, not just the primary label. Previously a symbols-layout entry such as `% per` or `( < { [` only contributed its first label to the letter's popup; the symbol key's own popup keys were discarded. addSymbolPopupKeys (and the number-row-in-symbols branch of addNumberRowOrPopupKeys) now collect both the symbol key's label and its popup labels via PopupSet.getPopupKeyLabels. PopupSet.symbol is renamed to PopupSet.symbols and changed from String? to Collection?. createPopupKeysArray addAll's them; getHintLabel keeps a single-character hint via firstOrNull(). Fixes #113 Assisted-by: GitHub Copilot CLI Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../internal/keyboard_parser/KeyboardParser.kt | 14 ++++++++++++-- .../internal/keyboard_parser/floris/PopupSet.kt | 2 +- .../keyboard/latin/utils/PopupKeysUtils.kt | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt index 29dcc182a..06fa6b2b9 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt @@ -267,7 +267,13 @@ class KeyboardParser(private val params: KeyboardParams, private val context: Co if (!params.mId.mNumberRowEnabled && params.mId.mNumberRowInSymbols && params.mId.mElementId == KeyboardId.ELEMENT_SYMBOLS) { // replace first symbols row with number row, but use the labels as popupKeys val numberRowCopy = numberRow.toMutableList() - numberRowCopy.forEachIndexed { index, keyData -> keyData.popup.symbol = baseKeys[0].getOrNull(index)?.label } + numberRowCopy.forEachIndexed { index, keyData -> + val symbolKey = baseKeys[0].getOrNull(index) ?: return@forEachIndexed + val symbols = mutableListOf() + symbolKey.label.takeIf { it.isNotEmpty() }?.let { symbols.add(it) } + symbolKey.popup.getPopupKeyLabels(params)?.let { symbols.addAll(it) } + if (symbols.isNotEmpty()) keyData.popup.symbols = symbols + } baseKeys[0] = numberRowCopy } else if (!params.mId.mNumberRowEnabled && params.mId.isAlphabetKeyboard && !hasBuiltInNumbers()) { if (baseKeys[0].any { it.popup.main != null || !it.popup.relevant.isNullOrEmpty() } // first row of baseKeys has any layout popup key @@ -290,7 +296,11 @@ class KeyboardParser(private val params: KeyboardParams, private val context: Co layout.forEachIndexed { i, row -> val baseRow = baseKeys.getOrNull(i) ?: return@forEachIndexed row.forEachIndexed { j, key -> - baseRow.getOrNull(j)?.popup?.symbol = key.label + val baseKey = baseRow.getOrNull(j) ?: return@forEachIndexed + val symbols = mutableListOf() + key.label.takeIf { it.isNotEmpty() }?.let { symbols.add(it) } + key.popup.getPopupKeyLabels(params)?.let { symbols.addAll(it) } + if (symbols.isNotEmpty()) baseKey.popup.symbols = symbols } } } diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/PopupSet.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/PopupSet.kt index 10b654b09..3f6c75b45 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/PopupSet.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/PopupSet.kt @@ -28,7 +28,7 @@ open class PopupSet( open fun isEmpty(): Boolean = main == null && relevant.isNullOrEmpty() var numberLabel: String? = null - var symbol: String? = null // maybe list of keys? + var symbols: Collection? = null fun merge(other: PopupSet?): PopupSet { if (other == null || other.isEmpty()) return this diff --git a/app/src/main/java/helium314/keyboard/latin/utils/PopupKeysUtils.kt b/app/src/main/java/helium314/keyboard/latin/utils/PopupKeysUtils.kt index 503dbf6f2..75ca1ba4b 100644 --- a/app/src/main/java/helium314/keyboard/latin/utils/PopupKeysUtils.kt +++ b/app/src/main/java/helium314/keyboard/latin/utils/PopupKeysUtils.kt @@ -31,7 +31,7 @@ fun createPopupKeysArray(popupSet: PopupSet<*>?, params: KeyboardParams, label: when (type) { POPUP_KEYS_NUMBER -> popupSet?.numberLabel?.let { popupKeys.add(it) } POPUP_KEYS_LAYOUT -> popupSet?.getPopupKeyLabels(params)?.let { popupKeys.addAll(it) } - POPUP_KEYS_SYMBOLS -> popupSet?.symbol?.let { popupKeys.add(it) } + POPUP_KEYS_SYMBOLS -> popupSet?.symbols?.let { popupKeys.addAll(it) } POPUP_KEYS_LANGUAGE -> params.mLocaleKeyboardInfos.getPopupKeys(label)?.let { popupKeys.addAll(it) } POPUP_KEYS_LANGUAGE_PRIORITY -> params.mLocaleKeyboardInfos.getPriorityPopupKeys(label)?.let { popupKeys.addAll(it) } } @@ -66,7 +66,7 @@ fun getHintLabel(popupSet: PopupSet<*>?, params: KeyboardParams, label: String): when (type) { POPUP_KEYS_NUMBER -> popupSet?.numberLabel?.let { hintLabel = it } POPUP_KEYS_LAYOUT -> popupSet?.getPopupKeyLabels(params)?.let { hintLabel = it.firstOrNull() } - POPUP_KEYS_SYMBOLS -> popupSet?.symbol?.let { hintLabel = it } + POPUP_KEYS_SYMBOLS -> popupSet?.symbols?.let { hintLabel = it.firstOrNull() } POPUP_KEYS_LANGUAGE -> params.mLocaleKeyboardInfos.getPopupKeys(label)?.let { hintLabel = it.firstOrNull() } POPUP_KEYS_LANGUAGE_PRIORITY -> params.mLocaleKeyboardInfos.getPriorityPopupKeys(label)?.let { hintLabel = it.firstOrNull() } }