Added IMDN status in chat rooms list for last message if outgoing + removed sender name in front of last message for 1-1 chat rooms
This commit is contained in:
parent
7136a991b3
commit
2fd0b87467
4 changed files with 68 additions and 18 deletions
|
@ -60,6 +60,10 @@ class ChatRoomData(private val chatRoom: ChatRoom) : ContactDataInterface {
|
||||||
|
|
||||||
val lastMessageText = MutableLiveData<SpannableStringBuilder>()
|
val lastMessageText = MutableLiveData<SpannableStringBuilder>()
|
||||||
|
|
||||||
|
val showLastMessageImdnIcon = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
val lastMessageImdnIcon = MutableLiveData<Int>()
|
||||||
|
|
||||||
val notificationsMuted = MutableLiveData<Boolean>()
|
val notificationsMuted = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
private val basicChatRoom: Boolean by lazy {
|
private val basicChatRoom: Boolean by lazy {
|
||||||
|
@ -160,14 +164,26 @@ class ChatRoomData(private val chatRoom: ChatRoom) : ContactDataInterface {
|
||||||
val builder = SpannableStringBuilder()
|
val builder = SpannableStringBuilder()
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
lastMessageText.value = builder
|
lastMessageText.value = builder
|
||||||
|
showLastMessageImdnIcon.value = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val sender: String =
|
if (msg.isOutgoing && msg.state != ChatMessage.State.Displayed) {
|
||||||
coreContext.contactsManager.findContactByAddress(msg.fromAddress)?.name
|
msg.addListener(object : ChatMessageListenerStub() {
|
||||||
?: LinphoneUtils.getDisplayName(msg.fromAddress)
|
override fun onMsgStateChanged(message: ChatMessage, state: ChatMessage.State) {
|
||||||
builder.append(sender)
|
computeLastMessageImdnIcon(message)
|
||||||
builder.append(": ")
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
computeLastMessageImdnIcon(msg)
|
||||||
|
|
||||||
|
if (!chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
||||||
|
val sender: String =
|
||||||
|
coreContext.contactsManager.findContactByAddress(msg.fromAddress)?.name
|
||||||
|
?: LinphoneUtils.getDisplayName(msg.fromAddress)
|
||||||
|
builder.append(coreContext.context.getString(R.string.chat_room_last_message_sender_format, sender))
|
||||||
|
builder.append(" ")
|
||||||
|
}
|
||||||
|
|
||||||
for (content in msg.contents) {
|
for (content in msg.contents) {
|
||||||
if (content.isIcalendar) {
|
if (content.isIcalendar) {
|
||||||
|
@ -189,6 +205,25 @@ class ChatRoomData(private val chatRoom: ChatRoom) : ContactDataInterface {
|
||||||
lastMessageText.value = builder
|
lastMessageText.value = builder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun computeLastMessageImdnIcon(msg: ChatMessage) {
|
||||||
|
val state = msg.state
|
||||||
|
showLastMessageImdnIcon.value = if (msg.isOutgoing) {
|
||||||
|
when (state) {
|
||||||
|
ChatMessage.State.DeliveredToUser, ChatMessage.State.Displayed,
|
||||||
|
ChatMessage.State.NotDelivered, ChatMessage.State.FileTransferError -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
lastMessageImdnIcon.value = when (state) {
|
||||||
|
ChatMessage.State.DeliveredToUser -> R.drawable.chat_delivered
|
||||||
|
ChatMessage.State.Displayed -> R.drawable.chat_read
|
||||||
|
ChatMessage.State.FileTransferError, ChatMessage.State.NotDelivered -> R.drawable.chat_error
|
||||||
|
else -> R.drawable.chat_error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun areNotificationsMuted(): Boolean {
|
private fun areNotificationsMuted(): Boolean {
|
||||||
val id = LinphoneUtils.getChatRoomId(chatRoom.localAddress, chatRoom.peerAddress)
|
val id = LinphoneUtils.getChatRoomId(chatRoom.localAddress, chatRoom.peerAddress)
|
||||||
return corePreferences.chatRoomMuted(id)
|
return corePreferences.chatRoomMuted(id)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
coilContact="@{data}"
|
coilContact="@{data}"
|
||||||
android:layout_width="@dimen/contact_avatar_size"
|
android:layout_width="@dimen/contact_avatar_size"
|
||||||
android:layout_height="@dimen/contact_avatar_size"
|
android:layout_height="@dimen/contact_avatar_size"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginStart="5dp"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:background="@drawable/generated_avatar_bg"
|
android:background="@drawable/generated_avatar_bg"
|
||||||
android:src="@drawable/voip_single_contact_avatar"
|
android:src="@drawable/voip_single_contact_avatar"
|
||||||
|
@ -67,7 +68,7 @@
|
||||||
android:id="@+id/securityLevel"
|
android:id="@+id/securityLevel"
|
||||||
android:layout_width="20dp"
|
android:layout_width="20dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:layout_marginLeft="25dp"
|
android:layout_marginStart="25dp"
|
||||||
android:contentDescription="@{data.securityLevelContentDescription}"
|
android:contentDescription="@{data.securityLevelContentDescription}"
|
||||||
android:src="@{data.securityLevelIcon, default=@drawable/security_alert_indicator}"
|
android:src="@{data.securityLevelIcon, default=@drawable/security_alert_indicator}"
|
||||||
android:visibility="@{data.encryptedChatRoom ? View.VISIBLE : View.INVISIBLE, default=invisible}"
|
android:visibility="@{data.encryptedChatRoom ? View.VISIBLE : View.INVISIBLE, default=invisible}"
|
||||||
|
@ -86,15 +87,16 @@
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="@id/avatar"
|
app:layout_constraintStart_toStartOf="@id/avatar"
|
||||||
app:layout_constraintEnd_toEndOf="@id/securityLevel"
|
app:layout_constraintEnd_toEndOf="@id/securityLevel"
|
||||||
app:layout_constraintTop_toBottomOf="@id/avatar" />
|
app:layout_constraintTop_toBottomOf="@id/avatar"
|
||||||
|
tools:ignore="RtlHardcoded,RtlSymmetry" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
style="@style/contact_name_list_cell_font"
|
style="@style/contact_name_list_cell_font"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginEnd="5dp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:text="@{data.oneToOneChatRoom ? (data.contact.name ?? data.displayName) : data.subject, default=`Lorem Ipsum`}"
|
android:text="@{data.oneToOneChatRoom ? (data.contact.name ?? data.displayName) : data.subject, default=`Lorem Ipsum`}"
|
||||||
|
@ -102,17 +104,27 @@
|
||||||
app:layout_constraintEnd_toStartOf="@id/unread"
|
app:layout_constraintEnd_toStartOf="@id/unread"
|
||||||
app:layout_constraintTop_toTopOf="@id/avatar" />
|
app:layout_constraintTop_toTopOf="@id/avatar" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imdn"
|
||||||
|
android:layout_width="15dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingEnd="3dp"
|
||||||
|
android:contentDescription="@string/content_description_delivery_status"
|
||||||
|
android:src="@{data.lastMessageImdnIcon, default=@drawable/chat_delivered}"
|
||||||
|
android:visibility="@{data.showLastMessageImdnIcon ? View.VISIBLE : View.GONE}"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/title"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/lastMessage"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/lastMessage"
|
android:id="@+id/lastMessage"
|
||||||
style="@style/standard_small_text_font"
|
style="@style/standard_small_text_font"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:text="@{data.lastMessageText, default=`Lorem ipsum dolor sit amet`}"
|
android:text="@{data.lastMessageText, default=`Lorem ipsum dolor sit amet`}"
|
||||||
app:layout_constraintStart_toEndOf="@id/date"
|
app:layout_constraintStart_toEndOf="@id/imdn"
|
||||||
app:layout_constraintEnd_toStartOf="@id/endBarrier"
|
app:layout_constraintEnd_toStartOf="@id/endBarrier"
|
||||||
app:layout_constraintTop_toBottomOf="@id/title" />
|
app:layout_constraintTop_toBottomOf="@id/title" />
|
||||||
|
|
||||||
|
@ -130,7 +142,7 @@
|
||||||
android:id="@+id/muted"
|
android:id="@+id/muted"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:contentDescription="@string/content_description_muted_chat_room"
|
android:contentDescription="@string/content_description_muted_chat_room"
|
||||||
android:src="@drawable/chat_room_menu_mute_notifications"
|
android:src="@drawable/chat_room_menu_mute_notifications"
|
||||||
|
@ -143,7 +155,7 @@
|
||||||
style="@style/unread_count_font"
|
style="@style/unread_count_font"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:background="@drawable/unread_message_count_bg"
|
android:background="@drawable/unread_message_count_bg"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
@ -157,7 +169,7 @@
|
||||||
android:id="@+id/ephemeral"
|
android:id="@+id/ephemeral"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:contentDescription="@string/content_description_ephemeral_chat_room"
|
android:contentDescription="@string/content_description_ephemeral_chat_room"
|
||||||
|
@ -185,7 +197,8 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:barrierDirection="left"
|
app:barrierDirection="left"
|
||||||
app:constraint_referenced_ids="ephemeral, muted, forward"/>
|
app:constraint_referenced_ids="ephemeral, muted, forward"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/lastMessage"/>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Barrier
|
<androidx.constraintlayout.widget.Barrier
|
||||||
android:id="@+id/endBarrier3"
|
android:id="@+id/endBarrier3"
|
||||||
|
|
|
@ -771,4 +771,5 @@
|
||||||
<string name="account_setting_delete_generic_confirmation_dialog">Votre compte sera supprimé localement.\nPour le supprimer de manière définitive, rendez-vous sur le site internet de votre fournisseur SIP.</string>
|
<string name="account_setting_delete_generic_confirmation_dialog">Votre compte sera supprimé localement.\nPour le supprimer de manière définitive, rendez-vous sur le site internet de votre fournisseur SIP.</string>
|
||||||
<string name="account_setting_delete_sip_linphone_org_confirmation_dialog">Votre compte sera supprimé localement.\nPour le supprimer de manière définitive, rendez-vous sur notre plateforme de gestion des comptes :</string>
|
<string name="account_setting_delete_sip_linphone_org_confirmation_dialog">Votre compte sera supprimé localement.\nPour le supprimer de manière définitive, rendez-vous sur notre plateforme de gestion des comptes :</string>
|
||||||
<string name="call_action_attended_transfer_call">Transfert supervisé</string>
|
<string name="call_action_attended_transfer_call">Transfert supervisé</string>
|
||||||
|
<string name="chat_room_last_message_sender_format">%s :</string>
|
||||||
</resources>
|
</resources>
|
|
@ -137,6 +137,7 @@
|
||||||
|
|
||||||
<!-- Chat -->
|
<!-- Chat -->
|
||||||
<string name="no_chat_history">No conversations</string>
|
<string name="no_chat_history">No conversations</string>
|
||||||
|
<string name="chat_room_last_message_sender_format">%s:</string>
|
||||||
<string name="chat_remote_is_composing">Remote is writing…</string>
|
<string name="chat_remote_is_composing">Remote is writing…</string>
|
||||||
<string name="chat_event_conference_created">You have joined the group</string>
|
<string name="chat_event_conference_created">You have joined the group</string>
|
||||||
<string name="chat_event_conference_destroyed">You have left the group</string>
|
<string name="chat_event_conference_destroyed">You have left the group</string>
|
||||||
|
|
Loading…
Reference in a new issue