From 0101e34352e66ee5641e2879263b5d4255ef53d2 Mon Sep 17 00:00:00 2001 From: user Date: Sun, 10 Sep 2023 13:14:33 +0300 Subject: [PATCH 01/11] Change NSFW Blur toggle to drop-down menu which applies only to NSFW communities (#957) --- app/schemas/com.jerboa.db.AppDB/26.json | 8 +- app/src/main/java/com/jerboa/MainActivity.kt | 17 +-- app/src/main/java/com/jerboa/Utils.kt | 8 ++ .../com/jerboa/datatypes/types/LocalUser.kt | 2 +- .../java/com/jerboa/datatypes/types/Others.kt | 16 +++ .../datatypes/types/SaveUserSettings.kt | 2 +- app/src/main/java/com/jerboa/db/AppDB.kt | 4 +- .../java/com/jerboa/db/AppDBMigrations.kt | 119 ++++++++++++++++++ .../java/com/jerboa/db/entity/AppSettings.kt | 4 +- .../ui/components/comment/CommentNode.kt | 8 +- .../ui/components/comment/CommentNodes.kt | 5 +- .../comment/mentionnode/CommentMentionNode.kt | 3 +- .../comment/replynode/CommentReplyNode.kt | 3 +- .../ui/components/community/Community.kt | 10 +- .../components/community/CommunityActivity.kt | 3 +- .../ui/components/community/CommunityLink.kt | 14 ++- .../community/list/CommunityList.kt | 4 +- .../community/list/CommunityListActivity.kt | 3 +- .../com/jerboa/ui/components/drawer/Drawer.kt | 9 +- .../ui/components/drawer/DrawerActivity.kt | 3 +- .../ui/components/home/BottomNavActivity.kt | 13 +- .../jerboa/ui/components/home/HomeActivity.kt | 5 +- .../ui/components/inbox/InboxActivity.kt | 5 +- .../person/PersonProfileActivity.kt | 5 +- .../jerboa/ui/components/post/PostActivity.kt | 3 +- .../jerboa/ui/components/post/PostListing.kt | 46 +++---- .../jerboa/ui/components/post/PostListings.kt | 5 +- .../settings/account/AccountSettings.kt | 17 +-- .../lookandfeel/LookAndFeelActivity.kt | 23 +++- app/src/main/res/values/strings.xml | 3 + 30 files changed, 277 insertions(+), 93 deletions(-) diff --git a/app/schemas/com.jerboa.db.AppDB/26.json b/app/schemas/com.jerboa.db.AppDB/26.json index 4a5345694..59cde33df 100644 --- a/app/schemas/com.jerboa.db.AppDB/26.json +++ b/app/schemas/com.jerboa.db.AppDB/26.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 26, - "identityHash": "bf20da38fc7d03e28121589dfb372eaf", + "identityHash": "98ab20c6cd84e7fedbb9eccc2e4c44b1", "entities": [ { "tableName": "Account", @@ -71,7 +71,7 @@ }, { "tableName": "AppSettings", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `font_size` INTEGER NOT NULL DEFAULT 16, `theme` INTEGER NOT NULL DEFAULT 0, `theme_color` INTEGER NOT NULL DEFAULT 0, `viewed_changelog` INTEGER NOT NULL DEFAULT 0, `post_view_mode` INTEGER NOT NULL DEFAULT 0, `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0, `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, `use_private_tabs` INTEGER NOT NULL DEFAULT 0, `secure_window` INTEGER NOT NULL DEFAULT 0, `blur_nsfw` INTEGER NOT NULL DEFAULT 1, `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 1, `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0, `backConfirmationMode` INTEGER NOT NULL DEFAULT 1, `show_post_link_previews` INTEGER NOT NULL DEFAULT 1, `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0, `auto_play_gifs` INTEGER NOT NULL DEFAULT 0)", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `font_size` INTEGER NOT NULL DEFAULT 16, `theme` INTEGER NOT NULL DEFAULT 0, `theme_color` INTEGER NOT NULL DEFAULT 0, `viewed_changelog` INTEGER NOT NULL DEFAULT 0, `post_view_mode` INTEGER NOT NULL DEFAULT 0, `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0, `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, `use_private_tabs` INTEGER NOT NULL DEFAULT 0, `secure_window` INTEGER NOT NULL DEFAULT 0, `blur_nsfw` INTEGER NOT NULL DEFAULT 1, `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 0, `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0, `backConfirmationMode` INTEGER NOT NULL DEFAULT 1, `show_post_link_previews` INTEGER NOT NULL DEFAULT 1, `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0, `auto_play_gifs` INTEGER NOT NULL DEFAULT 0)", "fields": [ { "fieldPath": "id", @@ -196,7 +196,7 @@ "columnName": "show_text_descriptions_in_navbar", "affinity": "INTEGER", "notNull": true, - "defaultValue": "1" + "defaultValue": "0" }, { "fieldPath": "markAsReadOnScroll", @@ -247,7 +247,7 @@ "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'bf20da38fc7d03e28121589dfb372eaf')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '98ab20c6cd84e7fedbb9eccc2e4c44b1')" ] } } \ No newline at end of file diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt index 927e15f52..2c32e94e3 100644 --- a/app/src/main/java/com/jerboa/MainActivity.kt +++ b/app/src/main/java/com/jerboa/MainActivity.kt @@ -35,6 +35,7 @@ import com.jerboa.api.API import com.jerboa.api.ApiState import com.jerboa.api.MINIMUM_API_VERSION import com.jerboa.datatypes.types.Community +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.APP_SETTINGS_DEFAULT import com.jerboa.feat.BackConfirmation.addConfirmationDialog import com.jerboa.feat.BackConfirmation.addConfirmationToast @@ -266,7 +267,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showPostLinkPreviews = appSettings.showPostLinkPreviews, markAsReadOnScroll = appSettings.markAsReadOnScroll, postActionbarMode = appSettings.postActionbarMode, @@ -308,7 +309,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showPostLinkPreviews = appSettings.showPostLinkPreviews, markAsReadOnScroll = appSettings.markAsReadOnScroll, postActionbarMode = appSettings.postActionbarMode, @@ -379,7 +380,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, onBack = appState::popBackStack, @@ -415,7 +416,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, markAsReadOnScroll = appSettings.markAsReadOnScroll, @@ -438,7 +439,7 @@ class MainActivity : AppCompatActivity() { accountViewModel = accountViewModel, siteViewModel = siteViewModel, selectMode = args.select, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], drawerState = drawerState, ) } @@ -493,7 +494,7 @@ class MainActivity : AppCompatActivity() { appState = appState, accountViewModel = accountViewModel, siteViewModel = siteViewModel, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], drawerState = drawerState, ) } @@ -527,7 +528,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showPostLinkPreview = appSettings.showPostLinkPreviews, postActionbarMode = appSettings.postActionbarMode, ) @@ -558,7 +559,7 @@ class MainActivity : AppCompatActivity() { showParentCommentNavigationButtons = appSettings.showParentCommentNavigationButtons, navigateParentCommentsWithVolumeButtons = appSettings.navigateParentCommentsWithVolumeButtons, siteViewModel = siteViewModel, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showPostLinkPreview = appSettings.showPostLinkPreviews, postActionbarMode = appSettings.postActionbarMode, ) diff --git a/app/src/main/java/com/jerboa/Utils.kt b/app/src/main/java/com/jerboa/Utils.kt index f7a1c50be..c6e14e9cc 100644 --- a/app/src/main/java/com/jerboa/Utils.kt +++ b/app/src/main/java/com/jerboa/Utils.kt @@ -939,6 +939,14 @@ fun nsfwCheck(postView: PostView): Boolean { return postView.post.nsfw || postView.community.nsfw } +fun needNsfwBlur(settings: ShowNsfwTypes, isCommunityNsfw: Boolean, isPostNsfw: Boolean = true): Boolean { + return isPostNsfw && when(settings){ + ShowNsfwTypes.BlurEverywhere -> true + ShowNsfwTypes.DoNotBlur -> false + ShowNsfwTypes.BlurEverywhereExceptNsfw -> !isCommunityNsfw + } +} + @RequiresApi(Build.VERSION_CODES.Q) @Throws(IOException::class) fun saveMediaQ( diff --git a/app/src/main/java/com/jerboa/datatypes/types/LocalUser.kt b/app/src/main/java/com/jerboa/datatypes/types/LocalUser.kt index ab9f7fddd..b56dafab2 100644 --- a/app/src/main/java/com/jerboa/datatypes/types/LocalUser.kt +++ b/app/src/main/java/com/jerboa/datatypes/types/LocalUser.kt @@ -8,7 +8,7 @@ data class LocalUser( val id: LocalUserId, val person_id: PersonId, val email: String? = null, - val show_nsfw: Boolean, + val show_nsfw: ShowNsfwTypes /* "BlurEverywhere" | "BlurEverywhereExceptNsfw" | "DoNotBlur" */, val theme: String, val default_sort_type: SortType /* "Active" | "Hot" | "New" | "Old" | "TopDay" | "TopWeek" | "TopMonth" | "TopYear" | "TopAll" | "MostComments" | "NewComments" | "TopHour" | "TopSixHour" | "TopTwelveHour" */, val default_listing_type: ListingType /* "All" | "Local" | "Subscribed" */, diff --git a/app/src/main/java/com/jerboa/datatypes/types/Others.kt b/app/src/main/java/com/jerboa/datatypes/types/Others.kt index e448c154e..e240c0f71 100644 --- a/app/src/main/java/com/jerboa/datatypes/types/Others.kt +++ b/app/src/main/java/com/jerboa/datatypes/types/Others.kt @@ -382,6 +382,22 @@ enum class ModlogActionType { AdminPurgeComment, } +/** + * Different show nsfw states + */ +enum class ShowNsfwTypes { + + @SerializedName("BlurEverywhere") + BlurEverywhere, + + @SerializedName("BlurEverywhereExceptNsfw") + BlurEverywhereExceptNsfw, + + @SerializedName("DoNotBlur") + DoNotBlur; + +} + @Parcelize data class PictrsImage( val file: String, diff --git a/app/src/main/java/com/jerboa/datatypes/types/SaveUserSettings.kt b/app/src/main/java/com/jerboa/datatypes/types/SaveUserSettings.kt index 4d740ac5d..61977f70f 100644 --- a/app/src/main/java/com/jerboa/datatypes/types/SaveUserSettings.kt +++ b/app/src/main/java/com/jerboa/datatypes/types/SaveUserSettings.kt @@ -7,7 +7,7 @@ import kotlinx.parcelize.Parcelize @Immutable @Parcelize data class SaveUserSettings( - val show_nsfw: Boolean? = null, + val show_nsfw: ShowNsfwTypes? /* "BlurEverywhere" | "BlurEverywhereExceptNsfw" | "DoNotBlur" */ = null, val show_scores: Boolean? = null, val theme: String? = null, val default_sort_type: SortType? /* "Active" | "Hot" | "New" | "Old" | "TopDay" | "TopWeek" | "TopMonth" | "TopYear" | "TopAll" | "MostComments" | "NewComments" | "TopHour" | "TopSixHour" | "TopTwelveHour" */ = null, diff --git a/app/src/main/java/com/jerboa/db/AppDB.kt b/app/src/main/java/com/jerboa/db/AppDB.kt index d09b1c794..b6efe1612 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 = 0, showTextDescriptionsInNavbar = true, backConfirmationMode = 1, markAsReadOnScroll = false, @@ -42,7 +42,7 @@ val APP_SETTINGS_DEFAULT = AppSettings( ) @Database( - version = 26, + version = 27, entities = [Account::class, AppSettings::class], exportSchema = true, ) diff --git a/app/src/main/java/com/jerboa/db/AppDBMigrations.kt b/app/src/main/java/com/jerboa/db/AppDBMigrations.kt index d45a071da..0a22d65f4 100644 --- a/app/src/main/java/com/jerboa/db/AppDBMigrations.kt +++ b/app/src/main/java/com/jerboa/db/AppDBMigrations.kt @@ -354,6 +354,123 @@ val MIGRATION_26_25 = object : Migration(26, 25) { } } +val MIGRATION_26_27 = object : Migration(26, 27) { + override fun migrate(database: SupportSQLiteDatabase) { + + database.execSQL( + """ + CREATE TABLE IF NOT EXISTS AppSettingsBackup ( + `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + `font_size` INTEGER NOT NULL DEFAULT 16, + `theme` INTEGER NOT NULL DEFAULT 0, + `theme_color` INTEGER NOT NULL DEFAULT 0, + `viewed_changelog` INTEGER NOT NULL DEFAULT 0, + `post_view_mode` INTEGER NOT NULL DEFAULT 0, + `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, + `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, + `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, + `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, + `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, + `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, + `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, + `use_private_tabs` INTEGER NOT NULL DEFAULT 0, + `secure_window` INTEGER NOT NULL DEFAULT 0, + `blur_nsfw` INTEGER NOT NULL DEFAULT 0, + `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 1, + `backConfirmationMode` INTEGER NOT NULL DEFAULT 1, + `show_post_link_previews` INTEGER NOT NULL DEFAULT 1, + `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0, + `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0, + `auto_play_gifs` INTEGER NOT NULL DEFAULT 0, + `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0 + ) + + """.trimIndent(), + ) + + database.execSQL( + """ + INSERT INTO AppSettingsBackup SELECT * FROM AppSettings + """, + ) + database.execSQL("DROP TABLE AppSettings") + database.execSQL("ALTER TABLE AppSettingsBackup RENAME to AppSettings") + + database.execSQL( + """ + UPDATE AppSettings + SET blur_nsfw = 2 + WHERE blur_nsfw = 0 + """.trimIndent(), + ) + database.execSQL( + """ + UPDATE AppSettings + SET blur_nsfw = 0 + WHERE blur_nsfw = 1 + """.trimIndent(), + ) + } +} + +val MIGRATION_27_26 = object : Migration(27, 26) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL( + """ + CREATE TABLE IF NOT EXISTS AppSettingsBackup ( + `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + `font_size` INTEGER NOT NULL DEFAULT 16, + `theme` INTEGER NOT NULL DEFAULT 0, + `theme_color` INTEGER NOT NULL DEFAULT 0, + `viewed_changelog` INTEGER NOT NULL DEFAULT 0, + `post_view_mode` INTEGER NOT NULL DEFAULT 0, + `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, + `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, + `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, + `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, + `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, + `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, + `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, + `use_private_tabs` INTEGER NOT NULL DEFAULT 0, + `secure_window` INTEGER NOT NULL DEFAULT 0, + `blur_nsfw` INTEGER NOT NULL DEFAULT 1, + `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 1, + `backConfirmationMode` INTEGER NOT NULL DEFAULT 1 + `show_post_link_previews` INTEGER NOT NULL DEFAULT 1 + `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0 + `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0 + `auto_play_gifs` INTEGER NOT NULL DEFAULT 0 + `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0 + ) + + """.trimIndent(), + ) + + database.execSQL( + """ + INSERT INTO AppSettingsBackup SELECT * FROM AppSettings + """, + ) + database.execSQL("DROP TABLE AppSettings") + database.execSQL("ALTER TABLE AppSettingsBackup RENAME to AppSettings") + + database.execSQL( + """ + UPDATE AppSettings + SET blur_nsfw = 1 + WHERE blur_nsfw = 0 + """.trimIndent(), + ) + database.execSQL( + """ + UPDATE AppSettings + SET blur_nsfw = 0 + WHERE blur_nsfw = 2 + """.trimIndent(), + ) + } +} + // Don't forget to test your migration with `./gradlew app:connectAndroidTest` val MIGRATIONS_LIST = arrayOf( MIGRATION_1_2, @@ -386,4 +503,6 @@ val MIGRATIONS_LIST = arrayOf( MIGRATION_25_24, MIGRATION_25_26, MIGRATION_26_25, + MIGRATION_26_27, + MIGRATION_27_26, ) 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..885c89050 100644 --- a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt +++ b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt @@ -85,9 +85,9 @@ data class AppSettings( val secureWindow: Boolean, @ColumnInfo( name = "blur_nsfw", - defaultValue = "1", + defaultValue = "0", ) - val blurNSFW: Boolean, + val blurNSFW: Int, @ColumnInfo( name = "show_text_descriptions_in_navbar", defaultValue = "1", 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 24b0b2fa5..8aa8c9792 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 @@ -216,7 +216,7 @@ fun LazyListScope.commentNodeItem( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showScores: Boolean, ) { val commentView = node.commentView @@ -483,7 +483,7 @@ fun PostAndCommunityContextHeader( community: Community, onCommunityClick: (community: Community) -> Unit, onPostClick: (postId: Int) -> Unit, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, ) { Column( modifier = Modifier.padding(top = LARGE_PADDING), @@ -515,7 +515,7 @@ fun PostAndCommunityContextHeaderPreview() { community = sampleCommunity, onCommunityClick = {}, onPostClick = {}, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, ) } @@ -690,7 +690,7 @@ fun CommentNodesPreview() { showActionBar = { _ -> true }, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, 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 ac7905ae2..2b039c980 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 @@ -12,6 +12,7 @@ import com.jerboa.CommentNodeData import com.jerboa.datatypes.types.CommentView import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import kotlinx.collections.immutable.ImmutableList @@ -50,7 +51,7 @@ fun CommentNodes( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showScores: Boolean, ) { LazyColumn(state = listState) { @@ -129,7 +130,7 @@ fun LazyListScope.commentNodeItems( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, 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 cbde0b7d5..75312928b 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 @@ -43,6 +43,7 @@ import com.jerboa.datatypes.samplePersonMentionView import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person import com.jerboa.datatypes.types.PersonMentionView +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.ui.components.comment.CommentBody import com.jerboa.ui.components.comment.PostAndCommunityContextHeader @@ -336,7 +337,7 @@ fun CommentMentionNode( onBlockCreatorClick: (creator: Person) -> Unit, account: Account, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, 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 99908a818..d34477729 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 @@ -41,6 +41,7 @@ import com.jerboa.datatypes.sampleCommentReplyView import com.jerboa.datatypes.types.CommentReplyView import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.ui.components.comment.CommentBody import com.jerboa.ui.components.comment.PostAndCommunityContextHeader @@ -321,7 +322,7 @@ fun CommentReplyNodeInbox( onBlockCreatorClick: (creator: Person) -> Unit, account: Account, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, 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 970b80b6f..f62d9951f 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 @@ -16,8 +16,10 @@ import com.jerboa.PostViewMode import com.jerboa.R import com.jerboa.datatypes.sampleCommunityView import com.jerboa.datatypes.types.CommunityView +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SortType import com.jerboa.datatypes.types.SubscribedType +import com.jerboa.needNsfwBlur import com.jerboa.ui.components.common.LargerCircularIcon import com.jerboa.ui.components.common.MenuItem import com.jerboa.ui.components.common.PictrsBannerImage @@ -31,7 +33,7 @@ fun CommunityTopSection( communityView: CommunityView, modifier: Modifier = Modifier, onClickFollowCommunity: (communityView: CommunityView) -> Unit, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, ) { Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -45,11 +47,11 @@ fun CommunityTopSection( PictrsBannerImage( url = it, modifier = Modifier.height(DRAWER_BANNER_SIZE), - blur = blurNSFW && communityView.community.nsfw, + blur = needNsfwBlur(blurNSFW, communityView.community.nsfw), ) } communityView.community.icon?.also { - LargerCircularIcon(icon = it, blur = blurNSFW && communityView.community.nsfw) + LargerCircularIcon(icon = it, blur = needNsfwBlur(blurNSFW, communityView.community.nsfw)) } } Column( @@ -119,7 +121,7 @@ fun CommunityTopSectionPreview() { CommunityTopSection( communityView = sampleCommunityView, onClickFollowCommunity = {}, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, ) } 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 af01f9c7c..d14ec211e 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 @@ -49,6 +49,7 @@ import com.jerboa.datatypes.types.GetSite import com.jerboa.datatypes.types.MarkPostAsRead import com.jerboa.datatypes.types.PostView import com.jerboa.datatypes.types.SavePost +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SubscribedType import com.jerboa.db.entity.getJWT import com.jerboa.db.entity.isAnon @@ -89,7 +90,7 @@ fun CommunityActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, postActionbarMode: Int, 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..3125966de 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,8 @@ 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.datatypes.types.ShowNsfwTypes +import com.jerboa.needNsfwBlur import com.jerboa.ui.components.common.CircularIcon import com.jerboa.ui.theme.DRAWER_ITEM_SPACING import com.jerboa.ui.theme.ICON_SIZE @@ -73,7 +75,7 @@ fun CommunityLink( onClick: (community: Community) -> Unit, clickable: Boolean = true, showDefaultIcon: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, ) { Row( verticalAlignment = Alignment.CenterVertically, @@ -90,7 +92,7 @@ fun CommunityLink( contentDescription = null, size = size, thumbnailSize = thumbnailSize, - blur = blurNSFW && community.nsfw, + blur = needNsfwBlur(blurNSFW, community.nsfw), ) } ?: run { if (showDefaultIcon) { @@ -118,7 +120,7 @@ fun CommunityLinkLarger( community: Community, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, ) { CommunityLink( community = community, @@ -141,7 +143,7 @@ fun CommunityLinkLargerWithUserCount( communityView: CommunityView, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, ) { CommunityLink( community = communityView.community, @@ -167,7 +169,7 @@ fun CommunityLinkPreview() { community = sampleCommunity, onClick = {}, showDefaultIcon = true, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, ) } @@ -178,6 +180,6 @@ fun CommunityLinkWithUsersPreview() { communityView = sampleCommunityView, onClick = {}, showDefaultIcon = true, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, ) } 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..763fb9300 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: ShowNsfwTypes, ) { val listState = rememberLazyListState() @@ -111,7 +111,7 @@ fun CommunityListingsPreview() { CommunityListings( communities = communities, onClickCommunity = {}, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, ) } 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 f929d648c..1cdfcd17c 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 @@ -20,6 +20,7 @@ import com.jerboa.JerboaAppState import com.jerboa.api.ApiState import com.jerboa.datatypes.types.Search import com.jerboa.datatypes.types.SearchType +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SortType import com.jerboa.db.entity.getJWT import com.jerboa.model.AccountViewModel @@ -46,7 +47,7 @@ fun CommunityListActivity( accountViewModel: AccountViewModel, selectMode: Boolean = false, siteViewModel: SiteViewModel, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, 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..e8f94819a 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 @@ -50,6 +50,7 @@ import com.jerboa.datatypes.types.CommunityFollowerView import com.jerboa.datatypes.types.ListingType import com.jerboa.datatypes.types.MyUserInfo import com.jerboa.datatypes.types.Person +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount import com.jerboa.db.entity.isAnon @@ -86,7 +87,7 @@ fun Drawer( onCommunityClick: (community: Community) -> Unit, onClickSettings: () -> Unit, isOpen: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -136,7 +137,7 @@ fun DrawerContent( onClickSettings: () -> Unit, myUserInfo: MyUserInfo?, unreadCount: Int, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -180,7 +181,7 @@ fun DrawerItemsMain( onClickListingType: (ListingType) -> Unit, onCommunityClick: (community: Community) -> Unit, unreadCount: Int, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -292,7 +293,7 @@ fun DrawerItemsMainPreview() { onCommunityClick = {}, onClickSettings = {}, unreadCount = 2, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, 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 9ea2fab8c..5b1563b0b 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 @@ -10,6 +10,7 @@ import androidx.compose.runtime.setValue import com.jerboa.api.ApiState import com.jerboa.closeDrawer import com.jerboa.datatypes.types.CommunityFollowerView +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.isAnon import com.jerboa.db.entity.isReady import com.jerboa.model.AccountViewModel @@ -31,7 +32,7 @@ fun MainDrawer( onCommunityClick: (Int) -> Unit, onClickLogin: () -> Unit, onSelectTab: (NavTab) -> Unit, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showBottomNav: Boolean, ) { val account = getCurrentAccount(accountViewModel) diff --git a/app/src/main/java/com/jerboa/ui/components/home/BottomNavActivity.kt b/app/src/main/java/com/jerboa/ui/components/home/BottomNavActivity.kt index 053ba95e6..1b18a3154 100644 --- a/app/src/main/java/com/jerboa/ui/components/home/BottomNavActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/home/BottomNavActivity.kt @@ -41,6 +41,7 @@ import androidx.navigation.compose.rememberNavController import arrow.core.Either import com.jerboa.JerboaAppState import com.jerboa.R +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.AppSettings import com.jerboa.feat.doIfReadyElseDisplayInfo import com.jerboa.model.AccountViewModel @@ -165,7 +166,7 @@ fun BottomNavActivity( scope = scope, drawerState = drawerState, onSelectTab = onSelectTab, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showBottomNav = appSettings.showBottomNav, onCommunityClick = appState::toCommunity, onSettingsClick = appState::toSettings, @@ -213,7 +214,7 @@ fun BottomNavActivity( useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, drawerState = drawerState, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showPostLinkPreviews = appSettings.showPostLinkPreviews, markAsReadOnScroll = appSettings.markAsReadOnScroll, postActionbarMode = appSettings.postActionbarMode, @@ -226,7 +227,7 @@ fun BottomNavActivity( accountViewModel = accountViewModel, selectMode = false, siteViewModel = siteViewModel, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], drawerState = drawerState, ) } @@ -236,7 +237,7 @@ fun BottomNavActivity( appState = appState, accountViewModel = accountViewModel, siteViewModel = siteViewModel, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], drawerState = drawerState, ) } @@ -252,7 +253,7 @@ fun BottomNavActivity( siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, markAsReadOnScroll = appSettings.markAsReadOnScroll, @@ -271,7 +272,7 @@ fun BottomNavActivity( siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, markAsReadOnScroll = appSettings.markAsReadOnScroll, 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 74e21f4de..a1abc6d1f 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 @@ -50,6 +50,7 @@ import com.jerboa.datatypes.types.DeletePost import com.jerboa.datatypes.types.MarkPostAsRead import com.jerboa.datatypes.types.PostView import com.jerboa.datatypes.types.SavePost +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.Tagline import com.jerboa.db.entity.Account import com.jerboa.db.entity.isAnon @@ -91,7 +92,7 @@ fun HomeActivity( useCustomTabs: Boolean, usePrivateTabs: Boolean, drawerState: DrawerState, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, postActionbarMode: Int, @@ -205,7 +206,7 @@ fun MainPostListingsContent( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, 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 00f9a57a3..a7c19854b 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 @@ -54,6 +54,7 @@ import com.jerboa.datatypes.types.MarkCommentReplyAsRead import com.jerboa.datatypes.types.MarkPersonMentionAsRead import com.jerboa.datatypes.types.MarkPrivateMessageAsRead import com.jerboa.datatypes.types.SaveComment +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.db.entity.isAnon import com.jerboa.feat.doIfReadyElseDisplayInfo @@ -90,7 +91,7 @@ fun InboxActivity( drawerState: DrawerState, siteViewModel: SiteViewModel, accountViewModel: AccountViewModel, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, ) { Log.d("jerboa", "got to inbox activity") @@ -222,7 +223,7 @@ fun InboxTabs( scope: CoroutineScope, snackbarHostState: SnackbarHostState, padding: PaddingValues, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, ) { val transferPrivateMessageDepsViaRoot = appState.rootChannel() val transferCommentReplyDepsViaRoot = appState.rootChannel() 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 b4f883ab1..dac8f4005 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 @@ -67,6 +67,7 @@ import com.jerboa.datatypes.types.PersonId import com.jerboa.datatypes.types.PostView import com.jerboa.datatypes.types.SaveComment import com.jerboa.datatypes.types.SavePost +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SortType import com.jerboa.db.entity.Account import com.jerboa.db.entity.getJWT @@ -119,7 +120,7 @@ fun PersonProfileActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showPostLinkPreviews: Boolean, drawerState: DrawerState, markAsReadOnScroll: Boolean, @@ -322,7 +323,7 @@ fun UserTabs( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, 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 da3117af2..bdaed43bf 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 @@ -74,6 +74,7 @@ import com.jerboa.datatypes.types.PostId import com.jerboa.datatypes.types.PostView import com.jerboa.datatypes.types.SaveComment import com.jerboa.datatypes.types.SavePost +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.isAnon import com.jerboa.feat.doIfReadyElseDisplayInfo import com.jerboa.feat.shareLink @@ -147,7 +148,7 @@ fun PostActivity( showVotingArrowsInListView: Boolean, showParentCommentNavigationButtons: Boolean, navigateParentCommentsWithVolumeButtons: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, 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 cf5c0037c..c374132ce 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 @@ -85,12 +85,14 @@ import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person import com.jerboa.datatypes.types.Post import com.jerboa.datatypes.types.PostView +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount import com.jerboa.feat.PostActionbarMode import com.jerboa.getPostType import com.jerboa.hostName import com.jerboa.isSameInstance +import com.jerboa.needNsfwBlur import com.jerboa.nsfwCheck import com.jerboa.rememberJerboaAppState import com.jerboa.siFormat @@ -139,7 +141,7 @@ fun PostHeaderLine( modifier: Modifier = Modifier, showCommunityName: Boolean = true, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showScores: Boolean, ) { val community = postView.community @@ -160,7 +162,7 @@ fun PostHeaderLine( size = MEDIUM_ICON_SIZE, modifier = Modifier.clickable { onCommunityClick(community) }, thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE, - blur = blurNSFW && community.nsfw, + blur = needNsfwBlur(blurNSFW, community.nsfw, postView.post.nsfw), ) } } @@ -249,7 +251,7 @@ fun PostHeaderLinePreview() { onCommunityClick = {}, onPersonClick = {}, showAvatar = true, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, showScores = true, ) } @@ -289,7 +291,7 @@ fun PostTitleBlock( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -344,7 +346,7 @@ fun PostName( @Composable fun PostTitleAndImageLink( postView: PostView, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -367,7 +369,7 @@ fun PostTitleAndImageLink( PictrsUrlImage( url = url, - blur = blurNSFW && nsfwCheck(postView), + blur = needNsfwBlur(blurNSFW, postView.community.nsfw, postView.post.nsfw), modifier = Modifier .combinedClickable( onClick = { appState.openImageViewer(url) }, @@ -382,7 +384,7 @@ fun PostTitleAndThumbnail( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -431,7 +433,7 @@ fun PostBody( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showPostLinkPreview: Boolean, appState: JerboaAppState, clickBody: () -> Unit = {}, @@ -517,7 +519,7 @@ fun PreviewStoryTitleAndMetadata() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -535,7 +537,7 @@ fun PreviewSourcePost() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -829,7 +831,7 @@ fun PreviewPostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -865,7 +867,7 @@ fun PreviewLinkPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -901,7 +903,7 @@ fun PreviewImagePostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -937,7 +939,7 @@ fun PreviewImagePostListingSmallCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -973,7 +975,7 @@ fun PreviewLinkNoThumbnailPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -1009,7 +1011,7 @@ fun PostListing( showVotingArrowsInListView: Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, appState: JerboaAppState, showPostLinkPreview: Boolean, showIfRead: Boolean, @@ -1228,7 +1230,7 @@ fun PostListingList( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, appState: JerboaAppState, showIfRead: Boolean, enableDownVotes: Boolean, @@ -1350,7 +1352,7 @@ private fun ThumbnailTile( postView: PostView, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, appState: JerboaAppState, ) { postView.post.url?.also { url -> @@ -1380,7 +1382,7 @@ private fun ThumbnailTile( postView.post.thumbnail_url?.also { thumbnail -> PictrsThumbnailImage( thumbnail = thumbnail, - blur = blurNSFW && nsfwCheck(postView), + blur = needNsfwBlur(blurNSFW, postView.community.nsfw, postView.post.nsfw), roundBottomEndCorner = postType != PostType.Link, modifier = postLinkPicMod, ) @@ -1444,7 +1446,7 @@ fun PostListingListPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1475,7 +1477,7 @@ fun PostListingListWithThumbPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1512,7 +1514,7 @@ fun PostListingCard( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, 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 031118bbf..9f47f22f2 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 @@ -25,6 +25,7 @@ import com.jerboa.datatypes.samplePostView import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person import com.jerboa.datatypes.types.PostView +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount import com.jerboa.isScrolledToEnd @@ -61,7 +62,7 @@ fun PostListings( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: ShowNsfwTypes, showPostLinkPreviews: Boolean, appState: JerboaAppState, markAsReadOnScroll: Boolean, @@ -172,7 +173,7 @@ fun PreviewPostListings() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = ShowNsfwTypes.BlurEverywhere, showPostLinkPreviews = true, appState = rememberJerboaAppState(), markAsReadOnScroll = false, diff --git a/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt b/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt index 94d580ab2..c40053bc1 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt @@ -28,6 +28,7 @@ import com.jerboa.api.ApiState import com.jerboa.api.uploadPictrsImage import com.jerboa.datatypes.types.ListingType import com.jerboa.datatypes.types.SaveUserSettings +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SortType import com.jerboa.db.entity.Account import com.jerboa.imageInputStreamFromUri @@ -128,7 +129,7 @@ fun SettingsForm( val defaultListingType = rememberIntSettingState(luv?.local_user?.default_listing_type?.ordinal ?: 0) val showAvatars = rememberBooleanSettingState(luv?.local_user?.show_avatars ?: false) - val showNsfw = rememberBooleanSettingState(luv?.local_user?.show_nsfw ?: false) + val showNsfw = rememberIntSettingState(luv?.local_user?.show_nsfw?.ordinal ?: 0) val showScores = rememberBooleanSettingState(luv?.local_user?.show_scores ?: false) val showBotAccount = rememberBooleanSettingState(luv?.local_user?.show_bot_accounts ?: false) val botAccount = rememberBooleanSettingState(luv?.person?.bot_account ?: false) @@ -154,7 +155,7 @@ fun SettingsForm( send_notifications_to_email = sendNotificationsToEmail.value, show_avatars = showAvatars.value, show_bot_accounts = showBotAccount.value, - show_nsfw = showNsfw.value, + show_nsfw = ShowNsfwTypes.entries[showNsfw.value], default_listing_type = ListingType.entries[defaultListingType.value], show_new_post_notifs = showNewPostNotifs.value, show_read_posts = showReadPosts.value, @@ -258,12 +259,14 @@ fun SettingsForm( title = { Text(text = stringResource(R.string.account_settings_default_sort_type)) }, items = sortTypeNames, ) - - SettingsCheckbox( + SettingsListDropdown( state = showNsfw, - title = { - Text(text = stringResource(R.string.account_settings_show_nsfw)) - }, + title = { Text(text = stringResource(R.string.account_settings_show_nsfw)) }, + items = listOf( + stringResource(R.string.account_settings_blur_everywhere), + stringResource(R.string.account_settings_blur_everywhere_except_nsfw), + stringResource(R.string.account_settings_do_not_blur), + ), ) SettingsCheckbox( state = showAvatars, 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..1862212bd 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 @@ -38,6 +38,7 @@ import com.jerboa.PostViewMode import com.jerboa.R import com.jerboa.ThemeColor import com.jerboa.ThemeMode +import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.APP_SETTINGS_DEFAULT import com.jerboa.db.entity.AppSettings import com.jerboa.feat.BackConfirmationMode @@ -89,7 +90,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) @@ -353,12 +354,26 @@ fun LookAndFeelActivity( }, onCheckedChange = { updateAppSettings() }, ) - SettingsCheckbox( + SettingsList( state = blurNSFW, + items = listOf( + stringResource(R.string.account_settings_blur_everywhere), + stringResource(R.string.account_settings_blur_everywhere_except_nsfw), + stringResource(R.string.account_settings_do_not_blur), + ), + icon = { + Icon( + imageVector = Icons.Outlined.ViewList, + contentDescription = null, + ) + }, title = { - Text(stringResource(id = R.string.blur_nsfw)) + Text(text = stringResource(R.string.look_and_feel_post_view)) + }, + onItemSelected = { i, _ -> + postViewModeState.value = i + updateAppSettings() }, - onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( state = showPostLinkPreviewMode, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8d5578e23..da6d0cb1f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,10 +12,13 @@ Avatar Banner Bio + Blur everywhere + Blur everywhere except NSFW Bot Account Default Listing Type Default Sort Type Display Name + Do not blur Email Local Matrix User From 6ff1a1cdaa19cccc7d795e3609f366f13fc339bc Mon Sep 17 00:00:00 2001 From: user Date: Mon, 11 Sep 2023 16:54:40 +0300 Subject: [PATCH 02/11] Revert "Change NSFW Blur toggle to drop-down menu which applies only to NSFW communities (#957)" This reverts commit 0101e34352e66ee5641e2879263b5d4255ef53d2. --- app/schemas/com.jerboa.db.AppDB/26.json | 8 +- app/src/main/java/com/jerboa/MainActivity.kt | 17 ++- app/src/main/java/com/jerboa/Utils.kt | 8 -- .../com/jerboa/datatypes/types/LocalUser.kt | 2 +- .../java/com/jerboa/datatypes/types/Others.kt | 16 --- .../datatypes/types/SaveUserSettings.kt | 2 +- app/src/main/java/com/jerboa/db/AppDB.kt | 4 +- .../java/com/jerboa/db/AppDBMigrations.kt | 119 ------------------ .../java/com/jerboa/db/entity/AppSettings.kt | 4 +- .../ui/components/comment/CommentNode.kt | 8 +- .../ui/components/comment/CommentNodes.kt | 5 +- .../comment/mentionnode/CommentMentionNode.kt | 3 +- .../comment/replynode/CommentReplyNode.kt | 3 +- .../ui/components/community/Community.kt | 10 +- .../components/community/CommunityActivity.kt | 3 +- .../ui/components/community/CommunityLink.kt | 14 +-- .../community/list/CommunityList.kt | 4 +- .../community/list/CommunityListActivity.kt | 3 +- .../com/jerboa/ui/components/drawer/Drawer.kt | 9 +- .../ui/components/drawer/DrawerActivity.kt | 3 +- .../ui/components/home/BottomNavActivity.kt | 13 +- .../jerboa/ui/components/home/HomeActivity.kt | 5 +- .../ui/components/inbox/InboxActivity.kt | 5 +- .../person/PersonProfileActivity.kt | 5 +- .../jerboa/ui/components/post/PostActivity.kt | 3 +- .../jerboa/ui/components/post/PostListing.kt | 46 ++++--- .../jerboa/ui/components/post/PostListings.kt | 5 +- .../settings/account/AccountSettings.kt | 17 ++- .../lookandfeel/LookAndFeelActivity.kt | 23 +--- app/src/main/res/values/strings.xml | 3 - 30 files changed, 93 insertions(+), 277 deletions(-) diff --git a/app/schemas/com.jerboa.db.AppDB/26.json b/app/schemas/com.jerboa.db.AppDB/26.json index 59cde33df..4a5345694 100644 --- a/app/schemas/com.jerboa.db.AppDB/26.json +++ b/app/schemas/com.jerboa.db.AppDB/26.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 26, - "identityHash": "98ab20c6cd84e7fedbb9eccc2e4c44b1", + "identityHash": "bf20da38fc7d03e28121589dfb372eaf", "entities": [ { "tableName": "Account", @@ -71,7 +71,7 @@ }, { "tableName": "AppSettings", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `font_size` INTEGER NOT NULL DEFAULT 16, `theme` INTEGER NOT NULL DEFAULT 0, `theme_color` INTEGER NOT NULL DEFAULT 0, `viewed_changelog` INTEGER NOT NULL DEFAULT 0, `post_view_mode` INTEGER NOT NULL DEFAULT 0, `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0, `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, `use_private_tabs` INTEGER NOT NULL DEFAULT 0, `secure_window` INTEGER NOT NULL DEFAULT 0, `blur_nsfw` INTEGER NOT NULL DEFAULT 1, `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 0, `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0, `backConfirmationMode` INTEGER NOT NULL DEFAULT 1, `show_post_link_previews` INTEGER NOT NULL DEFAULT 1, `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0, `auto_play_gifs` INTEGER NOT NULL DEFAULT 0)", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `font_size` INTEGER NOT NULL DEFAULT 16, `theme` INTEGER NOT NULL DEFAULT 0, `theme_color` INTEGER NOT NULL DEFAULT 0, `viewed_changelog` INTEGER NOT NULL DEFAULT 0, `post_view_mode` INTEGER NOT NULL DEFAULT 0, `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0, `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, `use_private_tabs` INTEGER NOT NULL DEFAULT 0, `secure_window` INTEGER NOT NULL DEFAULT 0, `blur_nsfw` INTEGER NOT NULL DEFAULT 1, `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 1, `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0, `backConfirmationMode` INTEGER NOT NULL DEFAULT 1, `show_post_link_previews` INTEGER NOT NULL DEFAULT 1, `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0, `auto_play_gifs` INTEGER NOT NULL DEFAULT 0)", "fields": [ { "fieldPath": "id", @@ -196,7 +196,7 @@ "columnName": "show_text_descriptions_in_navbar", "affinity": "INTEGER", "notNull": true, - "defaultValue": "0" + "defaultValue": "1" }, { "fieldPath": "markAsReadOnScroll", @@ -247,7 +247,7 @@ "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '98ab20c6cd84e7fedbb9eccc2e4c44b1')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'bf20da38fc7d03e28121589dfb372eaf')" ] } } \ No newline at end of file diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt index 2c32e94e3..927e15f52 100644 --- a/app/src/main/java/com/jerboa/MainActivity.kt +++ b/app/src/main/java/com/jerboa/MainActivity.kt @@ -35,7 +35,6 @@ import com.jerboa.api.API import com.jerboa.api.ApiState import com.jerboa.api.MINIMUM_API_VERSION import com.jerboa.datatypes.types.Community -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.APP_SETTINGS_DEFAULT import com.jerboa.feat.BackConfirmation.addConfirmationDialog import com.jerboa.feat.BackConfirmation.addConfirmationToast @@ -267,7 +266,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showPostLinkPreviews = appSettings.showPostLinkPreviews, markAsReadOnScroll = appSettings.markAsReadOnScroll, postActionbarMode = appSettings.postActionbarMode, @@ -309,7 +308,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showPostLinkPreviews = appSettings.showPostLinkPreviews, markAsReadOnScroll = appSettings.markAsReadOnScroll, postActionbarMode = appSettings.postActionbarMode, @@ -380,7 +379,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, onBack = appState::popBackStack, @@ -416,7 +415,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, markAsReadOnScroll = appSettings.markAsReadOnScroll, @@ -439,7 +438,7 @@ class MainActivity : AppCompatActivity() { accountViewModel = accountViewModel, siteViewModel = siteViewModel, selectMode = args.select, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, drawerState = drawerState, ) } @@ -494,7 +493,7 @@ class MainActivity : AppCompatActivity() { appState = appState, accountViewModel = accountViewModel, siteViewModel = siteViewModel, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, drawerState = drawerState, ) } @@ -528,7 +527,7 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showPostLinkPreview = appSettings.showPostLinkPreviews, postActionbarMode = appSettings.postActionbarMode, ) @@ -559,7 +558,7 @@ class MainActivity : AppCompatActivity() { showParentCommentNavigationButtons = appSettings.showParentCommentNavigationButtons, navigateParentCommentsWithVolumeButtons = appSettings.navigateParentCommentsWithVolumeButtons, siteViewModel = siteViewModel, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showPostLinkPreview = appSettings.showPostLinkPreviews, postActionbarMode = appSettings.postActionbarMode, ) diff --git a/app/src/main/java/com/jerboa/Utils.kt b/app/src/main/java/com/jerboa/Utils.kt index c6e14e9cc..f7a1c50be 100644 --- a/app/src/main/java/com/jerboa/Utils.kt +++ b/app/src/main/java/com/jerboa/Utils.kt @@ -939,14 +939,6 @@ fun nsfwCheck(postView: PostView): Boolean { return postView.post.nsfw || postView.community.nsfw } -fun needNsfwBlur(settings: ShowNsfwTypes, isCommunityNsfw: Boolean, isPostNsfw: Boolean = true): Boolean { - return isPostNsfw && when(settings){ - ShowNsfwTypes.BlurEverywhere -> true - ShowNsfwTypes.DoNotBlur -> false - ShowNsfwTypes.BlurEverywhereExceptNsfw -> !isCommunityNsfw - } -} - @RequiresApi(Build.VERSION_CODES.Q) @Throws(IOException::class) fun saveMediaQ( diff --git a/app/src/main/java/com/jerboa/datatypes/types/LocalUser.kt b/app/src/main/java/com/jerboa/datatypes/types/LocalUser.kt index b56dafab2..ab9f7fddd 100644 --- a/app/src/main/java/com/jerboa/datatypes/types/LocalUser.kt +++ b/app/src/main/java/com/jerboa/datatypes/types/LocalUser.kt @@ -8,7 +8,7 @@ data class LocalUser( val id: LocalUserId, val person_id: PersonId, val email: String? = null, - val show_nsfw: ShowNsfwTypes /* "BlurEverywhere" | "BlurEverywhereExceptNsfw" | "DoNotBlur" */, + val show_nsfw: Boolean, val theme: String, val default_sort_type: SortType /* "Active" | "Hot" | "New" | "Old" | "TopDay" | "TopWeek" | "TopMonth" | "TopYear" | "TopAll" | "MostComments" | "NewComments" | "TopHour" | "TopSixHour" | "TopTwelveHour" */, val default_listing_type: ListingType /* "All" | "Local" | "Subscribed" */, diff --git a/app/src/main/java/com/jerboa/datatypes/types/Others.kt b/app/src/main/java/com/jerboa/datatypes/types/Others.kt index e240c0f71..e448c154e 100644 --- a/app/src/main/java/com/jerboa/datatypes/types/Others.kt +++ b/app/src/main/java/com/jerboa/datatypes/types/Others.kt @@ -382,22 +382,6 @@ enum class ModlogActionType { AdminPurgeComment, } -/** - * Different show nsfw states - */ -enum class ShowNsfwTypes { - - @SerializedName("BlurEverywhere") - BlurEverywhere, - - @SerializedName("BlurEverywhereExceptNsfw") - BlurEverywhereExceptNsfw, - - @SerializedName("DoNotBlur") - DoNotBlur; - -} - @Parcelize data class PictrsImage( val file: String, diff --git a/app/src/main/java/com/jerboa/datatypes/types/SaveUserSettings.kt b/app/src/main/java/com/jerboa/datatypes/types/SaveUserSettings.kt index 61977f70f..4d740ac5d 100644 --- a/app/src/main/java/com/jerboa/datatypes/types/SaveUserSettings.kt +++ b/app/src/main/java/com/jerboa/datatypes/types/SaveUserSettings.kt @@ -7,7 +7,7 @@ import kotlinx.parcelize.Parcelize @Immutable @Parcelize data class SaveUserSettings( - val show_nsfw: ShowNsfwTypes? /* "BlurEverywhere" | "BlurEverywhereExceptNsfw" | "DoNotBlur" */ = null, + val show_nsfw: Boolean? = null, val show_scores: Boolean? = null, val theme: String? = null, val default_sort_type: SortType? /* "Active" | "Hot" | "New" | "Old" | "TopDay" | "TopWeek" | "TopMonth" | "TopYear" | "TopAll" | "MostComments" | "NewComments" | "TopHour" | "TopSixHour" | "TopTwelveHour" */ = null, diff --git a/app/src/main/java/com/jerboa/db/AppDB.kt b/app/src/main/java/com/jerboa/db/AppDB.kt index b6efe1612..d09b1c794 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 = 0, + blurNSFW = true, showTextDescriptionsInNavbar = true, backConfirmationMode = 1, markAsReadOnScroll = false, @@ -42,7 +42,7 @@ val APP_SETTINGS_DEFAULT = AppSettings( ) @Database( - version = 27, + version = 26, entities = [Account::class, AppSettings::class], exportSchema = true, ) diff --git a/app/src/main/java/com/jerboa/db/AppDBMigrations.kt b/app/src/main/java/com/jerboa/db/AppDBMigrations.kt index 0a22d65f4..d45a071da 100644 --- a/app/src/main/java/com/jerboa/db/AppDBMigrations.kt +++ b/app/src/main/java/com/jerboa/db/AppDBMigrations.kt @@ -354,123 +354,6 @@ val MIGRATION_26_25 = object : Migration(26, 25) { } } -val MIGRATION_26_27 = object : Migration(26, 27) { - override fun migrate(database: SupportSQLiteDatabase) { - - database.execSQL( - """ - CREATE TABLE IF NOT EXISTS AppSettingsBackup ( - `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, - `font_size` INTEGER NOT NULL DEFAULT 16, - `theme` INTEGER NOT NULL DEFAULT 0, - `theme_color` INTEGER NOT NULL DEFAULT 0, - `viewed_changelog` INTEGER NOT NULL DEFAULT 0, - `post_view_mode` INTEGER NOT NULL DEFAULT 0, - `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, - `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, - `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, - `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, - `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, - `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, - `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, - `use_private_tabs` INTEGER NOT NULL DEFAULT 0, - `secure_window` INTEGER NOT NULL DEFAULT 0, - `blur_nsfw` INTEGER NOT NULL DEFAULT 0, - `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 1, - `backConfirmationMode` INTEGER NOT NULL DEFAULT 1, - `show_post_link_previews` INTEGER NOT NULL DEFAULT 1, - `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0, - `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0, - `auto_play_gifs` INTEGER NOT NULL DEFAULT 0, - `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0 - ) - - """.trimIndent(), - ) - - database.execSQL( - """ - INSERT INTO AppSettingsBackup SELECT * FROM AppSettings - """, - ) - database.execSQL("DROP TABLE AppSettings") - database.execSQL("ALTER TABLE AppSettingsBackup RENAME to AppSettings") - - database.execSQL( - """ - UPDATE AppSettings - SET blur_nsfw = 2 - WHERE blur_nsfw = 0 - """.trimIndent(), - ) - database.execSQL( - """ - UPDATE AppSettings - SET blur_nsfw = 0 - WHERE blur_nsfw = 1 - """.trimIndent(), - ) - } -} - -val MIGRATION_27_26 = object : Migration(27, 26) { - override fun migrate(database: SupportSQLiteDatabase) { - database.execSQL( - """ - CREATE TABLE IF NOT EXISTS AppSettingsBackup ( - `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, - `font_size` INTEGER NOT NULL DEFAULT 16, - `theme` INTEGER NOT NULL DEFAULT 0, - `theme_color` INTEGER NOT NULL DEFAULT 0, - `viewed_changelog` INTEGER NOT NULL DEFAULT 0, - `post_view_mode` INTEGER NOT NULL DEFAULT 0, - `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, - `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, - `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, - `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, - `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, - `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, - `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, - `use_private_tabs` INTEGER NOT NULL DEFAULT 0, - `secure_window` INTEGER NOT NULL DEFAULT 0, - `blur_nsfw` INTEGER NOT NULL DEFAULT 1, - `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 1, - `backConfirmationMode` INTEGER NOT NULL DEFAULT 1 - `show_post_link_previews` INTEGER NOT NULL DEFAULT 1 - `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0 - `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0 - `auto_play_gifs` INTEGER NOT NULL DEFAULT 0 - `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0 - ) - - """.trimIndent(), - ) - - database.execSQL( - """ - INSERT INTO AppSettingsBackup SELECT * FROM AppSettings - """, - ) - database.execSQL("DROP TABLE AppSettings") - database.execSQL("ALTER TABLE AppSettingsBackup RENAME to AppSettings") - - database.execSQL( - """ - UPDATE AppSettings - SET blur_nsfw = 1 - WHERE blur_nsfw = 0 - """.trimIndent(), - ) - database.execSQL( - """ - UPDATE AppSettings - SET blur_nsfw = 0 - WHERE blur_nsfw = 2 - """.trimIndent(), - ) - } -} - // Don't forget to test your migration with `./gradlew app:connectAndroidTest` val MIGRATIONS_LIST = arrayOf( MIGRATION_1_2, @@ -503,6 +386,4 @@ val MIGRATIONS_LIST = arrayOf( MIGRATION_25_24, MIGRATION_25_26, MIGRATION_26_25, - MIGRATION_26_27, - MIGRATION_27_26, ) 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 885c89050..9d9a0b0d8 100644 --- a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt +++ b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt @@ -85,9 +85,9 @@ data class AppSettings( val secureWindow: Boolean, @ColumnInfo( name = "blur_nsfw", - defaultValue = "0", + defaultValue = "1", ) - val blurNSFW: Int, + val blurNSFW: Boolean, @ColumnInfo( name = "show_text_descriptions_in_navbar", defaultValue = "1", 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 8aa8c9792..24b0b2fa5 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 @@ -216,7 +216,7 @@ fun LazyListScope.commentNodeItem( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showScores: Boolean, ) { val commentView = node.commentView @@ -483,7 +483,7 @@ fun PostAndCommunityContextHeader( community: Community, onCommunityClick: (community: Community) -> Unit, onPostClick: (postId: Int) -> Unit, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, ) { Column( modifier = Modifier.padding(top = LARGE_PADDING), @@ -515,7 +515,7 @@ fun PostAndCommunityContextHeaderPreview() { community = sampleCommunity, onCommunityClick = {}, onPostClick = {}, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, ) } @@ -690,7 +690,7 @@ fun CommentNodesPreview() { showActionBar = { _ -> true }, enableDownVotes = true, showAvatar = true, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, 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 2b039c980..ac7905ae2 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 @@ -12,7 +12,6 @@ import com.jerboa.CommentNodeData import com.jerboa.datatypes.types.CommentView import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import kotlinx.collections.immutable.ImmutableList @@ -51,7 +50,7 @@ fun CommentNodes( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showScores: Boolean, ) { LazyColumn(state = listState) { @@ -130,7 +129,7 @@ fun LazyListScope.commentNodeItems( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, 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 75312928b..cbde0b7d5 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 @@ -43,7 +43,6 @@ import com.jerboa.datatypes.samplePersonMentionView import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person import com.jerboa.datatypes.types.PersonMentionView -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.ui.components.comment.CommentBody import com.jerboa.ui.components.comment.PostAndCommunityContextHeader @@ -337,7 +336,7 @@ fun CommentMentionNode( onBlockCreatorClick: (creator: Person) -> Unit, account: Account, showAvatar: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, 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 d34477729..99908a818 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 @@ -41,7 +41,6 @@ import com.jerboa.datatypes.sampleCommentReplyView import com.jerboa.datatypes.types.CommentReplyView import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.ui.components.comment.CommentBody import com.jerboa.ui.components.comment.PostAndCommunityContextHeader @@ -322,7 +321,7 @@ fun CommentReplyNodeInbox( onBlockCreatorClick: (creator: Person) -> Unit, account: Account, showAvatar: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, 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 f62d9951f..970b80b6f 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 @@ -16,10 +16,8 @@ import com.jerboa.PostViewMode import com.jerboa.R import com.jerboa.datatypes.sampleCommunityView import com.jerboa.datatypes.types.CommunityView -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SortType import com.jerboa.datatypes.types.SubscribedType -import com.jerboa.needNsfwBlur import com.jerboa.ui.components.common.LargerCircularIcon import com.jerboa.ui.components.common.MenuItem import com.jerboa.ui.components.common.PictrsBannerImage @@ -33,7 +31,7 @@ fun CommunityTopSection( communityView: CommunityView, modifier: Modifier = Modifier, onClickFollowCommunity: (communityView: CommunityView) -> Unit, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, ) { Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -47,11 +45,11 @@ fun CommunityTopSection( PictrsBannerImage( url = it, modifier = Modifier.height(DRAWER_BANNER_SIZE), - blur = needNsfwBlur(blurNSFW, communityView.community.nsfw), + blur = blurNSFW && communityView.community.nsfw, ) } communityView.community.icon?.also { - LargerCircularIcon(icon = it, blur = needNsfwBlur(blurNSFW, communityView.community.nsfw)) + LargerCircularIcon(icon = it, blur = blurNSFW && communityView.community.nsfw) } } Column( @@ -121,7 +119,7 @@ fun CommunityTopSectionPreview() { CommunityTopSection( communityView = sampleCommunityView, onClickFollowCommunity = {}, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, ) } 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 d14ec211e..af01f9c7c 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 @@ -49,7 +49,6 @@ import com.jerboa.datatypes.types.GetSite import com.jerboa.datatypes.types.MarkPostAsRead import com.jerboa.datatypes.types.PostView import com.jerboa.datatypes.types.SavePost -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SubscribedType import com.jerboa.db.entity.getJWT import com.jerboa.db.entity.isAnon @@ -90,7 +89,7 @@ fun CommunityActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, postActionbarMode: Int, 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 3125966de..5414f01c9 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,8 +27,6 @@ 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.datatypes.types.ShowNsfwTypes -import com.jerboa.needNsfwBlur import com.jerboa.ui.components.common.CircularIcon import com.jerboa.ui.theme.DRAWER_ITEM_SPACING import com.jerboa.ui.theme.ICON_SIZE @@ -75,7 +73,7 @@ fun CommunityLink( onClick: (community: Community) -> Unit, clickable: Boolean = true, showDefaultIcon: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, ) { Row( verticalAlignment = Alignment.CenterVertically, @@ -92,7 +90,7 @@ fun CommunityLink( contentDescription = null, size = size, thumbnailSize = thumbnailSize, - blur = needNsfwBlur(blurNSFW, community.nsfw), + blur = blurNSFW && community.nsfw, ) } ?: run { if (showDefaultIcon) { @@ -120,7 +118,7 @@ fun CommunityLinkLarger( community: Community, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, ) { CommunityLink( community = community, @@ -143,7 +141,7 @@ fun CommunityLinkLargerWithUserCount( communityView: CommunityView, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, ) { CommunityLink( community = communityView.community, @@ -169,7 +167,7 @@ fun CommunityLinkPreview() { community = sampleCommunity, onClick = {}, showDefaultIcon = true, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, ) } @@ -180,6 +178,6 @@ fun CommunityLinkWithUsersPreview() { communityView = sampleCommunityView, onClick = {}, showDefaultIcon = true, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, ) } 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 763fb9300..9e2db2d49 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: ShowNsfwTypes, + blurNSFW: Boolean, ) { val listState = rememberLazyListState() @@ -111,7 +111,7 @@ fun CommunityListingsPreview() { CommunityListings( communities = communities, onClickCommunity = {}, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, ) } 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 1cdfcd17c..f929d648c 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 @@ -20,7 +20,6 @@ import com.jerboa.JerboaAppState import com.jerboa.api.ApiState import com.jerboa.datatypes.types.Search import com.jerboa.datatypes.types.SearchType -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SortType import com.jerboa.db.entity.getJWT import com.jerboa.model.AccountViewModel @@ -47,7 +46,7 @@ fun CommunityListActivity( accountViewModel: AccountViewModel, selectMode: Boolean = false, siteViewModel: SiteViewModel, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, 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 e8f94819a..363e5dce3 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 @@ -50,7 +50,6 @@ import com.jerboa.datatypes.types.CommunityFollowerView import com.jerboa.datatypes.types.ListingType import com.jerboa.datatypes.types.MyUserInfo import com.jerboa.datatypes.types.Person -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount import com.jerboa.db.entity.isAnon @@ -87,7 +86,7 @@ fun Drawer( onCommunityClick: (community: Community) -> Unit, onClickSettings: () -> Unit, isOpen: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -137,7 +136,7 @@ fun DrawerContent( onClickSettings: () -> Unit, myUserInfo: MyUserInfo?, unreadCount: Int, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -181,7 +180,7 @@ fun DrawerItemsMain( onClickListingType: (ListingType) -> Unit, onCommunityClick: (community: Community) -> Unit, unreadCount: Int, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -293,7 +292,7 @@ fun DrawerItemsMainPreview() { onCommunityClick = {}, onClickSettings = {}, unreadCount = 2, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, 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 5b1563b0b..9ea2fab8c 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 @@ -10,7 +10,6 @@ import androidx.compose.runtime.setValue import com.jerboa.api.ApiState import com.jerboa.closeDrawer import com.jerboa.datatypes.types.CommunityFollowerView -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.isAnon import com.jerboa.db.entity.isReady import com.jerboa.model.AccountViewModel @@ -32,7 +31,7 @@ fun MainDrawer( onCommunityClick: (Int) -> Unit, onClickLogin: () -> Unit, onSelectTab: (NavTab) -> Unit, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showBottomNav: Boolean, ) { val account = getCurrentAccount(accountViewModel) diff --git a/app/src/main/java/com/jerboa/ui/components/home/BottomNavActivity.kt b/app/src/main/java/com/jerboa/ui/components/home/BottomNavActivity.kt index 1b18a3154..053ba95e6 100644 --- a/app/src/main/java/com/jerboa/ui/components/home/BottomNavActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/home/BottomNavActivity.kt @@ -41,7 +41,6 @@ import androidx.navigation.compose.rememberNavController import arrow.core.Either import com.jerboa.JerboaAppState import com.jerboa.R -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.AppSettings import com.jerboa.feat.doIfReadyElseDisplayInfo import com.jerboa.model.AccountViewModel @@ -166,7 +165,7 @@ fun BottomNavActivity( scope = scope, drawerState = drawerState, onSelectTab = onSelectTab, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showBottomNav = appSettings.showBottomNav, onCommunityClick = appState::toCommunity, onSettingsClick = appState::toSettings, @@ -214,7 +213,7 @@ fun BottomNavActivity( useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, drawerState = drawerState, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showPostLinkPreviews = appSettings.showPostLinkPreviews, markAsReadOnScroll = appSettings.markAsReadOnScroll, postActionbarMode = appSettings.postActionbarMode, @@ -227,7 +226,7 @@ fun BottomNavActivity( accountViewModel = accountViewModel, selectMode = false, siteViewModel = siteViewModel, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, drawerState = drawerState, ) } @@ -237,7 +236,7 @@ fun BottomNavActivity( appState = appState, accountViewModel = accountViewModel, siteViewModel = siteViewModel, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, drawerState = drawerState, ) } @@ -253,7 +252,7 @@ fun BottomNavActivity( siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, markAsReadOnScroll = appSettings.markAsReadOnScroll, @@ -272,7 +271,7 @@ fun BottomNavActivity( siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = ShowNsfwTypes.entries[appSettings.blurNSFW], + blurNSFW = appSettings.blurNSFW, showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, markAsReadOnScroll = appSettings.markAsReadOnScroll, 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 a1abc6d1f..74e21f4de 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 @@ -50,7 +50,6 @@ import com.jerboa.datatypes.types.DeletePost import com.jerboa.datatypes.types.MarkPostAsRead import com.jerboa.datatypes.types.PostView import com.jerboa.datatypes.types.SavePost -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.Tagline import com.jerboa.db.entity.Account import com.jerboa.db.entity.isAnon @@ -92,7 +91,7 @@ fun HomeActivity( useCustomTabs: Boolean, usePrivateTabs: Boolean, drawerState: DrawerState, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, postActionbarMode: Int, @@ -206,7 +205,7 @@ fun MainPostListingsContent( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, 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 a7c19854b..00f9a57a3 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 @@ -54,7 +54,6 @@ import com.jerboa.datatypes.types.MarkCommentReplyAsRead import com.jerboa.datatypes.types.MarkPersonMentionAsRead import com.jerboa.datatypes.types.MarkPrivateMessageAsRead import com.jerboa.datatypes.types.SaveComment -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.db.entity.isAnon import com.jerboa.feat.doIfReadyElseDisplayInfo @@ -91,7 +90,7 @@ fun InboxActivity( drawerState: DrawerState, siteViewModel: SiteViewModel, accountViewModel: AccountViewModel, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, ) { Log.d("jerboa", "got to inbox activity") @@ -223,7 +222,7 @@ fun InboxTabs( scope: CoroutineScope, snackbarHostState: SnackbarHostState, padding: PaddingValues, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, ) { val transferPrivateMessageDepsViaRoot = appState.rootChannel() val transferCommentReplyDepsViaRoot = appState.rootChannel() 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 dac8f4005..b4f883ab1 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 @@ -67,7 +67,6 @@ import com.jerboa.datatypes.types.PersonId import com.jerboa.datatypes.types.PostView import com.jerboa.datatypes.types.SaveComment import com.jerboa.datatypes.types.SavePost -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SortType import com.jerboa.db.entity.Account import com.jerboa.db.entity.getJWT @@ -120,7 +119,7 @@ fun PersonProfileActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showPostLinkPreviews: Boolean, drawerState: DrawerState, markAsReadOnScroll: Boolean, @@ -323,7 +322,7 @@ fun UserTabs( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, 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 bdaed43bf..da3117af2 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 @@ -74,7 +74,6 @@ import com.jerboa.datatypes.types.PostId import com.jerboa.datatypes.types.PostView import com.jerboa.datatypes.types.SaveComment import com.jerboa.datatypes.types.SavePost -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.isAnon import com.jerboa.feat.doIfReadyElseDisplayInfo import com.jerboa.feat.shareLink @@ -148,7 +147,7 @@ fun PostActivity( showVotingArrowsInListView: Boolean, showParentCommentNavigationButtons: Boolean, navigateParentCommentsWithVolumeButtons: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, 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 c374132ce..cf5c0037c 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 @@ -85,14 +85,12 @@ import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person import com.jerboa.datatypes.types.Post import com.jerboa.datatypes.types.PostView -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount import com.jerboa.feat.PostActionbarMode import com.jerboa.getPostType import com.jerboa.hostName import com.jerboa.isSameInstance -import com.jerboa.needNsfwBlur import com.jerboa.nsfwCheck import com.jerboa.rememberJerboaAppState import com.jerboa.siFormat @@ -141,7 +139,7 @@ fun PostHeaderLine( modifier: Modifier = Modifier, showCommunityName: Boolean = true, showAvatar: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showScores: Boolean, ) { val community = postView.community @@ -162,7 +160,7 @@ fun PostHeaderLine( size = MEDIUM_ICON_SIZE, modifier = Modifier.clickable { onCommunityClick(community) }, thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE, - blur = needNsfwBlur(blurNSFW, community.nsfw, postView.post.nsfw), + blur = blurNSFW && community.nsfw, ) } } @@ -251,7 +249,7 @@ fun PostHeaderLinePreview() { onCommunityClick = {}, onPersonClick = {}, showAvatar = true, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, showScores = true, ) } @@ -291,7 +289,7 @@ fun PostTitleBlock( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -346,7 +344,7 @@ fun PostName( @Composable fun PostTitleAndImageLink( postView: PostView, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -369,7 +367,7 @@ fun PostTitleAndImageLink( PictrsUrlImage( url = url, - blur = needNsfwBlur(blurNSFW, postView.community.nsfw, postView.post.nsfw), + blur = blurNSFW && nsfwCheck(postView), modifier = Modifier .combinedClickable( onClick = { appState.openImageViewer(url) }, @@ -384,7 +382,7 @@ fun PostTitleAndThumbnail( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -433,7 +431,7 @@ fun PostBody( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showPostLinkPreview: Boolean, appState: JerboaAppState, clickBody: () -> Unit = {}, @@ -519,7 +517,7 @@ fun PreviewStoryTitleAndMetadata() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -537,7 +535,7 @@ fun PreviewSourcePost() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -831,7 +829,7 @@ fun PreviewPostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -867,7 +865,7 @@ fun PreviewLinkPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -903,7 +901,7 @@ fun PreviewImagePostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -939,7 +937,7 @@ fun PreviewImagePostListingSmallCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -975,7 +973,7 @@ fun PreviewLinkNoThumbnailPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -1011,7 +1009,7 @@ fun PostListing( showVotingArrowsInListView: Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, appState: JerboaAppState, showPostLinkPreview: Boolean, showIfRead: Boolean, @@ -1230,7 +1228,7 @@ fun PostListingList( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, appState: JerboaAppState, showIfRead: Boolean, enableDownVotes: Boolean, @@ -1352,7 +1350,7 @@ private fun ThumbnailTile( postView: PostView, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, appState: JerboaAppState, ) { postView.post.url?.also { url -> @@ -1382,7 +1380,7 @@ private fun ThumbnailTile( postView.post.thumbnail_url?.also { thumbnail -> PictrsThumbnailImage( thumbnail = thumbnail, - blur = needNsfwBlur(blurNSFW, postView.community.nsfw, postView.post.nsfw), + blur = blurNSFW && nsfwCheck(postView), roundBottomEndCorner = postType != PostType.Link, modifier = postLinkPicMod, ) @@ -1446,7 +1444,7 @@ fun PostListingListPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1477,7 +1475,7 @@ fun PostListingListWithThumbPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1514,7 +1512,7 @@ fun PostListingCard( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, 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 9f47f22f2..031118bbf 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 @@ -25,7 +25,6 @@ import com.jerboa.datatypes.samplePostView import com.jerboa.datatypes.types.Community import com.jerboa.datatypes.types.Person import com.jerboa.datatypes.types.PostView -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount import com.jerboa.isScrolledToEnd @@ -62,7 +61,7 @@ fun PostListings( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: ShowNsfwTypes, + blurNSFW: Boolean, showPostLinkPreviews: Boolean, appState: JerboaAppState, markAsReadOnScroll: Boolean, @@ -173,7 +172,7 @@ fun PreviewPostListings() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = ShowNsfwTypes.BlurEverywhere, + blurNSFW = true, showPostLinkPreviews = true, appState = rememberJerboaAppState(), markAsReadOnScroll = false, diff --git a/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt b/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt index c40053bc1..94d580ab2 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt @@ -28,7 +28,6 @@ import com.jerboa.api.ApiState import com.jerboa.api.uploadPictrsImage import com.jerboa.datatypes.types.ListingType import com.jerboa.datatypes.types.SaveUserSettings -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.datatypes.types.SortType import com.jerboa.db.entity.Account import com.jerboa.imageInputStreamFromUri @@ -129,7 +128,7 @@ fun SettingsForm( val defaultListingType = rememberIntSettingState(luv?.local_user?.default_listing_type?.ordinal ?: 0) val showAvatars = rememberBooleanSettingState(luv?.local_user?.show_avatars ?: false) - val showNsfw = rememberIntSettingState(luv?.local_user?.show_nsfw?.ordinal ?: 0) + val showNsfw = rememberBooleanSettingState(luv?.local_user?.show_nsfw ?: false) val showScores = rememberBooleanSettingState(luv?.local_user?.show_scores ?: false) val showBotAccount = rememberBooleanSettingState(luv?.local_user?.show_bot_accounts ?: false) val botAccount = rememberBooleanSettingState(luv?.person?.bot_account ?: false) @@ -155,7 +154,7 @@ fun SettingsForm( send_notifications_to_email = sendNotificationsToEmail.value, show_avatars = showAvatars.value, show_bot_accounts = showBotAccount.value, - show_nsfw = ShowNsfwTypes.entries[showNsfw.value], + show_nsfw = showNsfw.value, default_listing_type = ListingType.entries[defaultListingType.value], show_new_post_notifs = showNewPostNotifs.value, show_read_posts = showReadPosts.value, @@ -259,14 +258,12 @@ fun SettingsForm( title = { Text(text = stringResource(R.string.account_settings_default_sort_type)) }, items = sortTypeNames, ) - SettingsListDropdown( + + SettingsCheckbox( state = showNsfw, - title = { Text(text = stringResource(R.string.account_settings_show_nsfw)) }, - items = listOf( - stringResource(R.string.account_settings_blur_everywhere), - stringResource(R.string.account_settings_blur_everywhere_except_nsfw), - stringResource(R.string.account_settings_do_not_blur), - ), + title = { + Text(text = stringResource(R.string.account_settings_show_nsfw)) + }, ) SettingsCheckbox( state = showAvatars, 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 1862212bd..69793b864 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 @@ -38,7 +38,6 @@ import com.jerboa.PostViewMode import com.jerboa.R import com.jerboa.ThemeColor import com.jerboa.ThemeMode -import com.jerboa.datatypes.types.ShowNsfwTypes import com.jerboa.db.APP_SETTINGS_DEFAULT import com.jerboa.db.entity.AppSettings import com.jerboa.feat.BackConfirmationMode @@ -90,7 +89,7 @@ fun LookAndFeelActivity( val usePrivateTabsState = rememberBooleanSettingState(settings.usePrivateTabs) val secureWindowState = rememberBooleanSettingState(settings.secureWindow) - val blurNSFW = rememberIntSettingState(settings.blurNSFW) + val blurNSFW = rememberBooleanSettingState(settings.blurNSFW) val backConfirmationMode = rememberIntSettingState(settings.backConfirmationMode) val showPostLinkPreviewMode = rememberBooleanSettingState(settings.showPostLinkPreviews) val postActionbarMode = rememberIntSettingState(settings.postActionbarMode) @@ -354,26 +353,12 @@ fun LookAndFeelActivity( }, onCheckedChange = { updateAppSettings() }, ) - SettingsList( + SettingsCheckbox( state = blurNSFW, - items = listOf( - stringResource(R.string.account_settings_blur_everywhere), - stringResource(R.string.account_settings_blur_everywhere_except_nsfw), - stringResource(R.string.account_settings_do_not_blur), - ), - icon = { - Icon( - imageVector = Icons.Outlined.ViewList, - contentDescription = null, - ) - }, title = { - Text(text = stringResource(R.string.look_and_feel_post_view)) - }, - onItemSelected = { i, _ -> - postViewModeState.value = i - updateAppSettings() + Text(stringResource(id = R.string.blur_nsfw)) }, + onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( state = showPostLinkPreviewMode, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index da6d0cb1f..8d5578e23 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,13 +12,10 @@ Avatar Banner Bio - Blur everywhere - Blur everywhere except NSFW Bot Account Default Listing Type Default Sort Type Display Name - Do not blur Email Local Matrix User From 3dbe8e38202431fd7928363e4f8b64450899f564 Mon Sep 17 00:00:00 2001 From: user Date: Mon, 11 Sep 2023 19:29:51 +0300 Subject: [PATCH 03/11] Change NSFW Blur toggle to drop-down menu with new options (#957) --- app/src/main/java/com/jerboa/Utils.kt | 10 +++++ app/src/main/java/com/jerboa/db/AppDB.kt | 2 +- .../java/com/jerboa/db/entity/AppSettings.kt | 2 +- .../java/com/jerboa/feat/BlurNsfwTypes.kt | 14 ++++++ .../ui/components/comment/CommentNode.kt | 8 ++-- .../ui/components/comment/CommentNodes.kt | 4 +- .../comment/mentionnode/CommentMentionNode.kt | 2 +- .../comment/replynode/CommentReplyNode.kt | 2 +- .../ui/components/community/Community.kt | 12 +++-- .../components/community/CommunityActivity.kt | 2 +- .../ui/components/community/CommunityLink.kt | 14 +++--- .../community/list/CommunityList.kt | 4 +- .../community/list/CommunityListActivity.kt | 2 +- .../com/jerboa/ui/components/drawer/Drawer.kt | 8 ++-- .../ui/components/drawer/DrawerActivity.kt | 2 +- .../jerboa/ui/components/home/HomeActivity.kt | 4 +- .../ui/components/inbox/InboxActivity.kt | 4 +- .../person/PersonProfileActivity.kt | 4 +- .../jerboa/ui/components/post/PostActivity.kt | 2 +- .../jerboa/ui/components/post/PostListing.kt | 45 ++++++++++--------- .../jerboa/ui/components/post/PostListings.kt | 4 +- .../lookandfeel/LookAndFeelActivity.kt | 20 +++++---- app/src/main/res/values/strings.xml | 4 ++ 23 files changed, 107 insertions(+), 68 deletions(-) create mode 100644 app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt diff --git a/app/src/main/java/com/jerboa/Utils.kt b/app/src/main/java/com/jerboa/Utils.kt index f7a1c50be..31d3c9375 100644 --- a/app/src/main/java/com/jerboa/Utils.kt +++ b/app/src/main/java/com/jerboa/Utils.kt @@ -74,6 +74,7 @@ import com.jerboa.api.ApiState import com.jerboa.datatypes.types.* import com.jerboa.db.APP_SETTINGS_DEFAULT import com.jerboa.db.entity.AppSettings +import com.jerboa.feat.BlurNsfwTypes import com.jerboa.ui.components.common.Route import com.jerboa.ui.components.inbox.InboxTab import com.jerboa.ui.components.person.UserTab @@ -939,6 +940,15 @@ fun nsfwCheck(postView: PostView): Boolean { return postView.post.nsfw || postView.community.nsfw } +fun needNsfwBlur(settings: BlurNsfwTypes, isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean { + return isPostNsfw && when(settings){ + BlurNsfwTypes.DoNotBlur -> false + BlurNsfwTypes.BlurEverywhere -> true + BlurNsfwTypes.BlurEverywhereExceptNsfw -> !isCommunityNsfw + BlurNsfwTypes.BlurOnlyNsfwCommunity -> isCommunityNsfw + } +} + @RequiresApi(Build.VERSION_CODES.Q) @Throws(IOException::class) fun saveMediaQ( 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/BlurNsfwTypes.kt b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt new file mode 100644 index 000000000..f4161321c --- /dev/null +++ b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt @@ -0,0 +1,14 @@ +package com.jerboa.feat + +import android.os.Parcelable +import androidx.annotation.StringRes +import com.jerboa.R +import kotlinx.parcelize.Parcelize + +@Parcelize +enum class BlurNsfwTypes(@StringRes val resId: Int) : Parcelable { + DoNotBlur(R.string.app_settings_do_not_blur), + BlurEverywhere(R.string.app_settings_blur_everywhere), + BlurEverywhereExceptNsfw(R.string.app_settings_blur_everywhere_except_nsfw), + BlurOnlyNsfwCommunity(R.string.app_settings_blur_only_nsfw_community), +} 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 24b0b2fa5..8a75c511e 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 @@ -216,7 +216,7 @@ fun LazyListScope.commentNodeItem( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showScores: Boolean, ) { val commentView = node.commentView @@ -483,7 +483,7 @@ fun PostAndCommunityContextHeader( community: Community, onCommunityClick: (community: Community) -> Unit, onPostClick: (postId: Int) -> Unit, - blurNSFW: Boolean, + blurNSFW: Int, ) { Column( modifier = Modifier.padding(top = LARGE_PADDING), @@ -515,7 +515,7 @@ fun PostAndCommunityContextHeaderPreview() { community = sampleCommunity, onCommunityClick = {}, onPostClick = {}, - blurNSFW = true, + blurNSFW = 1, ) } @@ -690,7 +690,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 ac7905ae2..d1ebb7a52 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 @@ -50,7 +50,7 @@ fun CommentNodes( showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showScores: Boolean, ) { LazyColumn(state = listState) { @@ -129,7 +129,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 cbde0b7d5..c108ec779 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 @@ -336,7 +336,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 99908a818..ecd9c9291 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 @@ -321,7 +321,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 970b80b6f..ac3d864b6 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 @@ -18,6 +18,10 @@ 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.BlurNsfwTypes +import com.jerboa.feat.PostActionbarMode +import com.jerboa.needNsfwBlur +import com.jerboa.toEnum import com.jerboa.ui.components.common.LargerCircularIcon import com.jerboa.ui.components.common.MenuItem import com.jerboa.ui.components.common.PictrsBannerImage @@ -31,7 +35,7 @@ fun CommunityTopSection( communityView: CommunityView, modifier: Modifier = Modifier, onClickFollowCommunity: (communityView: CommunityView) -> Unit, - blurNSFW: Boolean, + blurNSFW: Int, ) { Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -45,11 +49,11 @@ fun CommunityTopSection( PictrsBannerImage( url = it, modifier = Modifier.height(DRAWER_BANNER_SIZE), - blur = blurNSFW && communityView.community.nsfw, + blur = needNsfwBlur(blurNSFW.toEnum(), communityView.community.nsfw), ) } communityView.community.icon?.also { - LargerCircularIcon(icon = it, blur = blurNSFW && communityView.community.nsfw) + LargerCircularIcon(icon = it, blur = needNsfwBlur(blurNSFW.toEnum(), communityView.community.nsfw)) } } Column( @@ -119,7 +123,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 af01f9c7c..dcf144619 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 @@ -89,7 +89,7 @@ fun CommunityActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, postActionbarMode: Int, 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..738b62477 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,8 @@ 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.needNsfwBlur +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 +75,7 @@ fun CommunityLink( onClick: (community: Community) -> Unit, clickable: Boolean = true, showDefaultIcon: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, ) { Row( verticalAlignment = Alignment.CenterVertically, @@ -90,7 +92,7 @@ fun CommunityLink( contentDescription = null, size = size, thumbnailSize = thumbnailSize, - blur = blurNSFW && community.nsfw, + blur = needNsfwBlur(blurNSFW.toEnum(), community.nsfw), ) } ?: run { if (showDefaultIcon) { @@ -118,7 +120,7 @@ fun CommunityLinkLarger( community: Community, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, ) { CommunityLink( community = community, @@ -141,7 +143,7 @@ fun CommunityLinkLargerWithUserCount( communityView: CommunityView, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, ) { CommunityLink( community = communityView.community, @@ -167,7 +169,7 @@ fun CommunityLinkPreview() { community = sampleCommunity, onClick = {}, showDefaultIcon = true, - blurNSFW = true, + blurNSFW = 1, ) } @@ -178,6 +180,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 f929d648c..8e0c2d018 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, siteViewModel: SiteViewModel, - 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 9ea2fab8c..be037b97e 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 74e21f4de..5d54db68c 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 @@ -91,7 +91,7 @@ fun HomeActivity( useCustomTabs: Boolean, usePrivateTabs: Boolean, drawerState: DrawerState, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, postActionbarMode: Int, @@ -205,7 +205,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 00f9a57a3..46548185c 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 @@ -90,7 +90,7 @@ fun InboxActivity( drawerState: DrawerState, siteViewModel: SiteViewModel, accountViewModel: AccountViewModel, - blurNSFW: Boolean, + blurNSFW: Int, ) { Log.d("jerboa", "got to inbox activity") @@ -222,7 +222,7 @@ fun InboxTabs( scope: CoroutineScope, snackbarHostState: SnackbarHostState, padding: PaddingValues, - blurNSFW: Boolean, + blurNSFW: Int, ) { val transferPrivateMessageDepsViaRoot = appState.rootChannel() val transferCommentReplyDepsViaRoot = appState.rootChannel() 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 b4f883ab1..2c5ddc403 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 @@ -119,7 +119,7 @@ fun PersonProfileActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreviews: Boolean, drawerState: DrawerState, markAsReadOnScroll: Boolean, @@ -322,7 +322,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 da3117af2..d06a58bb9 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 @@ -147,7 +147,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 cf5c0037c..ebbb028eb 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 @@ -91,6 +91,7 @@ import com.jerboa.feat.PostActionbarMode import com.jerboa.getPostType import com.jerboa.hostName import com.jerboa.isSameInstance +import com.jerboa.needNsfwBlur import com.jerboa.nsfwCheck import com.jerboa.rememberJerboaAppState import com.jerboa.siFormat @@ -139,7 +140,7 @@ fun PostHeaderLine( modifier: Modifier = Modifier, showCommunityName: Boolean = true, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showScores: Boolean, ) { val community = postView.community @@ -160,7 +161,7 @@ fun PostHeaderLine( size = MEDIUM_ICON_SIZE, modifier = Modifier.clickable { onCommunityClick(community) }, thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE, - blur = blurNSFW && community.nsfw, + blur = needNsfwBlur(blurNSFW.toEnum(), community.nsfw), ) } } @@ -249,7 +250,7 @@ fun PostHeaderLinePreview() { onCommunityClick = {}, onPersonClick = {}, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, showScores = true, ) } @@ -289,7 +290,7 @@ fun PostTitleBlock( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -344,7 +345,7 @@ fun PostName( @Composable fun PostTitleAndImageLink( postView: PostView, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -367,7 +368,7 @@ fun PostTitleAndImageLink( PictrsUrlImage( url = url, - blur = blurNSFW && nsfwCheck(postView), + blur = needNsfwBlur(blurNSFW.toEnum(), postView.community.nsfw, postView.post.nsfw), modifier = Modifier .combinedClickable( onClick = { appState.openImageViewer(url) }, @@ -382,7 +383,7 @@ fun PostTitleAndThumbnail( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -431,7 +432,7 @@ fun PostBody( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, showPostLinkPreview: Boolean, appState: JerboaAppState, clickBody: () -> Unit = {}, @@ -517,7 +518,7 @@ fun PreviewStoryTitleAndMetadata() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -535,7 +536,7 @@ fun PreviewSourcePost() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -829,7 +830,7 @@ fun PreviewPostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -865,7 +866,7 @@ fun PreviewLinkPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -901,7 +902,7 @@ fun PreviewImagePostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -937,7 +938,7 @@ fun PreviewImagePostListingSmallCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -973,7 +974,7 @@ fun PreviewLinkNoThumbnailPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = true, + blurNSFW = 1, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -1009,7 +1010,7 @@ fun PostListing( showVotingArrowsInListView: Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showPostLinkPreview: Boolean, showIfRead: Boolean, @@ -1228,7 +1229,7 @@ fun PostListingList( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, showIfRead: Boolean, enableDownVotes: Boolean, @@ -1350,7 +1351,7 @@ private fun ThumbnailTile( postView: PostView, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Boolean, + blurNSFW: Int, appState: JerboaAppState, ) { postView.post.url?.also { url -> @@ -1380,7 +1381,7 @@ private fun ThumbnailTile( postView.post.thumbnail_url?.also { thumbnail -> PictrsThumbnailImage( thumbnail = thumbnail, - blur = blurNSFW && nsfwCheck(postView), + blur = needNsfwBlur(blurNSFW.toEnum(), postView.community.nsfw, postView.post.nsfw), roundBottomEndCorner = postType != PostType.Link, modifier = postLinkPicMod, ) @@ -1444,7 +1445,7 @@ fun PostListingListPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = 1, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1475,7 +1476,7 @@ fun PostListingListWithThumbPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = true, + blurNSFW = 1, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1512,7 +1513,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 031118bbf..50ec20ad6 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, @@ -172,7 +172,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..893ca6d60 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 @@ -89,7 +89,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) @@ -353,13 +353,6 @@ fun LookAndFeelActivity( }, onCheckedChange = { updateAppSettings() }, ) - SettingsCheckbox( - state = blurNSFW, - title = { - Text(stringResource(id = R.string.blur_nsfw)) - }, - onCheckedChange = { updateAppSettings() }, - ) SettingsCheckbox( state = showPostLinkPreviewMode, title = { @@ -381,6 +374,17 @@ fun LookAndFeelActivity( }, onCheckedChange = { updateAppSettings() }, ) + SettingsListDropdown( + state = blurNSFW, + title = { Text(stringResource(id = R.string.blur_nsfw)) }, + items = listOf( + stringResource(R.string.app_settings_do_not_blur), + stringResource(R.string.app_settings_blur_everywhere), + stringResource(R.string.app_settings_blur_everywhere_except_nsfw), + stringResource(R.string.app_settings_blur_only_nsfw_community), + ), + onItemSelected = { _,_ -> updateAppSettings() }, + ) } }, ) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8d5578e23..8a84799ca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -411,4 +411,8 @@ Open link Open link in external No activity (app) found that can open this link + Blur everywhere + Blur everywhere except NSFW + Blur only NSFW Community + Do not blur From a4470e7ee403aefe985c8c078779f3c667e174bb Mon Sep 17 00:00:00 2001 From: user Date: Tue, 12 Sep 2023 16:56:21 +0300 Subject: [PATCH 04/11] Change NSFW Blur toggle to drop-down menu with new options (#957) --- app/src/main/java/com/jerboa/Utils.kt | 10 --------- .../java/com/jerboa/feat/BlurNsfwTypes.kt | 16 +++++++++++++- .../ui/components/community/Community.kt | 9 ++++---- .../ui/components/community/CommunityLink.kt | 5 ++--- .../jerboa/ui/components/post/PostListing.kt | 8 +++---- .../lookandfeel/LookAndFeelActivity.kt | 22 +++++++++---------- 6 files changed, 36 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/com/jerboa/Utils.kt b/app/src/main/java/com/jerboa/Utils.kt index 31d3c9375..f7a1c50be 100644 --- a/app/src/main/java/com/jerboa/Utils.kt +++ b/app/src/main/java/com/jerboa/Utils.kt @@ -74,7 +74,6 @@ import com.jerboa.api.ApiState import com.jerboa.datatypes.types.* import com.jerboa.db.APP_SETTINGS_DEFAULT import com.jerboa.db.entity.AppSettings -import com.jerboa.feat.BlurNsfwTypes import com.jerboa.ui.components.common.Route import com.jerboa.ui.components.inbox.InboxTab import com.jerboa.ui.components.person.UserTab @@ -940,15 +939,6 @@ fun nsfwCheck(postView: PostView): Boolean { return postView.post.nsfw || postView.community.nsfw } -fun needNsfwBlur(settings: BlurNsfwTypes, isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean { - return isPostNsfw && when(settings){ - BlurNsfwTypes.DoNotBlur -> false - BlurNsfwTypes.BlurEverywhere -> true - BlurNsfwTypes.BlurEverywhereExceptNsfw -> !isCommunityNsfw - BlurNsfwTypes.BlurOnlyNsfwCommunity -> isCommunityNsfw - } -} - @RequiresApi(Build.VERSION_CODES.Q) @Throws(IOException::class) fun saveMediaQ( diff --git a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt index f4161321c..22d8ada39 100644 --- a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt +++ b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt @@ -3,6 +3,8 @@ 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 @@ -10,5 +12,17 @@ enum class BlurNsfwTypes(@StringRes val resId: Int) : Parcelable { DoNotBlur(R.string.app_settings_do_not_blur), BlurEverywhere(R.string.app_settings_blur_everywhere), BlurEverywhereExceptNsfw(R.string.app_settings_blur_everywhere_except_nsfw), - BlurOnlyNsfwCommunity(R.string.app_settings_blur_only_nsfw_community), + BlurOnlyNsfwCommunity(R.string.app_settings_blur_only_nsfw_community); +} + +fun Int.needNsfwBlur(postView : PostView) = + this.needNsfwBlur(postView.community.nsfw, postView.post.nsfw) + +fun Int.needNsfwBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean { + return isPostNsfw && when(this.toEnum()){ + BlurNsfwTypes.DoNotBlur -> false + BlurNsfwTypes.BlurEverywhere -> true + BlurNsfwTypes.BlurEverywhereExceptNsfw -> !isCommunityNsfw + BlurNsfwTypes.BlurOnlyNsfwCommunity -> isCommunityNsfw + } } 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 ac3d864b6..62c61e5ef 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 @@ -18,10 +18,8 @@ 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.BlurNsfwTypes +import com.jerboa.feat.needNsfwBlur import com.jerboa.feat.PostActionbarMode -import com.jerboa.needNsfwBlur -import com.jerboa.toEnum import com.jerboa.ui.components.common.LargerCircularIcon import com.jerboa.ui.components.common.MenuItem import com.jerboa.ui.components.common.PictrsBannerImage @@ -30,6 +28,7 @@ import com.jerboa.ui.components.common.SortOptionsDialog import com.jerboa.ui.components.common.SortTopOptionsDialog import com.jerboa.ui.theme.* + @Composable fun CommunityTopSection( communityView: CommunityView, @@ -49,11 +48,11 @@ fun CommunityTopSection( PictrsBannerImage( url = it, modifier = Modifier.height(DRAWER_BANNER_SIZE), - blur = needNsfwBlur(blurNSFW.toEnum(), communityView.community.nsfw), + blur = blurNSFW.needNsfwBlur(communityView.community.nsfw), ) } communityView.community.icon?.also { - LargerCircularIcon(icon = it, blur = needNsfwBlur(blurNSFW.toEnum(), communityView.community.nsfw)) + LargerCircularIcon(icon = it, blur = blurNSFW.needNsfwBlur(communityView.community.nsfw)) } } Column( 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 738b62477..6917271b3 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,8 +27,7 @@ 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.needNsfwBlur -import com.jerboa.toEnum +import com.jerboa.feat.needNsfwBlur import com.jerboa.ui.components.common.CircularIcon import com.jerboa.ui.theme.DRAWER_ITEM_SPACING import com.jerboa.ui.theme.ICON_SIZE @@ -92,7 +91,7 @@ fun CommunityLink( contentDescription = null, size = size, thumbnailSize = thumbnailSize, - blur = needNsfwBlur(blurNSFW.toEnum(), community.nsfw), + blur = blurNSFW.needNsfwBlur(community.nsfw), ) } ?: run { if (showDefaultIcon) { 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 ebbb028eb..61281c039 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 @@ -91,7 +91,7 @@ import com.jerboa.feat.PostActionbarMode import com.jerboa.getPostType import com.jerboa.hostName import com.jerboa.isSameInstance -import com.jerboa.needNsfwBlur +import com.jerboa.feat.needNsfwBlur import com.jerboa.nsfwCheck import com.jerboa.rememberJerboaAppState import com.jerboa.siFormat @@ -161,7 +161,7 @@ fun PostHeaderLine( size = MEDIUM_ICON_SIZE, modifier = Modifier.clickable { onCommunityClick(community) }, thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE, - blur = needNsfwBlur(blurNSFW.toEnum(), community.nsfw), + blur = blurNSFW.needNsfwBlur(community.nsfw), ) } } @@ -368,7 +368,7 @@ fun PostTitleAndImageLink( PictrsUrlImage( url = url, - blur = needNsfwBlur(blurNSFW.toEnum(), postView.community.nsfw, postView.post.nsfw), + blur = blurNSFW.needNsfwBlur(postView), modifier = Modifier .combinedClickable( onClick = { appState.openImageViewer(url) }, @@ -1381,7 +1381,7 @@ private fun ThumbnailTile( postView.post.thumbnail_url?.also { thumbnail -> PictrsThumbnailImage( thumbnail = thumbnail, - blur = needNsfwBlur(blurNSFW.toEnum(), postView.community.nsfw, postView.post.nsfw), + blur = blurNSFW.needNsfwBlur(postView), roundBottomEndCorner = postType != PostType.Link, modifier = postLinkPicMod, ) 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 893ca6d60..177dc10cc 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 @@ -160,6 +160,17 @@ fun LookAndFeelActivity( ) }, ) + SettingsListDropdown( + state = blurNSFW, + title = { Text(stringResource(id = R.string.blur_nsfw)) }, + items = listOf( + stringResource(R.string.app_settings_do_not_blur), + stringResource(R.string.app_settings_blur_everywhere), + stringResource(R.string.app_settings_blur_everywhere_except_nsfw), + stringResource(R.string.app_settings_blur_only_nsfw_community), + ), + onItemSelected = { _,_ -> updateAppSettings() }, + ) SettingsSlider( modifier = Modifier.padding(top = 10.dp), valueRange = 8f..48f, @@ -374,17 +385,6 @@ fun LookAndFeelActivity( }, onCheckedChange = { updateAppSettings() }, ) - SettingsListDropdown( - state = blurNSFW, - title = { Text(stringResource(id = R.string.blur_nsfw)) }, - items = listOf( - stringResource(R.string.app_settings_do_not_blur), - stringResource(R.string.app_settings_blur_everywhere), - stringResource(R.string.app_settings_blur_everywhere_except_nsfw), - stringResource(R.string.app_settings_blur_only_nsfw_community), - ), - onItemSelected = { _,_ -> updateAppSettings() }, - ) } }, ) From 1ea34d742ab69696066e57e4a98370a97c587f57 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 13 Sep 2023 19:09:53 +0300 Subject: [PATCH 05/11] Change NSFW Blur toggle to drop-down menu with new options (#957) --- app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt | 6 +++--- .../java/com/jerboa/ui/components/community/Community.kt | 6 ++++-- .../com/jerboa/ui/components/community/CommunityLink.kt | 4 +++- .../main/java/com/jerboa/ui/components/post/PostListing.kt | 7 ++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt index 22d8ada39..4b21c784e 100644 --- a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt +++ b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt @@ -15,11 +15,11 @@ enum class BlurNsfwTypes(@StringRes val resId: Int) : Parcelable { BlurOnlyNsfwCommunity(R.string.app_settings_blur_only_nsfw_community); } -fun Int.needNsfwBlur(postView : PostView) = +fun BlurNsfwTypes.needNsfwBlur(postView : PostView) = this.needNsfwBlur(postView.community.nsfw, postView.post.nsfw) -fun Int.needNsfwBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean { - return isPostNsfw && when(this.toEnum()){ +fun BlurNsfwTypes.needNsfwBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean { + return isPostNsfw && when(this){ BlurNsfwTypes.DoNotBlur -> false BlurNsfwTypes.BlurEverywhere -> true BlurNsfwTypes.BlurEverywhereExceptNsfw -> !isCommunityNsfw 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 62c61e5ef..b43b19acf 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 @@ -18,8 +18,10 @@ 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.BlurNsfwTypes import com.jerboa.feat.needNsfwBlur import com.jerboa.feat.PostActionbarMode +import com.jerboa.toEnum import com.jerboa.ui.components.common.LargerCircularIcon import com.jerboa.ui.components.common.MenuItem import com.jerboa.ui.components.common.PictrsBannerImage @@ -48,11 +50,11 @@ fun CommunityTopSection( PictrsBannerImage( url = it, modifier = Modifier.height(DRAWER_BANNER_SIZE), - blur = blurNSFW.needNsfwBlur(communityView.community.nsfw), + blur = blurNSFW.toEnum().needNsfwBlur(communityView.community.nsfw), ) } communityView.community.icon?.also { - LargerCircularIcon(icon = it, blur = blurNSFW.needNsfwBlur(communityView.community.nsfw)) + LargerCircularIcon(icon = it, blur = blurNSFW.toEnum().needNsfwBlur(communityView.community.nsfw)) } } Column( 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 6917271b3..291621f37 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,7 +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.BlurNsfwTypes import com.jerboa.feat.needNsfwBlur +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 @@ -91,7 +93,7 @@ fun CommunityLink( contentDescription = null, size = size, thumbnailSize = thumbnailSize, - blur = blurNSFW.needNsfwBlur(community.nsfw), + blur = blurNSFW.toEnum().needNsfwBlur(community.nsfw), ) } ?: run { if (showDefaultIcon) { 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 61281c039..a401285c8 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 @@ -87,6 +87,7 @@ 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.BlurNsfwTypes import com.jerboa.feat.PostActionbarMode import com.jerboa.getPostType import com.jerboa.hostName @@ -161,7 +162,7 @@ fun PostHeaderLine( size = MEDIUM_ICON_SIZE, modifier = Modifier.clickable { onCommunityClick(community) }, thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE, - blur = blurNSFW.needNsfwBlur(community.nsfw), + blur = blurNSFW.toEnum().needNsfwBlur(community.nsfw), ) } } @@ -368,7 +369,7 @@ fun PostTitleAndImageLink( PictrsUrlImage( url = url, - blur = blurNSFW.needNsfwBlur(postView), + blur = blurNSFW.toEnum().needNsfwBlur(postView), modifier = Modifier .combinedClickable( onClick = { appState.openImageViewer(url) }, @@ -1381,7 +1382,7 @@ private fun ThumbnailTile( postView.post.thumbnail_url?.also { thumbnail -> PictrsThumbnailImage( thumbnail = thumbnail, - blur = blurNSFW.needNsfwBlur(postView), + blur = blurNSFW.toEnum().needNsfwBlur(postView), roundBottomEndCorner = postType != PostType.Link, modifier = postLinkPicMod, ) From 316e331552c638169a2c5ce5d7bb8c14c5de7232 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 14 Sep 2023 09:58:50 +0300 Subject: [PATCH 06/11] Change NSFW Blur toggle to drop-down menu with new options (#957) --- .../main/java/com/jerboa/feat/BlurNsfwTypes.kt | 16 ++++++++-------- app/src/main/res/values/strings.xml | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt index 4b21c784e..5764cbb56 100644 --- a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt +++ b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt @@ -9,10 +9,10 @@ import kotlinx.parcelize.Parcelize @Parcelize enum class BlurNsfwTypes(@StringRes val resId: Int) : Parcelable { - DoNotBlur(R.string.app_settings_do_not_blur), - BlurEverywhere(R.string.app_settings_blur_everywhere), - BlurEverywhereExceptNsfw(R.string.app_settings_blur_everywhere_except_nsfw), - BlurOnlyNsfwCommunity(R.string.app_settings_blur_only_nsfw_community); + Nothing(R.string.app_settings_blur_nothing), + All(R.string.app_settings_blur_all), + OnlyInsideNsfwCommunities(R.string.app_settings_blur_only_inside_nsfw_community), + OnlyOutsideNsfwCommunities(R.string.app_settings_blur_only_outside_nsfw_community); } fun BlurNsfwTypes.needNsfwBlur(postView : PostView) = @@ -20,9 +20,9 @@ fun BlurNsfwTypes.needNsfwBlur(postView : PostView) = fun BlurNsfwTypes.needNsfwBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean { return isPostNsfw && when(this){ - BlurNsfwTypes.DoNotBlur -> false - BlurNsfwTypes.BlurEverywhere -> true - BlurNsfwTypes.BlurEverywhereExceptNsfw -> !isCommunityNsfw - BlurNsfwTypes.BlurOnlyNsfwCommunity -> isCommunityNsfw + BlurNsfwTypes.Nothing -> false + BlurNsfwTypes.All -> true + BlurNsfwTypes.OnlyInsideNsfwCommunities -> !isCommunityNsfw + BlurNsfwTypes.OnlyOutsideNsfwCommunities -> isCommunityNsfw } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8a84799ca..95d53699c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -411,8 +411,8 @@ Open link Open link in external No activity (app) found that can open this link - Blur everywhere - Blur everywhere except NSFW - Blur only NSFW Community - Do not blur + Blur nothing + Blur all + Blur only inside NSFW communities + Blur only outside NSFW communities From 61759d41470777f679193caca63acf421013fdf7 Mon Sep 17 00:00:00 2001 From: "maarten.vercruysse" Date: Thu, 14 Sep 2023 19:46:56 +0200 Subject: [PATCH 07/11] Add my changes + include main changes --- .../java/com/jerboa/feat/BlurNsfwTypes.kt | 17 ++++++------ .../ui/components/community/Community.kt | 2 -- .../jerboa/ui/components/post/PostListing.kt | 2 +- .../lookandfeel/LookAndFeelActivity.kt | 26 +++++++++++-------- app/src/main/res/values/strings.xml | 7 +++-- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt index 5764cbb56..0b795eff0 100644 --- a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt +++ b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt @@ -4,25 +4,24 @@ 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 BlurNsfwTypes(@StringRes val resId: Int) : Parcelable { - Nothing(R.string.app_settings_blur_nothing), - All(R.string.app_settings_blur_all), - OnlyInsideNsfwCommunities(R.string.app_settings_blur_only_inside_nsfw_community), - OnlyOutsideNsfwCommunities(R.string.app_settings_blur_only_outside_nsfw_community); + Nothing(R.string.app_settings_nothing), + All(R.string.account_settings_all), + OnlyFromNsfwCommunity(R.string.app_settings_blur_only_from_nsfw_community), + OnlyFromSfwCommunity(R.string.app_settings_blur_only_from_sfw_community), } -fun BlurNsfwTypes.needNsfwBlur(postView : PostView) = +fun BlurNsfwTypes.needNsfwBlur(postView: PostView) = this.needNsfwBlur(postView.community.nsfw, postView.post.nsfw) fun BlurNsfwTypes.needNsfwBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean { - return isPostNsfw && when(this){ + return isPostNsfw && when (this) { BlurNsfwTypes.Nothing -> false BlurNsfwTypes.All -> true - BlurNsfwTypes.OnlyInsideNsfwCommunities -> !isCommunityNsfw - BlurNsfwTypes.OnlyOutsideNsfwCommunities -> isCommunityNsfw + BlurNsfwTypes.OnlyFromNsfwCommunity -> isCommunityNsfw + BlurNsfwTypes.OnlyFromSfwCommunity -> !isCommunityNsfw } } 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 81425a59f..e9eb12597 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 @@ -22,7 +22,6 @@ import com.jerboa.datatypes.types.SortType import com.jerboa.datatypes.types.SubscribedType import com.jerboa.feat.BlurNsfwTypes import com.jerboa.feat.needNsfwBlur -import com.jerboa.feat.PostActionbarMode import com.jerboa.toEnum import com.jerboa.ui.components.common.LargerCircularIcon import com.jerboa.ui.components.common.PictrsBannerImage @@ -30,7 +29,6 @@ import com.jerboa.ui.components.common.SortOptionsDropdown import com.jerboa.ui.theme.* import com.jerboa.util.cascade.CascadeDropdownMenu - @Composable fun CommunityTopSection( communityView: CommunityView, 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 e214ffe68..45dfa417b 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 @@ -75,10 +75,10 @@ import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount import com.jerboa.feat.BlurNsfwTypes import com.jerboa.feat.PostActionbarMode +import com.jerboa.feat.needNsfwBlur import com.jerboa.getPostType import com.jerboa.hostName import com.jerboa.isSameInstance -import com.jerboa.feat.needNsfwBlur import com.jerboa.nsfwCheck import com.jerboa.rememberJerboaAppState import com.jerboa.siFormat 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 177dc10cc..2779b6caa 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.BlurNsfwTypes import com.jerboa.feat.PostActionbarMode import com.jerboa.feat.PostNavigationGestureMode import com.jerboa.getLangPreferenceDropdownEntries @@ -160,17 +162,7 @@ fun LookAndFeelActivity( ) }, ) - SettingsListDropdown( - state = blurNSFW, - title = { Text(stringResource(id = R.string.blur_nsfw)) }, - items = listOf( - stringResource(R.string.app_settings_do_not_blur), - stringResource(R.string.app_settings_blur_everywhere), - stringResource(R.string.app_settings_blur_everywhere_except_nsfw), - stringResource(R.string.app_settings_blur_only_nsfw_community), - ), - onItemSelected = { _,_ -> updateAppSettings() }, - ) + SettingsSlider( modifier = Modifier.padding(top = 10.dp), valueRange = 8f..48f, @@ -293,6 +285,18 @@ fun LookAndFeelActivity( ) }, ) + SettingsListDropdown( + state = blurNSFW, + icon = { + Icon( + imageVector = Icons.Outlined.LensBlur, + contentDescription = null, + ) + }, + title = { Text(stringResource(id = R.string.blur_nsfw)) }, + items = BlurNsfwTypes.entries.map { stringResource(it.resId) }, + onItemSelected = { _, _ -> updateAppSettings() }, + ) SettingsCheckbox( state = showBottomNavState, title = { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 439c6db3b..f3deff9db 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -418,8 +418,7 @@ Connect on Matrix Posts failed loading, retry Failed to share media! - Blur nothing - Blur all - Blur only inside NSFW communities - Blur only outside NSFW communities + Nothing + Only from NSFW communities + Only from SFW communities From 128aa70666667b965e559d65ef2575b04db73c84 Mon Sep 17 00:00:00 2001 From: MakcNmyc Date: Fri, 29 Sep 2023 12:02:22 +0300 Subject: [PATCH 08/11] Change NSFW Blur toggle to drop-down menu with new options (#957) --- .../java/com/jerboa/feat/BlurNsfwTypes.kt | 27 ----------- .../main/java/com/jerboa/feat/BlurTypes.kt | 45 +++++++++++++++++++ .../ui/components/community/Community.kt | 8 ++-- .../components/community/CommunityActivity.kt | 5 ++- .../ui/components/community/CommunityLink.kt | 6 +-- .../jerboa/ui/components/post/PostListing.kt | 10 ++--- .../lookandfeel/LookAndFeelActivity.kt | 4 +- app/src/main/res/values/strings.xml | 5 ++- 8 files changed, 65 insertions(+), 45 deletions(-) delete mode 100644 app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt create mode 100644 app/src/main/java/com/jerboa/feat/BlurTypes.kt diff --git a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt b/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt deleted file mode 100644 index 0b795eff0..000000000 --- a/app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.jerboa.feat - -import android.os.Parcelable -import androidx.annotation.StringRes -import com.jerboa.R -import com.jerboa.datatypes.types.PostView -import kotlinx.parcelize.Parcelize - -@Parcelize -enum class BlurNsfwTypes(@StringRes val resId: Int) : Parcelable { - Nothing(R.string.app_settings_nothing), - All(R.string.account_settings_all), - OnlyFromNsfwCommunity(R.string.app_settings_blur_only_from_nsfw_community), - OnlyFromSfwCommunity(R.string.app_settings_blur_only_from_sfw_community), -} - -fun BlurNsfwTypes.needNsfwBlur(postView: PostView) = - this.needNsfwBlur(postView.community.nsfw, postView.post.nsfw) - -fun BlurNsfwTypes.needNsfwBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean { - return isPostNsfw && when (this) { - BlurNsfwTypes.Nothing -> false - BlurNsfwTypes.All -> true - BlurNsfwTypes.OnlyFromNsfwCommunity -> isCommunityNsfw - BlurNsfwTypes.OnlyFromSfwCommunity -> !isCommunityNsfw - } -} 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..98dd252a3 --- /dev/null +++ b/app/src/main/java/com/jerboa/feat/BlurTypes.kt @@ -0,0 +1,45 @@ +package com.jerboa.feat + +import android.os.Parcelable +import androidx.annotation.StringRes +import androidx.compose.ui.res.stringResource +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), + ExceptFromNsfwInsideCommunity(R.string.app_settings_blur_nsfw_except_from_nsfw_inside_community); + + companion object { + fun usersEntries() : List = entries.filter { + it != ExceptFromNsfwInsideCommunity + } + + fun changeBlurTypeInsideCommunity(blurTypes: Int): Int = + if (blurTypes.toEnum() == NsfwExceptFromNsfwCommunities) { + ExceptFromNsfwInsideCommunity.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 + BlurTypes.ExceptFromNsfwInsideCommunity -> isPostNsfw && !isCommunityNsfw + } +} + + + 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 e9eb12597..34ffd3349 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,8 +20,8 @@ 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.BlurNsfwTypes -import com.jerboa.feat.needNsfwBlur +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 @@ -48,11 +48,11 @@ fun CommunityTopSection( PictrsBannerImage( url = it, modifier = Modifier.height(DRAWER_BANNER_SIZE), - blur = blurNSFW.toEnum().needNsfwBlur(communityView.community.nsfw), + blur = blurNSFW.toEnum().needBlur(communityView.community.nsfw), ) } communityView.community.icon?.also { - LargerCircularIcon(icon = it, blur = blurNSFW.toEnum().needNsfwBlur(communityView.community.nsfw)) + LargerCircularIcon(icon = it, blur = blurNSFW.toEnum().needBlur(communityView.community.nsfw)) } } Column( 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 7c8db6b39..c4502ff90 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 @@ -263,7 +264,7 @@ fun CommunityActivity( ) } }, - blurNSFW = blurNSFW, + blurNSFW = BlurTypes.changeBlurTypeInsideCommunity(blurNSFW), ) } @@ -434,7 +435,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 291621f37..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,8 +27,8 @@ 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.BlurNsfwTypes -import com.jerboa.feat.needNsfwBlur +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 @@ -93,7 +93,7 @@ fun CommunityLink( contentDescription = null, size = size, thumbnailSize = thumbnailSize, - blur = blurNSFW.toEnum().needNsfwBlur(community.nsfw), + blur = blurNSFW.toEnum().needBlur(community.nsfw), ) } ?: run { if (showDefaultIcon) { 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 45dfa417b..9f6c53e88 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,9 +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.BlurNsfwTypes +import com.jerboa.feat.BlurTypes import com.jerboa.feat.PostActionbarMode -import com.jerboa.feat.needNsfwBlur +import com.jerboa.feat.needBlur import com.jerboa.getPostType import com.jerboa.hostName import com.jerboa.isSameInstance @@ -150,7 +150,7 @@ fun PostHeaderLine( size = MEDIUM_ICON_SIZE, modifier = Modifier.clickable { onCommunityClick(community) }, thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE, - blur = blurNSFW.toEnum().needNsfwBlur(community.nsfw), + blur = blurNSFW.toEnum().needBlur(community.nsfw), ) } } @@ -357,7 +357,7 @@ fun PostTitleAndImageLink( PictrsUrlImage( url = url, - blur = blurNSFW.toEnum().needNsfwBlur(postView), + blur = blurNSFW.toEnum().needBlur(postView), modifier = Modifier .combinedClickable( onClick = { appState.openImageViewer(url) }, @@ -1349,7 +1349,7 @@ private fun ThumbnailTile( postView.post.thumbnail_url?.also { thumbnail -> PictrsThumbnailImage( thumbnail = thumbnail, - blur = blurNSFW.toEnum().needNsfwBlur(postView), + blur = blurNSFW.toEnum().needBlur(postView), roundBottomEndCorner = postType != PostType.Link, modifier = postLinkPicMod, ) 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 2779b6caa..94c5aab9f 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 @@ -42,7 +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.BlurNsfwTypes +import com.jerboa.feat.BlurTypes import com.jerboa.feat.PostActionbarMode import com.jerboa.feat.PostNavigationGestureMode import com.jerboa.getLangPreferenceDropdownEntries @@ -294,7 +294,7 @@ fun LookAndFeelActivity( ) }, title = { Text(stringResource(id = R.string.blur_nsfw)) }, - items = BlurNsfwTypes.entries.map { stringResource(it.resId) }, + items = BlurTypes.usersEntries().map { stringResource(it.resId) }, onItemSelected = { _, _ -> updateAppSettings() }, ) SettingsCheckbox( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f3deff9db..1100effe4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -419,6 +419,7 @@ Posts failed loading, retry Failed to share media! Nothing - Only from NSFW communities - Only from SFW communities + NSFW + NSFW except from NSFW communities + Except NSFW inside community From 0119777edc148cb8ec4275202713a2b835fa8d0f Mon Sep 17 00:00:00 2001 From: MakcNmyc Date: Tue, 10 Oct 2023 20:15:10 +0300 Subject: [PATCH 09/11] Change NSFW Blur toggle to drop-down menu with new options (#957) --- app/src/main/java/com/jerboa/feat/BlurTypes.kt | 11 ++--------- .../settings/lookandfeel/LookAndFeelActivity.kt | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/jerboa/feat/BlurTypes.kt b/app/src/main/java/com/jerboa/feat/BlurTypes.kt index 98dd252a3..29baeeb16 100644 --- a/app/src/main/java/com/jerboa/feat/BlurTypes.kt +++ b/app/src/main/java/com/jerboa/feat/BlurTypes.kt @@ -12,21 +12,15 @@ import kotlinx.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), - ExceptFromNsfwInsideCommunity(R.string.app_settings_blur_nsfw_except_from_nsfw_inside_community); + NsfwExceptFromNsfwCommunities(R.string.app_settings_blur_nsfw_except_from_nsfw_communities); companion object { - fun usersEntries() : List = entries.filter { - it != ExceptFromNsfwInsideCommunity - } - fun changeBlurTypeInsideCommunity(blurTypes: Int): Int = if (blurTypes.toEnum() == NsfwExceptFromNsfwCommunities) { - ExceptFromNsfwInsideCommunity.ordinal + Nothing.ordinal } else { blurTypes } - } } @@ -37,7 +31,6 @@ fun BlurTypes.needBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommuni return when (this) { BlurTypes.Nothing -> false BlurTypes.NSFW, BlurTypes.NsfwExceptFromNsfwCommunities -> isPostNsfw - BlurTypes.ExceptFromNsfwInsideCommunity -> isPostNsfw && !isCommunityNsfw } } 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 94c5aab9f..c985e843d 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 @@ -294,7 +294,7 @@ fun LookAndFeelActivity( ) }, title = { Text(stringResource(id = R.string.blur_nsfw)) }, - items = BlurTypes.usersEntries().map { stringResource(it.resId) }, + items = BlurTypes.entries.map { stringResource(it.resId) }, onItemSelected = { _, _ -> updateAppSettings() }, ) SettingsCheckbox( From 128d26373e4982951a9082ddc5120df0681ecdda Mon Sep 17 00:00:00 2001 From: MakcNmyc Date: Wed, 11 Oct 2023 20:55:17 +0300 Subject: [PATCH 10/11] Change NSFW Blur toggle to drop-down menu with new options (#957) --- app/src/main/java/com/jerboa/feat/BlurTypes.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/jerboa/feat/BlurTypes.kt b/app/src/main/java/com/jerboa/feat/BlurTypes.kt index 29baeeb16..75885e8b0 100644 --- a/app/src/main/java/com/jerboa/feat/BlurTypes.kt +++ b/app/src/main/java/com/jerboa/feat/BlurTypes.kt @@ -2,7 +2,6 @@ package com.jerboa.feat import android.os.Parcelable import androidx.annotation.StringRes -import androidx.compose.ui.res.stringResource import com.jerboa.R import com.jerboa.datatypes.types.PostView import com.jerboa.toEnum @@ -12,7 +11,8 @@ import kotlinx.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); + NsfwExceptFromNsfwCommunities(R.string.app_settings_blur_nsfw_except_from_nsfw_communities), + ; companion object { fun changeBlurTypeInsideCommunity(blurTypes: Int): Int = @@ -33,6 +33,3 @@ fun BlurTypes.needBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommuni BlurTypes.NSFW, BlurTypes.NsfwExceptFromNsfwCommunities -> isPostNsfw } } - - - From c69b05025319bef20dbfa584573e287cc0be4984 Mon Sep 17 00:00:00 2001 From: MakcNmyc Date: Sun, 15 Oct 2023 14:35:30 +0300 Subject: [PATCH 11/11] Change NSFW Blur toggle to drop-down menu with new options (#957) --- .../java/com/jerboa/ui/components/comment/CommentNode.kt | 2 +- .../main/java/com/jerboa/ui/components/post/PostListing.kt | 7 +------ .../components/settings/lookandfeel/LookAndFeelActivity.kt | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) 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 88e2479fe..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 @@ -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 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 db9cb8a22..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 @@ -530,7 +530,7 @@ fun PreviewSourcePost() { } @Composable -fun /FooterLine( +fun PostFooterLine( postView: PostView, instantScores: InstantScores, onUpvoteClick: () -> Unit, @@ -792,7 +792,6 @@ fun PreviewPostListingCard() { enableDownVotes = true, showAvatar = true, blurNSFW = 1, - showPostLinkPreview = true, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, @@ -828,7 +827,6 @@ fun PreviewLinkPostListing() { enableDownVotes = true, showAvatar = true, blurNSFW = 1, - showPostLinkPreview = true, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, @@ -864,7 +862,6 @@ fun PreviewImagePostListingCard() { enableDownVotes = true, showAvatar = true, blurNSFW = 1, - showPostLinkPreview = true, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, @@ -900,7 +897,6 @@ fun PreviewImagePostListingSmallCard() { enableDownVotes = true, showAvatar = true, blurNSFW = 1, - showPostLinkPreview = true, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, @@ -936,7 +932,6 @@ fun PreviewLinkNoThumbnailPostListing() { enableDownVotes = true, showAvatar = true, blurNSFW = 1, - showPostLinkPreview = true, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, 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 c985e843d..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 @@ -162,7 +162,6 @@ fun LookAndFeelActivity( ) }, ) - SettingsSlider( modifier = Modifier.padding(top = 10.dp), valueRange = 8f..48f,