diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/PrivacyDisclaimerScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/PrivacyDisclaimerScreen.kt index 8173359e45e3..81248e47851c 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/PrivacyDisclaimerScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/PrivacyDisclaimerScreen.kt @@ -1,5 +1,7 @@ package net.mullvad.mullvadvpn.compose.screen +import android.content.Context +import android.net.Uri import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement @@ -49,10 +51,12 @@ import net.mullvad.mullvadvpn.compose.destinations.SplashDestination import net.mullvad.mullvadvpn.compose.util.LaunchedEffectCollect import net.mullvad.mullvadvpn.compose.util.toDp import net.mullvad.mullvadvpn.constant.DAEMON_READY_TIMEOUT_MS +import net.mullvad.mullvadvpn.lib.common.util.openLink import net.mullvad.mullvadvpn.lib.theme.AppTheme import net.mullvad.mullvadvpn.lib.theme.Dimens import net.mullvad.mullvadvpn.lib.theme.color.AlphaScrollbar import net.mullvad.mullvadvpn.ui.MainActivity +import net.mullvad.mullvadvpn.util.appendHideNavOnPlayBuild import net.mullvad.mullvadvpn.viewmodel.PrivacyDisclaimerUiSideEffect import net.mullvad.mullvadvpn.viewmodel.PrivacyDisclaimerViewModel import net.mullvad.mullvadvpn.viewmodel.PrivacyDisclaimerViewState @@ -61,7 +65,13 @@ import org.koin.androidx.compose.koinViewModel @Preview @Composable private fun PreviewPrivacyDisclaimerScreen() { - AppTheme { PrivacyDisclaimerScreen(PrivacyDisclaimerViewState(false), {}, {}) } + AppTheme { + PrivacyDisclaimerScreen( + PrivacyDisclaimerViewState(isStartingService = false, isPlayBuild = false), + {}, + {} + ) + } } @Destination @@ -99,7 +109,11 @@ fun PrivacyDisclaimer( } } } - PrivacyDisclaimerScreen(state, {}, viewModel::setPrivacyDisclosureAccepted) + PrivacyDisclaimerScreen( + state, + { openPrivacyPolicy(context, state.isPlayBuild) }, + viewModel::setPrivacyDisclosureAccepted + ) } @Composable @@ -194,3 +208,13 @@ private fun ButtonPanel(isStartingService: Boolean, onAcceptClicked: () -> Unit) } } } + +private fun openPrivacyPolicy(context: Context, isPlayBuild: Boolean) { + context.openLink( + Uri.parse( + context.resources + .getString(R.string.privacy_policy_url) + .appendHideNavOnPlayBuild(isPlayBuild) + ) + ) +} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt index f36e579a52b3..afd3f7221117 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt @@ -148,7 +148,7 @@ val uiModule = module { DnsDialogViewModel(get(), get(), parameters.getOrNull(), parameters.getOrNull()) } viewModel { LoginViewModel(get(), get(), get(), get()) } - viewModel { PrivacyDisclaimerViewModel(get()) } + viewModel { PrivacyDisclaimerViewModel(get(), IS_PLAY_BUILD) } viewModel { SelectLocationViewModel(get(), get(), get()) } viewModel { SettingsViewModel(get(), get(), IS_PLAY_BUILD) } viewModel { SplashViewModel(get(), get(), get()) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/PrivacyDisclaimerViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/PrivacyDisclaimerViewModel.kt index 0e92a3967863..bfeadee54707 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/PrivacyDisclaimerViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/PrivacyDisclaimerViewModel.kt @@ -9,13 +9,17 @@ import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import net.mullvad.mullvadvpn.repository.PrivacyDisclaimerRepository -data class PrivacyDisclaimerViewState(val isStartingService: Boolean) +data class PrivacyDisclaimerViewState(val isStartingService: Boolean, val isPlayBuild: Boolean) class PrivacyDisclaimerViewModel( - private val privacyDisclaimerRepository: PrivacyDisclaimerRepository + private val privacyDisclaimerRepository: PrivacyDisclaimerRepository, + isPlayBuild: Boolean ) : ViewModel() { - private val _uiState = MutableStateFlow(PrivacyDisclaimerViewState(false)) + private val _uiState = + MutableStateFlow( + PrivacyDisclaimerViewState(isStartingService = false, isPlayBuild = isPlayBuild) + ) val uiState = _uiState private val _uiSideEffect = Channel()