Skip to content

Commit

Permalink
Merge branch 'develop' into handle_dialong_with_team_applock
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine committed Nov 9, 2023
2 parents 06400fd + 98659c9 commit 54002ef
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 2 deletions.
5 changes: 5 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 @@ -355,6 +355,11 @@ class WireActivity : AppCompatActivity() {
viewModel::dismissNewClientsDialog

Check warning on line 355 in app/src/main/kotlin/com/wire/android/ui/WireActivity.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/WireActivity.kt#L350-L355

Added lines #L350 - L355 were not covered by tests
)
}
if (showCallEndedBecauseOfConversationDegraded) {
GuestCallWasEndedBecauseOfVerificationDegradedDialog(
featureFlagNotificationViewModel::dismissCallEndedBecauseOfConversationDegraded
)
}
}
}

Expand Down
14 changes: 14 additions & 0 deletions app/src/main/kotlin/com/wire/android/ui/WireActivityDialogs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,20 @@ fun AccountLoggedOutDialog(blockUserUI: CurrentSessionErrorState?, navigateAway:
}
}

@Composable
fun GuestCallWasEndedBecauseOfVerificationDegradedDialog(onDismiss: () -> Unit) {
WireDialog(
title = stringResource(id = R.string.call_ended_because_of_verification_title),
text = stringResource(id = R.string.call_ended_because_of_verification_message),
onDismiss = onDismiss,
optionButton1Properties = WireDialogButtonProperties(
onClick = onDismiss,
text = stringResource(id = R.string.label_ok),
type = WireDialogButtonType.Primary,
)
)
}

@Composable
private fun accountLoggedOutDialog(reason: CurrentSessionErrorState, navigateAway: () -> Unit) {
appLogger.e("AccountLongedOutDialog: $reason")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ data class FeatureFlagState(
val enforcedTimeoutDuration: SelfDeletionDuration = SelfDeletionDuration.None,
val areSelfDeletedMessagesEnabled: Boolean = true,
val e2EIRequired: E2EIRequired? = null,
val e2EISnoozeInfo: E2EISnooze? = null
val e2EISnoozeInfo: E2EISnooze? = null,
val showCallEndedBecauseOfConversationDegraded: Boolean = false
) {
enum class SharingRestrictedState {
NONE, NO_USER, RESTRICTED_IN_TEAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class FeatureFlagNotificationViewModel @Inject constructor(
setGuestRoomLinkFeatureFlag(userId)
setE2EIRequiredState(userId)
setTeamAppLockFeatureFlag(userId)
observeCallEndedBecauseOfConversationDegraded(userId)
}
}
}
Expand Down Expand Up @@ -192,6 +193,12 @@ class FeatureFlagNotificationViewModel @Inject constructor(
}
}

private fun observeCallEndedBecauseOfConversationDegraded(userId: UserId) = viewModelScope.launch {
coreLogic.getSessionScope(userId).calls.observeEndCallDialog().collect {
featureFlagState = featureFlagState.copy(showCallEndedBecauseOfConversationDegraded = true)
}
}

fun dismissSelfDeletingMessagesDialog() {
featureFlagState = featureFlagState.copy(shouldShowSelfDeletingMessagesDialog = false)
viewModelScope.launch {
Expand Down Expand Up @@ -260,4 +267,8 @@ class FeatureFlagNotificationViewModel @Inject constructor(
fun dismissSnoozeE2EIdRequiredDialog() {
featureFlagState = featureFlagState.copy(e2EISnoozeInfo = null)
}

fun dismissCallEndedBecauseOfConversationDegraded() {
featureFlagState = featureFlagState.copy(showCallEndedBecauseOfConversationDegraded = false)
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1281,4 +1281,7 @@
<string name="e2ei_certificate_details_copy_to_clipboard">Copy to Clipboard</string>
<string name="e2ei_certificate_details_download">Download</string>
<string name="e2ei_certificate_details_certificate_copied_to_clipboard">Certificate copied to clipboard</string>

<string name="call_ended_because_of_verification_title">Conversation no longer verified</string>
<string name="call_ended_because_of_verification_message">The call was disconnected because at least one participant is no longer a verified contact.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ class FeatureFlagNotificationViewModelTest {
assertEquals(null, viewModel.featureFlagState.e2EISnoozeInfo)
}

@Test
fun givenOngoingCallEnded_thenShowDialog() = runTest {
val (_, viewModel) = Arrangement()
.withEndCallDialog()
.arrange()

viewModel.initialSync()
advanceUntilIdle()

assertEquals(true, viewModel.featureFlagState.showCallEndedBecauseOfConversationDegraded)
}

private inner class Arrangement {
init {
MockKAnnotations.init(this, relaxUnitFun = true)
Expand Down Expand Up @@ -236,6 +248,7 @@ class FeatureFlagNotificationViewModelTest {
coEvery { coreLogic.getSessionScope(any()).observeFileSharingStatus.invoke() } returns flowOf()
coEvery { coreLogic.getSessionScope(any()).observeGuestRoomLinkFeatureFlag.invoke() } returns flowOf()
coEvery { coreLogic.getSessionScope(any()).observeE2EIRequired.invoke() } returns flowOf()
coEvery { coreLogic.getSessionScope(any()).calls.observeEndCallDialog() } returns flowOf()
}

fun withCurrentSessions(result: CurrentSessionResult) = apply {
Expand All @@ -258,6 +271,10 @@ class FeatureFlagNotificationViewModelTest {
coEvery { coreLogic.getSessionScope(any()).observeE2EIRequired() } returns flowOf(result)
}

fun withEndCallDialog() = apply {
coEvery { coreLogic.getSessionScope(any()).calls.observeEndCallDialog() } returns flowOf(Unit)
}

fun arrange() = this to viewModel
}
}

0 comments on commit 54002ef

Please sign in to comment.