feat: replying to activities
This commit is contained in:
parent
6e3a3bb6f8
commit
d355cc561e
5 changed files with 63 additions and 1 deletions
|
@ -98,4 +98,13 @@ class AnilistMutations {
|
|||
return errors?.toString()
|
||||
?: (currContext()?.getString(ani.dantotsu.R.string.success) ?: "Success")
|
||||
}
|
||||
|
||||
suspend fun postReply(activityId: Int, text: String): String {
|
||||
val encodedText = Gson().toJson(text)
|
||||
val query = "mutation{SaveActivityReply(activityId:$activityId,text:$encodedText){id}}"
|
||||
val result = executeQuery<JsonObject>(query)
|
||||
val errors = result?.get("errors")
|
||||
return errors?.toString()
|
||||
?: (currContext()?.getString(ani.dantotsu.R.string.success) ?: "Success")
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package ani.dantotsu.profile.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
|
@ -17,6 +18,7 @@ import ani.dantotsu.profile.UsersDialogFragment
|
|||
import ani.dantotsu.setAnimation
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.util.AniMarkdown.Companion.getBasicAniHTML
|
||||
import ani.dantotsu.util.MarkdownCreatorActivity
|
||||
import com.xwray.groupie.GroupieAdapter
|
||||
import com.xwray.groupie.viewbinding.BindableItem
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -67,6 +69,21 @@ class ActivityItem(
|
|||
repliesAdapter.addAll(replyItems)
|
||||
binding.activityReplies.visibility = View.VISIBLE
|
||||
binding.commentTotalReplies.setText(R.string.hide_replies)
|
||||
if (activity.isLocked != true) {
|
||||
binding.commentReply.setOnClickListener {
|
||||
val context = binding.root.context
|
||||
ContextCompat.startActivity(
|
||||
context,
|
||||
Intent(context, MarkdownCreatorActivity::class.java)
|
||||
.putExtra("type", "replyActivity")
|
||||
.putExtra("parentId", activity.id),
|
||||
null
|
||||
)
|
||||
}
|
||||
} else {
|
||||
binding.commentReply.visibility = View.GONE
|
||||
binding.dot.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
|
|
@ -18,12 +18,12 @@ import io.noties.markwon.editor.MarkwonEditor
|
|||
import io.noties.markwon.editor.MarkwonEditorTextWatcher
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import tachiyomi.core.util.lang.launchIO
|
||||
import java.util.Locale
|
||||
|
||||
class MarkdownCreatorActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityMarkdownCreatorBinding
|
||||
private lateinit var type: String
|
||||
private var text: String = ""
|
||||
private var parentId: Int = 0
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -40,11 +40,22 @@ class MarkdownCreatorActivity : AppCompatActivity() {
|
|||
if (intent.hasExtra("type")) {
|
||||
type = intent.getStringExtra("type")!!
|
||||
} else {
|
||||
toast("Error: No type")
|
||||
finish()
|
||||
return
|
||||
}
|
||||
binding.markdownCreatorTitle.text = when (type) {
|
||||
"activity" -> getString(R.string.create_new_activity)
|
||||
"review" -> getString(R.string.create_new_review)
|
||||
"replyActivity" -> {
|
||||
parentId = intent.getIntExtra("parentId", -1)
|
||||
if (parentId == -1) {
|
||||
toast("Error: No parent ID")
|
||||
finish()
|
||||
return
|
||||
}
|
||||
getString(R.string.create_new_reply)
|
||||
}
|
||||
else -> ""
|
||||
}
|
||||
binding.editText.setText(text)
|
||||
|
@ -73,6 +84,7 @@ class MarkdownCreatorActivity : AppCompatActivity() {
|
|||
val success = when (type) {
|
||||
"activity" -> Anilist.mutation.postActivity(text)
|
||||
//"review" -> Anilist.mutation.postReview(text)
|
||||
"replyActivity" -> Anilist.mutation.postReply(parentId, text)
|
||||
else -> "Error: Unknown type"
|
||||
}
|
||||
toast(success)
|
||||
|
|
|
@ -229,6 +229,28 @@
|
|||
android:text="View replies"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dot"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:alpha="0.8"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="•"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/commentReply"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:alpha="0.8"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="@string/reply"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
|
|
@ -982,7 +982,9 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
|||
<string name="vote_out_of_total">(%1$s out of %2$s liked this review)</string>
|
||||
<string name="create_new_activity">Create New Activity</string>
|
||||
<string name="create_new_review">Create New Review</string>
|
||||
<string name="create_new_reply">Create New Reply</string>
|
||||
<string name="create">Create</string>
|
||||
<string name="preview">Preview</string>
|
||||
<string name="cannot_be_empty">Text cannot be empty</string>
|
||||
<string name="reply">Reply</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue