From 6faa46d37b2259d922d4dbc26cf7a123c3e7088e Mon Sep 17 00:00:00 2001 From: igarshep Date: Mon, 12 Jun 2023 01:26:42 -0500 Subject: [PATCH 1/4] respect avatar settings --- app/src/main/java/com/jerboa/MainActivity.kt | 3 +++ .../ui/components/comment/CommentNode.kt | 7 +++++++ .../ui/components/comment/CommentNodes.kt | 4 ++++ .../comment/mentionnode/CommentMentionNode.kt | 5 +++++ .../components/comment/reply/CommentReply.kt | 13 ++++++++++++ .../comment/reply/CommentReplyActivity.kt | 5 +++++ .../comment/replynode/CommentReplyNode.kt | 5 +++++ .../jerboa/ui/components/common/AppBars.kt | 3 +++ .../components/community/CommunityActivity.kt | 1 + .../com/jerboa/ui/components/home/Home.kt | 11 +++++++--- .../jerboa/ui/components/home/HomeActivity.kt | 1 + .../ui/components/inbox/InboxActivity.kt | 7 +++++++ .../ui/components/person/PersonProfile.kt | 20 ++++++++++++------- .../person/PersonProfileActivity.kt | 5 +++++ .../ui/components/person/PersonProfileLink.kt | 9 +++++++-- .../jerboa/ui/components/post/PostActivity.kt | 2 ++ .../jerboa/ui/components/post/PostListing.kt | 19 ++++++++++++++++++ .../jerboa/ui/components/post/PostListings.kt | 3 +++ .../privatemessage/PrivateMessage.kt | 6 ++++++ .../privatemessage/PrivateMessageReply.kt | 5 +++++ .../PrivateMessageReplyActivity.kt | 3 +++ 21 files changed, 125 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt index 4d87f6e4d..4005ce363 100644 --- a/app/src/main/java/com/jerboa/MainActivity.kt +++ b/app/src/main/java/com/jerboa/MainActivity.kt @@ -410,6 +410,7 @@ class MainActivity : ComponentActivity() { accountViewModel = accountViewModel, homeViewModel = homeViewModel, commentReplyViewModel = commentReplyViewModel, + siteViewModel = siteViewModel, ) } composable( @@ -489,6 +490,7 @@ class MainActivity : ComponentActivity() { accountViewModel = accountViewModel, personProfileViewModel = personProfileViewModel, navController = navController, + siteViewModel = siteViewModel, ) } composable( @@ -538,6 +540,7 @@ class MainActivity : ComponentActivity() { inboxViewModel = inboxViewModel, accountViewModel = accountViewModel, navController = navController, + siteViewModel = siteViewModel, ) } composable( 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 ee46cbba0..03e4f945e 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 @@ -99,6 +99,7 @@ fun CommentNodeHeader( isExpanded: Boolean, onClick: () -> Unit, onLongClick: () -> Unit, + showAvatar: Boolean, ) { CommentOrPostNodeHeader( creator = commentView.creator, @@ -115,6 +116,7 @@ fun CommentNodeHeader( isExpanded = isExpanded, onClick = onClick, onLongCLick = onLongClick, + showAvatar = showAvatar, ) } @@ -131,6 +133,7 @@ fun CommentNodeHeaderPreview() { onLongClick = {}, collapsedCommentsCount = 5, isExpanded = false, + showAvatar = true, ) } @@ -207,6 +210,7 @@ fun LazyListScope.commentNodeItem( isCollapsedByParent: Boolean, showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, + showAvatar: Boolean, ) { val commentView = node.commentView val commentId = commentView.comment.id @@ -281,6 +285,7 @@ fun LazyListScope.commentNodeItem( }, collapsedCommentsCount = node.commentView.counts.child_count, isExpanded = isExpanded(commentId), + showAvatar = showAvatar, ) AnimatedVisibility( visible = isExpanded(commentId) || showCollapsedCommentContent, @@ -388,6 +393,7 @@ fun LazyListScope.commentNodeItem( showCollapsedCommentContent = showCollapsedCommentContent, showActionBar = showActionBar, enableDownVotes = enableDownVotes, + showAvatar = showAvatar, ) } } @@ -632,6 +638,7 @@ fun CommentNodesPreview() { showCollapsedCommentContent = false, showActionBarByDefault = true, enableDownVotes = true, + showAvatar = 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 c93a983d7..1fbab5841 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 @@ -39,6 +39,7 @@ fun CommentNodes( isCollapsedByParent: Boolean, showActionBarByDefault: Boolean, enableDownVotes: Boolean, + showAvatar: Boolean, ) { // Holds the un-expanded comment ids val unExpandedComments = remember { mutableStateListOf() } @@ -86,6 +87,7 @@ fun CommentNodes( showActionBarByDefault xor commentsWithToggledActionBar.contains(commentId) }, enableDownVotes = enableDownVotes, + showAvatar = showAvatar, ) } } @@ -117,6 +119,7 @@ fun LazyListScope.commentNodeItems( isCollapsedByParent: Boolean, showActionBar: (commentId: Int) -> Boolean, enableDownVotes: Boolean, + showAvatar: Boolean, ) { nodes.forEach { node -> commentNodeItem( @@ -146,6 +149,7 @@ fun LazyListScope.commentNodeItems( isCollapsedByParent = isCollapsedByParent, showActionBar = showActionBar, enableDownVotes = enableDownVotes, + showAvatar = showAvatar, ) } } 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 5302ba077..8a0dc86f0 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 @@ -61,6 +61,7 @@ fun CommentMentionNodeHeader( myVote: Int?, onClick: () -> Unit, onLongClick: () -> Unit, + showAvatar: Boolean, ) { CommentOrPostNodeHeader( creator = personMentionView.creator, @@ -75,6 +76,7 @@ fun CommentMentionNodeHeader( isCommunityBanned = personMentionView.creator_banned_from_community, onClick = onClick, onLongCLick = onLongClick, + showAvatar = showAvatar, ) } @@ -88,6 +90,7 @@ fun CommentMentionNodeHeaderPreview() { onPersonClick = {}, onClick = {}, onLongClick = {}, + showAvatar = true, ) } @@ -290,6 +293,7 @@ fun CommentMentionNode( onLinkClick: (personMentionView: PersonMentionView) -> Unit, onBlockCreatorClick: (creator: PersonSafe) -> Unit, account: Account?, + showAvatar: Boolean, ) { // These are necessary for instant comment voting val score = personMentionView.counts.score @@ -322,6 +326,7 @@ fun CommentMentionNode( onLongClick = { isActionBarExpanded = !isActionBarExpanded }, + showAvatar = showAvatar, ) AnimatedVisibility( visible = isExpanded, 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 3888ee73c..b19326350 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 @@ -82,6 +82,7 @@ fun RepliedComment( commentView: CommentView, onPersonClick: (personId: Int) -> Unit, isModerator: Boolean, + showAvatar: Boolean, ) { Column(modifier = Modifier.padding(MEDIUM_PADDING)) { CommentNodeHeader( @@ -94,6 +95,7 @@ fun RepliedComment( isExpanded = true, onClick = {}, onLongClick = {}, + showAvatar = showAvatar, ) SelectionContainer { Text(text = commentView.comment.content) @@ -105,6 +107,7 @@ fun RepliedComment( fun RepliedCommentReply( commentReplyView: CommentReplyView, onPersonClick: (personId: Int) -> Unit, + showAvatar: Boolean, ) { Column(modifier = Modifier.padding(MEDIUM_PADDING)) { CommentReplyNodeHeader( @@ -114,6 +117,7 @@ fun RepliedCommentReply( myVote = commentReplyView.my_vote, onClick = {}, onLongClick = {}, + showAvatar = showAvatar, ) SelectionContainer { Text(text = commentReplyView.comment.content) @@ -125,6 +129,7 @@ fun RepliedCommentReply( fun RepliedMentionReply( personMentionView: PersonMentionView, onPersonClick: (personId: Int) -> Unit, + showAvatar: Boolean, ) { Column(modifier = Modifier.padding(MEDIUM_PADDING)) { CommentMentionNodeHeader( @@ -134,6 +139,7 @@ fun RepliedMentionReply( myVote = personMentionView.my_vote, onClick = {}, onLongClick = {}, + showAvatar = showAvatar, ) SelectionContainer { Text(text = personMentionView.comment.content) @@ -148,6 +154,7 @@ fun RepliedCommentPreview() { commentView = sampleCommentView, isModerator = false, onPersonClick = {}, + showAvatar = true, ) } @@ -181,6 +188,7 @@ fun CommentReply( isModerator: Boolean, account: Account?, modifier: Modifier = Modifier, + showAvatar: Boolean, ) { val scrollState = rememberScrollState() @@ -191,6 +199,7 @@ fun CommentReply( commentView = commentView, onPersonClick = onPersonClick, isModerator = isModerator, + showAvatar = showAvatar, ) Divider(modifier = Modifier.padding(vertical = LARGE_PADDING)) MarkdownTextField( @@ -210,6 +219,7 @@ fun CommentReplyReply( onPersonClick: (personId: Int) -> Unit, account: Account?, modifier: Modifier = Modifier, + showAvatar: Boolean, ) { val scrollState = rememberScrollState() @@ -219,6 +229,7 @@ fun CommentReplyReply( RepliedCommentReply( commentReplyView = commentReplyView, onPersonClick = onPersonClick, + showAvatar = showAvatar, ) Divider(modifier = Modifier.padding(vertical = LARGE_PADDING)) MarkdownTextField( @@ -238,6 +249,7 @@ fun MentionReply( onPersonClick: (personId: Int) -> Unit, account: Account?, modifier: Modifier = Modifier, + showAvatar: Boolean, ) { val scrollState = rememberScrollState() @@ -247,6 +259,7 @@ fun MentionReply( RepliedMentionReply( personMentionView = personMentionView, onPersonClick = onPersonClick, + showAvatar = showAvatar, ) Divider(modifier = Modifier.padding(vertical = LARGE_PADDING)) MarkdownTextField( diff --git a/app/src/main/java/com/jerboa/ui/components/comment/reply/CommentReplyActivity.kt b/app/src/main/java/com/jerboa/ui/components/comment/reply/CommentReplyActivity.kt index 9628ddda4..91b66e0a1 100644 --- a/app/src/main/java/com/jerboa/ui/components/comment/reply/CommentReplyActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/comment/reply/CommentReplyActivity.kt @@ -20,6 +20,7 @@ import androidx.navigation.NavController import com.jerboa.db.AccountViewModel import com.jerboa.isModerator import com.jerboa.ui.components.common.getCurrentAccount +import com.jerboa.ui.components.home.SiteViewModel import com.jerboa.ui.components.person.PersonProfileViewModel import com.jerboa.ui.components.post.PostViewModel @@ -31,6 +32,7 @@ fun CommentReplyActivity( personProfileViewModel: PersonProfileViewModel, postViewModel: PostViewModel, navController: NavController, + siteViewModel: SiteViewModel, ) { Log.d("jerboa", "got to comment reply activity") @@ -88,6 +90,7 @@ fun CommentReplyActivity( modifier = Modifier .padding(padding) .imePadding(), + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) is ReplyItem.PostItem -> PostReply( postView = replyItem.item, @@ -118,6 +121,7 @@ fun CommentReplyActivity( modifier = Modifier .padding(padding) .imePadding(), + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) is ReplyItem.MentionReplyItem -> MentionReply( @@ -131,6 +135,7 @@ fun CommentReplyActivity( modifier = Modifier .padding(padding) .imePadding(), + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) } } 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 02f5dd325..32f792f1a 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 @@ -61,6 +61,7 @@ fun CommentReplyNodeHeader( myVote: Int?, onClick: () -> Unit, onLongClick: () -> Unit, + showAvatar: Boolean, ) { CommentOrPostNodeHeader( creator = commentReplyView.creator, @@ -75,6 +76,7 @@ fun CommentReplyNodeHeader( isCommunityBanned = commentReplyView.creator_banned_from_community, onClick = onClick, onLongCLick = onLongClick, + showAvatar = showAvatar, ) } @@ -88,6 +90,7 @@ fun CommentReplyNodeHeaderPreview() { onPersonClick = {}, onClick = {}, onLongClick = {}, + showAvatar = true, ) } @@ -290,6 +293,7 @@ fun CommentReplyNode( onCommentLinkClick: (commentReplyView: CommentReplyView) -> Unit, onBlockCreatorClick: (creator: PersonSafe) -> Unit, account: Account?, + showAvatar: Boolean, ) { // These are necessary for instant comment voting val score = commentReplyView.counts.score @@ -322,6 +326,7 @@ fun CommentReplyNode( onLongClick = { isActionBarExpanded = !isActionBarExpanded }, + showAvatar = showAvatar, ) AnimatedVisibility( visible = isExpanded, 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 0691f9a08..3a377b908 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 @@ -237,6 +237,7 @@ fun CommentOrPostNodeHeader( onLongCLick: () -> Unit, isExpanded: Boolean = true, collapsedCommentsCount: Int = 0, + showAvatar: Boolean, ) { FlowRow( mainAxisAlignment = FlowMainAxisAlignment.SpaceBetween, @@ -274,6 +275,7 @@ fun CommentOrPostNodeHeader( isPostCreator = isPostCreator, isModerator = isModerator, isCommunityBanned = isCommunityBanned, + showAvatar = showAvatar, ) } ScoreAndTime( @@ -303,6 +305,7 @@ fun CommentOrPostNodeHeaderPreview() { isCommunityBanned = false, onClick = {}, onLongCLick = {}, + showAvatar = 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 ca056d927..7d18084e0 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 @@ -229,6 +229,7 @@ fun CommunityActivity( postViewMode = getPostViewMode(appSettingsViewModel), showVotingArrowsInListView = showVotingArrowsInListView, enableDownVotes = siteViewModel.siteRes?.site_view?.local_site?.enable_downvotes ?: true, + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) }, floatingActionButtonPosition = FabPosition.End, diff --git a/app/src/main/java/com/jerboa/ui/components/home/Home.kt b/app/src/main/java/com/jerboa/ui/components/home/Home.kt index 3e0a522c0..56a4985db 100644 --- a/app/src/main/java/com/jerboa/ui/components/home/Home.kt +++ b/app/src/main/java/com/jerboa/ui/components/home/Home.kt @@ -117,6 +117,7 @@ fun Drawer( myPerson = myUserInfo?.local_user_view?.person, showAccountAddMode = showAccountAddMode, onClickShowAccountAddMode = { showAccountAddMode = !showAccountAddMode }, + showAvatar = myUserInfo?.local_user_view?.local_user?.show_avatars ?: true, ) Divider() // Drawer items @@ -352,6 +353,7 @@ fun DrawerHeader( myPerson: PersonSafe?, onClickShowAccountAddMode: () -> Unit, showAccountAddMode: Boolean = false, + showAvatar: Boolean, ) { val sizeMod = Modifier .fillMaxWidth() @@ -373,7 +375,7 @@ fun DrawerHeader( modifier = sizeMod .padding(XL_PADDING), ) { - AvatarAndAccountName(myPerson) + AvatarAndAccountName(myPerson, showAvatar) Icon( imageVector = if (showAccountAddMode) { Icons.Outlined.ExpandLess @@ -387,13 +389,15 @@ fun DrawerHeader( } @Composable -fun AvatarAndAccountName(myPerson: PersonSafe?) { +fun AvatarAndAccountName(myPerson: PersonSafe?, showAvatar: Boolean) { Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(SMALL_PADDING), ) { myPerson?.avatar?.also { - LargerCircularIcon(icon = it) + if(showAvatar) { + LargerCircularIcon(icon = it) + } } PersonName( person = myPerson, @@ -408,6 +412,7 @@ fun DrawerHeaderPreview() { DrawerHeader( myPerson = samplePersonSafe, onClickShowAccountAddMode = {}, + showAvatar = true, ) } 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 9e67417fc..a0904e90c 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 @@ -277,6 +277,7 @@ fun MainPostListingsContent( account = account, showVotingArrowsInListView = showVotingArrowsInListView, enableDownVotes = siteViewModel.siteRes?.site_view?.local_site?.enable_downvotes ?: true, + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) } 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 e725384be..01ee0510f 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 @@ -30,6 +30,7 @@ import com.jerboa.ui.components.common.BottomAppBarAll import com.jerboa.ui.components.common.getCurrentAccount import com.jerboa.ui.components.common.simpleVerticalScrollbar import com.jerboa.ui.components.home.HomeViewModel +import com.jerboa.ui.components.home.SiteViewModel import com.jerboa.ui.components.privatemessage.PrivateMessage import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch @@ -43,6 +44,7 @@ fun InboxActivity( homeViewModel: HomeViewModel, accountViewModel: AccountViewModel, commentReplyViewModel: CommentReplyViewModel, + siteViewModel: SiteViewModel, ) { Log.d("jerboa", "got to inbox activity") @@ -105,6 +107,7 @@ fun InboxActivity( ctx = ctx, account = account, scope = scope, + siteViewModel = siteViewModel, ) }, bottomBar = { @@ -154,6 +157,7 @@ fun InboxTabs( scope: CoroutineScope, commentReplyViewModel: CommentReplyViewModel, padding: PaddingValues, + siteViewModel: SiteViewModel, ) { val tabTitles = InboxTab.values().map { it.toString() } val pagerState = rememberPagerState() @@ -324,6 +328,7 @@ fun InboxTabs( navController.navigate(route = "post/$postId") }, account = account, + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) } } @@ -462,6 +467,7 @@ fun InboxTabs( navController.navigate(route = "post/$postId") }, account = account, + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) } } @@ -537,6 +543,7 @@ fun InboxTabs( navController.navigate(route = "profile/$personId") }, account = acct, + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) } } 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 01e145e92..d7d6da35f 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 @@ -53,6 +53,7 @@ import com.jerboa.ui.theme.muted fun PersonProfileTopSection( personView: PersonViewSafe, modifier: Modifier = Modifier, + showAvatar: Boolean, ) { var showImage by remember { mutableStateOf(null) } @@ -80,12 +81,14 @@ fun PersonProfileTopSection( } Box(modifier = Modifier.padding(MEDIUM_PADDING)) { personView.person.avatar?.also { - LargerCircularIcon( - icon = it, - modifier = Modifier.clickable { - showImage = personView.person.avatar - }, - ) + if(showAvatar) { + LargerCircularIcon( + icon = it, + modifier = Modifier.clickable { + showImage = personView.person.avatar + }, + ) + } } } } @@ -139,7 +142,10 @@ fun CommentsAndPostsPreview() { @Preview @Composable fun PersonProfileTopSectionPreview() { - PersonProfileTopSection(personView = samplePersonView) + PersonProfileTopSection( + personView = samplePersonView, + showAvatar = true, + ) } @Composable 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 15e08cf26..8945d1fd3 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 @@ -147,6 +147,7 @@ fun PersonProfileActivity( appSettingsViewModel = appSettingsViewModel, showVotingArrowsInListView = showVotingArrowsInListView, enableDownVotes = siteViewModel.siteRes?.site_view?.local_site?.enable_downvotes ?: true, + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) }, bottomBar = { @@ -202,6 +203,7 @@ fun UserTabs( appSettingsViewModel: AppSettingsViewModel, showVotingArrowsInListView: Boolean, enableDownVotes: Boolean, + showAvatar: Boolean, ) { val tabTitles = if (savedMode) { listOf(UserTab.Posts.name, UserTab.Comments.name) @@ -265,6 +267,7 @@ fun UserTabs( personProfileViewModel.res?.person_view?.also { PersonProfileTopSection( personView = it, + showAvatar = showAvatar, ) } } @@ -404,6 +407,7 @@ fun UserTabs( postViewMode = getPostViewMode(appSettingsViewModel), showVotingArrowsInListView = showVotingArrowsInListView, enableDownVotes = enableDownVotes, + showAvatar = showAvatar, ) } UserTab.Comments.ordinal -> { @@ -541,6 +545,7 @@ fun UserTabs( isCollapsedByParent = false, showActionBarByDefault = appSettingsViewModel.appSettings.value?.showCommentActionBarByDefault ?: true, enableDownVotes = enableDownVotes, + showAvatar = showAvatar, ) } } 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 9f3c46887..741ffac7d 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 @@ -61,14 +61,17 @@ fun PersonProfileLink( isModerator: Boolean = false, isCommunityBanned: Boolean = false, color: Color = MaterialTheme.colorScheme.tertiary, + showAvatar: Boolean, ) { Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(SMALL_PADDING), modifier = Modifier.clickable { onClick(person.id) }, ) { - person.avatar?.also { - CircularIcon(icon = it) + if(showAvatar) { + person.avatar?.also { + CircularIcon(icon = it) + } } if (showTags) { if (isModerator) { @@ -107,6 +110,7 @@ fun PersonProfileLinkPreview() { PersonProfileLink( person = samplePersonSafe, onClick = {}, + showAvatar = true, ) } @@ -120,5 +124,6 @@ fun PersonProfileLinkPreviewTags() { isModerator = true, showTags = true, onClick = {}, + showAvatar = true, ) } 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 3f9694d89..da49c82cc 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 @@ -213,6 +213,7 @@ fun PostActivity( postViewMode = PostViewMode.Card, showVotingArrowsInListView = showVotingArrowsInListView, enableDownVotes = enableDownVotes, + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) } item(key = "${postView.post.id}_is_comment_view") { @@ -336,6 +337,7 @@ fun PostActivity( showActionBarByDefault xor commentsWithToggledActionBar.contains(commentId) }, enableDownVotes = enableDownVotes, + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) } } 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 08caced0d..eb12028a0 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 @@ -116,6 +116,7 @@ fun PostHeaderLine( isModerator: Boolean, modifier: Modifier = Modifier, showCommunityName: Boolean = true, + showAvatar: Boolean, ) { val community = postView.community Column(modifier = modifier) { @@ -156,6 +157,7 @@ fun PostHeaderLine( isModerator = isModerator, isCommunityBanned = postView.creator_banned_from_community, color = MaterialTheme.colorScheme.onSurface.muted, + showAvatar = showAvatar, ) if (postView.post.featured_local) { DotSpacer(0.dp) @@ -218,6 +220,7 @@ fun PostHeaderLinePreview() { isModerator = false, onCommunityClick = {}, onPersonClick = {}, + showAvatar = true, ) } @@ -242,6 +245,7 @@ fun PostNodeHeader( isCommunityBanned = postView.creator_banned_from_community, onClick = {}, onLongCLick = {}, + showAvatar = true, ) } @@ -662,6 +666,7 @@ fun PreviewPostListingCard() { postViewMode = PostViewMode.Card, showVotingArrowsInListView = true, enableDownVotes = true, + showAvatar = true, ) } @@ -689,6 +694,7 @@ fun PreviewLinkPostListing() { postViewMode = PostViewMode.Card, showVotingArrowsInListView = true, enableDownVotes = true, + showAvatar = true, ) } @@ -716,6 +722,7 @@ fun PreviewImagePostListingCard() { postViewMode = PostViewMode.Card, showVotingArrowsInListView = true, enableDownVotes = true, + showAvatar = true, ) } @@ -743,6 +750,7 @@ fun PreviewImagePostListingSmallCard() { postViewMode = PostViewMode.SmallCard, showVotingArrowsInListView = true, enableDownVotes = true, + showAvatar = true, ) } @@ -770,6 +778,7 @@ fun PreviewLinkNoThumbnailPostListing() { postViewMode = PostViewMode.Card, showVotingArrowsInListView = true, enableDownVotes = true, + showAvatar = true, ) } @@ -797,6 +806,7 @@ fun PostListing( postViewMode: PostViewMode, showVotingArrowsInListView: Boolean, enableDownVotes: Boolean, + showAvatar: Boolean, ) { // This stores vote data val instantScores = remember { @@ -846,6 +856,7 @@ fun PostListing( account = account, expandedImage = true, enableDownVotes = enableDownVotes, + showAvatar = showAvatar, ) PostViewMode.SmallCard -> PostListingCard( postView = postView, @@ -882,6 +893,7 @@ fun PostListing( fullBody = false, expandedImage = false, enableDownVotes = enableDownVotes, + showAvatar = showAvatar, ) PostViewMode.List -> PostListingList( postView = postView, @@ -908,6 +920,7 @@ fun PostListing( showCommunityName = showCommunityName, account = account, showVotingArrowsInListView = showVotingArrowsInListView, + showAvatar = showAvatar, ) } } @@ -972,6 +985,7 @@ fun PostListingList( showCommunityName: Boolean = true, account: Account?, showVotingArrowsInListView: Boolean, + showAvatar: Boolean, ) { Column( modifier = Modifier.padding( @@ -1020,6 +1034,7 @@ fun PostListingList( isModerator = isModerator, onClick = onPersonClick, color = MaterialTheme.colorScheme.onSurface.muted, + showAvatar = showAvatar, ) DotSpacer(0.dp) postView.post.url?.also { postUrl -> @@ -1129,6 +1144,7 @@ fun PostListingListPreview() { isModerator = false, account = null, showVotingArrowsInListView = true, + showAvatar = true, ) } @@ -1155,6 +1171,7 @@ fun PostListingListWithThumbPreview() { isModerator = false, account = null, showVotingArrowsInListView = true, + showAvatar = true, ) } @@ -1182,6 +1199,7 @@ fun PostListingCard( account: Account?, expandedImage: Boolean, enableDownVotes: Boolean, + showAvatar: Boolean, ) { Column( modifier = Modifier @@ -1199,6 +1217,7 @@ fun PostListingCard( isModerator = isModerator, showCommunityName = showCommunityName, modifier = Modifier.padding(horizontal = MEDIUM_PADDING), + showAvatar = showAvatar, ) // Title + metadata 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 5bb28370f..60b1ad15b 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 @@ -57,6 +57,7 @@ fun PostListings( postViewMode: PostViewMode, showVotingArrowsInListView: Boolean, enableDownVotes: Boolean, + showAvatar: Boolean, ) { SwipeRefresh( state = rememberSwipeRefreshState(loading), @@ -105,6 +106,7 @@ fun PostListings( postViewMode = postViewMode, showVotingArrowsInListView = showVotingArrowsInListView, enableDownVotes = enableDownVotes, + showAvatar = showAvatar, ) Divider(modifier = Modifier.padding(bottom = SMALL_PADDING)) } @@ -151,5 +153,6 @@ fun PreviewPostListings() { postViewMode = PostViewMode.Card, showVotingArrowsInListView = true, enableDownVotes = true, + showAvatar = true, ) } diff --git a/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessage.kt b/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessage.kt index a4a36747b..4fe690c8d 100644 --- a/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessage.kt +++ b/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessage.kt @@ -35,6 +35,7 @@ fun PrivateMessageHeader( privateMessageView: PrivateMessageView, onPersonClick: (personId: Int) -> Unit, myPersonId: Int, + showAvatar: Boolean, ) { val otherPerson: PersonSafe val fromOrTo: String @@ -61,6 +62,7 @@ fun PrivateMessageHeader( PersonProfileLink( person = otherPerson, onClick = { onPersonClick(otherPerson.id) }, + showAvatar = showAvatar, ) } @@ -82,6 +84,7 @@ fun PrivateMessageViewPreview() { privateMessageView = samplePrivateMessageView, myPersonId = 23, onPersonClick = {}, + showAvatar = true, ) } @@ -101,6 +104,7 @@ fun PrivateMessage( onPersonClick: (personId: Int) -> Unit, myPersonId: Int, // Required so we know the from / to account: Account?, + showAvatar: Boolean, ) { Column( modifier = Modifier @@ -113,6 +117,7 @@ fun PrivateMessage( privateMessageView = privateMessageView, onPersonClick = onPersonClick, myPersonId = myPersonId, + showAvatar = showAvatar, ) PrivateMessageBody(privateMessageView = privateMessageView) PrivateMessageFooterLine( @@ -182,5 +187,6 @@ fun PrivateMessagePreview() { onPersonClick = {}, onReplyClick = {}, onMarkAsReadClick = {}, + showAvatar = true, ) } diff --git a/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessageReply.kt b/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessageReply.kt index ddaff0fc9..c848e16aa 100644 --- a/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessageReply.kt +++ b/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessageReply.kt @@ -74,12 +74,14 @@ fun PrivateMessageReplyHeader( fun RepliedPrivateMessage( privateMessageView: PrivateMessageView, onPersonClick: (personId: Int) -> Unit, + showAvatar: Boolean, ) { Column(modifier = Modifier.padding(MEDIUM_PADDING)) { PrivateMessageHeader( privateMessageView = privateMessageView, onPersonClick = onPersonClick, myPersonId = privateMessageView.recipient.id, + showAvatar = showAvatar, ) SelectionContainer { Text(text = privateMessageView.private_message.content) @@ -93,6 +95,7 @@ fun RepliedPrivateMessagePreview() { RepliedPrivateMessage( privateMessageView = samplePrivateMessageView, onPersonClick = {}, + showAvatar = true, ) } @@ -104,6 +107,7 @@ fun PrivateMessageReply( onPersonClick: (personId: Int) -> Unit, account: Account?, modifier: Modifier = Modifier, + showAvatar: Boolean, ) { val scrollState = rememberScrollState() @@ -113,6 +117,7 @@ fun PrivateMessageReply( RepliedPrivateMessage( privateMessageView = privateMessageView, onPersonClick = onPersonClick, + showAvatar = showAvatar, ) Divider(modifier = Modifier.padding(vertical = LARGE_PADDING)) MarkdownTextField( diff --git a/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessageReplyActivity.kt b/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessageReplyActivity.kt index 4383435c2..ed235efb6 100644 --- a/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessageReplyActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/privatemessage/PrivateMessageReplyActivity.kt @@ -24,6 +24,7 @@ import androidx.navigation.NavController import com.jerboa.datatypes.api.CreatePrivateMessage import com.jerboa.db.AccountViewModel import com.jerboa.ui.components.common.getCurrentAccount +import com.jerboa.ui.components.home.SiteViewModel import com.jerboa.ui.components.inbox.InboxViewModel @Composable @@ -31,6 +32,7 @@ fun PrivateMessageReplyActivity( inboxViewModel: InboxViewModel, accountViewModel: AccountViewModel, navController: NavController, + siteViewModel: SiteViewModel, ) { Log.d("jerboa", "got to private message reply activity") @@ -84,6 +86,7 @@ fun PrivateMessageReplyActivity( modifier = Modifier .padding(padding) .imePadding(), + showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true, ) } } From 7ed4a901471dabb7d06250fb5209ce97609d6340 Mon Sep 17 00:00:00 2001 From: igarshep Date: Mon, 12 Jun 2023 08:54:37 -0500 Subject: [PATCH 2/4] fix formatting --- app/src/main/java/com/jerboa/ui/components/home/Home.kt | 2 +- .../main/java/com/jerboa/ui/components/person/PersonProfile.kt | 2 +- .../java/com/jerboa/ui/components/person/PersonProfileLink.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/jerboa/ui/components/home/Home.kt b/app/src/main/java/com/jerboa/ui/components/home/Home.kt index 56a4985db..34c3ae35d 100644 --- a/app/src/main/java/com/jerboa/ui/components/home/Home.kt +++ b/app/src/main/java/com/jerboa/ui/components/home/Home.kt @@ -395,7 +395,7 @@ fun AvatarAndAccountName(myPerson: PersonSafe?, showAvatar: Boolean) { horizontalArrangement = Arrangement.spacedBy(SMALL_PADDING), ) { myPerson?.avatar?.also { - if(showAvatar) { + if (showAvatar) { LargerCircularIcon(icon = it) } } 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 d7d6da35f..3e4289f5f 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 @@ -81,7 +81,7 @@ fun PersonProfileTopSection( } Box(modifier = Modifier.padding(MEDIUM_PADDING)) { personView.person.avatar?.also { - if(showAvatar) { + if (showAvatar) { LargerCircularIcon( icon = it, modifier = Modifier.clickable { 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 741ffac7d..19662619a 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 @@ -68,7 +68,7 @@ fun PersonProfileLink( horizontalArrangement = Arrangement.spacedBy(SMALL_PADDING), modifier = Modifier.clickable { onClick(person.id) }, ) { - if(showAvatar) { + if (showAvatar) { person.avatar?.also { CircularIcon(icon = it) } From 266755f144e26de1e06d7cc7c30f955b4fe7d031 Mon Sep 17 00:00:00 2001 From: igarshep Date: Mon, 12 Jun 2023 12:03:58 -0500 Subject: [PATCH 3/4] make showAvatar check consistent --- app/src/main/java/com/jerboa/ui/components/home/Home.kt | 4 ++-- .../java/com/jerboa/ui/components/person/PersonProfile.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/jerboa/ui/components/home/Home.kt b/app/src/main/java/com/jerboa/ui/components/home/Home.kt index 34c3ae35d..ebd0819ab 100644 --- a/app/src/main/java/com/jerboa/ui/components/home/Home.kt +++ b/app/src/main/java/com/jerboa/ui/components/home/Home.kt @@ -394,8 +394,8 @@ fun AvatarAndAccountName(myPerson: PersonSafe?, showAvatar: Boolean) { verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(SMALL_PADDING), ) { - myPerson?.avatar?.also { - if (showAvatar) { + if (showAvatar) { + myPerson?.avatar?.also { LargerCircularIcon(icon = it) } } 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 3e4289f5f..215735996 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 @@ -80,8 +80,8 @@ fun PersonProfileTopSection( ) } Box(modifier = Modifier.padding(MEDIUM_PADDING)) { - personView.person.avatar?.also { - if (showAvatar) { + if (showAvatar) { + personView.person.avatar?.also { LargerCircularIcon( icon = it, modifier = Modifier.clickable { From f2a18b2e400d65fa0a0ce83288c126eaf9adc034 Mon Sep 17 00:00:00 2001 From: igarshep Date: Mon, 12 Jun 2023 23:15:09 -0500 Subject: [PATCH 4/4] fix formatting again --- .../java/com/jerboa/ui/components/person/PersonProfileLink.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 859f178ed..502890608 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 @@ -73,8 +73,8 @@ fun PersonProfileLink( if (showAvatar) { person.avatar?.also { CircularIcon( - icon = it - contentDescription = null, + icon = it, + contentDescription = null, ) } }