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

feat(comments): add toast messages to badges #296

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ data class Comment(
val username: String,
@SerialName("profile_picture_url")
val profilePictureUrl: String?,
@SerialName("is_dev")
@Serializable(with = NumericBooleanSerializer::class)
val isDev: Boolean? = null,
@SerialName("is_mod")
@Serializable(with = NumericBooleanSerializer::class)
val isMod: Boolean? = null,
Expand Down
21 changes: 19 additions & 2 deletions app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.view.View
import android.widget.Toast
import android.widget.PopupMenu
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -138,8 +139,24 @@ class CommentItem(
commentsFragment.replyTo(this, comment.username)
commentsFragment.replyCallback(this)
}
viewBinding.modBadge.visibility = if (comment.isMod == true) View.VISIBLE else View.GONE
viewBinding.adminBadge.visibility = if (comment.isAdmin == true) View.VISIBLE else View.GONE
viewBinding.devBadge.apply {
visibility = if (comment.isDev == true) View.VISIBLE else View.GONE
setOnClickListener {
Toast.makeText(context, "App Developer", Toast.LENGTH_SHORT).show()
}
}
viewBinding.modBadge.apply {
visibility = if (comment.isMod == true) View.VISIBLE else View.GONE
setOnClickListener {
Toast.makeText(context, "Comment Moderator", Toast.LENGTH_SHORT).show()
}
}
viewBinding.adminBadge.apply {
visibility = if (comment.isAdmin == true) View.VISIBLE else View.GONE
setOnClickListener {
Toast.makeText(context, "Owner", Toast.LENGTH_SHORT).show()
}
}
viewBinding.commentInfo.setOnClickListener {
val popup = PopupMenu(commentsFragment.requireContext(), viewBinding.commentInfo)
popup.menuInflater.inflate(R.menu.profile_details_menu, popup.menu)
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_dev.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#00C2FD"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#000000"
android:pathData="M754,879q-8,0 -15,-2.5T726,868L522,664q-6,-6 -8.5,-13t-2.5,-15q0,-8 2.5,-15t8.5,-13l85,-85q6,-6 13,-8.5t15,-2.5q8,0 15,2.5t13,8.5l204,204q6,6 8.5,13t2.5,15q0,8 -2.5,15t-8.5,13l-85,85q-6,6 -13,8.5T754,879ZM754,784 L783,755 636,608 607,637 754,784ZM205,880q-8,0 -15.5,-3T176,868l-84,-84q-6,-6 -9,-13.5T80,755q0,-8 3,-15t9,-13l212,-212h85l34,-34 -165,-165h-57L80,195l113,-113 121,121v57l165,165 116,-116 -43,-43 56,-56L495,210l-28,-28 142,-142 28,28v113l56,-56 142,142q17,17 26,38.5t9,45.5q0,24 -9,46t-26,39l-85,-85 -56,56 -42,-42 -207,207v84L233,868q-6,6 -13,9t-15,3ZM205,784 L375,614v-29h-29L176,755l29,29ZM205,784 L176,755 191,769 205,784ZM754,784 L783,755 754,784Z"/>
</vector>
14 changes: 12 additions & 2 deletions app/src/main/res/layout/item_comments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginEnd="6dp"
android:layout_weight="0"
android:scaleX="0.9"
android:scaleY="0.9"
Expand All @@ -148,13 +147,24 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginEnd="6dp"
android:layout_weight="0"
android:scaleX="0.8"
android:scaleY="0.8"
android:src="@drawable/ic_shield"
android:visibility="visible"
tools:ignore="ContentDescription,RtlSymmetry" />

<ImageView
android:id="@+id/devBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_weight="0"
android:scaleX="0.75"
android:scaleY="0.75"
android:src="@drawable/ic_dev"
android:visibility="visible"
tools:ignore="ContentDescription,RtlSymmetry" />
</LinearLayout>

<TextView
Expand Down