Add filter library by customized update frequency
Supersedes #9619 Co-authored-by: quangkieu <quangkieu@users.noreply.github.com> (cherry picked from commit 028da099ddf42b8b305afad04aba5f819a8ce24c) # Conflicts: # app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt # domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt
This commit is contained in:
@@ -96,6 +96,8 @@ private fun ColumnScope.FilterPage(
|
||||
) {
|
||||
val filterDownloaded by screenModel.libraryPreferences.filterDownloaded().collectAsState()
|
||||
val downloadedOnly by screenModel.preferences.downloadedOnly().collectAsState()
|
||||
val autoUpdateMangaRestrictions by screenModel.libraryPreferences.autoUpdateMangaRestrictions().collectAsState()
|
||||
|
||||
TriStateItem(
|
||||
label = stringResource(MR.strings.label_downloaded),
|
||||
state = if (downloadedOnly) {
|
||||
@@ -130,6 +132,14 @@ private fun ColumnScope.FilterPage(
|
||||
state = filterCompleted,
|
||||
onClick = { screenModel.toggleFilter(LibraryPreferences::filterCompleted) },
|
||||
)
|
||||
if (LibraryPreferences.MANGA_OUTSIDE_RELEASE_PERIOD in autoUpdateMangaRestrictions) {
|
||||
val filterIntervalCustom by screenModel.libraryPreferences.filterIntervalCustom().collectAsState()
|
||||
TriStateItem(
|
||||
label = stringResource(MR.strings.action_filter_interval_custom),
|
||||
state = filterIntervalCustom,
|
||||
onClick = { screenModel.toggleFilter(LibraryPreferences::filterIntervalCustom) },
|
||||
)
|
||||
}
|
||||
// SY -->
|
||||
val filterLewd by screenModel.libraryPreferences.filterLewd().collectAsState()
|
||||
TriStateItem(
|
||||
|
||||
@@ -232,6 +232,7 @@ class LibraryScreenModel(
|
||||
prefs.filterStarted,
|
||||
prefs.filterBookmarked,
|
||||
prefs.filterCompleted,
|
||||
prefs.filterIntervalCustom,
|
||||
) + trackFilter.values
|
||||
).any { it != TriState.DISABLED }
|
||||
}
|
||||
@@ -278,12 +279,13 @@ class LibraryScreenModel(
|
||||
): LibraryMap {
|
||||
val prefs = getLibraryItemPreferencesFlow().first()
|
||||
val downloadedOnly = prefs.globalFilterDownloaded
|
||||
val filterDownloaded =
|
||||
if (downloadedOnly) TriState.ENABLED_IS else prefs.filterDownloaded
|
||||
val skipOutsideReleasePeriod = prefs.skipOutsideReleasePeriod
|
||||
val filterDownloaded = if (downloadedOnly) TriState.ENABLED_IS else prefs.filterDownloaded
|
||||
val filterUnread = prefs.filterUnread
|
||||
val filterStarted = prefs.filterStarted
|
||||
val filterBookmarked = prefs.filterBookmarked
|
||||
val filterCompleted = prefs.filterCompleted
|
||||
val filterIntervalCustom = prefs.filterIntervalCustom
|
||||
|
||||
val isNotLoggedInAnyTrack = loggedInTrackers.isEmpty()
|
||||
|
||||
@@ -319,6 +321,14 @@ class LibraryScreenModel(
|
||||
applyFilter(filterCompleted) { it.libraryManga.manga.status.toInt() == SManga.COMPLETED }
|
||||
}
|
||||
|
||||
val filterFnIntervalCustom: (LibraryItem) -> Boolean = {
|
||||
if (skipOutsideReleasePeriod) {
|
||||
applyFilter(filterIntervalCustom) { it.libraryManga.manga.fetchInterval < 0 }
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
// SY -->
|
||||
val filterFnLewd: (LibraryItem) -> Boolean = {
|
||||
applyFilter(filterLewd) { it.libraryManga.manga.isLewd() }
|
||||
@@ -335,7 +345,7 @@ class LibraryScreenModel(
|
||||
val isExcluded = excludedTracks.isNotEmpty() && mangaTracks.fastAny { it in excludedTracks }
|
||||
val isIncluded = includedTracks.isEmpty() || mangaTracks.fastAny { it in includedTracks }
|
||||
|
||||
return@tracking !isExcluded && isIncluded
|
||||
!isExcluded && isIncluded
|
||||
}
|
||||
|
||||
val filterFn: (LibraryItem) -> Boolean = {
|
||||
@@ -344,6 +354,7 @@ class LibraryScreenModel(
|
||||
filterFnStarted(it) &&
|
||||
filterFnBookmarked(it) &&
|
||||
filterFnCompleted(it) &&
|
||||
filterFnIntervalCustom(it) &&
|
||||
filterFnTracking(it) &&
|
||||
// SY -->
|
||||
filterFnLewd(it)
|
||||
@@ -461,6 +472,7 @@ class LibraryScreenModel(
|
||||
libraryPreferences.downloadBadge().changes(),
|
||||
libraryPreferences.localBadge().changes(),
|
||||
libraryPreferences.languageBadge().changes(),
|
||||
libraryPreferences.autoUpdateMangaRestrictions().changes(),
|
||||
|
||||
preferences.downloadedOnly().changes(),
|
||||
libraryPreferences.filterDownloaded().changes(),
|
||||
@@ -468,26 +480,28 @@ class LibraryScreenModel(
|
||||
libraryPreferences.filterStarted().changes(),
|
||||
libraryPreferences.filterBookmarked().changes(),
|
||||
libraryPreferences.filterCompleted().changes(),
|
||||
libraryPreferences.filterIntervalCustom().changes(),
|
||||
// SY -->
|
||||
libraryPreferences.filterLewd().changes(),
|
||||
// SY <--
|
||||
transform = {
|
||||
ItemPreferences(
|
||||
downloadBadge = it[0] as Boolean,
|
||||
localBadge = it[1] as Boolean,
|
||||
languageBadge = it[2] as Boolean,
|
||||
globalFilterDownloaded = it[3] as Boolean,
|
||||
filterDownloaded = it[4] as TriState,
|
||||
filterUnread = it[5] as TriState,
|
||||
filterStarted = it[6] as TriState,
|
||||
filterBookmarked = it[7] as TriState,
|
||||
filterCompleted = it[8] as TriState,
|
||||
// SY -->
|
||||
filterLewd = it[9] as TriState,
|
||||
// SY <--
|
||||
)
|
||||
},
|
||||
)
|
||||
) {
|
||||
ItemPreferences(
|
||||
downloadBadge = it[0] as Boolean,
|
||||
localBadge = it[1] as Boolean,
|
||||
languageBadge = it[2] as Boolean,
|
||||
skipOutsideReleasePeriod = LibraryPreferences.MANGA_OUTSIDE_RELEASE_PERIOD in (it[3] as Set<*>),
|
||||
globalFilterDownloaded = it[4] as Boolean,
|
||||
filterDownloaded = it[5] as TriState,
|
||||
filterUnread = it[6] as TriState,
|
||||
filterStarted = it[7] as TriState,
|
||||
filterBookmarked = it[8] as TriState,
|
||||
filterCompleted = it[9] as TriState,
|
||||
filterIntervalCustom = it[10] as TriState,
|
||||
// SY -->
|
||||
filterLewd = it[11] as TriState,
|
||||
// SY <--
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1266,6 +1280,7 @@ class LibraryScreenModel(
|
||||
val downloadBadge: Boolean,
|
||||
val localBadge: Boolean,
|
||||
val languageBadge: Boolean,
|
||||
val skipOutsideReleasePeriod: Boolean,
|
||||
|
||||
val globalFilterDownloaded: Boolean,
|
||||
val filterDownloaded: TriState,
|
||||
@@ -1273,6 +1288,7 @@ class LibraryScreenModel(
|
||||
val filterStarted: TriState,
|
||||
val filterBookmarked: TriState,
|
||||
val filterCompleted: TriState,
|
||||
val filterIntervalCustom: TriState,
|
||||
// SY -->
|
||||
val filterLewd: TriState,
|
||||
// SY <--
|
||||
|
||||
Reference in New Issue
Block a user