diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt index 468795c88b..4315ad13a8 100644 --- a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt +++ b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt @@ -1613,7 +1613,7 @@ Page(page:$page,perPage:50) { else if (global) "isFollowing:false,hasRepliesOrTypeText:true," else "isFollowing:true," return executeQuery( - """{Page(page:$page,perPage:$ITEMS_PER_PAGE){activities(${filter}sort:ID_DESC){__typename ... on TextActivity{id userId type replyCount text(asHtml:true)siteUrl isLocked isSubscribed likeCount isLiked isPinned createdAt user{id name bannerImage avatar{medium large}}replies{id userId activityId text(asHtml:true)likeCount isLiked createdAt user{id name bannerImage avatar{medium large}}likes{id name bannerImage avatar{medium large}}}likes{id name bannerImage avatar{medium large}}}... on ListActivity{id userId type replyCount status progress siteUrl isLocked isSubscribed likeCount isLiked isPinned createdAt user{id name bannerImage avatar{medium large}}media{id title{english romaji native userPreferred}bannerImage coverImage{medium large}}replies{id userId activityId text(asHtml:true)likeCount isLiked createdAt user{id name bannerImage avatar{medium large}}likes{id name bannerImage avatar{medium large}}}likes{id name bannerImage avatar{medium large}}}... on MessageActivity{id recipientId messengerId type replyCount likeCount message(asHtml:true)isLocked isSubscribed isLiked isPrivate siteUrl createdAt recipient{id name bannerImage avatar{medium large}}messenger{id name bannerImage avatar{medium large}}replies{id userId activityId text(asHtml:true)likeCount isLiked createdAt user{id name bannerImage avatar{medium large}}likes{id name bannerImage avatar{medium large}}}likes{id name bannerImage avatar{medium large}}}}}}""", + """{Page(page:$page,perPage:$ITEMS_PER_PAGE){activities(${filter}sort:ID_DESC){__typename ... on TextActivity{id userId type replyCount text(asHtml:true)siteUrl isLocked isSubscribed likeCount isLiked isPinned createdAt user{id name bannerImage avatar{medium large}}replies{id userId activityId text(asHtml:true)likeCount isLiked createdAt user{id name bannerImage avatar{medium large}}likes{id name bannerImage avatar{medium large}}}likes{id name bannerImage avatar{medium large}}}... on ListActivity{id userId type replyCount status progress siteUrl isLocked isSubscribed likeCount isLiked isPinned createdAt user{id name bannerImage avatar{medium large}}media{id title{english romaji native userPreferred}bannerImage coverImage{medium large}isAdult}replies{id userId activityId text(asHtml:true)likeCount isLiked createdAt user{id name bannerImage avatar{medium large}}likes{id name bannerImage avatar{medium large}}}likes{id name bannerImage avatar{medium large}}}... on MessageActivity{id recipientId messengerId type replyCount likeCount message(asHtml:true)isLocked isSubscribed isLiked isPrivate siteUrl createdAt recipient{id name bannerImage avatar{medium large}}messenger{id name bannerImage avatar{medium large}}replies{id userId activityId text(asHtml:true)likeCount isLiked createdAt user{id name bannerImage avatar{medium large}}likes{id name bannerImage avatar{medium large}}}likes{id name bannerImage avatar{medium large}}}}}}""", force = true ) } diff --git a/app/src/main/java/ani/dantotsu/media/ReviewActivity.kt b/app/src/main/java/ani/dantotsu/media/ReviewActivity.kt index d374776577..6b08734cd6 100644 --- a/app/src/main/java/ani/dantotsu/media/ReviewActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/ReviewActivity.kt @@ -19,7 +19,6 @@ import ani.dantotsu.connections.anilist.api.Query import ani.dantotsu.databinding.ActivityFollowBinding import ani.dantotsu.initActivity import ani.dantotsu.navBarHeight -import ani.dantotsu.profile.FollowerItem import ani.dantotsu.statusBarHeight import ani.dantotsu.themes.ThemeManager import ani.dantotsu.util.MarkdownCreatorActivity diff --git a/app/src/main/java/ani/dantotsu/profile/FollowActivity.kt b/app/src/main/java/ani/dantotsu/profile/FollowActivity.kt index 6e2a92fcb6..081b536a5a 100644 --- a/app/src/main/java/ani/dantotsu/profile/FollowActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/FollowActivity.kt @@ -93,26 +93,37 @@ class FollowActivity : AppCompatActivity() { val screenWidth = resources.displayMetrics.run { widthPixels / density } binding.listRecyclerView.layoutManager = when (getLayoutType(selected)) { 0 -> LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) - 1 -> GridLayoutManager(this, (screenWidth / 120f).toInt(), GridLayoutManager.VERTICAL, false) + 1 -> GridLayoutManager( + this, + (screenWidth / 120f).toInt(), + GridLayoutManager.VERTICAL, + false + ) + else -> LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false) } users?.forEach { user -> + val username = SpannableString(user.name ?: "Unknown") if (getLayoutType(selected) == 0) { - val username = SpannableString(user.name ?: "Unknown") adapter.add( FollowerItem( + false, user.id, username, user.avatar?.medium, user.bannerImage ?: user.avatar?.medium - ) { onUserClick(it) }) + ) { onUserClick(it) } + ) } else { adapter.add( - GridFollowerItem( + FollowerItem( + true, user.id, - user.name ?: "Unknown", - user.avatar?.medium - ) { onUserClick(it) }) + username, + user.avatar?.medium, + user.bannerImage ?: user.avatar?.medium + ) { onUserClick(it) } + ) } } } diff --git a/app/src/main/java/ani/dantotsu/profile/FollowerItem.kt b/app/src/main/java/ani/dantotsu/profile/FollowerItem.kt index 18c05a8951..824efc6aa4 100644 --- a/app/src/main/java/ani/dantotsu/profile/FollowerItem.kt +++ b/app/src/main/java/ani/dantotsu/profile/FollowerItem.kt @@ -3,39 +3,43 @@ package ani.dantotsu.profile import android.text.SpannableString import android.view.View +import androidx.viewbinding.ViewBinding import ani.dantotsu.R import ani.dantotsu.blurImage import ani.dantotsu.databinding.ItemFollowerBinding +import ani.dantotsu.databinding.ItemFollowerGridBinding import ani.dantotsu.loadImage import com.xwray.groupie.viewbinding.BindableItem class FollowerItem( + private val grid: Boolean, private val id: Int, private val name: SpannableString, private val avatar: String?, private val banner: String?, - private val altText: String? = null, val clickCallback: (Int) -> Unit -) : BindableItem() { - private lateinit var binding: ItemFollowerBinding +) : BindableItem() { - override fun bind(viewBinding: ItemFollowerBinding, position: Int) { - binding = viewBinding - binding.profileUserName.text = name - avatar?.let { binding.profileUserAvatar.loadImage(it) } - altText?.let { - binding.altText.visibility = View.VISIBLE - binding.altText.text = it + override fun bind(viewBinding: ViewBinding, position: Int) { + if (grid) { + val binding = viewBinding as ItemFollowerGridBinding + binding.profileUserName.text = name + avatar?.let { binding.profileUserAvatar.loadImage(it) } + binding.root.setOnClickListener { clickCallback(id) } + } else { + val binding = viewBinding as ItemFollowerBinding + binding.profileUserName.text = name + avatar?.let { binding.profileUserAvatar.loadImage(it) } + blurImage(binding.profileBannerImage, banner ?: avatar) + binding.root.setOnClickListener { clickCallback(id) } } - blurImage(binding.profileBannerImage, banner ?: avatar) - binding.root.setOnClickListener { clickCallback(id) } } override fun getLayout(): Int { - return R.layout.item_follower + return if(grid) R.layout.item_follower_grid else R.layout.item_follower } - override fun initializeViewBinding(view: View): ItemFollowerBinding { - return ItemFollowerBinding.bind(view) + override fun initializeViewBinding(view: View): ViewBinding { + return if(grid) ItemFollowerGridBinding.bind(view) else ItemFollowerBinding.bind(view) } } \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/profile/GridFollowerItem.kt b/app/src/main/java/ani/dantotsu/profile/GridFollowerItem.kt deleted file mode 100644 index 33d7e66be5..0000000000 --- a/app/src/main/java/ani/dantotsu/profile/GridFollowerItem.kt +++ /dev/null @@ -1,31 +0,0 @@ -package ani.dantotsu.profile - -import android.view.View -import ani.dantotsu.R -import ani.dantotsu.databinding.ItemFollowerGridBinding -import ani.dantotsu.loadImage -import com.xwray.groupie.viewbinding.BindableItem - -class GridFollowerItem( - private val id: Int, - private val name: String, - private val avatar: String?, - val clickCallback: (Int) -> Unit -) : BindableItem() { - private lateinit var binding: ItemFollowerGridBinding - - override fun bind(viewBinding: ItemFollowerGridBinding, position: Int) { - binding = viewBinding - binding.profileUserName.text = name - avatar?.let { binding.profileUserAvatar.loadImage(it) } - binding.root.setOnClickListener { clickCallback(id) } - } - - override fun getLayout(): Int { - return R.layout.item_follower_grid - } - - override fun initializeViewBinding(view: View): ItemFollowerGridBinding { - return ItemFollowerGridBinding.bind(view) - } -} \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/profile/activity/FeedFragment.kt b/app/src/main/java/ani/dantotsu/profile/activity/FeedFragment.kt index 0da64157be..102caea1b1 100644 --- a/app/src/main/java/ani/dantotsu/profile/activity/FeedFragment.kt +++ b/app/src/main/java/ani/dantotsu/profile/activity/FeedFragment.kt @@ -85,7 +85,9 @@ class FeedFragment : Fragment() { res?.data?.page?.activities?.let { activities -> activityList = activities val filtered = - activityList.filterNot { //filter out messages that are not directed to the user + activityList + .filter { if (Anilist.adult) true else it.media?.isAdult == false } + .filterNot { //filter out messages that are not directed to the user it.recipient?.id != null && it.recipient.id != Anilist.userid } adapter.update(filtered.map { diff --git a/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt b/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt index def4e73f0f..cf03c59cdf 100644 --- a/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt @@ -236,7 +236,7 @@ class NotificationActivity : AppCompatActivity() { context = it.title + ": " + it.content, createdAt = (it.time / 1000L).toInt(), image = it.image, - banner = it.banner + banner = it.banner ?: it.image ) newNotifications += notification }