feat: anilist post confirmation

This commit is contained in:
rebelonion 2024-05-16 10:05:31 -05:00
parent a3b1d3db57
commit 2c521b4ac6
3 changed files with 24 additions and 10 deletions

View file

@ -176,7 +176,7 @@ object Anilist {
"variables" to variables
)
val headers = mutableMapOf(
"Content-Type" to "application/json",
"Content-Type" to "application/json; charset=utf-8",
"Accept" to "application/json"
)

View file

@ -11,6 +11,7 @@ import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.databinding.ActivityMarkdownCreatorBinding
import ani.dantotsu.initActivity
import ani.dantotsu.navBarHeight
import ani.dantotsu.openLinkInBrowser
import ani.dantotsu.statusBarHeight
import ani.dantotsu.themes.ThemeManager
import ani.dantotsu.toast
@ -80,16 +81,26 @@ class MarkdownCreatorActivity : AppCompatActivity() {
toast(getString(R.string.cannot_be_empty))
return@setOnClickListener
}
launchIO {
val success = when (type) {
"activity" -> Anilist.mutation.postActivity(text)
//"review" -> Anilist.mutation.postReview(text)
"replyActivity" -> Anilist.mutation.postReply(parentId, text)
else -> "Error: Unknown type"
AlertDialogBuilder(this).apply {
setTitle(R.string.warning)
setMessage(R.string.post_to_anilist_warning)
setPosButton(R.string.i_understand) {
launchIO {
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)
}
onBackPressedDispatcher.onBackPressed()
}
toast(success)
}
onBackPressedDispatcher.onBackPressed()
setNeutralButton(R.string.open_rules) {
openLinkInBrowser("https://anilist.co/forum/thread/14")
}
setNegButton(R.string.cancel)
}.show()
}
binding.editText.requestFocus()

View file

@ -988,4 +988,7 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
<string name="cannot_be_empty">Text cannot be empty</string>
<string name="reply">Reply</string>
<string name="replies">Replies</string>
<string name="open_rules">Open Rules</string>
<string name="i_understand">I understand</string>
<string name="post_to_anilist_warning">By posting to AniList, you agree to the rules and guidelines of AniList</string>
</resources>