|
|
@ -18,7 +18,6 @@ import com.tailscale.ipn.ui.util.PeerCategorizer
|
|
|
|
import com.tailscale.ipn.ui.util.PeerSet
|
|
|
|
import com.tailscale.ipn.ui.util.PeerSet
|
|
|
|
import com.tailscale.ipn.ui.util.TimeUtil
|
|
|
|
import com.tailscale.ipn.ui.util.TimeUtil
|
|
|
|
import com.tailscale.ipn.ui.util.set
|
|
|
|
import com.tailscale.ipn.ui.util.set
|
|
|
|
import com.tailscale.ipn.App
|
|
|
|
|
|
|
|
import kotlinx.coroutines.flow.MutableStateFlow
|
|
|
|
import kotlinx.coroutines.flow.MutableStateFlow
|
|
|
|
import kotlinx.coroutines.flow.StateFlow
|
|
|
|
import kotlinx.coroutines.flow.StateFlow
|
|
|
|
import kotlinx.coroutines.flow.combine
|
|
|
|
import kotlinx.coroutines.flow.combine
|
|
|
@ -65,7 +64,8 @@ class MainViewModel : IpnViewModel() {
|
|
|
|
.collect { (currentState, prepared) ->
|
|
|
|
.collect { (currentState, prepared) ->
|
|
|
|
stateRes.set(userStringRes(currentState, previousState, prepared))
|
|
|
|
stateRes.set(userStringRes(currentState, previousState, prepared))
|
|
|
|
|
|
|
|
|
|
|
|
val isOn = when {
|
|
|
|
val isOn =
|
|
|
|
|
|
|
|
when {
|
|
|
|
currentState == State.Running || currentState == State.Starting -> true
|
|
|
|
currentState == State.Running || currentState == State.Starting -> true
|
|
|
|
previousState == State.NoState && currentState == State.Starting -> true
|
|
|
|
previousState == State.NoState && currentState == State.Starting -> true
|
|
|
|
else -> false
|
|
|
|
else -> false
|
|
|
@ -142,12 +142,12 @@ private fun userStringRes(currentState: State?, previousState: State?, vpnPrepar
|
|
|
|
previousState == State.NoState && currentState == State.Starting -> R.string.starting
|
|
|
|
previousState == State.NoState && currentState == State.Starting -> R.string.starting
|
|
|
|
currentState == State.NoState -> R.string.placeholder
|
|
|
|
currentState == State.NoState -> R.string.placeholder
|
|
|
|
currentState == State.InUseOtherUser -> R.string.placeholder
|
|
|
|
currentState == State.InUseOtherUser -> R.string.placeholder
|
|
|
|
currentState == State.NeedsLogin -> if (vpnPrepared) R.string.please_login else R.string.connect_to_vpn
|
|
|
|
currentState == State.NeedsLogin ->
|
|
|
|
|
|
|
|
if (vpnPrepared) R.string.please_login else R.string.connect_to_vpn
|
|
|
|
currentState == State.NeedsMachineAuth -> R.string.needs_machine_auth
|
|
|
|
currentState == State.NeedsMachineAuth -> R.string.needs_machine_auth
|
|
|
|
currentState == State.Stopped -> R.string.stopped
|
|
|
|
currentState == State.Stopped -> R.string.stopped
|
|
|
|
currentState == State.Starting -> R.string.starting
|
|
|
|
currentState == State.Starting -> R.string.starting
|
|
|
|
currentState == State.Running -> R.string.connected
|
|
|
|
currentState == State.Running -> R.string.connected
|
|
|
|
else -> R.string.placeholder
|
|
|
|
else -> R.string.placeholder
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resId
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|