mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-18 16:03:12 +00:00
add some more layouts
This commit is contained in:
parent
26c890a3e2
commit
38d8365e5b
13 changed files with 408 additions and 12 deletions
|
@ -71,6 +71,13 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
|||
// 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
|
||||
// check the kbd_files for thing like touchPositionCorrectionData
|
||||
// issues:
|
||||
// armenian has label flag fontNormal on all keys -> how to do? define on every letter, or have some other way of doing this?
|
||||
// add such a label flag to languageKeyTexts (apply only to alphabet layouts)
|
||||
// fontNormal: armenian, urdu, thai, ...
|
||||
// armenian bottom row: functional keys should be narrower
|
||||
// urdu: no labels because the moreKeys are languageMoreKeys -> need the moreKeys setting soon (at least setting to show first language moreKey if no symbol)
|
||||
// migrate pcqwerty to this style
|
||||
// this will be more complicated...
|
||||
// linked shift keys might be easy
|
||||
|
@ -156,7 +163,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
|
||||
&& 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)
|
||||
|
|
|
@ -240,7 +240,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
|||
|
||||
private fun getNumberRow(): ArrayList<KeyParams> =
|
||||
params.mLocaleKeyTexts.getNumberRow().mapTo(ArrayList()) {
|
||||
it.toKeyParams(params, labelFlags = Key.LABEL_FLAGS_DISABLE_HINT_LABEL or defaultLabelFlags)
|
||||
it.toKeyParams(params, additionalLabelFlags = Key.LABEL_FLAGS_DISABLE_HINT_LABEL or defaultLabelFlags)
|
||||
}
|
||||
|
||||
private fun getFunctionalKeyParams(def: String, label: String? = null, moreKeys: Array<String>? = null): KeyParams {
|
||||
|
|
|
@ -20,6 +20,8 @@ import org.dslul.openboard.inputmethod.latin.common.StringUtils
|
|||
// added toKeyParams for non-abstract KeyData
|
||||
// compute is using KeyboardParams (for shift state and variation)
|
||||
// char_width_selector and kana_selector throw an error (not yet supported)
|
||||
// added labelFlags to keyDate
|
||||
// added manualOrLocked for shift_state_selector
|
||||
/**
|
||||
* Basic interface for a key data object. Base for all key data objects across the IME, such as text, emojis and
|
||||
* selectors. The implementation is as abstract as possible, as different features require different implementations.
|
||||
|
@ -65,6 +67,7 @@ interface KeyData : AbstractKeyData {
|
|||
val label: String
|
||||
val groupId: Int
|
||||
val popup: PopupSet<AbstractKeyData> // not nullable because can't add number otherwise
|
||||
val labelFlags: Int
|
||||
|
||||
// groups (currently) not supported
|
||||
companion object {
|
||||
|
@ -107,7 +110,7 @@ interface KeyData : AbstractKeyData {
|
|||
|| code == KeyCode.HALF_SPACE || code == KeyCode.KESHIDA)
|
||||
}
|
||||
|
||||
fun toKeyParams(params: KeyboardParams, width: Float = params.mDefaultRelativeKeyWidth, labelFlags: Int = 0): KeyParams {
|
||||
fun toKeyParams(params: KeyboardParams, width: Float = params.mDefaultRelativeKeyWidth, additionalLabelFlags: Int = 0): KeyParams {
|
||||
require(type == KeyType.CHARACTER) { "currently only KeyType.CHARACTER is supported" }
|
||||
require(groupId == GROUP_DEFAULT) { "currently only KeyData.GROUP_DEFAULT is supported" }
|
||||
require(code >= 0) { "functional codes ($code) not (yet) supported" }
|
||||
|
@ -120,7 +123,7 @@ interface KeyData : AbstractKeyData {
|
|||
label.rtlLabel(params), // todo (when supported): convert special labels to keySpec
|
||||
params,
|
||||
width,
|
||||
labelFlags, // todo (non-latin): label flags... maybe relevant for some languages
|
||||
labelFlags or additionalLabelFlags,
|
||||
Key.BACKGROUND_TYPE_NORMAL, // todo (when supported): determine type
|
||||
popup.toMoreKeys(params),
|
||||
)
|
||||
|
@ -130,7 +133,7 @@ interface KeyData : AbstractKeyData {
|
|||
code, // todo (when supported): convert codes < 0, because florisboard layouts should still be usable
|
||||
params,
|
||||
width,
|
||||
labelFlags,
|
||||
labelFlags or additionalLabelFlags,
|
||||
Key.BACKGROUND_TYPE_NORMAL,
|
||||
popup.toMoreKeys(params),
|
||||
)
|
||||
|
@ -204,13 +207,14 @@ class ShiftStateSelector(
|
|||
val shiftedAutomatic: AbstractKeyData? = null,
|
||||
val capsLock: AbstractKeyData? = null,
|
||||
val default: AbstractKeyData? = null,
|
||||
val manualOrLocked: AbstractKeyData? = null,
|
||||
) : AbstractKeyData {
|
||||
override fun compute(params: KeyboardParams): KeyData? {
|
||||
return when (params.mId.mElementId) {
|
||||
KeyboardId.ELEMENT_ALPHABET, KeyboardId.ELEMENT_SYMBOLS -> unshifted ?: default
|
||||
KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED -> shiftedManual ?: shifted ?: default
|
||||
KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED -> shiftedManual ?: manualOrLocked ?: shifted ?: default
|
||||
KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED -> shiftedAutomatic ?: shifted ?: default
|
||||
KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED, KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED -> capsLock ?: shifted ?: default
|
||||
KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED, KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED -> capsLock ?: manualOrLocked ?: shifted ?: default
|
||||
else -> default // or rather unshifted?
|
||||
}?.compute(params)
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ class TextKeyData(
|
|||
override val code: Int = KeyCode.UNSPECIFIED,
|
||||
override val label: String = "",
|
||||
override val groupId: Int = KeyData.GROUP_DEFAULT,
|
||||
override val popup: PopupSet<AbstractKeyData> = PopupSet()
|
||||
override val popup: PopupSet<AbstractKeyData> = PopupSet(),
|
||||
override val labelFlags: Int = 0
|
||||
) : KeyData {
|
||||
override fun compute(params: KeyboardParams): KeyData {
|
||||
// if (evaluator.isSlot(this)) { // todo: currency key stuff probably should be taken from florisboard too
|
||||
|
@ -75,7 +76,8 @@ class AutoTextKeyData(
|
|||
override val code: Int = KeyCode.UNSPECIFIED,
|
||||
override val label: String = "",
|
||||
override val groupId: Int = KeyData.GROUP_DEFAULT,
|
||||
override val popup: PopupSet<AbstractKeyData> = PopupSet()
|
||||
override val popup: PopupSet<AbstractKeyData> = PopupSet(),
|
||||
override val labelFlags: Int = 0
|
||||
) : KeyData {
|
||||
// state and recompute not needed, as upcasing is done when creating KeyParams
|
||||
|
||||
|
@ -113,7 +115,8 @@ class MultiTextKeyData(
|
|||
val codePoints: IntArray = intArrayOf(),
|
||||
override val label: String = "",
|
||||
override val groupId: Int = KeyData.GROUP_DEFAULT,
|
||||
override val popup: PopupSet<AbstractKeyData> = PopupSet()
|
||||
override val popup: PopupSet<AbstractKeyData> = PopupSet(),
|
||||
override val labelFlags: Int = 0
|
||||
) : KeyData {
|
||||
@Transient override val code: Int = KeyCode.MULTIPLE_CODE_POINTS
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue