move information to subtype extra value:

whether layout has shift key
whether proximity-based corrections should be enabled when shift is enabled
This commit is contained in:
Helium314 2024-05-18 14:34:46 +02:00
parent b76dc8ced5
commit 1a630821db
4 changed files with 31 additions and 29 deletions

View file

@ -70,12 +70,8 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
// todo: add setting? maybe users want it in a custom layout
mParams.mAllowRedundantPopupKeys = mParams.mId.mElementId != KeyboardId.ELEMENT_SYMBOLS
// todo: should this be in subtype extra values?
mParams.mProximityCharsCorrectionEnabled = mParams.mId.isAlphabetKeyboard && when (layoutName) {
"bengali_akkhor", "georgian", "hindi", "lao", "nepali_romanized", "nepali_traditional", "sinhala", "thai" ->
mParams.mId.mElementId == KeyboardId.ELEMENT_ALPHABET // not for shifted layouts
else -> true
}
mParams.mProximityCharsCorrectionEnabled = mParams.mId.mElementId == KeyboardId.ELEMENT_ALPHABET
|| (mParams.mId.isAlphabetKeyboard && !mParams.mId.mSubtype.hasExtraValue(Constants.Subtype.ExtraValue.NO_SHIFT_PROXIMITY_CORRECTION))
addLocaleKeyTextsToParams(mContext, mParams, sv.mShowMorePopupKeys)
mParams.mPopupKeyTypes.addAll(sv.mPopupKeyTypes)

View file

@ -290,8 +290,8 @@ sealed interface KeyData : AbstractKeyData {
require(width >= 0f || width == -1f) { "illegal width $width" }
val newLabel = label.convertFlorisLabel().resolveStringLabel(params)
if (newLabel == KeyLabel.SHIFT && params.mId.isAlphabetKeyboard
&& params.mId.mSubtype.keyboardLayoutSetName in listOf("hindi_compact", "bengali", "arabic", "arabic_pc", "hebrew", "kannada", "kannada_extended","malayalam", "marathi", "farsi", "tamil", "telugu")) {
return null // these layouts have no shift key, todo: should be in subtype extras
&& params.mId.mSubtype.hasExtraValue(Constants.Subtype.ExtraValue.NO_SHIFT_KEY)) {
return null
}
val newCode = code.checkAndConvertCode()
val newLabelFlags = if (labelFlags == 0 && params.mId.isNumberLayout) {

View file

@ -72,6 +72,12 @@ public final class Constants {
*/
public static final String EMOJI_CAPABLE = "EmojiCapable";
/** Indicates that the subtype does not have a shift key */
public static final String NO_SHIFT_KEY = "NoShiftKey";
/** Indicates that for this subtype corrections should not be based on proximity of keys for when shifted */
public static final String NO_SHIFT_PROXIMITY_CORRECTION = "NoShiftProximityCorrection";
/**
* The subtype extra value used to indicate that the display name of this subtype
* contains a "%s" for printf-like replacement and it should be replaced by