mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-19 00:10:20 +00:00
non-null comute for KeyData, comments
This commit is contained in:
parent
3f30d5ce1f
commit
bd3e73ea10
3 changed files with 18 additions and 7 deletions
|
@ -65,12 +65,18 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
// todo: further plan
|
// todo: further plan
|
||||||
// release next version before continuing, testing current state for a while is likely necessary
|
// release next version before continuing, testing current state for a while is likely necessary
|
||||||
// migrate other languages/layouts to this style
|
// migrate other languages/layouts to this style
|
||||||
// may be tricky in some cases, like additional row, or no shift key, or pc qwerty layout
|
// may be tricky in some cases, like additional row, or no shift key
|
||||||
// also the integrated number row might cause issues, and should be removed / ignored
|
// also the integrated number row is weird together with the number row setting, and should be removed / ignored
|
||||||
// at least some of these layouts will need more complicated definition
|
// at least some of these layouts will need more complicated definition and have separate shift layouts
|
||||||
// test the zwnj key
|
// test the zwnj key
|
||||||
// label flags: some should be set by keyboard, not by row/letter
|
// label flags: some should be set by keyboard, not by row/letter
|
||||||
// e.g. arabic looks weird with number row in holo being bold, but all other letters normal
|
// e.g. arabic looks weird with number row in holo being bold, but all other letters normal
|
||||||
|
// migrate pcqwerty to this style
|
||||||
|
// this will be more complicated...
|
||||||
|
// linked shift keys might be easy
|
||||||
|
// distance below number row with high row, but reduced key height?
|
||||||
|
// consider settings key needs to disappear if device is locked
|
||||||
|
// ignore number row setting?
|
||||||
// migrate keypad layouts to this style
|
// migrate keypad layouts to this style
|
||||||
// will need more configurable layout definition -> another parser, or do it with compatible jsons
|
// will need more configurable layout definition -> another parser, or do it with compatible jsons
|
||||||
// make the remove duplicate moreKey thing an option?
|
// make the remove duplicate moreKey thing an option?
|
||||||
|
|
|
@ -110,7 +110,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
for (key in row) {
|
for (key in row) {
|
||||||
// todo: maybe autoScale / autoXScale if label has more than 2 characters (exception for emojis?)
|
// todo: maybe autoScale / autoXScale if label has more than 2 characters (exception for emojis?)
|
||||||
// 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) ?: continue
|
val keyParams = key.compute(params).toKeyParams(params, keyWidth, defaultLabelFlags)
|
||||||
paramsRow.add(keyParams)
|
paramsRow.add(keyParams)
|
||||||
}
|
}
|
||||||
if (spacerWidth != 0f) {
|
if (spacerWidth != 0f) {
|
||||||
|
@ -130,7 +130,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
// so the symbols keyboard is higher than the normal one
|
// so the symbols keyboard is higher than the normal one
|
||||||
// not a new issue, but should be solved in this migration
|
// not a new issue, but should be solved in this migration
|
||||||
// how? possibly scale all keyboards to height of main alphabet? (consider suggestion strip)
|
// how? possibly scale all keyboards to height of main alphabet? (consider suggestion strip)
|
||||||
keysInRows.forEach { it.forEach { it.mRelativeHeight *= heightRescale } }
|
keysInRows.forEach { key -> key.forEach { it.mRelativeHeight *= heightRescale } }
|
||||||
}
|
}
|
||||||
|
|
||||||
return keysInRows
|
return keysInRows
|
||||||
|
@ -295,7 +295,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
"!icon/space_key|!code/key_space", // !icon/space_key_for_number_layout in number layout, but not on tablet
|
"!icon/space_key|!code/key_space", // !icon/space_key_for_number_layout in number layout, but not on tablet
|
||||||
params,
|
params,
|
||||||
width, // will not be used for normal space (only in number layouts)
|
width, // will not be used for normal space (only in number layouts)
|
||||||
0, // todo (later): alignIconToBottom for non-tablet number layout
|
0, // todo (later): alignIconToBottom for non-tablet number layout -> check what it does / whether it's necessary
|
||||||
Key.BACKGROUND_TYPE_SPACEBAR,
|
Key.BACKGROUND_TYPE_SPACEBAR,
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
|
@ -342,7 +342,9 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
FunctionalKey.EMOJI_COM -> if (params.mId.mMode == KeyboardId.MODE_URL || params.mId.mMode == KeyboardId.MODE_EMAIL)
|
FunctionalKey.EMOJI_COM -> if (params.mId.mMode == KeyboardId.MODE_URL || params.mId.mMode == KeyboardId.MODE_EMAIL)
|
||||||
getFunctionalKeyParams(FunctionalKey.COM, width)
|
getFunctionalKeyParams(FunctionalKey.COM, width)
|
||||||
else getFunctionalKeyParams(FunctionalKey.EMOJI, width)
|
else getFunctionalKeyParams(FunctionalKey.EMOJI, width)
|
||||||
FunctionalKey.COM -> KeyParams( // todo: label and moreKeys could be in localeKeyTexts, handled like currency key
|
FunctionalKey.COM -> KeyParams(
|
||||||
|
// todo (later): label and moreKeys could be in localeKeyTexts, handled like currency key
|
||||||
|
// better not in the text files, because it should be handled in a more fine grained way
|
||||||
".com",
|
".com",
|
||||||
params,
|
params,
|
||||||
width,
|
width,
|
||||||
|
|
|
@ -99,6 +99,9 @@ interface KeyData : AbstractKeyData {
|
||||||
const val GROUP_KANA: Int = 97
|
const val GROUP_KANA: Int = 97
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make it non-nullable for simplicity, and to reflect current implementations
|
||||||
|
override fun compute(params: KeyboardParams): KeyData
|
||||||
|
|
||||||
fun isSpaceKey(): Boolean {
|
fun isSpaceKey(): Boolean {
|
||||||
return type == KeyType.CHARACTER && (code == KeyCode.SPACE || code == KeyCode.CJK_SPACE
|
return type == KeyType.CHARACTER && (code == KeyCode.SPACE || code == KeyCode.CJK_SPACE
|
||||||
|| code == KeyCode.HALF_SPACE || code == KeyCode.KESHIDA)
|
|| code == KeyCode.HALF_SPACE || code == KeyCode.KESHIDA)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue