diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-05-05 11:35:43 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-05-05 22:47:54 +0200 |
| commit | 7dfffe68f3f9c66790c069bb1cb7fb4da6eaa98d (patch) | |
| tree | b91240aba001a9cabcec51e3eeb4a5d7838bc77b /android | |
| parent | dc860e549ad9b88416ec38b8bd2b7f8936a65856 (diff) | |
| download | mullvadvpn-7dfffe68f3f9c66790c069bb1cb7fb4da6eaa98d.tar.xz mullvadvpn-7dfffe68f3f9c66790c069bb1cb7fb4da6eaa98d.zip | |
Fix select location button text in connect screen
- Remove unnecessary show location boolean
- Remove reliance on disconnected location
- Align state behaviour with desktop
- Update screen tests with the new behaviour
Diffstat (limited to 'android')
5 files changed, 20 insertions, 58 deletions
diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreenTest.kt index cccdfe8c09..14409f1fb2 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreenTest.kt @@ -115,7 +115,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connecting(null, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = InAppNotification.TunnelStateBlocked, @@ -143,7 +142,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connected(mockTunnelEndpoint, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -162,14 +160,12 @@ class ConnectScreenTest { fun testDisconnectingState() { composeExtension.use { // Arrange - val mockLocationName = "Home" initScreen( state = ConnectUiState( location = null, - selectedRelayItemTitle = mockLocationName, + selectedRelayItemTitle = null, tunnelState = TunnelState.Disconnecting(ActionAfterDisconnect.Nothing), - showLocation = true, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -179,7 +175,7 @@ class ConnectScreenTest { // Assert onNodeWithText("DISCONNECTING...").assertExists() - onNodeWithText(mockLocationName).assertExists() + onNodeWithText("Switch location").assertExists() onNodeWithText("Disconnect").assertExists() } } @@ -188,14 +184,13 @@ class ConnectScreenTest { fun testDisconnectedState() { composeExtension.use { // Arrange - val mockLocationName = "Home" + val mockSelectedRelayTitle = "Home" initScreen( state = ConnectUiState( location = null, - selectedRelayItemTitle = mockLocationName, + selectedRelayItemTitle = mockSelectedRelayTitle, tunnelState = TunnelState.Disconnected(), - showLocation = true, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -205,7 +200,7 @@ class ConnectScreenTest { // Assert onNodeWithText("DISCONNECTED").assertExists() - onNodeWithText(mockLocationName).assertExists() + onNodeWithText(mockSelectedRelayTitle).assertExists() onNodeWithText("Connect").assertExists() } } @@ -214,15 +209,13 @@ class ConnectScreenTest { fun testErrorStateBlocked() { composeExtension.use { // Arrange - val mockLocationName = "Home" initScreen( state = ConnectUiState( location = null, - selectedRelayItemTitle = mockLocationName, + selectedRelayItemTitle = null, tunnelState = TunnelState.Error(ErrorState(ErrorStateCause.StartTunnelError, true)), - showLocation = true, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = @@ -235,7 +228,7 @@ class ConnectScreenTest { // Assert onNodeWithText("BLOCKED CONNECTION").assertExists() - onNodeWithText(mockLocationName).assertExists() + onNodeWithText("Switch location").assertExists() onNodeWithText("Disconnect").assertExists() onNodeWithText("BLOCKING INTERNET").assertExists() } @@ -245,15 +238,13 @@ class ConnectScreenTest { fun testErrorStateNotBlocked() { composeExtension.use { // Arrange - val mockLocationName = "Home" initScreen( state = ConnectUiState( location = null, - selectedRelayItemTitle = mockLocationName, + selectedRelayItemTitle = null, tunnelState = TunnelState.Error(ErrorState(ErrorStateCause.StartTunnelError, false)), - showLocation = true, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = @@ -266,7 +257,7 @@ class ConnectScreenTest { // Assert onNodeWithText("FAILED TO CONNECT").assertExists() - onNodeWithText(mockLocationName).assertExists() + onNodeWithText("Switch location").assertExists() onNodeWithText("Dismiss").assertExists() onNodeWithText(text = "Critical error (your attention is required)", ignoreCase = true) .assertExists() @@ -283,7 +274,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Disconnecting(ActionAfterDisconnect.Reconnect), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = InAppNotification.TunnelStateBlocked, @@ -304,14 +294,12 @@ class ConnectScreenTest { fun testDisconnectingBlockState() { composeExtension.use { // Arrange - val mockLocationName = "Home" initScreen( state = ConnectUiState( location = null, - selectedRelayItemTitle = mockLocationName, + selectedRelayItemTitle = null, tunnelState = TunnelState.Disconnecting(ActionAfterDisconnect.Block), - showLocation = true, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = InAppNotification.TunnelStateBlocked, @@ -321,7 +309,7 @@ class ConnectScreenTest { // Assert onNodeWithText("BLOCKING...").assertExists() - onNodeWithText(mockLocationName).assertExists() + onNodeWithText("Switch location").assertExists() onNodeWithText("Disconnect").assertExists() onNodeWithText("BLOCKING INTERNET").assertExists() } @@ -331,15 +319,14 @@ class ConnectScreenTest { fun testClickSelectLocationButton() { composeExtension.use { // Arrange - val mockLocationName = "Home" + val mockSelectedRelayItemTitle = "Home" val mockedClickHandler: () -> Unit = mockk(relaxed = true) initScreen( state = ConnectUiState( location = null, - selectedRelayItemTitle = mockLocationName, + selectedRelayItemTitle = mockSelectedRelayItemTitle, tunnelState = TunnelState.Disconnected(), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -368,7 +355,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connected(mockTunnelEndpoint, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -397,7 +383,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connected(mockTunnelEndpoint, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -425,7 +410,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Disconnected(), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -453,7 +437,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connecting(null, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -505,7 +488,6 @@ class ConnectScreenTest { selectedRelayItemTitle = null, tunnelState = TunnelState.Connected(mockTunnelEndpoint, mockLocation, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -540,7 +522,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connecting(null, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = InAppNotification.UnsupportedVersion(versionInfo), @@ -568,7 +549,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connecting(null, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = @@ -598,7 +578,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connecting(null, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = InAppNotification.UnsupportedVersion(versionInfo), @@ -627,7 +606,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connecting(null, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = @@ -658,7 +636,6 @@ class ConnectScreenTest { location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Connecting(null, null, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = InAppNotification.NewVersionChangelog, @@ -723,7 +700,6 @@ class ConnectScreenTest { selectedRelayItemTitle = null, tunnelState = TunnelState.Connected(mockTunnelEndpoint, mockLocation, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -781,7 +757,6 @@ class ConnectScreenTest { selectedRelayItemTitle = null, tunnelState = TunnelState.Connected(mockTunnelEndpoint, mockLocation, emptyList()), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, @@ -831,7 +806,6 @@ class ConnectScreenTest { mockLocation, listOf(FeatureIndicator.MULTIHOP), ), - showLocation = false, deviceName = "", daysLeftUntilExpiry = null, inAppNotification = null, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/ConnectUiStatePreviewParameterProvider.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/ConnectUiStatePreviewParameterProvider.kt index d3c704d0a2..ea19fba8e7 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/ConnectUiStatePreviewParameterProvider.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/ConnectUiStatePreviewParameterProvider.kt @@ -45,7 +45,6 @@ private fun generateOtherStates(): Sequence<ConnectUiState> = ), selectedRelayItemTitle = "Relay Title", tunnelState = state, - showLocation = true, inAppNotification = if (index == 0) InAppNotification.NewDevice("Test Device") else null, deviceName = "Cool Beans", diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt index 7de950efc8..2a3474c755 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt @@ -687,7 +687,7 @@ private fun ButtonPanel( Column(modifier = Modifier.padding(vertical = Dimens.tinyPadding)) { SwitchLocationButton( text = - if (state.showLocation && state.selectedRelayItemTitle != null) { + if (state.selectedRelayItemTitle != null) { state.selectedRelayItemTitle } else { stringResource(id = R.string.switch_location) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/ConnectUiState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/ConnectUiState.kt index 63b596d513..956b1506a7 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/ConnectUiState.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/ConnectUiState.kt @@ -8,7 +8,6 @@ data class ConnectUiState( val location: GeoIpLocation?, val selectedRelayItemTitle: String?, val tunnelState: TunnelState, - val showLocation: Boolean, val inAppNotification: InAppNotification?, val deviceName: String?, val daysLeftUntilExpiry: Long?, @@ -24,7 +23,6 @@ data class ConnectUiState( location = null, selectedRelayItemTitle = null, tunnelState = TunnelState.Disconnected(), - showLocation = false, inAppNotification = null, deviceName = null, daysLeftUntilExpiry = null, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt index 3a100736b2..2ccb138a5f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt @@ -95,22 +95,13 @@ class ConnectViewModel( } is TunnelState.Error -> lastKnownDisconnectedLocation }, - selectedRelayItemTitle = selectedRelayItemTitle, - tunnelState = tunnelState, - showLocation = - when (tunnelState) { - is TunnelState.Disconnected -> tunnelState.location != null - is TunnelState.Disconnecting -> { - when (tunnelState.actionAfterDisconnect) { - ActionAfterDisconnect.Nothing -> false - ActionAfterDisconnect.Block -> true - ActionAfterDisconnect.Reconnect -> false - } - } - is TunnelState.Connecting -> false - is TunnelState.Connected -> false - is TunnelState.Error -> true + selectedRelayItemTitle = + if (tunnelState is TunnelState.Disconnected) { + selectedRelayItemTitle + } else { + null }, + tunnelState = tunnelState, inAppNotification = notifications.firstOrNull(), deviceName = deviceName, daysLeftUntilExpiry = accountData?.expiryDate?.daysFromNow(), |
