summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-04-04 19:52:13 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-04-27 16:21:52 +0000
commit018240b4d538739836525f1a84122632a55d8cb0 (patch)
treea0fc16a34d7f6cbd4ef4a8ac08af97408050b412 /android/src
parent13f53f0f0370891c22e15dbb5e83d75976cb7998 (diff)
downloadmullvadvpn-018240b4d538739836525f1a84122632a55d8cb0.tar.xz
mullvadvpn-018240b4d538739836525f1a84122632a55d8cb0.zip
Show generation error messages
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt24
1 files changed, 15 insertions, 9 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 8ea1f94b7b..c96f2d8ffb 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt
@@ -15,6 +15,7 @@ import net.mullvad.mullvadvpn.model.TunnelState
import net.mullvad.mullvadvpn.ui.widget.Button
import net.mullvad.mullvadvpn.ui.widget.CopyableInformationView
import net.mullvad.mullvadvpn.ui.widget.InformationView
+import net.mullvad.mullvadvpn.ui.widget.InformationView.WhenMissing
import net.mullvad.mullvadvpn.ui.widget.UrlButton
import net.mullvad.mullvadvpn.util.JobTracker
import net.mullvad.mullvadvpn.util.TimeAgoFormatter
@@ -193,10 +194,17 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre
val publicKeyAge =
DateTime.parse(key.dateCreated, RFC3339_FORMAT).withZone(DateTimeZone.UTC)
+ publicKey.error = null
publicKey.information = publicKeyString.substring(0, 20) + "..."
keyAge.information = timeAgoFormatter.format(publicKeyAge)
}
+ is KeygenEvent.TooManyKeys, is KeygenEvent.GenerationFailure -> {
+ publicKey.error = resources.getString(failureMessage(keyState.failure()!!))
+ publicKey.information = null
+ keyAge.information = null
+ }
null -> {
+ publicKey.error = null
publicKey.information = null
keyAge.information = null
}
@@ -227,8 +235,10 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre
private fun updateKeyStatus(verificationWasDone: Boolean, keyStatus: KeygenEvent?) {
if (keyStatus is KeygenEvent.NewKey) {
- if (keyStatus.replacementFailure != null) {
- showKeygenFailure(keyStatus.replacementFailure)
+ val replacementFailure = keyStatus.replacementFailure
+
+ if (replacementFailure != null) {
+ setStatusMessage(failureMessage(replacementFailure), R.color.red)
} else {
updateKeyIsValid(verificationWasDone, keyStatus.verified)
}
@@ -283,14 +293,10 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre
statusMessage.visibility = View.VISIBLE
}
- private fun showKeygenFailure(failure: KeygenFailure?) {
+ private fun failureMessage(failure: KeygenFailure): Int {
when (failure) {
- is KeygenFailure.TooManyKeys -> {
- setStatusMessage(R.string.too_many_keys, R.color.red)
- }
- is KeygenFailure.GenerationFailure -> {
- setStatusMessage(R.string.failed_to_generate_key, R.color.red)
- }
+ is KeygenFailure.TooManyKeys -> return R.string.too_many_keys
+ is KeygenFailure.GenerationFailure -> return R.string.failed_to_generate_key
}
}