diff --git a/app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt b/app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt index 39518f3b595..a146d4026fb 100644 --- a/app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt +++ b/app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt @@ -167,12 +167,16 @@ class MessageMapper @Inject constructor( val flowStatus = if (content is MessageContent.FailedDecryption) { MessageFlowStatus.Failure.Decryption(content.isDecryptionResolved) } else { - when (message.status) { - Message.Status.PENDING -> MessageFlowStatus.Sending - Message.Status.SENT -> MessageFlowStatus.Sent - Message.Status.READ -> MessageFlowStatus.Read(1) // TODO add read count - Message.Status.FAILED -> MessageFlowStatus.Failure.Send.Locally(isMessageEdited) - Message.Status.FAILED_REMOTELY -> MessageFlowStatus.Failure.Send.Remotely(isMessageEdited, message.conversationId.domain) + when (val status = message.status) { + Message.Status.Pending -> MessageFlowStatus.Sending + Message.Status.Sent -> MessageFlowStatus.Sent + is Message.Status.Read -> MessageFlowStatus.Read(status.readCount) + Message.Status.Failed -> MessageFlowStatus.Failure.Send.Locally(isMessageEdited) + Message.Status.FailedRemotely -> MessageFlowStatus.Failure.Send.Remotely( + isEdited = isMessageEdited, + backendWithFailure = message.conversationId.domain + ) + Message.Status.Delivered -> MessageFlowStatus.Delivered } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageStatusIndicator.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageStatusIndicator.kt index dbd614ce7c3..721261c4f6b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageStatusIndicator.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/MessageStatusIndicator.kt @@ -17,8 +17,10 @@ */ package com.wire.android.ui.home.conversations +import androidx.compose.foundation.layout.Row import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource @@ -46,16 +48,37 @@ fun MessageStatusIndicator(status: MessageFlowStatus, modifier: Modifier = Modif tint = MaterialTheme.wireColorScheme.error, contentDescription = stringResource(R.string.content_description_message_error_status), ) - // TODO handle read, sent and delivered status -// MessageFlowStatus.Sent -> Icon( -// modifier = modifier, -// painter = painterResource(id = R.drawable.ic_message_delivered), -// tint = MaterialTheme.wireColorScheme.onTertiaryButtonDisabled, -// contentDescription = stringResource(R.string.content_description_message_delivered_status), -// ) -// is MessageFlowStatus.Read -> {} -// MessageFlowStatus.Delivered -> TODO() - else -> HorizontalSpace.x16() + + MessageFlowStatus.Sent -> { + Icon( + modifier = modifier, + painter = painterResource(id = R.drawable.ic_message_sent), + tint = MaterialTheme.wireColorScheme.onTertiaryButtonDisabled, + contentDescription = stringResource(R.string.content_description_message_sent_status), + ) + } + + MessageFlowStatus.Delivered -> { + Icon( + modifier = modifier, + painter = painterResource(id = R.drawable.ic_message_delivered), + tint = MaterialTheme.wireColorScheme.onTertiaryButtonDisabled, + contentDescription = stringResource(R.string.content_description_message_delivered_status), + ) + } + + is MessageFlowStatus.Read -> { + Row { + Icon( + modifier = modifier, + painter = painterResource(id = R.drawable.ic_message_read), + tint = MaterialTheme.wireColorScheme.onTertiaryButtonDisabled, + contentDescription = stringResource(R.string.content_description_message_read_status), + ) + HorizontalSpace.x4() + Text(status.count.toString()) + } + } } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt index cd722eb4eae..87fb6def1d8 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt @@ -125,8 +125,8 @@ sealed class MessageEditStatus { sealed class MessageFlowStatus { - object Sending : MessageFlowStatus() - object Sent : MessageFlowStatus() + data object Sending : MessageFlowStatus() + data object Sent : MessageFlowStatus() sealed class Failure(val errorText: UIText) : MessageFlowStatus() { sealed class Send(errorText: UIText) : Failure(errorText) { data class Locally(val isEdited: Boolean) : Send( @@ -157,9 +157,9 @@ sealed class MessageFlowStatus { ) } - object Delivered : MessageFlowStatus() + data object Delivered : MessageFlowStatus() - data class Read(val count: Int) : MessageFlowStatus() + data class Read(val count: Long) : MessageFlowStatus() } @Stable diff --git a/app/src/test/kotlin/com/wire/android/framework/TestMessage.kt b/app/src/test/kotlin/com/wire/android/framework/TestMessage.kt index ba2fde75f69..7001e1d6ac8 100644 --- a/app/src/test/kotlin/com/wire/android/framework/TestMessage.kt +++ b/app/src/test/kotlin/com/wire/android/framework/TestMessage.kt @@ -20,20 +20,6 @@ package com.wire.android.framework -import com.wire.android.mapper.AssetMessageContentMetadata -import com.wire.android.model.UserAvatarData -import com.wire.android.ui.home.conversations.model.ExpirationStatus -import com.wire.android.ui.home.conversations.model.MessageBody -import com.wire.android.ui.home.conversations.model.MessageFlowStatus -import com.wire.android.ui.home.conversations.model.MessageFooter -import com.wire.android.ui.home.conversations.model.MessageHeader -import com.wire.android.ui.home.conversations.model.MessageSource -import com.wire.android.ui.home.conversations.model.MessageStatus -import com.wire.android.ui.home.conversations.model.MessageTime -import com.wire.android.ui.home.conversations.model.UIMessage -import com.wire.android.ui.home.conversations.model.UIMessageContent.TextMessage -import com.wire.android.ui.home.conversationslist.model.Membership -import com.wire.android.util.ui.UIText import com.wire.kalium.logic.data.conversation.ClientId import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.message.AssetContent @@ -42,27 +28,9 @@ import com.wire.kalium.logic.data.message.MessageContent import com.wire.kalium.logic.data.message.MessageEncryptionAlgorithm import com.wire.kalium.logic.data.message.MessagePreview import com.wire.kalium.logic.data.message.MessagePreviewContent -import com.wire.kalium.logic.data.user.UserAvailabilityStatus import com.wire.kalium.logic.data.user.UserId object TestMessage { - - val FAILED_DECRYPTION = Message.Regular( - id = "messageID", - content = MessageContent.FailedDecryption( - null, - senderUserId = UserId("user-id", "domain"), - isDecryptionResolved = false - ), - conversationId = ConversationId("convo-id", "convo.domain"), - date = "some-date", - senderUserId = UserId("user-id", "domain"), - senderClientId = ClientId("client-id"), - status = Message.Status.SENT, - editStatus = Message.EditStatus.NotEdited, - isSelfMessage = false - ) - val TEXT_MESSAGE = Message.Regular( id = "messageID", content = MessageContent.Text("Some Text Message"), @@ -70,7 +38,7 @@ object TestMessage { date = "some-date", senderUserId = UserId("user-id", "domain"), senderClientId = ClientId("client-id"), - status = Message.Status.SENT, + status = Message.Status.Sent, editStatus = Message.EditStatus.NotEdited, isSelfMessage = false ) @@ -107,7 +75,7 @@ object TestMessage { date = "some-date", senderUserId = UserId("user-id", "domain"), senderClientId = ClientId("client-id"), - status = Message.Status.SENT, + status = Message.Status.Sent, editStatus = Message.EditStatus.NotEdited, isSelfMessage = false ) @@ -118,11 +86,10 @@ object TestMessage { date = "some-date", senderUserId = UserId("user-id", "domain"), senderClientId = ClientId("client-id"), - status = Message.Status.SENT, + status = Message.Status.Sent, editStatus = Message.EditStatus.NotEdited, isSelfMessage = false ) - fun buildAssetMessage(assetContent: AssetContent) = Message.Regular( id = "messageID", content = MessageContent.Asset(assetContent), @@ -130,7 +97,7 @@ object TestMessage { date = "some-date", senderUserId = UserId("user-id", "domain"), senderClientId = ClientId("client-id"), - status = Message.Status.SENT, + status = Message.Status.Sent, editStatus = Message.EditStatus.NotEdited, isSelfMessage = false ) @@ -141,7 +108,7 @@ object TestMessage { conversationId = ConversationId("convo-id", "convo.domain"), date = "some-date", senderUserId = UserId("user-id", "domain"), - status = Message.Status.SENT, + status = Message.Status.Sent, expirationData = null ) @@ -151,49 +118,16 @@ object TestMessage { conversationId = ConversationId("convo-id", "convo.domain"), date = "some-date", senderUserId = UserId("user-id", "domain"), - status = Message.Status.SENT, + status = Message.Status.Sent, expirationData = null ) - val IMAGE_ASSET_MESSAGE_DATA_TEST = AssetMessageContentMetadata( - AssetContent( - 100L, - "dummy_data.tiff", - "image/tiff", - AssetContent.AssetMetadata.Image(50, 50), - AssetContent.RemoteData(ByteArray(16), ByteArray(16), "asset-id", "token", "domain.com", MessageEncryptionAlgorithm.AES_CBC), - Message.UploadStatus.NOT_UPLOADED, - Message.DownloadStatus.NOT_DOWNLOADED - ) - ) - val UI_MESSAGE_HEADER = MessageHeader( - username = UIText.DynamicString("username"), - membership = Membership.Guest, - isLegalHold = true, - messageTime = MessageTime("12.23pm"), - messageStatus = MessageStatus( - flowStatus = MessageFlowStatus.Sent, - expirationStatus = ExpirationStatus.NotExpirable - ), - messageId = "messageID", - connectionState = null, - isSenderDeleted = false, - isSenderUnavailable = false - ) - val UI_TEXT_MESSAGE = UIMessage.Regular( - userAvatarData = UserAvatarData(asset = null, availabilityStatus = UserAvailabilityStatus.NONE), - source = MessageSource.OtherUser, - header = UI_MESSAGE_HEADER, - messageContent = TextMessage(MessageBody(UIText.DynamicString("Some Text Message"))), - messageFooter = MessageFooter(UI_MESSAGE_HEADER.messageId) - ) - val MISSED_CALL_MESSAGE = Message.System( id = "messageID", content = MessageContent.MissedCall, conversationId = ConversationId("convo-id", "convo.domain"), date = "some-date", senderUserId = UserId("user-id", "domain"), - status = Message.Status.SENT, + status = Message.Status.Sent, expirationData = null ) @@ -203,10 +137,9 @@ object TestMessage { conversationId = ConversationId("convo-id", "convo.domain"), date = "some-date", senderUserId = UserId("user-id", "domain"), - status = Message.Status.SENT, + status = Message.Status.Sent, expirationData = null ) - val PREVIEW = MessagePreview( id = "messageId", conversationId = ConversationId("value", "domain"), diff --git a/app/src/test/kotlin/com/wire/android/mapper/MessageMapperTest.kt b/app/src/test/kotlin/com/wire/android/mapper/MessageMapperTest.kt index 575f7e97b54..6260951a7c6 100644 --- a/app/src/test/kotlin/com/wire/android/mapper/MessageMapperTest.kt +++ b/app/src/test/kotlin/com/wire/android/mapper/MessageMapperTest.kt @@ -94,7 +94,7 @@ class MessageMapperTest { val userId1 = UserId("user-id1", "user-domain") val userId2 = UserId("user-id2", "user-domain") val message1 = arrangement.testMessage(senderUserId = userId1, date = now) - val message2 = arrangement.testMessage(senderUserId = userId2, status = Message.Status.FAILED, date = yesterday) + val message2 = arrangement.testMessage(senderUserId = userId2, status = Message.Status.Failed, date = yesterday) val message3 = arrangement.testMessage(senderUserId = userId1, editStatus = Message.EditStatus.Edited(now), date = now) val message4 = arrangement.testMessage(senderUserId = userId1, visibility = Message.Visibility.DELETED, date = now) val message5 = arrangement.testMessage(senderUserId = userId1, date = now).failureToDecrypt(false) @@ -227,7 +227,7 @@ class MessageMapperTest { fun testMessage( senderUserId: UserId, - status: Message.Status = Message.Status.SENT, + status: Message.Status = Message.Status.Sent, visibility: Message.Visibility = Message.Visibility.VISIBLE, editStatus: Message.EditStatus = Message.EditStatus.NotEdited, date: String diff --git a/kalium b/kalium index fe7a70e2aaa..775684b17a6 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit fe7a70e2aaa57b7b00785c834aa07f2d04b0bf58 +Subproject commit 775684b17a6addab8cc727c817e4b33f279184fe