summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-03-26 12:17:12 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-05-23 10:30:24 +0000
commit57ec63b3ccb64396ffa29c441f309dd93f872106 (patch)
tree41567c92e7da926ec9ac7eda8299f1f74b04f3b0
parentae2d8f1da959aa4e1fa7bcd26704401f71087e70 (diff)
downloadmullvadvpn-57ec63b3ccb64396ffa29c441f309dd93f872106.tar.xz
mullvadvpn-57ec63b3ccb64396ffa29c441f309dd93f872106.zip
Add a `LocationConstraint` to each `RelayItem`
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/Relay.kt9
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCity.kt5
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCountry.kt4
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayItem.kt3
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayList.kt6
5 files changed, 24 insertions, 3 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/Relay.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/Relay.kt
index 131f71df9d..7e2f09e289 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/Relay.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/Relay.kt
@@ -1,8 +1,15 @@
package net.mullvad.mullvadvpn.relaylist
-data class Relay(override val name: String) : RelayItem {
+import net.mullvad.mullvadvpn.model.LocationConstraint
+
+data class Relay(
+ val countryCode: String,
+ val cityCode: String,
+ override val name: String
+) : RelayItem {
override val code = name
override val type = RelayItemType.Relay
+ override val location = LocationConstraint.Hostname(countryCode, cityCode, name)
override val hasChildren = false
override val visibleChildCount = 0
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCity.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCity.kt
index a5e1d5cce8..15c52fce43 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCity.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCity.kt
@@ -1,12 +1,17 @@
package net.mullvad.mullvadvpn.relaylist
+import net.mullvad.mullvadvpn.model.LocationConstraint
+
class RelayCity(
override val name: String,
+ val countryCode: String,
override val code: String,
override var expanded: Boolean,
val relays: List<Relay>
) : RelayItem {
override val type = RelayItemType.City
+ override val location = LocationConstraint.City(countryCode, code)
+
override val hasChildren
get() = relays.size > 1
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCountry.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCountry.kt
index 80b63875d5..fb2aacab33 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCountry.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCountry.kt
@@ -1,5 +1,7 @@
package net.mullvad.mullvadvpn.relaylist
+import net.mullvad.mullvadvpn.model.LocationConstraint
+
class RelayCountry(
override val name: String,
override val code: String,
@@ -7,6 +9,8 @@ class RelayCountry(
val cities: List<RelayCity>
) : RelayItem {
override val type = RelayItemType.Country
+ override val location = LocationConstraint.Country(code)
+
override val hasChildren
get() = getRelayCount() > 1
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayItem.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayItem.kt
index 9f325e6377..22f39cbf7e 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayItem.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayItem.kt
@@ -1,9 +1,12 @@
package net.mullvad.mullvadvpn.relaylist
+import net.mullvad.mullvadvpn.model.LocationConstraint
+
interface RelayItem {
val type: RelayItemType
val name: String
val code: String
+ val location: LocationConstraint
val hasChildren: Boolean
val visibleChildCount: Int
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayList.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayList.kt
index a70ac13eaa..964833f675 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayList.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayList.kt
@@ -6,9 +6,11 @@ class RelayList {
constructor(model: net.mullvad.mullvadvpn.model.RelayList) {
countries = model.countries.map { country ->
val cities = country.cities.map { city ->
- val relays = city.relays.map { relay -> Relay(relay.hostname) }
+ val relays = city.relays.map { relay ->
+ Relay(country.code, city.code, relay.hostname)
+ }
- RelayCity(city.name, city.code, false, relays)
+ RelayCity(city.name, country.code, city.code, false, relays)
}
RelayCountry(country.name, country.code, false, cities)