diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt index 8280bae1a..bd11a7773 100644 --- a/app/src/main/java/com/jerboa/MainActivity.kt +++ b/app/src/main/java/com/jerboa/MainActivity.kt @@ -233,10 +233,10 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showPostLinkPreviews = appSettings.showPostLinkPreviews, markAsReadOnScroll = appSettings.markAsReadOnScroll, - postActionbarMode = appSettings.postActionbarMode, + postActionBarMode = appSettings.postActionBarMode.toEnum(), swipeToActionPreset = appSettings.swipeToActionPreset.toEnum(), ) } @@ -277,10 +277,10 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showPostLinkPreviews = appSettings.showPostLinkPreviews, markAsReadOnScroll = appSettings.markAsReadOnScroll, - postActionbarMode = appSettings.postActionbarMode, + postActionBarMode = appSettings.postActionBarMode.toEnum(), swipeToActionPreset = appSettings.swipeToActionPreset.toEnum(), ) } @@ -316,12 +316,12 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, onBack = appState::popBackStack, markAsReadOnScroll = appSettings.markAsReadOnScroll, - postActionbarMode = appSettings.postActionbarMode, + postActionBarMode = appSettings.postActionBarMode.toEnum(), swipeToActionPreset = appSettings.swipeToActionPreset.toEnum(), ) } @@ -355,11 +355,11 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, markAsReadOnScroll = appSettings.markAsReadOnScroll, - postActionbarMode = appSettings.postActionbarMode, + postActionBarMode = appSettings.postActionBarMode.toEnum(), swipeToActionPreset = appSettings.swipeToActionPreset.toEnum(), ) } @@ -378,7 +378,7 @@ class MainActivity : AppCompatActivity() { CommunityListActivity( appState = appState, selectMode = args.select, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), drawerState = drawerState, followList = siteViewModel.getFollowList(), ) @@ -433,7 +433,7 @@ class MainActivity : AppCompatActivity() { appState = appState, accountViewModel = accountViewModel, siteViewModel = siteViewModel, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), drawerState = drawerState, ) } @@ -469,9 +469,9 @@ class MainActivity : AppCompatActivity() { siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showPostLinkPreview = appSettings.showPostLinkPreviews, - postActionbarMode = appSettings.postActionbarMode, + postActionBarMode = appSettings.postActionBarMode.toEnum(), swipeToActionPreset = appSettings.swipeToActionPreset.toEnum(), ) } @@ -503,9 +503,9 @@ class MainActivity : AppCompatActivity() { showParentCommentNavigationButtons = appSettings.showParentCommentNavigationButtons, navigateParentCommentsWithVolumeButtons = appSettings.navigateParentCommentsWithVolumeButtons, siteViewModel = siteViewModel, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showPostLinkPreview = appSettings.showPostLinkPreviews, - postActionbarMode = appSettings.postActionbarMode, + postActionBarMode = appSettings.postActionBarMode.toEnum(), swipeToActionPreset = appSettings.swipeToActionPreset.toEnum(), ) } diff --git a/app/src/main/java/com/jerboa/db/AppDB.kt b/app/src/main/java/com/jerboa/db/AppDB.kt index a5f18aac5..e0e571eaf 100644 --- a/app/src/main/java/com/jerboa/db/AppDB.kt +++ b/app/src/main/java/com/jerboa/db/AppDB.kt @@ -39,7 +39,7 @@ val APP_SETTINGS_DEFAULT = backConfirmationMode = 1, markAsReadOnScroll = false, showPostLinkPreviews = true, - postActionbarMode = 0, + postActionBarMode = 0, autoPlayGifs = false, swipeToActionPreset = SwipeToActionPreset.DEFAULT.ordinal, ) 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 e9429583f..be914c93f 100644 --- a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt +++ b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt @@ -114,7 +114,7 @@ data class AppSettings( name = "post_actionbar_mode", defaultValue = "0", ) - val postActionbarMode: Int, + val postActionBarMode: Int, @ColumnInfo( name = "auto_play_gifs", defaultValue = "0", diff --git a/app/src/main/java/com/jerboa/feat/BlurNSFW.kt b/app/src/main/java/com/jerboa/feat/BlurNSFW.kt new file mode 100644 index 000000000..9e8654493 --- /dev/null +++ b/app/src/main/java/com/jerboa/feat/BlurNSFW.kt @@ -0,0 +1,32 @@ +package com.jerboa.feat + +import androidx.annotation.StringRes +import com.jerboa.R +import it.vercruysse.lemmyapi.v0x19.datatypes.PostView + +enum class BlurNSFW( + @StringRes val resId: Int, +) { + Nothing(R.string.app_settings_nothing), + NSFW(R.string.app_settings_blur_nsfw), + NsfwExceptFromNsfwCommunities(R.string.app_settings_blur_nsfw_except_from_nsfw_communities), +} + +fun BlurNSFW.changeBlurTypeInsideCommunity() = + if (this == BlurNSFW.NsfwExceptFromNsfwCommunities) { + BlurNSFW.Nothing + } else { + this + } + +fun BlurNSFW.needBlur(postView: PostView) = this.needBlur(postView.community.nsfw, postView.post.nsfw) + +fun BlurNSFW.needBlur( + isCommunityNsfw: Boolean, + isPostNsfw: Boolean = isCommunityNsfw, +): Boolean { + return when (this) { + BlurNSFW.Nothing -> false + BlurNSFW.NSFW, BlurNSFW.NsfwExceptFromNsfwCommunities -> isPostNsfw + } +} diff --git a/app/src/main/java/com/jerboa/feat/BlurTypes.kt b/app/src/main/java/com/jerboa/feat/BlurTypes.kt deleted file mode 100644 index 9358d6eae..000000000 --- a/app/src/main/java/com/jerboa/feat/BlurTypes.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.jerboa.feat - -import androidx.annotation.StringRes -import com.jerboa.R -import com.jerboa.toEnum -import it.vercruysse.lemmyapi.v0x19.datatypes.PostView - -enum class BlurTypes( - @StringRes val resId: Int, -) { - Nothing(R.string.app_settings_nothing), - NSFW(R.string.app_settings_blur_nsfw), - NsfwExceptFromNsfwCommunities(R.string.app_settings_blur_nsfw_except_from_nsfw_communities), - ; - - companion object { - fun changeBlurTypeInsideCommunity(blurTypes: Int): Int = - if (blurTypes.toEnum() == NsfwExceptFromNsfwCommunities) { - Nothing.ordinal - } else { - blurTypes - } - } -} - -fun BlurTypes.needBlur(postView: PostView) = this.needBlur(postView.community.nsfw, postView.post.nsfw) - -fun BlurTypes.needBlur( - isCommunityNsfw: Boolean, - isPostNsfw: Boolean = isCommunityNsfw, -): Boolean { - return when (this) { - BlurTypes.Nothing -> false - BlurTypes.NSFW, BlurTypes.NsfwExceptFromNsfwCommunities -> isPostNsfw - } -} diff --git a/app/src/main/java/com/jerboa/feat/PostActionbarMode.kt b/app/src/main/java/com/jerboa/feat/PostActionBarMode.kt similarity index 90% rename from app/src/main/java/com/jerboa/feat/PostActionbarMode.kt rename to app/src/main/java/com/jerboa/feat/PostActionBarMode.kt index 8530c7016..a4aa6b95c 100644 --- a/app/src/main/java/com/jerboa/feat/PostActionbarMode.kt +++ b/app/src/main/java/com/jerboa/feat/PostActionBarMode.kt @@ -3,7 +3,7 @@ package com.jerboa.feat import androidx.annotation.StringRes import com.jerboa.R -enum class PostActionbarMode( +enum class PostActionBarMode( @StringRes val resId: Int, ) { RightHandShort(R.string.post_actionbar_mode_short_right), diff --git a/app/src/main/java/com/jerboa/feat/SwipeToAction.kt b/app/src/main/java/com/jerboa/feat/SwipeToAction.kt index 5e64bf638..02d130c17 100644 --- a/app/src/main/java/com/jerboa/feat/SwipeToAction.kt +++ b/app/src/main/java/com/jerboa/feat/SwipeToAction.kt @@ -3,7 +3,6 @@ package com.jerboa.feat import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.Comment import androidx.compose.material.icons.outlined.Bookmark -import androidx.compose.material.icons.outlined.Comment import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color 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 c1dbf2c64..69815d699 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 @@ -58,6 +58,7 @@ import com.jerboa.datatypes.sampleReplyCommentView import com.jerboa.datatypes.sampleSecondReplyCommentView import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount +import com.jerboa.feat.BlurNSFW import com.jerboa.feat.InstantScores import com.jerboa.feat.SwipeToActionPreset import com.jerboa.feat.SwipeToActionType @@ -81,7 +82,16 @@ import com.jerboa.ui.theme.SMALL_PADDING import com.jerboa.ui.theme.XXL_PADDING import com.jerboa.ui.theme.colorList import com.jerboa.ui.theme.muted -import it.vercruysse.lemmyapi.v0x19.datatypes.* +import it.vercruysse.lemmyapi.v0x19.datatypes.Comment +import it.vercruysse.lemmyapi.v0x19.datatypes.CommentId +import it.vercruysse.lemmyapi.v0x19.datatypes.CommentView +import it.vercruysse.lemmyapi.v0x19.datatypes.Community +import it.vercruysse.lemmyapi.v0x19.datatypes.CommunityModeratorView +import it.vercruysse.lemmyapi.v0x19.datatypes.Person +import it.vercruysse.lemmyapi.v0x19.datatypes.PersonId +import it.vercruysse.lemmyapi.v0x19.datatypes.PersonView +import it.vercruysse.lemmyapi.v0x19.datatypes.Post +import it.vercruysse.lemmyapi.v0x19.datatypes.PostId @Composable fun CommentNodeHeader( @@ -217,7 +227,7 @@ fun LazyListScope.commentNodeItem( showActionBar: (commentId: CommentId) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showScores: Boolean, swipeToActionPreset: SwipeToActionPreset, ) { @@ -524,7 +534,7 @@ fun LazyListScope.missingCommentNodeItem( showActionBar: (commentId: CommentId) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showScores: Boolean, swipeToActionPreset: SwipeToActionPreset, ) { @@ -692,7 +702,7 @@ fun PostAndCommunityContextHeader( community: Community, onCommunityClick: (community: Community) -> Unit, onPostClick: (postId: PostId) -> Unit, - blurNSFW: Int, + blurNSFW: BlurNSFW, ) { Column( modifier = Modifier.padding(top = LARGE_PADDING), @@ -724,7 +734,7 @@ fun PostAndCommunityContextHeaderPreview() { community = sampleCommunity, onCommunityClick = {}, onPostClick = {}, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, ) } @@ -929,7 +939,7 @@ fun CommentNodesPreview() { showActionBar = { _ -> true }, enableDownVotes = true, showAvatar = true, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, account = AnonAccount, showScores = true, swipeToActionPreset = SwipeToActionPreset.DEFAULT, 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 086ad0e4a..747970e43 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 @@ -13,6 +13,7 @@ import com.jerboa.CommentNodeData import com.jerboa.MissingCommentNode import com.jerboa.datatypes.BanFromCommunityData import com.jerboa.db.entity.Account +import com.jerboa.feat.BlurNSFW import com.jerboa.feat.SwipeToActionPreset import it.vercruysse.lemmyapi.v0x19.datatypes.CommentId import it.vercruysse.lemmyapi.v0x19.datatypes.CommentView @@ -63,7 +64,7 @@ fun CommentNodes( showActionBar: (commentId: CommentId) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showScores: Boolean, swipeToActionPreset: SwipeToActionPreset, ) { @@ -154,7 +155,7 @@ fun LazyListScope.commentNodeItems( showActionBar: (commentId: CommentId) -> Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showScores: Boolean, swipeToActionPreset: SwipeToActionPreset, ) { 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 1f0c0d64d..99c25fc84 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 @@ -29,6 +29,7 @@ import androidx.compose.ui.tooling.preview.Preview import com.jerboa.R import com.jerboa.datatypes.samplePersonMentionView import com.jerboa.db.entity.Account +import com.jerboa.feat.BlurNSFW import com.jerboa.feat.VoteType import com.jerboa.feat.canMod import com.jerboa.ui.components.comment.CommentBody @@ -262,7 +263,7 @@ fun CommentMentionNode( onBlockCreatorClick: (creator: Person) -> Unit, account: Account, showAvatar: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, enableDownvotes: Boolean, showScores: Boolean, ) { diff --git a/app/src/main/java/com/jerboa/ui/components/comment/reply/CommentReply.kt b/app/src/main/java/com/jerboa/ui/components/comment/reply/CommentReply.kt index 4838fcc90..a01b771f8 100644 --- a/app/src/main/java/com/jerboa/ui/components/comment/reply/CommentReply.kt +++ b/app/src/main/java/com/jerboa/ui/components/comment/reply/CommentReply.kt @@ -7,7 +7,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.* +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource 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 0a729bba9..2c12a4dfc 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 @@ -29,6 +29,7 @@ import androidx.compose.ui.tooling.preview.Preview import com.jerboa.R import com.jerboa.datatypes.sampleCommentReplyView import com.jerboa.db.entity.Account +import com.jerboa.feat.BlurNSFW import com.jerboa.feat.VoteType import com.jerboa.ui.components.comment.CommentBody import com.jerboa.ui.components.comment.PostAndCommunityContextHeader @@ -242,7 +243,7 @@ fun CommentReplyNodeInbox( onBlockCreatorClick: (creator: Person) -> Unit, account: Account, showAvatar: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, enableDownvotes: Boolean, showScores: Boolean, ) { diff --git a/app/src/main/java/com/jerboa/ui/components/common/AppBars.kt b/app/src/main/java/com/jerboa/ui/components/common/AppBars.kt index 921dc416c..2a84380a4 100644 --- a/app/src/main/java/com/jerboa/ui/components/common/AppBars.kt +++ b/app/src/main/java/com/jerboa/ui/components/common/AppBars.kt @@ -11,7 +11,6 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.* -import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.rememberLazyListState 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 0e246af08..39ef8f587 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 @@ -3,13 +3,42 @@ package com.jerboa.ui.components.community import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.basicMarquee -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.ArrowBack import androidx.compose.material.icons.automirrored.outlined.Sort -import androidx.compose.material.icons.outlined.* -import androidx.compose.material3.* -import androidx.compose.runtime.* +import androidx.compose.material.icons.outlined.Block +import androidx.compose.material.icons.outlined.CheckCircle +import androidx.compose.material.icons.outlined.Info +import androidx.compose.material.icons.outlined.MoreVert +import androidx.compose.material.icons.outlined.Refresh +import androidx.compose.material.icons.outlined.Share +import androidx.compose.material.icons.outlined.ViewAgenda +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarScrollBehavior +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -20,13 +49,15 @@ import com.jerboa.PostViewMode import com.jerboa.R import com.jerboa.datatypes.data import com.jerboa.datatypes.sampleCommunityView -import com.jerboa.feat.BlurTypes +import com.jerboa.feat.BlurNSFW import com.jerboa.feat.needBlur -import com.jerboa.toEnum import com.jerboa.ui.components.common.LargerCircularIcon import com.jerboa.ui.components.common.PictrsBannerImage import com.jerboa.ui.components.common.SortOptionsDropdown -import com.jerboa.ui.theme.* +import com.jerboa.ui.theme.ACTION_BAR_ICON_SIZE +import com.jerboa.ui.theme.DRAWER_BANNER_SIZE +import com.jerboa.ui.theme.MEDIUM_PADDING +import com.jerboa.ui.theme.muted import it.vercruysse.lemmyapi.dto.SortType import it.vercruysse.lemmyapi.dto.SubscribedType import it.vercruysse.lemmyapi.v0x19.datatypes.CommunityView @@ -37,7 +68,7 @@ fun CommunityTopSection( communityView: CommunityView, modifier: Modifier = Modifier, onClickFollowCommunity: (communityView: CommunityView) -> Unit, - blurNSFW: Int, + blurNSFW: BlurNSFW, ) { Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -52,11 +83,11 @@ fun CommunityTopSection( PictrsBannerImage( url = it, modifier = Modifier.height(DRAWER_BANNER_SIZE), - blur = blurNSFW.toEnum().needBlur(communityView.community.nsfw), + blur = blurNSFW.needBlur(communityView.community.nsfw), ) } communityView.community.icon?.also { - LargerCircularIcon(icon = it, blur = blurNSFW.toEnum().needBlur(communityView.community.nsfw)) + LargerCircularIcon(icon = it, blur = blurNSFW.needBlur(communityView.community.nsfw)) } } Column( @@ -128,7 +159,7 @@ fun CommunityTopSectionPreview() { CommunityTopSection( communityView = sampleCommunityView, onClickFollowCommunity = {}, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, ) } 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 54e20cfa2..7798467e9 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 @@ -34,9 +34,11 @@ import com.jerboa.R import com.jerboa.api.ApiState import com.jerboa.datatypes.BanFromCommunityData import com.jerboa.db.entity.isAnon -import com.jerboa.feat.BlurTypes +import com.jerboa.feat.BlurNSFW +import com.jerboa.feat.PostActionBarMode import com.jerboa.feat.SwipeToActionPreset import com.jerboa.feat.VoteType +import com.jerboa.feat.changeBlurTypeInsideCommunity import com.jerboa.feat.doIfReadyElseDisplayInfo import com.jerboa.feat.newVote import com.jerboa.feat.shareLink @@ -86,10 +88,10 @@ fun CommunityActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, swipeToActionPreset: SwipeToActionPreset, ) { Log.d("jerboa", "got to community activity") @@ -251,7 +253,7 @@ fun CommunityActivity( ) } }, - blurNSFW = BlurTypes.changeBlurTypeInsideCommunity(blurNSFW), + blurNSFW = blurNSFW.changeBlurTypeInsideCommunity(), ) } @@ -407,7 +409,7 @@ fun CommunityActivity( showAvatar = siteViewModel.showAvatar(), useCustomTabs = useCustomTabs, usePrivateTabs = usePrivateTabs, - blurNSFW = BlurTypes.changeBlurTypeInsideCommunity(blurNSFW), + blurNSFW = blurNSFW.changeBlurTypeInsideCommunity(), showPostLinkPreviews = showPostLinkPreviews, appState = appState, markAsReadOnScroll = markAsReadOnScroll, @@ -425,7 +427,7 @@ fun CommunityActivity( }, showIfRead = true, showScores = siteViewModel.showScores(), - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, showPostAppendRetry = communityViewModel.postsRes is ApiState.AppendingFailure, swipeToActionPreset = swipeToActionPreset, ) 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 721886746..62e83c643 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 @@ -25,9 +25,8 @@ import com.jerboa.R import com.jerboa.communityNameShown import com.jerboa.datatypes.sampleCommunity import com.jerboa.datatypes.sampleCommunityView -import com.jerboa.feat.BlurTypes +import com.jerboa.feat.BlurNSFW import com.jerboa.feat.needBlur -import com.jerboa.toEnum import com.jerboa.ui.components.common.CircularIcon import com.jerboa.ui.theme.DRAWER_ITEM_SPACING import com.jerboa.ui.theme.ICON_SIZE @@ -76,7 +75,7 @@ fun CommunityLink( onClick: (community: Community) -> Unit, clickable: Boolean = true, showDefaultIcon: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, ) { Row( verticalAlignment = Alignment.CenterVertically, @@ -94,7 +93,7 @@ fun CommunityLink( contentDescription = null, size = size, thumbnailSize = thumbnailSize, - blur = blurNSFW.toEnum().needBlur(community.nsfw), + blur = blurNSFW.needBlur(community.nsfw), ) } ?: run { if (showDefaultIcon) { @@ -122,7 +121,7 @@ fun CommunityLinkLarger( community: Community, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, ) { CommunityLink( community = community, @@ -146,7 +145,7 @@ fun CommunityLinkLargerWithUserCount( communityView: CommunityView, onClick: (community: Community) -> Unit, showDefaultIcon: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, ) { CommunityLink( community = communityView.community, @@ -173,7 +172,7 @@ fun CommunityLinkPreview() { community = sampleCommunity, onClick = {}, showDefaultIcon = true, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, ) } @@ -184,6 +183,6 @@ fun CommunityLinkWithUsersPreview() { communityView = sampleCommunityView, onClick = {}, showDefaultIcon = true, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, ) } 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 1126c3a9b..b0bab8438 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 @@ -23,6 +23,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.tooling.preview.Preview import com.jerboa.R import com.jerboa.datatypes.sampleCommunityView +import com.jerboa.feat.BlurNSFW import com.jerboa.ui.components.common.simpleVerticalScrollbar import com.jerboa.ui.components.community.CommunityLinkLarger import com.jerboa.ui.components.community.CommunityLinkLargerWithUserCount @@ -71,7 +72,7 @@ fun CommunityListings( communities: List, onClickCommunity: (community: Community) -> Unit, modifier: Modifier = Modifier, - blurNSFW: Int, + blurNSFW: BlurNSFW, ) { val listState = rememberLazyListState() @@ -111,7 +112,7 @@ fun CommunityListingsPreview() { CommunityListings( communities = communities, onClickCommunity = {}, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, ) } 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 e18ba9e8f..d508b1b5c 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 @@ -18,6 +18,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel import com.jerboa.DEBOUNCE_DELAY import com.jerboa.JerboaAppState import com.jerboa.api.ApiState +import com.jerboa.feat.BlurNSFW import com.jerboa.model.CommunityListViewModel import com.jerboa.ui.components.common.ApiEmptyText import com.jerboa.ui.components.common.ApiErrorText @@ -41,7 +42,7 @@ fun CommunityListActivity( appState: JerboaAppState, selectMode: Boolean = false, followList: List, - blurNSFW: Int, + blurNSFW: BlurNSFW, 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 34bcaa60f..0d6eb1bf6 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 @@ -49,6 +49,7 @@ import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount import com.jerboa.db.entity.isAnon import com.jerboa.db.entity.isReady +import com.jerboa.feat.BlurNSFW import com.jerboa.model.AccountViewModel import com.jerboa.model.AccountViewModelFactory import com.jerboa.ui.components.common.IconAndTextDrawerItem @@ -84,7 +85,7 @@ fun Drawer( onCommunityClick: (community: Community) -> Unit, onClickSettings: () -> Unit, isOpen: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -134,7 +135,7 @@ fun DrawerContent( onClickSettings: () -> Unit, myUserInfo: MyUserInfo?, unreadCount: Long, - blurNSFW: Int, + blurNSFW: BlurNSFW, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -178,7 +179,7 @@ fun DrawerItemsMain( onClickListingType: (ListingType) -> Unit, onCommunityClick: (community: Community) -> Unit, unreadCount: Long, - blurNSFW: Int, + blurNSFW: BlurNSFW, showBottomNav: Boolean, closeDrawer: () -> Unit, onSelectTab: (NavTab) -> Unit, @@ -290,7 +291,7 @@ fun DrawerItemsMainPreview() { onCommunityClick = {}, onClickSettings = {}, unreadCount = 2, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, 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 d0e07b0da..163cd0a02 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 @@ -11,6 +11,7 @@ import com.jerboa.api.ApiState import com.jerboa.closeDrawer import com.jerboa.db.entity.isAnon import com.jerboa.db.entity.isReady +import com.jerboa.feat.BlurNSFW import com.jerboa.model.AccountViewModel import com.jerboa.model.HomeViewModel import com.jerboa.model.SiteViewModel @@ -31,7 +32,7 @@ fun MainDrawer( onCommunityClick: (CommunityId) -> Unit, onClickLogin: () -> Unit, onSelectTab: (NavTab) -> Unit, - blurNSFW: Int, + blurNSFW: BlurNSFW, 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 971189baa..95db6b241 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 @@ -166,7 +166,7 @@ fun BottomNavActivity( scope = scope, drawerState = drawerState, onSelectTab = onSelectTab, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showBottomNav = appSettings.showBottomNav, onCommunityClick = appState::toCommunity, onSettingsClick = appState::toSettings, @@ -213,10 +213,10 @@ fun BottomNavActivity( useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, drawerState = drawerState, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showPostLinkPreviews = appSettings.showPostLinkPreviews, markAsReadOnScroll = appSettings.markAsReadOnScroll, - postActionbarMode = appSettings.postActionbarMode, + postActionBarMode = appSettings.postActionBarMode.toEnum(), swipeToActionPreset = appSettings.swipeToActionPreset.toEnum(), ) } @@ -226,7 +226,7 @@ fun BottomNavActivity( appState = appState, selectMode = false, followList = siteViewModel.getFollowList(), - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), drawerState = drawerState, ) } @@ -236,7 +236,7 @@ fun BottomNavActivity( appState = appState, accountViewModel = accountViewModel, siteViewModel = siteViewModel, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), drawerState = drawerState, ) } @@ -252,11 +252,11 @@ fun BottomNavActivity( siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, markAsReadOnScroll = appSettings.markAsReadOnScroll, - postActionbarMode = appSettings.postActionbarMode, + postActionBarMode = appSettings.postActionBarMode.toEnum(), swipeToActionPreset = appSettings.swipeToActionPreset.toEnum(), ) } @@ -272,11 +272,11 @@ fun BottomNavActivity( siteViewModel = siteViewModel, useCustomTabs = appSettings.useCustomTabs, usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, + blurNSFW = appSettings.blurNSFW.toEnum(), showPostLinkPreviews = appSettings.showPostLinkPreviews, drawerState = drawerState, markAsReadOnScroll = appSettings.markAsReadOnScroll, - postActionbarMode = appSettings.postActionbarMode, + postActionBarMode = appSettings.postActionBarMode.toEnum(), swipeToActionPreset = appSettings.swipeToActionPreset.toEnum(), ) } 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 ba39d6f69..8a8f03675 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 @@ -42,6 +42,8 @@ import com.jerboa.datatypes.BanFromCommunityData import com.jerboa.db.entity.Account import com.jerboa.db.entity.isAnon import com.jerboa.db.entity.isReady +import com.jerboa.feat.BlurNSFW +import com.jerboa.feat.PostActionBarMode import com.jerboa.feat.SwipeToActionPreset import com.jerboa.feat.VoteType import com.jerboa.feat.doIfReadyElseDisplayInfo @@ -91,10 +93,10 @@ fun HomeActivity( useCustomTabs: Boolean, usePrivateTabs: Boolean, drawerState: DrawerState, - blurNSFW: Int, + blurNSFW: BlurNSFW, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, swipeToActionPreset: SwipeToActionPreset, ) { Log.d("jerboa", "got to home activity") @@ -161,7 +163,7 @@ fun HomeActivity( showPostLinkPreviews = showPostLinkPreviews, markAsReadOnScroll = markAsReadOnScroll, snackbarHostState = snackbarHostState, - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, swipeToActionPreset = swipeToActionPreset, ) }, @@ -206,11 +208,11 @@ fun MainPostListingsContent( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showPostLinkPreviews: Boolean, snackbarHostState: SnackbarHostState, markAsReadOnScroll: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, swipeToActionPreset: SwipeToActionPreset, ) { val ctx = LocalContext.current @@ -425,7 +427,7 @@ fun MainPostListingsContent( }, showIfRead = true, showScores = siteViewModel.showScores(), - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, showPostAppendRetry = homeViewModel.postsRes is ApiState.AppendingFailure, swipeToActionPreset = swipeToActionPreset, ) 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 a1e8535a7..c40605435 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 @@ -44,6 +44,7 @@ import com.jerboa.R import com.jerboa.UnreadOrAll import com.jerboa.api.ApiState import com.jerboa.db.entity.Account +import com.jerboa.feat.BlurNSFW import com.jerboa.feat.VoteType import com.jerboa.feat.doIfReadyElseDisplayInfo import com.jerboa.feat.newVote @@ -83,7 +84,7 @@ fun InboxActivity( drawerState: DrawerState, siteViewModel: SiteViewModel, accountViewModel: AccountViewModel, - blurNSFW: Int, + blurNSFW: BlurNSFW, ) { Log.d("jerboa", "got to inbox activity") @@ -195,7 +196,7 @@ fun InboxTabs( scope: CoroutineScope, snackbarHostState: SnackbarHostState, padding: PaddingValues, - blurNSFW: Int, + blurNSFW: BlurNSFW, ) { val pagerState = rememberPagerState { InboxTab.entries.size } diff --git a/app/src/main/java/com/jerboa/ui/components/person/PersonProfile.kt b/app/src/main/java/com/jerboa/ui/components/person/PersonProfile.kt index 717e1090f..fd9dda4e3 100644 --- a/app/src/main/java/com/jerboa/ui/components/person/PersonProfile.kt +++ b/app/src/main/java/com/jerboa/ui/components/person/PersonProfile.kt @@ -13,7 +13,10 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.ArrowBack import androidx.compose.material.icons.automirrored.outlined.Message import androidx.compose.material.icons.automirrored.outlined.Sort -import androidx.compose.material.icons.outlined.* +import androidx.compose.material.icons.outlined.Block +import androidx.compose.material.icons.outlined.Flag +import androidx.compose.material.icons.outlined.Menu +import androidx.compose.material.icons.outlined.MoreVert import androidx.compose.material3.DropdownMenu import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider 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 8cbf2dfcc..f4bafaa91 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 @@ -51,6 +51,8 @@ import com.jerboa.datatypes.getDisplayName import com.jerboa.datatypes.getLocalizedStringForUserTab import com.jerboa.db.entity.Account import com.jerboa.db.entity.isAnon +import com.jerboa.feat.BlurNSFW +import com.jerboa.feat.PostActionBarMode import com.jerboa.feat.SwipeToActionPreset import com.jerboa.feat.VoteType import com.jerboa.feat.doIfReadyElseDisplayInfo @@ -116,11 +118,11 @@ fun PersonProfileActivity( showVotingArrowsInListView: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showPostLinkPreviews: Boolean, drawerState: DrawerState, markAsReadOnScroll: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, onBack: (() -> Unit)? = null, swipeToActionPreset: SwipeToActionPreset, ) { @@ -272,7 +274,7 @@ fun PersonProfileActivity( markAsReadOnScroll = markAsReadOnScroll, snackbarHostState = snackbarHostState, showScores = siteViewModel.showScores(), - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, swipeToActionPreset = swipeToActionPreset, ) }, @@ -303,12 +305,12 @@ fun UserTabs( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showPostLinkPreviews: Boolean, markAsReadOnScroll: Boolean, snackbarHostState: SnackbarHostState, showScores: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, swipeToActionPreset: SwipeToActionPreset, ) { val tabTitles = @@ -625,7 +627,7 @@ fun UserTabs( }, showIfRead = false, showScores = showScores, - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, showPostAppendRetry = personProfileViewModel.personDetailsRes is ApiState.AppendingFailure, swipeToActionPreset = swipeToActionPreset, ) diff --git a/app/src/main/java/com/jerboa/ui/components/person/PersonProfileLink.kt b/app/src/main/java/com/jerboa/ui/components/person/PersonProfileLink.kt index 9b0a8afe0..1ad36be87 100644 --- a/app/src/main/java/com/jerboa/ui/components/person/PersonProfileLink.kt +++ b/app/src/main/java/com/jerboa/ui/components/person/PersonProfileLink.kt @@ -4,7 +4,9 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.outlined.* +import androidx.compose.material.icons.outlined.NoAccounts +import androidx.compose.material.icons.outlined.Shield +import androidx.compose.material.icons.outlined.SmartToy import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text 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 eefd8fe09..b614cb2eb 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 @@ -59,6 +59,8 @@ import com.jerboa.buildCommentsTree import com.jerboa.datatypes.BanFromCommunityData import com.jerboa.datatypes.getLocalizedCommentSortTypeName import com.jerboa.db.entity.isAnon +import com.jerboa.feat.BlurNSFW +import com.jerboa.feat.PostActionBarMode import com.jerboa.feat.SwipeToActionPreset import com.jerboa.feat.VoteType import com.jerboa.feat.doIfReadyElseDisplayInfo @@ -92,7 +94,20 @@ import com.jerboa.ui.components.post.edit.PostEditReturn import com.jerboa.ui.components.remove.comment.CommentRemoveReturn import com.jerboa.ui.components.remove.post.PostRemoveReturn import it.vercruysse.lemmyapi.dto.CommentSortType -import it.vercruysse.lemmyapi.v0x19.datatypes.* +import it.vercruysse.lemmyapi.v0x19.datatypes.BlockPerson +import it.vercruysse.lemmyapi.v0x19.datatypes.CommentId +import it.vercruysse.lemmyapi.v0x19.datatypes.CommentView +import it.vercruysse.lemmyapi.v0x19.datatypes.CreateCommentLike +import it.vercruysse.lemmyapi.v0x19.datatypes.CreatePostLike +import it.vercruysse.lemmyapi.v0x19.datatypes.DeleteComment +import it.vercruysse.lemmyapi.v0x19.datatypes.DeletePost +import it.vercruysse.lemmyapi.v0x19.datatypes.FeaturePost +import it.vercruysse.lemmyapi.v0x19.datatypes.LockPost +import it.vercruysse.lemmyapi.v0x19.datatypes.PersonView +import it.vercruysse.lemmyapi.v0x19.datatypes.PostId +import it.vercruysse.lemmyapi.v0x19.datatypes.PostView +import it.vercruysse.lemmyapi.v0x19.datatypes.SaveComment +import it.vercruysse.lemmyapi.v0x19.datatypes.SavePost object PostViewReturn { const val POST_VIEW = "post-view::return(post-view)" @@ -131,9 +146,9 @@ fun PostActivity( showVotingArrowsInListView: Boolean, showParentCommentNavigationButtons: Boolean, navigateParentCommentsWithVolumeButtons: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showPostLinkPreview: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, swipeToActionPreset: SwipeToActionPreset, ) { Log.d("jerboa", "got to post activity") @@ -462,7 +477,7 @@ fun PostActivity( showPostLinkPreview = showPostLinkPreview, showIfRead = false, showScores = siteViewModel.showScores(), - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, swipeToActionPreset = swipeToActionPreset, ) } 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 0e19ca15e..1399b8ed0 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 @@ -69,9 +69,9 @@ import com.jerboa.datatypes.sampleMarkdownPostView import com.jerboa.datatypes.samplePostView import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount -import com.jerboa.feat.BlurTypes +import com.jerboa.feat.BlurNSFW import com.jerboa.feat.InstantScores -import com.jerboa.feat.PostActionbarMode +import com.jerboa.feat.PostActionBarMode import com.jerboa.feat.SwipeToActionPreset import com.jerboa.feat.SwipeToActionType import com.jerboa.feat.VoteType @@ -86,7 +86,6 @@ import com.jerboa.isSameInstance import com.jerboa.nsfwCheck import com.jerboa.rememberJerboaAppState import com.jerboa.siFormat -import com.jerboa.toEnum import com.jerboa.toHttps import com.jerboa.ui.components.common.ActionBarButton import com.jerboa.ui.components.common.ActionBarButtonAndBadge @@ -135,7 +134,7 @@ fun PostHeaderLine( modifier: Modifier = Modifier, showCommunityName: Boolean = true, showAvatar: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showScores: Boolean, ) { val community = postView.community @@ -156,7 +155,7 @@ fun PostHeaderLine( size = MEDIUM_ICON_SIZE, modifier = Modifier.clickable { onCommunityClick(community) }, thumbnailSize = LARGER_ICON_THUMBNAIL_SIZE, - blur = blurNSFW.toEnum().needBlur(community.nsfw), + blur = blurNSFW.needBlur(community.nsfw), ) } } @@ -250,7 +249,7 @@ fun PostHeaderLinePreview() { onCommunityClick = {}, onPersonClick = {}, showAvatar = true, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, showScores = true, ) } @@ -290,7 +289,7 @@ fun PostTitleBlock( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -346,7 +345,7 @@ fun PostName( @Composable fun PostTitleAndImageLink( postView: PostView, - blurNSFW: Int, + blurNSFW: BlurNSFW, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -369,7 +368,7 @@ fun PostTitleAndImageLink( PictrsUrlImage( url = url, - blur = blurNSFW.toEnum().needBlur(postView), + blur = blurNSFW.needBlur(postView), modifier = Modifier .combinedClickable( @@ -385,7 +384,7 @@ fun PostTitleAndThumbnail( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, appState: JerboaAppState, showIfRead: Boolean, ) { @@ -434,7 +433,7 @@ fun PostBody( account: Account, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showPostLinkPreview: Boolean, appState: JerboaAppState, clickBody: () -> Unit = {}, @@ -519,7 +518,7 @@ fun PreviewStoryTitleAndMetadata() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -537,7 +536,7 @@ fun PreviewSourcePost() { account = AnonAccount, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, showPostLinkPreview = true, appState = rememberJerboaAppState(), showIfRead = true, @@ -572,7 +571,7 @@ fun PostFooterLine( enableDownVotes: Boolean, viewSource: Boolean, showScores: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, fromPostActivity: Boolean, scope: CoroutineScope, ) { @@ -630,13 +629,11 @@ fun PostFooterLine( ) } - val postActionbar = postActionbarMode.toEnum() - val horizontalArrangement = - when (postActionbar) { - PostActionbarMode.Long -> Arrangement.spacedBy(XXL_PADDING) - PostActionbarMode.LeftHandShort -> Arrangement.spacedBy(LARGE_PADDING) - PostActionbarMode.RightHandShort -> Arrangement.spacedBy(LARGE_PADDING) + when (postActionBarMode) { + PostActionBarMode.Long -> Arrangement.spacedBy(XXL_PADDING) + PostActionBarMode.LeftHandShort -> Arrangement.spacedBy(LARGE_PADDING) + PostActionBarMode.RightHandShort -> Arrangement.spacedBy(LARGE_PADDING) } Row( @@ -648,7 +645,7 @@ fun PostFooterLine( .padding(bottom = SMALL_PADDING), ) { // Right handside shows the comments on the left side - if (postActionbar == PostActionbarMode.RightHandShort) { + if (postActionBarMode == PostActionBarMode.RightHandShort) { CommentNewCountRework( comments = postView.counts.comments, unreadCount = postView.unread_comments, @@ -676,7 +673,7 @@ fun PostFooterLine( ) } - if (postActionbar == PostActionbarMode.Long) { + if (postActionBarMode == PostActionBarMode.Long) { CommentNewCountRework( comments = postView.counts.comments, unreadCount = postView.unread_comments, @@ -721,7 +718,7 @@ fun PostFooterLine( account = account, onClick = { showMoreOptions = !showMoreOptions }, requiresAccount = false, - modifier = if (postActionbar == PostActionbarMode.LeftHandShort) { + modifier = if (postActionBarMode == PostActionBarMode.LeftHandShort) { Modifier.weight( 1F, true, @@ -731,7 +728,7 @@ fun PostFooterLine( }, ) - if (postActionbar == PostActionbarMode.LeftHandShort) { + if (postActionBarMode == PostActionBarMode.LeftHandShort) { CommentNewCountRework( comments = postView.counts.comments, unreadCount = postView.unread_comments, @@ -833,7 +830,7 @@ fun PostFooterLinePreview() { enableDownVotes = true, viewSource = false, showScores = true, - postActionbarMode = PostActionbarMode.Long.ordinal, + postActionBarMode = PostActionBarMode.Long, fromPostActivity = true, scope = rememberCoroutineScope(), ) @@ -870,12 +867,12 @@ fun PreviewPostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, showScores = true, - postActionbarMode = PostActionbarMode.Long.ordinal, + postActionBarMode = PostActionBarMode.Long, swipeToActionPreset = SwipeToActionPreset.DEFAULT, ) } @@ -911,12 +908,12 @@ fun PreviewLinkPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, showScores = true, - postActionbarMode = PostActionbarMode.Long.ordinal, + postActionBarMode = PostActionBarMode.Long, swipeToActionPreset = SwipeToActionPreset.DEFAULT, ) } @@ -952,12 +949,12 @@ fun PreviewImagePostListingCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, showScores = true, - postActionbarMode = PostActionbarMode.Long.ordinal, + postActionBarMode = PostActionBarMode.Long, swipeToActionPreset = SwipeToActionPreset.DEFAULT, ) } @@ -993,12 +990,12 @@ fun PreviewImagePostListingSmallCard() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, showScores = true, - postActionbarMode = PostActionbarMode.Long.ordinal, + postActionBarMode = PostActionBarMode.Long, swipeToActionPreset = SwipeToActionPreset.DEFAULT, ) } @@ -1034,12 +1031,12 @@ fun PreviewLinkNoThumbnailPostListing() { showVotingArrowsInListView = true, enableDownVotes = true, showAvatar = true, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, appState = rememberJerboaAppState(), showPostLinkPreview = true, showIfRead = true, showScores = true, - postActionbarMode = PostActionbarMode.Long.ordinal, + postActionBarMode = PostActionBarMode.Long, swipeToActionPreset = SwipeToActionPreset.DEFAULT, ) } @@ -1076,12 +1073,12 @@ fun PostListing( showVotingArrowsInListView: Boolean, enableDownVotes: Boolean, showAvatar: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, appState: JerboaAppState, showPostLinkPreview: Boolean, showIfRead: Boolean, showScores: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, swipeToActionPreset: SwipeToActionPreset, ) { val ctx = LocalContext.current @@ -1184,7 +1181,7 @@ fun PostListing( appState = appState, showIfRead = showIfRead, showScores = showScores, - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, ) PostViewMode.SmallCard -> @@ -1232,7 +1229,7 @@ fun PostListing( showPostLinkPreview = showPostLinkPreview, appState = appState, showScores = showScores, - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, ) PostViewMode.List -> @@ -1342,7 +1339,7 @@ fun PostListingList( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, appState: JerboaAppState, showIfRead: Boolean, enableDownVotes: Boolean, @@ -1467,7 +1464,7 @@ private fun ThumbnailTile( postView: PostView, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, appState: JerboaAppState, ) { postView.post.url?.also { url -> @@ -1497,7 +1494,7 @@ private fun ThumbnailTile( postView.post.thumbnail_url?.also { thumbnail -> PictrsThumbnailImage( thumbnail = thumbnail, - blur = blurNSFW.toEnum().needBlur(postView), + blur = blurNSFW.needBlur(postView), roundBottomEndCorner = postType != PostType.Link, modifier = postLinkPicMod, ) @@ -1562,7 +1559,7 @@ fun PostListingListPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1592,7 +1589,7 @@ fun PostListingListWithThumbPreview() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, appState = rememberJerboaAppState(), showIfRead = true, enableDownVotes = false, @@ -1633,12 +1630,12 @@ fun PostListingCard( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showPostLinkPreview: Boolean, appState: JerboaAppState, showIfRead: Boolean = false, showScores: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, ) { Column( modifier = @@ -1711,7 +1708,7 @@ fun PostListingCard( enableDownVotes = enableDownVotes, viewSource = viewSource, showScores = showScores, - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, fromPostActivity = fullBody, scope = appState.coroutineScope, ) 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 808bdc97c..ba712545f 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 @@ -26,6 +26,8 @@ import com.jerboa.datatypes.sampleLinkPostView import com.jerboa.datatypes.samplePostView import com.jerboa.db.entity.Account import com.jerboa.db.entity.AnonAccount +import com.jerboa.feat.BlurNSFW +import com.jerboa.feat.PostActionBarMode import com.jerboa.feat.SwipeToActionPreset import com.jerboa.isScrolledToEnd import com.jerboa.rememberJerboaAppState @@ -73,14 +75,14 @@ fun PostListings( showAvatar: Boolean, useCustomTabs: Boolean, usePrivateTabs: Boolean, - blurNSFW: Int, + blurNSFW: BlurNSFW, showPostLinkPreviews: Boolean, appState: JerboaAppState, markAsReadOnScroll: Boolean, onMarkAsRead: (postView: PostView) -> Unit, showIfRead: Boolean, showScores: Boolean, - postActionbarMode: Int, + postActionBarMode: PostActionBarMode, showPostAppendRetry: Boolean, swipeToActionPreset: SwipeToActionPreset, ) { @@ -135,7 +137,7 @@ fun PostListings( showPostLinkPreview = showPostLinkPreviews, showIfRead = showIfRead, showScores = showScores, - postActionbarMode = postActionbarMode, + postActionBarMode = postActionBarMode, swipeToActionPreset = swipeToActionPreset, ).let { if (!postView.read && markAsReadOnScroll) { @@ -204,14 +206,14 @@ fun PreviewPostListings() { showAvatar = true, useCustomTabs = false, usePrivateTabs = false, - blurNSFW = 1, + blurNSFW = BlurNSFW.NSFW, showPostLinkPreviews = true, appState = rememberJerboaAppState(), markAsReadOnScroll = false, onMarkAsRead = {}, showIfRead = true, showScores = true, - postActionbarMode = 0, + postActionBarMode = PostActionBarMode.Long, showPostAppendRetry = false, swipeToActionPreset = SwipeToActionPreset.DEFAULT, onReplyClick = {}, diff --git a/app/src/main/java/com/jerboa/ui/components/settings/about/AboutActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/about/AboutActivity.kt index 341806021..c5443cf89 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/about/AboutActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/about/AboutActivity.kt @@ -9,7 +9,12 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.Chat -import androidx.compose.material.icons.outlined.* +import androidx.compose.material.icons.outlined.AttachMoney +import androidx.compose.material.icons.outlined.BugReport +import androidx.compose.material.icons.outlined.Build +import androidx.compose.material.icons.outlined.Code +import androidx.compose.material.icons.outlined.NewReleases +import androidx.compose.material.icons.outlined.TravelExplore import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon 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 18b1ea7f7..847cc9aae 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 @@ -43,8 +43,8 @@ import com.jerboa.ThemeMode import com.jerboa.db.APP_SETTINGS_DEFAULT import com.jerboa.db.entity.AppSettings import com.jerboa.feat.BackConfirmationMode -import com.jerboa.feat.BlurTypes -import com.jerboa.feat.PostActionbarMode +import com.jerboa.feat.BlurNSFW +import com.jerboa.feat.PostActionBarMode import com.jerboa.feat.PostNavigationGestureMode import com.jerboa.feat.SwipeToActionPreset import com.jerboa.getLangPreferenceDropdownEntries @@ -101,7 +101,7 @@ fun LookAndFeelActivity( val blurNSFW = rememberIntSettingState(settings.blurNSFW) val backConfirmationMode = rememberIntSettingState(settings.backConfirmationMode) val showPostLinkPreviewMode = rememberBooleanSettingState(settings.showPostLinkPreviews) - val postActionbarMode = rememberIntSettingState(settings.postActionbarMode) + val postActionBarMode = rememberIntSettingState(settings.postActionBarMode) val snackbarHostState = remember { SnackbarHostState() } @@ -136,7 +136,7 @@ fun LookAndFeelActivity( backConfirmationMode = backConfirmationMode.value, showPostLinkPreviews = showPostLinkPreviewMode.value, markAsReadOnScroll = markAsReadOnScroll.value, - postActionbarMode = postActionbarMode.value, + postActionBarMode = postActionBarMode.value, autoPlayGifs = autoPlayGifs.value, postNavigationGestureMode = postNavigationGestureModeState.value, swipeToActionPreset = swipeToActionPreset.value, @@ -291,10 +291,10 @@ fun LookAndFeelActivity( title = { Text(text = stringResource(R.string.post_actionbar)) }, - state = postActionbarMode, - items = PostActionbarMode.entries.map { stringResource(it.resId) }, + state = postActionBarMode, + items = PostActionBarMode.entries.map { stringResource(it.resId) }, onItemSelected = { i, _ -> - postActionbarMode.value = i + postActionBarMode.value = i updateAppSettings() }, icon = { @@ -314,7 +314,7 @@ fun LookAndFeelActivity( ) }, title = { Text(stringResource(id = R.string.blur_nsfw)) }, - items = BlurTypes.entries.map { stringResource(it.resId) }, + items = BlurNSFW.entries.map { stringResource(it.resId) }, onItemSelected = { _, _ -> updateAppSettings() }, ) SettingsListDropdown( diff --git a/app/src/main/java/com/jerboa/util/CustomHttpLoggingInterceptor.kt b/app/src/main/java/com/jerboa/util/CustomHttpLoggingInterceptor.kt index 96ad3a51f..233493a0c 100644 --- a/app/src/main/java/com/jerboa/util/CustomHttpLoggingInterceptor.kt +++ b/app/src/main/java/com/jerboa/util/CustomHttpLoggingInterceptor.kt @@ -6,6 +6,7 @@ import okhttp3.Headers import okhttp3.HttpUrl import okhttp3.Interceptor import okhttp3.Response +import okhttp3.internal.charsetOrUtf8 import okhttp3.internal.http.promisesBody import okhttp3.internal.platform.Platform import okhttp3.logging.HttpLoggingInterceptor @@ -17,7 +18,6 @@ import org.json.JSONObject import java.io.IOException import java.nio.charset.Charset import java.util.concurrent.TimeUnit -import okhttp3.internal.charsetOrUtf8 as charsetOrUtf8 /** * Based of [HttpLoggingInterceptor], redacts the giving fields diff --git a/app/src/main/java/com/jerboa/util/cascade/CustomCascadeDropdown.kt b/app/src/main/java/com/jerboa/util/cascade/CustomCascadeDropdown.kt index 5ff93aaa1..d6a1cdf50 100644 --- a/app/src/main/java/com/jerboa/util/cascade/CustomCascadeDropdown.kt +++ b/app/src/main/java/com/jerboa/util/cascade/CustomCascadeDropdown.kt @@ -25,10 +25,10 @@ import com.jerboa.ui.theme.POPUP_MENU_WIDTH_RATIO import me.saket.cascade.CascadeColumnScope import me.saket.cascade.CascadeDefaults import me.saket.cascade.CascadeState +import me.saket.cascade.internal.copy import me.saket.cascade.rememberCascadeState import me.saket.cascade.PopupContent as CascadePopupContent import me.saket.cascade.internal.clickableWithoutRipple as clickableWithoutRippleCascade -import me.saket.cascade.internal.copy as copy import me.saket.cascade.internal.then as thenCascade @Composable diff --git a/app/src/main/java/com/jerboa/util/markwon/MarkwonLemmyLinkPlugin.kt b/app/src/main/java/com/jerboa/util/markwon/MarkwonLemmyLinkPlugin.kt index 7e724d213..e5b4d0c43 100644 --- a/app/src/main/java/com/jerboa/util/markwon/MarkwonLemmyLinkPlugin.kt +++ b/app/src/main/java/com/jerboa/util/markwon/MarkwonLemmyLinkPlugin.kt @@ -6,7 +6,10 @@ import android.text.style.URLSpan import android.text.util.Linkify import com.jerboa.ui.components.common.lemmyCommunityPattern import com.jerboa.ui.components.common.lemmyUserPattern -import io.noties.markwon.* +import io.noties.markwon.AbstractMarkwonPlugin +import io.noties.markwon.MarkwonPlugin +import io.noties.markwon.MarkwonVisitor +import io.noties.markwon.SpannableBuilder import io.noties.markwon.core.CorePlugin import io.noties.markwon.core.CoreProps import org.commonmark.node.Link