Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more message status icons #2045

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,16 @@
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

Check warning on line 177 in app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt#L176-L177

Added lines #L176 - L177 were not covered by tests
)
Message.Status.Delivered -> MessageFlowStatus.Delivered

Check warning on line 179 in app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/mapper/MessageMapper.kt#L179

Added line #L179 was not covered by tests
trOnk12 marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@

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(
Expand Down Expand Up @@ -157,9 +157,9 @@
)
}

object Delivered : MessageFlowStatus()
data object Delivered : MessageFlowStatus()

Check warning on line 160 in app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt#L160

Added line #L160 was not covered by tests

data class Read(val count: Int) : MessageFlowStatus()
data class Read(val count: Long) : MessageFlowStatus()

Check warning on line 162 in app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt#L162

Added line #L162 was not covered by tests
}

@Stable
Expand Down
83 changes: 8 additions & 75 deletions app/src/test/kotlin/com/wire/android/framework/TestMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,35 +28,17 @@ 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"),
conversationId = ConversationId("convo-id", "convo.domain"),
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
)
Expand Down Expand Up @@ -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
)
Expand All @@ -118,19 +86,18 @@ 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),
conversationId = ConversationId("convo-id", "convo.domain"),
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
)
Expand All @@ -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
)

Expand All @@ -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
)

Expand All @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion kalium
Submodule kalium updated 103 files
Loading