mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 13:49:13 +00:00
add numpad landscape layout
This commit is contained in:
parent
615fde1a7b
commit
57423626d3
3 changed files with 53 additions and 81 deletions
46
app/src/main/assets/layouts/numpad_landscape.json
Normal file
46
app/src/main/assets/layouts/numpad_landscape.json
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
[
|
||||||
|
[
|
||||||
|
{ "label": "(", "popup": { "relevant": [ { "label": "[" }, { "label": "{" } ] } },
|
||||||
|
{ "label": ")", "popup": { "relevant": [ { "label": "]" }, { "label": "}" } ] } },
|
||||||
|
{ "label": ":" },
|
||||||
|
{ "label": "1", "type": "numeric" },
|
||||||
|
{ "label": "2", "type": "numeric" },
|
||||||
|
{ "label": "3", "type": "numeric" },
|
||||||
|
{ "label": "+", "popup": { "main": { "label": "±" } } },
|
||||||
|
{ "label": "-", "popup": { "main": { "label": "~" } } },
|
||||||
|
{ "label": "space" }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ "label": "!" },
|
||||||
|
{ "label": "?" },
|
||||||
|
{ "label": ";" },
|
||||||
|
{ "label": "4", "type": "numeric" },
|
||||||
|
{ "label": "5", "type": "numeric" },
|
||||||
|
{ "label": "6", "type": "numeric" },
|
||||||
|
{ "label": "*", "popup": { "main": { "label": "×" } } },
|
||||||
|
{ "label": "/", "popup": { "main": { "label": "÷" } } },
|
||||||
|
{ "label": "delete" }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ "label": "|" },
|
||||||
|
{ "label": "$$$" },
|
||||||
|
{ "label": "&" },
|
||||||
|
{ "label": "7", "type": "numeric" },
|
||||||
|
{ "label": "8", "type": "numeric" },
|
||||||
|
{ "label": "9", "type": "numeric" },
|
||||||
|
{ "label": "#" },
|
||||||
|
{ "label": "%", "popup": { "main": { "label": "‰" } } },
|
||||||
|
{ "label": "action" }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ "label": "alpha" },
|
||||||
|
{ "label": "<", "popup": { "main": { "label": "≤" } } },
|
||||||
|
{ "label": ">", "popup": { "main": { "label": "≥" } } },
|
||||||
|
{ "label": "comma" },
|
||||||
|
{ "label": "0", "type": "numeric" },
|
||||||
|
{ "label": "period" },
|
||||||
|
{ "label": "=", "popup": { "relevant": [ { "label": "≠"}, { "label": "≈"} ] } },
|
||||||
|
{ "label": "=", "popup": { "relevant": [ { "label": "≠"}, { "label": "≈"} ] } },
|
||||||
|
{ "label": "symbol" }
|
||||||
|
]
|
||||||
|
]
|
|
@ -67,13 +67,8 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
return this
|
return this
|
||||||
|
|
||||||
// todo: further plan
|
// todo: further plan
|
||||||
// number layouts missing details
|
// make split layout work for emoji keyboard
|
||||||
// landscape: numpad layout has some extra keys
|
|
||||||
// tablet: number and phone layout have some extra keys (unify with numpad, so that extra keys show both in land and sw600? or only land?)
|
|
||||||
// now all layouts should be using the new parser -> throw an error instead of falling back to old parser
|
|
||||||
// more settings for localized number row, so it can be different in shift or symbols
|
// more settings for localized number row, so it can be different in shift or symbols
|
||||||
// migrate moreKeys and moreSuggestions to this style?
|
|
||||||
// at least they should not make use of the KeyTextsSet/Table (and of the XmlKeyboardParser?)
|
|
||||||
// setting which moreKeys to prefer (default: symbol or important language, always symbol, always language)
|
// setting which moreKeys to prefer (default: symbol or important language, always symbol, always language)
|
||||||
// setting whether to show duplicate moreKeys (describe properly what it actually does)
|
// setting whether to show duplicate moreKeys (describe properly what it actually does)
|
||||||
// some keyboard_layout_set have supportedScript that is enum synced with script id in ScriptUtils
|
// some keyboard_layout_set have supportedScript that is enum synced with script id in ScriptUtils
|
||||||
|
@ -159,83 +154,12 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
if (loadFromAssets(id) != null) {
|
if (loadFromAssets(id) != null) {
|
||||||
if (!DebugFlags.DEBUG_ENABLED)
|
|
||||||
return this
|
|
||||||
// comparison of old and new parser below, todo: remove once testing is complete
|
|
||||||
val keysInRowsFromXml = XmlKeyboardParser(xmlId, mParams, mContext).use { keyboardParser ->
|
|
||||||
keyboardParser.parseKeyboard()
|
|
||||||
}
|
|
||||||
if (keysInRowsFromXml.size != keysInRows.size) {
|
|
||||||
Log.w(TAG, "different sizes: ${keysInRows.size} vs ${keysInRowsFromXml.size}")
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
keysInRowsFromXml.forEachIndexed { index, xmlRow ->
|
|
||||||
val row = keysInRows[index].filter { !it.isSpacer }
|
|
||||||
val xmlRow2 = xmlRow.filter { !it.isSpacer }
|
|
||||||
if (row.size != xmlRow2.size) {
|
|
||||||
Log.w(TAG, "different row sizes in row ${index + 1}")
|
|
||||||
return@forEachIndexed
|
|
||||||
}
|
|
||||||
xmlRow2.forEachIndexed { index1, xmlParams ->
|
|
||||||
val keyParams = row[index1]
|
|
||||||
if (keyParams.mLabel != xmlParams.mLabel)
|
|
||||||
// currency keys (shift symbol) arranged differently
|
|
||||||
// obviously number row differences with possibly localized variants
|
|
||||||
Log.w(TAG, "label different: ${keyParams.mLabel} vs ${xmlParams.mLabel}")
|
|
||||||
if (keyParams.mMoreKeys == null && xmlParams.mMoreKeys != null)
|
|
||||||
Log.w(TAG, "moreKeys null for ${keyParams.mLabel} / ${keyParams.mCode}, but xml not null")
|
|
||||||
else if (xmlParams.mMoreKeys == null && keyParams.mMoreKeys != null)
|
|
||||||
// for ?123 key, wtf why are there moreKeys? can't see them anyway...
|
|
||||||
Log.w(TAG, "moreKeys not null for ${keyParams.mLabel} / ${keyParams.mCode}, but xml null")
|
|
||||||
else if (xmlParams.mMoreKeys == null || keyParams.mMoreKeys == null || keyParams.mMoreKeys.contentEquals(xmlParams.mMoreKeys))
|
|
||||||
Unit
|
|
||||||
else if (keyParams.mMoreKeys!!.size < xmlParams.mMoreKeys!!.size) {
|
|
||||||
if (keyParams.mMoreKeys!!.size - xmlParams.mMoreKeys!!.size == -1 && keyParams.mCode.toChar().lowercase() == "s")
|
|
||||||
Log.i(TAG, "missing moreKeys for ${keyParams.mLabel} / ${keyParams.mCode}")
|
|
||||||
else
|
|
||||||
Log.w(TAG, "missing moreKeys for ${keyParams.mLabel} / ${keyParams.mCode}")
|
|
||||||
} else if (keyParams.mMoreKeys!!.size > xmlParams.mMoreKeys!!.size) {
|
|
||||||
if (keyParams.mMoreKeys!!.toList().containsAll(xmlParams.mMoreKeys!!.toList()))
|
|
||||||
Log.i(TAG, "more moreKeys for ${keyParams.mLabel} / ${keyParams.mCode}, first same: ${keyParams.mMoreKeys?.firstOrNull() == xmlParams.mMoreKeys?.firstOrNull() }" +
|
|
||||||
", contains all original: true") // not really an issue i would say
|
|
||||||
else
|
|
||||||
Log.w(TAG, "more moreKeys for ${keyParams.mLabel} / ${keyParams.mCode}, first same: ${keyParams.mMoreKeys?.firstOrNull() == xmlParams.mMoreKeys?.firstOrNull() }" +
|
|
||||||
", contains all original: false")
|
|
||||||
} else if (!keyParams.mMoreKeys!!.toList().containsAll(xmlParams.mMoreKeys!!.toList()))
|
|
||||||
Log.w(TAG, "same size but missing moreKeys for ${keyParams.mLabel} / ${keyParams.mCode}")
|
|
||||||
if (keyParams.mCode != xmlParams.mCode)
|
|
||||||
Log.w(TAG, "code different: ${keyParams.mCode} vs ${xmlParams.mCode}")
|
|
||||||
if (keyParams.mIconId != xmlParams.mIconId)
|
|
||||||
Log.w(TAG, "icon different: ${keyParams.mIconId} vs ${xmlParams.mIconId}")
|
|
||||||
if (keyParams.mMoreKeysColumnAndFlags != xmlParams.mMoreKeysColumnAndFlags)
|
|
||||||
// symbols parentheses, symbols shift,
|
|
||||||
Log.w(TAG, "mMoreKeysColumnAndFlags different for ${keyParams.mLabel} / ${keyParams.mCode}: ${keyParams.mMoreKeysColumnAndFlags} vs ${xmlParams.mMoreKeysColumnAndFlags}")
|
|
||||||
if (keyParams.mHintLabel != xmlParams.mHintLabel
|
|
||||||
&& keyParams.mCode.toChar().lowercase() !in listOf("ö", "ä", "ü", "å", "ø", "æ", "é", "è", "à") // known, and imo irrelevant resp even better (but could be changed)
|
|
||||||
&& keyParams.mCode != '.'.code // happens for arabic, but really... hint label on period?
|
|
||||||
)
|
|
||||||
// extra and number keys are the difference so far
|
|
||||||
// persian has small difference
|
|
||||||
// khmer has some difference
|
|
||||||
// urdu has a lot of difference
|
|
||||||
Log.w(TAG, "hint label different for ${keyParams.mLabel} / ${keyParams.mCode}: ${keyParams.mHintLabel} vs ${xmlParams.mHintLabel}")
|
|
||||||
if (keyParams.mLabelFlags != xmlParams.mLabelFlags
|
|
||||||
&& !(keyParams.mLabelFlags - xmlParams.mLabelFlags == 0x40000000 && (mParams.mId.mElementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED || mParams.mId.mElementId == KeyboardId.ELEMENT_SYMBOLS)) // ignore the disableHintLabel flag
|
|
||||||
&& !(keyParams.mCode == -5 && keyParams.mLabelFlags - xmlParams.mLabelFlags == -0x10) // delete key with fontNormal (doesn't matter, happens because flags are set for entire row)
|
|
||||||
&& !(keyParams.mCode == -1 && keyParams.mLabelFlags - xmlParams.mLabelFlags == -0x10) // shift key with fontNormal (doesn't matter, happens because flags are set for entire row)
|
|
||||||
&& !(keyParams.mCode == -5 && keyParams.mLabelFlags - xmlParams.mLabelFlags == -0x4010) // delete key with fontNormal|autoXScale (doesn't matter, happens because flags are set for entire row)
|
|
||||||
&& !(keyParams.mCode == -1 && keyParams.mLabelFlags - xmlParams.mLabelFlags == -0x4010) // shift key with fontNormal|autoXScale (doesn't matter, happens because flags are set for entire row)
|
|
||||||
&& !(keyParams.mLabelFlags - xmlParams.mLabelFlags == 0x10 && mParams.mId.mSubtype.keyboardLayoutSetName == "bengali_unijoy") // bangla (bd) doesn't have fontNormal, but for me it has -> that's fine, imo better
|
|
||||||
)
|
|
||||||
Log.w(TAG, "label flags different for ${keyParams.mLabel} / ${keyParams.mCode}: ${keyParams.mLabelFlags.toString(16)} vs ${xmlParams.mLabelFlags.toString(16)}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
if (DebugFlags.DEBUG_ENABLED) {
|
if (DebugFlags.DEBUG_ENABLED) {
|
||||||
// looks like only emoji keyboards are still using the old parser, which is expected
|
Log.e(TAG, "falling back to old parser for $id")
|
||||||
Log.w(TAG, "falling back to old parser for $id")
|
|
||||||
Toast.makeText(mContext, "using old parser for $id", Toast.LENGTH_LONG).show()
|
Toast.makeText(mContext, "using old parser for $id", Toast.LENGTH_LONG).show()
|
||||||
|
// todo throw error?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mParams.mId = id
|
mParams.mId = id
|
||||||
|
|
|
@ -222,7 +222,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
|
|
||||||
private fun createNumericRows(baseKeys: MutableList<List<KeyData>>): ArrayList<ArrayList<KeyParams>> {
|
private fun createNumericRows(baseKeys: MutableList<List<KeyData>>): ArrayList<ArrayList<KeyParams>> {
|
||||||
val keysInRows = ArrayList<ArrayList<KeyParams>>()
|
val keysInRows = ArrayList<ArrayList<KeyParams>>()
|
||||||
if (context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
if (context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && params.mId.mElementId != KeyboardId.ELEMENT_NUMPAD) {
|
||||||
// add padding here instead of using xml (actually this is not good... todo (later))
|
// add padding here instead of using xml (actually this is not good... todo (later))
|
||||||
params.mLeftPadding = (params.mOccupiedWidth * 0.1f).toInt()
|
params.mLeftPadding = (params.mOccupiedWidth * 0.1f).toInt()
|
||||||
params.mRightPadding = (params.mOccupiedWidth * 0.1f).toInt()
|
params.mRightPadding = (params.mOccupiedWidth * 0.1f).toInt()
|
||||||
|
@ -729,7 +729,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSpaceLabel(): String =
|
private fun getSpaceLabel(): String =
|
||||||
if (params.mId.mElementId <= KeyboardId.ELEMENT_SYMBOLS_SHIFTED || isTablet())
|
if (params.mId.mElementId <= KeyboardId.ELEMENT_SYMBOLS_SHIFTED)
|
||||||
"!icon/space_key|!code/key_space"
|
"!icon/space_key|!code/key_space"
|
||||||
else "!icon/space_key_for_number_layout|!code/key_space"
|
else "!icon/space_key_for_number_layout|!code/key_space"
|
||||||
|
|
||||||
|
@ -748,6 +748,8 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
||||||
id.mElementId == KeyboardId.ELEMENT_SYMBOLS -> SimpleKeyboardParser(params, context).parseLayoutFromAssets("symbols")
|
id.mElementId == KeyboardId.ELEMENT_SYMBOLS -> SimpleKeyboardParser(params, context).parseLayoutFromAssets("symbols")
|
||||||
id.mElementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED
|
id.mElementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED
|
||||||
-> SimpleKeyboardParser(params, context).parseLayoutFromAssets("symbols_shifted")
|
-> SimpleKeyboardParser(params, context).parseLayoutFromAssets("symbols_shifted")
|
||||||
|
id.mElementId == KeyboardId.ELEMENT_NUMPAD && context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||||
|
-> JsonKeyboardParser(params, context).parseLayoutFromAssets("numpad_landscape")
|
||||||
id.mElementId == KeyboardId.ELEMENT_NUMPAD -> JsonKeyboardParser(params, context).parseLayoutFromAssets("numpad")
|
id.mElementId == KeyboardId.ELEMENT_NUMPAD -> JsonKeyboardParser(params, context).parseLayoutFromAssets("numpad")
|
||||||
id.mElementId == KeyboardId.ELEMENT_NUMBER -> JsonKeyboardParser(params, context).parseLayoutFromAssets("number")
|
id.mElementId == KeyboardId.ELEMENT_NUMBER -> JsonKeyboardParser(params, context).parseLayoutFromAssets("number")
|
||||||
id.mElementId == KeyboardId.ELEMENT_PHONE -> JsonKeyboardParser(params, context).parseLayoutFromAssets("phone")
|
id.mElementId == KeyboardId.ELEMENT_PHONE -> JsonKeyboardParser(params, context).parseLayoutFromAssets("phone")
|
||||||
|
|
Loading…
Add table
Reference in a new issue