Skip to content

Add theme properties for candidate label/text/comment color #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 29, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ object CustomThemeSerializer : JsonTransformingSerializer<Theme.Custom>(Theme.Cu
private val strategies: List<MigrationStrategy> =
// Add migrations here
listOf(
MigrationStrategy("2.1") {
JsonObject(it.toMutableMap().apply {
put("candidateTextColor", getValue("keyTextColor"))
put("candidateLabelColor", getValue("keyTextColor"))
put("candidateCommentColor", getValue("altKeyTextColor"))
})
},
MigrationStrategy("2.0") {
JsonObject(it.toMutableMap().apply {
if (get("backgroundImage") != null) {
Expand All @@ -80,7 +87,7 @@ object CustomThemeSerializer : JsonTransformingSerializer<Theme.Custom>(Theme.Cu

private const val VERSION = "version"

private const val CURRENT_VERSION = "2.0"
private const val CURRENT_VERSION = "2.1"
private const val FALLBACK_VERSION = "1.0"

private val knownVersions = strategies.map { it.version }
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/org/fcitx/fcitx5/android/data/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ sealed class Theme : Parcelable {
abstract val keyBackgroundColor: Int
abstract val keyTextColor: Int

// Color of candidate text
abstract val candidateTextColor: Int
abstract val candidateLabelColor: Int
abstract val candidateCommentColor: Int

abstract val altKeyBackgroundColor: Int
abstract val altKeyTextColor: Int

Expand Down Expand Up @@ -67,6 +72,9 @@ sealed class Theme : Parcelable {
override val keyboardColor: Int,
override val keyBackgroundColor: Int,
override val keyTextColor: Int,
override val candidateTextColor: Int,
override val candidateLabelColor: Int,
override val candidateCommentColor: Int,
override val altKeyBackgroundColor: Int,
override val altKeyTextColor: Int,
override val accentKeyBackgroundColor: Int,
Expand Down Expand Up @@ -115,6 +123,9 @@ sealed class Theme : Parcelable {
override val keyboardColor: Int,
override val keyBackgroundColor: Int,
override val keyTextColor: Int,
override val candidateTextColor: Int,
override val candidateLabelColor: Int,
override val candidateCommentColor: Int,
override val altKeyBackgroundColor: Int,
override val altKeyTextColor: Int,
override val accentKeyBackgroundColor: Int,
Expand All @@ -140,6 +151,9 @@ sealed class Theme : Parcelable {
keyboardColor: Number,
keyBackgroundColor: Number,
keyTextColor: Number,
candidateTextColor: Number,
candidateLabelColor: Number,
candidateCommentColor: Number,
altKeyBackgroundColor: Number,
altKeyTextColor: Number,
accentKeyBackgroundColor: Number,
Expand All @@ -161,6 +175,9 @@ sealed class Theme : Parcelable {
keyboardColor.toInt(),
keyBackgroundColor.toInt(),
keyTextColor.toInt(),
candidateTextColor.toInt(),
candidateLabelColor.toInt(),
candidateCommentColor.toInt(),
altKeyBackgroundColor.toInt(),
altKeyTextColor.toInt(),
accentKeyBackgroundColor.toInt(),
Expand All @@ -185,6 +202,9 @@ sealed class Theme : Parcelable {
keyboardColor,
keyBackgroundColor,
keyTextColor,
candidateTextColor,
candidateLabelColor,
candidateCommentColor,
altKeyBackgroundColor,
altKeyTextColor,
accentKeyBackgroundColor,
Expand Down Expand Up @@ -222,6 +242,9 @@ sealed class Theme : Parcelable {
keyboardColor,
keyBackgroundColor,
keyTextColor,
candidateTextColor,
candidateLabelColor,
candidateCommentColor,
altKeyBackgroundColor,
altKeyTextColor,
accentKeyBackgroundColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ object ThemePreset {
keyboardColor = 0xffeceff1,
keyBackgroundColor = 0xfffbfbfc,
keyTextColor = 0xff37474f,
candidateTextColor = 0xff37474f,
candidateLabelColor = 0xff37474f,
candidateCommentColor = 0xff7a858a,
altKeyBackgroundColor = 0xffdfe2e4,
// Google Pinyin's symbol color on alphabet key: #727d82
altKeyTextColor = 0xff7a858a,
Expand All @@ -38,6 +41,9 @@ object ThemePreset {
keyboardColor = 0xff263238,
keyBackgroundColor = 0xff404a50,
keyTextColor = 0xffd9dbdc,
candidateTextColor = 0xffd9dbdc,
candidateLabelColor = 0xffd9dbdc,
candidateCommentColor = 0xffadb1b3,
altKeyBackgroundColor = 0xff313c42,
// Google Pinyin's symbol color on alphabet key: #b3b7b9
altKeyTextColor = 0xffadb1b3,
Expand All @@ -62,6 +68,9 @@ object ThemePreset {
keyboardColor = 0xfffafafa,
keyBackgroundColor = 0xffffffff,
keyTextColor = 0xff212121,
candidateTextColor = 0xff212121,
candidateLabelColor = 0xff212121,
candidateCommentColor = 0xff6e6e6e,
altKeyBackgroundColor = 0xffe1e1e1,
// Google Pinyin's symbol color on alphabet key: #4e4e4e
altKeyTextColor = 0xff6e6e6e,
Expand All @@ -86,6 +95,9 @@ object ThemePreset {
keyboardColor = 0xff2d2d2d,
keyBackgroundColor = 0xff464646,
keyTextColor = 0xfffafafa,
candidateTextColor = 0xfffafafa,
candidateLabelColor = 0xfffafafa,
candidateCommentColor = 0xffacacac,
altKeyBackgroundColor = 0xff373737,
// Google Pinyin's symbol color on alphabet key: #d6d6d6
altKeyTextColor = 0xffacacac,
Expand All @@ -110,6 +122,9 @@ object ThemePreset {
keyboardColor = 0xff1565c0,
keyBackgroundColor = 0xff3f80cb,
keyTextColor = 0xffffffff,
candidateTextColor = 0xffffffff,
candidateLabelColor = 0xffffffff,
candidateCommentColor = 0xffa9c6e7,
altKeyBackgroundColor = 0xff2771c4,
// Google Pinyin's symbol color on alphabet key: #d6d6d6
altKeyTextColor = 0xffa9c6e7,
Expand All @@ -134,6 +149,9 @@ object ThemePreset {
keyboardColor = 0xff000000,
keyBackgroundColor = 0xff2e2e2e,
keyTextColor = 0xffffffff,
candidateTextColor = 0xffffffff,
candidateLabelColor = 0xffffffff,
candidateCommentColor = 0xffa1a1a1,
altKeyBackgroundColor = 0xff141414,
// Google Pinyin's symbol color on alphabet key: #d9e6f5
altKeyTextColor = 0xffa1a1a1,
Expand All @@ -158,6 +176,9 @@ object ThemePreset {
keyboardColor = 0xffECEFF4,
keyBackgroundColor = 0xffECEFF4,
keyTextColor = 0xff2E3440,
candidateTextColor = 0xff2E3440,
candidateLabelColor = 0xff2E3440,
candidateCommentColor = 0xff4C566A,
altKeyBackgroundColor = 0xffE5E9F0,
altKeyTextColor = 0xff434C5E,
accentKeyBackgroundColor = 0xff5E81AC,
Expand All @@ -181,6 +202,9 @@ object ThemePreset {
keyboardColor = 0xff2E3440,
keyBackgroundColor = 0xff4C566A,
keyTextColor = 0xffECEFF4,
candidateTextColor = 0xffECEFF4,
candidateLabelColor = 0xffECEFF4,
candidateCommentColor = 0xffD8DEE9,
altKeyBackgroundColor = 0xff3B4252,
altKeyTextColor = 0xffD8DEE9,
accentKeyBackgroundColor = 0xff88C0D0,
Expand All @@ -204,6 +228,9 @@ object ThemePreset {
keyboardColor = 0xff272822,
keyBackgroundColor = 0xff33342c,
keyTextColor = 0xffd6d6d6,
candidateTextColor = 0xffd6d6d6,
candidateLabelColor = 0xffd6d6d6,
candidateCommentColor = 0xff797979,
altKeyBackgroundColor = 0xff2d2e27,
altKeyTextColor = 0xff797979,
accentKeyBackgroundColor = 0xffb05279,
Expand All @@ -230,6 +257,9 @@ object ThemePreset {
keyboardColor = 0x00000000,
keyBackgroundColor = 0x4bffffff,
keyTextColor = 0xffffffff,
candidateTextColor = 0xffffffff,
candidateLabelColor = 0xffffffff,
candidateCommentColor = 0xc9ffffff,
altKeyBackgroundColor = 0x0cffffff,
altKeyTextColor = 0xc9ffffff,
accentKeyBackgroundColor = 0xff5e97f6,
Expand All @@ -256,6 +286,9 @@ object ThemePreset {
keyboardColor = 0x00000000,
keyBackgroundColor = 0x4bffffff,
keyTextColor = 0xff000000,
candidateTextColor = 0xff000000,
candidateLabelColor = 0xff000000,
candidateCommentColor = 0xb9000000,
altKeyBackgroundColor = 0x0cffffff,
altKeyTextColor = 0xb9000000,
accentKeyBackgroundColor = 0xff5e97f6,
Expand All @@ -271,4 +304,4 @@ object ThemePreset {
genericActiveForegroundColor = 0xffffffff
)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CandidateItemUi(override val ctx: Context, theme: Theme) : Ui {
textSize = 20f // sp
isSingleLine = true
gravity = gravityCenter
setTextColor(theme.keyTextColor)
setTextColor(theme.candidateTextColor)
}

override val root = view(::CustomGestureView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class LabeledCandidateItemUi(
}

fun update(candidate: FcitxEvent.Candidate, active: Boolean) {
val fg = if (active) theme.genericActiveForegroundColor else theme.keyTextColor
val altFg = if (active) theme.genericActiveForegroundColor else theme.altKeyTextColor
val labelFg = if (active) theme.genericActiveForegroundColor else theme.candidateLabelColor
val fg = if (active) theme.genericActiveForegroundColor else theme.candidateTextColor
val altFg = if (active) theme.genericActiveForegroundColor else theme.candidateCommentColor
root.text = buildSpannedString {
color(fg) { append(candidate.label) }
color(labelFg) { append(candidate.label) }
color(fg) { append(candidate.text) }
if (candidate.comment.isNotBlank()) {
append(" ")
Expand Down
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