Skip to content

Commit

Permalink
Add social media to content blockers
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Oct 2, 2023
1 parent 76a67da commit fbfa7cb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private fun PreviewVpnSettings() {
onToggleBlockMalware = {},
onToggleBlockAdultContent = {},
onToggleBlockGambling = {},
onToggleBlockSocialMedia = {},
onDnsClick = {},
onDnsInputChange = {},
onSaveDnsClick = {},
Expand Down Expand Up @@ -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 = {},
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
<string name="malware_info">Warning: The malware blocker is not an anti-virus and should not be treated as such, this is just an extra layer of protection.</string>
<string name="block_gambling_title">Gambling</string>
<string name="block_adult_content_title">Adult content</string>
<string name="block_social_media_title">Social media</string>
<string name="dns_content_blockers_subtitle">
<![CDATA[Disable <b>%s</b> below to activate these settings.]]>
</string>
Expand Down
3 changes: 3 additions & 0 deletions gui/locales/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1833,3 +1833,6 @@ msgid "an hour ago"
msgid_plural "%d hours ago"
msgstr[0] ""
msgstr[1] ""

msgid "Social media"
msgstr ""

0 comments on commit fbfa7cb

Please sign in to comment.