diff --git a/app/src/main/java/org/linphone/activities/main/chat/data/ChatRoomData.kt b/app/src/main/java/org/linphone/activities/main/chat/data/ChatRoomData.kt index 3312a9087..b9e2b01fb 100644 --- a/app/src/main/java/org/linphone/activities/main/chat/data/ChatRoomData.kt +++ b/app/src/main/java/org/linphone/activities/main/chat/data/ChatRoomData.kt @@ -60,6 +60,10 @@ class ChatRoomData(private val chatRoom: ChatRoom) : ContactDataInterface { val lastMessageText = MutableLiveData() + val showLastMessageImdnIcon = MutableLiveData() + + val lastMessageImdnIcon = MutableLiveData() + val notificationsMuted = MutableLiveData() private val basicChatRoom: Boolean by lazy { @@ -160,14 +164,26 @@ class ChatRoomData(private val chatRoom: ChatRoom) : ContactDataInterface { val builder = SpannableStringBuilder() if (msg == null) { lastMessageText.value = builder + showLastMessageImdnIcon.value = false return } - val sender: String = - coreContext.contactsManager.findContactByAddress(msg.fromAddress)?.name - ?: LinphoneUtils.getDisplayName(msg.fromAddress) - builder.append(sender) - builder.append(": ") + if (msg.isOutgoing && msg.state != ChatMessage.State.Displayed) { + msg.addListener(object : ChatMessageListenerStub() { + override fun onMsgStateChanged(message: ChatMessage, state: ChatMessage.State) { + computeLastMessageImdnIcon(message) + } + }) + } + 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) { if (content.isIcalendar) { @@ -189,6 +205,25 @@ class ChatRoomData(private val chatRoom: ChatRoom) : ContactDataInterface { 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 { val id = LinphoneUtils.getChatRoomId(chatRoom.localAddress, chatRoom.peerAddress) return corePreferences.chatRoomMuted(id) diff --git a/app/src/main/res/layout/chat_room_list_cell.xml b/app/src/main/res/layout/chat_room_list_cell.xml index 1f29840d4..1a9928e28 100644 --- a/app/src/main/res/layout/chat_room_list_cell.xml +++ b/app/src/main/res/layout/chat_room_list_cell.xml @@ -1,5 +1,6 @@ - @@ -42,7 +43,7 @@ coilContact="@{data}" android:layout_width="@dimen/contact_avatar_size" android:layout_height="@dimen/contact_avatar_size" - android:layout_marginLeft="5dp" + android:layout_marginStart="5dp" android:contentDescription="@null" android:background="@drawable/generated_avatar_bg" android:src="@drawable/voip_single_contact_avatar" @@ -67,7 +68,7 @@ android:id="@+id/securityLevel" android:layout_width="20dp" android:layout_height="20dp" - android:layout_marginLeft="25dp" + android:layout_marginStart="25dp" android:contentDescription="@{data.securityLevelContentDescription}" android:src="@{data.securityLevelIcon, default=@drawable/security_alert_indicator}" android:visibility="@{data.encryptedChatRoom ? View.VISIBLE : View.INVISIBLE, default=invisible}" @@ -86,15 +87,16 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="@id/avatar" app:layout_constraintEnd_toEndOf="@id/securityLevel" - app:layout_constraintTop_toBottomOf="@id/avatar" /> + app:layout_constraintTop_toBottomOf="@id/avatar" + tools:ignore="RtlHardcoded,RtlSymmetry" /> + + @@ -130,7 +142,7 @@ android:id="@+id/muted" android:layout_width="wrap_content" android:layout_height="20dp" - android:layout_marginRight="10dp" + android:layout_marginEnd="10dp" android:adjustViewBounds="true" android:contentDescription="@string/content_description_muted_chat_room" android:src="@drawable/chat_room_menu_mute_notifications" @@ -143,7 +155,7 @@ style="@style/unread_count_font" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="10dp" + android:layout_marginEnd="10dp" android:background="@drawable/unread_message_count_bg" android:ellipsize="end" android:gravity="center" @@ -157,7 +169,7 @@ android:id="@+id/ephemeral" android:layout_width="wrap_content" android:layout_height="20dp" - android:layout_marginRight="10dp" + android:layout_marginEnd="10dp" android:layout_marginBottom="5dp" android:adjustViewBounds="true" android:contentDescription="@string/content_description_ephemeral_chat_room" @@ -185,7 +197,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" app:barrierDirection="left" - app:constraint_referenced_ids="ephemeral, muted, forward"/> + app:constraint_referenced_ids="ephemeral, muted, forward" + app:layout_constraintStart_toEndOf="@id/lastMessage"/> Votre compte sera supprimé localement.\nPour le supprimer de manière définitive, rendez-vous sur le site internet de votre fournisseur SIP. Votre compte sera supprimé localement.\nPour le supprimer de manière définitive, rendez-vous sur notre plateforme de gestion des comptes : Transfert supervisé + %s : \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6b07d09df..cc35810b3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -137,6 +137,7 @@ No conversations + %s: Remote is writing… You have joined the group You have left the group