mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Sort drafts first, save drafts for new conversations, show drafts in widget
Closes #1296
This commit is contained in:
+4
-4
@@ -86,7 +86,6 @@ class ConversationsAdapter @Inject constructor(
|
||||
|
||||
override fun onBindViewHolder(viewHolder: QkViewHolder, position: Int) {
|
||||
val conversation = getItem(position) ?: return
|
||||
val lastMessage = conversation.lastMessage ?: return
|
||||
val view = viewHolder.containerView
|
||||
|
||||
view.isActivated = isSelected(conversation.id)
|
||||
@@ -94,7 +93,7 @@ class ConversationsAdapter @Inject constructor(
|
||||
view.avatars.recipients = conversation.recipients
|
||||
view.title.collapseEnabled = conversation.recipients.size > 1
|
||||
view.title.text = conversation.getTitle()
|
||||
view.date.text = dateFormatter.getConversationTimestamp(conversation.date)
|
||||
view.date.text = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp)
|
||||
view.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)
|
||||
@@ -103,8 +102,9 @@ class ConversationsAdapter @Inject constructor(
|
||||
view.pinned.isVisible = conversation.pinned
|
||||
|
||||
// If the last message wasn't incoming, then the colour doesn't really matter anyway
|
||||
val recipient = when (conversation.recipients.size) {
|
||||
1 -> conversation.recipients.firstOrNull()
|
||||
val lastMessage = conversation.lastMessage
|
||||
val recipient = when {
|
||||
conversation.recipients.size == 1 || lastMessage == null -> conversation.recipients.firstOrNull()
|
||||
else -> conversation.recipients.find { recipient ->
|
||||
phoneNumberUtils.compare(recipient.address, lastMessage.address)
|
||||
}
|
||||
|
||||
@@ -142,13 +142,18 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
remoteViews.setTextViewText(R.id.name, boldText(conversation.getTitle(), conversation.unread))
|
||||
|
||||
// Date
|
||||
val timestamp = dateFormatter.getConversationTimestamp(conversation.date)
|
||||
val timestamp = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp)
|
||||
remoteViews.setTextColor(R.id.date, if (conversation.unread) textPrimary else textTertiary)
|
||||
remoteViews.setTextViewText(R.id.date, boldText(timestamp, conversation.unread))
|
||||
|
||||
// Snippet
|
||||
val snippet = 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
|
||||
}
|
||||
remoteViews.setTextColor(R.id.snippet, if (conversation.unread) textPrimary else textTertiary)
|
||||
remoteViews.setTextViewText(R.id.snippet, boldText(conversation.snippet, conversation.unread))
|
||||
remoteViews.setTextViewText(R.id.snippet, boldText(snippet, conversation.unread))
|
||||
|
||||
// Launch conversation on click
|
||||
val clickIntent = Intent().putExtra("threadId", conversation.id)
|
||||
|
||||
Reference in New Issue
Block a user