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: End call on conversation degraded (WPB-4487) #2399

Merged
merged 10 commits into from
Nov 9, 2023
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 @@ -314,6 +314,11 @@ class WireActivity : AppCompatActivity() {
dismissDialog = featureFlagNotificationViewModel::dismissSnoozeE2EIdRequiredDialog
)
}
if (showCallEndedBecauseOfConversationDegraded) {
GuestCallWasEndedBecauseOfVerificationDegradedDialog(
featureFlagNotificationViewModel::dismissCallEndedBecauseOfConversationDegraded
)
}
}
UpdateAppDialog(viewModel.globalAppState.updateAppDialog, ::updateTheApp)
JoinConversationDialog(
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
}
}