Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Resizing or toggling the floating keyboard can unexpectedly commit the active composition and change ASCII mode because it reruns keyboard-switch initialization instead of preserving live input state.
4 open issues
What changed in this PR
Adds a floating-card mode to Trime’s keyboard, addressing the landscape floating-keyboard request in #2094.
Changes:
- Enables floating mode by default in landscape, with optional portrait mode and saved geometry.
- Adds dragging, snapping, resizing, collapsing, and docking, with overlay touch bounds and an embedded composer.
- Adds geometry and mode tests, localized labels, and control icons.
| File | Description |
|---|---|
app/src/test/java/com/osfans/trime/ime/keyboard/FloatingKeyboardModeTest.kt |
Tests orientation and preference-based mode selection. |
app/src/test/java/com/osfans/trime/ime/keyboard/FloatingKeyboardGeometryTest.kt |
Tests sizing, positioning, insets, and snapping. |
app/src/main/res/values/strings.xml |
Adds English floating-control labels. |
app/src/main/res/values/input_view_ids.xml |
Adds handle and composer-host IDs. |
app/src/main/res/values-zh-rTW/strings.xml |
Adds Traditional Chinese control labels. |
app/src/main/res/values-zh-rCN/strings.xml |
Adds Simplified Chinese control labels. |
app/src/main/res/drawable/ic_baseline_picture_in_picture_alt_24.xml |
Adds the floating-mode icon. |
app/src/main/res/drawable/ic_baseline_open_in_full_24.xml |
Adds the resize icon. |
app/src/main/res/drawable/ic_baseline_dock_to_bottom_24.xml |
Adds the docking icon. |
app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardWindow.kt |
Passes floating geometry into keyboard construction and adjusts layout selection. |
app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardPrefs.kt |
Uses portrait width for wide-screen detection. |
app/src/main/java/com/osfans/trime/ime/keyboard/Keyboard.kt |
Scales floating key height and disables split layouts. |
app/src/main/java/com/osfans/trime/ime/keyboard/FloatingKeyboardPrefs.kt |
Stores floating mode, scale, position, and collapse state. |
app/src/main/java/com/osfans/trime/ime/keyboard/FloatingKeyboardMode.kt |
Defines orientation-driven floating-mode selection. |
app/src/main/java/com/osfans/trime/ime/keyboard/FloatingKeyboardGeometry.kt |
Provides card sizing and positioning helpers. |
app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt |
Handles mode requests and reports overlay insets. |
app/src/main/java/com/osfans/trime/ime/core/InputView.kt |
Implements floating-card layout, controls, and gestures. |
app/src/main/java/com/osfans/trime/ime/composition/PreeditDelegate.kt |
Repositions the composer’s touch receiver. |
app/src/main/java/com/osfans/trime/ime/bar/ui/AlwaysUi.kt |
Adds and styles the floating/docking toggle. |
app/src/main/java/com/osfans/trime/ime/bar/InputBarDelegate.kt |
Connects the toggle to mode changes. |
app/src/main/java/com/osfans/trime/data/prefs/AppPrefs.kt |
Registers floating preferences and includes them in resets. |
Review effort: Balanced
| if (width != keyboardView.layoutParams.width) { | ||
| keyboardWindow.floatingScalePercent = | ||
| FloatingKeyboardGeometry.percentFor(baseWidth, width) | ||
| keyboardView.updateLayoutParams { this.width = width } |
| floatingToggleButton.apply { | ||
| contentDescription = context.getString(R.string.floating_keyboard_float) | ||
| setOnClickListener { | ||
| service.requestFloatingMode(!service.isFloatingKeyboardActive) |
| } | ||
|
|
||
| MotionEvent.ACTION_MOVE -> { | ||
| keyboardView.translationX = |
| // The layout depends on the floating flag (a card is never split), and | ||
| // the card width differs from the docked width. Rebuild the keyboards | ||
| // after the new size has been laid out instead of using the old width. | ||
| scheduleKeyboardRefresh() |
a0a3f31 to
16e5d70
Compare
补充审查反馈(在 Copilot 的 4 条意见之上)整体实现质量不错: 阻断 1:几何重建会提交正在输入的 composition 并重置 ascii_mode
if (currentMode != targetMode) {
service.postRimeJob {
commitComposition()
setRuntimeOption("ascii_mode", targetMode)
}
}拖动缩放手柄、切换悬浮/停靠、 阻断 2:resize 的每次 ACTION_MOVE 都触发一次完整键盘重建
建议一并处理
小问题
验证建议现有 508 行单测都是纯函数级,建议补:几何重建不触发 Copilot 的 4 条意见我逐条复核过,均成立;阻断 1/2 是对其第 1 条的调用链补充与放大,其余为额外发现。以上供参考,感谢贡献这个功能。 |
|
This is a good feature but also a large amount of changes, I think it may take longer time to get a closer look. |
|
Thanks for the work on this, I review this with my LLM and have some comments. The geometry helpers are clean, well-documented and well-tested, and splitting 1. Extract the floating-keyboard runtime into a
|
0287255 to
92e22ea
Compare
|
@Bambooin One last thing, you can prompt your LLM to "make sure there is no new bug or feature regression introduced, and reduce redundant comments and meaningless unit tests, keep code high quality and efficient". This is a skill that I usually used to avoid AI slops. |
92e22ea to
dcb9038
Compare
WhiredPlanck
left a comment
There was a problem hiding this comment.
Let's merge this and get it further polished in the future.


Pull request
Issue tracker
Fixes will automatically close the related issues
Fix #2094
Feature
Describe features of this pull request
Add floating feature support, this patch is verified with daily usage.
Assisted by LLM.
Code of conduct
Code style
make style-lintBuild pass
make debugManually test
Code Review
Daily build
Login and download artifact at https://github.com/osfans/trime/actions
Additional Info