Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 74094a2d authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #6576 from thundernest/change_theme_colors

Change theme colors
parents b8900fc9 6244ea65
Loading
Loading
Loading
Loading
+27 −0
Original line number Original line Diff line number Diff line
package com.fsck.k9.ui
package com.fsck.k9.ui


import android.content.res.Resources.Theme
import android.content.res.Resources.Theme
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.graphics.drawable.Drawable
import android.util.TypedValue
import android.util.TypedValue


@@ -15,6 +16,32 @@ fun Theme.resolveColorAttribute(attrId: Int): Int {
    return typedValue.data
    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 {
fun Theme.resolveDrawableAttribute(attrId: Int): Drawable {
    val typedValue = TypedValue()
    val typedValue = TypedValue()


+10 −2
Original line number Original line Diff line number Diff line
@@ -51,8 +51,16 @@ class MessageListAdapter internal constructor(
    private val answeredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnswered)
    private val answeredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnswered)
    private val forwardedAnsweredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnsweredForwarded)
    private val forwardedAnsweredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnsweredForwarded)
    private val previewTextColor: Int = theme.resolveColorAttribute(R.attr.messageListPreviewTextColor)
    private val previewTextColor: Int = theme.resolveColorAttribute(R.attr.messageListPreviewTextColor)
    private val activeItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListActiveItemBackgroundColor)
    private val activeItemBackgroundColor: Int = theme.resolveColorAttribute(
    private val selectedItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListSelectedBackgroundColor)
        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 regularItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListRegularItemBackgroundColor)
    private val readItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListReadItemBackgroundColor)
    private val readItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListReadItemBackgroundColor)
    private val unreadItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListUnreadItemBackgroundColor)
    private val unreadItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListUnreadItemBackgroundColor)
+1 −1
Original line number Original line Diff line number Diff line
@@ -6,7 +6,7 @@
  <path
  <path
      android:pathData="M20,20m-20,0a20,20 0,1 1,40 0a20,20 0,1 1,-40 0"
      android:pathData="M20,20m-20,0a20,20 0,1 1,40 0a20,20 0,1 1,-40 0"
      android:strokeWidth="1"
      android:strokeWidth="1"
      android:fillColor="#1976d2"
      android:fillColor="?attr/messageListSelectedCheckMarkColor"
      android:strokeColor="#00000000"/>
      android:strokeColor="#00000000"/>
  <path
  <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"
      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"
+4 −1
Original line number Original line Diff line number Diff line
@@ -33,6 +33,9 @@
        android:layout_margin="@dimen/floatingActionButtonMargin"
        android:layout_margin="@dimen/floatingActionButtonMargin"
        android:contentDescription="@string/compose_action"
        android:contentDescription="@string/compose_action"
        android:text="@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>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
+7 −0
Original line number Original line Diff line number Diff line
@@ -4,6 +4,8 @@
    <declare-styleable name="K9Styles">
    <declare-styleable name="K9Styles">
        <attr name="toolbarColor" format="reference|color" />
        <attr name="toolbarColor" format="reference|color" />
        <attr name="bottomBarBackground" 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="iconUnifiedInbox" format="reference" />
        <attr name="iconFolder" format="reference" />
        <attr name="iconFolder" format="reference" />
        <attr name="iconFolderInbox" format="reference" />
        <attr name="iconFolderInbox" format="reference" />
@@ -65,13 +67,18 @@
        <attr name="textColorPrimaryRecipientDropdown" format="reference" />
        <attr name="textColorPrimaryRecipientDropdown" format="reference" />
        <attr name="textColorSecondaryRecipientDropdown" format="reference" />
        <attr name="textColorSecondaryRecipientDropdown" format="reference" />
        <attr name="backgroundColorChooseAccountHeader" format="color" />
        <attr name="backgroundColorChooseAccountHeader" format="color" />
        <attr name="messageListSelectedCheckMarkColor" format="reference|color"/>
        <attr name="messageListSelectedBackgroundColor" 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="messageListRegularItemBackgroundColor" format="reference|color"/>
        <attr name="messageListReadItemBackgroundColor" format="reference|color"/>
        <attr name="messageListReadItemBackgroundColor" format="reference|color"/>
        <attr name="messageListUnreadItemBackgroundColor" format="reference|color"/>
        <attr name="messageListUnreadItemBackgroundColor" format="reference|color"/>
        <attr name="messageListThreadCountForegroundColor" format="reference|color"/>
        <attr name="messageListThreadCountForegroundColor" format="reference|color"/>
        <attr name="messageListThreadCountBackground" format="reference|color"/>
        <attr name="messageListThreadCountBackground" format="reference|color"/>
        <attr name="messageListActiveItemBackgroundColor" 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="messageListPreviewTextColor" format="reference|color"/>
        <attr name="messageListDividerColor" format="reference|color"/>
        <attr name="messageListDividerColor" format="reference|color"/>
        <attr name="messageListStateIconTint" format="reference|color"/>
        <attr name="messageListStateIconTint" format="reference|color"/>
Loading