feat(comments): "reply to" above text input
This commit is contained in:
parent
70c87b4067
commit
8ea6bf85b8
4 changed files with 24 additions and 4 deletions
|
@ -13,6 +13,8 @@ import ani.dantotsu.databinding.ItemCommentsBinding
|
|||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.openLinkInBrowser
|
||||
import ani.dantotsu.others.ImageViewDialog
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.snackString
|
||||
import com.xwray.groupie.GroupieAdapter
|
||||
import com.xwray.groupie.Section
|
||||
|
@ -37,7 +39,7 @@ class CommentItem(val comment: Comment,
|
|||
var binding: ItemCommentsBinding? = null
|
||||
val adapter = GroupieAdapter()
|
||||
val repliesSection = Section()
|
||||
private var isEditing = false
|
||||
var isEditing = false
|
||||
private var isReplying = false
|
||||
private var repliesVisible = false
|
||||
|
||||
|
@ -96,6 +98,7 @@ class CommentItem(val comment: Comment,
|
|||
}
|
||||
viewBinding.commentReply.setOnClickListener {
|
||||
replying(!isReplying)
|
||||
commentsActivity.replyTo(this, comment.username)
|
||||
commentsActivity.replyCallback(this)
|
||||
}
|
||||
viewBinding.modBadge.visibility = if (comment.isMod == true) View.VISIBLE else View.GONE
|
||||
|
@ -176,6 +179,7 @@ class CommentItem(val comment: Comment,
|
|||
|
||||
fun replying(isReplying: Boolean) {
|
||||
binding?.commentReply?.text = if (isReplying) currActivity()!!.getString(R.string.cancel) else "Reply"
|
||||
PrefManager.setVal(PrefName.ReplyTo, isReplying)
|
||||
this.isReplying = isReplying
|
||||
}
|
||||
|
||||
|
@ -183,7 +187,9 @@ class CommentItem(val comment: Comment,
|
|||
binding?.commentEdit?.text = if (isEditing) currActivity()!!.getString(R.string.cancel) else currActivity()!!.getString(R.string.edit)
|
||||
this.isEditing = isEditing
|
||||
}
|
||||
|
||||
fun test(isEditing: Boolean){
|
||||
this.isEditing = isEditing
|
||||
}
|
||||
private fun setVoteButtons(viewBinding: ItemCommentsBinding) {
|
||||
when (comment.userVoteType) {
|
||||
1 -> {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ani.dantotsu.media.comments
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.text.TextWatcher
|
||||
|
@ -82,13 +83,13 @@ class CommentsActivity : AppCompatActivity() {
|
|||
markwonEditor
|
||||
)
|
||||
)
|
||||
binding.commentReplyToContainer.visibility = View.GONE //TODO: implement reply
|
||||
|
||||
binding.commentsRefresh.setOnRefreshListener {
|
||||
lifecycleScope.launch {
|
||||
loadAndDisplayComments()
|
||||
binding.commentsRefresh.isRefreshing = false
|
||||
}
|
||||
binding.commentReplyToContainer.visibility = View.GONE
|
||||
}
|
||||
|
||||
binding.commentsList.adapter = adapter
|
||||
|
@ -291,13 +292,24 @@ class CommentsActivity : AppCompatActivity() {
|
|||
fun replyCallback(comment: CommentItem) {
|
||||
if (resetOldState() == InteractionState.REPLY) return
|
||||
commentWithInteraction = comment
|
||||
binding.commentReplyToContainer.visibility = View.VISIBLE
|
||||
binding.commentInput.requestFocus()
|
||||
binding.commentInput.setSelection(binding.commentInput.text.length)
|
||||
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.showSoftInput(binding.commentInput, InputMethodManager.SHOW_IMPLICIT)
|
||||
interactionState = InteractionState.REPLY
|
||||
}
|
||||
|
||||
}
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun replyTo(comment: CommentItem,Username: String) {
|
||||
binding.commentReplyToContainer.visibility = if (PrefManager.getVal(PrefName.ReplyTo)) View.VISIBLE else View.GONE
|
||||
binding.commentReplyTo.text = "Replying to $Username"
|
||||
binding.commentReplyToCancel.setOnClickListener {
|
||||
comment.replying(false)
|
||||
replyCallback(comment)
|
||||
binding.commentReplyToContainer.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
fun viewReplyCallback(comment: CommentItem) {
|
||||
lifecycleScope.launch {
|
||||
val replies = withContext(Dispatchers.IO) {
|
||||
|
|
|
@ -154,6 +154,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
|||
TagsListNonAdult(Pref(Location.Irrelevant, Set::class, setOf<String>())),
|
||||
MakeDefault(Pref(Location.Irrelevant, Boolean::class, true)),
|
||||
FirstComment(Pref(Location.Irrelevant, Boolean::class, true)),
|
||||
ReplyTo(Pref(Location.Irrelevant, Boolean::class, false)),
|
||||
|
||||
//Protected
|
||||
DiscordToken(Pref(Location.Protected, String::class, "")),
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue