From 0cf64862e1d12d28892b2562334cb5284faf7b5c Mon Sep 17 00:00:00 2001 From: boris Date: Mon, 24 Jul 2023 16:59:50 +0300 Subject: [PATCH] feat: Inform user about degraded conversation verification status (WPD-573) (#1989) --- .../mapper/SystemMessageContentMapper.kt | 6 ++++ .../home/conversations/SystemMessageItem.kt | 3 ++ .../ui/home/conversations/model/UIMessage.kt | 11 +++++-- .../drawable/ic_conversation_degraded_mls.xml | 10 +++++++ .../ic_conversation_degraded_proteus.xml | 30 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + kalium | 2 +- 7 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/ic_conversation_degraded_mls.xml create mode 100644 app/src/main/res/drawable/ic_conversation_degraded_proteus.xml diff --git a/app/src/main/kotlin/com/wire/android/mapper/SystemMessageContentMapper.kt b/app/src/main/kotlin/com/wire/android/mapper/SystemMessageContentMapper.kt index d86127f0034..fe909196e7e 100644 --- a/app/src/main/kotlin/com/wire/android/mapper/SystemMessageContentMapper.kt +++ b/app/src/main/kotlin/com/wire/android/mapper/SystemMessageContentMapper.kt @@ -27,6 +27,7 @@ import com.wire.android.ui.home.conversations.selfdeletion.SelfDeletionMapper.to import com.wire.android.util.formatFullDateShortTime import com.wire.android.util.orDefault import com.wire.android.util.ui.UIText +import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.message.Message import com.wire.kalium.logic.data.message.MessageContent import com.wire.kalium.logic.data.message.MessageContent.MemberChange @@ -61,6 +62,8 @@ class SystemMessageContentMapper @Inject constructor( is MessageContent.ConversationMessageTimerChanged -> mapConversationTimerChanged(message.senderUserId, content, members) is MessageContent.ConversationCreated -> mapConversationCreated(message.senderUserId, message.date, members) is MessageContent.MLSWrongEpochWarning -> mapMLSWrongEpochWarning() + is MessageContent.ConversationDegradedMLS -> mapConversationDegraded(Conversation.Protocol.MLS) + is MessageContent.ConversationDegradedProteus -> mapConversationDegraded(Conversation.Protocol.PROTEUS) } private fun mapConversationCreated(senderUserId: UserId, date: String, userList: List): UIMessageContent.SystemMessage { @@ -235,6 +238,9 @@ class SystemMessageContentMapper @Inject constructor( private fun mapConversationHistoryLost(): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.HistoryLost() private fun mapMLSWrongEpochWarning(): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.MLSWrongEpochWarning() + private fun mapConversationDegraded(protocol: Conversation.Protocol): UIMessageContent.SystemMessage = + UIMessageContent.SystemMessage.ConversationDegraded(protocol) + fun mapMemberName(user: User?, type: SelfNameType = SelfNameType.NameOrDeleted): UIText = when (user) { is OtherUser -> user.name?.let { UIText.DynamicString(it) } ?: UIText.StringResource(messageResourceProvider.memberNameDeleted) is SelfUser -> when (type) { diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/SystemMessageItem.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/SystemMessageItem.kt index ce5aa4edf11..75522786d5f 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/SystemMessageItem.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/SystemMessageItem.kt @@ -215,6 +215,7 @@ private fun getColorFilter(message: SystemMessage): ColorFilter? { return when (message) { is SystemMessage.MissedCall.OtherCalled -> null is SystemMessage.MissedCall.YouCalled -> null + is SystemMessage.ConversationDegraded -> null is SystemMessage.Knock -> ColorFilter.tint(colorsScheme().primary) is SystemMessage.MemberFailedToAdd -> ColorFilter.tint(colorsScheme().error) is SystemMessage.MemberAdded, @@ -387,6 +388,7 @@ private val SystemMessage.expandable is SystemMessage.MLSWrongEpochWarning -> false is SystemMessage.ConversationStartedWithMembers -> this.memberNames.size > EXPANDABLE_THRESHOLD is SystemMessage.MemberFailedToAdd -> this.usersCount > SINGLE_EXPANDABLE_THRESHOLD + is SystemMessage.ConversationDegraded -> false } private fun List.toUserNamesListString(res: Resources): String = when { @@ -444,6 +446,7 @@ fun SystemMessage.annotatedString( is SystemMessage.Knock -> arrayOf(author.asString(res)) is SystemMessage.HistoryLost -> arrayOf() is SystemMessage.MLSWrongEpochWarning -> arrayOf() + is SystemMessage.ConversationDegraded -> arrayOf() is SystemMessage.ConversationMessageTimerActivated -> arrayOf( author.asString(res), selfDeletionDuration.longLabel.asString(res) 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 7f1fb105b35..68de7c965d1 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 @@ -31,6 +31,7 @@ import com.wire.android.ui.home.messagecomposer.SelfDeletionDuration import com.wire.android.util.ui.UIText import com.wire.android.util.uiMessageDateTime import com.wire.kalium.logic.data.conversation.ClientId +import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.message.Message import com.wire.kalium.logic.data.message.MessageContent import com.wire.kalium.logic.data.user.AssetId @@ -65,8 +66,8 @@ sealed interface UIMessage { override val isPending: Boolean = header.messageStatus.flowStatus == MessageFlowStatus.Sending val isMyMessage = source == MessageSource.Self val isAssetMessage = messageContent is UIMessageContent.AssetMessage - || messageContent is UIMessageContent.ImageMessage - || messageContent is UIMessageContent.AudioAssetMessage + || messageContent is UIMessageContent.ImageMessage + || messageContent is UIMessageContent.AudioAssetMessage val isTextContentWithoutQuote = messageContent is UIMessageContent.TextMessage && messageContent.messageBody.quotedMessage == null } @@ -402,6 +403,12 @@ sealed class UIMessageContent { ) { val usersCount = memberNames.values.flatten().size } + + data class ConversationDegraded(val protocol: Conversation.Protocol) : SystemMessage( + if (protocol == Conversation.Protocol.MLS) R.drawable.ic_conversation_degraded_mls + else R.drawable.ic_conversation_degraded_proteus, + R.string.label_system_message_conversation_degraded + ) } } diff --git a/app/src/main/res/drawable/ic_conversation_degraded_mls.xml b/app/src/main/res/drawable/ic_conversation_degraded_mls.xml new file mode 100644 index 00000000000..f25ff071c0a --- /dev/null +++ b/app/src/main/res/drawable/ic_conversation_degraded_mls.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_conversation_degraded_proteus.xml b/app/src/main/res/drawable/ic_conversation_degraded_proteus.xml new file mode 100644 index 00000000000..c47a6684af1 --- /dev/null +++ b/app/src/main/res/drawable/ic_conversation_degraded_proteus.xml @@ -0,0 +1,30 @@ + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 032981e0e4c..db1b6424abe 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -577,6 +577,7 @@ With %1$s %1$s **participants** could not be added to the group. %1$s could not be added to the group as the backend of %2$s could not be reached. + This conversation is no longer verified, as some user uses at least one device without a valid end-to-end identity certificate. You added 1 person to the conversation diff --git a/kalium b/kalium index 8572b17509e..143a07a6c27 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit 8572b17509e429ae845f82316973c1d13459c8ea +Subproject commit 143a07a6c275d678a4e075297499b36703b42ac6