mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 14:02:44 +00:00
always add punctuation popups to non-priority popups
fixes #1062 (also remove unused function)
This commit is contained in:
parent
c0e3811698
commit
b43e06c66f
1 changed files with 2 additions and 18 deletions
|
@ -130,7 +130,8 @@ class LocaleKeyboardInfos(dataStream: InputStream?, locale: Locale) {
|
|||
else line.splitOnWhitespace()
|
||||
if (split.size == 1) return
|
||||
val key = split.first()
|
||||
val popupsMap = if (priority) priorityPopupKeys else popupKeys
|
||||
// punctuation keys must always be normal popups (or getPunctuationPopupKeys needs to be adjusted)
|
||||
val popupsMap = if (priority && key != "punctuation") priorityPopupKeys else popupKeys
|
||||
if (popupsMap[key] is MutableList)
|
||||
popupsMap[key] = popupsMap[key]!!.toMutableSet().also { it.addAll(split.drop(1)) }
|
||||
else if (popupsMap.containsKey(key)) popupsMap[key]!!.addAll(split.drop(1))
|
||||
|
@ -191,23 +192,6 @@ class LocaleKeyboardInfos(dataStream: InputStream?, locale: Locale) {
|
|||
fun getNumberLabel(numberIndex: Int?): String? = numberIndex?.let { numberKeys.getOrNull(it) }
|
||||
}
|
||||
|
||||
private fun mergePopupKeys(original: List<String>, added: List<String>): List<String> {
|
||||
if (original.any { it.startsWith(Key.POPUP_KEYS_AUTO_COLUMN_ORDER) } || added.any { it.startsWith(Key.POPUP_KEYS_AUTO_COLUMN_ORDER) }) {
|
||||
val popupKeys = (original + added).toSet()
|
||||
val originalColumnCount = original.firstOrNull { it.startsWith(Key.POPUP_KEYS_AUTO_COLUMN_ORDER) }
|
||||
?.substringAfter(Key.POPUP_KEYS_AUTO_COLUMN_ORDER)?.toIntOrNull()
|
||||
val l = popupKeys.filterNot { it.startsWith(Key.POPUP_KEYS_AUTO_COLUMN_ORDER) }
|
||||
if (originalColumnCount != null && popupKeys.size <= 20 // not for too wide layout
|
||||
&& originalColumnCount == round((original.size - 1 + 0.1f) / 2f).toInt()) { // +0.1 f against rounding issues
|
||||
// we had 2 rows, and want it again
|
||||
return (l + "${Key.POPUP_KEYS_AUTO_COLUMN_ORDER}${round(l.size / 2f).toInt()}")
|
||||
}
|
||||
// just drop autoColumnOrder otherwise
|
||||
return l
|
||||
}
|
||||
return original + added
|
||||
}
|
||||
|
||||
private fun addFixedColumnOrder(popupKeys: MutableCollection<String>) {
|
||||
// use intermediate list, because we can't add first in a LinkedHashSet (i.e. MutableSet)
|
||||
popupKeys.removeAll { it.startsWith(Key.POPUP_KEYS_FIXED_COLUMN_ORDER) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue