From eacd335c3043498c65791f4531a3aa3f0ee20084 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Wed, 25 Oct 2023 16:42:20 +0200 Subject: [PATCH] feat(comments): highlight creator comments --- .../java/com/github/libretube/api/obj/Comment.kt | 3 ++- .../github/libretube/ui/adapters/CommentsAdapter.kt | 6 +++++- .../java/com/github/libretube/util/PlayingQueue.kt | 7 ++++++- .../main/res/drawable/comment_channel_owner_bg.xml | 10 ++++++++++ app/src/main/res/layout/comments_row.xml | 13 ++++++++++++- 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/comment_channel_owner_bg.xml diff --git a/app/src/main/java/com/github/libretube/api/obj/Comment.kt b/app/src/main/java/com/github/libretube/api/obj/Comment.kt index 37a8fad04..60ac52e32 100644 --- a/app/src/main/java/com/github/libretube/api/obj/Comment.kt +++ b/app/src/main/java/com/github/libretube/api/obj/Comment.kt @@ -19,5 +19,6 @@ data class Comment( val thumbnail: String, val verified: Boolean, val replyCount: Long, - val creatorReplied: Boolean = false + val creatorReplied: Boolean = false, + val channelOwner: Boolean = false ) : Parcelable diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index 522d135a3..844738bcc 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -72,7 +72,11 @@ class CommentsAdapter( override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) { val comment = comments[position] holder.binding.apply { - commentInfos.text = comment.author + TextUtils.SEPARATOR + comment.commentedTime + commentAuthor.text = comment.author + if (comment.channelOwner) { + commentAuthor.setBackgroundResource(R.drawable.comment_channel_owner_bg) + } + commentInfos.text = TextUtils.SEPARATOR + comment.commentedTime commentText.movementMethod = LinkMovementMethodCompat.getInstance() commentText.text = comment.commentText?.replace("", " ") diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index 3b39ccaa9..c8758a36d 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -203,7 +203,12 @@ object PlayingQueue { } } - fun updateQueue(streamItem: StreamItem, playlistId: String?, channelId: String?, relatedStreams: List = emptyList()) { + fun updateQueue( + streamItem: StreamItem, + playlistId: String?, + channelId: String?, + relatedStreams: List = emptyList() + ) { if (playlistId != null) { insertPlaylist(playlistId, streamItem) } else if (channelId != null) { diff --git a/app/src/main/res/drawable/comment_channel_owner_bg.xml b/app/src/main/res/drawable/comment_channel_owner_bg.xml new file mode 100644 index 000000000..d2f581fd2 --- /dev/null +++ b/app/src/main/res/drawable/comment_channel_owner_bg.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/comments_row.xml b/app/src/main/res/layout/comments_row.xml index b7eef22e4..0b9f1442a 100644 --- a/app/src/main/res/layout/comments_row.xml +++ b/app/src/main/res/layout/comments_row.xml @@ -36,6 +36,17 @@ android:gravity="center_vertical" android:orientation="horizontal"> + + + tools:text="• 10h" />