Merge pull request #6576 from thundernest/change_theme_colors

Change theme colors
This commit is contained in:
cketti 2023-01-17 14:39:32 +01:00 committed by GitHub
commit 74094a2d66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 14 deletions

View file

@ -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()

View file

@ -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)

View file

@ -6,7 +6,7 @@
<path
android:pathData="M20,20m-20,0a20,20 0,1 1,40 0a20,20 0,1 1,-40 0"
android:strokeWidth="1"
android:fillColor="#1976d2"
android:fillColor="?attr/messageListSelectedCheckMarkColor"
android:strokeColor="#00000000"/>
<path
android:pathData="m16.795,23.875 l-4.17,-4.17 -1.42,1.41 5.59,5.59 12,-12 -1.41,-1.41z"

View file

@ -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" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -4,6 +4,8 @@
<declare-styleable name="K9Styles">
<attr name="toolbarColor" format="reference|color" />
<attr name="bottomBarBackground" format="reference|color" />
<attr name="floatingActionButtonBackgroundColor" format="reference|color" />
<attr name="floatingActionButtonForegroundColor" format="reference|color" />
<attr name="iconUnifiedInbox" format="reference" />
<attr name="iconFolder" format="reference" />
<attr name="iconFolderInbox" format="reference" />
@ -65,13 +67,18 @@
<attr name="textColorPrimaryRecipientDropdown" format="reference" />
<attr name="textColorSecondaryRecipientDropdown" format="reference" />
<attr name="backgroundColorChooseAccountHeader" format="color" />
<attr name="messageListSelectedCheckMarkColor" format="reference|color"/>
<attr name="messageListSelectedBackgroundColor" format="reference|color"/>
<attr name="messageListSelectedBackgroundAlphaFraction" format="fraction"/>
<attr name="messageListSelectedBackgroundAlphaBackground" format="reference|color"/>
<attr name="messageListRegularItemBackgroundColor" format="reference|color"/>
<attr name="messageListReadItemBackgroundColor" format="reference|color"/>
<attr name="messageListUnreadItemBackgroundColor" format="reference|color"/>
<attr name="messageListThreadCountForegroundColor" format="reference|color"/>
<attr name="messageListThreadCountBackground" format="reference|color"/>
<attr name="messageListActiveItemBackgroundColor" format="reference|color"/>
<attr name="messageListActiveItemBackgroundAlphaFraction" format="fraction"/>
<attr name="messageListActiveItemBackgroundAlphaBackground" format="reference|color"/>
<attr name="messageListPreviewTextColor" format="reference|color"/>
<attr name="messageListDividerColor" format="reference|color"/>
<attr name="messageListStateIconTint" format="reference|color"/>

View file

@ -16,12 +16,14 @@
<item name="android:statusBarColor">@color/material_gray_100</item>
<item name="toolbarColor">@color/material_gray_100</item>
<item name="colorPrimary">@color/material_blue_600</item>
<item name="colorPrimaryVariant">@color/material_blue_800</item>
<item name="colorSecondary">@color/material_pink_400</item>
<item name="colorSecondaryVariant">@color/material_pink_200</item>
<item name="colorPrimary">@color/material_gray_800</item>
<item name="colorPrimaryVariant">@color/material_gray_700</item>
<item name="colorSecondary">@color/material_pink_500</item>
<item name="colorSecondaryVariant">@color/material_pink_300</item>
<item name="colorOnSecondary">#ffffff</item>
<item name="bottomBarBackground">@color/material_gray_50</item>
<item name="floatingActionButtonBackgroundColor">?attr/colorPrimary</item>
<item name="floatingActionButtonForegroundColor">?attr/colorOnPrimary</item>
<item name="toolbarStyle">@style/Widget.K9.Toolbar</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
@ -87,13 +89,18 @@
<item name="iconSettingsImportStatus">@drawable/ic_import_status</item>
<item name="textColorPrimaryRecipientDropdown">@android:color/primary_text_light</item>
<item name="textColorSecondaryRecipientDropdown">@android:color/secondary_text_light</item>
<item name="messageListSelectedBackgroundColor">#ff99d9ee</item>
<item name="messageListSelectedCheckMarkColor">?attr/colorSecondary</item>
<item name="messageListSelectedBackgroundColor">?attr/colorSecondaryVariant</item>
<item name="messageListSelectedBackgroundAlphaFraction">33%</item>
<item name="messageListSelectedBackgroundAlphaBackground">?attr/colorSurface</item>
<item name="messageListRegularItemBackgroundColor">?android:attr/windowBackground</item>
<item name="messageListReadItemBackgroundColor">#ffd8d8d8</item>
<item name="messageListUnreadItemBackgroundColor">?attr/messageListRegularItemBackgroundColor</item>
<item name="messageListThreadCountForegroundColor">?android:attr/colorBackground</item>
<item name="messageListThreadCountBackground">@drawable/thread_count_box_light</item>
<item name="messageListActiveItemBackgroundColor">#ff2ea7d1</item>
<item name="messageListActiveItemBackgroundColor">?attr/colorSecondaryVariant</item>
<item name="messageListActiveItemBackgroundAlphaFraction">60%</item>
<item name="messageListActiveItemBackgroundAlphaBackground">?attr/colorSurface</item>
<item name="messageListPreviewTextColor">#ff696969</item>
<item name="messageListDividerColor">#ffcccccc</item>
<item name="messageListStateIconTint">#bbbbbb</item>
@ -170,11 +177,13 @@
<item name="android:statusBarColor">@color/material_gray_900</item>
<item name="toolbarColor">@color/material_gray_900</item>
<item name="colorPrimary">@color/material_blue_400</item>
<item name="colorPrimaryVariant">@color/material_blue_600</item>
<item name="colorPrimary">@color/material_gray_100</item>
<item name="colorPrimaryVariant">@color/material_gray_50</item>
<item name="colorSecondary">@color/material_pink_300</item>
<item name="colorSecondaryVariant">@color/material_pink_500</item>
<item name="bottomBarBackground">@color/material_gray_900</item>
<item name="floatingActionButtonBackgroundColor">?attr/colorPrimary</item>
<item name="floatingActionButtonForegroundColor">?attr/colorOnPrimary</item>
<item name="toolbarStyle">@style/Widget.K9.Toolbar</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
@ -240,13 +249,18 @@
<item name="iconSettingsImportStatus">@drawable/ic_import_status</item>
<item name="textColorPrimaryRecipientDropdown">@android:color/primary_text_dark</item>
<item name="textColorSecondaryRecipientDropdown">@android:color/secondary_text_dark</item>
<item name="messageListSelectedBackgroundColor">#ff347489</item>
<item name="messageListSelectedCheckMarkColor">?attr/colorSecondary</item>
<item name="messageListSelectedBackgroundColor">?attr/colorSecondaryVariant</item>
<item name="messageListSelectedBackgroundAlphaFraction">25%</item>
<item name="messageListSelectedBackgroundAlphaBackground">?attr/colorSurface</item>
<item name="messageListRegularItemBackgroundColor">?android:attr/windowBackground</item>
<item name="messageListReadItemBackgroundColor">?attr/messageListRegularItemBackgroundColor</item>
<item name="messageListUnreadItemBackgroundColor">#ff505050</item>
<item name="messageListThreadCountForegroundColor">?android:attr/colorBackground</item>
<item name="messageListThreadCountBackground">@drawable/thread_count_box_dark</item>
<item name="messageListActiveItemBackgroundColor">#ff33b5e5</item>
<item name="messageListActiveItemBackgroundColor">?attr/colorSecondaryVariant</item>
<item name="messageListActiveItemBackgroundAlphaFraction">50%</item>
<item name="messageListActiveItemBackgroundAlphaBackground">?attr/colorSurface</item>
<item name="messageListPreviewTextColor">#ffa0a0a0</item>
<item name="messageListDividerColor">#ff333333</item>
<item name="messageListStateIconTint">#777777</item>