Skip to content

Commit 69e8b3a

Browse files
committed
fix: disappear clipboard, collection and draft in LiquidKeyboard
1 parent 7202f5b commit 69e8b3a

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object TabManager {
5757
addTabHasKeys(name, type, keys)
5858
}
5959
tabSwitchData.addAll(
60-
tabTags.filter { SymbolKeyboardType.hasKeys(it.type) }
60+
tabTags.filter { SymbolKeyboardType.hasKey(it.type) }
6161
.map { SimpleKeyBean(it.text) },
6262
)
6363
}
@@ -78,6 +78,7 @@ object TabManager {
7878
val index = tabTags.indexOfFirst { it.text == name }
7979
if (index >= 0) {
8080
keyboards[index] = keyBeans
81+
return
8182
}
8283
}
8384
tabTags.add(TabTag(name, type))
@@ -89,11 +90,13 @@ object TabManager {
8990
type: SymbolKeyboardType,
9091
keys: ConfigItem?,
9192
) {
92-
// 处理single类型和no_key类型。前者把字符串切分为多个按键,后者把字符串转换为命令
93-
if (keys is ConfigValue) {
94-
val key = keys.getString()
93+
if (keys is ConfigValue?) {
94+
// 对于没有按键的类型,也要返回一个空的 key 值,否则无法显示在标签栏内
95+
val key = keys?.configValue?.getString() ?: ""
9596
when (type) {
97+
// 处理 SINGLE 类型:把字符串切分为多个按键
9698
SymbolKeyboardType.SINGLE -> addListTab(name, type, SimpleKeyDao.singleData(key))
99+
// 处理 NO_KEY 类型:把字符串转换为命令
97100
SymbolKeyboardType.NO_KEY -> {
98101
val commandType = KeyCommandType.fromString(key)
99102
tabTags.add(TabTag(name, type, commandType))
@@ -104,7 +107,7 @@ object TabManager {
104107
}
105108

106109
if (keys !is ConfigList) return
107-
val keysList: MutableList<SimpleKeyBean> = ArrayList()
110+
val keysList = mutableListOf<SimpleKeyBean>()
108111
for (k in keys) {
109112
if (k is ConfigValue) {
110113
keysList.add(SimpleKeyBean(k.getString()))
@@ -152,17 +155,11 @@ object TabManager {
152155

153156
val tabCandidates: ArrayList<TabTag>
154157
get() {
155-
var addExit = true
156-
for (tag in tabTags) {
157-
if (tag.command == KeyCommandType.EXIT) {
158-
addExit = false
159-
break
158+
return tabTags.apply {
159+
if (none { it.command == KeyCommandType.EXIT }) {
160+
add(tagExit)
161+
keyboards.add(notKeyboard)
160162
}
161163
}
162-
if (addExit) {
163-
tabTags.add(tagExit)
164-
keyboards.add(notKeyboard)
165-
}
166-
return tabTags
167164
}
168165
}

0 commit comments

Comments
 (0)