add missing labelFlag to hindi (compact) and marathi

and add debug info for some rarely occurring glitches
This commit is contained in:
Helium314 2023-12-01 16:16:04 +01:00
parent 5eaeb5892f
commit eafd0d4276
6 changed files with 100 additions and 78 deletions

View file

@ -0,0 +1,40 @@
[
[
{ "label": "औ" },
{ "label": "ऐ" },
{ "label": "आ" },
{ "label": "ई" },
{ "label": "ऊ" },
{ "label": "ब" },
{ "label": "ह" },
{ "label": "ग" },
{ "label": "द" },
{ "label": "ज" },
{ "label": "ड" }
],
[
{ "label": "ओ" },
{ "label": "ए" },
{ "label": "अ" },
{ "label": "इ" },
{ "label": "उ" },
{ "label": "प" },
{ "label": "र" },
{ "label": "क" },
{ "label": "त" },
{ "label": "च" },
{ "label": "ट" }
],
[
{ "label": "ऑ" },
{ "label": "्" },
{ "label": "ं" },
{ "label": "म" },
{ "label": "न" },
{ "label": "व" },
{ "label": "ल" },
{ "label": "स" },
{ "label": "य" },
{ "label": "क्ष", "labelFlags": 128 }
]
]

View file

@ -1,34 +0,0 @@
क्ष

View file

@ -0,0 +1,40 @@
[
[
{ "label": "ौ" },
{ "label": "ै" },
{ "label": "ा" },
{ "label": "ी" },
{ "label": "ू" },
{ "label": "ब" },
{ "label": "ह" },
{ "label": "ग" },
{ "label": "द" },
{ "label": "ज" },
{ "label": "ड" }
],
[
{ "label": "ो" },
{ "label": "े" },
{ "label": "्" },
{ "label": "ि" },
{ "label": "ु" },
{ "label": "प" },
{ "label": "र" },
{ "label": "क" },
{ "label": "त" },
{ "label": "च" },
{ "label": "ट" }
],
[
{ "label": "ॉ" },
{ "label": "ॅ" },
{ "label": "ं" },
{ "label": "म" },
{ "label": "न" },
{ "label": "व" },
{ "label": "ल" },
{ "label": "स" },
{ "label": "य" },
{ "label": "क्ष", "labelFlags": 128 }
]
]

View file

@ -1,34 +0,0 @@
ि
क्ष

View file

@ -64,10 +64,11 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
// todo: further plan
// migrate other languages/layouts to this style
// add a few individual key label flags: hindi_compact -> dammit... one key and there is need for json, marathi -> same
// thai and lao number rows... they should probably have none, can't do it generically
// so handle it like korean
// languageMoreKeys for bengali and hindi layouts are completely mixed up -> maybe need to use layoutMoreKeys... but that's not nice
// bangla (india) has different period & symbols label (should it really be latin?)
// maybe need separate key text files for _IN and _BD
// test whether the layouts really are the same
// comparing params with both parsers looks good, see list of detected differences below
// still need to check moreKeys, there will be many more differences that might just be minor
@ -76,7 +77,7 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
// 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
// armenian bottom row (and some more): functional keys could 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 morekey(s): layout default, take from symbols, layout default but fill from symbols if empty
@ -196,14 +197,9 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
// also check holo, there might be different default parameters
// and compare tablet layouts (how to best force it for both parsers?)
val keyParams = row[index1]
// bangla (india) has different period & symbols label (should it really be latin?)
// maybe need separate key text files for _IN and _BD
// hindi compact has a key with different label flags (marathi too? maybe i overlooked)
// lao has some sort of split number row, should be considered (how to deal with it?)
// thai also has this, leads to differences in hint labels and moreKeys
if (keyParams.mLabel != xmlParams.mLabel)
// currency keys (shift symbol) arranged differently
// obviously number row differences
// obviously number row differences with possibly localized variants
Log.w(TAG, "label different: ${keyParams.mLabel} vs ${xmlParams.mLabel}")
if (keyParams.mCode != xmlParams.mCode)
Log.w(TAG, "code different: ${keyParams.mCode} vs ${xmlParams.mCode}")
@ -222,6 +218,7 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
// armenian, arabic, bangla,... and many with "symbols" original shift and delete have LABEL_FLAGS_FONT_NORMAL, mine not (but my period has)
// malayalam delete also has LABEL_FLAGS_AUTO_X_SCALE, mine not
// tamil & telugu my delete has LABEL_FLAGS_AUTO_X_SCALE, original not
// hindi / marathi: -5 has 10, mine has 0 -> delete and LABEL_FLAGS_FONT_NORMAL
Log.w(TAG, "label flags different for ${keyParams.mLabel} / ${keyParams.mCode}: ${keyParams.mLabelFlags.toString(16)} vs ${xmlParams.mLabelFlags.toString(16)}")
}
}
@ -275,6 +272,8 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
var currentX = 0f
row.forEach {
it.setDimensionsFromRelativeSize(currentX, currentY)
if (DebugFlags.DEBUG_ENABLED)
Log.d(TAG, "setting size and position for ${it.mLabel}, ${it.mCode}: x ${currentX.toInt()}, w ${it.mFullWidth.toInt()}")
currentX += it.mFullWidth
}
// need to truncate to int here, otherwise it may end up one pixel lower than original

View file

@ -61,8 +61,13 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
} else if (!params.mId.mNumberRowEnabled && params.mId.isAlphabetKeyboard && params.mId.locale.language != "ko") {
// add number to the first 10 keys in first row
// setting the correct moreKeys is handled in PopupSet
// not for korean layouts, todo: should be decided in the layout, not in the parser
// not for korean layouts (add thai and lao to this), todo: should be decided in the layout, not in the parser
baseKeys.first().take(10).forEachIndexed { index, keyData -> keyData.popup.numberIndex = index }
if (DebugFlags.DEBUG_ENABLED && baseKeys.first().size < 10) {
val message = "first row only has ${baseKeys.first().size} keys: ${baseKeys.first().map { it.label }}"
Log.w(TAG, message)
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
}
}
val functionalKeysReversed = parseFunctionalKeys().reversed()
@ -73,6 +78,8 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
baseKeys.reversed().forEachIndexed { i, it ->
val row: List<KeyData> = if (i == 0) {
// add bottom row extra keys
// todo: question mark might be different -> get it from localeKeyTexts
// also, maybe check device dimension int instead of getting this from resources, then using language labels is easier
it + context.getString(R.string.key_def_extra_bottom_right)
.split(",").mapNotNull { if (it.isBlank()) null else it.trim().toTextKey() }
} else {
@ -118,6 +125,8 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
// but that could also be determined in toKeyParams
val keyParams = key.compute(params).toKeyParams(params, keyWidth, defaultLabelFlags)
paramsRow.add(keyParams)
if (DebugFlags.DEBUG_ENABLED)
Log.d(TAG, "adding key ${keyParams.mLabel}, ${keyParams.mCode}")
}
if (spacerWidth != 0f) {
paramsRow.add(KeyParams.newSpacer(params, spacerWidth))
@ -480,7 +489,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
val id = context.resources.getIdentifier("label_$this", "string", context.packageName)
if (id == 0) {
val message = "no resource for label $this in ${params.mId}"
Log.w(this::class.simpleName, message)
Log.w(TAG, message)
if (DebugFlags.DEBUG_ENABLED)
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
return this
@ -559,6 +568,8 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
}
companion object {
private val TAG = KeyboardParser::class.simpleName
fun parseFromAssets(params: KeyboardParams, context: Context): ArrayList<ArrayList<KeyParams>>? {
val id = params.mId
val layoutName = params.mId.mSubtype.keyboardLayoutSetName