diff options
| author | Albin <albin@mullvad.net> | 2024-07-04 11:48:19 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2024-07-04 11:48:19 +0200 |
| commit | 73bba2cfb78b789241db09ff5e39f638ecfad5ac (patch) | |
| tree | e91b65a9f91d81c353dc30cfe7be9d2eb29dcb7c /android/app | |
| parent | 6fcf6e0c507a90fa95e9f86bc88060629d7cc674 (diff) | |
| parent | a6d23d483fd16a8be34a6cc24cd8222f9757eef2 (diff) | |
| download | mullvadvpn-73bba2cfb78b789241db09ff5e39f638ecfad5ac.tar.xz mullvadvpn-73bba2cfb78b789241db09ff5e39f638ecfad5ac.zip | |
Merge branch 'only-show-unsupported-version-in-settings-droid-1103'
Diffstat (limited to 'android/app')
15 files changed, 26 insertions, 173 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 98c87114fb..9ba5db81bc 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 @@ -598,49 +598,10 @@ class ConnectScreenTest { } @Test - fun testOutdatedVersionNotification() { - composeExtension.use { - // Arrange - val versionInfo = - VersionInfo( - currentVersion = "1.0", - isSupported = true, - suggestedUpgradeVersion = "1.1" - ) - setContentWithTheme { - ConnectScreen( - state = - ConnectUiState( - location = null, - selectedRelayItemTitle = null, - tunnelState = TunnelState.Connecting(null, null), - inAddress = null, - outAddress = "", - showLocation = false, - deviceName = "", - daysLeftUntilExpiry = null, - inAppNotification = InAppNotification.UpdateAvailable(versionInfo), - isPlayBuild = false - ), - ) - } - - // Assert - onNodeWithText("UPDATE AVAILABLE").assertExists() - onNodeWithText("Install Mullvad VPN (1.1) to stay up to date").assertExists() - } - } - - @Test fun testUnsupportedVersionNotification() { composeExtension.use { // Arrange - val versionInfo = - VersionInfo( - currentVersion = "1.0", - isSupported = false, - suggestedUpgradeVersion = "1.1" - ) + val versionInfo = VersionInfo(currentVersion = "1.0", isSupported = false) setContentWithTheme { ConnectScreen( state = @@ -702,12 +663,7 @@ class ConnectScreenTest { composeExtension.use { // Arrange val mockedClickHandler: () -> Unit = mockk(relaxed = true) - val versionInfo = - VersionInfo( - isSupported = false, - currentVersion = "", - suggestedUpgradeVersion = "1.1" - ) + val versionInfo = VersionInfo(isSupported = false, currentVersion = "") setContentWithTheme { ConnectScreen( onUpdateVersionClick = mockedClickHandler, diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreenTest.kt index afa144f405..469fb629a4 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreenTest.kt @@ -31,7 +31,7 @@ class SettingsScreenTest { SettingsUiState( appVersion = "", isLoggedIn = true, - isUpdateAvailable = true, + isSupportedVersion = true, isPlayBuild = false ), ) @@ -54,7 +54,7 @@ class SettingsScreenTest { SettingsUiState( appVersion = "", isLoggedIn = false, - isUpdateAvailable = true, + isSupportedVersion = true, isPlayBuild = false ), ) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt index fdc01ab62d..a0dfe44f09 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt @@ -14,7 +14,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import net.mullvad.mullvadvpn.R @@ -95,7 +94,7 @@ internal fun NavigationTitleView( Image( painter = painterResource(id = R.drawable.icon_alert), modifier = Modifier.padding(end = Dimens.smallPadding), - contentDescription = stringResource(id = R.string.update_available) + contentDescription = null ) } Text( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt index c5600b92a2..5a10e005a5 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt @@ -50,12 +50,7 @@ private fun PreviewNotificationBanner() { val bannerDataList = listOf( InAppNotification.UnsupportedVersion( - versionInfo = - VersionInfo( - currentVersion = "1.0", - isSupported = false, - suggestedUpgradeVersion = null - ), + versionInfo = VersionInfo(currentVersion = "1.0", isSupported = false), ), InAppNotification.AccountExpiry(expiry = DateTime.now()), InAppNotification.TunnelStateBlocked, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationData.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationData.kt index b8ea96fc72..28efcee9c4 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationData.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationData.kt @@ -93,19 +93,6 @@ fun InAppNotification.toNotificationData( if (isPlayBuild) null else NotificationAction(R.drawable.icon_extlink, onClickUpdateVersion) ) - is InAppNotification.UpdateAvailable -> - NotificationData( - title = stringResource(id = R.string.update_available), - message = - stringResource( - id = R.string.update_available_description, - versionInfo.suggestedUpgradeVersion ?: "" - ), - statusLevel = StatusLevel.Warning, - action = - if (isPlayBuild) null - else NotificationAction(R.drawable.icon_extlink, onClickUpdateVersion) - ) } @Composable diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt index 15852560c1..c602d731f2 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt @@ -54,7 +54,7 @@ private fun PreviewSettings() { SettingsUiState( appVersion = "2222.22", isLoggedIn = true, - isUpdateAvailable = true, + isSupportedVersion = true, isPlayBuild = false ), ) @@ -172,13 +172,13 @@ private fun AppVersion(context: Context, state: SettingsUiState) { ) } }, - showWarning = state.isUpdateAvailable, + showWarning = !state.isSupportedVersion, isRowEnabled = !state.isPlayBuild ) - if (state.isUpdateAvailable) { + if (!state.isSupportedVersion) { Text( - text = stringResource(id = R.string.update_available_footer), + text = stringResource(id = R.string.unsupported_version_description), style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSecondary, modifier = diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SettingsUiState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SettingsUiState.kt index b325ed2ce7..8f5ce2d8a2 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SettingsUiState.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SettingsUiState.kt @@ -3,6 +3,6 @@ package net.mullvad.mullvadvpn.compose.state data class SettingsUiState( val appVersion: String, val isLoggedIn: Boolean, - val isUpdateAvailable: Boolean, + val isSupportedVersion: Boolean, val isPlayBuild: Boolean ) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/InAppNotificationController.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/InAppNotificationController.kt index 79db20d390..6686621f7b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/InAppNotificationController.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/InAppNotificationController.kt @@ -47,11 +47,6 @@ sealed class InAppNotification { override val statusLevel = StatusLevel.Info override val priority: Long = 1001 } - - data class UpdateAvailable(val versionInfo: VersionInfo) : InAppNotification() { - override val statusLevel = StatusLevel.Info - override val priority: Long = 1000 - } } class InAppNotificationController( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/VersionInfo.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/VersionInfo.kt index c0ab7dd0ed..7e2550974d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/VersionInfo.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/VersionInfo.kt @@ -1,9 +1,3 @@ package net.mullvad.mullvadvpn.ui -data class VersionInfo( - val currentVersion: String, - val isSupported: Boolean, - val suggestedUpgradeVersion: String? -) { - val isUpdateAvailable: Boolean = suggestedUpgradeVersion != null -} +data class VersionInfo(val currentVersion: String, val isSupported: Boolean) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AppVersionInfoRepository.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AppVersionInfoRepository.kt index 74b67348b3..63ce64cd06 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AppVersionInfoRepository.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AppVersionInfoRepository.kt @@ -12,10 +12,6 @@ class AppVersionInfoRepository( ) { fun versionInfo(): Flow<VersionInfo> = managementService.versionInfo.map { appVersionInfo -> - VersionInfo( - currentVersion = buildVersion.name, - isSupported = appVersionInfo.supported, - suggestedUpgradeVersion = appVersionInfo.suggestedUpgrade, - ) + VersionInfo(currentVersion = buildVersion.name, isSupported = appVersionInfo.supported) } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCase.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCase.kt index 43f1fdac77..18d4e2fc3e 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCase.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCase.kt @@ -14,24 +14,9 @@ class VersionNotificationUseCase( operator fun invoke() = appVersionInfoRepository .versionInfo() - .map { versionInfo -> - listOfNotNull( - unsupportedVersionNotification(versionInfo), - updateAvailableNotification(versionInfo) - ) - } + .map { versionInfo -> listOfNotNull(unsupportedVersionNotification(versionInfo)) } .distinctUntilChanged() - private fun updateAvailableNotification(versionInfo: VersionInfo): InAppNotification? { - if (!isVersionInfoNotificationEnabled) { - return null - } - - return if (versionInfo.isUpdateAvailable) { - InAppNotification.UpdateAvailable(versionInfo) - } else null - } - private fun unsupportedVersionNotification(versionInfo: VersionInfo): InAppNotification? { if (!isVersionInfoNotificationEnabled) { return null diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModel.kt index 5150af2747..21870d99b2 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModel.kt @@ -24,8 +24,7 @@ class SettingsViewModel( SettingsUiState( isLoggedIn = deviceState is DeviceState.LoggedIn, appVersion = versionInfo.currentVersion, - isUpdateAvailable = - versionInfo.let { it.isSupported.not() || it.isUpdateAvailable }, + isSupportedVersion = versionInfo.isSupported, isPlayBuild = isPlayBuild ) } @@ -35,7 +34,7 @@ class SettingsViewModel( SettingsUiState( appVersion = "", isLoggedIn = false, - isUpdateAvailable = false, + isSupportedVersion = true, isPlayBuild ) ) @@ -47,7 +46,7 @@ class SettingsViewModel( SettingsUiState( appVersion = "", isLoggedIn = false, - isUpdateAvailable = false, + isSupportedVersion = true, isPlayBuild ) ) diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt index 91749b468e..78f1563c85 100644 --- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt +++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt @@ -77,8 +77,7 @@ class InAppNotificationControllerTest { tunnelStateNotifications.value = listOf(tunnelStateBlocked, tunnelStateError) val unsupportedVersion = InAppNotification.UnsupportedVersion(mockk()) - val updateAvailable = InAppNotification.UpdateAvailable(mockk()) - versionNotifications.value = listOf(unsupportedVersion, updateAvailable) + versionNotifications.value = listOf(unsupportedVersion) val accountExpiry = InAppNotification.AccountExpiry(DateTime.now()) accountExpiryNotifications.value = listOf(accountExpiry) @@ -93,7 +92,6 @@ class InAppNotificationControllerTest { unsupportedVersion, accountExpiry, newDevice, - updateAvailable, ), notifications ) diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt index 9d40f9715c..944ebc11a4 100644 --- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt +++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt @@ -23,10 +23,7 @@ class VersionNotificationUseCaseTest { private val mockAppVersionInfoRepository: AppVersionInfoRepository = mockk() - private val versionInfo = - MutableStateFlow( - VersionInfo(currentVersion = "", isSupported = true, suggestedUpgradeVersion = null) - ) + private val versionInfo = MutableStateFlow(VersionInfo(currentVersion = "", isSupported = true)) private lateinit var versionNotificationUseCase: VersionNotificationUseCase @BeforeEach @@ -53,28 +50,6 @@ class VersionNotificationUseCaseTest { } @Test - fun `when a new version is available use case should emit UpdateAvailable with new version`() = - runTest { - versionNotificationUseCase().test { - // Arrange, Act - val upgradeVersionInfo = - VersionInfo( - currentVersion = "1.0", - isSupported = true, - suggestedUpgradeVersion = "1.1" - ) - awaitItem() - versionInfo.value = upgradeVersionInfo - - // Assert - assertEquals( - awaitItem(), - listOf(InAppNotification.UpdateAvailable(upgradeVersionInfo)) - ) - } - } - - @Test fun `when an unsupported version use case should emit UnsupportedVersion notification`() = runTest { versionNotificationUseCase().test { @@ -83,7 +58,6 @@ class VersionNotificationUseCaseTest { VersionInfo( currentVersion = "1.0", isSupported = false, - suggestedUpgradeVersion = null ) awaitItem() versionInfo.value = upgradeVersionInfo diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModelTest.kt index c76e2cd278..416dd7c1a9 100644 --- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModelTest.kt +++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModelTest.kt @@ -26,9 +26,7 @@ class SettingsViewModelTest { private val mockAppVersionInfoRepository: AppVersionInfoRepository = mockk() private val versionInfo = - MutableStateFlow( - VersionInfo(currentVersion = "", isSupported = false, suggestedUpgradeVersion = null) - ) + MutableStateFlow(VersionInfo(currentVersion = "", isSupported = false)) private lateinit var viewModel: SettingsViewModel @@ -60,53 +58,30 @@ class SettingsViewModelTest { } @Test - fun `when AppVersionInfoCache returns isOutdated false uiState should return isUpdateAvailable false`() = + fun `when AppVersionInfoRepository returns isSupported true uiState should return isSupportedVersion true`() = runTest { // Arrange - val versionInfoTestItem = - VersionInfo( - currentVersion = "1.0", - isSupported = true, - suggestedUpgradeVersion = null - ) - - // Act, Assert - viewModel.uiState.test { - awaitItem() // Wait for initial value - - versionInfo.value = versionInfoTestItem - val result = awaitItem() - assertEquals(false, result.isUpdateAvailable) - } - } - - @Test - fun `when AppVersionInfoCache returns isSupported false uiState should return isUpdateAvailable true`() = - runTest { - // Arrange - val versionInfoTestItem = - VersionInfo(currentVersion = "", isSupported = false, suggestedUpgradeVersion = "") + val versionInfoTestItem = VersionInfo(currentVersion = "", isSupported = true) versionInfo.value = versionInfoTestItem // Act, Assert viewModel.uiState.test { val result = awaitItem() - assertEquals(true, result.isUpdateAvailable) + assertEquals(true, result.isSupportedVersion) } } @Test - fun `when AppVersionInfoCache returns isOutdated true uiState should return isUpdateAvailable true`() = + fun `when AppVersionInfoRepository returns isSupported false uiState should return isSupportedVersion false`() = runTest { // Arrange - val versionInfoTestItem = - VersionInfo(currentVersion = "", isSupported = true, suggestedUpgradeVersion = "") + val versionInfoTestItem = VersionInfo(currentVersion = "", isSupported = false) versionInfo.value = versionInfoTestItem // Act, Assert viewModel.uiState.test { val result = awaitItem() - assertEquals(true, result.isUpdateAvailable) + assertEquals(false, result.isSupportedVersion) } } } |
