Skip to content

Commit

Permalink
feat(home): hive private media
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 committed Jun 13, 2024
1 parent 903423b commit 1670383
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ class AnilistQueries {

suspend fun initHomePage(): Map<String, ArrayList<*>> {
val removeList = PrefManager.getCustomVal("removeList", setOf<Int>())
val hidePrivate = PrefManager.getVal<Boolean>(PrefName.HidePrivate)
val removedMedia = ArrayList<Media>()
val toShow: List<Boolean> =
PrefManager.getVal(PrefName.HomeLayout) // anime continue, anime fav, anime planned, manga continue, manga fav, manga planned, recommendations
Expand Down Expand Up @@ -528,7 +529,7 @@ class AnilistQueries {
current?.lists?.forEach { li ->
li.entries?.reversed()?.forEach {
val m = Media(it)
if (m.id !in removeList) {
if (m.id !in removeList && if (hidePrivate) !m.isListPrivate else true) {
m.cameFromContinue = true
subMap[m.id] = m
} else {
Expand All @@ -540,7 +541,7 @@ class AnilistQueries {
repeating?.lists?.forEach { li ->
li.entries?.reversed()?.forEach {
val m = Media(it)
if (m.id !in removeList) {
if (m.id !in removeList && if (hidePrivate) !m.isListPrivate else true) {
m.cameFromContinue = true
subMap[m.id] = m
} else {
Expand Down Expand Up @@ -579,7 +580,7 @@ class AnilistQueries {
current?.lists?.forEach { li ->
li.entries?.reversed()?.forEach {
val m = Media(it)
if (m.id !in removeList) {
if (m.id !in removeList && if (hidePrivate) !m.isListPrivate else true) {
m.cameFromContinue = true
subMap[m.id] = m
} else {
Expand Down Expand Up @@ -612,7 +613,7 @@ class AnilistQueries {
apiMediaList?.edges?.forEach {
it.node?.let { i ->
val m = Media(i).apply { isFav = true }
if (m.id !in removeList) {
if (m.id !in removeList && if (hidePrivate) !m.isListPrivate else true) {
returnArray.add(m)
} else {
removedMedia.add(m)
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/ani/dantotsu/settings/SettingsCommonActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ class SettingsCommonActivity : AppCompatActivity() {
PrefManager.setVal(PrefName.ContinueMedia, isChecked)
}
),
Settings(
type = 2,
name = getString(R.string.hide_private),
desc = getString(R.string.hide_private_desc),
icon = R.drawable.ic_round_remove_red_eye_24,
isChecked = PrefManager.getVal(PrefName.HidePrivate),
switch = { isChecked, _ ->
PrefManager.setVal(PrefName.HidePrivate, isChecked)
restartApp()
}
),
Settings(
type = 2,
name = getString(R.string.search_source_list),
Expand Down

0 comments on commit 1670383

Please sign in to comment.