diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt index 39a61238f664..d0d8da8b5725 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt @@ -51,7 +51,7 @@ fun MtuDialog(mtuInitial: Int?, navigator: DestinationsNavigator) { } MtuDialog( mtuInitial = mtuInitial, - onSaveMtu = { mtu -> viewModel.onSaveClick(mtu) }, + onSaveMtu = viewModel::onSaveClick, onResetMtu = viewModel::onRestoreClick, onDismiss = navigator::navigateUp ) 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 8d48a3ecbd94..315fa35270ca 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 @@ -102,8 +102,8 @@ fun RedeemVoucher(resultBackNavigator: ResultBackNavigator) { val vm = koinViewModel() RedeemVoucherDialog( uiState = vm.uiState.collectAsState().value, - onVoucherInputChange = { vm.onVoucherInputChange(it) }, - onRedeem = { vm.onRedeem(it) }, + onVoucherInputChange = vm::onVoucherInputChange, + onRedeem = vm::onRedeem, onDismiss = { resultBackNavigator.navigateBack(result = it) } ) } 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 5ef960742b04..f90724d0cea7 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 @@ -61,8 +61,12 @@ import org.koin.androidx.compose.koinViewModel private fun PreviewOutOfTimeScreenDisconnected() { AppTheme { OutOfTimeScreen( - showSitePayment = true, - uiState = OutOfTimeUiState(tunnelState = TunnelState.Disconnected, "Heroic Frog"), + uiState = + OutOfTimeUiState( + tunnelState = TunnelState.Disconnected, + "Heroic Frog", + showSitePayment = true + ), ) } } @@ -72,9 +76,12 @@ private fun PreviewOutOfTimeScreenDisconnected() { private fun PreviewOutOfTimeScreenConnecting() { AppTheme { OutOfTimeScreen( - showSitePayment = true, uiState = - OutOfTimeUiState(tunnelState = TunnelState.Connecting(null, null), "Strong Rabbit"), + OutOfTimeUiState( + tunnelState = TunnelState.Connecting(null, null), + "Strong Rabbit", + showSitePayment = true + ), ) } } @@ -84,14 +91,14 @@ private fun PreviewOutOfTimeScreenConnecting() { private fun PreviewOutOfTimeScreenError() { AppTheme { OutOfTimeScreen( - showSitePayment = true, uiState = OutOfTimeUiState( tunnelState = TunnelState.Error( ErrorState(cause = ErrorStateCause.IsOffline, isBlocking = true) ), - deviceName = "Stable Horse" + deviceName = "Stable Horse", + showSitePayment = true ), ) } @@ -142,7 +149,6 @@ fun OutOfTime( } OutOfTimeScreen( - showSitePayment = IS_PLAY_BUILD.not(), uiState = state, onSitePaymentClick = vm::onSitePaymentClick, onRedeemVoucherClick = { @@ -162,7 +168,6 @@ fun OutOfTime( @Composable fun OutOfTimeScreen( - showSitePayment: Boolean, uiState: OutOfTimeUiState, onDisconnectClick: () -> Unit = {}, onSitePaymentClick: () -> Unit = {}, @@ -222,7 +227,7 @@ fun OutOfTimeScreen( text = buildString { append(stringResource(R.string.account_credit_has_expired)) - if (showSitePayment) { + if (uiState.showSitePayment) { append(" ") append(stringResource(R.string.add_time_to_account)) } @@ -266,7 +271,7 @@ fun OutOfTimeScreen( .align(Alignment.CenterHorizontally) ) } - if (showSitePayment) { + if (uiState.showSitePayment) { SitePaymentButton( onClick = onSitePaymentClick, isEnabled = uiState.tunnelState.enableSitePaymentButton(), diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/OutOfTimeUiState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/OutOfTimeUiState.kt index ba73fb337f01..60a9e4589bfe 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/OutOfTimeUiState.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/OutOfTimeUiState.kt @@ -5,5 +5,6 @@ import net.mullvad.mullvadvpn.model.TunnelState data class OutOfTimeUiState( val tunnelState: TunnelState = TunnelState.Disconnected, val deviceName: String = "", + val showSitePayment: Boolean = true, val billingPaymentState: PaymentState? = null, ) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt index 4ed8ece0f052..d5580f603a29 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt @@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import net.mullvad.mullvadvpn.compose.state.OutOfTimeUiState import net.mullvad.mullvadvpn.constant.ACCOUNT_EXPIRY_POLL_INTERVAL +import net.mullvad.mullvadvpn.constant.IS_PLAY_BUILD import net.mullvad.mullvadvpn.model.TunnelState import net.mullvad.mullvadvpn.repository.AccountRepository import net.mullvad.mullvadvpn.repository.DeviceRepository @@ -58,6 +59,7 @@ class OutOfTimeViewModel( OutOfTimeUiState( tunnelState = tunnelState, deviceName = deviceState.deviceName() ?: "", + showSitePayment = IS_PLAY_BUILD.not(), billingPaymentState = paymentAvailability?.toPaymentState(), ) }