From 8988b85e693b5cc5a0f3d5bd65d2cc481dc6a19d Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 13 Jan 2023 11:40:55 +0100 Subject: [PATCH 1/4] Make color of the selection check mark part of the theme --- app/ui/legacy/src/main/res/drawable/ic_check_circle_large.xml | 2 +- app/ui/legacy/src/main/res/values/attrs.xml | 1 + app/ui/legacy/src/main/res/values/themes.xml | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/ui/legacy/src/main/res/drawable/ic_check_circle_large.xml b/app/ui/legacy/src/main/res/drawable/ic_check_circle_large.xml index 6483898ca..52c9bcc0d 100644 --- a/app/ui/legacy/src/main/res/drawable/ic_check_circle_large.xml +++ b/app/ui/legacy/src/main/res/drawable/ic_check_circle_large.xml @@ -6,7 +6,7 @@ + diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index 4cc3fd819..eb188d569 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -87,6 +87,7 @@ @drawable/ic_import_status @android:color/primary_text_light @android:color/secondary_text_light + #ff1976d2 #ff99d9ee ?android:attr/windowBackground #ffd8d8d8 @@ -240,6 +241,7 @@ @drawable/ic_import_status @android:color/primary_text_dark @android:color/secondary_text_dark + #ff1976d2 #ff347489 ?android:attr/windowBackground ?attr/messageListRegularItemBackgroundColor From 5db9401f55b56aaebc1d7740b9f2ebe077ec3a27 Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 13 Jan 2023 12:03:48 +0100 Subject: [PATCH 2/4] Make colors of the floating action button part of the theme --- app/ui/legacy/src/main/res/layout/message_list_fragment.xml | 5 ++++- app/ui/legacy/src/main/res/values/attrs.xml | 2 ++ app/ui/legacy/src/main/res/values/themes.xml | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/ui/legacy/src/main/res/layout/message_list_fragment.xml b/app/ui/legacy/src/main/res/layout/message_list_fragment.xml index 6e7996124..975566b9a 100644 --- a/app/ui/legacy/src/main/res/layout/message_list_fragment.xml +++ b/app/ui/legacy/src/main/res/layout/message_list_fragment.xml @@ -33,6 +33,9 @@ android:layout_margin="@dimen/floatingActionButtonMargin" android:contentDescription="@string/compose_action" android:text="@string/compose_action" - app:icon="?attr/iconActionCompose" /> + android:textColor="?attr/floatingActionButtonForegroundColor" + app:backgroundTint="?attr/floatingActionButtonBackgroundColor" + app:icon="?attr/iconActionCompose" + app:iconTint="?attr/floatingActionButtonForegroundColor" /> diff --git a/app/ui/legacy/src/main/res/values/attrs.xml b/app/ui/legacy/src/main/res/values/attrs.xml index 33a6e920a..63f88c638 100644 --- a/app/ui/legacy/src/main/res/values/attrs.xml +++ b/app/ui/legacy/src/main/res/values/attrs.xml @@ -4,6 +4,8 @@ + + diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index eb188d569..a2df7c844 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -22,6 +22,8 @@ @color/material_pink_200 #ffffff @color/material_gray_50 + ?attr/colorSecondary + ?attr/colorOnSecondary @style/Widget.K9.Toolbar @style/PreferenceThemeOverlay @@ -176,6 +178,8 @@ @color/material_pink_300 @color/material_pink_500 @color/material_gray_900 + ?attr/colorSecondary + ?attr/colorOnSecondary @style/Widget.K9.Toolbar @style/PreferenceThemeOverlay From 9bed86a636be62ce4d09522672763e70561701e8 Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 13 Jan 2023 12:22:25 +0100 Subject: [PATCH 3/4] Change themes to use shades of gray as primary color Also use the primary color for the floating action button. --- app/ui/legacy/src/main/res/values/themes.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index a2df7c844..acbd8019a 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -16,14 +16,14 @@ @color/material_gray_100 @color/material_gray_100 - @color/material_blue_600 - @color/material_blue_800 - @color/material_pink_400 - @color/material_pink_200 + @color/material_gray_800 + @color/material_gray_700 + @color/material_pink_500 + @color/material_pink_300 #ffffff @color/material_gray_50 - ?attr/colorSecondary - ?attr/colorOnSecondary + ?attr/colorPrimary + ?attr/colorOnPrimary @style/Widget.K9.Toolbar @style/PreferenceThemeOverlay @@ -173,13 +173,13 @@ @color/material_gray_900 @color/material_gray_900 - @color/material_blue_400 - @color/material_blue_600 + @color/material_gray_100 + @color/material_gray_50 @color/material_pink_300 @color/material_pink_500 @color/material_gray_900 - ?attr/colorSecondary - ?attr/colorOnSecondary + ?attr/colorPrimary + ?attr/colorOnPrimary @style/Widget.K9.Toolbar @style/PreferenceThemeOverlay From 6244ea65735735046c1ea7c756aa232c7e23e397 Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 13 Jan 2023 13:10:26 +0100 Subject: [PATCH 4/4] Change colors for selected/active messages in the message list We can't use semi-transparent colors because the message list item backgrounds are drawn on top of other colors when using swipe actions. Instead, we mix the colors ourselves, e.g. 60% of ?attr/colorSecondaryVariant on ?attr/colorSurface --- .../java/com/fsck/k9/ui/ThemeExtensions.kt | 27 +++++++++++++++++++ .../k9/ui/messagelist/MessageListAdapter.kt | 12 +++++++-- app/ui/legacy/src/main/res/values/attrs.xml | 4 +++ app/ui/legacy/src/main/res/values/themes.xml | 20 +++++++++----- 4 files changed, 55 insertions(+), 8 deletions(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/ThemeExtensions.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/ThemeExtensions.kt index d8aa489e0..51c73e2d0 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/ThemeExtensions.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/ThemeExtensions.kt @@ -1,6 +1,7 @@ package com.fsck.k9.ui import android.content.res.Resources.Theme +import android.graphics.Color import android.graphics.drawable.Drawable import android.util.TypedValue @@ -15,6 +16,32 @@ fun Theme.resolveColorAttribute(attrId: Int): Int { return typedValue.data } +fun Theme.resolveColorAttribute(colorAttrId: Int, alphaFractionAttrId: Int, backgroundColorAttrId: Int): Int { + val typedValue = TypedValue() + + if (!resolveAttribute(colorAttrId, typedValue, true)) { + error("Couldn't resolve attribute ($colorAttrId)") + } + val color = typedValue.data + + if (!resolveAttribute(alphaFractionAttrId, typedValue, true)) { + error("Couldn't resolve attribute ($alphaFractionAttrId)") + } + val colorPercentage = TypedValue.complexToFloat(typedValue.data) + val backgroundPercentage = 1 - colorPercentage + + if (!resolveAttribute(backgroundColorAttrId, typedValue, true)) { + error("Couldn't resolve attribute ($colorAttrId)") + } + val backgroundColor = typedValue.data + + val red = colorPercentage * Color.red(color) + backgroundPercentage * Color.red(backgroundColor) + val green = colorPercentage * Color.green(color) + backgroundPercentage * Color.green(backgroundColor) + val blue = colorPercentage * Color.blue(color) + backgroundPercentage * Color.blue(backgroundColor) + + return Color.rgb(red.toInt(), green.toInt(), blue.toInt()) +} + fun Theme.resolveDrawableAttribute(attrId: Int): Drawable { val typedValue = TypedValue() diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListAdapter.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListAdapter.kt index b58281a03..18c937c28 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListAdapter.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListAdapter.kt @@ -51,8 +51,16 @@ class MessageListAdapter internal constructor( private val answeredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnswered) private val forwardedAnsweredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnsweredForwarded) private val previewTextColor: Int = theme.resolveColorAttribute(R.attr.messageListPreviewTextColor) - private val activeItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListActiveItemBackgroundColor) - private val selectedItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListSelectedBackgroundColor) + private val activeItemBackgroundColor: Int = theme.resolveColorAttribute( + colorAttrId = R.attr.messageListActiveItemBackgroundColor, + alphaFractionAttrId = R.attr.messageListActiveItemBackgroundAlphaFraction, + backgroundColorAttrId = R.attr.messageListActiveItemBackgroundAlphaBackground + ) + private val selectedItemBackgroundColor: Int = theme.resolveColorAttribute( + colorAttrId = R.attr.messageListSelectedBackgroundColor, + alphaFractionAttrId = R.attr.messageListSelectedBackgroundAlphaFraction, + backgroundColorAttrId = R.attr.messageListSelectedBackgroundAlphaBackground + ) private val regularItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListRegularItemBackgroundColor) private val readItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListReadItemBackgroundColor) private val unreadItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListUnreadItemBackgroundColor) diff --git a/app/ui/legacy/src/main/res/values/attrs.xml b/app/ui/legacy/src/main/res/values/attrs.xml index 63f88c638..c17bff604 100644 --- a/app/ui/legacy/src/main/res/values/attrs.xml +++ b/app/ui/legacy/src/main/res/values/attrs.xml @@ -69,12 +69,16 @@ + + + + diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index acbd8019a..55c4b43a1 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -89,14 +89,18 @@ @drawable/ic_import_status @android:color/primary_text_light @android:color/secondary_text_light - #ff1976d2 - #ff99d9ee + ?attr/colorSecondary + ?attr/colorSecondaryVariant + 33% + ?attr/colorSurface ?android:attr/windowBackground #ffd8d8d8 ?attr/messageListRegularItemBackgroundColor ?android:attr/colorBackground @drawable/thread_count_box_light - #ff2ea7d1 + ?attr/colorSecondaryVariant + 60% + ?attr/colorSurface #ff696969 #ffcccccc #bbbbbb @@ -245,14 +249,18 @@ @drawable/ic_import_status @android:color/primary_text_dark @android:color/secondary_text_dark - #ff1976d2 - #ff347489 + ?attr/colorSecondary + ?attr/colorSecondaryVariant + 25% + ?attr/colorSurface ?android:attr/windowBackground ?attr/messageListRegularItemBackgroundColor #ff505050 ?android:attr/colorBackground @drawable/thread_count_box_dark - #ff33b5e5 + ?attr/colorSecondaryVariant + 50% + ?attr/colorSurface #ffa0a0a0 #ff333333 #777777