mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 00:16:48 -06:00
Use text color, font face and red dot to differentiate unread messages (#2027)
This commit is contained in:
parent
7bee10d5ce
commit
515a3973b7
@ -1,15 +1,18 @@
|
|||||||
package io.github.wulkanowy.ui.modules.message.tab
|
package io.github.wulkanowy.ui.modules.message.tab
|
||||||
|
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.CompoundButton
|
import android.widget.CompoundButton
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.core.widget.ImageViewCompat
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.databinding.ItemMessageBinding
|
import io.github.wulkanowy.databinding.ItemMessageBinding
|
||||||
import io.github.wulkanowy.databinding.ItemMessageChipsBinding
|
import io.github.wulkanowy.databinding.ItemMessageChipsBinding
|
||||||
|
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -85,21 +88,35 @@ class MessageTabAdapter @Inject constructor() :
|
|||||||
val message = item.message
|
val message = item.message
|
||||||
|
|
||||||
with(holder.binding) {
|
with(holder.binding) {
|
||||||
val style = if (message.unread) Typeface.BOLD else Typeface.NORMAL
|
val normalFont = Typeface.create("sans-serif", Typeface.NORMAL)
|
||||||
|
val boldFont = Typeface.create("sans-serif-black", Typeface.NORMAL)
|
||||||
|
|
||||||
|
val primaryColor = root.context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||||
|
val secondaryColor = root.context.getThemeAttrColor(android.R.attr.textColorSecondary)
|
||||||
|
|
||||||
|
val currentFont = if (message.unread) boldFont else normalFont
|
||||||
|
val currentTextColor = if (message.unread) primaryColor else secondaryColor
|
||||||
|
|
||||||
with(messageItemAuthor) {
|
with(messageItemAuthor) {
|
||||||
text = message.correspondents
|
text = message.correspondents
|
||||||
setTypeface(null, style)
|
setTextColor(currentTextColor)
|
||||||
|
typeface = currentFont
|
||||||
}
|
}
|
||||||
messageItemSubject.run {
|
with(messageItemSubject) {
|
||||||
text = message.subject.ifBlank { context.getString(R.string.message_no_subject) }
|
text = message.subject.ifBlank { context.getString(R.string.message_no_subject) }
|
||||||
setTypeface(null, style)
|
setTextColor(currentTextColor)
|
||||||
|
typeface = currentFont
|
||||||
}
|
}
|
||||||
messageItemDate.run {
|
with(messageItemDate) {
|
||||||
text = message.date.toFormattedString()
|
text = message.date.toFormattedString()
|
||||||
setTypeface(null, style)
|
setTextColor(currentTextColor)
|
||||||
|
typeface = currentFont
|
||||||
}
|
}
|
||||||
messageItemAttachmentIcon.isVisible = message.hasAttachments
|
with(messageItemAttachmentIcon) {
|
||||||
|
ImageViewCompat.setImageTintList(this, ColorStateList.valueOf(currentTextColor))
|
||||||
|
isVisible = message.hasAttachments
|
||||||
|
}
|
||||||
|
messageItemUnreadIndicator.isVisible = message.unread
|
||||||
|
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
holder.bindingAdapterPosition.let {
|
holder.bindingAdapterPosition.let {
|
||||||
@ -111,7 +128,7 @@ class MessageTabAdapter @Inject constructor() :
|
|||||||
|
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
onLongItemClickListener(item)
|
onLongItemClickListener(item)
|
||||||
return@setOnLongClickListener true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
with(messageItemCheckbox) {
|
with(messageItemCheckbox) {
|
||||||
|
10
app/src/main/res/drawable/ic_circle.xml
Normal file
10
app/src/main/res/drawable/ic_circle.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
|
||||||
|
<solid android:color="@color/colorPrimary" />
|
||||||
|
|
||||||
|
<size
|
||||||
|
android:width="100dp"
|
||||||
|
android:height="100dp" />
|
||||||
|
</shape>
|
@ -30,6 +30,7 @@
|
|||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/messageItemDate"
|
app:layout_constraintEnd_toStartOf="@+id/messageItemDate"
|
||||||
app:layout_constraintStart_toEndOf="@id/messageItemCheckbox"
|
app:layout_constraintStart_toEndOf="@id/messageItemCheckbox"
|
||||||
@ -40,10 +41,13 @@
|
|||||||
android:id="@+id/messageItemDate"
|
android:id="@+id/messageItemDate"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:textSize="13sp"
|
android:textSize="13sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toStartOf="@id/messageItemUnreadIndicator"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_goneMarginEnd="0dp"
|
||||||
tools:text="@tools:sample/date/ddmmyy" />
|
tools:text="@tools:sample/date/ddmmyy" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -69,9 +73,21 @@
|
|||||||
android:layout_height="16dp"
|
android:layout_height="16dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/messageItemSubject"
|
app:layout_constraintBottom_toBottomOf="@id/messageItemSubject"
|
||||||
app:layout_constraintEnd_toEndOf="@id/messageItemDate"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:srcCompat="@drawable/ic_attachment"
|
app:srcCompat="@drawable/ic_attachment"
|
||||||
app:tint="?colorOnBackground"
|
app:tint="?android:textColorSecondary"
|
||||||
|
tools:ignore="ContentDescription"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/messageItemUnreadIndicator"
|
||||||
|
android:layout_width="10dp"
|
||||||
|
android:layout_height="10dp"
|
||||||
|
android:src="@drawable/ic_circle"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/messageItemDate"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/messageItemDate"
|
||||||
|
app:tint="?colorPrimary"
|
||||||
tools:ignore="ContentDescription"
|
tools:ignore="ContentDescription"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user