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 51c73e2d0..70819969e 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 @@ -2,7 +2,6 @@ package com.fsck.k9.ui import android.content.res.Resources.Theme import android.graphics.Color -import android.graphics.drawable.Drawable import android.util.TypedValue fun Theme.resolveColorAttribute(attrId: Int): Int { @@ -42,17 +41,6 @@ fun Theme.resolveColorAttribute(colorAttrId: Int, alphaFractionAttrId: Int, back return Color.rgb(red.toInt(), green.toInt(), blue.toInt()) } -fun Theme.resolveDrawableAttribute(attrId: Int): Drawable { - val typedValue = TypedValue() - - val found = resolveAttribute(attrId, typedValue, true) - if (!found) { - throw IllegalStateException("Couldn't resolve attribute ($attrId)") - } - - return getDrawable(typedValue.resourceId) -} - fun Theme.getIntArray(attrId: Int): IntArray { 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 17263d9d0..8ae2d0b53 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 @@ -33,7 +33,6 @@ import com.fsck.k9.mail.Address import com.fsck.k9.ui.R import com.fsck.k9.ui.helper.RelativeDateTimeFormatter import com.fsck.k9.ui.resolveColorAttribute -import com.fsck.k9.ui.resolveDrawableAttribute import kotlin.math.max private const val FOOTER_ID = 1L @@ -51,9 +50,10 @@ class MessageListAdapter internal constructor( private val relativeDateTimeFormatter: RelativeDateTimeFormatter, ) : RecyclerView.Adapter() { - private val forwardedIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListForwarded) - private val answeredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnswered) - private val forwardedAnsweredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnsweredForwarded) + private val forwardedIcon: Drawable = ResourcesCompat.getDrawable(res, R.drawable.ic_messagelist_forwarded, theme)!! + private val answeredIcon: Drawable = ResourcesCompat.getDrawable(res, R.drawable.ic_messagelist_answered, theme)!! + private val forwardedAnsweredIcon: Drawable = ResourcesCompat + .getDrawable(res, R.drawable.ic_messagelist_answered_forwarded, theme)!! private val unreadTextColor: Int = theme.resolveColorAttribute(R.attr.messageListUnreadTextColor) private val readTextColor: Int = theme.resolveColorAttribute(R.attr.messageListReadTextColor) private val previewTextColor: Int = theme.resolveColorAttribute(R.attr.messageListPreviewTextColor) @@ -317,11 +317,13 @@ class MessageListAdapter internal constructor( textViewMarginTop = compactTextViewMarginTop lineSpacingMultiplier = compactLineSpacingMultiplier } + UiDensity.Default -> { verticalPadding = defaultVerticalPadding textViewMarginTop = defaultTextViewMarginTop lineSpacingMultiplier = defaultLineSpacingMultiplier } + UiDensity.Relaxed -> { verticalPadding = relaxedVerticalPadding textViewMarginTop = relaxedTextViewMarginTop @@ -349,9 +351,11 @@ class MessageListAdapter internal constructor( val messageListItem = getItem(position) bindMessageViewHolder(holder as MessageViewHolder, messageListItem) } + TYPE_FOOTER -> { bindFooterViewHolder(holder as FooterViewHolder) } + else -> { error("Unsupported type: $viewType") } diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/SwipeResourceProvider.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/SwipeResourceProvider.kt index 55b09c816..c98305661 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/SwipeResourceProvider.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/SwipeResourceProvider.kt @@ -2,24 +2,24 @@ package com.fsck.k9.ui.messagelist import android.content.res.Resources.Theme import android.graphics.drawable.Drawable -import androidx.annotation.AttrRes +import androidx.annotation.DrawableRes +import androidx.core.content.res.ResourcesCompat import com.fsck.k9.SwipeAction import com.fsck.k9.ui.R import com.fsck.k9.ui.resolveColorAttribute -import com.fsck.k9.ui.resolveDrawableAttribute class SwipeResourceProvider(val theme: Theme) { val iconTint = theme.resolveColorAttribute(R.attr.messageListSwipeIconTint) - private val selectIcon = theme.loadDrawable(R.attr.messageListSwipeSelectIcon) - private val markAsReadIcon = theme.loadDrawable(R.attr.messageListSwipeMarkAsReadIcon) - private val markAsUnreadIcon = theme.loadDrawable(R.attr.messageListSwipeMarkAsUnreadIcon) - private val addStarIcon = theme.loadDrawable(R.attr.messageListSwipeAddStarIcon) - private val removeStarIcon = theme.loadDrawable(R.attr.messageListSwipeRemoveStarIcon) - private val archiveIcon = theme.loadDrawable(R.attr.messageListSwipeArchiveIcon) - private val deleteIcon = theme.loadDrawable(R.attr.messageListSwipeDeleteIcon) - private val spamIcon = theme.loadDrawable(R.attr.messageListSwipeSpamIcon) - private val moveIcon = theme.loadDrawable(R.attr.messageListSwipeMoveIcon) + private val selectIcon = theme.loadDrawable(R.drawable.ic_check_circle) + private val markAsReadIcon = theme.loadDrawable(R.drawable.ic_opened_envelope) + private val markAsUnreadIcon = theme.loadDrawable(R.drawable.ic_mark_new) + private val addStarIcon = theme.loadDrawable(R.drawable.ic_star) + private val removeStarIcon = theme.loadDrawable(R.drawable.ic_star_outline) + private val archiveIcon = theme.loadDrawable(R.drawable.ic_archive) + private val deleteIcon = theme.loadDrawable(R.drawable.ic_trash_can) + private val spamIcon = theme.loadDrawable(R.drawable.ic_alert_octagon) + private val moveIcon = theme.loadDrawable(R.drawable.ic_move_to_folder) private val noActionColor = theme.resolveColorAttribute(R.attr.messageListSwipeDisabledBackgroundColor) private val selectColor = theme.resolveColorAttribute(R.attr.messageListSwipeSelectBackgroundColor) @@ -81,6 +81,6 @@ class SwipeResourceProvider(val theme: Theme) { } } -private fun Theme.loadDrawable(@AttrRes attributeId: Int): Drawable { - return resolveDrawableAttribute(attributeId).mutate() +private fun Theme.loadDrawable(@DrawableRes drawableResId: Int): Drawable { + return ResourcesCompat.getDrawable(resources, drawableResId, this)!! } diff --git a/app/ui/legacy/src/main/res/layout/message_details_participant_item.xml b/app/ui/legacy/src/main/res/layout/message_details_participant_item.xml index 84078125f..4a8079986 100644 --- a/app/ui/legacy/src/main/res/layout/message_details_participant_item.xml +++ b/app/ui/legacy/src/main/res/layout/message_details_participant_item.xml @@ -63,7 +63,7 @@ android:paddingHorizontal="12dp" app:layout_constraintEnd_toStartOf="@id/menu_overflow" app:layout_constraintTop_toTopOf="@+id/menu_overflow" - app:srcCompat="?attr/messageDetailsAddContactIcon" /> + app:srcCompat="@drawable/ic_person_add" /> + app:srcCompat="@drawable/ic_messagelist_answered" /> + app:srcCompat="@drawable/ic_messagelist_attachment" /> - - - - - - - - - - - - - - @@ -54,7 +40,6 @@ - diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index 160214a2f..2b216d577 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -88,32 +88,18 @@ #ff444444 #ffcccccc #bbbbbb - @drawable/ic_messagelist_attachment - @drawable/ic_messagelist_answered - @drawable/ic_messagelist_forwarded - @drawable/ic_messagelist_answered_forwarded #ffffff @color/material_gray_200 - @drawable/ic_check_circle @color/material_blue_600 - @drawable/ic_opened_envelope - @drawable/ic_mark_new @color/material_blue_600 - @drawable/ic_star - @drawable/ic_star_outline @color/material_orange_600 - @drawable/ic_archive @color/material_green_600 - @drawable/ic_trash_can @color/material_red_600 - @drawable/ic_alert_octagon @color/material_red_700 - @drawable/ic_move_to_folder @color/material_purple_500 #fbbc04 - @drawable/ic_person_add #ffcccccc #ffababab @array/contact_picture_fallback_background_colors_light @@ -123,7 +109,6 @@ #dd2222 #888 - @drawable/ic_visibility #000 #FF8800 #CC0000 @@ -224,32 +209,18 @@ #ffaaaaaa #ff333333 #777777 - @drawable/ic_messagelist_attachment - @drawable/ic_messagelist_answered - @drawable/ic_messagelist_forwarded - @drawable/ic_messagelist_answered_forwarded #ffffff @color/material_gray_900 - @drawable/ic_check_circle @color/material_blue_700 - @drawable/ic_opened_envelope - @drawable/ic_mark_new @color/material_blue_700 - @drawable/ic_star - @drawable/ic_star_outline @color/material_orange_700 - @drawable/ic_archive @color/material_green_700 - @drawable/ic_trash_can @color/material_red_700 - @drawable/ic_alert_octagon @color/material_red_800 - @drawable/ic_move_to_folder @color/material_purple_600 #fdd663 - @drawable/ic_person_add #ff555555 #313131 #ff606060 @@ -259,7 +230,6 @@ #dd2222 #bbb - @drawable/ic_visibility #fff #ee7700 #CC0000