Skip to content

Commit

Permalink
Remove update available message
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-mullvad committed Jul 1, 2024
1 parent ab4f5b3 commit 63d6dd5
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -597,40 +597,6 @@ 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SettingsScreenTest {
SettingsUiState(
appVersion = "",
isLoggedIn = true,
isUpdateAvailable = true,
isUnsupportedVersion = false,
isPlayBuild = false
),
)
Expand All @@ -54,7 +54,7 @@ class SettingsScreenTest {
SettingsUiState(
appVersion = "",
isLoggedIn = false,
isUpdateAvailable = true,
isUnsupportedVersion = false,
isPlayBuild = false
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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 = ""
)
}
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.mullvad.mullvadvpn.compose.screen

import android.util.Log
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -32,6 +33,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.compose.dropUnlessResumed
import co.touchlab.kermit.Logger
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootGraph
import com.ramcosta.composedestinations.generated.destinations.LoginDestination
Expand Down Expand Up @@ -160,6 +162,8 @@ fun DeviceList(
onTryAgainClicked = viewModel::fetchDevices,
navigateToRemoveDeviceConfirmationDialog =
dropUnlessResumed<Device> {
//Logger.i("DeviceList: remove device: $it")
Log.d("mullvad", "DeviceList: remove device: $it")
navigator.navigate(RemoveDeviceConfirmationDialogDestination(it))
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private fun PreviewSettings() {
SettingsUiState(
appVersion = "2222.22",
isLoggedIn = true,
isUpdateAvailable = true,
isUnsupportedVersion = true,
isPlayBuild = false
),
)
Expand Down Expand Up @@ -172,13 +172,13 @@ private fun AppVersion(context: Context, state: SettingsUiState) {
)
}
},
showWarning = state.isUpdateAvailable,
showWarning = state.isUnsupportedVersion,
isRowEnabled = !state.isPlayBuild
)

if (state.isUpdateAvailable) {
if (state.isUnsupportedVersion) {
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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package net.mullvad.mullvadvpn.compose.state
data class SettingsUiState(
val appVersion: String,
val isLoggedIn: Boolean,
val isUpdateAvailable: Boolean,
val isUnsupportedVersion: Boolean,
val isPlayBuild: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ data class VersionInfo(
val currentVersion: String,
val isSupported: Boolean,
val suggestedUpgradeVersion: String?
) {
val isUpdateAvailable: Boolean = suggestedUpgradeVersion != null
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,11 @@ class VersionNotificationUseCase(
.versionInfo()
.map { versionInfo ->
listOfNotNull(
unsupportedVersionNotification(versionInfo),
updateAvailableNotification(versionInfo)
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class SettingsViewModel(
SettingsUiState(
isLoggedIn = deviceState is DeviceState.LoggedIn,
appVersion = versionInfo.currentVersion,
isUpdateAvailable =
versionInfo.let { it.isSupported.not() || it.isUpdateAvailable },
isUnsupportedVersion = versionInfo.isSupported.not(),
isPlayBuild = isPlayBuild
)
}
Expand All @@ -35,7 +34,7 @@ class SettingsViewModel(
SettingsUiState(
appVersion = "",
isLoggedIn = false,
isUpdateAvailable = false,
isUnsupportedVersion = false,
isPlayBuild
)
)
Expand All @@ -47,7 +46,7 @@ class SettingsViewModel(
SettingsUiState(
appVersion = "",
isLoggedIn = false,
isUpdateAvailable = false,
isUnsupportedVersion = false,
isPlayBuild
)
)
Expand Down
2 changes: 0 additions & 2 deletions android/lib/resource/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@
<string name="custom_tunnel_host_resolution_error">Unable to resolve host of custom tunnel. Try changing your settings.</string>
<string name="is_offline">Your device is offline. The tunnel will automatically connect once your device is back online.</string>
<string name="virtual_adapter_problem">Virtual adapter error</string>
<string name="update_available">UPDATE AVAILABLE</string>
<string name="update_available_description">Install Mullvad VPN (%1$s) to stay up to date</string>
<string name="unsupported_version">UNSUPPORTED VERSION</string>
<string name="unsupported_version_description">Your privacy might be at risk with this unsupported app version. Please update now.</string>
<string name="unsupported_version_without_upgrade">You are running an unsupported app version.</string>
Expand Down

0 comments on commit 63d6dd5

Please sign in to comment.