feat(keyboard): app setting to override the numeric-input layout - #47
feat(keyboard): app setting to override the numeric-input layout#47SandyYuR wants to merge 8 commits into
Conversation
72aef92 to
f2e2f4d
Compare
…_Separator and KP_Equal key mappings Numpad keys sent through the simulated keyboard now always carry META_NUM_LOCK_ON so Android KeyCharacterMap produces the correct digit/symbol unicode characters instead of navigation keys. KP_Separator (0xffac -> KEYCODE_NUMPAD_COMMA) and KP_Equal (0xffbd -> KEYCODE_NUMPAD_EQUALS) join the generated fcitx<->android key mapping in both directions. The numpad keycode range is hoisted into a shared top-level constant so it is not reallocated on every simulated key event.
Numeric-only editors (TYPE_CLASS_NUMBER / TYPE_CLASS_PHONE) can now use a custom text keyboard layout via the new 数字键盘布局 app setting (keyboard settings, editor category). It opens a picker listing the layers of the currently enabled text keyboard layout file (base layouts plus ime:submode entries) with the built-in number keypad as the default; selecting a layer short-circuits the built-in NumberKeyboard for numeric editors. Stale or unresolvable values fall back to the built-in keypad. The option lives only in app settings: TextKeyboardLayout.json keeps defining text keyboard layouts exclusively, with no data-structure or parsing changes. At runtime the override reuses the existing forced-layer pipeline as a fallback value (getLayout/height/aux bar/signature untouched), and the BACK layer history is cleared on input restart. PIN-style numeric password fields are included; their candidate bar stays empty via the Password capability flag now derived uniformly for NUMBER and PHONE classes.
Pressing an explicit user key targeting the text keyboard (e.g. an ABC-style LayoutSwitchKey with switch target Text) now resets latched and one-shot layers in addition to the numeric override handling. Previously a MacroKey layer switch (TO/OSL) kept its forced layer in the controller, so while the keyboard was already the TextKeyboard the switchLayout early return left the latched layer in place and the key appeared to do nothing. Also clears the BACK layer history on the explicit reset so a later BACK key cannot resurrect a stale layer.
|
补充修复(d421ba66):MacroKey 层切换(TO/OSL)锁存的层会让 LayoutSwitchKey 切回文本键盘失效。 原因:层切换走 修复:显式用户按键切回文本键盘时,同时清空 latched/one-shot 层与 BACK 历史栈, 日志复现:BaseKeyboard executeMacro |
A MacroKey layer switch (TO) applies the latched layer via applyEffectiveTextLayer and then relayouts through switchLayout(Text, remember=false). That internal Text->Text switch hit the releaseManualNumericLayout branch inherited from the layoutswitch-key fix: after the user had manually shown the numeric keyboard with a LayoutSwitchKey, manual=true, so the relayout reset forcedKey to the (null) session fallback and clobbered the layer that was latched a moment earlier - the keyboard jumped back to the text main keyboard instead of the target layer. Internal Text->Text relayouts (layer switches, one-shot consumption, onStartInput) now leave the manual numeric state untouched; releasing it remains exclusive to explicit user keys targeting the text keyboard (fromUserKey=true), which already clears latched layers as well.
|
补充修复(9358ec9e,与上一条修复同区域):LayoutSwitchKey 手动切出数字键盘后,MacroKey 层切换被冲掉、落回文本主键盘。 原因:MacroKey TO 层切换在 修复:内部 Text→Text 重排(层切换、one-shot 消费、onStartInput)不再触碰手动数字布局状态;
|

数字输入框使用自定义布局(应用设置)
键盘设置 → 编辑器分类下新增「数字键盘布局」设置项,与「文本键盘布局文件」设置并列。
点击后弹出单选列表:
复用布局编辑器的 LayoutDataManager 解析逻辑,与编辑页下拉枚举一致)。
选择某个层后,数字输入框(TYPE_CLASS_NUMBER / TYPE_CLASS_PHONE,含 PIN 数字密码框)
短路内置数字键盘并展示该自定义布局;用户自行指定、自行负责,布局不存在或值失效时回退内置键盘。
实现解耦说明
的数据结构与解析逻辑完全未动,未混入任何数字键盘相关定义,避免深耦合、方便后续维护。
(getLayout/高度/辅助栏/签名)零改动、无新增分支;BACK 层历史在输入重启时清空。
simulatedMetaState() 拆分,并为该函数补充 keyCode 参数,自定义按钮路径同样受益。
数字键盘按键修复
PIN 数字密码框
Password capability flag 对 NUMBER/PHONE 两类统一推导(TYPE_NUMBER_VARIATION_PASSWORD),
候选栏与文本密码框一致置空。
已在 SandyYuR/fcitx5-android 的 fx 分支(同步上游最新提交)构建并实测。