android: hide Accounts if VPN not prepared (#402)

Updates tailscale/tailscale#12148

Signed-off-by: kari-ts <kari@tailscale.com>
angott/l10n-it
kari-ts 3 weeks ago committed by GitHub
parent 9aa3a840de
commit 32e29c4efd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -44,6 +44,7 @@ fun SettingsView(settingsNav: SettingsNav, viewModel: SettingsViewModel = viewMo
val managedByOrganization = viewModel.managedByOrganization.collectAsState().value
val tailnetLockEnabled = viewModel.tailNetLockEnabled.collectAsState().value
val corpDNSEnabled = viewModel.corpDNSEnabled.collectAsState().value
val isVPNPrepared = viewModel.vpnPrepared.collectAsState().value
val showTailnetLock = MDMSettings.manageTailnetLock.flow.collectAsState().value
@ -52,10 +53,12 @@ fun SettingsView(settingsNav: SettingsNav, viewModel: SettingsViewModel = viewMo
Header(titleRes = R.string.settings_title, onBack = settingsNav.onNavigateBackHome)
}) { innerPadding ->
Column(modifier = Modifier.padding(innerPadding).verticalScroll(rememberScrollState())) {
UserView(
profile = user,
actionState = UserActionState.NAV,
onClick = settingsNav.onNavigateToUserSwitcher)
if (isVPNPrepared){
UserView(
profile = user,
actionState = UserActionState.NAV,
onClick = settingsNav.onNavigateToUserSwitcher)
}
if (isAdmin) {
Lists.ItemDivider()

@ -29,6 +29,8 @@ open class IpnViewModel : ViewModel() {
val loggedInUser: StateFlow<IpnLocal.LoginProfile?> = MutableStateFlow(null)
val loginProfiles: StateFlow<List<IpnLocal.LoginProfile>?> = MutableStateFlow(null)
private val _vpnPrepared = MutableStateFlow(false)
val vpnPrepared: StateFlow<Boolean> = _vpnPrepared
// The userId associated with the current node. ie: The logged in user.
private var selfNodeUserId: UserID? = null
@ -59,11 +61,15 @@ open class IpnViewModel : ViewModel() {
}
// VPN Control
fun setVpnPrepared(prepared: Boolean) {
_vpnPrepared.value = prepared
}
fun startVPN() {
UninitializedApp.get().startVPN()
}
fun stopVPN() {
fun stopVPN() {
UninitializedApp.get().stopVPN()
}

@ -33,9 +33,7 @@ class MainViewModel : IpnViewModel() {
private val _vpnToggleState = MutableStateFlow(false)
val vpnToggleState: StateFlow<Boolean> = _vpnToggleState
// Whether or not the VPN has been prepared
private val _vpnPrepared = MutableStateFlow(false)
val vpnPrepared: StateFlow<Boolean> = _vpnPrepared
// Permission to prepare VPN
private var vpnPermissionLauncher: ActivityResultLauncher<Intent>? = null
// The list of peers
@ -131,10 +129,6 @@ class MainViewModel : IpnViewModel() {
fun setVpnPermissionLauncher(launcher: ActivityResultLauncher<Intent>) {
vpnPermissionLauncher = launcher
}
fun setVpnPrepared(prepared: Boolean) {
_vpnPrepared.value = prepared
}
}
private fun userStringRes(currentState: State?, previousState: State?, vpnPrepared: Boolean): Int {

Loading…
Cancel
Save