mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-02-07 14:58:24 +00:00
Added icon next to last message in conversations list depending on it's content
This commit is contained in:
parent
eebc1bc91e
commit
049f63b61e
2 changed files with 40 additions and 7 deletions
|
|
@ -36,6 +36,7 @@ import org.linphone.core.Friend
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.FileUtils
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
import org.linphone.utils.ShortcutUtils
|
||||
import org.linphone.utils.TimestampUtils
|
||||
|
|
@ -77,9 +78,9 @@ class ConversationModel
|
|||
|
||||
val lastMessageText = MutableLiveData<Spannable>()
|
||||
|
||||
val lastMessageIcon = MutableLiveData<Int>()
|
||||
val lastMessageDeliveryIcon = MutableLiveData<Int>()
|
||||
|
||||
val isLastMessageForwarded = MutableLiveData<Boolean>()
|
||||
val lastMessageContentIcon = MutableLiveData<Int>()
|
||||
|
||||
val isLastMessageOutgoing = MutableLiveData<Boolean>()
|
||||
|
||||
|
|
@ -186,6 +187,7 @@ class ConversationModel
|
|||
Log.d(
|
||||
"$TAG Ephemeral messages are [${if (chatRoom.isEphemeralEnabled) "enabled" else "disabled"}], lifetime is [${chatRoom.ephemeralLifetime}]"
|
||||
)
|
||||
lastMessageContentIcon.postValue(0)
|
||||
|
||||
updateLastMessage()
|
||||
updateLastUpdatedTime()
|
||||
|
|
@ -292,9 +294,36 @@ class ConversationModel
|
|||
|
||||
isLastMessageOutgoing.postValue(isOutgoing)
|
||||
if (isOutgoing) {
|
||||
lastMessageIcon.postValue(LinphoneUtils.getChatIconResId(message.state))
|
||||
lastMessageDeliveryIcon.postValue(LinphoneUtils.getChatIconResId(message.state))
|
||||
}
|
||||
|
||||
if (message.isForward) {
|
||||
lastMessageContentIcon.postValue(R.drawable.forward)
|
||||
} else {
|
||||
val firstContent = message.contents.firstOrNull()
|
||||
val icon = if (firstContent?.isIcalendar == true) {
|
||||
R.drawable.calendar
|
||||
} else if (firstContent?.isVoiceRecording == true) {
|
||||
R.drawable.waveform
|
||||
} else if (firstContent?.isFile == true) {
|
||||
val mime = "${firstContent.type}/${firstContent.subtype}"
|
||||
val mimeType = FileUtils.getMimeType(mime)
|
||||
val drawable = when (mimeType) {
|
||||
FileUtils.MimeType.Image -> R.drawable.file_image
|
||||
FileUtils.MimeType.Video -> R.drawable.file_video
|
||||
FileUtils.MimeType.Audio -> R.drawable.file_audio
|
||||
FileUtils.MimeType.Pdf -> R.drawable.file_pdf
|
||||
FileUtils.MimeType.PlainText -> R.drawable.file_text
|
||||
else -> R.drawable.file
|
||||
}
|
||||
drawable
|
||||
} else if (firstContent?.isFileTransfer == true) {
|
||||
R.drawable.download_simple
|
||||
} else {
|
||||
0
|
||||
}
|
||||
lastMessageContentIcon.postValue(icon)
|
||||
}
|
||||
isLastMessageForwarded.postValue(message.isForward)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -309,6 +338,9 @@ class ConversationModel
|
|||
if (message.isOutgoing && message.state != ChatMessage.State.Displayed) {
|
||||
message.addListener(chatMessageListener)
|
||||
lastMessage = message
|
||||
} else if (message.contents.find { it.isFileTransfer == true } != null) {
|
||||
message.addListener(chatMessageListener)
|
||||
lastMessage = message
|
||||
}
|
||||
} else {
|
||||
Log.w("$TAG No last message to display for conversation [$id]")
|
||||
|
|
|
|||
|
|
@ -104,9 +104,10 @@
|
|||
android:layout_marginStart="@{model.lastMessageTextSender.length() > 0 ? @dimen/five : @dimen/zero}"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:src="@drawable/forward"
|
||||
android:visibility="@{model.isLastMessageForwarded ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:src="@{model.lastMessageContentIcon, default=@drawable/forward}"
|
||||
android:visibility="@{model.lastMessageContentIcon > 0 && !model.isComposing ? View.VISIBLE : View.GONE}"
|
||||
android:contentDescription="@null"
|
||||
app:tint="?attr/color_main2_600"
|
||||
app:layout_constraintStart_toEndOf="@id/last_message_sender"
|
||||
app:layout_constraintEnd_toStartOf="@id/last_message_or_composing"
|
||||
app:layout_constraintTop_toTopOf="@id/last_message_or_composing"
|
||||
|
|
@ -164,7 +165,7 @@
|
|||
android:layout_height="@dimen/small_icon_size"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:contentDescription="@string/content_description_chat_bubble_delivery_status"
|
||||
android:src="@{model.lastMessageIcon, default=@drawable/animated_in_progress}"
|
||||
android:src="@{model.lastMessageDeliveryIcon, default=@drawable/animated_in_progress}"
|
||||
android:visibility="@{model.isLastMessageOutgoing ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toStartOf="@id/notifications_count"
|
||||
app:layout_constraintTop_toBottomOf="@id/date_time"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue