mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-18 16:03:12 +00:00
add slavic layouts for new parser
This commit is contained in:
parent
a1dbfedc0b
commit
26c890a3e2
18 changed files with 383 additions and 4 deletions
|
@ -63,7 +63,6 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
|||
return this
|
||||
|
||||
// todo: further plan
|
||||
// release next version before continuing, testing current state for a while is likely necessary
|
||||
// migrate other languages/layouts to this style
|
||||
// may be tricky in some cases, like additional row, or no shift key
|
||||
// also the integrated number row is weird together with the number row setting, and should be removed / ignored
|
||||
|
@ -71,6 +70,7 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
|||
// test the zwnj key
|
||||
// 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
|
||||
// careful with korean, iirc the layouts are copied somewhere in the code -> try reading them instead of having them duplicate hardcoded
|
||||
// migrate pcqwerty to this style
|
||||
// this will be more complicated...
|
||||
// linked shift keys might be easy
|
||||
|
@ -119,6 +119,9 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
|||
// does glide typing work with multiple letters on one key? if not, users should be notified
|
||||
// maybe allow users to define their own symbol and shift-symbol layouts
|
||||
// allow users to import layouts, which essentially just fills the text from a file
|
||||
// add setting to use moreKeys from symbol layout (always, never, only if none defined)
|
||||
// should also have sth related to hint, because hint and start morekey maybe should stay
|
||||
// option to add extra keys for all layouts?
|
||||
|
||||
// labelFlags should be set correctly
|
||||
// alignHintLabelToBottom: on lxx and rounded themes, but did not find what it actually does...
|
||||
|
@ -153,6 +156,7 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
|||
|
||||
fun loadFromXml(xmlId: Int, id: KeyboardId): KeyboardBuilder<KP> {
|
||||
if (Settings.getInstance().current.mUseNewKeyboardParsing
|
||||
// && id.mElementId != KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED && id.mElementId != KeyboardId.ELEMENT_SYMBOLS_SHIFTED
|
||||
&& this::class == KeyboardBuilder::class // otherwise this will apply to moreKeys and moreSuggestions, and then some parameters are off
|
||||
) {
|
||||
if (loadFromAssets(id) != null)
|
||||
|
|
|
@ -556,16 +556,19 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
|||
-> SimpleKeyboardParser(params, context).parseLayoutFromAssets("symbols_shifted")
|
||||
!id.isAlphabetKeyboard -> null
|
||||
layoutFileNames.contains("$layoutName.json") -> JsonKeyboardParser(params, context).parseLayoutFromAssets(layoutName)
|
||||
layoutFileNames.contains("${getSimpleLayoutName(layoutName)}.txt")
|
||||
layoutFileNames.contains("${getSimpleLayoutName(layoutName, params)}.txt")
|
||||
-> SimpleKeyboardParser(params, context).parseLayoutFromAssets(layoutName)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic // unsupported without JvmStatic
|
||||
protected fun getSimpleLayoutName(layoutName: String) = when (layoutName) {
|
||||
// todo: should be removed in the end (after removing old parser), and the internal layout names changed for easier finding
|
||||
// currently it's spread out everywhere... method.xml, locale_and_extra_value_to_keyboard_layout_set_map, getKeyboardLayoutNameForLocale, ...
|
||||
protected fun getSimpleLayoutName(layoutName: String, params: KeyboardParams) = when (layoutName) {
|
||||
"swiss", "german", "serbian_qwertz" -> "qwertz"
|
||||
"nordic", "spanish" -> "qwerty"
|
||||
"south_slavic", "east_slavic" -> params.mId.locale.language // layouts split per language now, much less convoluted
|
||||
else -> layoutName
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class SimpleKeyboardParser(private val params: KeyboardParams, private val conte
|
|||
&& params.mId.mSubtype.keyboardLayoutSetName in listOf("nordic", "spanish", "german", "swiss", "serbian_qwertz")
|
||||
|
||||
override fun getLayoutFromAssets(layoutName: String) =
|
||||
context.assets.open("layouts/${getSimpleLayoutName(layoutName)}.txt").reader().readText()
|
||||
context.assets.open("layouts/${getSimpleLayoutName(layoutName, params)}.txt").reader().readText()
|
||||
|
||||
override fun parseCoreLayout(layoutContent: String): MutableList<List<KeyData>> {
|
||||
val rowStrings = layoutContent.replace("\r\n", "\n").split("\n\n")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue