mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Split library preferences from PreferencesHelper (#8036)
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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, | ||||
| ) { | ||||
|  | ||||
|   | ||||
| @@ -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, | ||||
| ) { | ||||
|  | ||||
|   | ||||
| @@ -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, | ||||
| ) { | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| package eu.kanade.tachiyomi.ui.library.setting | ||||
| package eu.kanade.domain.library.model | ||||
| 
 | ||||
| interface Flag { | ||||
|     val flag: Long | ||||
| @@ -1,4 +1,4 @@ | ||||
| package eu.kanade.tachiyomi.ui.library.setting | ||||
| package eu.kanade.domain.library.model | ||||
| 
 | ||||
| import eu.kanade.domain.category.model.Category | ||||
| 
 | ||||
| @@ -1,4 +1,4 @@ | ||||
| package eu.kanade.tachiyomi.ui.library.setting | ||||
| package eu.kanade.domain.library.model | ||||
| 
 | ||||
| import eu.kanade.domain.category.model.Category | ||||
| 
 | ||||
| @@ -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 | ||||
| } | ||||
| @@ -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()) | ||||
|   | ||||
| @@ -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<List<UpdatesWithRelations>> = subscribe(calendar.time.time) | ||||
|   | ||||
| @@ -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 | ||||
|  | ||||
|   | ||||
| @@ -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( | ||||
|   | ||||
| @@ -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( | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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( | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -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") | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -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<PreferencesHelper>() | ||||
|         val preferences = Injekt.get<LibraryPreferences>() | ||||
|         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<PreferencesHelper>() | ||||
|             val preferences = Injekt.get<LibraryPreferences>() | ||||
|             val interval = prefInterval ?: preferences.libraryUpdateInterval().get() | ||||
|             if (interval > 0) { | ||||
|                 val restrictions = preferences.libraryUpdateDeviceRestriction().get() | ||||
|   | ||||
| @@ -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<Pair<Manga, String?>>() | ||||
|         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) | ||||
|             } | ||||
|   | ||||
| @@ -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" | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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<TrackManager>().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<GridCells> { | ||||
|         val isLandscape = LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE | ||||
|         return produceState<GridCells>(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 { | ||||
|   | ||||
| @@ -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<Long, Map<Long, Boolean>>): 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<Int> { | ||||
|         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 | ||||
|   | ||||
| @@ -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 | ||||
|  | ||||
|         /** | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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<UpdatesController>(), 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()) | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user