Skip to content

Commit

Permalink
feat: legal hold indication on conversation header and on conversatio…
Browse files Browse the repository at this point in the history
…n list [WPB-4568] (#2562)
  • Loading branch information
saleniuk authored Jan 3, 2024
1 parent 5533ae4 commit c38ab0f
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package com.wire.android.ui.common

import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
Expand All @@ -31,7 +32,7 @@ import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.util.ui.PreviewMultipleThemes

@Composable
fun LegalHoldIndicator(modifier: Modifier = Modifier) {
fun LegalHoldIndicator(modifier: Modifier = Modifier.size(dimensions().spacing12x)) {
Icon(
painter = painterResource(id = R.drawable.ic_legal_hold),
contentDescription = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ import com.wire.android.model.UserAvatarData
import com.wire.android.ui.calling.controlbuttons.JoinButton
import com.wire.android.ui.calling.controlbuttons.StartCallButton
import com.wire.android.ui.common.ConversationVerificationIcons
import com.wire.android.ui.common.LegalHoldIndicator
import com.wire.android.ui.common.UserProfileAvatar
import com.wire.android.ui.common.button.WireSecondaryIconButton
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.conversationColor
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.spacers.HorizontalSpace
import com.wire.android.ui.common.topappbar.NavigationIconButton
import com.wire.android.ui.common.topappbar.NavigationIconType
import com.wire.android.ui.home.conversations.info.ConversationAvatar
Expand Down Expand Up @@ -140,6 +142,10 @@ private fun ConversationScreenTopAppBarContent(
conversationInfoViewState.mlsVerificationStatus,
conversationInfoViewState.proteusVerificationStatus
)
if (conversationInfoViewState.legalHoldStatus == Conversation.LegalHoldStatus.ENABLED) {
HorizontalSpace.x4()
LegalHoldIndicator()
}
if (isDropDownEnabled && isInteractionEnabled) {
Icon(
painter = painterResource(id = R.drawable.ic_dropdown_icon),
Expand Down Expand Up @@ -386,3 +392,29 @@ fun PreviewConversationScreenTopAppBarShortTitleWithVerified() {
isSearchEnabled = false
)
}

@Preview("Topbar with a short conversation title and verified")
@Composable
fun PreviewConversationScreenTopAppBarShortTitleWithLegalHold() {
val conversationId = QualifiedID("", "")
ConversationScreenTopAppBarContent(
ConversationInfoViewState(
conversationId = ConversationId("value", "domain"),
conversationName = UIText.DynamicString("Short title"),
conversationDetailsData = ConversationDetailsData.Group(conversationId),
conversationAvatar = ConversationAvatar.Group(conversationId),
protocolInfo = Conversation.ProtocolInfo.Proteus,
legalHoldStatus = Conversation.LegalHoldStatus.ENABLED,
),
onBackButtonClick = {},
onDropDownClick = {},
isDropDownEnabled = true,
onSearchButtonClick = {},
onPhoneButtonClick = {},
hasOngoingCall = false,
onJoinCallButtonClick = {},
onPermanentPermissionDecline = {},
isInteractionEnabled = true,
isSearchEnabled = false
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class ConversationInfoViewModel @Inject constructor(
conversationType = conversationDetails.conversation.type,
protocolInfo = conversationDetails.conversation.protocol,
mlsVerificationStatus = conversationDetails.conversation.mlsVerificationStatus,
proteusVerificationStatus = conversationDetails.conversation.proteusVerificationStatus
proteusVerificationStatus = conversationDetails.conversation.proteusVerificationStatus,
legalHoldStatus = conversationDetails.conversation.legalHoldStatus,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ data class ConversationInfoViewState(
val protocolInfo: Conversation.ProtocolInfo? = null,
val mlsVerificationStatus: Conversation.VerificationStatus? = null,
val proteusVerificationStatus: Conversation.VerificationStatus? = null,
val legalHoldStatus: Conversation.LegalHoldStatus = Conversation.LegalHoldStatus.UNKNOWN,
)

sealed class ConversationDetailsData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import com.wire.kalium.logic.data.conversation.ConversationDetails.Connection
import com.wire.kalium.logic.data.conversation.ConversationDetails.Group
import com.wire.kalium.logic.data.conversation.ConversationDetails.OneOne
import com.wire.kalium.logic.data.conversation.ConversationDetails.Self
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.conversation.Conversation.LegalHoldStatus
import com.wire.kalium.logic.data.conversation.MutedConversationStatus
import com.wire.kalium.logic.data.conversation.UnreadEventCount
import com.wire.kalium.logic.data.id.ConversationId
Expand Down Expand Up @@ -547,7 +547,7 @@ private fun ConversationDetails.toConversationItem(
groupName = conversation.name.orEmpty(),
conversationId = conversation.id,
mutedStatus = conversation.mutedStatus,
isLegalHold = legalHoldStatus.showLegalHoldIndicator(),
isLegalHold = conversation.legalHoldStatus.showLegalHoldIndicator(),
lastMessageContent = lastMessage.toUIPreview(unreadEventCount),
badgeEventType = parseConversationEventType(
conversation.mutedStatus,
Expand Down Expand Up @@ -578,7 +578,7 @@ private fun ConversationDetails.toConversationItem(
),
conversationId = conversation.id,
mutedStatus = conversation.mutedStatus,
isLegalHold = legalHoldStatus.showLegalHoldIndicator(),
isLegalHold = conversation.legalHoldStatus.showLegalHoldIndicator(),
lastMessageContent = lastMessage.toUIPreview(unreadEventCount),
badgeEventType = parsePrivateConversationEventType(
otherUser.connectionStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class ImportMediaAuthenticatedViewModel @Inject constructor(
groupName = conversation.name.orEmpty(),
conversationId = conversation.id,
mutedStatus = conversation.mutedStatus,
isLegalHold = legalHoldStatus.showLegalHoldIndicator(),
isLegalHold = conversation.legalHoldStatus.showLegalHoldIndicator(),
lastMessageContent = lastMessage.toUIPreview(unreadEventCount),
badgeEventType = parseConversationEventType(
conversation.mutedStatus,
Expand Down Expand Up @@ -217,7 +217,7 @@ class ImportMediaAuthenticatedViewModel @Inject constructor(
),
conversationId = conversation.id,
mutedStatus = conversation.mutedStatus,
isLegalHold = legalHoldStatus.showLegalHoldIndicator(),
isLegalHold = conversation.legalHoldStatus.showLegalHoldIndicator(),
lastMessageContent = lastMessage.toUIPreview(unreadEventCount),
badgeEventType = parsePrivateConversationEventType(
otherUser.connectionStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package com.wire.android.framework
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.Conversation.ProtocolInfo
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.user.type.UserType

object TestConversationDetails {
Expand All @@ -42,20 +41,17 @@ object TestConversationDetails {
val CONVERSATION_ONE_ONE = ConversationDetails.OneOne(
TestConversation.ONE_ON_ONE,
TestUser.OTHER_USER,
LegalHoldStatus.DISABLED,
UserType.EXTERNAL,
lastMessage = null,
unreadEventCount = emptyMap()
)

val GROUP = ConversationDetails.Group(
TestConversation.ONE_ON_ONE,
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserCreator = true,
isSelfUserMember = true,
unreadEventCount = emptyMap(),
selfRole = Conversation.Member.Role.Member
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.message.SelfDeletionTimer
import com.wire.kalium.logic.data.sync.SyncState
import com.wire.kalium.logic.data.user.ConnectionState
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.user.OtherUser
import com.wire.kalium.logic.data.user.UserAssetId
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
Expand Down Expand Up @@ -368,7 +367,6 @@ internal fun withMockConversationDetailsOneOnOne(
every { isUnavailableUser } returns unavailable
every { deleted } returns false
},
legalHoldStatus = LegalHoldStatus.DISABLED,
userType = UserType.INTERNAL,
lastMessage = null,
unreadEventCount = emptyMap()
Expand All @@ -380,7 +378,6 @@ internal fun mockConversationDetailsGroup(
) = ConversationDetails.Group(
conversation = TestConversation.GROUP()
.copy(name = conversationName, id = mockedConversationId),
legalHoldStatus = mockk(),
hasOngoingCall = false,
lastMessage = null,
isSelfUserCreator = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import com.wire.android.ui.home.conversationslist.model.DialogState
import com.wire.android.ui.navArgs
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.conversation.MutedConversationStatus
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.TeamId
import com.wire.kalium.logic.data.message.SelfDeletionTimer
import com.wire.kalium.logic.data.team.Team
import com.wire.kalium.logic.feature.conversation.ArchiveStatusUpdateResult
import com.wire.kalium.logic.feature.conversation.ClearConversationContentUseCase
Expand All @@ -52,7 +52,6 @@ import com.wire.kalium.logic.feature.conversation.UpdateConversationMutedStatusU
import com.wire.kalium.logic.feature.conversation.UpdateConversationReceiptModeUseCase
import com.wire.kalium.logic.feature.publicuser.RefreshUsersWithoutMetadataUseCase
import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveSelfDeletionTimerSettingsForConversationUseCase
import com.wire.kalium.logic.data.message.SelfDeletionTimer
import com.wire.kalium.logic.feature.team.DeleteTeamConversationUseCase
import com.wire.kalium.logic.feature.team.GetSelfTeamUseCase
import com.wire.kalium.logic.feature.user.GetSelfUserUseCase
Expand Down Expand Up @@ -596,7 +595,6 @@ class GroupConversationDetailsViewModelTest {
proteusVerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
legalHoldStatus = Conversation.LegalHoldStatus.DISABLED
),
legalHoldStatus = LegalHoldStatus.DISABLED,
hasOngoingCall = false,
lastMessage = null,
isSelfUserCreator = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.wire.android.framework.TestUser
import com.wire.android.ui.home.conversations.ConversationNavArgs
import com.wire.android.ui.navArgs
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.user.type.UserType
import com.wire.kalium.logic.feature.conversation.ObserveConversationDetailsUseCase
Expand All @@ -51,7 +50,6 @@ class ConversationMigrationViewModelTest {
ConversationDetails.OneOne(
conversation = TestConversation.ONE_ON_ONE,
otherUser = TestUser.OTHER_USER.copy(activeOneOnOneConversationId = conversationId),
legalHoldStatus = LegalHoldStatus.ENABLED,
userType = UserType.NONE,
unreadEventCount = mapOf(),
lastMessage = null
Expand All @@ -70,7 +68,6 @@ class ConversationMigrationViewModelTest {
ConversationDetails.OneOne(
conversation = TestConversation.ONE_ON_ONE,
otherUser = TestUser.OTHER_USER.copy(activeOneOnOneConversationId = expectedActiveOneOnOneId),
legalHoldStatus = LegalHoldStatus.ENABLED,
userType = UserType.NONE,
unreadEventCount = mapOf(),
lastMessage = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ package com.wire.android.ui.home.gallery
import androidx.lifecycle.SavedStateHandle
import app.cash.turbine.test
import com.wire.android.config.CoroutineTestExtension
import com.wire.android.config.NavigationTestExtension
import com.wire.android.config.TestDispatcherProvider
import com.wire.android.framework.FakeKaliumFileSystem
import com.wire.android.config.NavigationTestExtension
import com.wire.android.ui.home.conversations.MediaGallerySnackbarMessages
import com.wire.android.ui.home.conversations.delete.DeleteMessageDialogActiveState
import com.wire.android.ui.home.conversations.delete.DeleteMessageDialogsState
Expand All @@ -36,7 +36,6 @@ import com.wire.kalium.logic.CoreFailure
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.conversation.ConversationDetails.OneOne
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.conversation.MutedConversationStatus.AllAllowed
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.user.ConnectionState
Expand Down Expand Up @@ -321,7 +320,6 @@ class MediaGalleryViewModelTest {
defederated = false,
isProteusVerified = false
),
legalHoldStatus = LegalHoldStatus.DISABLED,
userType = UserType.INTERNAL,
lastMessage = null,
unreadEventCount = emptyMap()
Expand Down

0 comments on commit c38ab0f

Please sign in to comment.