feat : qol things
This commit is contained in:
parent
039e3d63fe
commit
48ccb2c581
9 changed files with 98 additions and 110 deletions
|
@ -84,6 +84,7 @@ import androidx.core.view.updateLayoutParams
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
@ -96,6 +97,7 @@ import ani.dantotsu.connections.crashlytics.CrashlyticsInterface
|
||||||
import ani.dantotsu.databinding.ItemCountDownBinding
|
import ani.dantotsu.databinding.ItemCountDownBinding
|
||||||
import ani.dantotsu.media.Media
|
import ani.dantotsu.media.Media
|
||||||
import ani.dantotsu.notifications.IncognitoNotificationClickReceiver
|
import ani.dantotsu.notifications.IncognitoNotificationClickReceiver
|
||||||
|
import ani.dantotsu.others.ImageViewDialog
|
||||||
import ani.dantotsu.others.SpoilerPlugin
|
import ani.dantotsu.others.SpoilerPlugin
|
||||||
import ani.dantotsu.parsers.ShowResponse
|
import ani.dantotsu.parsers.ShowResponse
|
||||||
import ani.dantotsu.settings.saving.PrefManager
|
import ani.dantotsu.settings.saving.PrefManager
|
||||||
|
@ -1392,6 +1394,13 @@ fun Context.getThemeColor(@AttrRes attribute: Int): Int {
|
||||||
theme.resolveAttribute(attribute, typedValue, true)
|
theme.resolveAttribute(attribute, typedValue, true)
|
||||||
return typedValue.data
|
return typedValue.data
|
||||||
}
|
}
|
||||||
|
fun ImageView.openImage(title: String, image: String) {
|
||||||
|
setOnLongClickListener{
|
||||||
|
ImageViewDialog.newInstance(
|
||||||
|
context as FragmentActivity, title, image
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Builds the markwon instance with all the plugins
|
* Builds the markwon instance with all the plugins
|
||||||
* @return the markwon instance
|
* @return the markwon instance
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
package ani.dantotsu.connections.github
|
|
||||||
|
|
||||||
import ani.dantotsu.settings.Developer
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import kotlinx.serialization.SerialName
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
class Forks {
|
|
||||||
|
|
||||||
fun getForks(): Array<Developer> {
|
|
||||||
var forks = arrayOf<Developer>()
|
|
||||||
runBlocking(Dispatchers.IO) {
|
|
||||||
val trustedForks = arrayOf(
|
|
||||||
GithubResponse(
|
|
||||||
"Awery",
|
|
||||||
GithubResponse.Owner(
|
|
||||||
"MrBoomDeveloper",
|
|
||||||
"https://avatars.githubusercontent.com/u/92123190?v=4"
|
|
||||||
),
|
|
||||||
"https://github.com/MrBoomDeveloper/Awery"
|
|
||||||
),
|
|
||||||
)
|
|
||||||
trustedForks.forEach {
|
|
||||||
forks = forks.plus(
|
|
||||||
Developer(
|
|
||||||
it.name,
|
|
||||||
it.owner.avatarUrl,
|
|
||||||
it.owner.login,
|
|
||||||
it.htmlUrl
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return forks
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class GithubResponse(
|
|
||||||
@SerialName("name")
|
|
||||||
val name: String,
|
|
||||||
val owner: Owner,
|
|
||||||
@SerialName("html_url")
|
|
||||||
val htmlUrl: String,
|
|
||||||
) {
|
|
||||||
@Serializable
|
|
||||||
data class Owner(
|
|
||||||
@SerialName("login")
|
|
||||||
val login: String,
|
|
||||||
@SerialName("avatar_url")
|
|
||||||
val avatarUrl: String
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -528,26 +528,11 @@ class MediaInfoFragment : Fragment() {
|
||||||
parent,
|
parent,
|
||||||
false
|
false
|
||||||
).apply {
|
).apply {
|
||||||
fun onUserClick(userId: Int) {
|
|
||||||
val review = media.review!!.find { i -> i.id == userId }
|
|
||||||
if (review != null) {
|
|
||||||
startActivity(
|
|
||||||
Intent(requireContext(), ReviewViewActivity::class.java)
|
|
||||||
.putExtra("review", review)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val adapter = GroupieAdapter()
|
val adapter = GroupieAdapter()
|
||||||
media.review!!.forEach {
|
media.review!!.forEach { adapter.add(ReviewAdapter(it)) }
|
||||||
adapter.add(ReviewAdapter(it, ::onUserClick))
|
|
||||||
}
|
|
||||||
itemTitle.setText(R.string.reviews)
|
itemTitle.setText(R.string.reviews)
|
||||||
itemRecycler.adapter = adapter
|
itemRecycler.adapter = adapter
|
||||||
itemRecycler.layoutManager = LinearLayoutManager(
|
itemRecycler.layoutManager = LinearLayoutManager(requireContext())
|
||||||
requireContext(),
|
|
||||||
LinearLayoutManager.VERTICAL,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
itemMore.visibility = View.VISIBLE
|
itemMore.visibility = View.VISIBLE
|
||||||
itemMore.setSafeOnClickListener {
|
itemMore.setSafeOnClickListener {
|
||||||
startActivity(
|
startActivity(
|
||||||
|
|
|
@ -122,19 +122,7 @@ class ReviewActivity : AppCompatActivity() {
|
||||||
private fun fillList() {
|
private fun fillList() {
|
||||||
adapter.clear()
|
adapter.clear()
|
||||||
reviews.forEach {
|
reviews.forEach {
|
||||||
adapter.add(
|
adapter.add(ReviewAdapter(it))
|
||||||
ReviewAdapter(
|
|
||||||
it,
|
|
||||||
this::onUserClick
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onUserClick(userId: Int) {
|
|
||||||
val review = reviews.find { it.id == userId }
|
|
||||||
if (review != null) {
|
|
||||||
startActivity(Intent(this, ReviewViewActivity::class.java).putExtra("review", review))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,24 @@
|
||||||
package ani.dantotsu.media
|
package ani.dantotsu.media
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Intent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.core.app.ActivityOptionsCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.util.Pair
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import ani.dantotsu.R
|
import ani.dantotsu.R
|
||||||
import ani.dantotsu.connections.anilist.Anilist
|
import ani.dantotsu.connections.anilist.Anilist
|
||||||
import ani.dantotsu.connections.anilist.api.Query
|
import ani.dantotsu.connections.anilist.api.Query
|
||||||
import ani.dantotsu.databinding.ItemReviewsBinding
|
import ani.dantotsu.databinding.ItemReviewsBinding
|
||||||
import ani.dantotsu.loadImage
|
import ani.dantotsu.loadImage
|
||||||
|
import ani.dantotsu.openImage
|
||||||
|
import ani.dantotsu.others.ImageViewDialog
|
||||||
|
import ani.dantotsu.profile.ProfileActivity
|
||||||
import ani.dantotsu.profile.activity.ActivityItemBuilder
|
import ani.dantotsu.profile.activity.ActivityItemBuilder
|
||||||
import ani.dantotsu.toast
|
import ani.dantotsu.toast
|
||||||
import com.xwray.groupie.viewbinding.BindableItem
|
import com.xwray.groupie.viewbinding.BindableItem
|
||||||
|
@ -18,19 +30,49 @@ import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class ReviewAdapter(
|
class ReviewAdapter(
|
||||||
private var review: Query.Review,
|
private var review: Query.Review,
|
||||||
val clickCallback: (Int) -> Unit
|
|
||||||
) : BindableItem<ItemReviewsBinding>() {
|
) : BindableItem<ItemReviewsBinding>() {
|
||||||
private lateinit var binding: ItemReviewsBinding
|
private lateinit var binding: ItemReviewsBinding
|
||||||
|
|
||||||
override fun bind(viewBinding: ItemReviewsBinding, position: Int) {
|
override fun bind(viewBinding: ItemReviewsBinding, position: Int) {
|
||||||
binding = viewBinding
|
binding = viewBinding
|
||||||
|
val context = binding.root.context
|
||||||
binding.reviewUserName.text = review.user?.name
|
binding.reviewUserName.text = review.user?.name
|
||||||
binding.reviewUserAvatar.loadImage(review.user?.avatar?.medium)
|
binding.reviewUserAvatar.loadImage(review.user?.avatar?.medium)
|
||||||
binding.reviewText.text = review.summary
|
binding.reviewText.text = review.summary
|
||||||
binding.reviewPostTime.text = ActivityItemBuilder.getDateTime(review.createdAt)
|
binding.reviewPostTime.text = ActivityItemBuilder.getDateTime(review.createdAt)
|
||||||
val text = "[${review.score/ 10.0f}]"
|
val text = "[${review.score/ 10.0f}]"
|
||||||
binding.reviewTag.text = text
|
binding.reviewTag.text = text
|
||||||
binding.root.setOnClickListener { clickCallback(review.id) }
|
binding.root.setOnClickListener {
|
||||||
|
ContextCompat.startActivity(
|
||||||
|
context,
|
||||||
|
Intent(context, ReviewViewActivity::class.java)
|
||||||
|
.putExtra("review", review),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
binding.reviewUserName.setOnClickListener {
|
||||||
|
ContextCompat.startActivity(
|
||||||
|
context,
|
||||||
|
Intent(context, ProfileActivity::class.java)
|
||||||
|
.putExtra("userId", review.user?.id),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
binding.reviewUserAvatar.setOnClickListener {
|
||||||
|
ContextCompat.startActivity(
|
||||||
|
context,
|
||||||
|
Intent(context, ProfileActivity::class.java)
|
||||||
|
.putExtra("userId", review.user?.id),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
binding.reviewUserAvatar.openImage(
|
||||||
|
context.getString(
|
||||||
|
R.string.avatar,
|
||||||
|
review.user?.name
|
||||||
|
),
|
||||||
|
review.user?.avatar?.medium ?: ""
|
||||||
|
)
|
||||||
userVote(review.userRating)
|
userVote(review.userRating)
|
||||||
enableVote()
|
enableVote()
|
||||||
binding.reviewTotalVotes.text = review.rating.toString()
|
binding.reviewTotalVotes.text = review.rating.toString()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ani.dantotsu.media
|
package ani.dantotsu.media
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -18,6 +19,9 @@ import ani.dantotsu.getThemeColor
|
||||||
import ani.dantotsu.initActivity
|
import ani.dantotsu.initActivity
|
||||||
import ani.dantotsu.loadImage
|
import ani.dantotsu.loadImage
|
||||||
import ani.dantotsu.navBarHeight
|
import ani.dantotsu.navBarHeight
|
||||||
|
import ani.dantotsu.openImage
|
||||||
|
import ani.dantotsu.others.ImageViewDialog
|
||||||
|
import ani.dantotsu.profile.ProfileActivity
|
||||||
import ani.dantotsu.profile.activity.ActivityItemBuilder
|
import ani.dantotsu.profile.activity.ActivityItemBuilder
|
||||||
import ani.dantotsu.statusBarHeight
|
import ani.dantotsu.statusBarHeight
|
||||||
import ani.dantotsu.themes.ThemeManager
|
import ani.dantotsu.themes.ThemeManager
|
||||||
|
@ -47,6 +51,20 @@ class ReviewViewActivity : AppCompatActivity() {
|
||||||
binding.userName.text = review.user?.name
|
binding.userName.text = review.user?.name
|
||||||
binding.userAvatar.loadImage(review.user?.avatar?.medium)
|
binding.userAvatar.loadImage(review.user?.avatar?.medium)
|
||||||
binding.userTime.text = ActivityItemBuilder.getDateTime(review.createdAt)
|
binding.userTime.text = ActivityItemBuilder.getDateTime(review.createdAt)
|
||||||
|
binding.userContainer.setOnClickListener {
|
||||||
|
startActivity(Intent(this, ProfileActivity::class.java)
|
||||||
|
.putExtra("userId", review.user?.id)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
binding.userAvatar.openImage(
|
||||||
|
binding.root.context.getString(R.string.avatar, review.user?.name),
|
||||||
|
review.user?.avatar?.medium ?: ""
|
||||||
|
)
|
||||||
|
binding.userAvatar.setOnClickListener {
|
||||||
|
startActivity(Intent(this, ProfileActivity::class.java)
|
||||||
|
.putExtra("userId", review.user?.id)
|
||||||
|
)
|
||||||
|
}
|
||||||
binding.profileUserBio.settings.loadWithOverviewMode = true
|
binding.profileUserBio.settings.loadWithOverviewMode = true
|
||||||
binding.profileUserBio.settings.useWideViewPort = true
|
binding.profileUserBio.settings.useWideViewPort = true
|
||||||
binding.profileUserBio.setInitialScale(1)
|
binding.profileUserBio.setInitialScale(1)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import ani.dantotsu.copyToClipboard
|
||||||
import ani.dantotsu.databinding.ItemCommentsBinding
|
import ani.dantotsu.databinding.ItemCommentsBinding
|
||||||
import ani.dantotsu.getAppString
|
import ani.dantotsu.getAppString
|
||||||
import ani.dantotsu.loadImage
|
import ani.dantotsu.loadImage
|
||||||
|
import ani.dantotsu.openImage
|
||||||
import ani.dantotsu.others.ImageViewDialog
|
import ani.dantotsu.others.ImageViewDialog
|
||||||
import ani.dantotsu.profile.ProfileActivity
|
import ani.dantotsu.profile.ProfileActivity
|
||||||
import ani.dantotsu.setAnimation
|
import ani.dantotsu.setAnimation
|
||||||
|
@ -251,13 +252,10 @@ class CommentItem(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commentTotalVotes.text = (comment.upvotes - comment.downvotes).toString()
|
commentTotalVotes.text = (comment.upvotes - comment.downvotes).toString()
|
||||||
commentUserAvatar.setOnLongClickListener {
|
commentUserAvatar.openImage(
|
||||||
ImageViewDialog.newInstance(
|
|
||||||
commentsFragment.activity,
|
|
||||||
commentsFragment.activity.getString(R.string.avatar, comment.username),
|
commentsFragment.activity.getString(R.string.avatar, comment.username),
|
||||||
comment.profilePictureUrl
|
comment.profilePictureUrl ?: ""
|
||||||
)
|
)
|
||||||
}
|
|
||||||
comment.profilePictureUrl?.let { commentUserAvatar.loadImage(it) }
|
comment.profilePictureUrl?.let { commentUserAvatar.loadImage(it) }
|
||||||
commentUserName.text = comment.username
|
commentUserName.text = comment.username
|
||||||
val userColor = "[${levelColor.second}]"
|
val userColor = "[${levelColor.second}]"
|
||||||
|
|
|
@ -28,6 +28,7 @@ import ani.dantotsu.initActivity
|
||||||
import ani.dantotsu.loadImage
|
import ani.dantotsu.loadImage
|
||||||
import ani.dantotsu.media.user.ListActivity
|
import ani.dantotsu.media.user.ListActivity
|
||||||
import ani.dantotsu.navBarHeight
|
import ani.dantotsu.navBarHeight
|
||||||
|
import ani.dantotsu.openImage
|
||||||
import ani.dantotsu.openLinkInBrowser
|
import ani.dantotsu.openLinkInBrowser
|
||||||
import ani.dantotsu.others.ImageViewDialog
|
import ani.dantotsu.others.ImageViewDialog
|
||||||
import ani.dantotsu.profile.activity.FeedFragment
|
import ani.dantotsu.profile.activity.FeedFragment
|
||||||
|
@ -171,13 +172,10 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
||||||
}
|
}
|
||||||
|
|
||||||
profileUserAvatar.loadImage(user.avatar?.medium)
|
profileUserAvatar.loadImage(user.avatar?.medium)
|
||||||
profileUserAvatar.setOnLongClickListener {
|
profileUserAvatar.openImage(
|
||||||
ImageViewDialog.newInstance(
|
context.getString(R.string.avatar, user.name),
|
||||||
context,
|
user.avatar?.medium ?: ""
|
||||||
getString(R.string.avatar, user.name),
|
|
||||||
user.avatar?.medium
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
profileUserName.text = user.name
|
profileUserName.text = user.name
|
||||||
val bannerAnimations: ImageView= if (PrefManager.getVal(PrefName.BannerAnimations)) profileBannerImage else profileBannerImageNoKen
|
val bannerAnimations: ImageView= if (PrefManager.getVal(PrefName.BannerAnimations)) profileBannerImage else profileBannerImageNoKen
|
||||||
|
|
||||||
|
@ -192,13 +190,10 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
||||||
profileMenuButton.updateLayoutParams<ViewGroup.MarginLayoutParams> { topMargin += statusBarHeight }
|
profileMenuButton.updateLayoutParams<ViewGroup.MarginLayoutParams> { topMargin += statusBarHeight }
|
||||||
profileButtonContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> { topMargin += statusBarHeight }
|
profileButtonContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> { topMargin += statusBarHeight }
|
||||||
|
|
||||||
profileBannerImage.setOnLongClickListener {
|
profileBannerImage.openImage(
|
||||||
ImageViewDialog.newInstance(
|
context.getString(R.string.banner, user.name),
|
||||||
context,
|
user.bannerImage ?: user.avatar?.medium ?: ""
|
||||||
getString(R.string.banner, user.name),
|
|
||||||
user.bannerImage
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
mMaxScrollSize = profileAppBar.totalScrollRange
|
mMaxScrollSize = profileAppBar.totalScrollRange
|
||||||
profileAppBar.addOnOffsetChangedListener(context)
|
profileAppBar.addOnOffsetChangedListener(context)
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import ani.dantotsu.BottomSheetDialogFragment
|
import ani.dantotsu.BottomSheetDialogFragment
|
||||||
import ani.dantotsu.R
|
import ani.dantotsu.R
|
||||||
import ani.dantotsu.connections.github.Forks
|
|
||||||
import ani.dantotsu.databinding.BottomSheetDevelopersBinding
|
import ani.dantotsu.databinding.BottomSheetDevelopersBinding
|
||||||
|
|
||||||
class ForksDialogFragment : BottomSheetDialogFragment() {
|
class ForksDialogFragment : BottomSheetDialogFragment() {
|
||||||
|
@ -26,7 +25,16 @@ class ForksDialogFragment : BottomSheetDialogFragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.devsTitle.setText(R.string.forks)
|
binding.devsTitle.setText(R.string.forks)
|
||||||
binding.devsRecyclerView.adapter = DevelopersAdapter(Forks().getForks())
|
binding.devsRecyclerView.adapter = DevelopersAdapter(
|
||||||
|
arrayOf(
|
||||||
|
Developer(
|
||||||
|
"Awery",
|
||||||
|
"https://avatars.githubusercontent.com/u/92123190?v=4",
|
||||||
|
"MrBoomDeveloper",
|
||||||
|
"https://github.com/MrBoomDeveloper/Awery"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
binding.devsRecyclerView.layoutManager = LinearLayoutManager(requireContext())
|
binding.devsRecyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue