LibraryPreferences.kt 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package eu.kanade.domain.library.service
  2. import eu.kanade.domain.library.model.LibraryDisplayMode
  3. import eu.kanade.domain.library.model.LibrarySort
  4. import eu.kanade.tachiyomi.core.preference.PreferenceStore
  5. import eu.kanade.tachiyomi.data.preference.DEVICE_ONLY_ON_WIFI
  6. import eu.kanade.tachiyomi.data.preference.MANGA_HAS_UNREAD
  7. import eu.kanade.tachiyomi.data.preference.MANGA_NON_COMPLETED
  8. import eu.kanade.tachiyomi.data.preference.MANGA_NON_READ
  9. import eu.kanade.tachiyomi.widget.ExtendedNavigationView
  10. class LibraryPreferences(
  11. private val preferenceStore: PreferenceStore,
  12. ) {
  13. fun libraryDisplayMode() = preferenceStore.getObject("pref_display_mode_library", LibraryDisplayMode.default, LibraryDisplayMode.Serializer::serialize, LibraryDisplayMode.Serializer::deserialize)
  14. fun librarySortingMode() = preferenceStore.getObject("library_sorting_mode", LibrarySort.default, LibrarySort.Serializer::serialize, LibrarySort.Serializer::deserialize)
  15. fun portraitColumns() = preferenceStore.getInt("pref_library_columns_portrait_key", 0)
  16. fun landscapeColumns() = preferenceStore.getInt("pref_library_columns_landscape_key", 0)
  17. fun libraryUpdateInterval() = preferenceStore.getInt("pref_library_update_interval_key", 24)
  18. fun libraryUpdateLastTimestamp() = preferenceStore.getLong("library_update_last_timestamp", 0L)
  19. fun libraryUpdateDeviceRestriction() = preferenceStore.getStringSet("library_update_restriction", setOf(DEVICE_ONLY_ON_WIFI))
  20. fun libraryUpdateMangaRestriction() = preferenceStore.getStringSet("library_update_manga_restriction", setOf(MANGA_HAS_UNREAD, MANGA_NON_COMPLETED, MANGA_NON_READ))
  21. // region Filter
  22. fun filterDownloaded() = preferenceStore.getInt("pref_filter_library_downloaded", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
  23. fun filterUnread() = preferenceStore.getInt("pref_filter_library_unread", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
  24. fun filterStarted() = preferenceStore.getInt("pref_filter_library_started", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
  25. fun filterCompleted() = preferenceStore.getInt("pref_filter_library_completed", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
  26. fun filterTracking(name: Int) = preferenceStore.getInt("pref_filter_library_tracked_$name", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
  27. // endregion
  28. // region Badges
  29. fun downloadBadge() = preferenceStore.getBoolean("display_download_badge", false)
  30. fun localBadge() = preferenceStore.getBoolean("display_local_badge", true)
  31. fun unreadBadge() = preferenceStore.getBoolean("display_unread_badge", true)
  32. fun languageBadge() = preferenceStore.getBoolean("display_language_badge", false)
  33. fun showUpdatesNavBadge() = preferenceStore.getBoolean("library_update_show_tab_badge", false)
  34. fun unreadUpdatesCount() = preferenceStore.getInt("library_unread_updates_count", 0)
  35. // endregion
  36. // region Category
  37. fun defaultCategory() = preferenceStore.getInt("default_category", -1)
  38. fun lastUsedCategory() = preferenceStore.getInt("last_used_category", 0)
  39. fun categoryTabs() = preferenceStore.getBoolean("display_category_tabs", true)
  40. fun categoryNumberOfItems() = preferenceStore.getBoolean("display_number_of_items", false)
  41. fun categorizedDisplaySettings() = preferenceStore.getBoolean("categorized_display", false)
  42. fun libraryUpdateCategories() = preferenceStore.getStringSet("library_update_categories", emptySet())
  43. fun libraryUpdateCategoriesExclude() = preferenceStore.getStringSet("library_update_categories_exclude", emptySet())
  44. // endregion
  45. }