mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
+23
-14
@@ -22,6 +22,10 @@ import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.text.bold
|
||||
import androidx.core.text.buildSpannedString
|
||||
import androidx.core.text.color
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.Navigator
|
||||
@@ -86,19 +90,6 @@ class ConversationsAdapter @Inject constructor(
|
||||
override fun onBindViewHolder(holder: QkViewHolder<ConversationListItemBinding>, position: Int) {
|
||||
val conversation = getItem(position) ?: return
|
||||
|
||||
holder.binding.root.isActivated = isSelected(conversation.id)
|
||||
|
||||
holder.binding.avatars.recipients = conversation.recipients
|
||||
holder.binding.title.collapseEnabled = conversation.recipients.size > 1
|
||||
holder.binding.title.text = conversation.getTitle()
|
||||
holder.binding.date.text = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp)
|
||||
holder.binding.snippet.text = when {
|
||||
conversation.draft.isNotEmpty() -> context.getString(R.string.main_draft, conversation.draft)
|
||||
conversation.me -> context.getString(R.string.main_sender_you, conversation.snippet)
|
||||
else -> conversation.snippet
|
||||
}
|
||||
holder.binding.pinned.isVisible = conversation.pinned
|
||||
|
||||
// If the last message wasn't incoming, then the colour doesn't really matter anyway
|
||||
val lastMessage = conversation.lastMessage
|
||||
val recipient = when {
|
||||
@@ -107,8 +98,26 @@ class ConversationsAdapter @Inject constructor(
|
||||
phoneNumberUtils.compare(recipient.address, lastMessage.address)
|
||||
}
|
||||
}
|
||||
val theme = colors.theme(recipient).theme
|
||||
|
||||
holder.binding.unread.setTint(colors.theme(recipient).theme)
|
||||
holder.binding.root.isActivated = isSelected(conversation.id)
|
||||
|
||||
holder.binding.avatars.recipients = conversation.recipients
|
||||
holder.binding.title.collapseEnabled = conversation.recipients.size > 1
|
||||
holder.binding.title.text = buildSpannedString {
|
||||
append(conversation.getTitle())
|
||||
if (conversation.draft.isNotEmpty()) {
|
||||
color(theme) { append(" " + context.getString(R.string.main_draft)) }
|
||||
}
|
||||
}
|
||||
holder.binding.date.text = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp)
|
||||
holder.binding.snippet.text = when {
|
||||
conversation.draft.isNotEmpty() -> conversation.draft
|
||||
conversation.me -> context.getString(R.string.main_sender_you, conversation.snippet)
|
||||
else -> conversation.snippet
|
||||
}
|
||||
holder.binding.pinned.isVisible = conversation.pinned
|
||||
holder.binding.unread.setTint(theme)
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
|
||||
Reference in New Issue
Block a user