diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/RedeemVoucherDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/RedeemVoucherDialog.kt index 3753b4d2e6aa..27377570c280 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/RedeemVoucherDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/RedeemVoucherDialog.kt @@ -100,7 +100,7 @@ fun RedeemVoucherDialog( uiState: VoucherDialogUiState, onVoucherInputChange: (String) -> Unit = {}, onRedeem: (voucherCode: String) -> Unit, - onDismiss: () -> Unit + onDismiss: (isTimeAdded: Boolean) -> Unit ) { AlertDialog( title = { @@ -146,7 +146,9 @@ fun RedeemVoucherDialog( R.string.changes_dialog_dismiss_button else R.string.cancel ), - onClick = onDismiss + onClick = { + onDismiss(uiState.voucherViewModelState is VoucherDialogState.Success) + } ) } }, @@ -192,7 +194,9 @@ fun RedeemVoucherDialog( }, containerColor = MaterialTheme.colorScheme.background, titleContentColor = MaterialTheme.colorScheme.onBackground, - onDismissRequest = onDismiss + onDismissRequest = { + onDismiss(uiState.voucherViewModelState is VoucherDialogState.Success) + } ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/RedeemVoucherDialogScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/RedeemVoucherDialogScreen.kt index 1344db5b2091..1db18b01a31b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/RedeemVoucherDialogScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/RedeemVoucherDialogScreen.kt @@ -26,7 +26,7 @@ internal fun RedeemVoucherDialogScreen( uiState: VoucherDialogUiState, onVoucherInputChange: (String) -> Unit = {}, onRedeem: (voucherCode: String) -> Unit, - onDismiss: () -> Unit + onDismiss: (isTimeAdded: Boolean) -> Unit ) { RedeemVoucherDialog(uiState, onVoucherInputChange, onRedeem, onDismiss) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt index 700ffba14576..53df05c5f3fe 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt @@ -46,7 +46,8 @@ class OutOfTimeFragment : BaseFragment() { private fun openRedeemVoucherFragment() { val transaction = parentFragmentManager.beginTransaction() transaction.addToBackStack(null) - RedeemVoucherDialogFragment().show(transaction, null) + RedeemVoucherDialogFragment { wasSuccessful -> if (wasSuccessful) advanceToConnectScreen() } + .show(transaction, null) } private fun advanceToConnectScreen() { diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt index 61f24e45fcf3..2730fde5479d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt @@ -14,7 +14,7 @@ import net.mullvad.mullvadvpn.lib.theme.AppTheme import net.mullvad.mullvadvpn.viewmodel.VoucherDialogViewModel import org.koin.androidx.viewmodel.ext.android.viewModel -class RedeemVoucherDialogFragment : DialogFragment() { +class RedeemVoucherDialogFragment(val onDialogDismiss: (Boolean) -> Unit = {}) : DialogFragment() { private val vm by viewModel() private lateinit var voucherDialog: Dialog @@ -31,7 +31,10 @@ class RedeemVoucherDialogFragment : DialogFragment() { uiState = vm.uiState.collectAsState().value, onVoucherInputChange = { vm.onVoucherInputChange(it) }, onRedeem = { vm.onRedeem(it) }, - onDismiss = { onDismiss(voucherDialog) } + onDismiss = { + onDismiss(voucherDialog) + onDialogDismiss(it) + } ) } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/WelcomeFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/WelcomeFragment.kt index 403c50ccec12..d04c5de53afd 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/WelcomeFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/WelcomeFragment.kt @@ -45,7 +45,8 @@ class WelcomeFragment : BaseFragment() { private fun openRedeemVoucherFragment() { val transaction = parentFragmentManager.beginTransaction() transaction.addToBackStack(null) - RedeemVoucherDialogFragment().show(transaction, null) + RedeemVoucherDialogFragment { wasSuccessful -> if (wasSuccessful) advanceToConnectScreen() } + .show(transaction, null) } private fun advanceToConnectScreen() {