diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-04 17:30:45 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-22 16:36:57 +0000 |
| commit | 3fecfc0e865b43d77d027924a0fe3633e5e50d4b (patch) | |
| tree | e2648b8e8c5b870e05cad200631bcc1f69fc20a6 /android/src/main | |
| parent | 060460086bdf699b4d4822be3f03295fadc6bc4d (diff) | |
| download | mullvadvpn-3fecfc0e865b43d77d027924a0fe3633e5e50d4b.tar.xz mullvadvpn-3fecfc0e865b43d77d027924a0fe3633e5e50d4b.zip | |
Use split tunnelling status to update UI
Diffstat (limited to 'android/src/main')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/SplitTunnellingFragment.kt | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/SplitTunnellingFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/SplitTunnellingFragment.kt index a5097ac33e..dc905abdbf 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/SplitTunnellingFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/SplitTunnellingFragment.kt @@ -110,8 +110,15 @@ class SplitTunnellingFragment : ServiceDependentFragment(OnNoService.GoToLaunchS setDuration(200) } + if (configureSpinner()) { + jobTracker.newUiJob("enableAdapter") { + loadingSpinner.visibility = View.GONE + appListAdapter.enabled = true + } + } + enabledToggle = header.findViewById<CellSwitch>(R.id.enabled_toggle).apply { - if (appListAdapter.enabled) { + if (splitTunnelling.enabled) { forcefullySetState(CellSwitch.State.ON) } else { forcefullySetState(CellSwitch.State.OFF) @@ -131,29 +138,32 @@ class SplitTunnellingFragment : ServiceDependentFragment(OnNoService.GoToLaunchS } private fun enable() { - appListAdapter.apply { - if (!isListReady) { - enabled = false - showLoadingSpinner() - onListReady = { - hideLoadingSpinner() - } - } else { - enabled = true - } - } - + splitTunnelling.enabled = true + appListAdapter.enabled = configureSpinner() excludeApplications.visibility = View.VISIBLE excludeApplicationsFadeOut.reverse() - splitTunnelling.enabled = true } private fun disable() { - appListAdapter.enabled = false splitTunnelling.enabled = false + appListAdapter.enabled = false excludeApplicationsFadeOut.start() } + private fun configureSpinner(): Boolean { + if (splitTunnelling.enabled && !appListAdapter.isListReady) { + showLoadingSpinner() + + appListAdapter.onListReady = { + hideLoadingSpinner() + } + + return false + } else { + return splitTunnelling.enabled + } + } + private fun showLoadingSpinner() { loadingSpinner.visibility = View.VISIBLE loadingSpinnerFadeIn.start() |
