Skip to content

Commit fda9ecb

Browse files
DEAN-Cherryrocka
andauthored
Add theme properties for candidate label/text/comment color (#647)
bump theme verison to 2.1 Co-authored-by: rocka <i@rocka.me>
1 parent 3dff0a3 commit fda9ecb

File tree

5 files changed

+70
-6
lines changed

5 files changed

+70
-6
lines changed

app/src/main/java/org/fcitx/fcitx5/android/data/theme/CustomThemeSerializer.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ object CustomThemeSerializer : JsonTransformingSerializer<Theme.Custom>(Theme.Cu
5555
private val strategies: List<MigrationStrategy> =
5656
// Add migrations here
5757
listOf(
58+
MigrationStrategy("2.1") {
59+
JsonObject(it.toMutableMap().apply {
60+
put("candidateTextColor", getValue("keyTextColor"))
61+
put("candidateLabelColor", getValue("keyTextColor"))
62+
put("candidateCommentColor", getValue("altKeyTextColor"))
63+
})
64+
},
5865
MigrationStrategy("2.0") {
5966
JsonObject(it.toMutableMap().apply {
6067
if (get("backgroundImage") != null) {
@@ -80,7 +87,7 @@ object CustomThemeSerializer : JsonTransformingSerializer<Theme.Custom>(Theme.Cu
8087

8188
private const val VERSION = "version"
8289

83-
private const val CURRENT_VERSION = "2.0"
90+
private const val CURRENT_VERSION = "2.1"
8491
private const val FALLBACK_VERSION = "1.0"
8592

8693
private val knownVersions = strategies.map { it.version }

app/src/main/java/org/fcitx/fcitx5/android/data/theme/Theme.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ sealed class Theme : Parcelable {
3030
abstract val keyBackgroundColor: Int
3131
abstract val keyTextColor: Int
3232

33+
// Color of candidate text
34+
abstract val candidateTextColor: Int
35+
abstract val candidateLabelColor: Int
36+
abstract val candidateCommentColor: Int
37+
3338
abstract val altKeyBackgroundColor: Int
3439
abstract val altKeyTextColor: Int
3540

@@ -67,6 +72,9 @@ sealed class Theme : Parcelable {
6772
override val keyboardColor: Int,
6873
override val keyBackgroundColor: Int,
6974
override val keyTextColor: Int,
75+
override val candidateTextColor: Int,
76+
override val candidateLabelColor: Int,
77+
override val candidateCommentColor: Int,
7078
override val altKeyBackgroundColor: Int,
7179
override val altKeyTextColor: Int,
7280
override val accentKeyBackgroundColor: Int,
@@ -115,6 +123,9 @@ sealed class Theme : Parcelable {
115123
override val keyboardColor: Int,
116124
override val keyBackgroundColor: Int,
117125
override val keyTextColor: Int,
126+
override val candidateTextColor: Int,
127+
override val candidateLabelColor: Int,
128+
override val candidateCommentColor: Int,
118129
override val altKeyBackgroundColor: Int,
119130
override val altKeyTextColor: Int,
120131
override val accentKeyBackgroundColor: Int,
@@ -140,6 +151,9 @@ sealed class Theme : Parcelable {
140151
keyboardColor: Number,
141152
keyBackgroundColor: Number,
142153
keyTextColor: Number,
154+
candidateTextColor: Number,
155+
candidateLabelColor: Number,
156+
candidateCommentColor: Number,
143157
altKeyBackgroundColor: Number,
144158
altKeyTextColor: Number,
145159
accentKeyBackgroundColor: Number,
@@ -161,6 +175,9 @@ sealed class Theme : Parcelable {
161175
keyboardColor.toInt(),
162176
keyBackgroundColor.toInt(),
163177
keyTextColor.toInt(),
178+
candidateTextColor.toInt(),
179+
candidateLabelColor.toInt(),
180+
candidateCommentColor.toInt(),
164181
altKeyBackgroundColor.toInt(),
165182
altKeyTextColor.toInt(),
166183
accentKeyBackgroundColor.toInt(),
@@ -185,6 +202,9 @@ sealed class Theme : Parcelable {
185202
keyboardColor,
186203
keyBackgroundColor,
187204
keyTextColor,
205+
candidateTextColor,
206+
candidateLabelColor,
207+
candidateCommentColor,
188208
altKeyBackgroundColor,
189209
altKeyTextColor,
190210
accentKeyBackgroundColor,
@@ -222,6 +242,9 @@ sealed class Theme : Parcelable {
222242
keyboardColor,
223243
keyBackgroundColor,
224244
keyTextColor,
245+
candidateTextColor,
246+
candidateLabelColor,
247+
candidateCommentColor,
225248
altKeyBackgroundColor,
226249
altKeyTextColor,
227250
accentKeyBackgroundColor,

app/src/main/java/org/fcitx/fcitx5/android/data/theme/ThemePreset.kt

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ object ThemePreset {
1414
keyboardColor = 0xffeceff1,
1515
keyBackgroundColor = 0xfffbfbfc,
1616
keyTextColor = 0xff37474f,
17+
candidateTextColor = 0xff37474f,
18+
candidateLabelColor = 0xff37474f,
19+
candidateCommentColor = 0xff7a858a,
1720
altKeyBackgroundColor = 0xffdfe2e4,
1821
// Google Pinyin's symbol color on alphabet key: #727d82
1922
altKeyTextColor = 0xff7a858a,
@@ -38,6 +41,9 @@ object ThemePreset {
3841
keyboardColor = 0xff263238,
3942
keyBackgroundColor = 0xff404a50,
4043
keyTextColor = 0xffd9dbdc,
44+
candidateTextColor = 0xffd9dbdc,
45+
candidateLabelColor = 0xffd9dbdc,
46+
candidateCommentColor = 0xffadb1b3,
4147
altKeyBackgroundColor = 0xff313c42,
4248
// Google Pinyin's symbol color on alphabet key: #b3b7b9
4349
altKeyTextColor = 0xffadb1b3,
@@ -62,6 +68,9 @@ object ThemePreset {
6268
keyboardColor = 0xfffafafa,
6369
keyBackgroundColor = 0xffffffff,
6470
keyTextColor = 0xff212121,
71+
candidateTextColor = 0xff212121,
72+
candidateLabelColor = 0xff212121,
73+
candidateCommentColor = 0xff6e6e6e,
6574
altKeyBackgroundColor = 0xffe1e1e1,
6675
// Google Pinyin's symbol color on alphabet key: #4e4e4e
6776
altKeyTextColor = 0xff6e6e6e,
@@ -86,6 +95,9 @@ object ThemePreset {
8695
keyboardColor = 0xff2d2d2d,
8796
keyBackgroundColor = 0xff464646,
8897
keyTextColor = 0xfffafafa,
98+
candidateTextColor = 0xfffafafa,
99+
candidateLabelColor = 0xfffafafa,
100+
candidateCommentColor = 0xffacacac,
89101
altKeyBackgroundColor = 0xff373737,
90102
// Google Pinyin's symbol color on alphabet key: #d6d6d6
91103
altKeyTextColor = 0xffacacac,
@@ -110,6 +122,9 @@ object ThemePreset {
110122
keyboardColor = 0xff1565c0,
111123
keyBackgroundColor = 0xff3f80cb,
112124
keyTextColor = 0xffffffff,
125+
candidateTextColor = 0xffffffff,
126+
candidateLabelColor = 0xffffffff,
127+
candidateCommentColor = 0xffa9c6e7,
113128
altKeyBackgroundColor = 0xff2771c4,
114129
// Google Pinyin's symbol color on alphabet key: #d6d6d6
115130
altKeyTextColor = 0xffa9c6e7,
@@ -134,6 +149,9 @@ object ThemePreset {
134149
keyboardColor = 0xff000000,
135150
keyBackgroundColor = 0xff2e2e2e,
136151
keyTextColor = 0xffffffff,
152+
candidateTextColor = 0xffffffff,
153+
candidateLabelColor = 0xffffffff,
154+
candidateCommentColor = 0xffa1a1a1,
137155
altKeyBackgroundColor = 0xff141414,
138156
// Google Pinyin's symbol color on alphabet key: #d9e6f5
139157
altKeyTextColor = 0xffa1a1a1,
@@ -158,6 +176,9 @@ object ThemePreset {
158176
keyboardColor = 0xffECEFF4,
159177
keyBackgroundColor = 0xffECEFF4,
160178
keyTextColor = 0xff2E3440,
179+
candidateTextColor = 0xff2E3440,
180+
candidateLabelColor = 0xff2E3440,
181+
candidateCommentColor = 0xff4C566A,
161182
altKeyBackgroundColor = 0xffE5E9F0,
162183
altKeyTextColor = 0xff434C5E,
163184
accentKeyBackgroundColor = 0xff5E81AC,
@@ -181,6 +202,9 @@ object ThemePreset {
181202
keyboardColor = 0xff2E3440,
182203
keyBackgroundColor = 0xff4C566A,
183204
keyTextColor = 0xffECEFF4,
205+
candidateTextColor = 0xffECEFF4,
206+
candidateLabelColor = 0xffECEFF4,
207+
candidateCommentColor = 0xffD8DEE9,
184208
altKeyBackgroundColor = 0xff3B4252,
185209
altKeyTextColor = 0xffD8DEE9,
186210
accentKeyBackgroundColor = 0xff88C0D0,
@@ -204,6 +228,9 @@ object ThemePreset {
204228
keyboardColor = 0xff272822,
205229
keyBackgroundColor = 0xff33342c,
206230
keyTextColor = 0xffd6d6d6,
231+
candidateTextColor = 0xffd6d6d6,
232+
candidateLabelColor = 0xffd6d6d6,
233+
candidateCommentColor = 0xff797979,
207234
altKeyBackgroundColor = 0xff2d2e27,
208235
altKeyTextColor = 0xff797979,
209236
accentKeyBackgroundColor = 0xffb05279,
@@ -230,6 +257,9 @@ object ThemePreset {
230257
keyboardColor = 0x00000000,
231258
keyBackgroundColor = 0x4bffffff,
232259
keyTextColor = 0xffffffff,
260+
candidateTextColor = 0xffffffff,
261+
candidateLabelColor = 0xffffffff,
262+
candidateCommentColor = 0xc9ffffff,
233263
altKeyBackgroundColor = 0x0cffffff,
234264
altKeyTextColor = 0xc9ffffff,
235265
accentKeyBackgroundColor = 0xff5e97f6,
@@ -256,6 +286,9 @@ object ThemePreset {
256286
keyboardColor = 0x00000000,
257287
keyBackgroundColor = 0x4bffffff,
258288
keyTextColor = 0xff000000,
289+
candidateTextColor = 0xff000000,
290+
candidateLabelColor = 0xff000000,
291+
candidateCommentColor = 0xb9000000,
259292
altKeyBackgroundColor = 0x0cffffff,
260293
altKeyTextColor = 0xb9000000,
261294
accentKeyBackgroundColor = 0xff5e97f6,
@@ -271,4 +304,4 @@ object ThemePreset {
271304
genericActiveForegroundColor = 0xffffffff
272305
)
273306

274-
}
307+
}

app/src/main/java/org/fcitx/fcitx5/android/input/candidates/CandidateItemUi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CandidateItemUi(override val ctx: Context, theme: Theme) : Ui {
2525
textSize = 20f // sp
2626
isSingleLine = true
2727
gravity = gravityCenter
28-
setTextColor(theme.keyTextColor)
28+
setTextColor(theme.candidateTextColor)
2929
}
3030

3131
override val root = view(::CustomGestureView) {

app/src/main/java/org/fcitx/fcitx5/android/input/candidates/floating/LabeledCandidateItemUi.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ class LabeledCandidateItemUi(
2727
}
2828

2929
fun update(candidate: FcitxEvent.Candidate, active: Boolean) {
30-
val fg = if (active) theme.genericActiveForegroundColor else theme.keyTextColor
31-
val altFg = if (active) theme.genericActiveForegroundColor else theme.altKeyTextColor
30+
val labelFg = if (active) theme.genericActiveForegroundColor else theme.candidateLabelColor
31+
val fg = if (active) theme.genericActiveForegroundColor else theme.candidateTextColor
32+
val altFg = if (active) theme.genericActiveForegroundColor else theme.candidateCommentColor
3233
root.text = buildSpannedString {
33-
color(fg) { append(candidate.label) }
34+
color(labelFg) { append(candidate.label) }
3435
color(fg) { append(candidate.text) }
3536
if (candidate.comment.isNotBlank()) {
3637
append(" ")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy