From a984929ab268193a8569f6604e596ad46d0b7051 Mon Sep 17 00:00:00 2001 From: Jonatan Rhodin Date: Mon, 2 Sep 2024 16:03:43 +0200 Subject: [PATCH] Remove auto-connect feature from ui --- .../compose/screen/VpnSettingsScreenTest.kt | 6 ++--- ...SettingsUiStatePreviewParameterProvider.kt | 2 +- .../compose/screen/VpnSettingsScreen.kt | 25 ------------------- .../compose/state/VpnSettingsUiState.kt | 3 --- .../repository/SettingsRepository.kt | 2 -- .../viewmodel/VpnSettingsViewModel.kt | 9 ------- .../viewmodel/VpnSettingsViewModelState.kt | 3 --- .../lib/daemon/grpc/ManagementService.kt | 7 ------ .../lib/daemon/grpc/mapper/ToDomain.kt | 1 - .../lib/model/SetAutoConnectError.kt | 5 ---- .../mullvad/mullvadvpn/lib/model/Settings.kt | 1 - 11 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/SetAutoConnectError.kt diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreenTest.kt index 5c0c004036a8..42a939250216 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreenTest.kt @@ -528,7 +528,7 @@ class VpnSettingsScreenTest { // Arrange setContentWithTheme { VpnSettingsScreen( - state = VpnSettingsUiState.createDefault(systemVpnSettingsAvailable = false), + state = VpnSettingsUiState.createDefault(systemVpnSettingsAvailable = false) ) } @@ -546,9 +546,9 @@ class VpnSettingsScreenTest { state = VpnSettingsUiState.createDefault( systemVpnSettingsAvailable = false, - autoStartAndConnectOnBoot = false + autoStartAndConnectOnBoot = false, ), - onToggleAutoStartAndConnectOnBoot = mockOnToggleAutoStartAndConnectOnBoot + onToggleAutoStartAndConnectOnBoot = mockOnToggleAutoStartAndConnectOnBoot, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/VpnSettingsUiStatePreviewParameterProvider.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/VpnSettingsUiStatePreviewParameterProvider.kt index e583e6ea0ca6..c041f5516c52 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/VpnSettingsUiStatePreviewParameterProvider.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/VpnSettingsUiStatePreviewParameterProvider.kt @@ -19,7 +19,6 @@ class VpnSettingsUiStatePreviewParameterProvider : PreviewParameterProvider Unit = {}, onToggleBlockAds: (Boolean) -> Unit = {}, onToggleBlockMalware: (Boolean) -> Unit = {}, - onToggleAutoConnect: (Boolean) -> Unit = {}, onToggleLocalNetworkSharing: (Boolean) -> Unit = {}, onDisableDaita: () -> Unit = {}, onToggleBlockAdultContent: (Boolean) -> Unit = {}, @@ -332,28 +329,6 @@ fun VpnSettingsScreen( text = stringResource(id = R.string.auto_connect_and_lockdown_mode_footer) ) } - item { - Spacer(modifier = Modifier.height(Dimens.cellLabelVerticalPadding)) - HeaderSwitchComposeCell( - title = stringResource(R.string.auto_connect_legacy), - isToggled = state.isAutoConnectEnabled, - isEnabled = true, - onCellClicked = { newValue -> onToggleAutoConnect(newValue) }, - ) - } - item { - SwitchComposeSubtitleCell( - text = - HtmlCompat.fromHtml( - textResource( - R.string.auto_connect_footer_legacy, - textResource(R.string.auto_connect_and_lockdown_mode), - ), - HtmlCompat.FROM_HTML_MODE_COMPACT, - ) - .toAnnotatedString(boldFontWeight = FontWeight.ExtraBold) - ) - } } else { item { Spacer(modifier = Modifier.height(Dimens.cellLabelVerticalPadding)) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/VpnSettingsUiState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/VpnSettingsUiState.kt index 4c5f2c2ffb3f..eede76ff7c01 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/VpnSettingsUiState.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/VpnSettingsUiState.kt @@ -11,7 +11,6 @@ import net.mullvad.mullvadvpn.viewmodel.CustomDnsItem data class VpnSettingsUiState( val mtu: Mtu?, - val isAutoConnectEnabled: Boolean, val isLocalNetworkSharingEnabled: Boolean, val isDaitaEnabled: Boolean, val isCustomDnsEnabled: Boolean, @@ -34,7 +33,6 @@ data class VpnSettingsUiState( companion object { fun createDefault( mtu: Mtu? = null, - isAutoConnectEnabled: Boolean = false, isLocalNetworkSharingEnabled: Boolean = false, isDaitaEnabled: Boolean = false, isCustomDnsEnabled: Boolean = false, @@ -52,7 +50,6 @@ data class VpnSettingsUiState( ) = VpnSettingsUiState( mtu, - isAutoConnectEnabled, isLocalNetworkSharingEnabled, isDaitaEnabled, isCustomDnsEnabled, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/SettingsRepository.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/SettingsRepository.kt index 0fa5e69940dd..8be8d2ae7ed2 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/SettingsRepository.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/SettingsRepository.kt @@ -68,8 +68,6 @@ class SettingsRepository( suspend fun setObfuscation(value: ObfuscationMode) = managementService.setObfuscation(value) - suspend fun setAutoConnect(isEnabled: Boolean) = managementService.setAutoConnect(isEnabled) - suspend fun setLocalNetworkSharing(isEnabled: Boolean) = managementService.setAllowLan(isEnabled) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModel.kt index ec73067687be..7829d0ce24cc 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModel.kt @@ -65,7 +65,6 @@ class VpnSettingsViewModel( ) { settings, portRanges, customWgPort, autoStartAndConnectOnBoot -> VpnSettingsViewModelState( mtuValue = settings?.tunnelOptions?.wireguard?.mtu, - isAutoConnectEnabled = settings?.autoConnect ?: false, isLocalNetworkSharingEnabled = settings?.allowLan ?: false, isDaitaEnabled = settings?.isDaitaEnabled() ?: false, isCustomDnsEnabled = settings?.isCustomDnsEnabled() ?: false, @@ -114,14 +113,6 @@ class VpnSettingsViewModel( } } - fun onToggleAutoConnect(isEnabled: Boolean) { - viewModelScope.launch(dispatcher) { - repository.setAutoConnect(isEnabled).onLeft { - _uiSideEffect.send(VpnSettingsSideEffect.ShowToast.GenericError) - } - } - } - fun onToggleLocalNetworkSharing(isEnabled: Boolean) { viewModelScope.launch(dispatcher) { repository.setLocalNetworkSharing(isEnabled).onLeft { diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModelState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModelState.kt index 4798a8a91b95..624716198d6f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModelState.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModelState.kt @@ -11,7 +11,6 @@ import net.mullvad.mullvadvpn.lib.model.QuantumResistantState data class VpnSettingsViewModelState( val mtuValue: Mtu?, - val isAutoConnectEnabled: Boolean, val isLocalNetworkSharingEnabled: Boolean, val isDaitaEnabled: Boolean, val isCustomDnsEnabled: Boolean, @@ -34,7 +33,6 @@ data class VpnSettingsViewModelState( fun toUiState(): VpnSettingsUiState = VpnSettingsUiState( mtuValue, - isAutoConnectEnabled, isLocalNetworkSharingEnabled, isDaitaEnabled, isCustomDnsEnabled, @@ -55,7 +53,6 @@ data class VpnSettingsViewModelState( fun default() = VpnSettingsViewModelState( mtuValue = null, - isAutoConnectEnabled = false, isLocalNetworkSharingEnabled = false, isDaitaEnabled = false, isCustomDnsEnabled = false, diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt index 514d4f83aa6b..3ffbe0fc4a2e 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt @@ -103,7 +103,6 @@ import net.mullvad.mullvadvpn.lib.model.RemoveApiAccessMethodError import net.mullvad.mullvadvpn.lib.model.RemoveSplitTunnelingAppError import net.mullvad.mullvadvpn.lib.model.SetAllowLanError import net.mullvad.mullvadvpn.lib.model.SetApiAccessMethodError -import net.mullvad.mullvadvpn.lib.model.SetAutoConnectError import net.mullvad.mullvadvpn.lib.model.SetDaitaSettingsError import net.mullvad.mullvadvpn.lib.model.SetDnsOptionsError import net.mullvad.mullvadvpn.lib.model.SetObfuscationOptionsError @@ -502,12 +501,6 @@ class ManagementService( .mapLeft(SetObfuscationOptionsError::Unknown) .mapEmpty() - suspend fun setAutoConnect(isEnabled: Boolean): Either = - Either.catch { grpc.setAutoConnect(BoolValue.of(isEnabled)) } - .onLeft { Logger.e("Set auto connect error") } - .mapLeft(SetAutoConnectError::Unknown) - .mapEmpty() - suspend fun setAllowLan(allow: Boolean): Either = Either.catch { grpc.setAllowLan(BoolValue.of(allow)) } .onLeft { Logger.e("Set allow lan error") } diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt index 0f57ce58dc99..99b4554f0b2c 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt @@ -254,7 +254,6 @@ internal fun ManagementInterface.Settings.toDomain(): Settings = obfuscationSettings = obfuscationSettings.toDomain(), customLists = customLists.customListsList.map { it.toDomain() }, allowLan = allowLan, - autoConnect = autoConnect, tunnelOptions = tunnelOptions.toDomain(), relayOverrides = relayOverridesList.map { it.toDomain() }, showBetaReleases = showBetaReleases, diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/SetAutoConnectError.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/SetAutoConnectError.kt deleted file mode 100644 index b2b3b74edf36..000000000000 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/SetAutoConnectError.kt +++ /dev/null @@ -1,5 +0,0 @@ -package net.mullvad.mullvadvpn.lib.model - -sealed interface SetAutoConnectError { - data class Unknown(val throwable: Throwable) : SetAutoConnectError -} diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/Settings.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/Settings.kt index f59d85184cfd..b3f1a2e8a071 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/Settings.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/Settings.kt @@ -8,7 +8,6 @@ data class Settings( val obfuscationSettings: ObfuscationSettings, val customLists: List, val allowLan: Boolean, - val autoConnect: Boolean, val tunnelOptions: TunnelOptions, val relayOverrides: List, val showBetaReleases: Boolean,