Remove redundant preference keys

This commit is contained in:
arkon 2022-09-20 00:13:33 -04:00
parent c2a831dded
commit 2b089648a3
11 changed files with 149 additions and 213 deletions

View File

@ -13,64 +13,64 @@ class LibraryPreferences(
private val preferenceStore: PreferenceStore, private val preferenceStore: PreferenceStore,
) { ) {
fun libraryDisplayMode() = this.preferenceStore.getObject("pref_display_mode_library", LibraryDisplayMode.default, LibraryDisplayMode.Serializer::serialize, LibraryDisplayMode.Serializer::deserialize) fun libraryDisplayMode() = preferenceStore.getObject("pref_display_mode_library", LibraryDisplayMode.default, LibraryDisplayMode.Serializer::serialize, LibraryDisplayMode.Serializer::deserialize)
fun librarySortingMode() = this.preferenceStore.getObject("library_sorting_mode", LibrarySort.default, LibrarySort.Serializer::serialize, LibrarySort.Serializer::deserialize) fun librarySortingMode() = preferenceStore.getObject("library_sorting_mode", LibrarySort.default, LibrarySort.Serializer::serialize, LibrarySort.Serializer::deserialize)
fun portraitColumns() = this.preferenceStore.getInt("pref_library_columns_portrait_key", 0) fun portraitColumns() = preferenceStore.getInt("pref_library_columns_portrait_key", 0)
fun landscapeColumns() = this.preferenceStore.getInt("pref_library_columns_landscape_key", 0) fun landscapeColumns() = preferenceStore.getInt("pref_library_columns_landscape_key", 0)
fun libraryUpdateInterval() = this.preferenceStore.getInt("pref_library_update_interval_key", 24) fun libraryUpdateInterval() = preferenceStore.getInt("pref_library_update_interval_key", 24)
fun libraryUpdateLastTimestamp() = this.preferenceStore.getLong("library_update_last_timestamp", 0L) fun libraryUpdateLastTimestamp() = preferenceStore.getLong("library_update_last_timestamp", 0L)
fun libraryUpdateDeviceRestriction() = this.preferenceStore.getStringSet("library_update_restriction", setOf(DEVICE_ONLY_ON_WIFI)) fun libraryUpdateDeviceRestriction() = preferenceStore.getStringSet("library_update_restriction", setOf(DEVICE_ONLY_ON_WIFI))
fun libraryUpdateMangaRestriction() = this.preferenceStore.getStringSet("library_update_manga_restriction", setOf(MANGA_HAS_UNREAD, MANGA_NON_COMPLETED, MANGA_NON_READ)) fun libraryUpdateMangaRestriction() = preferenceStore.getStringSet("library_update_manga_restriction", setOf(MANGA_HAS_UNREAD, MANGA_NON_COMPLETED, MANGA_NON_READ))
// region Filter // region Filter
fun filterDownloaded() = this.preferenceStore.getInt("pref_filter_library_downloaded", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) fun filterDownloaded() = preferenceStore.getInt("pref_filter_library_downloaded", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
fun filterUnread() = this.preferenceStore.getInt("pref_filter_library_unread", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) fun filterUnread() = preferenceStore.getInt("pref_filter_library_unread", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
fun filterStarted() = this.preferenceStore.getInt("pref_filter_library_started", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) fun filterStarted() = preferenceStore.getInt("pref_filter_library_started", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
fun filterCompleted() = this.preferenceStore.getInt("pref_filter_library_completed", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) fun filterCompleted() = preferenceStore.getInt("pref_filter_library_completed", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
fun filterTracking(name: Int) = this.preferenceStore.getInt("pref_filter_library_tracked_$name", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) fun filterTracking(name: Int) = preferenceStore.getInt("pref_filter_library_tracked_$name", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
// endregion // endregion
// region Badges // region Badges
fun downloadBadge() = this.preferenceStore.getBoolean("display_download_badge", false) fun downloadBadge() = preferenceStore.getBoolean("display_download_badge", false)
fun localBadge() = this.preferenceStore.getBoolean("display_local_badge", true) fun localBadge() = preferenceStore.getBoolean("display_local_badge", true)
fun unreadBadge() = this.preferenceStore.getBoolean("display_unread_badge", true) fun unreadBadge() = preferenceStore.getBoolean("display_unread_badge", true)
fun languageBadge() = this.preferenceStore.getBoolean("display_language_badge", false) fun languageBadge() = preferenceStore.getBoolean("display_language_badge", false)
fun showUpdatesNavBadge() = this.preferenceStore.getBoolean("library_update_show_tab_badge", false) fun showUpdatesNavBadge() = preferenceStore.getBoolean("library_update_show_tab_badge", false)
fun unreadUpdatesCount() = this.preferenceStore.getInt("library_unread_updates_count", 0) fun unreadUpdatesCount() = preferenceStore.getInt("library_unread_updates_count", 0)
// endregion // endregion
// region Category // region Category
fun defaultCategory() = this.preferenceStore.getInt("default_category", -1) fun defaultCategory() = preferenceStore.getInt("default_category", -1)
fun lastUsedCategory() = this.preferenceStore.getInt("last_used_category", 0) fun lastUsedCategory() = preferenceStore.getInt("last_used_category", 0)
fun categoryTabs() = this.preferenceStore.getBoolean("display_category_tabs", true) fun categoryTabs() = preferenceStore.getBoolean("display_category_tabs", true)
fun categoryNumberOfItems() = this.preferenceStore.getBoolean("display_number_of_items", false) fun categoryNumberOfItems() = preferenceStore.getBoolean("display_number_of_items", false)
fun categorizedDisplaySettings() = this.preferenceStore.getBoolean("categorized_display", false) fun categorizedDisplaySettings() = preferenceStore.getBoolean("categorized_display", false)
fun libraryUpdateCategories() = this.preferenceStore.getStringSet("library_update_categories", emptySet()) fun libraryUpdateCategories() = preferenceStore.getStringSet("library_update_categories", emptySet())
fun libraryUpdateCategoriesExclude() = this.preferenceStore.getStringSet("library_update_categories_exclude", emptySet()) fun libraryUpdateCategoriesExclude() = preferenceStore.getStringSet("library_update_categories_exclude", emptySet())
// endregion // endregion
} }

View File

@ -10,27 +10,27 @@ class SourcePreferences(
private val preferenceStore: PreferenceStore, private val preferenceStore: PreferenceStore,
) { ) {
fun sourceDisplayMode() = this.preferenceStore.getObject("pref_display_mode_catalogue", LibraryDisplayMode.default, LibraryDisplayMode.Serializer::serialize, LibraryDisplayMode.Serializer::deserialize) fun sourceDisplayMode() = preferenceStore.getObject("pref_display_mode_catalogue", LibraryDisplayMode.default, LibraryDisplayMode.Serializer::serialize, LibraryDisplayMode.Serializer::deserialize)
fun enabledLanguages() = this.preferenceStore.getStringSet("source_languages", LocaleHelper.getDefaultEnabledLanguages()) fun enabledLanguages() = preferenceStore.getStringSet("source_languages", LocaleHelper.getDefaultEnabledLanguages())
fun disabledSources() = this.preferenceStore.getStringSet("hidden_catalogues", emptySet()) fun disabledSources() = preferenceStore.getStringSet("hidden_catalogues", emptySet())
fun pinnedSources() = this.preferenceStore.getStringSet("pinned_catalogues", emptySet()) fun pinnedSources() = preferenceStore.getStringSet("pinned_catalogues", emptySet())
fun duplicatePinnedSources() = this.preferenceStore.getBoolean("duplicate_pinned_sources", false) fun duplicatePinnedSources() = preferenceStore.getBoolean("duplicate_pinned_sources", false)
fun lastUsedSource() = this.preferenceStore.getLong("last_catalogue_source", -1) fun lastUsedSource() = preferenceStore.getLong("last_catalogue_source", -1)
fun showNsfwSource() = this.preferenceStore.getBoolean("show_nsfw_source", true) fun showNsfwSource() = preferenceStore.getBoolean("show_nsfw_source", true)
fun migrationSortingMode() = this.preferenceStore.getEnum("pref_migration_sorting", SetMigrateSorting.Mode.ALPHABETICAL) fun migrationSortingMode() = preferenceStore.getEnum("pref_migration_sorting", SetMigrateSorting.Mode.ALPHABETICAL)
fun migrationSortingDirection() = this.preferenceStore.getEnum("pref_migration_direction", SetMigrateSorting.Direction.ASCENDING) fun migrationSortingDirection() = preferenceStore.getEnum("pref_migration_direction", SetMigrateSorting.Direction.ASCENDING)
fun extensionUpdatesCount() = this.preferenceStore.getInt("ext_updates_count", 0) fun extensionUpdatesCount() = preferenceStore.getInt("ext_updates_count", 0)
fun trustedSignatures() = this.preferenceStore.getStringSet("trusted_signatures", emptySet()) fun trustedSignatures() = preferenceStore.getStringSet("trusted_signatures", emptySet())
fun searchPinnedSourcesOnly() = this.preferenceStore.getBoolean("search_pinned_sources_only", false) fun searchPinnedSourcesOnly() = preferenceStore.getBoolean("search_pinned_sources_only", false)
} }

View File

@ -5,50 +5,8 @@ package eu.kanade.tachiyomi.data.preference
*/ */
object PreferenceKeys { object PreferenceKeys {
const val confirmExit = "pref_confirm_exit"
const val showReadingMode = "pref_show_reading_mode"
const val defaultReadingMode = "pref_default_reading_mode_key"
const val defaultOrientationType = "pref_default_orientation_type_key"
const val autoUpdateTrack = "pref_auto_update_manga_sync_key"
const val downloadOnlyOverWifi = "pref_download_only_over_wifi_key"
const val folderPerManga = "create_folder_per_manga"
const val removeAfterReadSlots = "remove_after_read_slots"
const val removeAfterMarkedAsRead = "pref_remove_after_marked_as_read_key"
const val removeBookmarkedChapters = "pref_remove_bookmarked"
const val autoUpdateMetadata = "auto_update_metadata"
const val autoUpdateTrackers = "auto_update_trackers"
const val dateFormat = "app_date_format" const val dateFormat = "app_date_format"
const val skipRead = "skip_read"
const val skipFiltered = "skip_filtered"
const val defaultChapterFilterByRead = "default_chapter_filter_by_read"
const val defaultChapterFilterByDownloaded = "default_chapter_filter_by_downloaded"
const val defaultChapterFilterByBookmarked = "default_chapter_filter_by_bookmarked"
const val defaultChapterSortBySourceOrNumber = "default_chapter_sort_by_source_or_number" // and upload date
const val defaultChapterSortByAscendingOrDescending = "default_chapter_sort_by_ascending_or_descending"
const val defaultChapterDisplayByNameOrNumber = "default_chapter_display_by_name_or_number"
const val autoClearChapterCache = "auto_clear_chapter_cache"
fun trackUsername(syncId: Long) = "pref_mangasync_username_$syncId" fun trackUsername(syncId: Long) = "pref_mangasync_username_$syncId"
fun trackPassword(syncId: Long) = "pref_mangasync_password_$syncId" fun trackPassword(syncId: Long) = "pref_mangasync_password_$syncId"

View File

@ -39,198 +39,199 @@ class PreferencesHelper(
"backup", "backup",
).toUri() ).toUri()
fun confirmExit() = this.preferenceStore.getBoolean(Keys.confirmExit, false) fun confirmExit() = preferenceStore.getBoolean("pref_confirm_exit", false)
fun sideNavIconAlignment() = this.preferenceStore.getInt("pref_side_nav_icon_alignment", 0) fun sideNavIconAlignment() = preferenceStore.getInt("pref_side_nav_icon_alignment", 0)
fun autoUpdateMetadata() = this.preferenceStore.getBoolean(Keys.autoUpdateMetadata, false) fun autoUpdateMetadata() = preferenceStore.getBoolean("auto_update_metadata", false)
fun autoUpdateTrackers() = this.preferenceStore.getBoolean(Keys.autoUpdateTrackers, false) fun autoUpdateTrackers() = preferenceStore.getBoolean("auto_update_trackers", false)
fun themeMode() = this.preferenceStore.getEnum( fun themeMode() = preferenceStore.getEnum(
"pref_theme_mode_key", "pref_theme_mode_key",
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Values.ThemeMode.system } else { Values.ThemeMode.light }, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Values.ThemeMode.system } else { Values.ThemeMode.light },
) )
fun appTheme() = this.preferenceStore.getEnum( fun appTheme() = preferenceStore.getEnum(
"pref_app_theme", "pref_app_theme",
if (DeviceUtil.isDynamicColorAvailable) { Values.AppTheme.MONET } else { Values.AppTheme.DEFAULT }, if (DeviceUtil.isDynamicColorAvailable) { Values.AppTheme.MONET } else { Values.AppTheme.DEFAULT },
) )
fun themeDarkAmoled() = this.preferenceStore.getBoolean("pref_theme_dark_amoled_key", false) fun themeDarkAmoled() = preferenceStore.getBoolean("pref_theme_dark_amoled_key", false)
fun pageTransitions() = this.preferenceStore.getBoolean("pref_enable_transitions_key", true) fun pageTransitions() = preferenceStore.getBoolean("pref_enable_transitions_key", true)
fun doubleTapAnimSpeed() = this.preferenceStore.getInt("pref_double_tap_anim_speed", 500) fun doubleTapAnimSpeed() = preferenceStore.getInt("pref_double_tap_anim_speed", 500)
fun showPageNumber() = this.preferenceStore.getBoolean("pref_show_page_number_key", true) fun showPageNumber() = preferenceStore.getBoolean("pref_show_page_number_key", true)
fun dualPageSplitPaged() = this.preferenceStore.getBoolean("pref_dual_page_split", false) fun dualPageSplitPaged() = preferenceStore.getBoolean("pref_dual_page_split", false)
fun dualPageInvertPaged() = this.preferenceStore.getBoolean("pref_dual_page_invert", false) fun dualPageInvertPaged() = preferenceStore.getBoolean("pref_dual_page_invert", false)
fun dualPageSplitWebtoon() = this.preferenceStore.getBoolean("pref_dual_page_split_webtoon", false) fun dualPageSplitWebtoon() = preferenceStore.getBoolean("pref_dual_page_split_webtoon", false)
fun dualPageInvertWebtoon() = this.preferenceStore.getBoolean("pref_dual_page_invert_webtoon", false) fun dualPageInvertWebtoon() = preferenceStore.getBoolean("pref_dual_page_invert_webtoon", false)
fun longStripSplitWebtoon() = this.preferenceStore.getBoolean("pref_long_strip_split_webtoon", true) fun longStripSplitWebtoon() = preferenceStore.getBoolean("pref_long_strip_split_webtoon", true)
fun showReadingMode() = this.preferenceStore.getBoolean(Keys.showReadingMode, true) fun showReadingMode() = preferenceStore.getBoolean("pref_show_reading_mode", true)
fun trueColor() = this.preferenceStore.getBoolean("pref_true_color_key", false) fun trueColor() = preferenceStore.getBoolean("pref_true_color_key", false)
fun fullscreen() = this.preferenceStore.getBoolean("fullscreen", true) fun fullscreen() = preferenceStore.getBoolean("fullscreen", true)
fun cutoutShort() = this.preferenceStore.getBoolean("cutout_short", true) fun cutoutShort() = preferenceStore.getBoolean("cutout_short", true)
fun keepScreenOn() = this.preferenceStore.getBoolean("pref_keep_screen_on_key", true) fun keepScreenOn() = preferenceStore.getBoolean("pref_keep_screen_on_key", true)
fun customBrightness() = this.preferenceStore.getBoolean("pref_custom_brightness_key", false) fun customBrightness() = preferenceStore.getBoolean("pref_custom_brightness_key", false)
fun customBrightnessValue() = this.preferenceStore.getInt("custom_brightness_value", 0) fun customBrightnessValue() = preferenceStore.getInt("custom_brightness_value", 0)
fun colorFilter() = this.preferenceStore.getBoolean("pref_color_filter_key", false) fun colorFilter() = preferenceStore.getBoolean("pref_color_filter_key", false)
fun colorFilterValue() = this.preferenceStore.getInt("color_filter_value", 0) fun colorFilterValue() = preferenceStore.getInt("color_filter_value", 0)
fun colorFilterMode() = this.preferenceStore.getInt("color_filter_mode", 0) fun colorFilterMode() = preferenceStore.getInt("color_filter_mode", 0)
fun grayscale() = this.preferenceStore.getBoolean("pref_grayscale", false) fun grayscale() = preferenceStore.getBoolean("pref_grayscale", false)
fun invertedColors() = this.preferenceStore.getBoolean("pref_inverted_colors", false) fun invertedColors() = preferenceStore.getBoolean("pref_inverted_colors", false)
fun defaultReadingMode() = this.preferenceStore.getInt(Keys.defaultReadingMode, ReadingModeType.RIGHT_TO_LEFT.flagValue) fun defaultReadingMode() = preferenceStore.getInt("pref_default_reading_mode_key", ReadingModeType.RIGHT_TO_LEFT.flagValue)
fun defaultOrientationType() = this.preferenceStore.getInt(Keys.defaultOrientationType, OrientationType.FREE.flagValue) fun defaultOrientationType() = preferenceStore.getInt("pref_default_orientation_type_key", OrientationType.FREE.flagValue)
fun imageScaleType() = this.preferenceStore.getInt("pref_image_scale_type_key", 1) fun imageScaleType() = preferenceStore.getInt("pref_image_scale_type_key", 1)
fun zoomStart() = this.preferenceStore.getInt("pref_zoom_start_key", 1) fun zoomStart() = preferenceStore.getInt("pref_zoom_start_key", 1)
fun readerTheme() = this.preferenceStore.getInt("pref_reader_theme_key", 1) fun readerTheme() = preferenceStore.getInt("pref_reader_theme_key", 1)
fun alwaysShowChapterTransition() = this.preferenceStore.getBoolean("always_show_chapter_transition", true) fun alwaysShowChapterTransition() = preferenceStore.getBoolean("always_show_chapter_transition", true)
fun cropBorders() = this.preferenceStore.getBoolean("crop_borders", false) fun cropBorders() = preferenceStore.getBoolean("crop_borders", false)
fun navigateToPan() = this.preferenceStore.getBoolean("navigate_pan", true) fun navigateToPan() = preferenceStore.getBoolean("navigate_pan", true)
fun landscapeZoom() = this.preferenceStore.getBoolean("landscape_zoom", true) fun landscapeZoom() = preferenceStore.getBoolean("landscape_zoom", true)
fun cropBordersWebtoon() = this.preferenceStore.getBoolean("crop_borders_webtoon", false) fun cropBordersWebtoon() = preferenceStore.getBoolean("crop_borders_webtoon", false)
fun webtoonSidePadding() = this.preferenceStore.getInt("webtoon_side_padding", 0) fun webtoonSidePadding() = preferenceStore.getInt("webtoon_side_padding", 0)
fun pagerNavInverted() = this.preferenceStore.getEnum("reader_tapping_inverted", Values.TappingInvertMode.NONE) fun pagerNavInverted() = preferenceStore.getEnum("reader_tapping_inverted", Values.TappingInvertMode.NONE)
fun webtoonNavInverted() = this.preferenceStore.getEnum("reader_tapping_inverted_webtoon", Values.TappingInvertMode.NONE) fun webtoonNavInverted() = preferenceStore.getEnum("reader_tapping_inverted_webtoon", Values.TappingInvertMode.NONE)
fun readWithLongTap() = this.preferenceStore.getBoolean("reader_long_tap", true) fun readWithLongTap() = preferenceStore.getBoolean("reader_long_tap", true)
fun readWithVolumeKeys() = this.preferenceStore.getBoolean("reader_volume_keys", false) fun readWithVolumeKeys() = preferenceStore.getBoolean("reader_volume_keys", false)
fun readWithVolumeKeysInverted() = this.preferenceStore.getBoolean("reader_volume_keys_inverted", false) fun readWithVolumeKeysInverted() = preferenceStore.getBoolean("reader_volume_keys_inverted", false)
fun navigationModePager() = this.preferenceStore.getInt("reader_navigation_mode_pager", 0) fun navigationModePager() = preferenceStore.getInt("reader_navigation_mode_pager", 0)
fun navigationModeWebtoon() = this.preferenceStore.getInt("reader_navigation_mode_webtoon", 0) fun navigationModeWebtoon() = preferenceStore.getInt("reader_navigation_mode_webtoon", 0)
fun showNavigationOverlayNewUser() = this.preferenceStore.getBoolean("reader_navigation_overlay_new_user", true) fun showNavigationOverlayNewUser() = preferenceStore.getBoolean("reader_navigation_overlay_new_user", true)
fun showNavigationOverlayOnStart() = this.preferenceStore.getBoolean("reader_navigation_overlay_on_start", false) fun showNavigationOverlayOnStart() = preferenceStore.getBoolean("reader_navigation_overlay_on_start", false)
fun readerHideThreshold() = this.preferenceStore.getEnum("reader_hide_threshold", Values.ReaderHideThreshold.LOW) fun readerHideThreshold() = preferenceStore.getEnum("reader_hide_threshold", Values.ReaderHideThreshold.LOW)
fun autoUpdateTrack() = this.preferenceStore.getBoolean(Keys.autoUpdateTrack, true) fun autoUpdateTrack() = preferenceStore.getBoolean("pref_auto_update_manga_sync_key", true)
fun lastVersionCode() = this.preferenceStore.getInt("last_version_code", 0) fun lastVersionCode() = preferenceStore.getInt("last_version_code", 0)
fun trackUsername(sync: TrackService) = this.preferenceStore.getString(Keys.trackUsername(sync.id), "") fun trackUsername(sync: TrackService) = preferenceStore.getString(Keys.trackUsername(sync.id), "")
fun trackPassword(sync: TrackService) = this.preferenceStore.getString(Keys.trackPassword(sync.id), "") fun trackPassword(sync: TrackService) = preferenceStore.getString(Keys.trackPassword(sync.id), "")
fun setTrackCredentials(sync: TrackService, username: String, password: String) { fun setTrackCredentials(sync: TrackService, username: String, password: String) {
trackUsername(sync).set(username) trackUsername(sync).set(username)
trackPassword(sync).set(password) trackPassword(sync).set(password)
} }
fun trackToken(sync: TrackService) = this.preferenceStore.getString(Keys.trackToken(sync.id), "") fun trackToken(sync: TrackService) = preferenceStore.getString(Keys.trackToken(sync.id), "")
fun anilistScoreType() = this.preferenceStore.getString("anilist_score_type", Anilist.POINT_10) fun anilistScoreType() = preferenceStore.getString("anilist_score_type", Anilist.POINT_10)
fun backupsDirectory() = this.preferenceStore.getString("backup_directory", defaultBackupDir.toString()) fun backupsDirectory() = preferenceStore.getString("backup_directory", defaultBackupDir.toString())
fun relativeTime() = this.preferenceStore.getInt("relative_time", 7) fun relativeTime() = preferenceStore.getInt("relative_time", 7)
fun dateFormat(format: String = this.preferenceStore.getString(Keys.dateFormat, "").get()): DateFormat = when (format) { fun dateFormat(format: String = preferenceStore.getString(Keys.dateFormat, "").get()): DateFormat = when (format) {
"" -> DateFormat.getDateInstance(DateFormat.SHORT) "" -> DateFormat.getDateInstance(DateFormat.SHORT)
else -> SimpleDateFormat(format, Locale.getDefault()) else -> SimpleDateFormat(format, Locale.getDefault())
} }
fun downloadsDirectory() = this.preferenceStore.getString("download_directory", defaultDownloadsDir.toString()) fun downloadsDirectory() = preferenceStore.getString("download_directory", defaultDownloadsDir.toString())
fun downloadOnlyOverWifi() = this.preferenceStore.getBoolean(Keys.downloadOnlyOverWifi, true) fun downloadOnlyOverWifi() = preferenceStore.getBoolean("pref_download_only_over_wifi_key", true)
fun saveChaptersAsCBZ() = this.preferenceStore.getBoolean("save_chapter_as_cbz", true) fun saveChaptersAsCBZ() = preferenceStore.getBoolean("save_chapter_as_cbz", true)
fun splitTallImages() = this.preferenceStore.getBoolean("split_tall_images", false) fun splitTallImages() = preferenceStore.getBoolean("split_tall_images", false)
fun folderPerManga() = this.preferenceStore.getBoolean(Keys.folderPerManga, false) fun folderPerManga() = preferenceStore.getBoolean("create_folder_per_manga", false)
fun numberOfBackups() = this.preferenceStore.getInt("backup_slots", 2) fun numberOfBackups() = preferenceStore.getInt("backup_slots", 2)
fun backupInterval() = this.preferenceStore.getInt("backup_interval", 12) fun backupInterval() = preferenceStore.getInt("backup_interval", 12)
fun removeAfterReadSlots() = this.preferenceStore.getInt(Keys.removeAfterReadSlots, -1) fun removeAfterReadSlots() = preferenceStore.getInt("remove_after_read_slots", -1)
fun removeAfterMarkedAsRead() = this.preferenceStore.getBoolean(Keys.removeAfterMarkedAsRead, false) fun removeAfterMarkedAsRead() = preferenceStore.getBoolean("pref_remove_after_marked_as_read_key", false)
fun removeBookmarkedChapters() = this.preferenceStore.getBoolean(Keys.removeBookmarkedChapters, false) fun removeBookmarkedChapters() = preferenceStore.getBoolean("pref_remove_bookmarked", false)
fun removeExcludeCategories() = this.preferenceStore.getStringSet("remove_exclude_categories", emptySet()) fun removeExcludeCategories() = preferenceStore.getStringSet("remove_exclude_categories", emptySet())
fun downloadedOnly() = this.preferenceStore.getBoolean("pref_downloaded_only", false) fun downloadedOnly() = preferenceStore.getBoolean("pref_downloaded_only", false)
fun automaticExtUpdates() = this.preferenceStore.getBoolean("automatic_ext_updates", true) fun automaticExtUpdates() = preferenceStore.getBoolean("automatic_ext_updates", true)
fun lastAppCheck() = this.preferenceStore.getLong("last_app_check", 0) fun lastAppCheck() = preferenceStore.getLong("last_app_check", 0)
fun lastExtCheck() = this.preferenceStore.getLong("last_ext_check", 0) fun lastExtCheck() = preferenceStore.getLong("last_ext_check", 0)
fun downloadNewChapters() = this.preferenceStore.getBoolean("download_new", false) fun downloadNewChapters() = preferenceStore.getBoolean("download_new", false)
fun downloadNewChapterCategories() = this.preferenceStore.getStringSet("download_new_categories", emptySet()) fun downloadNewChapterCategories() = preferenceStore.getStringSet("download_new_categories", emptySet())
fun downloadNewChapterCategoriesExclude() = this.preferenceStore.getStringSet("download_new_categories_exclude", emptySet()) fun downloadNewChapterCategoriesExclude() = preferenceStore.getStringSet("download_new_categories_exclude", emptySet())
fun autoDownloadWhileReading() = this.preferenceStore.getInt("auto_download_while_reading", 0) fun autoDownloadWhileReading() = preferenceStore.getInt("auto_download_while_reading", 0)
fun skipRead() = this.preferenceStore.getBoolean(Keys.skipRead, false) fun skipRead() = preferenceStore.getBoolean("skip_read", false)
fun skipFiltered() = this.preferenceStore.getBoolean(Keys.skipFiltered, true) fun skipFiltered() = preferenceStore.getBoolean("skip_filtered", true)
fun migrateFlags() = this.preferenceStore.getInt("migrate_flags", Int.MAX_VALUE) fun migrateFlags() = preferenceStore.getInt("migrate_flags", Int.MAX_VALUE)
fun filterChapterByRead() = this.preferenceStore.getInt(Keys.defaultChapterFilterByRead, DomainManga.SHOW_ALL.toInt()) fun filterChapterByRead() = preferenceStore.getInt("default_chapter_filter_by_read", DomainManga.SHOW_ALL.toInt())
fun filterChapterByDownloaded() = this.preferenceStore.getInt(Keys.defaultChapterFilterByDownloaded, DomainManga.SHOW_ALL.toInt()) fun filterChapterByDownloaded() = preferenceStore.getInt("default_chapter_filter_by_downloaded", DomainManga.SHOW_ALL.toInt())
fun filterChapterByBookmarked() = this.preferenceStore.getInt(Keys.defaultChapterFilterByBookmarked, DomainManga.SHOW_ALL.toInt()) fun filterChapterByBookmarked() = preferenceStore.getInt("default_chapter_filter_by_bookmarked", DomainManga.SHOW_ALL.toInt())
fun sortChapterBySourceOrNumber() = this.preferenceStore.getInt(Keys.defaultChapterSortBySourceOrNumber, DomainManga.CHAPTER_SORTING_SOURCE.toInt()) // and upload date
fun sortChapterBySourceOrNumber() = preferenceStore.getInt("default_chapter_sort_by_source_or_number", DomainManga.CHAPTER_SORTING_SOURCE.toInt())
fun displayChapterByNameOrNumber() = this.preferenceStore.getInt(Keys.defaultChapterDisplayByNameOrNumber, DomainManga.CHAPTER_DISPLAY_NAME.toInt()) fun displayChapterByNameOrNumber() = preferenceStore.getInt("default_chapter_display_by_name_or_number", DomainManga.CHAPTER_DISPLAY_NAME.toInt())
fun sortChapterByAscendingOrDescending() = this.preferenceStore.getInt(Keys.defaultChapterSortByAscendingOrDescending, DomainManga.CHAPTER_SORT_DESC.toInt()) fun sortChapterByAscendingOrDescending() = preferenceStore.getInt("default_chapter_sort_by_ascending_or_descending", DomainManga.CHAPTER_SORT_DESC.toInt())
fun incognitoMode() = this.preferenceStore.getBoolean("incognito_mode", false) fun incognitoMode() = preferenceStore.getBoolean("incognito_mode", false)
fun tabletUiMode() = this.preferenceStore.getEnum("tablet_ui_mode", Values.TabletUiMode.AUTOMATIC) fun tabletUiMode() = preferenceStore.getEnum("tablet_ui_mode", Values.TabletUiMode.AUTOMATIC)
fun extensionInstaller() = this.preferenceStore.getEnum( fun extensionInstaller() = preferenceStore.getEnum(
"extension_installer", "extension_installer",
if (DeviceUtil.isMiui) Values.ExtensionInstaller.LEGACY else Values.ExtensionInstaller.PACKAGEINSTALLER, if (DeviceUtil.isMiui) Values.ExtensionInstaller.LEGACY else Values.ExtensionInstaller.PACKAGEINSTALLER,
) )
fun autoClearChapterCache() = this.preferenceStore.getBoolean(Keys.autoClearChapterCache, false) fun autoClearChapterCache() = preferenceStore.getBoolean("auto_clear_chapter_cache", false)
fun setChapterSettingsDefault(manga: Manga) { fun setChapterSettingsDefault(manga: Manga) {
filterChapterByRead().set(manga.readFilter) filterChapterByRead().set(manga.readFilter)

View File

@ -61,7 +61,6 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.io.File import java.io.File
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
class SettingsAdvancedController( class SettingsAdvancedController(
private val mangaRepository: MangaRepository = Injekt.get(), private val mangaRepository: MangaRepository = Injekt.get(),
@ -157,9 +156,8 @@ class SettingsAdvancedController(
onClick { clearChapterCache() } onClick { clearChapterCache() }
} }
switchPreference { switchPreference {
key = Keys.autoClearChapterCache bindTo(preferences.autoClearChapterCache())
titleRes = R.string.pref_auto_clear_chapter_cache titleRes = R.string.pref_auto_clear_chapter_cache
defaultValue = false
} }
preference { preference {
key = "pref_clear_database" key = "pref_clear_database"

View File

@ -17,7 +17,6 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.util.preference.bindTo import eu.kanade.tachiyomi.util.preference.bindTo
import eu.kanade.tachiyomi.util.preference.defaultValue
import eu.kanade.tachiyomi.util.preference.entriesRes import eu.kanade.tachiyomi.util.preference.entriesRes
import eu.kanade.tachiyomi.util.preference.infoPreference import eu.kanade.tachiyomi.util.preference.infoPreference
import eu.kanade.tachiyomi.util.preference.intListPreference import eu.kanade.tachiyomi.util.preference.intListPreference
@ -38,7 +37,6 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.io.File import java.io.File
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
class SettingsDownloadController : SettingsController() { class SettingsDownloadController : SettingsController() {
@ -66,9 +64,8 @@ class SettingsDownloadController : SettingsController() {
.launchIn(viewScope) .launchIn(viewScope)
} }
switchPreference { switchPreference {
key = Keys.downloadOnlyOverWifi bindTo(preferences.downloadOnlyOverWifi())
titleRes = R.string.connected_to_wifi titleRes = R.string.connected_to_wifi
defaultValue = true
} }
switchPreference { switchPreference {
bindTo(preferences.saveChaptersAsCBZ()) bindTo(preferences.saveChaptersAsCBZ())
@ -84,12 +81,11 @@ class SettingsDownloadController : SettingsController() {
titleRes = R.string.pref_category_delete_chapters titleRes = R.string.pref_category_delete_chapters
switchPreference { switchPreference {
key = Keys.removeAfterMarkedAsRead bindTo(preferences.removeAfterMarkedAsRead())
titleRes = R.string.pref_remove_after_marked_as_read titleRes = R.string.pref_remove_after_marked_as_read
defaultValue = false
} }
intListPreference { intListPreference {
key = Keys.removeAfterReadSlots bindTo(preferences.removeAfterReadSlots())
titleRes = R.string.pref_remove_after_read titleRes = R.string.pref_remove_after_read
entriesRes = arrayOf( entriesRes = arrayOf(
R.string.disabled, R.string.disabled,
@ -100,13 +96,11 @@ class SettingsDownloadController : SettingsController() {
R.string.fifth_to_last, R.string.fifth_to_last,
) )
entryValues = arrayOf("-1", "0", "1", "2", "3", "4") entryValues = arrayOf("-1", "0", "1", "2", "3", "4")
defaultValue = "-1"
summary = "%s" summary = "%s"
} }
switchPreference { switchPreference {
key = Keys.removeBookmarkedChapters bindTo(preferences.removeBookmarkedChapters())
titleRes = R.string.pref_remove_bookmarked_chapters titleRes = R.string.pref_remove_bookmarked_chapters
defaultValue = false
} }
multiSelectListPreference { multiSelectListPreference {
bindTo(preferences.removeExcludeCategories()) bindTo(preferences.removeExcludeCategories())

View File

@ -9,7 +9,6 @@ import androidx.preference.PreferenceScreen
import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.library.service.LibraryPreferences
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.preference.bindTo import eu.kanade.tachiyomi.util.preference.bindTo
import eu.kanade.tachiyomi.util.preference.defaultValue
import eu.kanade.tachiyomi.util.preference.listPreference import eu.kanade.tachiyomi.util.preference.listPreference
import eu.kanade.tachiyomi.util.preference.onChange import eu.kanade.tachiyomi.util.preference.onChange
import eu.kanade.tachiyomi.util.preference.onClick import eu.kanade.tachiyomi.util.preference.onClick
@ -19,7 +18,6 @@ import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.LocaleHelper
import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParser
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
class SettingsGeneralController : SettingsController() { class SettingsGeneralController : SettingsController() {
@ -33,9 +31,8 @@ class SettingsGeneralController : SettingsController() {
titleRes = R.string.pref_library_update_show_tab_badge titleRes = R.string.pref_library_update_show_tab_badge
} }
switchPreference { switchPreference {
key = Keys.confirmExit bindTo(preferences.confirmExit())
titleRes = R.string.pref_confirm_exit titleRes = R.string.pref_confirm_exit
defaultValue = false
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
preference { preference {

View File

@ -47,7 +47,6 @@ import kotlinx.coroutines.runBlocking
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
class SettingsLibraryController : SettingsController() { class SettingsLibraryController : SettingsController() {
@ -278,17 +277,15 @@ class SettingsLibraryController : SettingsController() {
.launchIn(viewScope) .launchIn(viewScope)
} }
switchPreference { switchPreference {
key = Keys.autoUpdateMetadata bindTo(preferences.autoUpdateMetadata())
titleRes = R.string.pref_library_update_refresh_metadata titleRes = R.string.pref_library_update_refresh_metadata
summaryRes = R.string.pref_library_update_refresh_metadata_summary summaryRes = R.string.pref_library_update_refresh_metadata_summary
defaultValue = false
} }
if (trackManager.hasLoggedServices()) { if (trackManager.hasLoggedServices()) {
switchPreference { switchPreference {
key = Keys.autoUpdateTrackers bindTo(preferences.autoUpdateTrackers())
titleRes = R.string.pref_library_update_refresh_trackers titleRes = R.string.pref_library_update_refresh_trackers
summaryRes = R.string.pref_library_update_refresh_trackers_summary summaryRes = R.string.pref_library_update_refresh_trackers_summary
defaultValue = false
} }
} }
} }

View File

@ -8,7 +8,6 @@ import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
import eu.kanade.tachiyomi.util.preference.bindTo import eu.kanade.tachiyomi.util.preference.bindTo
import eu.kanade.tachiyomi.util.preference.defaultValue
import eu.kanade.tachiyomi.util.preference.entriesRes import eu.kanade.tachiyomi.util.preference.entriesRes
import eu.kanade.tachiyomi.util.preference.intListPreference import eu.kanade.tachiyomi.util.preference.intListPreference
import eu.kanade.tachiyomi.util.preference.listPreference import eu.kanade.tachiyomi.util.preference.listPreference
@ -17,7 +16,6 @@ import eu.kanade.tachiyomi.util.preference.summaryRes
import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.hasDisplayCutout import eu.kanade.tachiyomi.util.system.hasDisplayCutout
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
class SettingsReaderController : SettingsController() { class SettingsReaderController : SettingsController() {
@ -25,7 +23,7 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_category_reader titleRes = R.string.pref_category_reader
intListPreference { intListPreference {
key = Keys.defaultReadingMode bindTo(preferences.defaultReadingMode())
titleRes = R.string.pref_viewer_type titleRes = R.string.pref_viewer_type
entriesRes = arrayOf( entriesRes = arrayOf(
R.string.left_to_right_viewer, R.string.left_to_right_viewer,
@ -36,7 +34,6 @@ class SettingsReaderController : SettingsController() {
) )
entryValues = ReadingModeType.values().drop(1) entryValues = ReadingModeType.values().drop(1)
.map { value -> "${value.flagValue}" }.toTypedArray() .map { value -> "${value.flagValue}" }.toTypedArray()
defaultValue = "${ReadingModeType.RIGHT_TO_LEFT.flagValue}"
summary = "%s" summary = "%s"
} }
intListPreference { intListPreference {
@ -47,10 +44,9 @@ class SettingsReaderController : SettingsController() {
summary = "%s" summary = "%s"
} }
switchPreference { switchPreference {
key = Keys.showReadingMode bindTo(preferences.showReadingMode())
titleRes = R.string.pref_show_reading_mode titleRes = R.string.pref_show_reading_mode
summaryRes = R.string.pref_show_reading_mode_summary summaryRes = R.string.pref_show_reading_mode_summary
defaultValue = true
} }
switchPreference { switchPreference {
bindTo(preferences.showNavigationOverlayOnStart()) bindTo(preferences.showNavigationOverlayOnStart())
@ -73,7 +69,7 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_category_display titleRes = R.string.pref_category_display
intListPreference { intListPreference {
key = Keys.defaultOrientationType bindTo(preferences.defaultOrientationType())
titleRes = R.string.pref_rotation_type titleRes = R.string.pref_rotation_type
entriesRes = arrayOf( entriesRes = arrayOf(
R.string.rotation_free, R.string.rotation_free,
@ -85,7 +81,6 @@ class SettingsReaderController : SettingsController() {
) )
entryValues = OrientationType.values().drop(1) entryValues = OrientationType.values().drop(1)
.map { value -> "${value.flagValue}" }.toTypedArray() .map { value -> "${value.flagValue}" }.toTypedArray()
defaultValue = "${OrientationType.FREE.flagValue}"
summary = "%s" summary = "%s"
} }
intListPreference { intListPreference {
@ -123,14 +118,12 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_category_reading titleRes = R.string.pref_category_reading
switchPreference { switchPreference {
key = Keys.skipRead bindTo(preferences.skipRead())
titleRes = R.string.pref_skip_read_chapters titleRes = R.string.pref_skip_read_chapters
defaultValue = false
} }
switchPreference { switchPreference {
key = Keys.skipFiltered bindTo(preferences.skipFiltered())
titleRes = R.string.pref_skip_filtered_chapters titleRes = R.string.pref_skip_filtered_chapters
defaultValue = true
} }
switchPreference { switchPreference {
bindTo(preferences.alwaysShowChapterTransition()) bindTo(preferences.alwaysShowChapterTransition())
@ -318,10 +311,9 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_read_with_long_tap titleRes = R.string.pref_read_with_long_tap
} }
switchPreference { switchPreference {
key = Keys.folderPerManga bindTo(preferences.folderPerManga())
titleRes = R.string.pref_create_folder_per_manga titleRes = R.string.pref_create_folder_per_manga
summaryRes = R.string.pref_create_folder_per_manga_summary summaryRes = R.string.pref_create_folder_per_manga_summary
defaultValue = false
} }
} }
} }

View File

@ -19,7 +19,7 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.setting.track.TrackLoginDialog import eu.kanade.tachiyomi.ui.setting.track.TrackLoginDialog
import eu.kanade.tachiyomi.ui.setting.track.TrackLogoutDialog import eu.kanade.tachiyomi.ui.setting.track.TrackLogoutDialog
import eu.kanade.tachiyomi.util.preference.add import eu.kanade.tachiyomi.util.preference.add
import eu.kanade.tachiyomi.util.preference.defaultValue import eu.kanade.tachiyomi.util.preference.bindTo
import eu.kanade.tachiyomi.util.preference.iconRes import eu.kanade.tachiyomi.util.preference.iconRes
import eu.kanade.tachiyomi.util.preference.infoPreference import eu.kanade.tachiyomi.util.preference.infoPreference
import eu.kanade.tachiyomi.util.preference.onClick import eu.kanade.tachiyomi.util.preference.onClick
@ -44,9 +44,8 @@ class SettingsTrackingController :
titleRes = R.string.pref_category_tracking titleRes = R.string.pref_category_tracking
switchPreference { switchPreference {
key = Keys.autoUpdateTrack bindTo(preferences.autoUpdateTrack())
titleRes = R.string.pref_auto_update_manga_sync titleRes = R.string.pref_auto_update_manga_sync
defaultValue = true
} }
preferenceCategory { preferenceCategory {

View File

@ -8,19 +8,19 @@ class SecurityPreferences(
private val preferenceStore: PreferenceStore private val preferenceStore: PreferenceStore
) { ) {
fun useAuthenticator() = this.preferenceStore.getBoolean("use_biometric_lock", false) fun useAuthenticator() = preferenceStore.getBoolean("use_biometric_lock", false)
fun lockAppAfter() = this.preferenceStore.getInt("lock_app_after", 0) fun lockAppAfter() = preferenceStore.getInt("lock_app_after", 0)
fun secureScreen() = this.preferenceStore.getEnum("secure_screen_v2", SecureScreenMode.INCOGNITO) fun secureScreen() = preferenceStore.getEnum("secure_screen_v2", SecureScreenMode.INCOGNITO)
fun hideNotificationContent() = this.preferenceStore.getBoolean("hide_notification_content", false) fun hideNotificationContent() = preferenceStore.getBoolean("hide_notification_content", false)
/** /**
* For app lock. Will be set when there is a pending timed lock. * For app lock. Will be set when there is a pending timed lock.
* Otherwise this pref should be deleted. * Otherwise this pref should be deleted.
*/ */
fun lastAppClosed() = this.preferenceStore.getLong("last_app_closed", 0) fun lastAppClosed() = preferenceStore.getLong("last_app_closed", 0)
enum class SecureScreenMode(val titleResId: Int) { enum class SecureScreenMode(val titleResId: Int) {
ALWAYS(R.string.lock_always), ALWAYS(R.string.lock_always),