diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-02-03 11:23:12 +0100 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-02-03 11:23:12 +0100 |
| commit | 15e3f3a3e1dc5842105760833f13543bbb992dfa (patch) | |
| tree | 2b87dd7cad5e4e01e6b06600eba21afd4a756800 /android | |
| parent | 018997ab24afb19e1c4d4251a8007f0874f94472 (diff) | |
| parent | 464447f3c55d34958807554a74453195e338c85b (diff) | |
| download | mullvadvpn-15e3f3a3e1dc5842105760833f13543bbb992dfa.tar.xz mullvadvpn-15e3f3a3e1dc5842105760833f13543bbb992dfa.zip | |
Merge branch 'custom-list-without-location-is-shown-as-blocked-by-entry-droid-1762'
Diffstat (limited to 'android')
2 files changed, 20 insertions, 14 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt index 4f6d4b75c9..1b8918e2de 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt @@ -164,7 +164,7 @@ fun RelayItemCell( if (content != null) { content() } - Name(name = item.name, state = state) + Name(name = item.name, state = state, active = item.active) } if (item.hasChildren) { @@ -207,14 +207,19 @@ fun CheckableRelayLocationCell( } @Composable -private fun Name(modifier: Modifier = Modifier, name: String, state: RelayListItemState?) { +private fun Name( + modifier: Modifier = Modifier, + name: String, + state: RelayListItemState?, + active: Boolean, +) { Text( text = state?.let { name.withSuffix(state) } ?: name, color = MaterialTheme.colorScheme.onSurface, modifier = modifier .alpha( - if (state == null) { + if (state == null && active) { AlphaVisible } else { AlphaInactive diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/location/RelayItemListCreator.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/location/RelayItemListCreator.kt index c4b9e44f4d..6bd1e31573 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/location/RelayItemListCreator.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/location/RelayItemListCreator.kt @@ -114,7 +114,7 @@ private fun createCustomListRelayItems( state = customList.createState( relayListType = relayListType, - selectedByOther = selectedByOtherEntryExitList, + selectedByOtherId = selectedByOtherEntryExitList, ), expanded = expanded, ) @@ -180,7 +180,7 @@ private fun createCustomListEntry( state = item.createState( relayListType = relayListType, - selectedByOther = selectedByOtherEntryExitList, + selectedByOtherId = selectedByOtherEntryExitList, ), expanded = expanded, depth = depth, @@ -237,7 +237,7 @@ private fun createGeoLocationEntry( state = item.createState( relayListType = relayListType, - selectedByOther = selectedByOtherEntryExitList, + selectedByOtherId = selectedByOtherEntryExitList, ), depth = depth, expanded = expanded, @@ -332,19 +332,20 @@ private fun String.isSearching() = length >= MIN_SEARCH_LENGTH private fun RelayItem.createState( relayListType: RelayListType, - selectedByOther: RelayItemId?, + selectedByOtherId: RelayItemId?, ): RelayListItemState? { - val selectedByOther = + val isSelectedByOther = when (this) { is RelayItem.CustomList -> { - selectedByOther == customList.id || - customList.locations.all { it == selectedByOther } + selectedByOtherId == customList.id || + (customList.locations.isNotEmpty() && + customList.locations.all { it == selectedByOtherId }) } - is RelayItem.Location.City -> selectedByOther == id - is RelayItem.Location.Country -> selectedByOther == id - is RelayItem.Location.Relay -> selectedByOther == id + is RelayItem.Location.City -> selectedByOtherId == id + is RelayItem.Location.Country -> selectedByOtherId == id + is RelayItem.Location.Relay -> selectedByOtherId == id } - return if (selectedByOther) { + return if (isSelectedByOther) { when (relayListType) { RelayListType.ENTRY -> RelayListItemState.USED_AS_EXIT RelayListType.EXIT -> RelayListItemState.USED_AS_ENTRY |
