From 1694f4c57a683ca61241b52324956107bfe58dcf 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 ++--- .../compose/screen/VpnSettingsScreen.kt | 26 ------------------- .../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 - 10 files changed, 3 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 d30c55a1150d..5844f638bd78 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 @@ -603,7 +603,7 @@ class VpnSettingsScreenTest { // Arrange setContentWithTheme { VpnSettingsScreen( - state = VpnSettingsUiState.createDefault(systemVpnSettingsAvailable = false), + state = VpnSettingsUiState.createDefault(systemVpnSettingsAvailable = false) ) } @@ -621,9 +621,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/screen/VpnSettingsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt index 8d8c6c7a77e4..ee57fbbf3602 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt @@ -116,7 +116,6 @@ private fun PreviewVpnSettings() { VpnSettingsScreen( state = VpnSettingsUiState.createDefault( - isAutoConnectEnabled = true, mtu = Mtu(1337), isCustomDnsEnabled = true, customDnsItems = listOf(CustomDnsItem("0.0.0.0", false)), @@ -125,7 +124,6 @@ private fun PreviewVpnSettings() { onToggleBlockTrackers = {}, onToggleBlockAds = {}, onToggleBlockMalware = {}, - onToggleAutoConnect = {}, onToggleLocalNetworkSharing = {}, onToggleBlockAdultContent = {}, onToggleBlockGambling = {}, @@ -241,7 +239,6 @@ fun VpnSettings( onToggleBlockTrackers = vm::onToggleBlockTrackers, onToggleBlockAds = vm::onToggleBlockAds, onToggleBlockMalware = vm::onToggleBlockMalware, - onToggleAutoConnect = vm::onToggleAutoConnect, onToggleLocalNetworkSharing = vm::onToggleLocalNetworkSharing, onDisableDaita = { vm.onToggleDaita(false) }, onToggleBlockAdultContent = vm::onToggleBlockAdultContent, @@ -294,7 +291,6 @@ fun VpnSettingsScreen( onToggleBlockTrackers: (Boolean) -> Unit = {}, onToggleBlockAds: (Boolean) -> Unit = {}, onToggleBlockMalware: (Boolean) -> Unit = {}, - onToggleAutoConnect: (Boolean) -> Unit = {}, onToggleLocalNetworkSharing: (Boolean) -> Unit = {}, onDisableDaita: () -> Unit = {}, onToggleBlockAdultContent: (Boolean) -> Unit = {}, @@ -337,28 +333,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 9ea3b07be83f..f544535da1ec 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, @@ -31,7 +30,6 @@ data class VpnSettingsUiState( companion object { fun createDefault( mtu: Mtu? = null, - isAutoConnectEnabled: Boolean = false, isLocalNetworkSharingEnabled: Boolean = false, isDaitaEnabled: Boolean = false, isCustomDnsEnabled: Boolean = false, @@ -48,7 +46,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 d66d4a5c009c..8a35a426ba75 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 @@ -64,8 +64,6 @@ class SettingsRepository( suspend fun setObfuscation(value: SelectedObfuscation) = 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 080a99ae380e..b722e5412dd5 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, @@ -113,14 +112,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 b81a0b198825..eb7035aa38e7 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.SelectedObfuscation data class VpnSettingsViewModelState( val mtuValue: Mtu?, - val isAutoConnectEnabled: Boolean, val isLocalNetworkSharingEnabled: Boolean, val isDaitaEnabled: Boolean, val isCustomDnsEnabled: Boolean, @@ -29,7 +28,6 @@ data class VpnSettingsViewModelState( fun toUiState(): VpnSettingsUiState = VpnSettingsUiState( mtuValue, - isAutoConnectEnabled, isLocalNetworkSharingEnabled, isDaitaEnabled, isCustomDnsEnabled, @@ -49,7 +47,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 f444edce39f3..a41d97c4d518 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.RemoveSplitTunnelingAppError import net.mullvad.mullvadvpn.lib.model.SelectedObfuscation 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 @@ -490,12 +489,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 1ff297312bec..5416b9806ab3 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 @@ -253,7 +253,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,