From fbfa7cb5a8f7158bd21fda8ac31411024e2bdc60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Thu, 28 Sep 2023 15:42:29 +0200 Subject: [PATCH] Add social media to content blockers --- .../mullvadvpn/compose/screen/VpnSettingsScreen.kt | 13 +++++++++++++ .../mullvadvpn/ui/fragment/VpnSettingsFragment.kt | 1 + .../mullvadvpn/viewmodel/VpnSettingsViewModel.kt | 7 +++++++ .../lib/resource/src/main/res/values/strings.xml | 1 + gui/locales/messages.pot | 3 +++ 5 files changed, 25 insertions(+) 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 3ff4719b59af..41751ad02ded 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 @@ -113,6 +113,7 @@ private fun PreviewVpnSettings() { onToggleBlockMalware = {}, onToggleBlockAdultContent = {}, onToggleBlockGambling = {}, + onToggleBlockSocialMedia = {}, onDnsClick = {}, onDnsInputChange = {}, onSaveDnsClick = {}, @@ -156,6 +157,7 @@ fun VpnSettingsScreen( onToggleBlockMalware: (Boolean) -> Unit = {}, onToggleBlockAdultContent: (Boolean) -> Unit = {}, onToggleBlockGambling: (Boolean) -> Unit = {}, + onToggleBlockSocialMedia: (Boolean) -> Unit = {}, onDnsClick: (index: Int?) -> Unit = {}, onDnsInputChange: (String) -> Unit = {}, onSaveDnsClick: () -> Unit = {}, @@ -396,6 +398,17 @@ fun VpnSettingsScreen( ) } + itemWithDivider { + NormalSwitchComposeCell( + title = stringResource(R.string.block_social_media_title), + isToggled = uiState.contentBlockersOptions.blockSocialMedia, + isEnabled = !uiState.isCustomDnsEnabled, + onCellClicked = { onToggleBlockSocialMedia(it) }, + background = MaterialTheme.colorScheme.secondaryContainer, + startPadding = Dimens.indentedCellStartPadding + ) + } + if (uiState.isCustomDnsEnabled) { item { ContentBlockersDisableModeCellSubtitle( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/VpnSettingsFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/VpnSettingsFragment.kt index bf799d887a7c..e3ed6c469dbd 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/VpnSettingsFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/VpnSettingsFragment.kt @@ -38,6 +38,7 @@ class VpnSettingsFragment : BaseFragment() { onToggleBlockMalware = vm::onToggleBlockMalware, onToggleBlockAdultContent = vm::onToggleBlockAdultContent, onToggleBlockGambling = vm::onToggleBlockGambling, + onToggleBlockSocialMedia = vm::onToggleBlockSocialMedia, onDnsClick = vm::onDnsClick, onDnsInputChange = vm::onDnsInputChange, onSaveDnsClick = vm::onSaveDnsClick, 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 7d3344d9487d..2c8e30f2b479 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 @@ -290,6 +290,13 @@ class VpnSettingsViewModel( showApplySettingChangesWarningToast() } + fun onToggleBlockSocialMedia(isEnabled: Boolean) { + updateDefaultDnsOptionsViaRepository( + vmState.value.contentBlockersOptions.copy(blockSocialMedia = isEnabled) + ) + showApplySettingChangesWarningToast() + } + fun onRemoveDnsClick() = viewModelScope.launch(dispatcher) { val dialog = diff --git a/android/lib/resource/src/main/res/values/strings.xml b/android/lib/resource/src/main/res/values/strings.xml index 6b1486fe5623..988b343c19a2 100644 --- a/android/lib/resource/src/main/res/values/strings.xml +++ b/android/lib/resource/src/main/res/values/strings.xml @@ -180,6 +180,7 @@ Warning: The malware blocker is not an anti-virus and should not be treated as such, this is just an extra layer of protection. Gambling Adult content + Social media %s below to activate these settings.]]> diff --git a/gui/locales/messages.pot b/gui/locales/messages.pot index 26035a4321a8..13a9d8d9112d 100644 --- a/gui/locales/messages.pot +++ b/gui/locales/messages.pot @@ -1833,3 +1833,6 @@ msgid "an hour ago" msgid_plural "%d hours ago" msgstr[0] "" msgstr[1] "" + +msgid "Social media" +msgstr ""