don't set tablet extra keys for custom layouts

fixes #1180
This commit is contained in:
Helium314 2025-01-05 22:46:40 +01:00
parent d25df2c4de
commit 3cf9d4c87e
4 changed files with 4 additions and 6 deletions

View file

@ -91,6 +91,7 @@ public class KeyboardParams {
public boolean mAllowRedundantPopupKeys;
@NonNull
public LocaleKeyboardInfos mLocaleKeyboardInfos;
public boolean setTabletExtraKeys;
public int mMostCommonKeyHeight = 0;
public int mMostCommonKeyWidth = 0;
@ -284,5 +285,6 @@ public class KeyboardParams {
keyAttr.recycle();
keyboardAttr.recycle();
}
setTabletExtraKeys = Settings.getInstance().isTablet() && !mId.mSubtype.isCustom();
}
}

View file

@ -108,11 +108,8 @@ class KeyboardParser(private val params: KeyboardParams, private val context: Co
val functionalKeys = mutableListOf<Pair<List<KeyParams>, List<KeyParams>>>()
val baseKeyParams = baseKeys.mapIndexed { i, it ->
val row: List<KeyData> = if (params.mId.isAlphaOrSymbolKeyboard && i == baseKeys.lastIndex - 1 && Settings.getInstance().isTablet) {
val row: List<KeyData> = if (params.mId.isAlphaOrSymbolKeyboard && i == baseKeys.lastIndex - 1 && params.setTabletExtraKeys) {
// add bottom row extra keys
// todo (later): this can make very customized layouts look awkward
// decide when to (not) add it
// when not adding, consider that punctuation popup keys should not remove those keys!
val tabletExtraKeys = params.mLocaleKeyboardInfos.getTabletExtraKeys(params.mId.mElementId)
tabletExtraKeys.first + it + tabletExtraKeys.second
} else {

View file

@ -86,7 +86,6 @@ class LocaleKeyboardInfos(dataStream: InputStream?, locale: Locale) {
}
/** Pair(extraKeysLeft, extraKeysRight) */
// todo: they should be optional, or will unexpectedly appear on custom layouts
fun getTabletExtraKeys(elementId: Int): Pair<List<KeyData>, List<KeyData>> {
val flags = Key.LABEL_FLAGS_FONT_DEFAULT
return when (elementId) {

View file

@ -141,7 +141,7 @@ sealed interface KeyData : AbstractKeyData {
for (i in popupKeys.indices)
popupKeys[i] = popupKeys[i].rtlLabel(params) // for parentheses
}
if (Settings.getInstance().isTablet && popupKeys.contains("!") && popupKeys.contains("?")) {
if (params.setTabletExtraKeys && popupKeys.contains("!") && popupKeys.contains("?")) {
// remove ! and ? keys and reduce number in autoColumnOrder
// this makes use of removal of empty popupKeys in PopupKeySpec.insertAdditionalPopupKeys
popupKeys[popupKeys.indexOf("!")] = ""