diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ContentBlockersInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ContentBlockersInfoDialog.kt index 145208ce165e..09e3d0fa6b55 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ContentBlockersInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ContentBlockersInfoDialog.kt @@ -2,6 +2,7 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.spec.DestinationStyle @@ -24,6 +25,6 @@ fun ContentBlockersInfoDialog(navigator: DestinationsNavigator) { stringResource(id = R.string.settings_changes_effect_warning_content_blocker) ) }, - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt index f58768d0c6ab..c692b27305c9 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator @@ -20,6 +21,6 @@ private fun PreviewCustomDnsInfoDialog() { fun CustomDnsInfoDialog(navigator: DestinationsNavigator) { InfoDialog( message = stringResource(id = R.string.settings_changes_effect_warning_content_blocker), - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceNameInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceNameInfoDialog.kt index 0e1c315959a4..258af7e44a78 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceNameInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceNameInfoDialog.kt @@ -2,6 +2,7 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.spec.DestinationStyle @@ -19,6 +20,6 @@ fun DeviceNameInfoDialog(navigator: DestinationsNavigator) { appendLine() append(stringResource(id = R.string.device_name_info_third_paragraph)) }, - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DiscardChangesDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DiscardChangesDialog.kt index 5ebb8c081101..adac4935bb31 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DiscardChangesDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DiscardChangesDialog.kt @@ -24,7 +24,7 @@ fun DiscardChangesDialog(resultBackNavigator: ResultBackNavigator) { dismissButton = { PrimaryButton( modifier = Modifier.focusRequester(FocusRequester()), - onClick = dropUnlessResumed {resultBackNavigator.navigateBack()}, + onClick = dropUnlessResumed { resultBackNavigator.navigateBack() }, text = stringResource(id = R.string.cancel) ) }, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt index 7deab3444ac0..be0a6eb38df9 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt @@ -76,7 +76,8 @@ fun DnsDialog( viewModel::onDnsInputChange, onSaveDnsClick = viewModel::onSaveDnsClick, onRemoveDnsClick = viewModel::onRemoveDnsClick, - onDismiss = dropUnlessResumed { resultNavigator.navigateBack(result = DnsDialogResult.Cancel) } + onDismiss = + dropUnlessResumed { resultNavigator.navigateBack(result = DnsDialogResult.Cancel) } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt index ebe46b6050dd..e67796d37e3d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator @@ -26,6 +27,6 @@ fun LocalNetworkSharingInfoDialog(navigator: DestinationsNavigator) { appendLine(stringResource(id = R.string.local_network_sharing_additional_info)) appendLine(textResource(id = R.string.local_network_sharing_ip_ranges)) }, - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt index 1f627be040fa..a00d75b53eaf 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator @@ -20,6 +21,6 @@ private fun PreviewMalwareInfoDialog() { fun MalwareInfoDialog(navigator: DestinationsNavigator) { InfoDialog( message = stringResource(id = R.string.malware_info), - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt index cf4db26e2e9b..e6e3edd3ac34 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator @@ -20,6 +21,6 @@ private fun PreviewObfuscationInfoDialog() { fun ObfuscationInfoDialog(navigator: DestinationsNavigator) { InfoDialog( message = stringResource(id = R.string.obfuscation_info), - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt index e7773ed0a382..47ea8badfc65 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator @@ -21,6 +22,6 @@ fun QuantumResistanceInfoDialog(navigator: DestinationsNavigator) { InfoDialog( message = stringResource(id = R.string.quantum_resistant_info_first_paragaph), additionalInfo = stringResource(id = R.string.quantum_resistant_info_second_paragaph), - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ReportProblemNoEmailDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ReportProblemNoEmailDialog.kt index d2e35f055244..b015d7c5b7e1 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ReportProblemNoEmailDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ReportProblemNoEmailDialog.kt @@ -33,7 +33,7 @@ private fun PreviewReportProblemNoEmailDialog() { @Composable fun ReportProblemNoEmailDialog(resultBackNavigator: ResultBackNavigator) { AlertDialog( - onDismissRequest = dropUnlessResumed {resultBackNavigator.navigateBack() }, + onDismissRequest = dropUnlessResumed { resultBackNavigator.navigateBack() }, icon = { Icon( painter = painterResource(id = R.drawable.icon_alert), diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ServerIpOverridesInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ServerIpOverridesInfoDialog.kt index 9b6054f1f0f8..a42e314991e8 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ServerIpOverridesInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ServerIpOverridesInfoDialog.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator @@ -27,6 +28,6 @@ fun ServerIpOverridesInfoDialog(navigator: DestinationsNavigator) { appendLine() append(stringResource(id = R.string.server_ip_overrides_info_third_paragraph)) }, - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt index 1c5c4ccef636..22a93bb4bf0b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator @@ -21,6 +22,6 @@ private fun PreviewUdpOverTcpPortInfoDialog() { fun UdpOverTcpPortInfoDialog(navigator: DestinationsNavigator) { InfoDialog( message = stringResource(id = R.string.udp_over_tcp_port_info), - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardCustomPortDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardCustomPortDialog.kt index 2e77ccd9b2b1..6640984a0f03 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardCustomPortDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardCustomPortDialog.kt @@ -16,7 +16,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview -import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.result.EmptyResultBackNavigator import com.ramcosta.composedestinations.result.ResultBackNavigator diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt index 7de2e97fbb09..6d497dd93ec4 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt @@ -4,6 +4,7 @@ import android.os.Parcelable import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator @@ -40,6 +41,6 @@ fun WireguardPortInfoDialog( id = R.string.wireguard_port_info_port_range, argument.portRanges.asString() ), - onDismiss = navigator::navigateUp + onDismiss = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/payment/VerificationPendingDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/payment/VerificationPendingDialog.kt index 7d49a133f359..81a0b25b8702 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/payment/VerificationPendingDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/payment/VerificationPendingDialog.kt @@ -7,6 +7,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.compositeOver import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.spec.DestinationStyle @@ -24,7 +25,7 @@ private fun PreviewVerificationPendingDialog() { @Destination(style = DestinationStyle.Dialog::class) @Composable fun VerificationPendingDialog(navigator: DestinationsNavigator) { - VerificationPendingDialog(onClose = navigator::navigateUp) + VerificationPendingDialog(onClose = dropUnlessResumed { navigator.navigateUp() }) } @Composable diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt index d78592775b3a..d5c921240633 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.popUpTo @@ -123,9 +124,7 @@ fun Account( AccountScreen( state = state, uiSideEffect = vm.uiSideEffect, - onRedeemVoucherClick = { - navigator.navigate(RedeemVoucherDestination) { launchSingleTop = true } - }, + onRedeemVoucherClick = dropUnlessResumed { navigator.navigate(RedeemVoucherDestination) }, onManageAccountClick = vm::onManageAccountClick, onLogoutClick = vm::onLogoutClick, navigateToLogin = { @@ -135,16 +134,14 @@ fun Account( } }, onCopyAccountNumber = vm::onCopyAccountNumber, - onBackClick = navigator::navigateUp, - navigateToDeviceInfo = { - navigator.navigate(DeviceNameInfoDialogDestination) { launchSingleTop = true } - }, + onBackClick = dropUnlessResumed { navigator.navigateUp() }, + navigateToDeviceInfo = + dropUnlessResumed { navigator.navigate(DeviceNameInfoDialogDestination) }, onPurchaseBillingProductClick = { productId -> - navigator.navigate(PaymentDestination(productId)) { launchSingleTop = true } + navigator.navigate(PaymentDestination(productId), onlyIfResumed = true) }, - navigateToVerificationPendingDialog = { - navigator.navigate(VerificationPendingDialogDestination) { launchSingleTop = true } - } + navigateToVerificationPendingDialog = + dropUnlessResumed { navigator.navigate(VerificationPendingDialogDestination) } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt index 5a01e4c94164..95d5ca6dcf27 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt @@ -47,6 +47,7 @@ import androidx.constraintlayout.compose.ConstrainedLayoutReference import androidx.constraintlayout.compose.ConstraintLayout import androidx.constraintlayout.compose.ConstraintLayoutScope import androidx.core.text.HtmlCompat +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import kotlinx.coroutines.launch @@ -74,7 +75,7 @@ private fun PreviewAutoConnectAndLockdownModeScreen() { @Destination(style = SlideInFromRightTransition::class) @Composable fun AutoConnectAndLockdownMode(navigator: DestinationsNavigator) { - AutoConnectAndLockdownModeScreen(onBackClick = navigator::navigateUp) + AutoConnectAndLockdownModeScreen(onBackClick = dropUnlessResumed { navigator.navigateUp() }) } @OptIn(ExperimentalFoundationApi::class) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt index 94b5ef3b5b85..a1debe63f6f1 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt @@ -44,6 +44,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.Lifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.popUpTo @@ -143,12 +144,12 @@ fun Connect( openAccountPage(sideEffect.token) } is ConnectViewModel.UiSideEffect.OutOfTime -> - navigator.navigate(OutOfTimeDestination, true) { + navigator.navigate(OutOfTimeDestination) { launchSingleTop = true popUpTo(NavGraphs.root) { inclusive = true } } ConnectViewModel.UiSideEffect.RevokedDevice -> - navigator.navigate(DeviceRevokedDestination, true) { + navigator.navigate(DeviceRevokedDestination) { launchSingleTop = true popUpTo(NavGraphs.root) { inclusive = true } } @@ -175,9 +176,7 @@ fun Connect( onReconnectClick = connectViewModel::onReconnectClick, onConnectClick = connectViewModel::onConnectClick, onCancelClick = connectViewModel::onCancelClick, - onSwitchLocationClick = { - navigator.navigate(SelectLocationDestination, true) { launchSingleTop = true } - }, + onSwitchLocationClick = dropUnlessResumed { navigator.navigate(SelectLocationDestination) }, onUpdateVersionClick = { val intent = Intent( @@ -192,12 +191,8 @@ fun Connect( context.startActivity(intent) }, onManageAccountClick = connectViewModel::onManageAccountClick, - onSettingsClick = { - navigator.navigate(SettingsDestination, true) { launchSingleTop = true } - }, - onAccountClick = { - navigator.navigate(AccountDestination, true) { launchSingleTop = true } - }, + onSettingsClick = dropUnlessResumed { navigator.navigate(SettingsDestination) }, + onAccountClick = dropUnlessResumed { navigator.navigate(AccountDestination) }, onDismissNewDeviceClick = connectViewModel::dismissNewDeviceNotification, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt index fc5fc62c3d9b..bbde96b99fb7 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.result.NavResult @@ -115,13 +116,14 @@ fun CustomListLocations( onSearchTermInput = customListsViewModel::onSearchTermInput, onSaveClick = customListsViewModel::save, onRelaySelectionClick = customListsViewModel::onRelaySelectionClick, - onBackClick = { - if (state.hasUnsavedChanges) { - navigator.navigate(DiscardChangesDialogDestination) { launchSingleTop = true } - } else { - backNavigator.navigateBack() + onBackClick = + dropUnlessResumed { + if (state.hasUnsavedChanges) { + navigator.navigate(DiscardChangesDialogDestination) + } else { + backNavigator.navigateBack() + } } - } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt index b039f838a2bd..7611cfcf6bc7 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt @@ -23,6 +23,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.result.NavResult @@ -92,19 +93,19 @@ fun CustomLists( CustomListsScreen( state = state, snackbarHostState = snackbarHostState, - addCustomList = { - navigator.navigate( - CreateCustomListDestination(), - ) { - launchSingleTop = true - } - }, + addCustomList = + dropUnlessResumed { + navigator.navigate( + CreateCustomListDestination(), + ) + }, openCustomList = { customList -> - navigator.navigate(EditCustomListDestination(customListId = customList.id)) { - launchSingleTop = true - } + navigator.navigate( + EditCustomListDestination(customListId = customList.id), + onlyIfResumed = true + ) }, - onBackClick = navigator::navigateUp + onBackClick = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceListScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceListScreen.kt index 64414b38c064..c6d8a06d208c 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceListScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceListScreen.kt @@ -31,6 +31,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.lifecycle.Lifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.popUpTo @@ -146,19 +147,18 @@ fun DeviceList( DeviceListScreen( state = state, snackbarHostState = snackbarHostState, - onBackClick = navigator::navigateUp, - onContinueWithLogin = { - navigator.navigate(LoginDestination(accountNumber)) { - launchSingleTop = true - popUpTo(LoginDestination) { inclusive = true } - } - }, - onSettingsClicked = { navigator.navigate(SettingsDestination) { launchSingleTop = true } }, + onBackClick = dropUnlessResumed { navigator.navigateUp() }, + onContinueWithLogin = + dropUnlessResumed { + navigator.navigate(LoginDestination(accountNumber)) { + launchSingleTop = true + popUpTo(LoginDestination) { inclusive = true } + } + }, + onSettingsClicked = dropUnlessResumed { navigator.navigate(SettingsDestination) }, onTryAgainClicked = viewModel::fetchDevices, navigateToRemoveDeviceConfirmationDialog = { - navigator.navigate(RemoveDeviceConfirmationDialogDestination(it)) { - launchSingleTop = true - } + navigator.navigate(RemoveDeviceConfirmationDialogDestination(it), onlyIfResumed = true) } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceRevokedScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceRevokedScreen.kt index f5167bad54f4..ac434243835b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceRevokedScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/DeviceRevokedScreen.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.unit.sp import androidx.constraintlayout.compose.ConstraintLayout import androidx.constraintlayout.compose.Dimension import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.popUpTo @@ -63,7 +64,7 @@ fun DeviceRevoked(navigator: DestinationsNavigator) { DeviceRevokedScreen( state = state, - onSettingsClicked = { navigator.navigate(SettingsDestination) { launchSingleTop = true } }, + onSettingsClicked = dropUnlessResumed { navigator.navigate(SettingsDestination) }, onGoToLoginClicked = viewModel::onGoToLoginClicked ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/EditCustomListScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/EditCustomListScreen.kt index 29a1fa103773..151c49dd0e8e 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/EditCustomListScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/EditCustomListScreen.kt @@ -101,24 +101,23 @@ fun EditCustomList( state = state, onDeleteList = { name -> navigator.navigate( - DeleteCustomListDestination(customListId = customListId, name = name) - ) { - launchSingleTop = true - } + DeleteCustomListDestination(customListId = customListId, name = name), + onlyIfResumed = true + ) }, onNameClicked = { id, name -> navigator.navigate( - EditCustomListNameDestination(customListId = id, initialName = name) - ) { - launchSingleTop = true - } + EditCustomListNameDestination(customListId = id, initialName = name), + onlyIfResumed = true + ) }, onLocationsClicked = { - navigator.navigate(CustomListLocationsDestination(customListId = it, newList = false)) { - launchSingleTop = true - } + navigator.navigate( + CustomListLocationsDestination(customListId = it, newList = false), + onlyIfResumed = true + ) }, - onBackClick = dropUnlessResumed { backNavigator.navigateBack()} + onBackClick = dropUnlessResumed { backNavigator.navigateBack() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreen.kt index f58b28eacaa8..4458f8b5887b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreen.kt @@ -27,6 +27,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import net.mullvad.mullvadvpn.R @@ -79,7 +80,7 @@ fun FilterScreen(navigator: DestinationsNavigator) { } FilterScreen( state = state, - onBackClick = navigator::navigateUp, + onBackClick = dropUnlessResumed { navigator.navigateUp() }, onApplyClick = viewModel::onApplyButtonClicked, onSelectedOwnership = viewModel::setSelectedOwnership, onAllProviderCheckChange = viewModel::setAllProviders, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/LoginScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/LoginScreen.kt index b004314f4fae..80c30f6400a7 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/LoginScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/LoginScreen.kt @@ -47,6 +47,7 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.popUpTo @@ -156,7 +157,7 @@ fun Login( vm::createAccount, vm::clearAccountHistory, vm::onAccountNumberChange, - { navigator.navigate(SettingsDestination) } + dropUnlessResumed { navigator.navigate(SettingsDestination) } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/NoDaemonScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/NoDaemonScreen.kt index af47b37fc258..82ae16a20804 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/NoDaemonScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/NoDaemonScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.core.app.ActivityCompat.finishAffinity +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import net.mullvad.mullvadvpn.R @@ -43,7 +44,7 @@ private fun PreviewNoDaemonScreen() { @Destination(style = DefaultTransition::class) @Composable fun NoDaemonScreen(navigator: DestinationsNavigator) { - NoDaemonScreen { navigator.navigate(SettingsDestination) } + NoDaemonScreen(dropUnlessResumed { navigator.navigate(SettingsDestination) }) } @Composable diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/OutOfTimeScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/OutOfTimeScreen.kt index d557558a6022..22ab725e7f52 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/OutOfTimeScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/OutOfTimeScreen.kt @@ -23,6 +23,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.Lifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.popUpTo @@ -151,17 +152,15 @@ fun OutOfTime( OutOfTimeScreen( state = state, onSitePaymentClick = vm::onSitePaymentClick, - onRedeemVoucherClick = { - navigator.navigate(RedeemVoucherDestination) { launchSingleTop = true } - }, - onSettingsClick = { navigator.navigate(SettingsDestination) { launchSingleTop = true } }, - onAccountClick = { navigator.navigate(AccountDestination) { launchSingleTop = true } }, + onRedeemVoucherClick = dropUnlessResumed { navigator.navigate(RedeemVoucherDestination) }, + onSettingsClick = dropUnlessResumed { navigator.navigate(SettingsDestination) }, + onAccountClick = dropUnlessResumed { navigator.navigate(AccountDestination) }, onDisconnectClick = vm::onDisconnectClick, onPurchaseBillingProductClick = { productId -> - navigator.navigate(PaymentDestination(productId)) { launchSingleTop = true } + navigator.navigate(PaymentDestination(productId), onlyIfResumed = true) }, navigateToVerificationPendingDialog = { - navigator.navigate(VerificationPendingDialogDestination) { launchSingleTop = true } + navigator.navigate(VerificationPendingDialogDestination, onlyIfResumed = true) } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ReportProblemScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ReportProblemScreen.kt index c46eb93894c1..a464a573f775 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ReportProblemScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ReportProblemScreen.kt @@ -27,6 +27,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.withStyle import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.result.NavResult @@ -120,12 +121,13 @@ fun ReportProblem( state, onSendReport = { vm.sendReport(state.email, state.description) }, onClearSendResult = vm::clearSendResult, - onNavigateToViewLogs = { - navigator.navigate(ViewLogsDestination()) { launchSingleTop = true } - }, + onNavigateToViewLogs = + dropUnlessResumed { + navigator.navigate(ViewLogsDestination()) { launchSingleTop = true } + }, onEmailChanged = vm::updateEmail, onDescriptionChanged = vm::updateDescription, - onBackClick = navigator::navigateUp, + onBackClick = dropUnlessResumed { navigator.navigateUp() }, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt index 735478aee0b9..fd7b89a48b71 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt @@ -150,10 +150,9 @@ fun SelectLocation( val snackbarHostState = remember { SnackbarHostState() } val context = LocalContext.current - val navigateBack = dropUnlessResumed { backNavigator.navigateBack(result = true)} LaunchedEffectCollect(vm.uiSideEffect) { when (it) { - SelectLocationSideEffect.CloseScreen -> navigateBack() + SelectLocationSideEffect.CloseScreen -> backNavigator.navigateBack(result = true) is SelectLocationSideEffect.LocationAddedToCustomList -> launch { snackbarHostState.showResultSnackbar( @@ -205,28 +204,37 @@ fun SelectLocation( onBackClick = dropUnlessResumed { backNavigator.navigateBack() }, onFilterClick = dropUnlessResumed { navigator.navigate(FilterScreenDestination) }, onCreateCustomList = { relayItem -> - navigator.navigate(CreateCustomListDestination(locationCode = relayItem?.id)) { + navigator.navigate( + CreateCustomListDestination(locationCode = relayItem?.id), + onlyIfResumed = true + ) { launchSingleTop = true } }, - onEditCustomLists = { navigator.navigate(CustomListsDestination()) }, + onEditCustomLists = dropUnlessResumed { navigator.navigate(CustomListsDestination()) }, removeOwnershipFilter = vm::removeOwnerFilter, removeProviderFilter = vm::removeProviderFilter, onAddLocationToList = vm::addLocationToList, onRemoveLocationFromList = vm::removeLocationFromList, onEditCustomListName = { navigator.navigate( - EditCustomListNameDestination(customListId = it.id, initialName = it.customListName) + EditCustomListNameDestination( + customListId = it.id, + initialName = it.customListName + ), + onlyIfResumed = true ) }, onEditLocationsCustomList = { navigator.navigate( - CustomListLocationsDestination(customListId = it.id, newList = false) + CustomListLocationsDestination(customListId = it.id, newList = false), + onlyIfResumed = true ) }, onDeleteCustomList = { navigator.navigate( - DeleteCustomListDestination(customListId = it.id, name = it.customListName) + DeleteCustomListDestination(customListId = it.id, name = it.customListName), + onlyIfResumed = true ) } ) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ServerIpOverridesScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ServerIpOverridesScreen.kt index 7f9542f22a8b..5a7c9be2a626 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ServerIpOverridesScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ServerIpOverridesScreen.kt @@ -40,6 +40,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.result.ResultRecipient @@ -143,17 +144,13 @@ fun ServerIpOverrides( ServerIpOverridesScreen( state, - onBackClick = navigator::navigateUp, - onInfoClick = { - navigator.navigate(ServerIpOverridesInfoDialogDestination, onlyIfResumed = true) - }, - onResetOverridesClick = { - navigator.navigate(ResetServerIpOverridesConfirmationDestination, onlyIfResumed = true) - }, - onImportByFile = { openFileLauncher.launch("application/json") }, - onImportByText = { - navigator.navigate(ImportOverridesByTextDestination, onlyIfResumed = true) - }, + onBackClick = dropUnlessResumed { navigator.navigateUp() }, + onInfoClick = + dropUnlessResumed { navigator.navigate(ServerIpOverridesInfoDialogDestination) }, + onResetOverridesClick = + dropUnlessResumed { navigator.navigate(ResetServerIpOverridesConfirmationDestination) }, + onImportByFile = dropUnlessResumed { openFileLauncher.launch("application/json") }, + onImportByText = dropUnlessResumed { navigator.navigate(ImportOverridesByTextDestination) }, snackbarHostState ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt index 611f2e29ae9a..63229ea2aa98 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import net.mullvad.mullvadvpn.R @@ -66,16 +67,12 @@ fun Settings(navigator: DestinationsNavigator) { val state by vm.uiState.collectAsStateWithLifecycle() SettingsScreen( state = state, - onVpnSettingCellClick = { - navigator.navigate(VpnSettingsDestination) { launchSingleTop = true } - }, - onSplitTunnelingCellClick = { - navigator.navigate(SplitTunnelingDestination) { launchSingleTop = true } - }, - onReportProblemCellClick = { - navigator.navigate(ReportProblemDestination) { launchSingleTop = true } - }, - onBackClick = navigator::navigateUp + onVpnSettingCellClick = dropUnlessResumed { navigator.navigate(VpnSettingsDestination) }, + onSplitTunnelingCellClick = + dropUnlessResumed { navigator.navigate(SplitTunnelingDestination) }, + onReportProblemCellClick = + dropUnlessResumed { navigator.navigate(ReportProblemDestination) }, + onBackClick = dropUnlessResumed { navigator.navigateUp() } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SplitTunnelingScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SplitTunnelingScreen.kt index a9b7873a2f5e..280cef18022a 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SplitTunnelingScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SplitTunnelingScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import net.mullvad.mullvadvpn.R @@ -98,7 +99,7 @@ fun SplitTunneling(navigator: DestinationsNavigator) { onShowSystemAppsClick = viewModel::onShowSystemAppsClick, onExcludeAppClick = viewModel::onExcludeAppClick, onIncludeAppClick = viewModel::onIncludeAppClick, - onBackClick = navigator::navigateUp, + onBackClick = dropUnlessResumed { navigator.navigateUp() }, onResolveIcon = { packageName -> packageManager.getApplicationIconBitmapOrNull(packageName) }, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt index 05eb72c14291..fbb0ea82ce5c 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt @@ -28,6 +28,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import kotlinx.coroutines.launch @@ -64,7 +65,7 @@ private fun PreviewViewLogsLoadingScreen() { fun ViewLogs(navigator: DestinationsNavigator) { val vm = koinViewModel() val state by vm.uiState.collectAsStateWithLifecycle() - ViewLogsScreen(state = state, onBackClick = navigator::navigateUp) + ViewLogsScreen(state = state, onBackClick = dropUnlessResumed { navigator.navigateUp() }) } @OptIn(ExperimentalMaterial3Api::class) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt index bc0c0443dd8a..5c3bf9bb77fe 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt @@ -31,6 +31,7 @@ import androidx.core.text.HtmlCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.result.ResultRecipient @@ -199,40 +200,30 @@ fun VpnSettings( VpnSettingsScreen( state = state, snackbarHostState = snackbarHostState, - navigateToContentBlockersInfo = { - navigator.navigate(ContentBlockersInfoDialogDestination) { launchSingleTop = true } - }, - navigateToAutoConnectScreen = { - navigator.navigate(AutoConnectAndLockdownModeDestination) { launchSingleTop = true } - }, - navigateToCustomDnsInfo = { - navigator.navigate(CustomDnsInfoDialogDestination) { launchSingleTop = true } - }, - navigateToMalwareInfo = { - navigator.navigate(MalwareInfoDialogDestination) { launchSingleTop = true } - }, - navigateToObfuscationInfo = { - navigator.navigate(ObfuscationInfoDialogDestination) { launchSingleTop = true } - }, - navigateToQuantumResistanceInfo = { - navigator.navigate(QuantumResistanceInfoDialogDestination) { launchSingleTop = true } - }, - navigateUdp2TcpInfo = { - navigator.navigate(UdpOverTcpPortInfoDialogDestination) { launchSingleTop = true } - }, + navigateToContentBlockersInfo = + dropUnlessResumed { navigator.navigate(ContentBlockersInfoDialogDestination) }, + navigateToAutoConnectScreen = + dropUnlessResumed { navigator.navigate(AutoConnectAndLockdownModeDestination) }, + navigateToCustomDnsInfo = + dropUnlessResumed { navigator.navigate(CustomDnsInfoDialogDestination) }, + navigateToMalwareInfo = + dropUnlessResumed { navigator.navigate(MalwareInfoDialogDestination) }, + navigateToObfuscationInfo = + dropUnlessResumed { navigator.navigate(ObfuscationInfoDialogDestination) }, + navigateToQuantumResistanceInfo = + dropUnlessResumed { navigator.navigate(QuantumResistanceInfoDialogDestination) }, + navigateUdp2TcpInfo = + dropUnlessResumed { navigator.navigate(UdpOverTcpPortInfoDialogDestination) }, navigateToWireguardPortInfo = { navigator.navigate( - WireguardPortInfoDialogDestination(WireguardPortInfoDialogArgument(it)) - ) { - launchSingleTop = true - } - }, - navigateToLocalNetworkSharingInfo = { - navigator.navigate(LocalNetworkSharingInfoDialogDestination) { launchSingleTop = true } - }, - navigateToServerIpOverrides = { - navigator.navigate(ServerIpOverridesDestination) { launchSingleTop = true } + WireguardPortInfoDialogDestination(WireguardPortInfoDialogArgument(it)), + onlyIfResumed = true + ) }, + navigateToLocalNetworkSharingInfo = + dropUnlessResumed { navigator.navigate(LocalNetworkSharingInfoDialogDestination) }, + navigateToServerIpOverrides = + dropUnlessResumed { navigator.navigate(ServerIpOverridesDestination) }, onToggleBlockTrackers = vm::onToggleBlockTrackers, onToggleBlockAds = vm::onToggleBlockAds, onToggleBlockMalware = vm::onToggleBlockMalware, @@ -242,10 +233,10 @@ fun VpnSettings( onToggleBlockGambling = vm::onToggleBlockGambling, onToggleBlockSocialMedia = vm::onToggleBlockSocialMedia, navigateToMtuDialog = { - navigator.navigate(MtuDialogDestination(it)) { launchSingleTop = true } + navigator.navigate(MtuDialogDestination(it), onlyIfResumed = true) }, navigateToDns = { index, address -> - navigator.navigate(DnsDialogDestination(index, address)) { launchSingleTop = true } + navigator.navigate(DnsDialogDestination(index, address), onlyIfResumed = true) }, navigateToWireguardPortDialog = { val args = @@ -253,12 +244,10 @@ fun VpnSettings( state.customWireguardPort?.toPortOrNull(), state.availablePortRanges ) - navigator.navigate(WireguardCustomPortDialogDestination(args)) { - launchSingleTop = true - } + navigator.navigate(WireguardCustomPortDialogDestination(args), onlyIfResumed = true) }, onToggleDnsClick = vm::onToggleCustomDns, - onBackClick = navigator::navigateUp, + onBackClick = dropUnlessResumed { navigator.navigateUp() }, onSelectObfuscationSetting = vm::onSelectObfuscationSetting, onSelectQuantumResistanceSetting = vm::onSelectQuantumResistanceSetting, onWireguardPortSelected = vm::onWireguardPortSelected, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/WelcomeScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/WelcomeScreen.kt index 342f11594365..71594527fd7a 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/WelcomeScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/WelcomeScreen.kt @@ -27,6 +27,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.Lifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.compose.dropUnlessResumed import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.popUpTo @@ -142,21 +143,17 @@ fun Welcome( WelcomeScreen( state = state, - onSitePaymentClick = vm::onSitePaymentClick, - onRedeemVoucherClick = { - navigator.navigate(RedeemVoucherDestination) { launchSingleTop = true } - }, - onSettingsClick = { navigator.navigate(SettingsDestination) { launchSingleTop = true } }, - onAccountClick = { navigator.navigate(AccountDestination) { launchSingleTop = true } }, - navigateToDeviceInfoDialog = { - navigator.navigate(DeviceNameInfoDialogDestination) { launchSingleTop = true } - }, + onSitePaymentClick = dropUnlessResumed { vm.onSitePaymentClick() }, + onRedeemVoucherClick = dropUnlessResumed { navigator.navigate(RedeemVoucherDestination) }, + onSettingsClick = dropUnlessResumed { navigator.navigate(SettingsDestination) }, + onAccountClick = dropUnlessResumed { navigator.navigate(AccountDestination) }, + navigateToDeviceInfoDialog = + dropUnlessResumed { navigator.navigate(DeviceNameInfoDialogDestination) }, onPurchaseBillingProductClick = { productId -> - navigator.navigate(PaymentDestination(productId)) { launchSingleTop = true } + navigator.navigate(PaymentDestination(productId), onlyIfResumed = true) }, - navigateToVerificationPendingDialog = { - navigator.navigate(VerificationPendingDialogDestination) { launchSingleTop = true } - } + navigateToVerificationPendingDialog = + dropUnlessResumed { navigator.navigate(VerificationPendingDialogDestination) } ) } diff --git a/android/gradle/verification-metadata.xml b/android/gradle/verification-metadata.xml index dee23f902770..2f16a1d3f5ca 100644 --- a/android/gradle/verification-metadata.xml +++ b/android/gradle/verification-metadata.xml @@ -1250,11 +1250,11 @@ - - - + + + - + @@ -1274,20 +1274,20 @@ - - + + - - + + - - + + - - + + @@ -1314,12 +1314,12 @@ - - - + + + - - + + @@ -1359,12 +1359,12 @@ - - - + + + - - + + @@ -1383,12 +1383,12 @@ - - - + + + - - + + @@ -1407,12 +1407,12 @@ - - - + + + - - + + @@ -1452,52 +1452,52 @@ - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - - + + - - + + - - + + @@ -1521,28 +1521,28 @@ - - - + + + - + - - - + + + - + - - - + + + - - + + @@ -1582,55 +1582,55 @@ - - + + - - + + - - + + - - - + + + - + - - - + + + - + - - - + + + - + - - + + - - + + - - - + + + - - + + @@ -1649,12 +1649,12 @@ - - - + + + - - + + @@ -1694,12 +1694,12 @@ - - - + + + - - + + @@ -2620,6 +2620,11 @@ + + + + + @@ -2662,6 +2667,11 @@ + + + + + @@ -2686,6 +2696,16 @@ + + + + + + + + + + @@ -3188,6 +3208,16 @@ + + + + + + + + + + @@ -6771,6 +6801,9 @@ + + + @@ -6779,23 +6812,46 @@ + + + + + + + + + + + + + + + + + + + + + + +