summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-04-02 15:09:21 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-04-27 16:21:51 +0000
commit8465274743fab5a6bbfc001c968d618220c4e9f4 (patch)
treed548f1c6e8ad83ca23ff451aeb63475fa94665a3
parent193744db3f49d6d85953132194c14cef5026043b (diff)
downloadmullvadvpn-8465274743fab5a6bbfc001c968d618220c4e9f4.tar.xz
mullvadvpn-8465274743fab5a6bbfc001c968d618220c4e9f4.zip
Create `keyStatus` property
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt17
1 files changed, 13 insertions, 4 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt
index 4f67bd8e1d..53fadccf63 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt
@@ -54,6 +54,14 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre
updateButtons()
}
}
+
+ private var keyStatus: KeygenEvent? = null
+ set(value) {
+ if (field != value) {
+ field = value
+ }
+ }
+
private var hasConnectivity = true
set(value) {
if (field != value) {
@@ -166,6 +174,7 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre
}
keyStatusListener.onKeyStatusChange = { newKeyStatus ->
+ keyStatus = newKeyStatus
updateViewsJob?.cancel()
updateViewsJob = updateViewJob()
}
@@ -192,7 +201,7 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre
private fun updateViews() {
clearErrorMessage()
- when (val keyState = keyStatusListener.keyStatus) {
+ when (val keyState = keyStatus) {
null -> {
publicKey.information = null
}
@@ -226,7 +235,7 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre
private fun updateButtons() {
uiJobTracker.newJob("updateButtons", GlobalScope.launch(Dispatchers.Main) {
val isIdle = actionState == ActionState.Idle
- val hasKey = keyStatusListener.keyStatus is KeygenEvent.NewKey
+ val hasKey = keyStatus is KeygenEvent.NewKey
generateKeyButton.setEnabled(isIdle && hasConnectivity)
verifyKeyButton.setEnabled(isIdle && hasConnectivity)
@@ -256,7 +265,7 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre
}
private fun setGenerateButton() {
- if (keyStatusListener.keyStatus is KeygenEvent.NewKey) {
+ if (keyStatus is KeygenEvent.NewKey) {
generateKeyButton.setText(R.string.wireguard_replace_key)
} else {
generateKeyButton.setText(R.string.wireguard_generate_key)
@@ -314,7 +323,7 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre
statusMessage.visibility = View.VISIBLE
actionState = ActionState.Idle
- when (val state = keyStatusListener.keyStatus) {
+ when (val state = keyStatus) {
is KeygenEvent.NewKey -> {
if (state.verified == null) {
Toast.makeText(parentActivity,