Skip to content

Commit

Permalink
feat: remove 18+ media and anilist adult is off
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 committed May 23, 2024
1 parent d06c980 commit 773b7f5
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ Page(page:$page,perPage:50) {
else if (global) "isFollowing:false,hasRepliesOrTypeText:true,"
else "isFollowing:true,"
return executeQuery<FeedResponse>(
"""{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
)
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/ani/dantotsu/media/ReviewActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 18 additions & 7 deletions app/src/main/java/ani/dantotsu/profile/FollowActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
)
}
}
}
Expand Down
34 changes: 19 additions & 15 deletions app/src/main/java/ani/dantotsu/profile/FollowerItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemFollowerBinding>() {
private lateinit var binding: ItemFollowerBinding
) : BindableItem<ViewBinding>() {

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)
}
}
31 changes: 0 additions & 31 deletions app/src/main/java/ani/dantotsu/profile/GridFollowerItem.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 773b7f5

Please sign in to comment.