diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-08-02 11:29:37 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-08-02 22:13:23 +0000 |
| commit | 5f462da000fa9875139e2b8a9bfb9e926076605d (patch) | |
| tree | 66a179b923cf1a9b5806fdc13fe00fa41d2d67d5 | |
| parent | e8813b572c245c4042456992acdb9d94449526b3 (diff) | |
| download | mullvadvpn-5f462da000fa9875139e2b8a9bfb9e926076605d.tar.xz mullvadvpn-5f462da000fa9875139e2b8a9bfb9e926076605d.zip | |
Show relay in IP address
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> |
