@@ -57,7 +57,7 @@ object TabManager {
57
57
addTabHasKeys(name, type, keys)
58
58
}
59
59
tabSwitchData.addAll(
60
- tabTags.filter { SymbolKeyboardType .hasKeys (it.type) }
60
+ tabTags.filter { SymbolKeyboardType .hasKey (it.type) }
61
61
.map { SimpleKeyBean (it.text) },
62
62
)
63
63
}
@@ -78,6 +78,7 @@ object TabManager {
78
78
val index = tabTags.indexOfFirst { it.text == name }
79
79
if (index >= 0 ) {
80
80
keyboards[index] = keyBeans
81
+ return
81
82
}
82
83
}
83
84
tabTags.add(TabTag (name, type))
@@ -89,11 +90,13 @@ object TabManager {
89
90
type : SymbolKeyboardType ,
90
91
keys : ConfigItem ? ,
91
92
) {
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() ? : " "
95
96
when (type) {
97
+ // 处理 SINGLE 类型:把字符串切分为多个按键
96
98
SymbolKeyboardType .SINGLE -> addListTab(name, type, SimpleKeyDao .singleData(key))
99
+ // 处理 NO_KEY 类型:把字符串转换为命令
97
100
SymbolKeyboardType .NO_KEY -> {
98
101
val commandType = KeyCommandType .fromString(key)
99
102
tabTags.add(TabTag (name, type, commandType))
@@ -104,7 +107,7 @@ object TabManager {
104
107
}
105
108
106
109
if (keys !is ConfigList ) return
107
- val keysList: MutableList <SimpleKeyBean > = ArrayList ()
110
+ val keysList = mutableListOf <SimpleKeyBean >()
108
111
for (k in keys) {
109
112
if (k is ConfigValue ) {
110
113
keysList.add(SimpleKeyBean (k.getString()))
@@ -152,17 +155,11 @@ object TabManager {
152
155
153
156
val tabCandidates: ArrayList <TabTag >
154
157
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)
160
162
}
161
163
}
162
- if (addExit) {
163
- tabTags.add(tagExit)
164
- keyboards.add(notKeyboard)
165
- }
166
- return tabTags
167
164
}
168
165
}
0 commit comments