summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt2
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt42
-rw-r--r--android/src/main/res/values/strings.xml3
3 files changed, 42 insertions, 5 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt
index c90a557163..d80d385970 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt
@@ -64,7 +64,7 @@ class ConnectFragment : Fragment() {
headerBar = HeaderBar(view, context!!)
notificationBanner = NotificationBanner(view, context!!, versionInfoCache)
status = ConnectionStatus(view, context!!)
- locationInfo = LocationInfo(view)
+ locationInfo = LocationInfo(view, context!!)
actionButton = ConnectActionButton(view)
actionButton.apply {
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt
index b890c7b4a2..ed47c38a2b 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt
@@ -1,17 +1,22 @@
package net.mullvad.mullvadvpn
+import android.content.Context
import android.view.View
import android.widget.TextView
+import net.mullvad.mullvadvpn.model.Endpoint
import net.mullvad.mullvadvpn.model.GeoIpLocation
+import net.mullvad.mullvadvpn.model.TransportProtocol
import net.mullvad.mullvadvpn.model.TunnelState
-class LocationInfo(val parentView: View) {
+class LocationInfo(val parentView: View, val context: Context) {
private val country: TextView = parentView.findViewById(R.id.country)
private val city: TextView = parentView.findViewById(R.id.city)
private val hostname: TextView = parentView.findViewById(R.id.hostname)
private val protocol: TextView = parentView.findViewById(R.id.tunnel_protocol)
+ private val inAddress: TextView = parentView.findViewById(R.id.in_address)
+ private var endpoint: Endpoint? = null
private var isTunnelInfoVisible = false
var location: GeoIpLocation? = null
@@ -26,9 +31,18 @@ class LocationInfo(val parentView: View) {
field = value
when (value) {
- is TunnelState.Connecting -> isTunnelInfoVisible = true
- is TunnelState.Connected -> isTunnelInfoVisible = true
- else -> isTunnelInfoVisible = false
+ is TunnelState.Connecting -> {
+ endpoint = value.endpoint?.endpoint
+ isTunnelInfoVisible = true
+ }
+ is TunnelState.Connected -> {
+ endpoint = value.endpoint.endpoint
+ isTunnelInfoVisible = true
+ }
+ else -> {
+ endpoint = null
+ isTunnelInfoVisible = false
+ }
}
updateTunnelInfo()
@@ -44,9 +58,29 @@ class LocationInfo(val parentView: View) {
private fun hideTunnelInfo() {
protocol.text = ""
+ inAddress.text = ""
}
private fun showTunnelInfo() {
protocol.setText(R.string.wireguard)
+ showInAddress(endpoint)
+ }
+
+ private fun showInAddress(endpoint: Endpoint?) {
+ if (endpoint != null) {
+ val transportProtocol = when (endpoint.protocol) {
+ is TransportProtocol.Tcp -> context.getString(R.string.tcp)
+ is TransportProtocol.Udp -> context.getString(R.string.udp)
+ }
+
+ inAddress.text = context.getString(
+ R.string.in_address,
+ endpoint.address.address.hostAddress,
+ endpoint.address.port,
+ transportProtocol
+ )
+ } else {
+ inAddress.text = ""
+ }
}
}
diff --git a/android/src/main/res/values/strings.xml b/android/src/main/res/values/strings.xml
index 318f4e6c46..80f86bf565 100644
--- a/android/src/main/res/values/strings.xml
+++ b/android/src/main/res/values/strings.xml
@@ -61,6 +61,9 @@
<string name="disconnect">Disconnect</string>
<string name="switch_location">Switch location</string>
<string name="wireguard">WireGuard</string>
+ <string name="tcp">TCP</string>
+ <string name="udp">UDP</string>
+ <string name="in_address">In %1$s:%2$d %3$s</string>
<string name="blocking_internet">Blocking internet</string>
<string name="auth_failed">Account authentication failed.</string>