summaryrefslogtreecommitdiffhomepage
path: root/android/app
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2024-08-09 10:36:28 +0200
committerBug Magnet <marco.nikic@mullvad.net>2024-08-12 12:05:10 +0200
commitdbe9218b608ea5f6b2172c8f94c5e6048da04f17 (patch)
tree4a3228f2ceb684b27f0deb98e1f5f4f6e94f1d29 /android/app
parent749c479d9ed8a266cbe893f963bfe9825e6bab5b (diff)
downloadmullvadvpn-dbe9218b608ea5f6b2172c8f94c5e6048da04f17.tar.xz
mullvadvpn-dbe9218b608ea5f6b2172c8f94c5e6048da04f17.zip
Show the name of the custom list in remove location bottom sheet
Diffstat (limited to 'android/app')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt13
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SelectLocationViewModel.kt9
3 files changed, 17 insertions, 7 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt
index e96fc66221..1b82861e76 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt
@@ -92,7 +92,9 @@ import net.mullvad.mullvadvpn.compose.transitions.SelectLocationTransition
import net.mullvad.mullvadvpn.compose.util.CollectSideEffectWithLifecycle
import net.mullvad.mullvadvpn.compose.util.RunOnKeyChange
import net.mullvad.mullvadvpn.compose.util.showSnackbarImmediately
+import net.mullvad.mullvadvpn.lib.model.CustomList
import net.mullvad.mullvadvpn.lib.model.CustomListId
+import net.mullvad.mullvadvpn.lib.model.CustomListName
import net.mullvad.mullvadvpn.lib.model.RelayItem
import net.mullvad.mullvadvpn.lib.model.RelayItemId
import net.mullvad.mullvadvpn.lib.theme.AppTheme
@@ -365,6 +367,7 @@ fun SelectLocationScreen(
bottomSheetState =
ShowCustomListsEntryBottomSheet(
listItem.parentId,
+ listItem.parentName,
listItem.item
)
}
@@ -589,7 +592,8 @@ private fun BottomSheets(
CustomListEntryBottomSheet(
sheetState = sheetState,
onBackgroundColor = onBackgroundColor,
- customListId = bottomSheetState.parentId,
+ customListId = bottomSheetState.customListId,
+ customListName = bottomSheetState.customListName,
item = bottomSheetState.item,
onRemoveLocationFromList = onRemoveLocationFromList,
closeBottomSheet = onCloseBottomSheet
@@ -784,6 +788,7 @@ private fun CustomListEntryBottomSheet(
onBackgroundColor: Color,
sheetState: SheetState,
customListId: CustomListId,
+ customListName: CustomListName,
item: RelayItem.Location,
onRemoveLocationFromList: (location: RelayItem.Location, customListId: CustomListId) -> Unit,
closeBottomSheet: (animate: Boolean) -> Unit
@@ -794,7 +799,8 @@ private fun CustomListEntryBottomSheet(
modifier = Modifier.testTag(SELECT_LOCATION_LOCATION_BOTTOM_SHEET_TEST_TAG)
) {
HeaderCell(
- text = stringResource(id = R.string.remove_location_from_list, item.name),
+ text =
+ stringResource(id = R.string.remove_location_from_list, item.name, customListName),
background = Color.Unspecified
)
HorizontalDivider(color = onBackgroundColor)
@@ -902,7 +908,8 @@ sealed interface BottomSheetState {
data class ShowCustomListsBottomSheet(val editListEnabled: Boolean) : BottomSheetState
data class ShowCustomListsEntryBottomSheet(
- val parentId: CustomListId,
+ val customListId: CustomListId,
+ val customListName: CustomListName,
val item: RelayItem.Location
) : BottomSheetState
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt
index 5d6b683116..88d557c532 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt
@@ -1,6 +1,7 @@
package net.mullvad.mullvadvpn.compose.state
import net.mullvad.mullvadvpn.lib.model.CustomListId
+import net.mullvad.mullvadvpn.lib.model.CustomListName
import net.mullvad.mullvadvpn.lib.model.RelayItem
typealias ModelOwnership = net.mullvad.mullvadvpn.lib.model.Ownership
@@ -60,6 +61,7 @@ sealed interface RelayListItem {
data class CustomListEntryItem(
val parentId: CustomListId,
+ val parentName: CustomListName,
val item: RelayItem.Location,
override val expanded: Boolean,
override val depth: Int = 0
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SelectLocationViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SelectLocationViewModel.kt
index a219bb976b..1cd17b9ba1 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SelectLocationViewModel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SelectLocationViewModel.kt
@@ -214,7 +214,7 @@ class SelectLocationViewModel(
if (expanded) {
addAll(
customList.locations.flatMap {
- createCustomListEntry(parent = customList.id, item = it, 1, isExpanded)
+ createCustomListEntry(parent = customList, item = it, 1, isExpanded)
}
)
}
@@ -240,15 +240,16 @@ class SelectLocationViewModel(
}
private fun createCustomListEntry(
- parent: CustomListId,
+ parent: RelayItem.CustomList,
item: RelayItem.Location,
depth: Int = 1,
isExpanded: (String) -> Boolean,
): List<RelayListItem.CustomListEntryItem> = buildList {
- val expanded = isExpanded(item.id.expandKey(parent))
+ val expanded = isExpanded(item.id.expandKey(parent.id))
add(
RelayListItem.CustomListEntryItem(
- parentId = parent,
+ parentId = parent.id,
+ parentName = parent.customList.name,
item = item,
expanded = expanded,
depth