Skip to content

Commit 3475646

Browse files
committed
Merge branch 'select-location-recents-missing-extra-information-droid-2451'
2 parents ce7401b + 91f593d commit 3475646

File tree

17 files changed

+196
-67
lines changed

17 files changed

+196
-67
lines changed

android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/data/DummyRelayItems.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ private val DUMMY_RELAY_1 =
2525
daita = false,
2626
quic = null,
2727
lwo = false,
28+
cityName = "Relay City 1",
29+
countryName = "RCo1",
2830
)
2931
private val DUMMY_RELAY_2 =
3032
RelayItem.Location.Relay(
@@ -39,6 +41,8 @@ private val DUMMY_RELAY_2 =
3941
daita = false,
4042
quic = null,
4143
lwo = false,
44+
cityName = "Relay City 2",
45+
countryName = "RCo2",
4246
)
4347
private val DUMMY_RELAY_3 =
4448
RelayItem.Location.Relay(
@@ -53,6 +57,8 @@ private val DUMMY_RELAY_3 =
5357
daita = true,
5458
quic = null,
5559
lwo = true,
60+
cityName = "Relay City 3",
61+
countryName = "RCo3",
5662
)
5763
private val DUMMY_RELAY_4 =
5864
RelayItem.Location.Relay(
@@ -67,6 +73,8 @@ private val DUMMY_RELAY_4 =
6773
daita = false,
6874
quic = Quic(inAddresses = listOf()),
6975
lwo = true,
76+
cityName = "Relay City 4",
77+
countryName = "RCo4",
7078
)
7179
private val DUMMY_RELAY_5 =
7280
RelayItem.Location.Relay(
@@ -81,6 +89,8 @@ private val DUMMY_RELAY_5 =
8189
daita = false,
8290
quic = Quic(inAddresses = listOf()),
8391
lwo = true,
92+
cityName = "Relay City 5",
93+
countryName = "RCo4",
8494
)
8595
private val DUMMY_RELAY_6 =
8696
RelayItem.Location.Relay(
@@ -95,6 +105,8 @@ private val DUMMY_RELAY_6 =
95105
daita = true,
96106
quic = Quic(inAddresses = listOf()),
97107
lwo = true,
108+
cityName = "Relay City 5",
109+
countryName = "RCo4",
98110
)
99111
private val DUMMY_RELAY_7 =
100112
RelayItem.Location.Relay(
@@ -109,6 +121,8 @@ private val DUMMY_RELAY_7 =
109121
daita = false,
110122
quic = Quic(inAddresses = listOf()),
111123
lwo = false,
124+
cityName = "Relay City 5",
125+
countryName = "RCo4",
112126
)
113127
private val DUMMY_RELAY_8 =
114128
RelayItem.Location.Relay(
@@ -123,6 +137,8 @@ private val DUMMY_RELAY_8 =
123137
daita = false,
124138
quic = null,
125139
lwo = false,
140+
cityName = "Relay City 5",
141+
countryName = "RCo4",
126142
)
127143
private val DUMMY_RELAY_9 =
128144
RelayItem.Location.Relay(
@@ -137,6 +153,8 @@ private val DUMMY_RELAY_9 =
137153
daita = true,
138154
quic = null,
139155
lwo = true,
156+
cityName = "Relay City 5",
157+
countryName = "RCo4",
140158
)
141159
private val DUMMY_RELAY_10 =
142160
RelayItem.Location.Relay(
@@ -151,6 +169,8 @@ private val DUMMY_RELAY_10 =
151169
daita = true,
152170
quic = null,
153171
lwo = false,
172+
cityName = "Relay City 5",
173+
countryName = "RCo4",
154174
)
155175
private val DUMMY_RELAY_11 =
156176
RelayItem.Location.Relay(
@@ -165,6 +185,8 @@ private val DUMMY_RELAY_11 =
165185
daita = false,
166186
quic = Quic(inAddresses = listOf()),
167187
lwo = false,
188+
cityName = "Relay City 5",
189+
countryName = "RCo4",
168190
)
169191
private val DUMMY_RELAY_12 =
170192
RelayItem.Location.Relay(
@@ -179,30 +201,36 @@ private val DUMMY_RELAY_12 =
179201
daita = false,
180202
quic = Quic(inAddresses = listOf()),
181203
lwo = true,
204+
cityName = "Relay City 5",
205+
countryName = "RCo4",
182206
)
183207
private val DUMMY_RELAY_CITY_1 =
184208
RelayItem.Location.City(
185209
name = "Relay City 1",
186210
id = GeoLocationId.City(country = GeoLocationId.Country("RCo1"), code = "RCi1"),
187211
relays = listOf(DUMMY_RELAY_1),
212+
countryName = "RCo1",
188213
)
189214
private val DUMMY_RELAY_CITY_2 =
190215
RelayItem.Location.City(
191216
name = "Relay City 2",
192217
id = GeoLocationId.City(country = GeoLocationId.Country("RCo2"), code = "RCi2"),
193218
relays = listOf(DUMMY_RELAY_2),
219+
countryName = "RCo2",
194220
)
195221
private val DUMMY_RELAY_CITY_3 =
196222
RelayItem.Location.City(
197223
name = "Relay City 3",
198224
id = GeoLocationId.City(country = GeoLocationId.Country("RCo3"), code = "RCi3"),
199225
relays = listOf(DUMMY_RELAY_3),
226+
countryName = "RCo3",
200227
)
201228
private val DUMMY_RELAY_CITY_4 =
202229
RelayItem.Location.City(
203230
name = "Relay City 4",
204231
id = GeoLocationId.City(country = GeoLocationId.Country("RCo4"), code = "RCi4"),
205232
relays = listOf(DUMMY_RELAY_4),
233+
countryName = "RCo4",
206234
)
207235
private val DUMMY_RELAY_CITY_5 =
208236
RelayItem.Location.City(
@@ -219,6 +247,7 @@ private val DUMMY_RELAY_CITY_5 =
219247
DUMMY_RELAY_11,
220248
DUMMY_RELAY_12,
221249
),
250+
countryName = "RCo4",
222251
)
223252
private val DUMMY_RELAY_COUNTRY_1 =
224253
RelayItem.Location.Country(

android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/data/DummyRelayListItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fun createSimpleRelayListItemList(
1616
if (recentItems.isNotEmpty()) {
1717
add(RelayListItem.RecentsListHeader)
1818
recentItems.forEach {
19-
add(RelayListItem.RecentListItem(it, isSelected = it.id == selectedItem))
19+
add(RelayListItem.RecentListItem(item = it, isSelected = it.id == selectedItem))
2020
}
2121
}
2222
add(RelayListItem.CustomListHeader)

android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreenTest.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package net.mullvad.mullvadvpn.compose.screen.location
22

33
import androidx.compose.ui.test.ExperimentalTestApi
4+
import androidx.compose.ui.test.hasAnyAncestor
5+
import androidx.compose.ui.test.hasTestTag
6+
import androidx.compose.ui.test.hasText
47
import androidx.compose.ui.test.onNodeWithTag
58
import androidx.compose.ui.test.onNodeWithText
69
import androidx.compose.ui.test.performClick
@@ -28,7 +31,7 @@ import net.mullvad.mullvadvpn.lib.model.RelayListType
2831
import net.mullvad.mullvadvpn.lib.ui.component.relaylist.ItemPosition
2932
import net.mullvad.mullvadvpn.lib.ui.component.relaylist.RelayListItem
3033
import net.mullvad.mullvadvpn.lib.ui.tag.GEOLOCATION_NAME_TAG
31-
import net.mullvad.mullvadvpn.lib.ui.tag.RECENT_NAME_TAG
34+
import net.mullvad.mullvadvpn.lib.ui.tag.RECENT_CELL_TEST_TAG
3235
import net.mullvad.mullvadvpn.lib.ui.tag.SELECT_LOCATION_CUSTOM_LIST_BOTTOM_SHEET_TEST_TAG
3336
import net.mullvad.mullvadvpn.lib.ui.tag.SELECT_LOCATION_LOCATION_BOTTOM_SHEET_TEST_TAG
3437
import net.mullvad.mullvadvpn.lib.usecase.ModifyMultihopError
@@ -265,7 +268,7 @@ class SelectLocationScreenTest {
265268
MutableStateFlow(
266269
Lce.Content(
267270
SelectLocationListUiState(
268-
relayListItems = listOf(RelayListItem.RecentListItem(recent)),
271+
relayListItems = listOf(RelayListItem.RecentListItem(item = recent)),
269272
customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS,
270273
relayListType = RelayListType.Single,
271274
)
@@ -444,9 +447,9 @@ class SelectLocationScreenTest {
444447
)
445448

446449
// Assert
447-
onNodeWithTagAndText(
448-
testTag = RECENT_NAME_TAG,
449-
text = selectableItem.name,
450+
onNode(
451+
hasText(selectableItem.name)
452+
.and(hasAnyAncestor(hasTestTag(RECENT_CELL_TEST_TAG))),
450453
useUnmergedTree = true,
451454
)
452455
.assertExists()

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/RelayListContent.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import net.mullvad.mullvadvpn.lib.model.CustomListId
2929
import net.mullvad.mullvadvpn.lib.model.RelayItem
3030
import net.mullvad.mullvadvpn.lib.model.RelayItemId
3131
import net.mullvad.mullvadvpn.lib.model.RelayListType
32+
import net.mullvad.mullvadvpn.lib.ui.component.listitem.SelectableListItem
3233
import net.mullvad.mullvadvpn.lib.ui.component.relaylist.ItemPosition
3334
import net.mullvad.mullvadvpn.lib.ui.component.relaylist.RelayListItem
3435
import net.mullvad.mullvadvpn.lib.ui.component.relaylist.SelectableRelayListItem
@@ -152,8 +153,21 @@ private fun RecentListItem(
152153
onSelect: (RelayItem) -> Unit,
153154
onUpdateBottomSheetState: (LocationBottomSheetState) -> Unit,
154155
) {
155-
SelectableRelayListItem(
156-
relayListItem = listItem,
156+
val subtitle =
157+
when (listItem.item) {
158+
is RelayItem.Location.Relay -> "${listItem.cityName}, ${listItem.countryName}"
159+
is RelayItem.Location.City -> listItem.countryName
160+
is RelayItem.Location.Country,
161+
is RelayItem.CustomList -> null
162+
}
163+
164+
SelectableListItem(
165+
modifier = Modifier.positionalPadding(listItem.itemPosition),
166+
isSelected = listItem.isSelected,
167+
isEnabled = listItem.item.active,
168+
testTag = RECENT_CELL_TEST_TAG,
169+
title = listItem.item.name,
170+
subtitle = subtitle,
157171
onClick = { onSelect(listItem.item) },
158172
onLongClick = {
159173
when (val entry = listItem.item) {
@@ -167,8 +181,6 @@ private fun RecentListItem(
167181
)
168182
}
169183
},
170-
onToggleExpand = { _ -> },
171-
modifier = Modifier.positionalPadding(listItem.itemPosition).testTag(RECENT_CELL_TEST_TAG),
172184
)
173185
}
174186

android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SearchLocationViewModelTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class SearchLocationViewModelTest {
159159
id = GeoLocationId.City(GeoLocationId.Country("se"), "got"),
160160
"Gothenburg",
161161
emptyList(),
162+
countryName = "Sweden",
162163
)
163164
),
164165
),

android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationListViewModelTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ class SelectLocationListViewModelTest {
286286
id = GeoLocationId.City(GeoLocationId.Country("se"), "got"),
287287
"Gothenburg",
288288
emptyList(),
289+
countryName = "Sweden",
289290
)
290291
),
291292
),

android/lib/feature/customlist/impl/src/test/java/net/mullvad/mullvadvpn/customlist/impl/CustomListLocationsViewModelTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,11 @@ class CustomListLocationsViewModelTest {
368368
daita = false,
369369
quic = null,
370370
lwo = false,
371+
countryName = "Sweden",
372+
cityName = "Gothenburg",
371373
)
372374
),
375+
countryName = "Sweden",
373376
)
374377
),
375378
)
@@ -387,6 +390,8 @@ class CustomListLocationsViewModelTest {
387390
daita = false,
388391
quic = null,
389392
lwo = false,
393+
cityName = "Copenhagen",
394+
countryName = "Denmark",
390395
)
391396
}
392397
}

android/lib/grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/grpc/mapper/ToDomain.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,28 +567,39 @@ internal fun ManagementInterface.RelayListCountry.toDomain(): RelayItem.Location
567567
countryCode,
568568
name,
569569
citiesList
570-
.map { city -> city.toDomain(countryCode) }
570+
.map { city -> city.toDomain(countryCode = countryCode, countryName = name) }
571571
.filter { it.relays.isNotEmpty() }
572572
.sortedBy { it.name },
573573
)
574574
}
575575

576576
internal fun ManagementInterface.RelayListCity.toDomain(
577-
countryCode: GeoLocationId.Country
577+
countryCode: GeoLocationId.Country,
578+
countryName: String,
578579
): RelayItem.Location.City {
579580
val cityCode = GeoLocationId.City(countryCode, code)
580581
return RelayItem.Location.City(
581582
name = name,
583+
countryName = countryName,
582584
id = cityCode,
583-
relays = relaysList.map { it.toDomain(cityCode) }.sortedWith(RelayNameComparator),
585+
relays =
586+
relaysList
587+
.map {
588+
it.toDomain(cityCode = cityCode, cityName = name, countryName = countryName)
589+
}
590+
.sortedWith(RelayNameComparator),
584591
)
585592
}
586593

587594
internal fun ManagementInterface.Relay.toDomain(
588-
cityCode: GeoLocationId.City
595+
cityCode: GeoLocationId.City,
596+
cityName: String,
597+
countryName: String,
589598
): RelayItem.Location.Relay =
590599
RelayItem.Location.Relay(
591600
id = GeoLocationId.Hostname(cityCode, hostname),
601+
cityName = cityName,
602+
countryName = countryName,
592603
active = active,
593604
provider = ProviderId(provider),
594605
ownership = if (owned) Ownership.MullvadOwned else Ownership.Rented,

0 commit comments

Comments
 (0)