mirror of
https://github.com/fcitx5-android/fcitx5-android.git
synced 2026-08-02 20:16:06 +08:00
Add theme properties for candidate label/text/comment color (#647)
bump theme verison to 2.1 Co-authored-by: rocka <i@rocka.me>
This commit is contained in:
parent
3dff0a3a94
commit
fda9ecbc2a
@ -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) {
|
||||
@ -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 }
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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(),
|
||||
@ -185,6 +202,9 @@ sealed class Theme : Parcelable {
|
||||
keyboardColor,
|
||||
keyBackgroundColor,
|
||||
keyTextColor,
|
||||
candidateTextColor,
|
||||
candidateLabelColor,
|
||||
candidateCommentColor,
|
||||
altKeyBackgroundColor,
|
||||
altKeyTextColor,
|
||||
accentKeyBackgroundColor,
|
||||
@ -222,6 +242,9 @@ sealed class Theme : Parcelable {
|
||||
keyboardColor,
|
||||
keyBackgroundColor,
|
||||
keyTextColor,
|
||||
candidateTextColor,
|
||||
candidateLabelColor,
|
||||
candidateCommentColor,
|
||||
altKeyBackgroundColor,
|
||||
altKeyTextColor,
|
||||
accentKeyBackgroundColor,
|
||||
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -158,6 +176,9 @@ object ThemePreset {
|
||||
keyboardColor = 0xffECEFF4,
|
||||
keyBackgroundColor = 0xffECEFF4,
|
||||
keyTextColor = 0xff2E3440,
|
||||
candidateTextColor = 0xff2E3440,
|
||||
candidateLabelColor = 0xff2E3440,
|
||||
candidateCommentColor = 0xff4C566A,
|
||||
altKeyBackgroundColor = 0xffE5E9F0,
|
||||
altKeyTextColor = 0xff434C5E,
|
||||
accentKeyBackgroundColor = 0xff5E81AC,
|
||||
@ -181,6 +202,9 @@ object ThemePreset {
|
||||
keyboardColor = 0xff2E3440,
|
||||
keyBackgroundColor = 0xff4C566A,
|
||||
keyTextColor = 0xffECEFF4,
|
||||
candidateTextColor = 0xffECEFF4,
|
||||
candidateLabelColor = 0xffECEFF4,
|
||||
candidateCommentColor = 0xffD8DEE9,
|
||||
altKeyBackgroundColor = 0xff3B4252,
|
||||
altKeyTextColor = 0xffD8DEE9,
|
||||
accentKeyBackgroundColor = 0xff88C0D0,
|
||||
@ -204,6 +228,9 @@ object ThemePreset {
|
||||
keyboardColor = 0xff272822,
|
||||
keyBackgroundColor = 0xff33342c,
|
||||
keyTextColor = 0xffd6d6d6,
|
||||
candidateTextColor = 0xffd6d6d6,
|
||||
candidateLabelColor = 0xffd6d6d6,
|
||||
candidateCommentColor = 0xff797979,
|
||||
altKeyBackgroundColor = 0xff2d2e27,
|
||||
altKeyTextColor = 0xff797979,
|
||||
accentKeyBackgroundColor = 0xffb05279,
|
||||
@ -230,6 +257,9 @@ object ThemePreset {
|
||||
keyboardColor = 0x00000000,
|
||||
keyBackgroundColor = 0x4bffffff,
|
||||
keyTextColor = 0xffffffff,
|
||||
candidateTextColor = 0xffffffff,
|
||||
candidateLabelColor = 0xffffffff,
|
||||
candidateCommentColor = 0xc9ffffff,
|
||||
altKeyBackgroundColor = 0x0cffffff,
|
||||
altKeyTextColor = 0xc9ffffff,
|
||||
accentKeyBackgroundColor = 0xff5e97f6,
|
||||
@ -256,6 +286,9 @@ object ThemePreset {
|
||||
keyboardColor = 0x00000000,
|
||||
keyBackgroundColor = 0x4bffffff,
|
||||
keyTextColor = 0xff000000,
|
||||
candidateTextColor = 0xff000000,
|
||||
candidateLabelColor = 0xff000000,
|
||||
candidateCommentColor = 0xb9000000,
|
||||
altKeyBackgroundColor = 0x0cffffff,
|
||||
altKeyTextColor = 0xb9000000,
|
||||
accentKeyBackgroundColor = 0xff5e97f6,
|
||||
@ -271,4 +304,4 @@ object ThemePreset {
|
||||
genericActiveForegroundColor = 0xffffffff
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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(" ")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user