Skip to content

Commit 73bba2c

Browse files
committed
Merge branch 'only-show-unsupported-version-in-settings-droid-1103'
2 parents 6fcf6e0 + a6d23d4 commit 73bba2c

File tree

36 files changed

+26
-216
lines changed

36 files changed

+26
-216
lines changed

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

+2-46
Original file line numberDiff line numberDiff line change
@@ -597,50 +597,11 @@ class ConnectScreenTest {
597597
}
598598
}
599599

600-
@Test
601-
fun testOutdatedVersionNotification() {
602-
composeExtension.use {
603-
// Arrange
604-
val versionInfo =
605-
VersionInfo(
606-
currentVersion = "1.0",
607-
isSupported = true,
608-
suggestedUpgradeVersion = "1.1"
609-
)
610-
setContentWithTheme {
611-
ConnectScreen(
612-
state =
613-
ConnectUiState(
614-
location = null,
615-
selectedRelayItemTitle = null,
616-
tunnelState = TunnelState.Connecting(null, null),
617-
inAddress = null,
618-
outAddress = "",
619-
showLocation = false,
620-
deviceName = "",
621-
daysLeftUntilExpiry = null,
622-
inAppNotification = InAppNotification.UpdateAvailable(versionInfo),
623-
isPlayBuild = false
624-
),
625-
)
626-
}
627-
628-
// Assert
629-
onNodeWithText("UPDATE AVAILABLE").assertExists()
630-
onNodeWithText("Install Mullvad VPN (1.1) to stay up to date").assertExists()
631-
}
632-
}
633-
634600
@Test
635601
fun testUnsupportedVersionNotification() {
636602
composeExtension.use {
637603
// Arrange
638-
val versionInfo =
639-
VersionInfo(
640-
currentVersion = "1.0",
641-
isSupported = false,
642-
suggestedUpgradeVersion = "1.1"
643-
)
604+
val versionInfo = VersionInfo(currentVersion = "1.0", isSupported = false)
644605
setContentWithTheme {
645606
ConnectScreen(
646607
state =
@@ -702,12 +663,7 @@ class ConnectScreenTest {
702663
composeExtension.use {
703664
// Arrange
704665
val mockedClickHandler: () -> Unit = mockk(relaxed = true)
705-
val versionInfo =
706-
VersionInfo(
707-
isSupported = false,
708-
currentVersion = "",
709-
suggestedUpgradeVersion = "1.1"
710-
)
666+
val versionInfo = VersionInfo(isSupported = false, currentVersion = "")
711667
setContentWithTheme {
712668
ConnectScreen(
713669
onUpdateVersionClick = mockedClickHandler,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SettingsScreenTest {
3131
SettingsUiState(
3232
appVersion = "",
3333
isLoggedIn = true,
34-
isUpdateAvailable = true,
34+
isSupportedVersion = true,
3535
isPlayBuild = false
3636
),
3737
)
@@ -54,7 +54,7 @@ class SettingsScreenTest {
5454
SettingsUiState(
5555
appVersion = "",
5656
isLoggedIn = false,
57-
isUpdateAvailable = true,
57+
isSupportedVersion = true,
5858
isPlayBuild = false
5959
),
6060
)

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import androidx.compose.ui.Alignment
1414
import androidx.compose.ui.Modifier
1515
import androidx.compose.ui.graphics.Color
1616
import androidx.compose.ui.res.painterResource
17-
import androidx.compose.ui.res.stringResource
1817
import androidx.compose.ui.text.style.TextOverflow
1918
import androidx.compose.ui.tooling.preview.Preview
2019
import net.mullvad.mullvadvpn.R
@@ -95,7 +94,7 @@ internal fun NavigationTitleView(
9594
Image(
9695
painter = painterResource(id = R.drawable.icon_alert),
9796
modifier = Modifier.padding(end = Dimens.smallPadding),
98-
contentDescription = stringResource(id = R.string.update_available)
97+
contentDescription = null
9998
)
10099
}
101100
Text(

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt

+1-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@ private fun PreviewNotificationBanner() {
5050
val bannerDataList =
5151
listOf(
5252
InAppNotification.UnsupportedVersion(
53-
versionInfo =
54-
VersionInfo(
55-
currentVersion = "1.0",
56-
isSupported = false,
57-
suggestedUpgradeVersion = null
58-
),
53+
versionInfo = VersionInfo(currentVersion = "1.0", isSupported = false),
5954
),
6055
InAppNotification.AccountExpiry(expiry = DateTime.now()),
6156
InAppNotification.TunnelStateBlocked,

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationData.kt

-13
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,6 @@ fun InAppNotification.toNotificationData(
9393
if (isPlayBuild) null
9494
else NotificationAction(R.drawable.icon_extlink, onClickUpdateVersion)
9595
)
96-
is InAppNotification.UpdateAvailable ->
97-
NotificationData(
98-
title = stringResource(id = R.string.update_available),
99-
message =
100-
stringResource(
101-
id = R.string.update_available_description,
102-
versionInfo.suggestedUpgradeVersion ?: ""
103-
),
104-
statusLevel = StatusLevel.Warning,
105-
action =
106-
if (isPlayBuild) null
107-
else NotificationAction(R.drawable.icon_extlink, onClickUpdateVersion)
108-
)
10996
}
11097

11198
@Composable

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private fun PreviewSettings() {
5454
SettingsUiState(
5555
appVersion = "2222.22",
5656
isLoggedIn = true,
57-
isUpdateAvailable = true,
57+
isSupportedVersion = true,
5858
isPlayBuild = false
5959
),
6060
)
@@ -172,13 +172,13 @@ private fun AppVersion(context: Context, state: SettingsUiState) {
172172
)
173173
}
174174
},
175-
showWarning = state.isUpdateAvailable,
175+
showWarning = !state.isSupportedVersion,
176176
isRowEnabled = !state.isPlayBuild
177177
)
178178

179-
if (state.isUpdateAvailable) {
179+
if (!state.isSupportedVersion) {
180180
Text(
181-
text = stringResource(id = R.string.update_available_footer),
181+
text = stringResource(id = R.string.unsupported_version_description),
182182
style = MaterialTheme.typography.labelMedium,
183183
color = MaterialTheme.colorScheme.onSecondary,
184184
modifier =

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SettingsUiState.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package net.mullvad.mullvadvpn.compose.state
33
data class SettingsUiState(
44
val appVersion: String,
55
val isLoggedIn: Boolean,
6-
val isUpdateAvailable: Boolean,
6+
val isSupportedVersion: Boolean,
77
val isPlayBuild: Boolean
88
)

android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/InAppNotificationController.kt

-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ sealed class InAppNotification {
4747
override val statusLevel = StatusLevel.Info
4848
override val priority: Long = 1001
4949
}
50-
51-
data class UpdateAvailable(val versionInfo: VersionInfo) : InAppNotification() {
52-
override val statusLevel = StatusLevel.Info
53-
override val priority: Long = 1000
54-
}
5550
}
5651

5752
class InAppNotificationController(
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
package net.mullvad.mullvadvpn.ui
22

3-
data class VersionInfo(
4-
val currentVersion: String,
5-
val isSupported: Boolean,
6-
val suggestedUpgradeVersion: String?
7-
) {
8-
val isUpdateAvailable: Boolean = suggestedUpgradeVersion != null
9-
}
3+
data class VersionInfo(val currentVersion: String, val isSupported: Boolean)

android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AppVersionInfoRepository.kt

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ class AppVersionInfoRepository(
1212
) {
1313
fun versionInfo(): Flow<VersionInfo> =
1414
managementService.versionInfo.map { appVersionInfo ->
15-
VersionInfo(
16-
currentVersion = buildVersion.name,
17-
isSupported = appVersionInfo.supported,
18-
suggestedUpgradeVersion = appVersionInfo.suggestedUpgrade,
19-
)
15+
VersionInfo(currentVersion = buildVersion.name, isSupported = appVersionInfo.supported)
2016
}
2117
}

android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCase.kt

+1-16
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,9 @@ class VersionNotificationUseCase(
1414
operator fun invoke() =
1515
appVersionInfoRepository
1616
.versionInfo()
17-
.map { versionInfo ->
18-
listOfNotNull(
19-
unsupportedVersionNotification(versionInfo),
20-
updateAvailableNotification(versionInfo)
21-
)
22-
}
17+
.map { versionInfo -> listOfNotNull(unsupportedVersionNotification(versionInfo)) }
2318
.distinctUntilChanged()
2419

25-
private fun updateAvailableNotification(versionInfo: VersionInfo): InAppNotification? {
26-
if (!isVersionInfoNotificationEnabled) {
27-
return null
28-
}
29-
30-
return if (versionInfo.isUpdateAvailable) {
31-
InAppNotification.UpdateAvailable(versionInfo)
32-
} else null
33-
}
34-
3520
private fun unsupportedVersionNotification(versionInfo: VersionInfo): InAppNotification? {
3621
if (!isVersionInfoNotificationEnabled) {
3722
return null

android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModel.kt

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class SettingsViewModel(
2424
SettingsUiState(
2525
isLoggedIn = deviceState is DeviceState.LoggedIn,
2626
appVersion = versionInfo.currentVersion,
27-
isUpdateAvailable =
28-
versionInfo.let { it.isSupported.not() || it.isUpdateAvailable },
27+
isSupportedVersion = versionInfo.isSupported,
2928
isPlayBuild = isPlayBuild
3029
)
3130
}
@@ -35,7 +34,7 @@ class SettingsViewModel(
3534
SettingsUiState(
3635
appVersion = "",
3736
isLoggedIn = false,
38-
isUpdateAvailable = false,
37+
isSupportedVersion = true,
3938
isPlayBuild
4039
)
4140
)
@@ -47,7 +46,7 @@ class SettingsViewModel(
4746
SettingsUiState(
4847
appVersion = "",
4948
isLoggedIn = false,
50-
isUpdateAvailable = false,
49+
isSupportedVersion = true,
5150
isPlayBuild
5251
)
5352
)

android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ class InAppNotificationControllerTest {
7777
tunnelStateNotifications.value = listOf(tunnelStateBlocked, tunnelStateError)
7878

7979
val unsupportedVersion = InAppNotification.UnsupportedVersion(mockk())
80-
val updateAvailable = InAppNotification.UpdateAvailable(mockk())
81-
versionNotifications.value = listOf(unsupportedVersion, updateAvailable)
80+
versionNotifications.value = listOf(unsupportedVersion)
8281

8382
val accountExpiry = InAppNotification.AccountExpiry(DateTime.now())
8483
accountExpiryNotifications.value = listOf(accountExpiry)
@@ -93,7 +92,6 @@ class InAppNotificationControllerTest {
9392
unsupportedVersion,
9493
accountExpiry,
9594
newDevice,
96-
updateAvailable,
9795
),
9896
notifications
9997
)

android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt

+1-27
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ class VersionNotificationUseCaseTest {
2323

2424
private val mockAppVersionInfoRepository: AppVersionInfoRepository = mockk()
2525

26-
private val versionInfo =
27-
MutableStateFlow(
28-
VersionInfo(currentVersion = "", isSupported = true, suggestedUpgradeVersion = null)
29-
)
26+
private val versionInfo = MutableStateFlow(VersionInfo(currentVersion = "", isSupported = true))
3027
private lateinit var versionNotificationUseCase: VersionNotificationUseCase
3128

3229
@BeforeEach
@@ -52,28 +49,6 @@ class VersionNotificationUseCaseTest {
5249
versionNotificationUseCase().test { assertTrue { awaitItem().isEmpty() } }
5350
}
5451

55-
@Test
56-
fun `when a new version is available use case should emit UpdateAvailable with new version`() =
57-
runTest {
58-
versionNotificationUseCase().test {
59-
// Arrange, Act
60-
val upgradeVersionInfo =
61-
VersionInfo(
62-
currentVersion = "1.0",
63-
isSupported = true,
64-
suggestedUpgradeVersion = "1.1"
65-
)
66-
awaitItem()
67-
versionInfo.value = upgradeVersionInfo
68-
69-
// Assert
70-
assertEquals(
71-
awaitItem(),
72-
listOf(InAppNotification.UpdateAvailable(upgradeVersionInfo))
73-
)
74-
}
75-
}
76-
7752
@Test
7853
fun `when an unsupported version use case should emit UnsupportedVersion notification`() =
7954
runTest {
@@ -83,7 +58,6 @@ class VersionNotificationUseCaseTest {
8358
VersionInfo(
8459
currentVersion = "1.0",
8560
isSupported = false,
86-
suggestedUpgradeVersion = null
8761
)
8862
awaitItem()
8963
versionInfo.value = upgradeVersionInfo

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

+7-32
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ class SettingsViewModelTest {
2626
private val mockAppVersionInfoRepository: AppVersionInfoRepository = mockk()
2727

2828
private val versionInfo =
29-
MutableStateFlow(
30-
VersionInfo(currentVersion = "", isSupported = false, suggestedUpgradeVersion = null)
31-
)
29+
MutableStateFlow(VersionInfo(currentVersion = "", isSupported = false))
3230

3331
private lateinit var viewModel: SettingsViewModel
3432

@@ -60,53 +58,30 @@ class SettingsViewModelTest {
6058
}
6159

6260
@Test
63-
fun `when AppVersionInfoCache returns isOutdated false uiState should return isUpdateAvailable false`() =
61+
fun `when AppVersionInfoRepository returns isSupported true uiState should return isSupportedVersion true`() =
6462
runTest {
6563
// Arrange
66-
val versionInfoTestItem =
67-
VersionInfo(
68-
currentVersion = "1.0",
69-
isSupported = true,
70-
suggestedUpgradeVersion = null
71-
)
72-
73-
// Act, Assert
74-
viewModel.uiState.test {
75-
awaitItem() // Wait for initial value
76-
77-
versionInfo.value = versionInfoTestItem
78-
val result = awaitItem()
79-
assertEquals(false, result.isUpdateAvailable)
80-
}
81-
}
82-
83-
@Test
84-
fun `when AppVersionInfoCache returns isSupported false uiState should return isUpdateAvailable true`() =
85-
runTest {
86-
// Arrange
87-
val versionInfoTestItem =
88-
VersionInfo(currentVersion = "", isSupported = false, suggestedUpgradeVersion = "")
64+
val versionInfoTestItem = VersionInfo(currentVersion = "", isSupported = true)
8965
versionInfo.value = versionInfoTestItem
9066

9167
// Act, Assert
9268
viewModel.uiState.test {
9369
val result = awaitItem()
94-
assertEquals(true, result.isUpdateAvailable)
70+
assertEquals(true, result.isSupportedVersion)
9571
}
9672
}
9773

9874
@Test
99-
fun `when AppVersionInfoCache returns isOutdated true uiState should return isUpdateAvailable true`() =
75+
fun `when AppVersionInfoRepository returns isSupported false uiState should return isSupportedVersion false`() =
10076
runTest {
10177
// Arrange
102-
val versionInfoTestItem =
103-
VersionInfo(currentVersion = "", isSupported = true, suggestedUpgradeVersion = "")
78+
val versionInfoTestItem = VersionInfo(currentVersion = "", isSupported = false)
10479
versionInfo.value = versionInfoTestItem
10580

10681
// Act, Assert
10782
viewModel.uiState.test {
10883
val result = awaitItem()
109-
assertEquals(true, result.isUpdateAvailable)
84+
assertEquals(false, result.isSupportedVersion)
11085
}
11186
}
11287
}

0 commit comments

Comments
 (0)