Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#345 respect avatar settings #554

Merged
merged 5 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/main/java/com/jerboa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ class MainActivity : ComponentActivity() {
accountViewModel = accountViewModel,
homeViewModel = homeViewModel,
commentReplyViewModel = commentReplyViewModel,
siteViewModel = siteViewModel,
)
}
composable(
Expand Down Expand Up @@ -489,6 +490,7 @@ class MainActivity : ComponentActivity() {
accountViewModel = accountViewModel,
personProfileViewModel = personProfileViewModel,
navController = navController,
siteViewModel = siteViewModel,
)
}
composable(
Expand Down Expand Up @@ -538,6 +540,7 @@ class MainActivity : ComponentActivity() {
inboxViewModel = inboxViewModel,
accountViewModel = accountViewModel,
navController = navController,
siteViewModel = siteViewModel,
)
}
composable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ fun CommentNodeHeader(
isExpanded: Boolean,
onClick: () -> Unit,
onLongClick: () -> Unit,
showAvatar: Boolean,
) {
CommentOrPostNodeHeader(
creator = commentView.creator,
Expand All @@ -115,6 +116,7 @@ fun CommentNodeHeader(
isExpanded = isExpanded,
onClick = onClick,
onLongCLick = onLongClick,
showAvatar = showAvatar,
)
}

Expand All @@ -131,6 +133,7 @@ fun CommentNodeHeaderPreview() {
onLongClick = {},
collapsedCommentsCount = 5,
isExpanded = false,
showAvatar = true,
)
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -281,6 +285,7 @@ fun LazyListScope.commentNodeItem(
},
collapsedCommentsCount = node.commentView.counts.child_count,
isExpanded = isExpanded(commentId),
showAvatar = showAvatar,
)
AnimatedVisibility(
visible = isExpanded(commentId) || showCollapsedCommentContent,
Expand Down Expand Up @@ -388,6 +393,7 @@ fun LazyListScope.commentNodeItem(
showCollapsedCommentContent = showCollapsedCommentContent,
showActionBar = showActionBar,
enableDownVotes = enableDownVotes,
showAvatar = showAvatar,
)
}
}
Expand Down Expand Up @@ -639,6 +645,7 @@ fun CommentNodesPreview() {
showCollapsedCommentContent = false,
showActionBarByDefault = true,
enableDownVotes = true,
showAvatar = true,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ fun CommentNodes(
isCollapsedByParent: Boolean,
showActionBarByDefault: Boolean,
enableDownVotes: Boolean,
showAvatar: Boolean,
) {
// Holds the un-expanded comment ids
val unExpandedComments = remember { mutableStateListOf<Int>() }
Expand Down Expand Up @@ -86,6 +87,7 @@ fun CommentNodes(
showActionBarByDefault xor commentsWithToggledActionBar.contains(commentId)
},
enableDownVotes = enableDownVotes,
showAvatar = showAvatar,
)
}
}
Expand Down Expand Up @@ -117,6 +119,7 @@ fun LazyListScope.commentNodeItems(
isCollapsedByParent: Boolean,
showActionBar: (commentId: Int) -> Boolean,
enableDownVotes: Boolean,
showAvatar: Boolean,
) {
nodes.forEach { node ->
commentNodeItem(
Expand Down Expand Up @@ -146,6 +149,7 @@ fun LazyListScope.commentNodeItems(
isCollapsedByParent = isCollapsedByParent,
showActionBar = showActionBar,
enableDownVotes = enableDownVotes,
showAvatar = showAvatar,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fun CommentMentionNodeHeader(
myVote: Int?,
onClick: () -> Unit,
onLongClick: () -> Unit,
showAvatar: Boolean,
) {
CommentOrPostNodeHeader(
creator = personMentionView.creator,
Expand All @@ -75,6 +76,7 @@ fun CommentMentionNodeHeader(
isCommunityBanned = personMentionView.creator_banned_from_community,
onClick = onClick,
onLongCLick = onLongClick,
showAvatar = showAvatar,
)
}

Expand All @@ -88,6 +90,7 @@ fun CommentMentionNodeHeaderPreview() {
onPersonClick = {},
onClick = {},
onLongClick = {},
showAvatar = true,
)
}

Expand Down Expand Up @@ -305,6 +308,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
Expand Down Expand Up @@ -337,6 +341,7 @@ fun CommentMentionNode(
onLongClick = {
isActionBarExpanded = !isActionBarExpanded
},
showAvatar = showAvatar,
)
AnimatedVisibility(
visible = isExpanded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ fun RepliedComment(
commentView: CommentView,
onPersonClick: (personId: Int) -> Unit,
isModerator: Boolean,
showAvatar: Boolean,
) {
Column(modifier = Modifier.padding(MEDIUM_PADDING)) {
CommentNodeHeader(
Expand All @@ -94,6 +95,7 @@ fun RepliedComment(
isExpanded = true,
onClick = {},
onLongClick = {},
showAvatar = showAvatar,
)
SelectionContainer {
Text(text = commentView.comment.content)
Expand All @@ -105,6 +107,7 @@ fun RepliedComment(
fun RepliedCommentReply(
commentReplyView: CommentReplyView,
onPersonClick: (personId: Int) -> Unit,
showAvatar: Boolean,
) {
Column(modifier = Modifier.padding(MEDIUM_PADDING)) {
CommentReplyNodeHeader(
Expand All @@ -114,6 +117,7 @@ fun RepliedCommentReply(
myVote = commentReplyView.my_vote,
onClick = {},
onLongClick = {},
showAvatar = showAvatar,
)
SelectionContainer {
Text(text = commentReplyView.comment.content)
Expand All @@ -125,6 +129,7 @@ fun RepliedCommentReply(
fun RepliedMentionReply(
personMentionView: PersonMentionView,
onPersonClick: (personId: Int) -> Unit,
showAvatar: Boolean,
) {
Column(modifier = Modifier.padding(MEDIUM_PADDING)) {
CommentMentionNodeHeader(
Expand All @@ -134,6 +139,7 @@ fun RepliedMentionReply(
myVote = personMentionView.my_vote,
onClick = {},
onLongClick = {},
showAvatar = showAvatar,
)
SelectionContainer {
Text(text = personMentionView.comment.content)
Expand All @@ -148,6 +154,7 @@ fun RepliedCommentPreview() {
commentView = sampleCommentView,
isModerator = false,
onPersonClick = {},
showAvatar = true,
)
}

Expand Down Expand Up @@ -181,6 +188,7 @@ fun CommentReply(
isModerator: Boolean,
account: Account?,
modifier: Modifier = Modifier,
showAvatar: Boolean,
) {
val scrollState = rememberScrollState()

Expand All @@ -191,6 +199,7 @@ fun CommentReply(
commentView = commentView,
onPersonClick = onPersonClick,
isModerator = isModerator,
showAvatar = showAvatar,
)
Divider(modifier = Modifier.padding(vertical = LARGE_PADDING))
MarkdownTextField(
Expand All @@ -210,6 +219,7 @@ fun CommentReplyReply(
onPersonClick: (personId: Int) -> Unit,
account: Account?,
modifier: Modifier = Modifier,
showAvatar: Boolean,
) {
val scrollState = rememberScrollState()

Expand All @@ -219,6 +229,7 @@ fun CommentReplyReply(
RepliedCommentReply(
commentReplyView = commentReplyView,
onPersonClick = onPersonClick,
showAvatar = showAvatar,
)
Divider(modifier = Modifier.padding(vertical = LARGE_PADDING))
MarkdownTextField(
Expand All @@ -238,6 +249,7 @@ fun MentionReply(
onPersonClick: (personId: Int) -> Unit,
account: Account?,
modifier: Modifier = Modifier,
showAvatar: Boolean,
) {
val scrollState = rememberScrollState()

Expand All @@ -247,6 +259,7 @@ fun MentionReply(
RepliedMentionReply(
personMentionView = personMentionView,
onPersonClick = onPersonClick,
showAvatar = showAvatar,
)
Divider(modifier = Modifier.padding(vertical = LARGE_PADDING))
MarkdownTextField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -31,6 +32,7 @@ fun CommentReplyActivity(
personProfileViewModel: PersonProfileViewModel,
postViewModel: PostViewModel,
navController: NavController,
siteViewModel: SiteViewModel,
) {
Log.d("jerboa", "got to comment reply activity")

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -131,6 +135,7 @@ fun CommentReplyActivity(
modifier = Modifier
.padding(padding)
.imePadding(),
showAvatar = siteViewModel.siteRes?.my_user?.local_user_view?.local_user?.show_avatars ?: true,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fun CommentReplyNodeHeader(
myVote: Int?,
onClick: () -> Unit,
onLongClick: () -> Unit,
showAvatar: Boolean,
) {
CommentOrPostNodeHeader(
creator = commentReplyView.creator,
Expand All @@ -75,6 +76,7 @@ fun CommentReplyNodeHeader(
isCommunityBanned = commentReplyView.creator_banned_from_community,
onClick = onClick,
onLongCLick = onLongClick,
showAvatar = showAvatar,
)
}

Expand All @@ -88,6 +90,7 @@ fun CommentReplyNodeHeaderPreview() {
onPersonClick = {},
onClick = {},
onLongClick = {},
showAvatar = true,
)
}

Expand Down Expand Up @@ -303,6 +306,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
Expand Down Expand Up @@ -335,6 +339,7 @@ fun CommentReplyNode(
onLongClick = {
isActionBarExpanded = !isActionBarExpanded
},
showAvatar = showAvatar,
)
AnimatedVisibility(
visible = isExpanded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ fun CommentOrPostNodeHeader(
onLongCLick: () -> Unit,
isExpanded: Boolean = true,
collapsedCommentsCount: Int = 0,
showAvatar: Boolean,
) {
FlowRow(
mainAxisAlignment = FlowMainAxisAlignment.SpaceBetween,
Expand Down Expand Up @@ -279,6 +280,7 @@ fun CommentOrPostNodeHeader(
isPostCreator = isPostCreator,
isModerator = isModerator,
isCommunityBanned = isCommunityBanned,
showAvatar = showAvatar,
)
}
ScoreAndTime(
Expand Down Expand Up @@ -308,6 +310,7 @@ fun CommentOrPostNodeHeaderPreview() {
isCommunityBanned = false,
onClick = {},
onLongCLick = {},
showAvatar = true,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,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,
Expand Down
Loading