mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-16 23:12:47 +00:00
add missing labelFlag to hindi (compact) and marathi
and add debug info for some rarely occurring glitches
This commit is contained in:
parent
5eaeb5892f
commit
eafd0d4276
6 changed files with 100 additions and 78 deletions
40
app/src/main/assets/layouts/hindi_compact.json
Normal file
40
app/src/main/assets/layouts/hindi_compact.json
Normal 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 }
|
||||||
|
]
|
||||||
|
]
|
|
@ -1,34 +0,0 @@
|
||||||
औ
|
|
||||||
ऐ
|
|
||||||
आ
|
|
||||||
ई
|
|
||||||
ऊ
|
|
||||||
ब
|
|
||||||
ह
|
|
||||||
ग
|
|
||||||
द
|
|
||||||
ज
|
|
||||||
ड
|
|
||||||
|
|
||||||
ओ
|
|
||||||
ए
|
|
||||||
अ
|
|
||||||
इ
|
|
||||||
उ
|
|
||||||
प
|
|
||||||
र
|
|
||||||
क
|
|
||||||
त
|
|
||||||
च
|
|
||||||
ट
|
|
||||||
|
|
||||||
ऑ
|
|
||||||
्
|
|
||||||
ं
|
|
||||||
म
|
|
||||||
न
|
|
||||||
व
|
|
||||||
ल
|
|
||||||
स
|
|
||||||
य
|
|
||||||
क्ष
|
|
40
app/src/main/assets/layouts/marathi.json
Normal file
40
app/src/main/assets/layouts/marathi.json
Normal 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 }
|
||||||
|
]
|
||||||
|
]
|
|
@ -1,34 +0,0 @@
|
||||||
ौ
|
|
||||||
ै
|
|
||||||
ा
|
|
||||||
ी
|
|
||||||
ू
|
|
||||||
ब
|
|
||||||
ह
|
|
||||||
ग
|
|
||||||
द
|
|
||||||
ज
|
|
||||||
ड
|
|
||||||
|
|
||||||
ो
|
|
||||||
े
|
|
||||||
्
|
|
||||||
ि
|
|
||||||
ु
|
|
||||||
प
|
|
||||||
र
|
|
||||||
क
|
|
||||||
त
|
|
||||||
च
|
|
||||||
ट
|
|
||||||
|
|
||||||
ॉ
|
|
||||||
ॅ
|
|
||||||
ं
|
|
||||||
म
|
|
||||||
न
|
|
||||||
व
|
|
||||||
ल
|
|
||||||
स
|
|
||||||
य
|
|
||||||
क्ष
|
|
|
@ -64,10 +64,11 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
|
|
||||||
// todo: further plan
|
// todo: further plan
|
||||||
// migrate other languages/layouts to this style
|
// 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
|
// thai and lao number rows... they should probably have none, can't do it generically
|
||||||
// so handle it like korean
|
// 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
|
// 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
|
// test whether the layouts really are the same
|
||||||
// comparing params with both parsers looks good, see list of detected differences below
|
// 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
|
// 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...
|
// 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
|
// but currently it's still read from xml outside the keyboard parser, so that's fine for now
|
||||||
// issues:
|
// 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)
|
// 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)
|
// 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
|
// 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
|
// also check holo, there might be different default parameters
|
||||||
// and compare tablet layouts (how to best force it for both parsers?)
|
// and compare tablet layouts (how to best force it for both parsers?)
|
||||||
val keyParams = row[index1]
|
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)
|
if (keyParams.mLabel != xmlParams.mLabel)
|
||||||
// currency keys (shift symbol) arranged differently
|
// 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}")
|
Log.w(TAG, "label different: ${keyParams.mLabel} vs ${xmlParams.mLabel}")
|
||||||
if (keyParams.mCode != xmlParams.mCode)
|
if (keyParams.mCode != xmlParams.mCode)
|
||||||
Log.w(TAG, "code different: ${keyParams.mCode} vs ${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)
|
// 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
|
// malayalam delete also has LABEL_FLAGS_AUTO_X_SCALE, mine not
|
||||||
// tamil & telugu my delete has LABEL_FLAGS_AUTO_X_SCALE, original 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)}")
|
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
|
var currentX = 0f
|
||||||
row.forEach {
|
row.forEach {
|
||||||
it.setDimensionsFromRelativeSize(currentX, currentY)
|
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
|
currentX += it.mFullWidth
|
||||||
}
|
}
|
||||||
// need to truncate to int here, otherwise it may end up one pixel lower than original
|
// need to truncate to int here, otherwise it may end up one pixel lower than original
|
||||||
|
|
|
@ -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") {
|
} else if (!params.mId.mNumberRowEnabled && params.mId.isAlphabetKeyboard && params.mId.locale.language != "ko") {
|
||||||
// add number to the first 10 keys in first row
|
// add number to the first 10 keys in first row
|
||||||
// setting the correct moreKeys is handled in PopupSet
|
// 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 }
|
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()
|
val functionalKeysReversed = parseFunctionalKeys().reversed()
|
||||||
|
|
||||||
|
@ -73,6 +78,8 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
baseKeys.reversed().forEachIndexed { i, it ->
|
baseKeys.reversed().forEachIndexed { i, it ->
|
||||||
val row: List<KeyData> = if (i == 0) {
|
val row: List<KeyData> = if (i == 0) {
|
||||||
// add bottom row extra keys
|
// 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)
|
it + context.getString(R.string.key_def_extra_bottom_right)
|
||||||
.split(",").mapNotNull { if (it.isBlank()) null else it.trim().toTextKey() }
|
.split(",").mapNotNull { if (it.isBlank()) null else it.trim().toTextKey() }
|
||||||
} else {
|
} else {
|
||||||
|
@ -118,6 +125,8 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
// but that could also be determined in toKeyParams
|
// but that could also be determined in toKeyParams
|
||||||
val keyParams = key.compute(params).toKeyParams(params, keyWidth, defaultLabelFlags)
|
val keyParams = key.compute(params).toKeyParams(params, keyWidth, defaultLabelFlags)
|
||||||
paramsRow.add(keyParams)
|
paramsRow.add(keyParams)
|
||||||
|
if (DebugFlags.DEBUG_ENABLED)
|
||||||
|
Log.d(TAG, "adding key ${keyParams.mLabel}, ${keyParams.mCode}")
|
||||||
}
|
}
|
||||||
if (spacerWidth != 0f) {
|
if (spacerWidth != 0f) {
|
||||||
paramsRow.add(KeyParams.newSpacer(params, spacerWidth))
|
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)
|
val id = context.resources.getIdentifier("label_$this", "string", context.packageName)
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
val message = "no resource for label $this in ${params.mId}"
|
val message = "no resource for label $this in ${params.mId}"
|
||||||
Log.w(this::class.simpleName, message)
|
Log.w(TAG, message)
|
||||||
if (DebugFlags.DEBUG_ENABLED)
|
if (DebugFlags.DEBUG_ENABLED)
|
||||||
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
|
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
|
||||||
return this
|
return this
|
||||||
|
@ -559,6 +568,8 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private val TAG = KeyboardParser::class.simpleName
|
||||||
|
|
||||||
fun parseFromAssets(params: KeyboardParams, context: Context): ArrayList<ArrayList<KeyParams>>? {
|
fun parseFromAssets(params: KeyboardParams, context: Context): ArrayList<ArrayList<KeyParams>>? {
|
||||||
val id = params.mId
|
val id = params.mId
|
||||||
val layoutName = params.mId.mSubtype.keyboardLayoutSetName
|
val layoutName = params.mId.mSubtype.keyboardLayoutSetName
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue