Skip to content

Commit 4e7eec0

Browse files
fix: crash when selecting new theme/color
1 parent 8e8f8d3 commit 4e7eec0

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

app/src/main/assets/shared/tongwenfeng.trime.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ fallback_colors:
109109
# hilited_back_color: back_color
110110
# hilited_candidate_text_color: hilited_text_color
111111
# hilited_candidate_back_color: hilited_back_color
112+
# hilited_candidate_button_color: hilited_candidate_back_color # 候选栏工具按钮高亮背景色
112113
# hilited_label_color: hilited_candidate_text_color # 高亮候选序号 颜色
113114
# hilited_comment_text_color: comment_text_color
114115
# hilited_key_back_color: hilited_candidate_back_color

app/src/main/java/com/osfans/trime/data/theme/ColorManager.kt

+5-9
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ object ColorManager {
6565
"hilited_back_color" to "back_color",
6666
"hilited_candidate_text_color" to "hilited_text_color",
6767
"hilited_candidate_back_color" to "hilited_back_color",
68+
"hilited_candidate_button_color" to "hilited_candidate_back_color",
6869
"hilited_label_color" to "hilited_candidate_text_color",
6970
"hilited_comment_text_color" to "comment_text_color",
7071
"hilited_key_back_color" to "hilited_candidate_back_color",
@@ -131,15 +132,10 @@ object ColorManager {
131132
}
132133

133134
private fun evaluateActiveColorScheme(): ColorScheme =
134-
if (followSystemDayNight) {
135-
if (isNightMode) {
136-
darkModeColorScheme
137-
} else {
138-
lightModeColorScheme
139-
} ?: colorScheme(normalModeColor)!!
140-
} else {
141-
colorScheme(normalModeColor)!!
142-
}
135+
when {
136+
followSystemDayNight -> if (isNightMode) darkModeColorScheme else lightModeColorScheme
137+
else -> null
138+
} ?: colorScheme(normalModeColor) ?: colorScheme("default")!!
143139

144140
/** 每次切换主题后,都要调用此函数,初始化配色 */
145141
fun switchTheme(theme: Theme) {

app/src/main/java/com/osfans/trime/ime/bar/ui/ToolButton.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ToolButton(
3838
) : this(context) {
3939
image.imageTintList = ColorStateList.valueOf(ColorManager.getColor("comment_text_color"))
4040
setIcon(icon)
41-
setPressHighlightColor(ColorManager.getColor("hilited_on_key_back_color"))
41+
setPressHighlightColor(ColorManager.getColor("hilited_candidate_button_color"))
4242
add(image, lParams(wrapContent, wrapContent, gravityCenter))
4343
}
4444

0 commit comments

Comments
 (0)