Skip to content

Commit

Permalink
feat: legal hold indication on user profiles [WPB-4780] (#2658)
Browse files Browse the repository at this point in the history
  • Loading branch information
saleniuk authored Feb 6, 2024
1 parent 9caf09c commit fe78d52
Show file tree
Hide file tree
Showing 25 changed files with 609 additions and 105 deletions.
15 changes: 15 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,19 @@ class UseCaseModule {
fun provideObserveIsAppLockEditableUseCase(
@KaliumCoreLogic coreLogic: CoreLogic
): ObserveIsAppLockEditableUseCase = coreLogic.getGlobalScope().observeIsAppLockEditableUseCase

@ViewModelScoped
@Provides
fun provideObserveLegalHoldRequestUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).observeLegalHoldRequest

@ViewModelScoped
@Provides
fun provideObserveLegalHoldForSelfUserUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).observeLegalHoldForSelfUser

@ViewModelScoped
@Provides
fun provideObserveLegalHoldForUserUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).observeLegalHoldStateForUser
}
3 changes: 3 additions & 0 deletions app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class WireActivity : AppCompatActivity() {
appLogger.i("$TAG persistent connection status")
viewModel.observePersistentConnectionStatus()

appLogger.i("$TAG legal hold requested status")
legalHoldRequestedViewModel.observeLegalHoldRequest()

appLogger.i("$TAG start destination")
val startDestination = when (viewModel.initialAppState) {
InitialAppState.NOT_MIGRATED -> MigrationScreenDestination
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.legalhold.banner

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import com.wire.android.ui.common.LegalHoldIndicator
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.dimensions

@Composable
fun LegalHoldBaseBanner(
onClick: () -> Unit = {},
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(dimensions().spacing8x),
modifier = modifier
.clip(RoundedCornerShape(dimensions().spacing12x))
.background(colorsScheme().surface)
.border(
width = dimensions().spacing1x,
shape = RoundedCornerShape(dimensions().spacing12x),
color = colorsScheme().error
)
.clickable(onClick = onClick)
.heightIn(min = dimensions().legalHoldBannerMinHeight)
.padding(
horizontal = dimensions().spacing12x,
vertical = dimensions().spacing4x
)
) {
LegalHoldIndicator()
content()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.legalhold.banner

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextDecoration
import com.wire.android.R
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.typography
import com.wire.android.ui.theme.WireTheme
import com.wire.android.util.ui.PreviewMultipleThemes

@Composable
fun LegalHoldPendingBanner(
onClick: () -> Unit = {},
modifier: Modifier = Modifier,
) {
LegalHoldBaseBanner(onClick = onClick, modifier = modifier) {
Row {
Text(
text = stringResource(id = R.string.legal_hold_is_pending_label),
style = typography().label01,
color = colorsScheme().onSurface,
)
Text(
text = stringResource(id = R.string.legal_hold_accept),
style = typography().label02,
textDecoration = TextDecoration.Underline,
color = colorsScheme().onSurface,
modifier = Modifier.padding(start = dimensions().spacing2x),
)
}
}
}

@Composable
@PreviewMultipleThemes
fun PreviewLegalHoldPendingBanner() {
WireTheme {
LegalHoldPendingBanner()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,13 @@
*/
package com.wire.android.ui.legalhold.banner

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import com.wire.android.R
import com.wire.android.ui.common.LegalHoldIndicator
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.typography
import com.wire.android.ui.theme.WireTheme
import com.wire.android.util.ui.PreviewMultipleThemes
Expand All @@ -47,25 +34,7 @@ fun LegalHoldSubjectBanner(
onClick: () -> Unit = {},
modifier: Modifier = Modifier,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(dimensions().spacing8x),
modifier = modifier
.clip(RoundedCornerShape(dimensions().spacing12x))
.background(colorsScheme().surface)
.border(
width = dimensions().spacing1x,
shape = RoundedCornerShape(dimensions().spacing12x),
color = colorsScheme().error
)
.clickable(onClick = onClick)
.heightIn(min = 26.dp)
.padding(
horizontal = dimensions().spacing12x,
vertical = dimensions().spacing4x
)
) {
LegalHoldIndicator()
LegalHoldBaseBanner(onClick = onClick, modifier = modifier) {
val resources = LocalContext.current.resources
Text(
text = resources.stringWithStyledArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class LegalHoldRequestedViewModel @Inject constructor(
}
}

init {
fun observeLegalHoldRequest() {
viewModelScope.launch {
legalHoldRequestDataStateFlow.collectLatest { legalHoldRequestData ->
state = when (legalHoldRequestData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import com.wire.android.util.ui.PreviewMultipleThemes

@Composable
fun LegalHoldSubjectBaseDialog(
name: String,
title: String,
customInfo: String? = null,
withDefaultInfo: Boolean,
cancelText: String,
Expand All @@ -45,7 +45,7 @@ fun LegalHoldSubjectBaseDialog(
if (withDefaultInfo) stringResource(id = R.string.legal_hold_subject_dialog_description) else null
).joinToString("\n\n")
WireDialog(
title = stringResource(id = R.string.legal_hold_subject_dialog_title, name),
title = title,
text = text,
onDismiss = dialogDismissed,
buttonsHorizontalAlignment = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun LegalHoldSubjectConnectionDialog(
connectClicked: () -> Unit,
) {
LegalHoldSubjectBaseDialog(
name = userName,
title = stringResource(id = R.string.legal_hold_subject_dialog_title, userName),
withDefaultInfo = true,
cancelText = stringResource(id = R.string.label_cancel),
dialogDismissed = dialogDismissed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun LegalHoldSubjectConversationDialog(
dialogDismissed: () -> Unit,
) {
LegalHoldSubjectBaseDialog(
name = conversationName,
title = stringResource(id = R.string.legal_hold_subject_dialog_title, conversationName),
customInfo = stringResource(id = R.string.legal_hold_subject_dialog_description_group),
withDefaultInfo = true,
cancelText = stringResource(id = R.string.label_close),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun LegalHoldSubjectMessageDialog(
sendAnywayClicked: () -> Unit,
) {
LegalHoldSubjectBaseDialog(
name = conversationName,
title = stringResource(id = R.string.legal_hold_subject_dialog_title, conversationName),
customInfo = stringResource(id = R.string.legal_hold_subject_dialog_description_message),
withDefaultInfo = false,
cancelText = stringResource(id = R.string.label_cancel),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ fun LegalHoldSubjectProfileDialog(
dialogDismissed: () -> Unit,
) {
LegalHoldSubjectBaseDialog(
name = userName,
title = stringResource(id = R.string.legal_hold_subject_dialog_title, userName),
withDefaultInfo = true,
cancelText = stringResource(id = R.string.label_close),
dialogDismissed = dialogDismissed)
}
@Composable
fun LegalHoldSubjectProfileSelfDialog(dialogDismissed: () -> Unit) {
LegalHoldSubjectBaseDialog(
title = stringResource(id = R.string.legal_hold_subject_self_dialog_title),
withDefaultInfo = true,
cancelText = stringResource(id = R.string.label_close),
dialogDismissed = dialogDismissed)
Expand All @@ -42,3 +50,10 @@ fun PreviewLegalHoldSubjectProfileDialog() {
LegalHoldSubjectProfileDialog("username", {})
}
}
@Composable
@PreviewMultipleThemes
fun PreviewLegalHoldSubjectProfileSelfDialog() {
WireTheme {
LegalHoldSubjectProfileSelfDialog {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ data class WireDimensions(
// Conversation options
val conversationOptionsItemMinHeight: Dp,
// Import media
val importedMediaAssetSize: Dp
val importedMediaAssetSize: Dp,
// legal hold banner
val legalHoldBannerMinHeight: Dp,
)

private val DefaultPhonePortraitWireDimensions: WireDimensions = WireDimensions(
Expand Down Expand Up @@ -334,7 +336,8 @@ private val DefaultPhonePortraitWireDimensions: WireDimensions = WireDimensions(
ongoingCallLabelHeight = 28.dp,
audioMessageHeight = 48.dp,
importedMediaAssetSize = 120.dp,
typingIndicatorHeight = 24.dp
typingIndicatorHeight = 24.dp,
legalHoldBannerMinHeight = 26.dp,
)

private val DefaultPhoneLandscapeWireDimensions: WireDimensions = DefaultPhonePortraitWireDimensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ import com.wire.android.ui.common.UserProfileAvatar
import com.wire.android.ui.common.banner.SecurityClassificationBannerForUser
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.progress.WireCircularProgressIndicator
import com.wire.android.ui.common.spacers.VerticalSpace
import com.wire.android.ui.home.conversations.details.SearchAndMediaRow
import com.wire.android.ui.home.conversationslist.model.Membership
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireTypography
Expand Down Expand Up @@ -91,9 +89,6 @@ fun UserProfileInfo(
delayToShowPlaceholderIfNoAsset: Duration = 200.milliseconds,
isProteusVerified: Boolean = false,
isMLSVerified: Boolean = false,
onSearchConversationMessagesClick: () -> Unit = {},
onConversationMediaClick: () -> Unit = {},
shouldShowSearchButton: Boolean = false
) {
Column(
horizontalAlignment = CenterHorizontally,
Expand Down Expand Up @@ -233,14 +228,6 @@ fun UserProfileInfo(
modifier = Modifier.padding(top = dimensions().spacing8x)
)
}

if (shouldShowSearchButton) {
VerticalSpace.x24()
SearchAndMediaRow(
onSearchConversationMessagesClick = onSearchConversationMessagesClick,
onConversationMediaClick = onConversationMediaClick
)
}
}
}

Expand Down
Loading

0 comments on commit fe78d52

Please sign in to comment.