mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +01:00
Add Filter by Completed for library (#941)
* issue 938 added filter by completed manga status * changed to use existing string fixed space issue in method in presenter
This commit is contained in:
parent
e8b432485d
commit
bfa386acba
@ -87,6 +87,8 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val filterUnread = "pref_filter_unread_key"
|
const val filterUnread = "pref_filter_unread_key"
|
||||||
|
|
||||||
|
const val filterCompleted = "pref_filter_completed_key"
|
||||||
|
|
||||||
const val librarySortingMode = "library_sorting_mode"
|
const val librarySortingMode = "library_sorting_mode"
|
||||||
|
|
||||||
const val automaticUpdates = "automatic_updates"
|
const val automaticUpdates = "automatic_updates"
|
||||||
|
@ -145,6 +145,8 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun filterUnread() = rxPrefs.getBoolean(Keys.filterUnread, false)
|
fun filterUnread() = rxPrefs.getBoolean(Keys.filterUnread, false)
|
||||||
|
|
||||||
|
fun filterCompleted() = rxPrefs.getBoolean(Keys.filterCompleted, false)
|
||||||
|
|
||||||
fun librarySortingMode() = rxPrefs.getInteger(Keys.librarySortingMode, 0)
|
fun librarySortingMode() = rxPrefs.getInteger(Keys.librarySortingMode, 0)
|
||||||
|
|
||||||
fun librarySortingAscending() = rxPrefs.getBoolean("library_sorting_ascending", true)
|
fun librarySortingAscending() = rxPrefs.getBoolean("library_sorting_ascending", true)
|
||||||
|
@ -74,7 +74,9 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
|
|
||||||
private val unread = Item.CheckboxGroup(R.string.action_filter_unread, this)
|
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)
|
override val header = Item.Header(R.string.action_filter)
|
||||||
|
|
||||||
@ -83,6 +85,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
override fun initModels() {
|
override fun initModels() {
|
||||||
downloaded.checked = preferences.filterDownloaded().getOrDefault()
|
downloaded.checked = preferences.filterDownloaded().getOrDefault()
|
||||||
unread.checked = preferences.filterUnread().getOrDefault()
|
unread.checked = preferences.filterUnread().getOrDefault()
|
||||||
|
completed.checked = preferences.filterCompleted().getOrDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClicked(item: Item) {
|
override fun onItemClicked(item: Item) {
|
||||||
@ -91,6 +94,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
when (item) {
|
when (item) {
|
||||||
downloaded -> preferences.filterDownloaded().set(item.checked)
|
downloaded -> preferences.filterDownloaded().set(item.checked)
|
||||||
unread -> preferences.filterUnread().set(item.checked)
|
unread -> preferences.filterUnread().set(item.checked)
|
||||||
|
completed -> preferences.filterCompleted().set(item.checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.notifyItemChanged(item)
|
adapter.notifyItemChanged(item)
|
||||||
|
@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.util.combineLatest
|
import eu.kanade.tachiyomi.util.combineLatest
|
||||||
@ -101,6 +102,8 @@ class LibraryPresenter(
|
|||||||
|
|
||||||
val filterUnread = preferences.filterUnread().getOrDefault()
|
val filterUnread = preferences.filterUnread().getOrDefault()
|
||||||
|
|
||||||
|
val filterCompleted = preferences.filterCompleted().getOrDefault()
|
||||||
|
|
||||||
val filterFn: (Manga) -> Boolean = f@ { manga ->
|
val filterFn: (Manga) -> Boolean = f@ { manga ->
|
||||||
// Filter out manga without source.
|
// Filter out manga without source.
|
||||||
val source = sourceManager.get(manga.source) ?: return@f false
|
val source = sourceManager.get(manga.source) ?: return@f false
|
||||||
@ -110,6 +113,10 @@ class LibraryPresenter(
|
|||||||
return@f false
|
return@f false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filterCompleted && manga.status != SManga.COMPLETED) {
|
||||||
|
return@f false
|
||||||
|
}
|
||||||
|
|
||||||
// Filter when the download directory doesn't exist or is null.
|
// Filter when the download directory doesn't exist or is null.
|
||||||
if (filterDownloaded) {
|
if (filterDownloaded) {
|
||||||
// Get the directories for the source of the manga.
|
// Get the directories for the source of the manga.
|
||||||
|
Loading…
Reference in New Issue
Block a user