summaryrefslogtreecommitdiffhomepage
path: root/android/src/main
diff options
context:
space:
mode:
authorEmīls Piņķis <emils@mullvad.net>2019-09-07 01:38:22 +0100
committerEmīls Piņķis <emils@mullvad.net>2019-09-07 01:38:22 +0100
commit76be396b390fba33ed3c410c88c963be4849deae (patch)
tree019802bba0a830e50c49bc846e5f118cbcbd651b /android/src/main
parentd939ef55c0e21e97b3d9f39dcd54e96a879b0aed (diff)
parent73c301b45273c8fe7ea9361e217c898834ebacac (diff)
downloadmullvadvpn-76be396b390fba33ed3c410c88c963be4849deae.tar.xz
mullvadvpn-76be396b390fba33ed3c410c88c963be4849deae.zip
Merge branch 'android-show-wg-key-error'
Diffstat (limited to 'android/src/main')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt41
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt3
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt13
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt15
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/model/BlockReason.kt9
-rw-r--r--android/src/main/res/values/strings.xml6
6 files changed, 38 insertions, 49 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt
index aaa8032542..b4d05bdefa 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt
@@ -10,40 +10,6 @@ import net.mullvad.mullvadvpn.model.TunnelState
class ConnectActionButton(val parentView: View) {
private val button: Button = parentView.findViewById(R.id.action_button)
- private var enabled = true
- set(value) {
- if (field != value) {
- field = value
-
- button.setEnabled(value)
- button.setAlpha(if (value) 1.0F else 0.5F)
- }
- }
-
- private var canConnect = true
- set(value) {
- field = value
- updateEnabled()
- }
-
- private var showingConnect = true
- set(value) {
- field = value
- updateEnabled()
- }
-
- var keyState: KeygenEvent? = null
- set(value) {
- when (value) {
- null -> canConnect = true
- is KeygenEvent.NewKey -> canConnect = true
- is KeygenEvent.TooManyKeys -> canConnect = false
- is KeygenEvent.GenerationFailure -> canConnect = false
- }
-
- field = value
- }
-
var tunnelState: TunnelState = TunnelState.Disconnected()
set(value) {
when (value) {
@@ -84,22 +50,15 @@ class ConnectActionButton(val parentView: View) {
private fun disconnected() {
button.setBackgroundResource(R.drawable.green_button_background)
button.setText(R.string.connect)
- showingConnect = true
}
private fun connecting() {
button.setBackgroundResource(R.drawable.transparent_red_button_background)
button.setText(R.string.cancel)
- showingConnect = false
}
private fun connected() {
button.setBackgroundResource(R.drawable.transparent_red_button_background)
button.setText(R.string.disconnect)
- showingConnect = false
- }
-
- private fun updateEnabled() {
- enabled = !showingConnect || canConnect
}
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt
index 7e74c53066..af666f99e4 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt
@@ -135,7 +135,7 @@ class ConnectFragment : Fragment() {
}
tunnelStateListener?.let { listener ->
- connectionProxy.awaitThen {
+ connectionProxy.awaitThen {
onUiStateChange.unsubscribe(listener)
}
}
@@ -174,7 +174,6 @@ class ConnectFragment : Fragment() {
private fun updateKeyStatus(keyStatus: KeygenEvent?) = GlobalScope.launch(Dispatchers.Main) {
notificationBanner.keyState = keyStatus
- actionButton.keyState = keyStatus
}
private fun openSwitchLocationScreen() {
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt
index aa0aea2afe..acc11784fb 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt
@@ -10,6 +10,7 @@ import android.view.View
import net.mullvad.mullvadvpn.dataproxy.AppVersionInfoCache
import net.mullvad.mullvadvpn.model.ActionAfterDisconnect
import net.mullvad.mullvadvpn.model.BlockReason
+import net.mullvad.mullvadvpn.model.ParameterGenerationError
import net.mullvad.mullvadvpn.model.KeygenEvent
import net.mullvad.mullvadvpn.model.TunnelState
@@ -56,7 +57,7 @@ class NotificationBanner(
private fun update() {
externalLink = null
- updateBasedOnKeyState() || updateBasedOnTunnelState() || updateBasedOnVersionInfo()
+ updateBasedOnTunnelState() || updateBasedOnKeyState() || updateBasedOnVersionInfo()
}
private fun updateBasedOnKeyState(): Boolean {
@@ -132,11 +133,17 @@ class NotificationBanner(
is BlockReason.SetFirewallPolicyError -> R.string.set_firewall_policy_error
is BlockReason.SetDnsError -> R.string.set_dns_error
is BlockReason.StartTunnelError -> R.string.start_tunnel_error
- is BlockReason.NoMatchingRelay -> R.string.no_matching_relay
is BlockReason.IsOffline -> R.string.is_offline
is BlockReason.TapAdapterProblem -> R.string.tap_adapter_problem
+ is BlockReason.ParameterGeneration -> {
+ when (reason.error) {
+ is ParameterGenerationError.NoMatchingRelay -> R.string.no_matching_relay
+ is ParameterGenerationError.NoMatchingBridgeRelay -> R.string.no_matching_bridge_relay
+ is ParameterGenerationError.NoWireguardKey -> R.string.no_wireguard_key
+ is ParameterGenerationError.CustomTunnelHostResultionError -> R.string.custom_tunnel_host_resolution_error
+ }
+ }
}
-
showError(R.string.blocking_internet, messageText)
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt
index 1b5e1a3cfe..e9564d38b4 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt
@@ -89,8 +89,6 @@ class WireguardKeyFragment : Fragment() {
private fun updateViews() {
clearErrorMessage()
- actionButton.setClickable(true)
-
when (val keyState = keyStatusListener.keyStatus) {
null -> {
publicKey.visibility = View.INVISIBLE
@@ -167,6 +165,11 @@ class WireguardKeyFragment : Fragment() {
}
private fun drawNoConnectionState() {
+ actionButton.setClickable(true)
+ visitWebsiteView.setClickable(true)
+ actionButton.setAlpha(1f)
+ visitWebsiteView.setAlpha(1f)
+
when (tunnelState) {
is TunnelState.Connecting, is TunnelState.Disconnecting -> {
statusMessage.setText(R.string.wireguard_key_connectivity)
@@ -174,6 +177,14 @@ class WireguardKeyFragment : Fragment() {
actionButton.visibility = View.GONE
actionSpinner.visibility = View.VISIBLE
}
+ is TunnelState.Blocked -> {
+ statusMessage.setText(R.string.wireguard_key_blocked_state_message)
+ statusMessage.visibility = View.VISIBLE
+ actionButton.setClickable(false)
+ actionButton.setAlpha(0.5f)
+ visitWebsiteView.setClickable(false)
+ visitWebsiteView.setAlpha(0.5f)
+ }
}
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/model/BlockReason.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/model/BlockReason.kt
index 769a97b6fa..ae4d392fc2 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/model/BlockReason.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/model/BlockReason.kt
@@ -6,7 +6,14 @@ sealed class BlockReason {
class SetFirewallPolicyError : BlockReason()
class SetDnsError : BlockReason()
class StartTunnelError : BlockReason()
- class NoMatchingRelay : BlockReason()
+ class ParameterGeneration(val error: ParameterGenerationError) : BlockReason()
class IsOffline : BlockReason()
class TapAdapterProblem : BlockReason()
}
+
+sealed class ParameterGenerationError {
+ class NoMatchingRelay : ParameterGenerationError()
+ class NoMatchingBridgeRelay : ParameterGenerationError()
+ class NoWireguardKey : ParameterGenerationError()
+ class CustomTunnelHostResultionError : ParameterGenerationError()
+}
diff --git a/android/src/main/res/values/strings.xml b/android/src/main/res/values/strings.xml
index 37d31e758f..f03cef4181 100644
--- a/android/src/main/res/values/strings.xml
+++ b/android/src/main/res/values/strings.xml
@@ -85,6 +85,9 @@
<string name="set_dns_error">Failed to set system DNS server</string>
<string name="start_tunnel_error">Failed to start tunnel connection</string>
<string name="no_matching_relay">No relay server matches the current settings</string>
+ <string name="no_matching_bridge_relay">No bridge relay server matches the current settings</string>
+ <string name="no_wireguard_key">No WireGuard key set</string>
+ <string name="custom_tunnel_host_resolution_error">Failed to resolve the hostname of custom server</string>
<string name="is_offline">This device is offline, no tunnels can be established</string>
<string name="tap_adapter_problem">TAP adapter error</string>
<string name="wireguard_error">WireGuard error</string>
@@ -113,6 +116,9 @@
<string name="wireguard_key_connectivity">
Connectivity required to manage your key.
</string>
+ <string name="wireguard_key_blocked_state_message">
+ Can\'t manage keys in blocked state
+ </string>
<string name="wireguard_key_valid">
Key is valid
</string>