Skip to content

Commit 3dd930c

Browse files
committed
fix: back button in LiquidKeyboard didn't work well with some themes
1 parent 73bfd86 commit 3dd930c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

app/src/main/java/com/osfans/trime/ime/symbol/LiquidKeyboard.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class LiquidKeyboard(
128128
}
129129

130130
override fun onCreateView(): View =
131-
LiquidLayout(context, theme).apply {
131+
LiquidLayout(context, service, theme).apply {
132132
liquidLayout = this
133133
tabsUi.apply {
134134
setTabs(TabManager.tabTags)

app/src/main/java/com/osfans/trime/ime/symbol/LiquidLayout.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.osfans.trime.data.theme.ColorManager
88
import com.osfans.trime.data.theme.EventManager
99
import com.osfans.trime.data.theme.FontManager
1010
import com.osfans.trime.data.theme.Theme
11-
import com.osfans.trime.ime.text.TextInputManager
11+
import com.osfans.trime.ime.core.TrimeInputMethodService
1212
import splitties.dimensions.dp
1313
import splitties.views.backgroundColor
1414
import splitties.views.dsl.constraintlayout.above
@@ -34,7 +34,7 @@ import splitties.views.gravityCenter
3434
import splitties.views.padding
3535

3636
@SuppressLint("ViewConstructor")
37-
class LiquidLayout(context: Context, theme: Theme) : ConstraintLayout(context) {
37+
class LiquidLayout(context: Context, service: TrimeInputMethodService, theme: Theme) : ConstraintLayout(context) {
3838
// TODO: 继承一个键盘视图嵌入到这里,而不是自定义一个视图
3939
val operations =
4040
constraintLayout {
@@ -59,10 +59,15 @@ class LiquidLayout(context: Context, theme: Theme) : ConstraintLayout(context) {
5959
)
6060
ColorManager.getColor("key_back_color")?.let { bg -> backgroundColor = bg }
6161
setOnClickListener {
62-
val event = EventManager.getEvent(operation.first)
63-
TextInputManager.getInstance().run {
64-
onPress(event.code)
65-
onEvent(event)
62+
// TODO: 这个方式不太优雅,还需打磨
63+
if (operation.first == "liquid_keyboard_exit") {
64+
service.selectLiquidKeyboard(-1)
65+
} else {
66+
val event = EventManager.getEvent(operation.first)
67+
service.textInputManager?.run {
68+
onPress(event.code)
69+
onEvent(event)
70+
}
6671
}
6772
}
6873
}

0 commit comments

Comments
 (0)