diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-08-02 00:10:27 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-08-02 13:46:52 +0000 |
| commit | 5e6baa8cc2150661e99b3ae5192193e0d2c0eaa7 (patch) | |
| tree | 09c391a78c14526dfbd42c89ad6a1ff983481855 /android/src | |
| parent | 3712d4b6ba67e88575a233a7fc9df8fcca670e7b (diff) | |
| download | mullvadvpn-5e6baa8cc2150661e99b3ae5192193e0d2c0eaa7.tar.xz mullvadvpn-5e6baa8cc2150661e99b3ae5192193e0d2c0eaa7.zip | |
Handle location listener in `ConnectFragment`
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt | 8 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt | 13 |
2 files changed, 7 insertions, 14 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt index e9713fff60..6d413eef3c 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, locationInfoCache) + locationInfo = LocationInfo(view) actionButton = ConnectActionButton(view) actionButton.apply { @@ -95,6 +95,10 @@ class ConnectFragment : Fragment() { updateKeyStatusJob = updateKeyStatus(keyStatus) } + locationInfoCache.onNewLocation = { location -> + locationInfo.location = location + } + relayListListener.onRelayListChange = { relayList, selectedRelayItem -> switchLocationButton.location = selectedRelayItem } @@ -102,13 +106,13 @@ class ConnectFragment : Fragment() { override fun onPause() { keyStatusListener.onKeyStatusChange = null + locationInfoCache.onNewLocation = null relayListListener.onRelayListChange = null super.onPause() } override fun onDestroyView() { - locationInfo.onDestroy() switchLocationButton.onDestroy() connectionProxy.onUiStateChange = null diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt index 36e3a35223..74e826261d 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt @@ -3,28 +3,17 @@ package net.mullvad.mullvadvpn import android.view.View import android.widget.TextView -import net.mullvad.mullvadvpn.dataproxy.LocationInfoCache import net.mullvad.mullvadvpn.model.GeoIpLocation -class LocationInfo(val parentView: View, val locationInfoCache: LocationInfoCache) { +class LocationInfo(val parentView: View) { private val countryLabel: TextView = parentView.findViewById(R.id.country) private val cityLabel: TextView = parentView.findViewById(R.id.city) private val hostnameLabel: TextView = parentView.findViewById(R.id.hostname) - init { - locationInfoCache.onNewLocation = { newLocation -> - location = newLocation - } - } - var location: GeoIpLocation? = null set(value) { countryLabel.text = value?.country ?: "" cityLabel.text = value?.city ?: "" hostnameLabel.text = value?.hostname ?: "" } - - fun onDestroy() { - locationInfoCache.onNewLocation = null - } } |
