diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 15a092b391..2ee14b3bbd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -87,6 +87,8 @@ object PreferenceKeys { const val filterUnread = "pref_filter_unread_key" + const val filterCompleted = "pref_filter_completed_key" + const val librarySortingMode = "library_sorting_mode" const val automaticUpdates = "automatic_updates" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 13057e2952..8e0f401a04 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -145,6 +145,8 @@ class PreferencesHelper(val context: Context) { fun filterUnread() = rxPrefs.getBoolean(Keys.filterUnread, false) + fun filterCompleted() = rxPrefs.getBoolean(Keys.filterCompleted, false) + fun librarySortingMode() = rxPrefs.getInteger(Keys.librarySortingMode, 0) fun librarySortingAscending() = rxPrefs.getBoolean("library_sorting_ascending", true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryNavigationView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryNavigationView.kt index 2edd7a6346..6c1d4a0405 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryNavigationView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryNavigationView.kt @@ -74,7 +74,9 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A private val unread = Item.CheckboxGroup(R.string.action_filter_unread, this) - override val items = listOf(downloaded, unread) + private val completed = Item.CheckboxGroup(R.string.completed, this) + + override val items = listOf(downloaded, unread, completed) override val header = Item.Header(R.string.action_filter) @@ -83,6 +85,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A override fun initModels() { downloaded.checked = preferences.filterDownloaded().getOrDefault() unread.checked = preferences.filterUnread().getOrDefault() + completed.checked = preferences.filterCompleted().getOrDefault() } override fun onItemClicked(item: Item) { @@ -91,6 +94,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A when (item) { downloaded -> preferences.filterDownloaded().set(item.checked) unread -> preferences.filterUnread().set(item.checked) + completed -> preferences.filterCompleted().set(item.checked) } adapter.notifyItemChanged(item) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index e09e837cc4..7661f218f8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.SourceManager +import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.util.combineLatest @@ -101,6 +102,8 @@ class LibraryPresenter( val filterUnread = preferences.filterUnread().getOrDefault() + val filterCompleted = preferences.filterCompleted().getOrDefault() + val filterFn: (Manga) -> Boolean = f@ { manga -> // Filter out manga without source. val source = sourceManager.get(manga.source) ?: return@f false @@ -110,6 +113,10 @@ class LibraryPresenter( return@f false } + if (filterCompleted && manga.status != SManga.COMPLETED) { + return@f false + } + // Filter when the download directory doesn't exist or is null. if (filterDownloaded) { // Get the directories for the source of the manga.