Merge branch 'dev' of https://github.com/rebelonion/Dantotsu into dev
This commit is contained in:
commit
612936476d
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.loadImage
|
||||||
import ani.dantotsu.openLinkInBrowser
|
import ani.dantotsu.openLinkInBrowser
|
||||||
import ani.dantotsu.others.ImageViewDialog
|
import ani.dantotsu.others.ImageViewDialog
|
||||||
|
import ani.dantotsu.settings.saving.PrefManager
|
||||||
|
import ani.dantotsu.settings.saving.PrefName
|
||||||
import ani.dantotsu.snackString
|
import ani.dantotsu.snackString
|
||||||
import com.xwray.groupie.GroupieAdapter
|
import com.xwray.groupie.GroupieAdapter
|
||||||
import com.xwray.groupie.Section
|
import com.xwray.groupie.Section
|
||||||
|
@ -39,7 +41,7 @@ class CommentItem(val comment: Comment,
|
||||||
var binding: ItemCommentsBinding? = null
|
var binding: ItemCommentsBinding? = null
|
||||||
val adapter = GroupieAdapter()
|
val adapter = GroupieAdapter()
|
||||||
val repliesSection = Section()
|
val repliesSection = Section()
|
||||||
private var isEditing = false
|
var isEditing = false
|
||||||
private var isReplying = false
|
private var isReplying = false
|
||||||
private var repliesVisible = false
|
private var repliesVisible = false
|
||||||
|
|
||||||
|
@ -98,6 +100,7 @@ class CommentItem(val comment: Comment,
|
||||||
}
|
}
|
||||||
viewBinding.commentReply.setOnClickListener {
|
viewBinding.commentReply.setOnClickListener {
|
||||||
replying(!isReplying)
|
replying(!isReplying)
|
||||||
|
commentsActivity.replyTo(this, comment.username)
|
||||||
commentsActivity.replyCallback(this)
|
commentsActivity.replyCallback(this)
|
||||||
}
|
}
|
||||||
viewBinding.modBadge.visibility = if (comment.isMod == true) View.VISIBLE else View.GONE
|
viewBinding.modBadge.visibility = if (comment.isMod == true) View.VISIBLE else View.GONE
|
||||||
|
@ -178,6 +181,7 @@ class CommentItem(val comment: Comment,
|
||||||
|
|
||||||
fun replying(isReplying: Boolean) {
|
fun replying(isReplying: Boolean) {
|
||||||
binding?.commentReply?.text = if (isReplying) currActivity()!!.getString(R.string.cancel) else "Reply"
|
binding?.commentReply?.text = if (isReplying) currActivity()!!.getString(R.string.cancel) else "Reply"
|
||||||
|
PrefManager.setVal(PrefName.ReplyTo, isReplying)
|
||||||
this.isReplying = isReplying
|
this.isReplying = isReplying
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +189,9 @@ class CommentItem(val comment: Comment,
|
||||||
binding?.commentEdit?.text = if (isEditing) currActivity()!!.getString(R.string.cancel) else currActivity()!!.getString(R.string.edit)
|
binding?.commentEdit?.text = if (isEditing) currActivity()!!.getString(R.string.cancel) else currActivity()!!.getString(R.string.edit)
|
||||||
this.isEditing = isEditing
|
this.isEditing = isEditing
|
||||||
}
|
}
|
||||||
|
fun test(isEditing: Boolean){
|
||||||
|
this.isEditing = isEditing
|
||||||
|
}
|
||||||
private fun setVoteButtons(viewBinding: ItemCommentsBinding) {
|
private fun setVoteButtons(viewBinding: ItemCommentsBinding) {
|
||||||
when (comment.userVoteType) {
|
when (comment.userVoteType) {
|
||||||
1 -> {
|
1 -> {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ani.dantotsu.media.comments
|
package ani.dantotsu.media.comments
|
||||||
|
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
|
@ -85,13 +86,13 @@ class CommentsActivity : AppCompatActivity() {
|
||||||
markwonEditor
|
markwonEditor
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
binding.commentReplyToContainer.visibility = View.GONE //TODO: implement reply
|
|
||||||
|
|
||||||
binding.commentsRefresh.setOnRefreshListener {
|
binding.commentsRefresh.setOnRefreshListener {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
loadAndDisplayComments()
|
loadAndDisplayComments()
|
||||||
binding.commentsRefresh.isRefreshing = false
|
binding.commentsRefresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
binding.commentReplyToContainer.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.commentsList.adapter = adapter
|
binding.commentsList.adapter = adapter
|
||||||
|
@ -315,13 +316,24 @@ class CommentsActivity : AppCompatActivity() {
|
||||||
fun replyCallback(comment: CommentItem) {
|
fun replyCallback(comment: CommentItem) {
|
||||||
if (resetOldState() == InteractionState.REPLY) return
|
if (resetOldState() == InteractionState.REPLY) return
|
||||||
commentWithInteraction = comment
|
commentWithInteraction = comment
|
||||||
|
binding.commentReplyToContainer.visibility = View.VISIBLE
|
||||||
binding.commentInput.requestFocus()
|
binding.commentInput.requestFocus()
|
||||||
binding.commentInput.setSelection(binding.commentInput.text.length)
|
binding.commentInput.setSelection(binding.commentInput.text.length)
|
||||||
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
imm.showSoftInput(binding.commentInput, InputMethodManager.SHOW_IMPLICIT)
|
imm.showSoftInput(binding.commentInput, InputMethodManager.SHOW_IMPLICIT)
|
||||||
interactionState = InteractionState.REPLY
|
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) {
|
fun viewReplyCallback(comment: CommentItem) {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val replies = withContext(Dispatchers.IO) {
|
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>())),
|
TagsListNonAdult(Pref(Location.Irrelevant, Set::class, setOf<String>())),
|
||||||
MakeDefault(Pref(Location.Irrelevant, Boolean::class, true)),
|
MakeDefault(Pref(Location.Irrelevant, Boolean::class, true)),
|
||||||
FirstComment(Pref(Location.Irrelevant, Boolean::class, true)),
|
FirstComment(Pref(Location.Irrelevant, Boolean::class, true)),
|
||||||
|
ReplyTo(Pref(Location.Irrelevant, Boolean::class, false)),
|
||||||
|
|
||||||
//Protected
|
//Protected
|
||||||
DiscordToken(Pref(Location.Protected, String::class, "")),
|
DiscordToken(Pref(Location.Protected, String::class, "")),
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone"
|
||||||
tools:ignore="UseCompoundDrawables">
|
tools:ignore="UseCompoundDrawables">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue