diff --git a/app/src/main/java/com/jerboa/db/AppDB.kt b/app/src/main/java/com/jerboa/db/AppDB.kt index d09b1c794..0b2470d43 100644 --- a/app/src/main/java/com/jerboa/db/AppDB.kt +++ b/app/src/main/java/com/jerboa/db/AppDB.kt @@ -32,7 +32,7 @@ val APP_SETTINGS_DEFAULT = AppSettings( useCustomTabs = true, usePrivateTabs = false, secureWindow = false, - blurNSFW = true, + blurNSFW = 1, showTextDescriptionsInNavbar = true, backConfirmationMode = 1, markAsReadOnScroll = false, diff --git a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt index 9d9a0b0d8..78ac66a29 100644 --- a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt +++ b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt @@ -87,7 +87,7 @@ data class AppSettings( name = "blur_nsfw", defaultValue = "1", ) - val blurNSFW: Boolean, + val blurNSFW: Int, @ColumnInfo( name = "show_text_descriptions_in_navbar", defaultValue = "1", diff --git a/app/src/main/java/com/jerboa/feat/BlurTypes.kt b/app/src/main/java/com/jerboa/feat/BlurTypes.kt new file mode 100644 index 000000000..75885e8b0 --- /dev/null +++ b/app/src/main/java/com/jerboa/feat/BlurTypes.kt @@ -0,0 +1,35 @@ +package com.jerboa.feat + +import android.os.Parcelable +import androidx.annotation.StringRes +import com.jerboa.R +import com.jerboa.datatypes.types.PostView +import com.jerboa.toEnum +import kotlinx.parcelize.Parcelize + +@Parcelize +enum class BlurTypes(@StringRes val resId: Int) : Parcelable { + Nothing(R.string.app_settings_nothing), + NSFW(R.string.app_settings_blur_nsfw), + NsfwExceptFromNsfwCommunities(R.string.app_settings_blur_nsfw_except_from_nsfw_communities), + ; + + companion object { + fun changeBlurTypeInsideCommunity(blurTypes: Int): Int = + if (blurTypes.toEnum() == NsfwExceptFromNsfwCommunities) { + Nothing.ordinal + } else { + blurTypes + } + } +} + +fun BlurTypes.needBlur(postView: PostView) = + this.needBlur(postView.community.nsfw, postView.post.nsfw) + +fun BlurTypes.needBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean { + return when (this) { + BlurTypes.Nothing -> false + BlurTypes.NSFW, BlurTypes.NsfwExceptFromNsfwCommunities -> isPostNsfw + } +} diff --git a/app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt b/app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt index b1fd980fb..75590b06f 100644 --- a/app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt +++ b/app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt @@ -202,7 +202,7 @@ fun LazyListScope.commentNodeItem( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showScores: Boolean, ) { val commentView = node.commentView @@ -446,7 +446,7 @@ fun LazyListScope.missingCommentNodeItem( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showScores: Boolean, ) { val commentId = node.missingCommentView.commentId @@ -602,7 +602,7 @@ fun PostAndCommunityContextHeader( community: Community, onCommunityClick: (community: Community) -> Unit, onPostClick: (postId: Int) -> Unit, - blurNSFW: Boolean, + blurNSFW: Int, ) { Column( modifier = Modifier.padding(top = LARGE_PADDING), @@ -634,7 +634,7 @@ fun PostAndCommunityContextHeaderPreview() { community = sampleCommunity, onCommunityClick = {}, onPostClick = {}, - blurNSFW = true, + blurNSFW = 1, ) } @@ -788,7 +788,7 @@ fun CommentNodesPreview() { showActionBar = { _ -> true }, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, account = AnonAccount, showScores = true, ) diff --git a/app/src/main/java/com/jerboa/ui/components/comment/CommentNodes.kt b/app/src/main/java/com/jerboa/ui/components/comment/CommentNodes.kt index c252557d8..76b96ee4e 100644 --- a/app/src/main/java/com/jerboa/ui/components/comment/CommentNodes.kt +++ b/app/src/main/java/com/jerboa/ui/components/comment/CommentNodes.kt @@ -52,7 +52,7 @@ fun CommentNodes( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showScores: Boolean, ) { LazyColumn(state = listState) { @@ -131,7 +131,7 @@ fun LazyListScope.commentNodeItems( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showScores: Boolean, ) { nodes.forEach { node -> diff --git a/app/src/main/java/com/jerboa/ui/components/comment/mentionnode/CommentMentionNode.kt b/app/src/main/java/com/jerboa/ui/components/comment/mentionnode/CommentMentionNode.kt index 41f0772e8..7568c6c9f 100644 --- a/app/src/main/java/com/jerboa/ui/components/comment/mentionnode/CommentMentionNode.kt +++ b/app/src/main/java/com/jerboa/ui/components/comment/mentionnode/CommentMentionNode.kt @@ -232,7 +232,7 @@ fun CommentMentionNode( onBlockCreatorClick: (creator: Person) -> Unit, account: Account, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, enableDownvotes: Boolean, showScores: Boolean, ) { diff --git a/app/src/main/java/com/jerboa/ui/components/comment/replynode/CommentReplyNode.kt b/app/src/main/java/com/jerboa/ui/components/comment/replynode/CommentReplyNode.kt index 36dc9a4ac..ad3904742 100644 --- a/app/src/main/java/com/jerboa/ui/components/comment/replynode/CommentReplyNode.kt +++ b/app/src/main/java/com/jerboa/ui/components/comment/replynode/CommentReplyNode.kt @@ -231,7 +231,7 @@ fun CommentReplyNodeInbox( onBlockCreatorClick: (creator: Person) -> Unit, account: Account, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, enableDownvotes: Boolean, showScores: Boolean, ) { diff --git a/app/src/main/java/com/jerboa/ui/components/community/Community.kt b/app/src/main/java/com/jerboa/ui/components/community/Community.kt index 79c3f446a..63e02f702 100644 --- a/app/src/main/java/com/jerboa/ui/components/community/Community.kt +++ b/app/src/main/java/com/jerboa/ui/components/community/Community.kt @@ -20,6 +20,9 @@ import com.jerboa.datatypes.sampleCommunityView import com.jerboa.datatypes.types.CommunityView import com.jerboa.datatypes.types.SortType import com.jerboa.datatypes.types.SubscribedType +import com.jerboa.feat.BlurTypes +import com.jerboa.feat.needBlur +import com.jerboa.toEnum import com.jerboa.ui.components.common.LargerCircularIcon import com.jerboa.ui.components.common.PictrsBannerImage import com.jerboa.ui.components.common.SortOptionsDropdown @@ -31,7 +34,7 @@ fun CommunityTopSection( communityView: CommunityView, modifier: Modifier = Modifier, onClickFollowCommunity: (communityView: CommunityView) -> Unit, - blurNSFW: Boolean, + blurNSFW: Int, ) { Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -45,11 +48,11 @@ fun CommunityTopSection( PictrsBannerImage( url = it, modifier = Modifier.height(DRAWER_BANNER_SIZE), - blur = blurNSFW && communityView.community.nsfw, + blur = blurNSFW.toEnum().needBlur(communityView.community.nsfw), ) } communityView.community.icon?.also { - LargerCircularIcon(icon = it, blur = blurNSFW && communityView.community.nsfw) + LargerCircularIcon(icon = it, blur = blurNSFW.toEnum().needBlur(communityView.community.nsfw)) } } Column( @@ -119,7 +122,7 @@ fun CommunityTopSectionPreview() { CommunityTopSection( communityView = sampleCommunityView, onClickFollowCommunity = {}, - blurNSFW = true, + blurNSFW = 1, ) } diff --git a/app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt b/app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt index 07494c204..35462decb 100644 --- a/app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt @@ -48,6 +48,7 @@ import com.jerboa.datatypes.types.SavePost import com.jerboa.datatypes.types.SubscribedType import com.jerboa.db.entity.getJWT import com.jerboa.db.entity.isAnon +import com.jerboa.feat.BlurTypes import com.jerboa.feat.doIfReadyElseDisplayInfo import com.jerboa.feat.shareLink import com.jerboa.hostName @@ -83,7 +84,7 @@ fun CommunityActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, postActionbarMode: Int, @@ -264,7 +265,7 @@ fun CommunityActivity( ) } }, - blurNSFW = blurNSFW, + blurNSFW = BlurTypes.changeBlurTypeInsideCommunity(blurNSFW), ) } @@ -432,7 +433,7 @@ fun CommunityActivity( showAvatar = siteViewModel.showAvatar(), useCustomTabs = useCustomTabs, usePrivateTabs = usePrivateTabs, - blurNSFW = blurNSFW, + blurNSFW = BlurTypes.changeBlurTypeInsideCommunity(blurNSFW), showPostLinkPreviews = showPostLinkPreviews, appState = appState, markAsReadOnScroll = markAsReadOnScroll, diff --git a/app/src/main/java/com/jerboa/ui/components/community/CommunityLink.kt b/app/src/main/java/com/jerboa/ui/components/community/CommunityLink.kt index 5414f01c9..6e68e578d 100644 --- a/app/src/main/java/com/jerboa/ui/components/community/CommunityLink.kt +++ b/app/src/main/java/com/jerboa/ui/components/community/CommunityLink.kt @@ -27,6 +27,9 @@ import com.jerboa.datatypes.sampleCommunity import com.jerboa.datatypes.sampleCommunityView import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.CommunityView +import com.jerboa.feat.BlurTypes +import com.jerboa.feat.needBlur +import com.jerboa.toEnum import com.jerboa.ui.components.common.CircularIcon import com.jerboa.ui.theme.DRAWER_ITEM_SPACING import com.jerboa.ui.theme.ICON_SIZE @@ -73,7 +76,7 @@ fun CommunityLink( onClick: (community: Community) -> Unit, clickable: Boolean = true, showDefaultIcon: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, ) { Row( verticalAlignment = Alignment.CenterVertically, @@ -90,7 +93,7 @@ fun CommunityLink( contentDescription = null, size = size, thumbnailSize = thumbnailSize, - blur = blurNSFW && community.nsfw, + blur = blurNSFW.toEnum().needBlur(community.nsfw), ) } ?: run { if (showDefaultIcon) { @@ -118,7 +121,7 @@ fun CommunityLinkLarger( community: Community, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, ) { CommunityLink( community = community, @@ -141,7 +144,7 @@ fun CommunityLinkLargerWithUserCount( communityView: CommunityView, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, ) { CommunityLink( community = communityView.community, @@ -167,7 +170,7 @@ fun CommunityLinkPreview() { community = sampleCommunity, onClick = {}, showDefaultIcon = true, - blurNSFW = true, + blurNSFW = 1, ) } @@ -178,6 +181,6 @@ fun CommunityLinkWithUsersPreview() { communityView = sampleCommunityView, onClick = {}, showDefaultIcon = true, - blurNSFW = true, + blurNSFW = 1, ) } diff --git a/app/src/main/java/com/jerboa/ui/components/community/list/CommunityList.kt b/app/src/main/java/com/jerboa/ui/components/community/list/CommunityList.kt index 9e2db2d49..6ab0bb18b 100644 --- a/app/src/main/java/com/jerboa/ui/components/community/list/CommunityList.kt +++ b/app/src/main/java/com/jerboa/ui/components/community/list/CommunityList.kt @@ -71,7 +71,7 @@ fun CommunityListings( communities: List, onClickCommunity: (community: Community) -> Unit, modifier: Modifier = Modifier, - blurNSFW: Boolean, + blurNSFW: Int, ) { val listState = rememberLazyListState() @@ -111,7 +111,7 @@ fun CommunityListingsPreview() { CommunityListings( communities = communities, onClickCommunity = {}, - blurNSFW = true, + blurNSFW = 1, ) } diff --git a/app/src/main/java/com/jerboa/ui/components/community/list/CommunityListActivity.kt b/app/src/main/java/com/jerboa/ui/components/community/list/CommunityListActivity.kt index c63939a64..e2bde8b7f 100644 --- a/app/src/main/java/com/jerboa/ui/components/community/list/CommunityListActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/community/list/CommunityListActivity.kt @@ -46,7 +46,7 @@ fun CommunityListActivity( accountViewModel: AccountViewModel, selectMode: Boolean = false, followList: ImmutableList, - blurNSFW: Boolean, + blurNSFW: Int, drawerState: DrawerState, ) { Log.d("jerboa", "got to community list activity") diff --git a/app/src/main/java/com/jerboa/ui/components/drawer/Drawer.kt b/app/src/main/java/com/jerboa/ui/components/drawer/Drawer.kt index 363e5dce3..e925e2773 100644 --- a/app/src/main/java/com/jerboa/ui/components/drawer/Drawer.kt +++ b/app/src/main/java/com/jerboa/ui/components/drawer/Drawer.kt @@ -86,7 +86,7 @@ fun Drawer( onCommunityClick: (community: Community) -> Unit, onClickSettings: () -> Unit, isOpen: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -136,7 +136,7 @@ fun DrawerContent( onClickSettings: () -> Unit, myUserInfo: MyUserInfo?, unreadCount: Int, - blurNSFW: Boolean, + blurNSFW: Int, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -180,7 +180,7 @@ fun DrawerItemsMain( onClickListingType: (ListingType) -> Unit, onCommunityClick: (community: Community) -> Unit, unreadCount: Int, - blurNSFW: Boolean, + blurNSFW: Int, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -292,7 +292,7 @@ fun DrawerItemsMainPreview() { onCommunityClick = {}, onClickSettings = {}, unreadCount = 2, - blurNSFW = true, + blurNSFW = 1, showBottomNav = false, closeDrawer = {}, onSelectTab = {}, diff --git a/app/src/main/java/com/jerboa/ui/components/drawer/DrawerActivity.kt b/app/src/main/java/com/jerboa/ui/components/drawer/DrawerActivity.kt index 29e6c6a7b..81a9fd644 100644 --- a/app/src/main/java/com/jerboa/ui/components/drawer/DrawerActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/drawer/DrawerActivity.kt @@ -31,7 +31,7 @@ fun MainDrawer( onCommunityClick: (Int) -> Unit, onClickLogin: () -> Unit, onSelectTab: (NavTab) -> Unit, - blurNSFW: Boolean, + blurNSFW: Int, showBottomNav: Boolean, ) { val account = getCurrentAccount(accountViewModel) diff --git a/app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt b/app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt index dc7230ca5..e75ab2cc4 100644 --- a/app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt @@ -86,7 +86,7 @@ fun HomeActivity( useCustomTabs: Boolean, usePrivateTabs: Boolean, drawerState: DrawerState, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, postActionbarMode: Int, @@ -197,7 +197,7 @@ fun MainPostListingsContent( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreviews: Boolean, snackbarHostState: SnackbarHostState, markAsReadOnScroll: Boolean, diff --git a/app/src/main/java/com/jerboa/ui/components/inbox/InboxActivity.kt b/app/src/main/java/com/jerboa/ui/components/inbox/InboxActivity.kt index efa3c0e6f..1e835df58 100644 --- a/app/src/main/java/com/jerboa/ui/components/inbox/InboxActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/inbox/InboxActivity.kt @@ -85,7 +85,7 @@ fun InboxActivity( drawerState: DrawerState, siteViewModel: SiteViewModel, accountViewModel: AccountViewModel, - blurNSFW: Boolean, + blurNSFW: Int, ) { Log.d("jerboa", "got to inbox activity") @@ -202,7 +202,7 @@ fun InboxTabs( scope: CoroutineScope, snackbarHostState: SnackbarHostState, padding: PaddingValues, - blurNSFW: Boolean, + blurNSFW: Int, ) { val tabTitles = InboxTab.entries.map { getLocalizedStringForInboxTab(ctx, it) } val pagerState = rememberPagerState { tabTitles.size } diff --git a/app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt b/app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt index 8be4dfd74..e0bff450c 100644 --- a/app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt @@ -111,7 +111,7 @@ fun PersonProfileActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreviews: Boolean, drawerState: DrawerState, markAsReadOnScroll: Boolean, @@ -293,7 +293,7 @@ fun UserTabs( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, snackbarHostState: SnackbarHostState, diff --git a/app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt b/app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt index 2d2649fd6..1fc2e897f 100644 --- a/app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt @@ -141,7 +141,7 @@ fun PostActivity( showVotingArrowsInListView: Boolean, showParentCommentNavigationButtons: Boolean, navigateParentCommentsWithVolumeButtons: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreview: Boolean, postActionbarMode: Int, ) { diff --git a/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt b/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt index 28af8b66b..a4cc61cfb 100644 --- a/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt +++ b/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt @@ -73,7 +73,9 @@ import com.jerboa.datatypes.types.Post import com.jerboa.datatypes.types.PostView import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount +import com.jerboa.feat.BlurTypes import com.jerboa.feat.PostActionbarMode +import com.jerboa.feat.needBlur import com.jerboa.getPostType import com.jerboa.hostName import com.jerboa.isSameInstance @@ -127,7 +129,7 @@ fun PostHeaderLine( modifier: Modifier = Modifier, showCommunityName: Boolean = true, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showScores: Boolean, ) { val community = postView.community @@ -148,7 +150,7 @@ fun PostHeaderLine( size = MEDIUM_ICON_SIZE, modifier = Modifier.clickable { onCommunityClick(community) }, thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE, - blur = blurNSFW && community.nsfw, + blur = blurNSFW.toEnum().needBlur(community.nsfw), ) } } @@ -234,7 +236,7 @@ fun PostHeaderLinePreview() { onCommunityClick = {}, onPersonClick = {}, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, showScores = true, ) } @@ -274,7 +276,7 @@ fun PostTitleBlock( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -329,7 +331,7 @@ fun PostName( @Composable fun PostTitleAndImageLink( postView: PostView, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -352,7 +354,7 @@ fun PostTitleAndImageLink( PictrsUrlImage( url = url, - blur = blurNSFW && nsfwCheck(postView), + blur = blurNSFW.toEnum().needBlur(postView), modifier = Modifier .combinedClickable( onClick = { appState.openImageViewer(url) }, @@ -367,7 +369,7 @@ fun PostTitleAndThumbnail( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -416,7 +418,7 @@ fun PostBody( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreview: Boolean, appState: JerboaAppState, clickBody: () -> Unit = {}, @@ -502,7 +504,7 @@ fun PreviewStoryTitleAndMetadata() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -520,7 +522,7 @@ fun PreviewSourcePost() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -789,7 +791,7 @@ fun PreviewPostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, @@ -824,7 +826,7 @@ fun PreviewLinkPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, @@ -859,7 +861,7 @@ fun PreviewImagePostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, @@ -894,7 +896,7 @@ fun PreviewImagePostListingSmallCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, @@ -929,7 +931,7 @@ fun PreviewLinkNoThumbnailPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, @@ -964,7 +966,7 @@ fun PostListing( showVotingArrowsInListView: Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showPostLinkPreview: Boolean, showIfRead: Boolean, @@ -1181,7 +1183,7 @@ fun PostListingList( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showIfRead: Boolean, enableDownVotes: Boolean, @@ -1303,7 +1305,7 @@ private fun ThumbnailTile( postView: PostView, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, ) { postView.post.url?.also { url -> @@ -1333,7 +1335,7 @@ private fun ThumbnailTile( postView.post.thumbnail_url?.also { thumbnail -> PictrsThumbnailImage( thumbnail = thumbnail, - blur = blurNSFW && nsfwCheck(postView), + blur = blurNSFW.toEnum().needBlur(postView), roundBottomEndCorner = postType != PostType.Link, modifier = postLinkPicMod, ) @@ -1397,7 +1399,7 @@ fun PostListingListPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = 1, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1428,7 +1430,7 @@ fun PostListingListWithThumbPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = 1, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1464,7 +1466,7 @@ fun PostListingCard( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreview: Boolean, appState: JerboaAppState, showIfRead: Boolean = false, diff --git a/app/src/main/java/com/jerboa/ui/components/post/PostListings.kt b/app/src/main/java/com/jerboa/ui/components/post/PostListings.kt index 4b102d268..f1f66c588 100644 --- a/app/src/main/java/com/jerboa/ui/components/post/PostListings.kt +++ b/app/src/main/java/com/jerboa/ui/components/post/PostListings.kt @@ -61,7 +61,7 @@ fun PostListings( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreviews: Boolean, appState: JerboaAppState, markAsReadOnScroll: Boolean, @@ -177,7 +177,7 @@ fun PreviewPostListings() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreviews = true, appState = rememberJerboaAppState(), markAsReadOnScroll = false, diff --git a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt index 69793b864..894f63deb 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt @@ -12,6 +12,7 @@ import androidx.compose.material.icons.outlined.ExitToApp import androidx.compose.material.icons.outlined.FormatSize import androidx.compose.material.icons.outlined.Forum import androidx.compose.material.icons.outlined.Language +import androidx.compose.material.icons.outlined.LensBlur import androidx.compose.material.icons.outlined.Palette import androidx.compose.material.icons.outlined.Swipe import androidx.compose.material.icons.outlined.ViewList @@ -41,6 +42,7 @@ import com.jerboa.ThemeMode import com.jerboa.db.APP_SETTINGS_DEFAULT import com.jerboa.db.entity.AppSettings import com.jerboa.feat.BackConfirmationMode +import com.jerboa.feat.BlurTypes import com.jerboa.feat.PostActionbarMode import com.jerboa.feat.PostNavigationGestureMode import com.jerboa.getLangPreferenceDropdownEntries @@ -89,7 +91,7 @@ fun LookAndFeelActivity( val usePrivateTabsState = rememberBooleanSettingState(settings.usePrivateTabs) val secureWindowState = rememberBooleanSettingState(settings.secureWindow) - val blurNSFW = rememberBooleanSettingState(settings.blurNSFW) + val blurNSFW = rememberIntSettingState(settings.blurNSFW) val backConfirmationMode = rememberIntSettingState(settings.backConfirmationMode) val showPostLinkPreviewMode = rememberBooleanSettingState(settings.showPostLinkPreviews) val postActionbarMode = rememberIntSettingState(settings.postActionbarMode) @@ -282,6 +284,18 @@ fun LookAndFeelActivity( ) }, ) + SettingsListDropdown( + state = blurNSFW, + icon = { + Icon( + imageVector = Icons.Outlined.LensBlur, + contentDescription = null, + ) + }, + title = { Text(stringResource(id = R.string.blur_nsfw)) }, + items = BlurTypes.entries.map { stringResource(it.resId) }, + onItemSelected = { _, _ -> updateAppSettings() }, + ) SettingsCheckbox( state = showBottomNavState, title = { @@ -353,13 +367,6 @@ fun LookAndFeelActivity( }, onCheckedChange = { updateAppSettings() }, ) - SettingsCheckbox( - state = blurNSFW, - title = { - Text(stringResource(id = R.string.blur_nsfw)) - }, - onCheckedChange = { updateAppSettings() }, - ) SettingsCheckbox( state = showPostLinkPreviewMode, title = { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 230db4f47..6b85c0267 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -392,6 +392,10 @@ Connect on Matrix Posts failed loading, retry Failed to share media! + Nothing + NSFW + NSFW except from NSFW communities + Except NSFW inside community Failed to parse datetime There is no record of this comment