From fb7811a3487c0334a3b91ed693b871803d582936 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Wed, 2 Aug 2023 15:34:31 +0200 Subject: [PATCH 1/6] add more message status icons --- .../com/wire/android/mapper/MessageMapper.kt | 13 +++--- .../conversations/MessageStatusIndicator.kt | 43 ++++++++++++++----- .../ui/home/conversations/model/UIMessage.kt | 2 +- kalium | 2 +- 4 files changed, 42 insertions(+), 18 deletions(-) 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..da267285eba 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,13 @@ 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(isMessageEdited, 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..dd5b40a13cd 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,11 @@ */ package com.wire.android.ui.home.conversations +import androidx.compose.foundation.layout.Box +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 +49,36 @@ 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.error, + contentDescription = stringResource(R.string.content_description_message_read_status), + ) + 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..124374f605d 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 @@ -159,7 +159,7 @@ sealed class MessageFlowStatus { object Delivered : MessageFlowStatus() - data class Read(val count: Int) : MessageFlowStatus() + data class Read(val count: Long) : MessageFlowStatus() } @Stable diff --git a/kalium b/kalium index 67514c7ec13..ad652616b8a 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit 67514c7ec1394fbb477c9c3fb92600838f2642a5 +Subproject commit ad652616b8ac3394a640a38822b47d5c900d2c38 From 3bf744735e8330f8a77c46d0f36a300c0c214a8c Mon Sep 17 00:00:00 2001 From: Mateusz Date: Thu, 3 Aug 2023 10:19:48 +0200 Subject: [PATCH 2/6] fix message status --- .../android/ui/home/conversations/MessageStatusIndicator.kt | 3 ++- .../wire/android/ui/home/conversations/model/UIMessage.kt | 6 +++--- kalium | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) 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 dd5b40a13cd..9991acf2254 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 @@ -73,9 +73,10 @@ fun MessageStatusIndicator(status: MessageFlowStatus, modifier: Modifier = Modif Icon( modifier = modifier, painter = painterResource(id = R.drawable.ic_message_read), - tint = MaterialTheme.wireColorScheme.error, + 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 124374f605d..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,7 +157,7 @@ sealed class MessageFlowStatus { ) } - object Delivered : MessageFlowStatus() + data object Delivered : MessageFlowStatus() data class Read(val count: Long) : MessageFlowStatus() } diff --git a/kalium b/kalium index ad652616b8a..7722de85f73 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit ad652616b8ac3394a640a38822b47d5c900d2c38 +Subproject commit 7722de85f73a8d3866c272e03a4b899cddfd5ef0 From a66ab4a2fdaf5c6391236c59534d61f0aef1eb64 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Thu, 3 Aug 2023 10:22:35 +0200 Subject: [PATCH 3/6] remove unused import --- .../wire/android/ui/home/conversations/MessageStatusIndicator.kt | 1 - 1 file changed, 1 deletion(-) 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 9991acf2254..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,7 +17,6 @@ */ package com.wire.android.ui.home.conversations -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme From 4881fabf8d31660da4ed903af5f9736b0fe8b23e Mon Sep 17 00:00:00 2001 From: Mateusz Date: Fri, 4 Aug 2023 12:04:28 +0200 Subject: [PATCH 4/6] fix detekt --- app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt | 5 ++++- kalium | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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 da267285eba..a146d4026fb 100644 --- a/app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt +++ b/app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt @@ -172,7 +172,10 @@ class MessageMapper @Inject constructor( 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(isMessageEdited, message.conversationId.domain) + Message.Status.FailedRemotely -> MessageFlowStatus.Failure.Send.Remotely( + isEdited = isMessageEdited, + backendWithFailure = message.conversationId.domain + ) Message.Status.Delivered -> MessageFlowStatus.Delivered } } diff --git a/kalium b/kalium index 7722de85f73..2f69a801ccf 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit 7722de85f73a8d3866c272e03a4b899cddfd5ef0 +Subproject commit 2f69a801ccf01b2629eaf1f82f08973ac06340d1 From 36cccf4ace67ac32a5da4398901703dd16849f4c Mon Sep 17 00:00:00 2001 From: Mateusz Date: Fri, 4 Aug 2023 14:05:07 +0200 Subject: [PATCH 5/6] add test covering mapping from details view --- .../com/wire/android/framework/TestMessage.kt | 83 ++----------------- .../wire/android/mapper/MessageMapperTest.kt | 4 +- 2 files changed, 10 insertions(+), 77 deletions(-) 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 From 08460f61d0874a082d998165b492ce616ab53000 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Mon, 7 Aug 2023 13:32:14 +0200 Subject: [PATCH 6/6] fix the failing json --- kalium | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kalium b/kalium index 2f69a801ccf..663af3fc441 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit 2f69a801ccf01b2629eaf1f82f08973ac06340d1 +Subproject commit 663af3fc441d8e9bf3deb69c191b6e4b3b468495