Skip to content

Commit

Permalink
Fix privacy policy link not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Mar 14, 2024
1 parent c4f84fc commit 079de9a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -99,7 +109,11 @@ fun PrivacyDisclaimer(
}
}
}
PrivacyDisclaimerScreen(state, {}, viewModel::setPrivacyDisclosureAccepted)
PrivacyDisclaimerScreen(
state,
{ openPrivacyPolicy(context, state.isPlayBuild) },
viewModel::setPrivacyDisclosureAccepted
)
}

@Composable
Expand Down Expand Up @@ -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)
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PrivacyDisclaimerUiSideEffect>()
Expand Down

0 comments on commit 079de9a

Please sign in to comment.