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.NotificationResponse
|
||||||
import ani.dantotsu.connections.anilist.api.Page
|
import ani.dantotsu.connections.anilist.api.Page
|
||||||
import ani.dantotsu.connections.anilist.api.Query
|
import ani.dantotsu.connections.anilist.api.Query
|
||||||
import ani.dantotsu.connections.anilist.api.Social
|
|
||||||
import ani.dantotsu.connections.anilist.api.ToggleLike
|
import ani.dantotsu.connections.anilist.api.ToggleLike
|
||||||
import ani.dantotsu.currContext
|
import ani.dantotsu.currContext
|
||||||
import ani.dantotsu.isOnline
|
import ani.dantotsu.isOnline
|
||||||
|
@ -413,6 +412,7 @@ class AnilistQueries {
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun initHomePage(): Map<String, ArrayList<*>> {
|
suspend fun initHomePage(): Map<String, ArrayList<*>> {
|
||||||
|
val removeList = PrefManager.getCustomVal("removeList", setOf<Int>())
|
||||||
val toShow: List<Boolean> =
|
val toShow: List<Boolean> =
|
||||||
PrefManager.getVal(PrefName.HomeLayout) // anime continue, anime fav, anime planned, manga continue, manga fav, manga planned, recommendations
|
PrefManager.getVal(PrefName.HomeLayout) // anime continue, anime fav, anime planned, manga continue, manga fav, manga planned, recommendations
|
||||||
var query = """{"""
|
var query = """{"""
|
||||||
|
@ -462,15 +462,20 @@ class AnilistQueries {
|
||||||
current?.lists?.forEach { li ->
|
current?.lists?.forEach { li ->
|
||||||
li.entries?.reversed()?.forEach {
|
li.entries?.reversed()?.forEach {
|
||||||
val m = Media(it)
|
val m = Media(it)
|
||||||
m.cameFromContinue = true
|
if (m.id !in removeList) {
|
||||||
subMap[m.id] = m
|
m.cameFromContinue = true
|
||||||
|
subMap[m.id] = m
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repeating?.lists?.forEach { li ->
|
repeating?.lists?.forEach { li ->
|
||||||
li.entries?.reversed()?.forEach {
|
li.entries?.reversed()?.forEach {
|
||||||
val m = Media(it)
|
val m = Media(it)
|
||||||
m.cameFromContinue = true
|
if (m.id !in removeList) {
|
||||||
subMap[m.id] = m
|
m.cameFromContinue = true
|
||||||
|
subMap[m.id] = m
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type != "Anime") {
|
if (type != "Anime") {
|
||||||
|
@ -504,8 +509,10 @@ class AnilistQueries {
|
||||||
current?.lists?.forEach { li ->
|
current?.lists?.forEach { li ->
|
||||||
li.entries?.reversed()?.forEach {
|
li.entries?.reversed()?.forEach {
|
||||||
val m = Media(it)
|
val m = Media(it)
|
||||||
m.cameFromContinue = true
|
if (m.id !in removeList) {
|
||||||
subMap[m.id] = m
|
m.cameFromContinue = true
|
||||||
|
subMap[m.id] = m
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@ -532,7 +539,10 @@ class AnilistQueries {
|
||||||
val returnArray = arrayListOf<Media>()
|
val returnArray = arrayListOf<Media>()
|
||||||
apiMediaList?.edges?.forEach {
|
apiMediaList?.edges?.forEach {
|
||||||
it.node?.let { i ->
|
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
|
returnMap["favorite$type"] = returnArray
|
||||||
|
|
|
@ -20,6 +20,7 @@ import ani.dantotsu.connections.anilist.api.FuzzyDate
|
||||||
import ani.dantotsu.connections.mal.MAL
|
import ani.dantotsu.connections.mal.MAL
|
||||||
import ani.dantotsu.databinding.BottomSheetMediaListBinding
|
import ani.dantotsu.databinding.BottomSheetMediaListBinding
|
||||||
import ani.dantotsu.navBarHeight
|
import ani.dantotsu.navBarHeight
|
||||||
|
import ani.dantotsu.settings.saving.PrefManager
|
||||||
import ani.dantotsu.snackString
|
import ani.dantotsu.snackString
|
||||||
import ani.dantotsu.tryWith
|
import ani.dantotsu.tryWith
|
||||||
import com.google.android.material.materialswitch.MaterialSwitch
|
import com.google.android.material.materialswitch.MaterialSwitch
|
||||||
|
@ -187,7 +188,15 @@ class MediaListDialogFragment : BottomSheetDialogFragment() {
|
||||||
binding.mediaListPrivate.setOnCheckedChangeListener { _, checked ->
|
binding.mediaListPrivate.setOnCheckedChangeListener { _, checked ->
|
||||||
media?.isListPrivate = 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 {
|
media?.userRepeat?.apply {
|
||||||
binding.mediaListRewatch.setText(this.toString())
|
binding.mediaListRewatch.setText(this.toString())
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import ani.dantotsu.connections.mal.MAL
|
||||||
import ani.dantotsu.databinding.BottomSheetMediaListSmallBinding
|
import ani.dantotsu.databinding.BottomSheetMediaListSmallBinding
|
||||||
import ani.dantotsu.navBarHeight
|
import ani.dantotsu.navBarHeight
|
||||||
import ani.dantotsu.others.getSerialized
|
import ani.dantotsu.others.getSerialized
|
||||||
|
import ani.dantotsu.settings.saving.PrefManager
|
||||||
import ani.dantotsu.snackString
|
import ani.dantotsu.snackString
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -170,7 +171,15 @@ class MediaListDialogSmallFragment : BottomSheetDialogFragment() {
|
||||||
binding.mediaListPrivate.setOnCheckedChangeListener { _, checked ->
|
binding.mediaListPrivate.setOnCheckedChangeListener { _, checked ->
|
||||||
media.isListPrivate = 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 {
|
binding.mediaListSave.setOnClickListener {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
|
|
|
@ -338,6 +338,13 @@
|
||||||
android:fontFamily="@font/poppins_bold"
|
android:fontFamily="@font/poppins_bold"
|
||||||
android:text="@string/list_private" />
|
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
|
<TextView
|
||||||
android:id="@+id/mediaListAddCustomList"
|
android:id="@+id/mediaListAddCustomList"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -178,6 +178,14 @@
|
||||||
android:fontFamily="@font/poppins_bold"
|
android:fontFamily="@font/poppins_bold"
|
||||||
android:text="@string/list_private" />
|
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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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="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="copy_report">Copy Report</string>
|
||||||
<string name="share_as_file">Share as file</string>
|
<string name="share_as_file">Share as file</string>
|
||||||
|
<string name="hide_in_home_screen">Hide in Home Screen</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue