Skip to content

Commit

Permalink
feat: private message
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 committed Jun 1, 2024
1 parent 74cab22 commit 6f685a4
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 198 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
android:name=".others.imagesearch.ImageSearchActivity"
android:parentActivityName=".MainActivity" />
<activity
android:name=".util.MarkdownCreatorActivity"
android:name=".util.ActivityMarkdownCreator"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".parsers.ParserTestActivity" />
<activity
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/ani/dantotsu/Functions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ fun savePrefsToDownloads(
}
)
}

@SuppressLint("StringFormatMatches")
fun savePrefs(serialized: String, path: String, title: String, context: Context): File? {
var file = File(path, "$title.ani")
var counter = 1
Expand All @@ -874,6 +874,7 @@ fun savePrefs(serialized: String, path: String, title: String, context: Context)
}
}

@SuppressLint("StringFormatMatches")
fun savePrefs(
serialized: String,
path: String,
Expand Down Expand Up @@ -920,7 +921,7 @@ fun shareImage(title: String, bitmap: Bitmap, context: Context) {
intent.putExtra(Intent.EXTRA_STREAM, contentUri)
context.startActivity(Intent.createChooser(intent, "Share $title"))
}

@SuppressLint("StringFormatMatches")
fun saveImage(image: Bitmap, path: String, imageFileName: String): File? {
val imageFile = File(path, "$imageFileName.png")
return try {
Expand Down Expand Up @@ -1500,7 +1501,6 @@ fun buildMarkwon(
}
return false
}

override fun onLoadFailed(
e: GlideException?,
model: Any?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,41 @@ class AnilistMutations {
)
}

suspend fun postActivity(text: String, edit : Int? = null): String {
suspend fun postActivity(text: String, edit: Int? = null): String {
val encodedText = text.stringSanitizer()
val query = "mutation{SaveTextActivity(${if (edit != null) "id:$edit," else ""} text:$encodedText){siteUrl}}"
val query =
"mutation{SaveTextActivity(${if (edit != null) "id:$edit," else ""} text:$encodedText){siteUrl}}"
val result = executeQuery<JsonObject>(query)
val errors = result?.get("errors")
return errors?.toString()
?: (currContext()?.getString(ani.dantotsu.R.string.success) ?: "Success")
}
suspend fun postMessage(userId: Int, text: String, edit: Int? = null,isPrivate: Boolean = false): String {
val encodedText = text.replace("","").stringSanitizer()
val query = "mutation{SaveMessageActivity(${if (edit != null) "id:$edit," else ""} recipientId:$userId,message:$encodedText,private:$isPrivate){id}}"

suspend fun postMessage(
userId: Int,
text: String,
edit: Int? = null,
isPrivate: Boolean = false
): String {
val encodedText = text.replace("", "").stringSanitizer()
val query =
"mutation{SaveMessageActivity(${if (edit != null) "id:$edit," else ""} recipientId:$userId,message:$encodedText,private:$isPrivate){id}}"
val result = executeQuery<JsonObject>(query)
val errors = result?.get("errors")
return errors?.toString()
?: (currContext()?.getString(ani.dantotsu.R.string.success) ?: "Success")
}
suspend fun postReply(activityId: Int, text: String, edit: Int? = null ): String {

suspend fun postReply(activityId: Int, text: String, edit: Int? = null): String {
val encodedText = text.stringSanitizer()
val query = "mutation{SaveActivityReply(${if (edit != null) "id:$edit," else ""} activityId:$activityId,text:$encodedText){id}}"
val query =
"mutation{SaveActivityReply(${if (edit != null) "id:$edit," else ""} 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")
}

suspend fun postReview(summary: String, body: String, mediaId: Int, score: Int): String {
val encodedSummary = summary.stringSanitizer()
val encodedBody = body.stringSanitizer()
Expand All @@ -143,7 +154,6 @@ class AnilistMutations {
}



private fun String.stringSanitizer(): String {
val sb = StringBuilder()
var i = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import ani.dantotsu.databinding.BottomSheetRecyclerBinding
import ani.dantotsu.profile.ProfileActivity
import ani.dantotsu.profile.activity.ActivityReplyItem
import ani.dantotsu.snackString
import ani.dantotsu.util.MarkdownCreatorActivity
import ani.dantotsu.util.ActivityMarkdownCreator
import com.xwray.groupie.GroupieAdapter
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

Expand Down Expand Up @@ -50,7 +49,7 @@ class RepliesBottomDialog : BottomSheetDialogFragment() {
binding.replyButton.setOnClickListener {
ContextCompat.startActivity(
context,
Intent(context, MarkdownCreatorActivity::class.java)
Intent(context, ActivityMarkdownCreator::class.java)
.putExtra("type", "replyActivity")
.putExtra("parentId", activityId),
null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ani.dantotsu.home.status

import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.ViewGroup
Expand All @@ -16,7 +15,7 @@ import ani.dantotsu.profile.User
import ani.dantotsu.setAnimation
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.snackString
import ani.dantotsu.util.MarkdownCreatorActivity
import ani.dantotsu.util.ActivityMarkdownCreator

class UserStatusAdapter(private val user: ArrayList<User>) :
RecyclerView.Adapter<UserStatusAdapter.UsersViewHolder>() {
Expand All @@ -43,7 +42,7 @@ class UserStatusAdapter(private val user: ArrayList<User>) :
if (user[bindingAdapterPosition].id == Anilist.userid) {
ContextCompat.startActivity(
itemView.context,
Intent(itemView.context, MarkdownCreatorActivity::class.java)
Intent(itemView.context, ActivityMarkdownCreator::class.java)
.putExtra("type", "activity"),
null
)
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/ani/dantotsu/media/ReviewActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ani.dantotsu.media
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.text.SpannableString
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
Expand All @@ -21,7 +20,7 @@ import ani.dantotsu.initActivity
import ani.dantotsu.navBarHeight
import ani.dantotsu.statusBarHeight
import ani.dantotsu.themes.ThemeManager
import ani.dantotsu.util.MarkdownCreatorActivity
import ani.dantotsu.util.ActivityMarkdownCreator
import com.xwray.groupie.GroupieAdapter
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -59,7 +58,7 @@ class ReviewActivity : AppCompatActivity() {
binding.followFilterButton.setOnClickListener {
ContextCompat.startActivity(
this,
Intent(this, MarkdownCreatorActivity::class.java)
Intent(this, ActivityMarkdownCreator::class.java)
.putExtra("type", "review"),
null
)
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import ani.dantotsu.snackString
import ani.dantotsu.statusBarHeight
import ani.dantotsu.themes.ThemeManager
import ani.dantotsu.toast
import ani.dantotsu.util.MarkdownCreatorActivity
import com.google.android.material.appbar.AppBarLayout
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import ani.dantotsu.databinding.FragmentFeedBinding
import ani.dantotsu.media.MediaDetailsActivity
import ani.dantotsu.navBarHeight
import ani.dantotsu.profile.ProfileActivity
import ani.dantotsu.setBaseline
import ani.dantotsu.util.MarkdownCreatorActivity
import ani.dantotsu.util.ActivityMarkdownCreator
import com.xwray.groupie.GroupieAdapter
import eu.kanade.tachiyomi.util.system.getSerializableCompat
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -53,14 +52,14 @@ class ActivityFragment : Fragment() {
if(userId == Anilist.userid) {
ContextCompat.startActivity(
requireContext(),
Intent(context, MarkdownCreatorActivity::class.java)
Intent(context, ActivityMarkdownCreator::class.java)
.putExtra("type", "activity"),
null
)
} else{
ContextCompat.startActivity(
requireContext(),
Intent(context, MarkdownCreatorActivity::class.java)
Intent(context, ActivityMarkdownCreator::class.java)
.putExtra("type", "message")
.putExtra("userId", userId),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.view.View
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.LinearLayoutManager
import ani.dantotsu.R
import ani.dantotsu.blurImage
import ani.dantotsu.buildMarkwon
Expand All @@ -19,7 +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 ani.dantotsu.util.ActivityMarkdownCreator
import com.xwray.groupie.GroupieAdapter
import com.xwray.groupie.viewbinding.BindableItem
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -152,7 +151,7 @@ class ActivityItem(
binding.activityEdit.setOnClickListener {
ContextCompat.startActivity(
context,
Intent(context, MarkdownCreatorActivity::class.java)
Intent(context, ActivityMarkdownCreator::class.java)
.putExtra("type", "activity")
.putExtra("other", activity.text)
.putExtra("edit", activity.id),
Expand Down Expand Up @@ -183,7 +182,7 @@ class ActivityItem(
binding.activityEdit.setOnClickListener {
ContextCompat.startActivity(
context,
Intent(context, MarkdownCreatorActivity::class.java)
Intent(context, ActivityMarkdownCreator::class.java)
.putExtra("type", "message")
.putExtra("other", activity.message)
.putExtra("edit", activity.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ani.dantotsu.profile.User
import ani.dantotsu.profile.UsersDialogFragment
import ani.dantotsu.snackString
import ani.dantotsu.util.AniMarkdown.Companion.getBasicAniHTML
import ani.dantotsu.util.MarkdownCreatorActivity
import ani.dantotsu.util.ActivityMarkdownCreator
import com.xwray.groupie.GroupieAdapter
import com.xwray.groupie.viewbinding.BindableItem
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -81,7 +81,7 @@ class ActivityReplyItem(
binding.activityReply.setOnClickListener {
ContextCompat.startActivity(
context,
Intent(context, MarkdownCreatorActivity::class.java)
Intent(context, ActivityMarkdownCreator::class.java)
.putExtra("type", "replyActivity")
.putExtra("parentId", parentId)
.putExtra("other", "@${reply.user.name} "),
Expand All @@ -92,7 +92,7 @@ class ActivityReplyItem(
binding.activityEdit.setOnClickListener {
ContextCompat.startActivity(
context,
Intent(context, MarkdownCreatorActivity::class.java)
Intent(context, ActivityMarkdownCreator::class.java)
.putExtra("type", "replyActivity")
.putExtra("parentId", parentId)
.putExtra("other", reply.text)
Expand Down
Loading

0 comments on commit 6f685a4

Please sign in to comment.