From c740558327f0f40f1b58d04ca5d5baed9285f048 Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 20 Sep 2022 05:55:07 +0200 Subject: [PATCH] Split library preferences from PreferencesHelper (#8036) --- .../interactor/CreateCategoryWithName.kt | 4 +- .../category/interactor/ResetCategoryFlags.kt | 6 +- .../interactor/SetDisplayModeForCategory.kt | 8 +- .../interactor/SetSortModeForCategory.kt | 8 +- .../setting => domain/library/model}/Flag.kt | 2 +- .../library/model}/LibraryDisplayMode.kt | 2 +- .../library/model}/LibrarySort.kt | 2 +- .../library/service/LibraryPreferences.kt | 76 +++++++++++++++++++ .../source/service/SourcePreferences.kt | 3 + .../domain/updates/interactor/GetUpdates.kt | 4 +- .../presentation/browse/BrowseSourceScreen.kt | 2 +- .../browse/components/BrowseSourceToolbar.kt | 2 +- .../presentation/library/LibraryScreen.kt | 2 +- .../library/components/LibraryContent.kt | 2 +- .../library/components/LibraryPager.kt | 2 +- .../java/eu/kanade/tachiyomi/AppModule.kt | 4 + .../java/eu/kanade/tachiyomi/Migrations.kt | 37 ++++----- .../tachiyomi/data/backup/BackupManager.kt | 4 +- .../data/library/LibraryUpdateJob.kt | 6 +- .../data/library/LibraryUpdateService.kt | 14 ++-- .../data/preference/PreferenceKeys.kt | 14 ---- .../data/preference/PreferencesHelper.kt | 53 ------------- .../source/browse/BrowseSourcePresenter.kt | 10 ++- .../tachiyomi/ui/library/LibraryPresenter.kt | 32 ++++---- .../ui/library/LibrarySettingsSheet.kt | 54 ++++++------- .../kanade/tachiyomi/ui/main/MainActivity.kt | 7 +- .../tachiyomi/ui/manga/MangaPresenter.kt | 4 +- .../ui/recent/updates/UpdatesPresenter.kt | 4 +- .../ui/setting/SettingsGeneralController.kt | 6 +- .../ui/setting/SettingsLibraryController.kt | 47 ++++++------ .../util/chapter/LibraryFlagsTest.kt | 6 +- 31 files changed, 234 insertions(+), 193 deletions(-) rename app/src/main/java/eu/kanade/{tachiyomi/ui/library/setting => domain/library/model}/Flag.kt (93%) rename app/src/main/java/eu/kanade/{tachiyomi/ui/library/setting => domain/library/model}/LibraryDisplayMode.kt (97%) rename app/src/main/java/eu/kanade/{tachiyomi/ui/library/setting => domain/library/model}/LibrarySort.kt (98%) create mode 100644 app/src/main/java/eu/kanade/domain/library/service/LibraryPreferences.kt diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt b/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt index 50bb8036a5..a4ee211961 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt @@ -3,7 +3,7 @@ package eu.kanade.domain.category.interactor import eu.kanade.domain.category.model.Category import eu.kanade.domain.category.model.anyWithName import eu.kanade.domain.category.repository.CategoryRepository -import eu.kanade.tachiyomi.data.preference.PreferencesHelper +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.tachiyomi.util.system.logcat import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.withContext @@ -11,7 +11,7 @@ import logcat.LogPriority class CreateCategoryWithName( private val categoryRepository: CategoryRepository, - private val preferences: PreferencesHelper, + private val preferences: LibraryPreferences, ) { private val initialFlags: Long diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/ResetCategoryFlags.kt b/app/src/main/java/eu/kanade/domain/category/interactor/ResetCategoryFlags.kt index 7e92e557dc..7733019676 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/ResetCategoryFlags.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/ResetCategoryFlags.kt @@ -1,11 +1,11 @@ package eu.kanade.domain.category.interactor import eu.kanade.domain.category.repository.CategoryRepository -import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import eu.kanade.tachiyomi.ui.library.setting.plus +import eu.kanade.domain.library.model.plus +import eu.kanade.domain.library.service.LibraryPreferences class ResetCategoryFlags( - private val preferences: PreferencesHelper, + private val preferences: LibraryPreferences, private val categoryRepository: CategoryRepository, ) { diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/SetDisplayModeForCategory.kt b/app/src/main/java/eu/kanade/domain/category/interactor/SetDisplayModeForCategory.kt index 6a476e316e..4644556215 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/SetDisplayModeForCategory.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/SetDisplayModeForCategory.kt @@ -3,12 +3,12 @@ package eu.kanade.domain.category.interactor import eu.kanade.domain.category.model.Category import eu.kanade.domain.category.model.CategoryUpdate import eu.kanade.domain.category.repository.CategoryRepository -import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode -import eu.kanade.tachiyomi.ui.library.setting.plus +import eu.kanade.domain.library.model.LibraryDisplayMode +import eu.kanade.domain.library.model.plus +import eu.kanade.domain.library.service.LibraryPreferences class SetDisplayModeForCategory( - private val preferences: PreferencesHelper, + private val preferences: LibraryPreferences, private val categoryRepository: CategoryRepository, ) { diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/SetSortModeForCategory.kt b/app/src/main/java/eu/kanade/domain/category/interactor/SetSortModeForCategory.kt index 6966f6fab6..d9c9ad6ccc 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/SetSortModeForCategory.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/SetSortModeForCategory.kt @@ -3,12 +3,12 @@ package eu.kanade.domain.category.interactor import eu.kanade.domain.category.model.Category import eu.kanade.domain.category.model.CategoryUpdate import eu.kanade.domain.category.repository.CategoryRepository -import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import eu.kanade.tachiyomi.ui.library.setting.LibrarySort -import eu.kanade.tachiyomi.ui.library.setting.plus +import eu.kanade.domain.library.model.LibrarySort +import eu.kanade.domain.library.model.plus +import eu.kanade.domain.library.service.LibraryPreferences class SetSortModeForCategory( - private val preferences: PreferencesHelper, + private val preferences: LibraryPreferences, private val categoryRepository: CategoryRepository, ) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/Flag.kt b/app/src/main/java/eu/kanade/domain/library/model/Flag.kt similarity index 93% rename from app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/Flag.kt rename to app/src/main/java/eu/kanade/domain/library/model/Flag.kt index a8653059b2..95203841a2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/Flag.kt +++ b/app/src/main/java/eu/kanade/domain/library/model/Flag.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.library.setting +package eu.kanade.domain.library.model interface Flag { val flag: Long diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/LibraryDisplayMode.kt b/app/src/main/java/eu/kanade/domain/library/model/LibraryDisplayMode.kt similarity index 97% rename from app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/LibraryDisplayMode.kt rename to app/src/main/java/eu/kanade/domain/library/model/LibraryDisplayMode.kt index bcb0d7bd5f..d96e1ff811 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/LibraryDisplayMode.kt +++ b/app/src/main/java/eu/kanade/domain/library/model/LibraryDisplayMode.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.library.setting +package eu.kanade.domain.library.model import eu.kanade.domain.category.model.Category diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/LibrarySort.kt b/app/src/main/java/eu/kanade/domain/library/model/LibrarySort.kt similarity index 98% rename from app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/LibrarySort.kt rename to app/src/main/java/eu/kanade/domain/library/model/LibrarySort.kt index dd54bd9993..b757ff4b9d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/LibrarySort.kt +++ b/app/src/main/java/eu/kanade/domain/library/model/LibrarySort.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.library.setting +package eu.kanade.domain.library.model import eu.kanade.domain.category.model.Category diff --git a/app/src/main/java/eu/kanade/domain/library/service/LibraryPreferences.kt b/app/src/main/java/eu/kanade/domain/library/service/LibraryPreferences.kt new file mode 100644 index 0000000000..b6b362ddbc --- /dev/null +++ b/app/src/main/java/eu/kanade/domain/library/service/LibraryPreferences.kt @@ -0,0 +1,76 @@ +package eu.kanade.domain.library.service + +import eu.kanade.domain.library.model.LibraryDisplayMode +import eu.kanade.domain.library.model.LibrarySort +import eu.kanade.tachiyomi.core.preference.PreferenceStore +import eu.kanade.tachiyomi.data.preference.DEVICE_ONLY_ON_WIFI +import eu.kanade.tachiyomi.data.preference.MANGA_HAS_UNREAD +import eu.kanade.tachiyomi.data.preference.MANGA_NON_COMPLETED +import eu.kanade.tachiyomi.data.preference.MANGA_NON_READ +import eu.kanade.tachiyomi.widget.ExtendedNavigationView + +class LibraryPreferences( + private val preferenceStore: PreferenceStore, +) { + + fun libraryDisplayMode() = this.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 portraitColumns() = this.preferenceStore.getInt("pref_library_columns_portrait_key", 0) + + fun landscapeColumns() = this.preferenceStore.getInt("pref_library_columns_landscape_key", 0) + + fun libraryUpdateInterval() = this.preferenceStore.getInt("pref_library_update_interval_key", 24) + fun libraryUpdateLastTimestamp() = this.preferenceStore.getLong("library_update_last_timestamp", 0L) + + fun libraryUpdateDeviceRestriction() = this.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)) + + // region Filter + + fun filterDownloaded() = this.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 filterStarted() = this.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 filterTracking(name: Int) = this.preferenceStore.getInt("pref_filter_library_tracked_$name", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) + + // endregion + + // region Badges + + fun downloadBadge() = this.preferenceStore.getBoolean("display_download_badge", false) + + fun localBadge() = this.preferenceStore.getBoolean("display_local_badge", true) + + fun unreadBadge() = this.preferenceStore.getBoolean("display_unread_badge", true) + + fun languageBadge() = this.preferenceStore.getBoolean("display_language_badge", false) + + fun showUpdatesNavBadge() = this.preferenceStore.getBoolean("library_update_show_tab_badge", false) + fun unreadUpdatesCount() = this.preferenceStore.getInt("library_unread_updates_count", 0) + + // endregion + + // region Category + + fun defaultCategory() = this.preferenceStore.getInt("default_category", -1) + + fun lastUsedCategory() = this.preferenceStore.getInt("last_used_category", 0) + + fun categoryTabs() = this.preferenceStore.getBoolean("display_category_tabs", true) + + fun categoryNumberOfItems() = this.preferenceStore.getBoolean("display_number_of_items", false) + + fun categorizedDisplaySettings() = this.preferenceStore.getBoolean("categorized_display", false) + + fun libraryUpdateCategories() = this.preferenceStore.getStringSet("library_update_categories", emptySet()) + + fun libraryUpdateCategoriesExclude() = this.preferenceStore.getStringSet("library_update_categories_exclude", emptySet()) + + // endregion +} diff --git a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt index 2ee3b3eb11..a6337343e5 100644 --- a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt @@ -1,5 +1,6 @@ package eu.kanade.domain.source.service +import eu.kanade.domain.library.model.LibraryDisplayMode import eu.kanade.domain.source.interactor.SetMigrateSorting import eu.kanade.tachiyomi.core.preference.PreferenceStore import eu.kanade.tachiyomi.core.preference.getEnum @@ -9,6 +10,8 @@ class SourcePreferences( private val preferenceStore: PreferenceStore, ) { + fun sourceDisplayMode() = this.preferenceStore.getObject("pref_display_mode_catalogue", LibraryDisplayMode.default, LibraryDisplayMode.Serializer::serialize, LibraryDisplayMode.Serializer::deserialize) + fun enabledLanguages() = this.preferenceStore.getStringSet("source_languages", LocaleHelper.getDefaultEnabledLanguages()) fun disabledSources() = this.preferenceStore.getStringSet("hidden_catalogues", emptySet()) diff --git a/app/src/main/java/eu/kanade/domain/updates/interactor/GetUpdates.kt b/app/src/main/java/eu/kanade/domain/updates/interactor/GetUpdates.kt index ce39d6e521..00a9a8bf82 100644 --- a/app/src/main/java/eu/kanade/domain/updates/interactor/GetUpdates.kt +++ b/app/src/main/java/eu/kanade/domain/updates/interactor/GetUpdates.kt @@ -1,15 +1,15 @@ package eu.kanade.domain.updates.interactor +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.updates.model.UpdatesWithRelations import eu.kanade.domain.updates.repository.UpdatesRepository -import eu.kanade.tachiyomi.data.preference.PreferencesHelper import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.onEach import java.util.Calendar class GetUpdates( private val repository: UpdatesRepository, - private val preferences: PreferencesHelper, + private val preferences: LibraryPreferences, ) { fun subscribe(calendar: Calendar): Flow> = subscribe(calendar.time.time) diff --git a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt index e2f4461236..389882c4d4 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt @@ -34,6 +34,7 @@ import androidx.paging.LoadState import androidx.paging.compose.LazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems import eu.kanade.data.source.NoResultsException +import eu.kanade.domain.library.model.LibraryDisplayMode import eu.kanade.domain.manga.model.Manga import eu.kanade.domain.source.interactor.GetRemoteManga import eu.kanade.presentation.browse.components.BrowseSourceComfortableGrid @@ -48,7 +49,6 @@ import eu.kanade.presentation.components.Scaffold import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourcePresenter -import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode import eu.kanade.tachiyomi.ui.more.MoreController import eu.kanade.tachiyomi.widget.EmptyView diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt index 47b6d081d8..f3fdc6ea86 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt @@ -19,6 +19,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction +import eu.kanade.domain.library.model.LibraryDisplayMode import eu.kanade.presentation.browse.BrowseSourceState import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.AppBarActions @@ -27,7 +28,6 @@ import eu.kanade.presentation.components.SearchToolbar import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.LocalSource -import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode @Composable fun BrowseSourceToolbar( diff --git a/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt b/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt index 54f6d7cdaa..ac13782e38 100644 --- a/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt @@ -4,6 +4,7 @@ import androidx.compose.animation.Crossfade import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import eu.kanade.domain.category.model.Category +import eu.kanade.domain.library.model.display import eu.kanade.presentation.components.LibraryBottomActionMenu import eu.kanade.presentation.components.LoadingScreen import eu.kanade.presentation.components.Scaffold @@ -11,7 +12,6 @@ import eu.kanade.presentation.library.components.LibraryContent import eu.kanade.presentation.library.components.LibraryToolbar import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.ui.library.LibraryPresenter -import eu.kanade.tachiyomi.ui.library.setting.display @Composable fun LibraryScreen( diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt index 440214fc8b..029209bdab 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt @@ -18,13 +18,13 @@ import com.google.accompanist.swiperefresh.SwipeRefresh import com.google.accompanist.swiperefresh.rememberSwipeRefreshState import eu.kanade.core.prefs.PreferenceMutableState import eu.kanade.domain.category.model.Category +import eu.kanade.domain.library.model.LibraryDisplayMode import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.SwipeRefreshIndicator import eu.kanade.presentation.library.LibraryState import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.LibraryManga import eu.kanade.tachiyomi.ui.library.LibraryItem -import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode import eu.kanade.tachiyomi.widget.EmptyView import kotlinx.coroutines.delay import kotlinx.coroutines.launch diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryPager.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryPager.kt index a8d15c385b..ffefb3348c 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryPager.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryPager.kt @@ -12,9 +12,9 @@ import androidx.compose.ui.platform.LocalConfiguration import com.google.accompanist.pager.HorizontalPager import com.google.accompanist.pager.PagerState import eu.kanade.core.prefs.PreferenceMutableState +import eu.kanade.domain.library.model.LibraryDisplayMode import eu.kanade.tachiyomi.data.database.models.LibraryManga import eu.kanade.tachiyomi.ui.library.LibraryItem -import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode @Composable fun LibraryPager( diff --git a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt index f918592e0d..544b05f12c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt @@ -13,6 +13,7 @@ import eu.kanade.data.AndroidDatabaseHandler import eu.kanade.data.DatabaseHandler import eu.kanade.data.dateAdapter import eu.kanade.data.listOfStringsAdapter +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.core.preference.AndroidPreferenceStore import eu.kanade.tachiyomi.core.preference.PreferenceStore @@ -147,6 +148,9 @@ class PreferenceModule(val application: Application) : InjektModule { addSingletonFactory { SecurityPreferences(get()) } + addSingletonFactory { + LibraryPreferences(get()) + } addSingletonFactory { PreferencesHelper( context = application, diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index de636e0032..174c61349a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -4,12 +4,12 @@ import android.content.Context import android.os.Build import androidx.core.content.edit import androidx.preference.PreferenceManager +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.core.security.SecurityPreferences import eu.kanade.tachiyomi.data.backup.BackupCreatorJob import eu.kanade.tachiyomi.data.library.LibraryUpdateJob import eu.kanade.tachiyomi.data.preference.MANGA_NON_COMPLETED -import eu.kanade.tachiyomi.data.preference.PreferenceKeys import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.track.TrackManager @@ -41,6 +41,7 @@ object Migrations { networkPreferences: NetworkPreferences, sourcePreferences: SourcePreferences, securityPreferences: SecurityPreferences, + libraryPreferences: LibraryPreferences, ): Boolean { val oldVersion = preferences.lastVersionCode().get() if (oldVersion < BuildConfig.VERSION_CODE) { @@ -107,11 +108,11 @@ object Migrations { } if (oldVersion < 44) { // Reset sorting preference if using removed sort by source - val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0) + val oldSortingMode = prefs.getInt(libraryPreferences.librarySortingMode().key(), 0) if (oldSortingMode == 5) { // SOURCE = 5 prefs.edit { - putInt(PreferenceKeys.librarySortingMode, 0) // ALPHABETICAL = 0 + putInt(libraryPreferences.librarySortingMode().key(), 0) // ALPHABETICAL = 0 } } } @@ -126,13 +127,13 @@ object Migrations { } } prefs.edit { - putInt(PreferenceKeys.filterDownloaded, convertBooleanPrefToTriState("pref_filter_downloaded_key")) + putInt(libraryPreferences.filterDownloaded().key(), convertBooleanPrefToTriState("pref_filter_downloaded_key")) remove("pref_filter_downloaded_key") - putInt(PreferenceKeys.filterUnread, convertBooleanPrefToTriState("pref_filter_unread_key")) + putInt(libraryPreferences.filterUnread().key(), convertBooleanPrefToTriState("pref_filter_unread_key")) remove("pref_filter_unread_key") - putInt(PreferenceKeys.filterCompleted, convertBooleanPrefToTriState("pref_filter_completed_key")) + putInt(libraryPreferences.filterCompleted().key(), convertBooleanPrefToTriState("pref_filter_completed_key")) remove("pref_filter_completed_key") } } @@ -197,14 +198,14 @@ object Migrations { } if (oldVersion < 61) { // Handle removed every 1 or 2 hour library updates - val updateInterval = preferences.libraryUpdateInterval().get() + val updateInterval = libraryPreferences.libraryUpdateInterval().get() if (updateInterval == 1 || updateInterval == 2) { - preferences.libraryUpdateInterval().set(3) + libraryPreferences.libraryUpdateInterval().set(3) LibraryUpdateJob.setupTask(context, 3) } } if (oldVersion < 64) { - val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0) + val oldSortingMode = prefs.getInt(libraryPreferences.librarySortingMode().key(), 0) val oldSortingDirection = prefs.getBoolean("library_sorting_ascending", true) val newSortingMode = when (oldSortingMode) { @@ -225,12 +226,12 @@ object Migrations { } prefs.edit(commit = true) { - remove(PreferenceKeys.librarySortingMode) + remove(libraryPreferences.librarySortingMode().key()) remove("library_sorting_ascending") } prefs.edit { - putString(PreferenceKeys.librarySortingMode, newSortingMode) + putString(libraryPreferences.librarySortingMode().key(), newSortingMode) putString("library_sorting_ascending", newSortingDirection) } } @@ -241,16 +242,16 @@ object Migrations { } if (oldVersion < 71) { // Handle removed every 3, 4, 6, and 8 hour library updates - val updateInterval = preferences.libraryUpdateInterval().get() + val updateInterval = libraryPreferences.libraryUpdateInterval().get() if (updateInterval in listOf(3, 4, 6, 8)) { - preferences.libraryUpdateInterval().set(12) + libraryPreferences.libraryUpdateInterval().set(12) LibraryUpdateJob.setupTask(context, 12) } } if (oldVersion < 72) { val oldUpdateOngoingOnly = prefs.getBoolean("pref_update_only_non_completed_key", true) if (!oldUpdateOngoingOnly) { - preferences.libraryUpdateMangaRestriction() -= MANGA_NON_COMPLETED + libraryPreferences.libraryUpdateMangaRestriction() -= MANGA_NON_COMPLETED } } if (oldVersion < 75) { @@ -275,20 +276,20 @@ object Migrations { if (oldVersion < 81) { // Handle renamed enum values prefs.edit { - val newSortingMode = when (val oldSortingMode = prefs.getString(PreferenceKeys.librarySortingMode, "ALPHABETICAL")) { + val newSortingMode = when (val oldSortingMode = prefs.getString(libraryPreferences.librarySortingMode().key(), "ALPHABETICAL")) { "LAST_CHECKED" -> "LAST_MANGA_UPDATE" "UNREAD" -> "UNREAD_COUNT" "DATE_FETCHED" -> "CHAPTER_FETCH_DATE" else -> oldSortingMode } - putString(PreferenceKeys.librarySortingMode, newSortingMode) + putString(libraryPreferences.librarySortingMode().key(), newSortingMode) } } if (oldVersion < 82) { prefs.edit { - val sort = prefs.getString(PreferenceKeys.librarySortingMode, null) ?: return@edit + val sort = prefs.getString(libraryPreferences.librarySortingMode().key(), null) ?: return@edit val direction = prefs.getString("library_sorting_ascending", "ASCENDING")!! - putString(PreferenceKeys.librarySortingMode, "$sort,$direction") + putString(libraryPreferences.librarySortingMode().key(), "$sort,$direction") remove("library_sorting_ascending") } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt index aa5790a30d..4d9d851d0a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt @@ -10,6 +10,7 @@ import eu.kanade.data.DatabaseHandler import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.model.Category import eu.kanade.domain.history.model.HistoryUpdate +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.manga.interactor.GetFavorites import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.backup.BackupConst.BACKUP_CATEGORY @@ -57,6 +58,7 @@ class BackupManager( private val handler: DatabaseHandler = Injekt.get() private val sourceManager: SourceManager = Injekt.get() private val preferences: PreferencesHelper = Injekt.get() + private val libraryPreferences: LibraryPreferences = Injekt.get() private val getCategories: GetCategories = Injekt.get() private val getFavorites: GetFavorites = Injekt.get() @@ -271,7 +273,7 @@ class BackupManager( category } - preferences.categorizedDisplaySettings().set( + libraryPreferences.categorizedDisplaySettings().set( (dbCategories + categories) .distinctBy { it.flags } .size > 1, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt index fb14b3ce75..c5e10b0366 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt @@ -8,11 +8,11 @@ import androidx.work.PeriodicWorkRequestBuilder import androidx.work.WorkManager import androidx.work.Worker import androidx.work.WorkerParameters +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.tachiyomi.data.preference.DEVICE_BATTERY_NOT_LOW import eu.kanade.tachiyomi.data.preference.DEVICE_CHARGING import eu.kanade.tachiyomi.data.preference.DEVICE_NETWORK_NOT_METERED import eu.kanade.tachiyomi.data.preference.DEVICE_ONLY_ON_WIFI -import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.util.system.isConnectedToWifi import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -22,7 +22,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet Worker(context, workerParams) { override fun doWork(): Result { - val preferences = Injekt.get() + val preferences = Injekt.get() val restrictions = preferences.libraryUpdateDeviceRestriction().get() if ((DEVICE_ONLY_ON_WIFI in restrictions) && !context.isConnectedToWifi()) { return Result.failure() @@ -39,7 +39,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet private const val TAG = "LibraryUpdate" fun setupTask(context: Context, prefInterval: Int? = null) { - val preferences = Injekt.get() + val preferences = Injekt.get() val interval = prefInterval ?: preferences.libraryUpdateInterval().get() if (interval > 0) { val restrictions = preferences.libraryUpdateDeviceRestriction().get() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 70a807292f..0756c2f520 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -13,6 +13,7 @@ import eu.kanade.domain.chapter.interactor.GetChapterByMangaId import eu.kanade.domain.chapter.interactor.SyncChaptersWithSource import eu.kanade.domain.chapter.interactor.SyncChaptersWithTrackServiceTwoWay import eu.kanade.domain.chapter.model.toDbChapter +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.manga.interactor.GetLibraryManga import eu.kanade.domain.manga.interactor.GetManga import eu.kanade.domain.manga.interactor.UpdateManga @@ -86,6 +87,7 @@ import eu.kanade.domain.manga.model.Manga as DomainManga class LibraryUpdateService( val sourceManager: SourceManager = Injekt.get(), val preferences: PreferencesHelper = Injekt.get(), + val libraryPreferences: LibraryPreferences = Injekt.get(), val downloadManager: DownloadManager = Injekt.get(), val trackManager: TrackManager = Injekt.get(), val coverCache: CoverCache = Injekt.get(), @@ -228,7 +230,7 @@ class LibraryUpdateService( // If this is a chapter update; set the last update time to now if (target == Target.CHAPTERS) { - preferences.libraryUpdateLastTimestamp().set(Date().time) + libraryPreferences.libraryUpdateLastTimestamp().set(Date().time) } // Update favorite manga @@ -264,14 +266,14 @@ class LibraryUpdateService( val listToUpdate = if (categoryId != -1L) { libraryManga.filter { it.category.toLong() == categoryId } } else { - val categoriesToUpdate = preferences.libraryUpdateCategories().get().map(String::toInt) + val categoriesToUpdate = libraryPreferences.libraryUpdateCategories().get().map(String::toInt) val listToInclude = if (categoriesToUpdate.isNotEmpty()) { libraryManga.filter { it.category in categoriesToUpdate } } else { libraryManga } - val categoriesToExclude = preferences.libraryUpdateCategoriesExclude().get().map(String::toInt) + val categoriesToExclude = libraryPreferences.libraryUpdateCategoriesExclude().get().map(String::toInt) val listToExclude = if (categoriesToExclude.isNotEmpty()) { libraryManga.filter { it.category in categoriesToExclude } } else { @@ -312,8 +314,8 @@ class LibraryUpdateService( val failedUpdates = CopyOnWriteArrayList>() val hasDownloads = AtomicBoolean(false) val loggedServices by lazy { trackManager.services.filter { it.isLogged } } - val currentUnreadUpdatesCount = preferences.unreadUpdatesCount().get() - val restrictions = preferences.libraryUpdateMangaRestriction().get() + val currentUnreadUpdatesCount = libraryPreferences.unreadUpdatesCount().get() + val restrictions = libraryPreferences.libraryUpdateMangaRestriction().get() withIOContext { mangaToUpdate.groupBy { it.source } @@ -396,7 +398,7 @@ class LibraryUpdateService( if (newUpdates.isNotEmpty()) { notifier.showUpdateNotifications(newUpdates) val newChapterCount = newUpdates.sumOf { it.second.size } - preferences.unreadUpdatesCount().set(currentUnreadUpdatesCount + newChapterCount) + libraryPreferences.unreadUpdatesCount().set(currentUnreadUpdatesCount + newChapterCount) if (hasDownloads.get()) { DownloadService.start(this) } 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 c03c7c1ec1..faff829f35 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 @@ -25,26 +25,12 @@ object PreferenceKeys { const val removeBookmarkedChapters = "pref_remove_bookmarked" - const val filterDownloaded = "pref_filter_library_downloaded" - - const val filterUnread = "pref_filter_library_unread" - - const val filterStarted = "pref_filter_library_started" - - const val filterCompleted = "pref_filter_library_completed" - - const val filterTracked = "pref_filter_library_tracked" - - const val librarySortingMode = "library_sorting_mode" - const val autoUpdateMetadata = "auto_update_metadata" const val autoUpdateTrackers = "auto_update_trackers" const val dateFormat = "app_date_format" - const val defaultCategory = "default_category" - const val skipRead = "skip_read" const val skipFiltered = "skip_filtered" 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 89e99c3c9b..1944e0a1b6 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 @@ -10,13 +10,10 @@ import eu.kanade.tachiyomi.core.preference.getEnum import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.anilist.Anilist -import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode -import eu.kanade.tachiyomi.ui.library.setting.LibrarySort import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType import eu.kanade.tachiyomi.util.system.DeviceUtil import eu.kanade.tachiyomi.util.system.isDynamicColorAvailable -import eu.kanade.tachiyomi.widget.ExtendedNavigationView import java.io.File import java.text.DateFormat import java.text.SimpleDateFormat @@ -144,18 +141,10 @@ class PreferencesHelper( fun readerHideThreshold() = this.preferenceStore.getEnum("reader_hide_threshold", Values.ReaderHideThreshold.LOW) - fun portraitColumns() = this.preferenceStore.getInt("pref_library_columns_portrait_key", 0) - - fun landscapeColumns() = this.preferenceStore.getInt("pref_library_columns_landscape_key", 0) - fun autoUpdateTrack() = this.preferenceStore.getBoolean(Keys.autoUpdateTrack, true) - fun lastUsedCategory() = this.preferenceStore.getInt("last_used_category", 0) - fun lastVersionCode() = this.preferenceStore.getInt("last_version_code", 0) - fun sourceDisplayMode() = this.preferenceStore.getObject("pref_display_mode_catalogue", LibraryDisplayMode.default, LibraryDisplayMode.Serializer::serialize, LibraryDisplayMode.Serializer::deserialize) - fun trackUsername(sync: TrackService) = this.preferenceStore.getString(Keys.trackUsername(sync.id), "") fun trackPassword(sync: TrackService) = this.preferenceStore.getString(Keys.trackPassword(sync.id), "") @@ -200,46 +189,8 @@ class PreferencesHelper( fun removeExcludeCategories() = this.preferenceStore.getStringSet("remove_exclude_categories", emptySet()) - fun libraryUpdateInterval() = this.preferenceStore.getInt("pref_library_update_interval_key", 24) - fun libraryUpdateLastTimestamp() = this.preferenceStore.getLong("library_update_last_timestamp", 0L) - - fun libraryUpdateDeviceRestriction() = this.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 showUpdatesNavBadge() = this.preferenceStore.getBoolean("library_update_show_tab_badge", false) - fun unreadUpdatesCount() = this.preferenceStore.getInt("library_unread_updates_count", 0) - - fun libraryUpdateCategories() = this.preferenceStore.getStringSet("library_update_categories", emptySet()) - fun libraryUpdateCategoriesExclude() = this.preferenceStore.getStringSet("library_update_categories_exclude", emptySet()) - - fun libraryDisplayMode() = this.preferenceStore.getObject("pref_display_mode_library", LibraryDisplayMode.default, LibraryDisplayMode.Serializer::serialize, LibraryDisplayMode.Serializer::deserialize) - - fun downloadBadge() = this.preferenceStore.getBoolean("display_download_badge", false) - - fun localBadge() = this.preferenceStore.getBoolean("display_local_badge", true) - fun downloadedOnly() = this.preferenceStore.getBoolean("pref_downloaded_only", false) - fun unreadBadge() = this.preferenceStore.getBoolean("display_unread_badge", true) - - fun languageBadge() = this.preferenceStore.getBoolean("display_language_badge", false) - - fun categoryTabs() = this.preferenceStore.getBoolean("display_category_tabs", true) - - fun categoryNumberOfItems() = this.preferenceStore.getBoolean("display_number_of_items", false) - - fun filterDownloaded() = this.preferenceStore.getInt(Keys.filterDownloaded, ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) - - fun filterUnread() = this.preferenceStore.getInt(Keys.filterUnread, ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) - - fun filterStarted() = this.preferenceStore.getInt(Keys.filterStarted, ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) - - fun filterCompleted() = this.preferenceStore.getInt(Keys.filterCompleted, ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) - - fun filterTracking(name: Int) = this.preferenceStore.getInt("${Keys.filterTracked}_$name", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) - - fun librarySortingMode() = this.preferenceStore.getObject(Keys.librarySortingMode, LibrarySort.default, LibrarySort.Serializer::serialize, LibrarySort.Serializer::deserialize) - fun automaticExtUpdates() = this.preferenceStore.getBoolean("automatic_ext_updates", true) fun lastAppCheck() = this.preferenceStore.getLong("last_app_check", 0) @@ -252,10 +203,6 @@ class PreferencesHelper( fun autoDownloadWhileReading() = this.preferenceStore.getInt("auto_download_while_reading", 0) - fun defaultCategory() = this.preferenceStore.getInt(Keys.defaultCategory, -1) - - fun categorizedDisplaySettings() = this.preferenceStore.getBoolean("categorized_display", false) - fun skipRead() = this.preferenceStore.getBoolean(Keys.skipRead, false) fun skipFiltered() = this.preferenceStore.getBoolean(Keys.skipFiltered, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt index 84a6d68914..acf8a9b865 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt @@ -23,6 +23,7 @@ import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.interactor.SetMangaCategories import eu.kanade.domain.chapter.interactor.GetChapterByMangaId import eu.kanade.domain.chapter.interactor.SyncChaptersWithTrackServiceTwoWay +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.manga.interactor.GetDuplicateLibraryManga import eu.kanade.domain.manga.interactor.GetManga import eu.kanade.domain.manga.interactor.InsertManga @@ -30,6 +31,7 @@ import eu.kanade.domain.manga.interactor.UpdateManga import eu.kanade.domain.manga.model.toDbManga import eu.kanade.domain.manga.model.toMangaUpdate import eu.kanade.domain.source.interactor.GetRemoteManga +import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.track.interactor.InsertTrack import eu.kanade.domain.track.model.toDomainTrack import eu.kanade.presentation.browse.BrowseSourceState @@ -86,6 +88,8 @@ open class BrowseSourcePresenter( private val state: BrowseSourceStateImpl = BrowseSourceState(searchQuery) as BrowseSourceStateImpl, private val sourceManager: SourceManager = Injekt.get(), private val preferences: PreferencesHelper = Injekt.get(), + private val sourcePreferences: SourcePreferences = Injekt.get(), + private val libraryPreferences: LibraryPreferences = Injekt.get(), private val coverCache: CoverCache = Injekt.get(), private val getRemoteManga: GetRemoteManga = Injekt.get(), private val getManga: GetManga = Injekt.get(), @@ -101,7 +105,7 @@ open class BrowseSourcePresenter( private val loggedServices by lazy { Injekt.get().services.filter { it.isLogged } } - var displayMode by preferences.sourceDisplayMode().asState() + var displayMode by sourcePreferences.sourceDisplayMode().asState() val isDownloadOnly: Boolean by preferences.downloadedOnly().asState() val isIncognitoMode: Boolean by preferences.incognitoMode().asState() @@ -110,7 +114,7 @@ open class BrowseSourcePresenter( fun getColumnsPreferenceForCurrentOrientation(): State { val isLandscape = LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE return produceState(initialValue = GridCells.Adaptive(128.dp), isLandscape) { - (if (isLandscape) preferences.landscapeColumns() else preferences.portraitColumns()) + (if (isLandscape) libraryPreferences.landscapeColumns() else libraryPreferences.portraitColumns()) .changes() .collectLatest { columns -> value = if (columns == 0) GridCells.Adaptive(128.dp) else GridCells.Fixed(columns) @@ -257,7 +261,7 @@ open class BrowseSourcePresenter( fun addFavorite(manga: DomainManga) { presenterScope.launch { val categories = getCategories() - val defaultCategoryId = preferences.defaultCategory().get() + val defaultCategoryId = libraryPreferences.defaultCategory().get() val defaultCategory = categories.find { it.id == defaultCategoryId.toLong() } when { 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 1898fe7302..f09fd4471a 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 @@ -22,6 +22,9 @@ import eu.kanade.domain.category.model.Category import eu.kanade.domain.chapter.interactor.GetChapterByMangaId import eu.kanade.domain.chapter.interactor.SetReadStatus import eu.kanade.domain.chapter.model.toDbChapter +import eu.kanade.domain.library.model.LibrarySort +import eu.kanade.domain.library.model.sort +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.manga.interactor.GetLibraryManga import eu.kanade.domain.manga.interactor.UpdateManga import eu.kanade.domain.manga.model.Manga @@ -43,8 +46,6 @@ 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.ui.library.setting.LibrarySort -import eu.kanade.tachiyomi.ui.library.setting.sort import eu.kanade.tachiyomi.util.lang.combineLatest import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchNonCancellableIO @@ -90,6 +91,7 @@ class LibraryPresenter( private val updateManga: UpdateManga = Injekt.get(), private val setMangaCategories: SetMangaCategories = Injekt.get(), private val preferences: PreferencesHelper = Injekt.get(), + private val libraryPreferences: LibraryPreferences = Injekt.get(), private val coverCache: CoverCache = Injekt.get(), private val sourceManager: SourceManager = Injekt.get(), private val downloadManager: DownloadManager = Injekt.get(), @@ -100,10 +102,10 @@ class LibraryPresenter( val isLibraryEmpty by derivedStateOf { loadedManga.isEmpty() } - val tabVisibility by preferences.categoryTabs().asState() - val mangaCountVisibility by preferences.categoryNumberOfItems().asState() + val tabVisibility by libraryPreferences.categoryTabs().asState() + val mangaCountVisibility by libraryPreferences.categoryNumberOfItems().asState() - var activeCategory: Int by preferences.lastUsedCategory().asState() + var activeCategory: Int by libraryPreferences.lastUsedCategory().asState() val isDownloadOnly: Boolean by preferences.downloadedOnly().asState() val isIncognitoMode: Boolean by preferences.incognitoMode().asState() @@ -170,13 +172,13 @@ class LibraryPresenter( */ private fun applyFilters(map: LibraryMap, trackMap: Map>): LibraryMap { val downloadedOnly = preferences.downloadedOnly().get() - val filterDownloaded = preferences.filterDownloaded().get() - val filterUnread = preferences.filterUnread().get() - val filterStarted = preferences.filterStarted().get() - val filterCompleted = preferences.filterCompleted().get() + val filterDownloaded = libraryPreferences.filterDownloaded().get() + val filterUnread = libraryPreferences.filterUnread().get() + val filterStarted = libraryPreferences.filterStarted().get() + val filterCompleted = libraryPreferences.filterCompleted().get() val loggedInServices = trackManager.services.filter { trackService -> trackService.isLogged } .associate { trackService -> - Pair(trackService.id, preferences.filterTracking(trackService.id.toInt()).get()) + Pair(trackService.id, libraryPreferences.filterTracking(trackService.id.toInt()).get()) } val isNotAnyLoggedIn = !loggedInServices.values.any() @@ -271,10 +273,10 @@ class LibraryPresenter( * @param map the map of manga. */ private fun setBadges(map: LibraryMap) { - val showDownloadBadges = preferences.downloadBadge().get() - val showUnreadBadges = preferences.unreadBadge().get() - val showLocalBadges = preferences.localBadge().get() - val showLanguageBadges = preferences.languageBadge().get() + val showDownloadBadges = libraryPreferences.downloadBadge().get() + val showUnreadBadges = libraryPreferences.unreadBadge().get() + val showLocalBadges = libraryPreferences.localBadge().get() + val showLanguageBadges = libraryPreferences.languageBadge().get() for ((_, itemList) in map) { for (item in itemList) { @@ -611,7 +613,7 @@ class LibraryPresenter( } fun getColumnsPreferenceForCurrentOrientation(isLandscape: Boolean): PreferenceMutableState { - return (if (isLandscape) preferences.landscapeColumns() else preferences.portraitColumns()).asState() + return (if (isLandscape) libraryPreferences.landscapeColumns() else libraryPreferences.portraitColumns()).asState() } // TODO: This is good but should we separate title from count or get categories with count from db diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt index d23ae5b9f6..65b4c32a44 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt @@ -7,14 +7,15 @@ import com.bluelinelabs.conductor.Router import eu.kanade.domain.category.interactor.SetDisplayModeForCategory import eu.kanade.domain.category.interactor.SetSortModeForCategory import eu.kanade.domain.category.model.Category +import eu.kanade.domain.library.model.LibraryDisplayMode +import eu.kanade.domain.library.model.LibrarySort +import eu.kanade.domain.library.model.display +import eu.kanade.domain.library.model.sort +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackService -import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode -import eu.kanade.tachiyomi.ui.library.setting.LibrarySort -import eu.kanade.tachiyomi.ui.library.setting.display -import eu.kanade.tachiyomi.ui.library.setting.sort import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.widget.ExtendedNavigationView import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State @@ -129,14 +130,14 @@ class LibrarySettingsSheet( downloaded.state = State.INCLUDE.value downloaded.enabled = false } else { - downloaded.state = preferences.filterDownloaded().get() + downloaded.state = libraryPreferences.filterDownloaded().get() } - unread.state = preferences.filterUnread().get() - started.state = preferences.filterStarted().get() - completed.state = preferences.filterCompleted().get() + unread.state = libraryPreferences.filterUnread().get() + started.state = libraryPreferences.filterStarted().get() + completed.state = libraryPreferences.filterCompleted().get() trackFilters.forEach { trackFilter -> - trackFilter.value.state = preferences.filterTracking(trackFilter.key.toInt()).get() + trackFilter.value.state = libraryPreferences.filterTracking(trackFilter.key.toInt()).get() } } @@ -150,14 +151,14 @@ class LibrarySettingsSheet( } item.state = newState when (item) { - downloaded -> preferences.filterDownloaded().set(newState) - unread -> preferences.filterUnread().set(newState) - started -> preferences.filterStarted().set(newState) - completed -> preferences.filterCompleted().set(newState) + downloaded -> libraryPreferences.filterDownloaded().set(newState) + unread -> libraryPreferences.filterUnread().set(newState) + started -> libraryPreferences.filterStarted().set(newState) + completed -> libraryPreferences.filterCompleted().set(newState) else -> { trackFilters.forEach { trackFilter -> if (trackFilter.value == item) { - preferences.filterTracking(trackFilter.key.toInt()).set(newState) + libraryPreferences.filterTracking(trackFilter.key.toInt()).set(newState) } } } @@ -360,20 +361,20 @@ class LibrarySettingsSheet( override val footer = null override fun initModels() { - downloadBadge.checked = preferences.downloadBadge().get() - unreadBadge.checked = preferences.unreadBadge().get() - localBadge.checked = preferences.localBadge().get() - languageBadge.checked = preferences.languageBadge().get() + downloadBadge.checked = libraryPreferences.downloadBadge().get() + unreadBadge.checked = libraryPreferences.unreadBadge().get() + localBadge.checked = libraryPreferences.localBadge().get() + languageBadge.checked = libraryPreferences.languageBadge().get() } override fun onItemClicked(item: Item) { item as Item.CheckboxGroup item.checked = !item.checked when (item) { - downloadBadge -> preferences.downloadBadge().set((item.checked)) - unreadBadge -> preferences.unreadBadge().set((item.checked)) - localBadge -> preferences.localBadge().set((item.checked)) - languageBadge -> preferences.languageBadge().set((item.checked)) + downloadBadge -> libraryPreferences.downloadBadge().set((item.checked)) + unreadBadge -> libraryPreferences.unreadBadge().set((item.checked)) + localBadge -> libraryPreferences.localBadge().set((item.checked)) + languageBadge -> libraryPreferences.languageBadge().set((item.checked)) else -> {} } adapter.notifyItemChanged(item) @@ -389,16 +390,16 @@ class LibrarySettingsSheet( override val footer = null override fun initModels() { - showTabs.checked = preferences.categoryTabs().get() - showNumberOfItems.checked = preferences.categoryNumberOfItems().get() + showTabs.checked = libraryPreferences.categoryTabs().get() + showNumberOfItems.checked = libraryPreferences.categoryNumberOfItems().get() } override fun onItemClicked(item: Item) { item as Item.CheckboxGroup item.checked = !item.checked when (item) { - showTabs -> preferences.categoryTabs().set(item.checked) - showNumberOfItems -> preferences.categoryNumberOfItems().set(item.checked) + showTabs -> libraryPreferences.categoryTabs().set(item.checked) + showNumberOfItems -> libraryPreferences.categoryNumberOfItems().set(item.checked) else -> {} } adapter.notifyItemChanged(item) @@ -410,6 +411,7 @@ class LibrarySettingsSheet( ExtendedNavigationView(context, attrs) { val preferences: PreferencesHelper by injectLazy() + val libraryPreferences: LibraryPreferences by injectLazy() lateinit var adapter: Adapter /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 3352ffa230..1c44a552d4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -31,6 +31,7 @@ import com.bluelinelabs.conductor.RouterTransaction import com.google.android.material.navigation.NavigationBarView import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback import dev.chrisbanes.insetter.applyInsetter +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.Migrations @@ -80,6 +81,7 @@ import uy.kohesive.injekt.injectLazy class MainActivity : BaseActivity() { private val sourcePreferences: SourcePreferences by injectLazy() + private val libraryPreferences: LibraryPreferences by injectLazy() lateinit var binding: MainActivityBinding @@ -117,6 +119,7 @@ class MainActivity : BaseActivity() { networkPreferences = Injekt.get(), sourcePreferences = sourcePreferences, securityPreferences = Injekt.get(), + libraryPreferences = libraryPreferences, ) } else { false @@ -255,7 +258,7 @@ class MainActivity : BaseActivity() { } } - merge(preferences.showUpdatesNavBadge().changes(), preferences.unreadUpdatesCount().changes()) + merge(libraryPreferences.showUpdatesNavBadge().changes(), libraryPreferences.unreadUpdatesCount().changes()) .onEach { setUnreadUpdatesBadge() } .launchIn(lifecycleScope) @@ -385,7 +388,7 @@ class MainActivity : BaseActivity() { } private fun setUnreadUpdatesBadge() { - val updates = if (preferences.showUpdatesNavBadge().get()) preferences.unreadUpdatesCount().get() else 0 + val updates = if (libraryPreferences.showUpdatesNavBadge().get()) libraryPreferences.unreadUpdatesCount().get() else 0 if (updates > 0) { nav.getOrCreateBadge(R.id.nav_updates).apply { number = updates diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index fea2c52d58..9f7c0cd216 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -15,6 +15,7 @@ import eu.kanade.domain.chapter.interactor.SyncChaptersWithTrackServiceTwoWay import eu.kanade.domain.chapter.interactor.UpdateChapter import eu.kanade.domain.chapter.model.ChapterUpdate import eu.kanade.domain.chapter.model.toDbChapter +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.manga.interactor.GetDuplicateLibraryManga import eu.kanade.domain.manga.interactor.GetMangaWithChapters import eu.kanade.domain.manga.interactor.SetMangaChapterFlags @@ -81,6 +82,7 @@ class MangaPresenter( val mangaId: Long, val isFromSource: Boolean, private val preferences: PreferencesHelper = Injekt.get(), + private val libraryPreferences: LibraryPreferences = Injekt.get(), private val trackManager: TrackManager = Injekt.get(), private val sourceManager: SourceManager = Injekt.get(), private val downloadManager: DownloadManager = Injekt.get(), @@ -283,7 +285,7 @@ class MangaPresenter( // Now check if user previously set categories, when available val categories = getCategories() - val defaultCategoryId = preferences.defaultCategory().get().toLong() + val defaultCategoryId = libraryPreferences.defaultCategory().get().toLong() val defaultCategory = categories.find { it.id == defaultCategoryId } when { // Default category set diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt index 098a82b109..bbdbf8f200 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt @@ -10,6 +10,7 @@ import eu.kanade.domain.chapter.interactor.SetReadStatus import eu.kanade.domain.chapter.interactor.UpdateChapter import eu.kanade.domain.chapter.model.ChapterUpdate import eu.kanade.domain.chapter.model.toDbChapter +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.manga.interactor.GetManga import eu.kanade.domain.updates.interactor.GetUpdates import eu.kanade.domain.updates.model.UpdatesWithRelations @@ -53,12 +54,13 @@ class UpdatesPresenter( private val downloadManager: DownloadManager = Injekt.get(), private val getChapter: GetChapter = Injekt.get(), preferences: PreferencesHelper = Injekt.get(), + libraryPreferences: LibraryPreferences = Injekt.get(), ) : BasePresenter(), UpdatesState by state { val isDownloadOnly: Boolean by preferences.downloadedOnly().asState() val isIncognitoMode: Boolean by preferences.incognitoMode().asState() - val lastUpdated by preferences.libraryUpdateLastTimestamp().asState() + val lastUpdated by libraryPreferences.libraryUpdateLastTimestamp().asState() val relativeTime: Int by preferences.relativeTime().asState() val dateFormat: DateFormat by mutableStateOf(preferences.dateFormat()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index 5561051a24..7ba5be3931 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -6,6 +6,7 @@ import android.provider.Settings import androidx.appcompat.app.AppCompatDelegate import androidx.core.os.LocaleListCompat import androidx.preference.PreferenceScreen +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.preference.bindTo import eu.kanade.tachiyomi.util.preference.defaultValue @@ -17,15 +18,18 @@ import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.LocaleHelper import org.xmlpull.v1.XmlPullParser +import uy.kohesive.injekt.injectLazy import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsGeneralController : SettingsController() { + private val libraryPreferences: LibraryPreferences by injectLazy() + override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply { titleRes = R.string.pref_category_general switchPreference { - bindTo(preferences.showUpdatesNavBadge()) + bindTo(libraryPreferences.showUpdatesNavBadge()) titleRes = R.string.pref_library_update_show_tab_badge } switchPreference { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index eb9e87d550..ff0295f493 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -10,6 +10,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.interactor.ResetCategoryFlags import eu.kanade.domain.category.model.Category +import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.presentation.category.visualName import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.library.LibraryUpdateJob @@ -20,7 +21,6 @@ import eu.kanade.tachiyomi.data.preference.DEVICE_ONLY_ON_WIFI import eu.kanade.tachiyomi.data.preference.MANGA_HAS_UNREAD import eu.kanade.tachiyomi.data.preference.MANGA_NON_COMPLETED import eu.kanade.tachiyomi.data.preference.MANGA_NON_READ -import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.databinding.PrefLibraryColumnsBinding import eu.kanade.tachiyomi.ui.base.controller.DialogController @@ -54,6 +54,7 @@ class SettingsLibraryController : SettingsController() { private val getCategories: GetCategories by injectLazy() private val trackManager: TrackManager by injectLazy() private val resetCategoryFlags: ResetCategoryFlags by injectLazy() + private val libraryPreferences: LibraryPreferences by injectLazy() override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply { titleRes = R.string.pref_category_library @@ -79,7 +80,7 @@ class SettingsLibraryController : SettingsController() { } } - combine(preferences.portraitColumns().changes(), preferences.landscapeColumns().changes()) { portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) } + combine(libraryPreferences.portraitColumns().changes(), libraryPreferences.landscapeColumns().changes()) { portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) } .onEach { (portraitCols, landscapeCols) -> val portrait = getColumnValue(portraitCols) val landscape = getColumnValue(landscapeCols) @@ -106,15 +107,15 @@ class SettingsLibraryController : SettingsController() { } intListPreference { - key = Keys.defaultCategory + val defaultCategory = libraryPreferences.defaultCategory() + bindTo(defaultCategory) titleRes = R.string.default_category entries = arrayOf(context.getString(R.string.default_category_summary)) + allCategories.map { it.visualName(context) }.toTypedArray() - entryValues = arrayOf("-1") + allCategories.map { it.id.toString() }.toTypedArray() - defaultValue = "-1" + entryValues = arrayOf(defaultCategory.defaultValue().toString()) + allCategories.map { it.id.toString() }.toTypedArray() - val selectedCategory = allCategories.find { it.id == preferences.defaultCategory().get().toLong() } + val selectedCategory = allCategories.find { it.id == defaultCategory.get().toLong() } summary = selectedCategory?.visualName(context) ?: context.getString(R.string.default_category_summary) onChange { newValue -> @@ -126,10 +127,10 @@ class SettingsLibraryController : SettingsController() { } switchPreference { - bindTo(preferences.categorizedDisplaySettings()) + bindTo(libraryPreferences.categorizedDisplaySettings()) titleRes = R.string.categorized_display_settings - preferences.categorizedDisplaySettings().changes() + libraryPreferences.categorizedDisplaySettings().changes() .onEach { if (it.not()) { resetCategoryFlags.await() @@ -143,7 +144,7 @@ class SettingsLibraryController : SettingsController() { titleRes = R.string.pref_category_library_update intListPreference { - bindTo(preferences.libraryUpdateInterval()) + bindTo(libraryPreferences.libraryUpdateInterval()) titleRes = R.string.pref_library_update_interval entriesRes = arrayOf( R.string.update_never, @@ -163,12 +164,12 @@ class SettingsLibraryController : SettingsController() { } } multiSelectListPreference { - bindTo(preferences.libraryUpdateDeviceRestriction()) + bindTo(libraryPreferences.libraryUpdateDeviceRestriction()) titleRes = R.string.pref_library_update_restriction entriesRes = arrayOf(R.string.connected_to_wifi, R.string.network_not_metered, R.string.charging, R.string.battery_not_low) entryValues = arrayOf(DEVICE_ONLY_ON_WIFI, DEVICE_NETWORK_NOT_METERED, DEVICE_CHARGING, DEVICE_BATTERY_NOT_LOW) - visibleIf(preferences.libraryUpdateInterval()) { it > 0 } + visibleIf(libraryPreferences.libraryUpdateInterval()) { it > 0 } onChange { // Post to event looper to allow the preference to be updated. @@ -177,7 +178,7 @@ class SettingsLibraryController : SettingsController() { } fun updateSummary() { - val restrictions = preferences.libraryUpdateDeviceRestriction().get() + val restrictions = libraryPreferences.libraryUpdateDeviceRestriction().get() .sorted() .map { when (it) { @@ -197,18 +198,18 @@ class SettingsLibraryController : SettingsController() { summary = context.getString(R.string.restrictions, restrictionsText) } - preferences.libraryUpdateDeviceRestriction().changes() + libraryPreferences.libraryUpdateDeviceRestriction().changes() .onEach { updateSummary() } .launchIn(viewScope) } multiSelectListPreference { - bindTo(preferences.libraryUpdateMangaRestriction()) + bindTo(libraryPreferences.libraryUpdateMangaRestriction()) titleRes = R.string.pref_library_update_manga_restriction entriesRes = arrayOf(R.string.pref_update_only_completely_read, R.string.pref_update_only_started, R.string.pref_update_only_non_completed) entryValues = arrayOf(MANGA_HAS_UNREAD, MANGA_NON_READ, MANGA_NON_COMPLETED) fun updateSummary() { - val restrictions = preferences.libraryUpdateMangaRestriction().get().sorted() + val restrictions = libraryPreferences.libraryUpdateMangaRestriction().get().sorted() .map { when (it) { MANGA_NON_READ -> context.getString(R.string.pref_update_only_started) @@ -226,12 +227,12 @@ class SettingsLibraryController : SettingsController() { summary = restrictionsText } - preferences.libraryUpdateMangaRestriction().changes() + libraryPreferences.libraryUpdateMangaRestriction().changes() .onEach { updateSummary() } .launchIn(viewScope) } preference { - bindTo(preferences.libraryUpdateCategories()) + bindTo(libraryPreferences.libraryUpdateCategories()) titleRes = R.string.categories onClick { @@ -239,10 +240,10 @@ class SettingsLibraryController : SettingsController() { } fun updateSummary() { - val includedCategories = preferences.libraryUpdateCategories().get() + val includedCategories = libraryPreferences.libraryUpdateCategories().get() .mapNotNull { id -> allCategories.find { it.id == id.toLong() } } .sortedBy { it.order } - val excludedCategories = preferences.libraryUpdateCategoriesExclude().get() + val excludedCategories = libraryPreferences.libraryUpdateCategoriesExclude().get() .mapNotNull { id -> allCategories.find { it.id == id.toLong() } } .sortedBy { it.order } @@ -269,10 +270,10 @@ class SettingsLibraryController : SettingsController() { } } - preferences.libraryUpdateCategories().changes() + libraryPreferences.libraryUpdateCategories().changes() .onEach { updateSummary() } .launchIn(viewScope) - preferences.libraryUpdateCategoriesExclude().changes() + libraryPreferences.libraryUpdateCategoriesExclude().changes() .onEach { updateSummary() } .launchIn(viewScope) } @@ -295,7 +296,7 @@ class SettingsLibraryController : SettingsController() { class LibraryColumnsDialog : DialogController() { - private val preferences: PreferencesHelper = Injekt.get() + private val preferences: LibraryPreferences = Injekt.get() private var portrait = preferences.portraitColumns().get() private var landscape = preferences.landscapeColumns().get() @@ -338,7 +339,7 @@ class SettingsLibraryController : SettingsController() { class LibraryGlobalUpdateCategoriesDialog : DialogController() { - private val preferences: PreferencesHelper = Injekt.get() + private val preferences: LibraryPreferences = Injekt.get() private val getCategories: GetCategories = Injekt.get() override fun onCreateDialog(savedViewState: Bundle?): Dialog { diff --git a/app/src/test/java/eu/kanade/tachiyomi/util/chapter/LibraryFlagsTest.kt b/app/src/test/java/eu/kanade/tachiyomi/util/chapter/LibraryFlagsTest.kt index 873dbf680d..4e1f935f0a 100644 --- a/app/src/test/java/eu/kanade/tachiyomi/util/chapter/LibraryFlagsTest.kt +++ b/app/src/test/java/eu/kanade/tachiyomi/util/chapter/LibraryFlagsTest.kt @@ -1,8 +1,8 @@ package eu.kanade.tachiyomi.util.chapter -import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode -import eu.kanade.tachiyomi.ui.library.setting.LibrarySort -import eu.kanade.tachiyomi.ui.library.setting.plus +import eu.kanade.domain.library.model.LibraryDisplayMode +import eu.kanade.domain.library.model.LibrarySort +import eu.kanade.domain.library.model.plus import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotEquals import org.junit.jupiter.api.Test