Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change message list to material 3 part 1 #7877

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.graphics.drawable.Drawable
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.AbsoluteSizeSpan
import android.text.style.ForegroundColorSpan
import android.text.style.StyleSpan
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -55,9 +54,6 @@ class MessageListAdapter internal constructor(
private val answeredIcon: Drawable = ResourcesCompat.getDrawable(res, Icons.Outlined.Reply, theme)!!
private val forwardedAnsweredIcon: Drawable =
ResourcesCompat.getDrawable(res, Icons.Outlined.CompareArrows, 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)
private val activeItemBackgroundColor: Int = theme.resolveColorAttribute(
colorAttrId = R.attr.messageListActiveItemBackgroundColor,
alphaFractionAttrId = R.attr.messageListActiveItemBackgroundAlphaFraction,
Expand Down Expand Up @@ -375,7 +371,6 @@ class MessageListAdapter internal constructor(
}

with(messageListItem) {
val textColor = if (isRead) readTextColor else unreadTextColor
val maybeBoldTypeface = if (isRead) Typeface.NORMAL else Typeface.BOLD
val displayDate = relativeDateTimeFormatter.formatDate(messageDate)
val displayThreadCount = if (appearance.showingThreadedList) threadCount else 0
Expand Down Expand Up @@ -409,13 +404,11 @@ class MessageListAdapter internal constructor(
messageStringBuilder.append(" – ").append(preview)
}
}
holder.preview.setTextColor(textColor)
holder.preview.setText(messageStringBuilder, TextView.BufferType.SPANNABLE)

formatPreviewText(holder.preview, beforePreviewText, isRead)

holder.subject.typeface = Typeface.create(holder.subject.typeface, maybeBoldTypeface)
holder.subject.setTextColor(textColor)

val firstLineText = if (appearance.senderAboveSubject) displayName else subject
holder.subject.text = firstLineText
Expand All @@ -427,7 +420,6 @@ class MessageListAdapter internal constructor(
}

holder.date.typeface = Typeface.create(holder.date.typeface, maybeBoldTypeface)
holder.date.setTextColor(textColor)
holder.date.text = displayDate
holder.attachment.isVisible = hasAttachments

Expand All @@ -450,14 +442,6 @@ class MessageListAdapter internal constructor(

val beforePreviewLength = beforePreviewText.length
addBeforePreviewSpan(previewText, beforePreviewLength, messageRead)

// Set span (color) for preview message
previewText.setSpan(
ForegroundColorSpan(previewTextColor),
beforePreviewLength,
previewText.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
)
}

private fun addBeforePreviewSpan(text: Spannable, length: Int, messageRead: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:layout_height="1px"
android:layout_marginHorizontal="32dp"
android:layout_marginVertical="8dp"
android:background="?attr/messageDetailsDividerColor"
android:background="?attr/colorOutlineVariant"
android:focusable="false" />
3 changes: 1 addition & 2 deletions app/ui/legacy/src/main/res/layout/message_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/status"
app:layout_constraintTop_toTopOf="@+id/top_guideline"
tools:text="Subject"
tools:textColor="?attr/messageListReadTextColor" />
tools:text="Subject" />

<TextView
android:id="@+id/thread_count"
Expand Down
2 changes: 1 addition & 1 deletion app/ui/legacy/src/main/res/layout/split_message_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:id="@+id/message_list_divider"
android:layout_width="1px"
android:layout_height="fill_parent"
android:background="?attr/messageListDividerColor"
android:background="?attr/colorOutlineVariant"
tools:ignore="PxUsage"/>

<androidx.fragment.app.FragmentContainerView
Expand Down
5 changes: 0 additions & 5 deletions app/ui/legacy/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@
<attr name="messageListActiveItemBackgroundColor" format="reference|color"/>
<attr name="messageListActiveItemBackgroundAlphaFraction" format="fraction"/>
<attr name="messageListActiveItemBackgroundAlphaBackground" format="reference|color"/>
<attr name="messageListUnreadTextColor" format="reference|color"/>
<attr name="messageListReadTextColor" format="reference|color"/>
<attr name="messageListPreviewTextColor" format="reference|color"/>
<attr name="messageListDividerColor" format="reference|color"/>
<attr name="messageListSwipeSelectColor" format="reference|color"/>
<attr name="messageListSwipeToggleReadColor" format="reference|color"/>
<attr name="messageListSwipeToggleStarColor" format="reference|color"/>
<attr name="messageListSwipeArchiveColor" format="reference|color"/>
<attr name="messageListSwipeDeleteColor" format="reference|color"/>
<attr name="messageListSwipeSpamColor" format="reference|color"/>
<attr name="messageListSwipeMoveColor" format="reference|color"/>
<attr name="messageDetailsDividerColor" format="reference|color"/>
<attr name="contactPictureFallbackDefaultBackgroundColor" format="reference|color"/>
<attr name="contactPictureFallbackBackgroundColors" format="reference"/>
<attr name="contactTokenBackgroundColor" format="reference|color"/>
Expand Down
11 changes: 1 addition & 10 deletions app/ui/legacy/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@
<item name="messageListActiveItemBackgroundColor">?attr/colorSecondaryVariant</item>
<item name="messageListActiveItemBackgroundAlphaFraction">60%</item>
<item name="messageListActiveItemBackgroundAlphaBackground">?attr/colorSurface</item>
<item name="messageListUnreadTextColor">#dd000000</item>
<item name="messageListReadTextColor">#ff444444</item>
<item name="messageListPreviewTextColor">#ff444444</item>
<item name="messageListDividerColor">#ffcccccc</item>

<item name="messageListSwipeSelectColor">@color/material_blue_600</item>
<item name="messageListSwipeToggleReadColor">@color/material_blue_600</item>
Expand All @@ -91,7 +87,6 @@
<item name="messageListSwipeSpamColor">@color/material_red_700</item>
<item name="messageListSwipeMoveColor">@color/material_purple_500</item>

<item name="messageDetailsDividerColor">#ffcccccc</item>
<item name="contactPictureFallbackDefaultBackgroundColor">#ffababab</item>
<item name="contactPictureFallbackBackgroundColors">@array/contact_picture_fallback_background_colors_light</item>
<item name="contactTokenBackgroundColor">#ccc</item>
Expand Down Expand Up @@ -182,17 +177,14 @@

<item name="textColorPrimaryRecipientDropdown">@android:color/primary_text_dark</item>
<item name="textColorSecondaryRecipientDropdown">@android:color/secondary_text_dark</item>

<item name="messageListRegularItemBackgroundColor">?android:attr/windowBackground</item>
<item name="messageListReadItemBackgroundColor">?attr/messageListRegularItemBackgroundColor</item>
<item name="messageListUnreadItemBackgroundColor">#ff505050</item>
<item name="messageListThreadCountTextColor">?android:attr/textColorSecondary</item>
<item name="messageListActiveItemBackgroundColor">?attr/colorSecondaryVariant</item>
<item name="messageListActiveItemBackgroundAlphaFraction">50%</item>
<item name="messageListActiveItemBackgroundAlphaBackground">?attr/colorSurface</item>
<item name="messageListUnreadTextColor">#ffffffff</item>
<item name="messageListReadTextColor">#ffaaaaaa</item>
<item name="messageListPreviewTextColor">#ffaaaaaa</item>
<item name="messageListDividerColor">#ff333333</item>

<item name="messageListSwipeSelectColor">@color/material_blue_700</item>
<item name="messageListSwipeToggleReadColor">@color/material_blue_700</item>
Expand All @@ -202,7 +194,6 @@
<item name="messageListSwipeSpamColor">@color/material_red_800</item>
<item name="messageListSwipeMoveColor">@color/material_purple_600</item>

<item name="messageDetailsDividerColor">#ff555555</item>
<item name="contactTokenBackgroundColor">#313131</item>
<item name="contactPictureFallbackDefaultBackgroundColor">#ff606060</item>
<item name="contactPictureFallbackBackgroundColors">@array/contact_picture_fallback_background_colors_dark</item>
Expand Down