feat: hide media from home screen
This commit is contained in:
parent
7bdc7c1719
commit
425ca158a3
6 changed files with 54 additions and 10 deletions
|
@ -11,7 +11,6 @@ import ani.dantotsu.connections.anilist.api.FuzzyDate
|
|||
import ani.dantotsu.connections.anilist.api.NotificationResponse
|
||||
import ani.dantotsu.connections.anilist.api.Page
|
||||
import ani.dantotsu.connections.anilist.api.Query
|
||||
import ani.dantotsu.connections.anilist.api.Social
|
||||
import ani.dantotsu.connections.anilist.api.ToggleLike
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.isOnline
|
||||
|
@ -413,6 +412,7 @@ class AnilistQueries {
|
|||
}
|
||||
|
||||
suspend fun initHomePage(): Map<String, ArrayList<*>> {
|
||||
val removeList = PrefManager.getCustomVal("removeList", setOf<Int>())
|
||||
val toShow: List<Boolean> =
|
||||
PrefManager.getVal(PrefName.HomeLayout) // anime continue, anime fav, anime planned, manga continue, manga fav, manga planned, recommendations
|
||||
var query = """{"""
|
||||
|
@ -462,17 +462,22 @@ class AnilistQueries {
|
|||
current?.lists?.forEach { li ->
|
||||
li.entries?.reversed()?.forEach {
|
||||
val m = Media(it)
|
||||
if (m.id !in removeList) {
|
||||
m.cameFromContinue = true
|
||||
subMap[m.id] = m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repeating?.lists?.forEach { li ->
|
||||
li.entries?.reversed()?.forEach {
|
||||
val m = Media(it)
|
||||
if (m.id !in removeList) {
|
||||
m.cameFromContinue = true
|
||||
subMap[m.id] = m
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type != "Anime") {
|
||||
returnArray.addAll(subMap.values)
|
||||
returnMap["current$type"] = returnArray
|
||||
|
@ -504,10 +509,12 @@ class AnilistQueries {
|
|||
current?.lists?.forEach { li ->
|
||||
li.entries?.reversed()?.forEach {
|
||||
val m = Media(it)
|
||||
if (m.id !in removeList) {
|
||||
m.cameFromContinue = true
|
||||
subMap[m.id] = m
|
||||
}
|
||||
}
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val list = PrefManager.getNullableCustomVal(
|
||||
"continueAnimeList",
|
||||
|
@ -532,7 +539,10 @@ class AnilistQueries {
|
|||
val returnArray = arrayListOf<Media>()
|
||||
apiMediaList?.edges?.forEach {
|
||||
it.node?.let { i ->
|
||||
returnArray.add(Media(i).apply { isFav = true })
|
||||
val m = Media(i).apply { isFav = true }
|
||||
if (m.id !in removeList) {
|
||||
returnArray.add(m)
|
||||
}
|
||||
}
|
||||
}
|
||||
returnMap["favorite$type"] = returnArray
|
||||
|
|
|
@ -20,6 +20,7 @@ import ani.dantotsu.connections.anilist.api.FuzzyDate
|
|||
import ani.dantotsu.connections.mal.MAL
|
||||
import ani.dantotsu.databinding.BottomSheetMediaListBinding
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.tryWith
|
||||
import com.google.android.material.materialswitch.MaterialSwitch
|
||||
|
@ -187,7 +188,15 @@ class MediaListDialogFragment : BottomSheetDialogFragment() {
|
|||
binding.mediaListPrivate.setOnCheckedChangeListener { _, checked ->
|
||||
media?.isListPrivate = checked
|
||||
}
|
||||
|
||||
val removeList = PrefManager.getCustomVal("removeList", setOf<Int>())
|
||||
binding.mediaListShow.isChecked = media?.id in removeList
|
||||
binding.mediaListShow.setOnCheckedChangeListener { _, checked ->
|
||||
if (checked) {
|
||||
PrefManager.setCustomVal("removeList", removeList.plus(media?.id))
|
||||
} else {
|
||||
PrefManager.setCustomVal("removeList", removeList.minus(media?.id))
|
||||
}
|
||||
}
|
||||
media?.userRepeat?.apply {
|
||||
binding.mediaListRewatch.setText(this.toString())
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import ani.dantotsu.connections.mal.MAL
|
|||
import ani.dantotsu.databinding.BottomSheetMediaListSmallBinding
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.snackString
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -170,7 +171,15 @@ class MediaListDialogSmallFragment : BottomSheetDialogFragment() {
|
|||
binding.mediaListPrivate.setOnCheckedChangeListener { _, checked ->
|
||||
media.isListPrivate = checked
|
||||
}
|
||||
|
||||
val removeList = PrefManager.getCustomVal("removeList", setOf<Int>())
|
||||
binding.mediaListShow.isChecked = media?.id in removeList
|
||||
binding.mediaListShow.setOnCheckedChangeListener { _, checked ->
|
||||
if (checked) {
|
||||
PrefManager.setCustomVal("removeList", removeList.plus(media.id))
|
||||
} else {
|
||||
PrefManager.setCustomVal("removeList", removeList.minus(media.id))
|
||||
}
|
||||
}
|
||||
binding.mediaListSave.setOnClickListener {
|
||||
scope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
|
|
|
@ -338,6 +338,13 @@
|
|||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/list_private" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/mediaListShow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/hide_in_home_screen" />
|
||||
<TextView
|
||||
android:id="@+id/mediaListAddCustomList"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -178,6 +178,14 @@
|
|||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/list_private" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/mediaListShow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/hide_in_home_screen" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -972,4 +972,5 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
|||
<string name="an_unexpected_error_occurred">An unexpected error occurred.\nPlease send a crash report to the developer :)</string>
|
||||
<string name="copy_report">Copy Report</string>
|
||||
<string name="share_as_file">Share as file</string>
|
||||
<string name="hide_in_home_screen">Hide in Home Screen</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue