Split library preferences from PreferencesHelper (#8036)
(cherry picked from commit c740558327f0f40f1b58d04ca5d5baed9285f048) # Conflicts: # app/src/main/java/eu/kanade/domain/category/interactor/SetDisplayModeForCategory.kt # app/src/main/java/eu/kanade/domain/category/interactor/SetSortModeForCategory.kt # app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt # app/src/main/java/eu/kanade/tachiyomi/AppModule.kt # app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt # app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt # app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt # app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt # app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt
This commit is contained in:
parent
d73e7aee9d
commit
b7363706d7
@ -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,13 +3,13 @@ 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.LibraryGroup
|
||||
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.LibraryGroup
|
||||
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,13 +3,13 @@ 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.LibraryGroup
|
||||
import eu.kanade.tachiyomi.ui.library.setting.LibrarySort
|
||||
import eu.kanade.tachiyomi.ui.library.setting.plus
|
||||
import eu.kanade.domain.library.model.LibraryGroup
|
||||
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
|
@ -0,0 +1,7 @@
|
||||
package eu.kanade.domain.library.model
|
||||
|
||||
enum class GroupLibraryMode {
|
||||
GLOBAL,
|
||||
ALL_BUT_UNGROUPED,
|
||||
ALL,
|
||||
}
|
@ -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
|
||||
package eu.kanade.domain.library.model
|
||||
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -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,95 @@
|
||||
package eu.kanade.domain.library.service
|
||||
|
||||
import eu.kanade.domain.library.model.GroupLibraryMode
|
||||
import eu.kanade.domain.library.model.LibraryDisplayMode
|
||||
import eu.kanade.domain.library.model.LibraryGroup
|
||||
import eu.kanade.domain.library.model.LibrarySort
|
||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||
import eu.kanade.tachiyomi.core.preference.getEnum
|
||||
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)
|
||||
|
||||
// SY -->
|
||||
fun filterLewd() = this.preferenceStore.getInt("pref_filter_library_lewd", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
|
||||
// SY <--
|
||||
|
||||
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
|
||||
|
||||
// SY -->
|
||||
|
||||
fun sortTagsForLibrary() = this.preferenceStore.getStringSet("sort_tags_for_library", mutableSetOf())
|
||||
|
||||
fun groupLibraryUpdateType() = this.preferenceStore.getEnum("group_library_update_type", GroupLibraryMode.GLOBAL)
|
||||
|
||||
fun startReadingButton() = this.preferenceStore.getBoolean("start_reading_button", true)
|
||||
|
||||
fun groupLibraryBy() = this.preferenceStore.getInt("group_library_by", LibraryGroup.BY_DEFAULT)
|
||||
|
||||
// SY <--
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package eu.kanade.domain.manga.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.library.service.LibraryPreferences
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
|
||||
class CreateSortTag(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: LibraryPreferences,
|
||||
private val getSortTag: GetSortTag,
|
||||
) {
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package eu.kanade.domain.manga.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.library.service.LibraryPreferences
|
||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||
|
||||
class DeleteSortTag(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: LibraryPreferences,
|
||||
private val getSortTag: GetSortTag,
|
||||
) {
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package eu.kanade.domain.manga.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.library.service.LibraryPreferences
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
class GetSortTag(private val preferences: PreferencesHelper) {
|
||||
class GetSortTag(private val preferences: LibraryPreferences) {
|
||||
|
||||
fun subscribe(): Flow<List<String>> {
|
||||
return preferences.sortTagsForLibrary().changes()
|
||||
@ -14,7 +14,7 @@ class GetSortTag(private val preferences: PreferencesHelper) {
|
||||
fun await() = getSortTags(preferences).let(::mapSortTags)
|
||||
|
||||
companion object {
|
||||
fun getSortTags(preferences: PreferencesHelper) = preferences.sortTagsForLibrary().get()
|
||||
fun getSortTags(preferences: LibraryPreferences) = preferences.sortTagsForLibrary().get()
|
||||
|
||||
fun mapSortTags(tags: Set<String>) = tags.mapNotNull {
|
||||
val index = it.indexOf('|')
|
||||
|
@ -1,9 +1,9 @@
|
||||
package eu.kanade.domain.manga.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.library.service.LibraryPreferences
|
||||
|
||||
class ReorderSortTag(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: LibraryPreferences,
|
||||
private val getSortTag: GetSortTag,
|
||||
) {
|
||||
|
||||
|
@ -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)
|
||||
|
@ -7,12 +7,12 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import eu.kanade.domain.library.model.LibraryDisplayMode
|
||||
import eu.kanade.domain.manga.model.Manga
|
||||
import eu.kanade.presentation.browse.components.BrowseSourceSimpleToolbar
|
||||
import eu.kanade.presentation.components.Scaffold
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourcePresenter
|
||||
import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode
|
||||
|
||||
@Composable
|
||||
fun BrowseMangadexFollowsScreen(
|
||||
|
@ -35,6 +35,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
|
||||
@ -50,7 +51,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
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||
|
@ -13,11 +13,11 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.domain.library.model.LibraryDisplayMode
|
||||
import eu.kanade.presentation.components.AppBar
|
||||
import eu.kanade.presentation.components.AppBarActions
|
||||
import eu.kanade.presentation.components.DropdownMenu
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode
|
||||
|
||||
@Composable
|
||||
fun BrowseSourceSimpleToolbar(
|
||||
|
@ -20,6 +20,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
|
||||
@ -29,7 +30,6 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode
|
||||
import exh.source.anyIs
|
||||
|
||||
@Composable
|
||||
|
@ -6,8 +6,8 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import eu.kanade.domain.category.model.Category
|
||||
import eu.kanade.domain.library.model.LibraryGroup
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryGroup
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
||||
import exh.source.PERV_EDEN_EN_SOURCE_ID
|
||||
import exh.source.PERV_EDEN_IT_SOURCE_ID
|
||||
|
@ -20,13 +20,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(
|
||||
|
@ -16,6 +16,7 @@ import eu.kanade.data.dateAdapter
|
||||
import eu.kanade.data.listOfLongsAdapter
|
||||
import eu.kanade.data.listOfStringsAdapter
|
||||
import eu.kanade.data.listOfStringsAndAdapter
|
||||
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
|
||||
@ -174,6 +175,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
|
||||
@ -43,6 +43,7 @@ object Migrations {
|
||||
networkPreferences: NetworkPreferences,
|
||||
sourcePreferences: SourcePreferences,
|
||||
securityPreferences: SecurityPreferences,
|
||||
libraryPreferences: LibraryPreferences,
|
||||
): Boolean {
|
||||
val oldVersion = preferences.lastVersionCode().get()
|
||||
if (oldVersion < BuildConfig.VERSION_CODE) {
|
||||
@ -109,11 +110,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
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,13 +129,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")
|
||||
}
|
||||
}
|
||||
@ -199,14 +200,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)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@ -228,12 +229,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)
|
||||
}
|
||||
}
|
||||
@ -244,16 +245,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) {
|
||||
@ -278,20 +279,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")
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import eu.kanade.data.manga.mangaMapper
|
||||
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.domain.manga.interactor.GetFlatMetadataById
|
||||
import eu.kanade.domain.manga.interactor.GetMergedManga
|
||||
@ -76,6 +77,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()
|
||||
|
||||
@ -329,7 +331,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,9 @@ 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.model.GroupLibraryMode
|
||||
import eu.kanade.domain.library.model.LibraryGroup
|
||||
import eu.kanade.domain.library.service.LibraryPreferences
|
||||
import eu.kanade.domain.manga.interactor.GetFavorites
|
||||
import eu.kanade.domain.manga.interactor.GetLibraryManga
|
||||
import eu.kanade.domain.manga.interactor.GetManga
|
||||
@ -40,7 +43,6 @@ import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
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.PreferenceValues.GroupLibraryMode
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
@ -50,7 +52,6 @@ import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.UnmeteredSource
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryGroup
|
||||
import eu.kanade.tachiyomi.ui.manga.track.TrackItem
|
||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import eu.kanade.tachiyomi.util.prepUpdateCover
|
||||
@ -104,6 +105,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(),
|
||||
@ -268,7 +270,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
|
||||
@ -307,7 +309,7 @@ class LibraryUpdateService(
|
||||
fun addMangaToQueue(categoryId: Long, group: Int, groupExtra: String?) {
|
||||
val libraryManga = runBlocking { getLibraryManga.await() }
|
||||
// SY -->
|
||||
val groupLibraryUpdateType = preferences.groupLibraryUpdateType().get()
|
||||
val groupLibraryUpdateType = libraryPreferences.groupLibraryUpdateType().get()
|
||||
// SY <--
|
||||
|
||||
val listToUpdate = if (categoryId != -1L) {
|
||||
@ -318,14 +320,14 @@ class LibraryUpdateService(
|
||||
groupLibraryUpdateType == GroupLibraryMode.GLOBAL ||
|
||||
(groupLibraryUpdateType == GroupLibraryMode.ALL_BUT_UNGROUPED && group == LibraryGroup.UNGROUPED)
|
||||
) {
|
||||
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 }.toSet()
|
||||
} else {
|
||||
@ -398,8 +400,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 }
|
||||
@ -483,7 +485,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,28 +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 filterLewd = "pref_filter_library_lewd"
|
||||
|
||||
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"
|
||||
|
@ -78,12 +78,4 @@ object PreferenceValues {
|
||||
PACKAGEINSTALLER(R.string.ext_installer_packageinstaller),
|
||||
SHIZUKU(R.string.ext_installer_shizuku),
|
||||
}
|
||||
|
||||
// SY -->
|
||||
enum class GroupLibraryMode {
|
||||
GLOBAL,
|
||||
ALL_BUT_UNGROUPED,
|
||||
ALL,
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
|
@ -10,16 +10,12 @@ 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.LibraryGroup
|
||||
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.ReaderBottomButton
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig
|
||||
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
|
||||
@ -153,18 +149,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), "")
|
||||
@ -209,50 +197,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: Long) = this.preferenceStore.getInt("${Keys.filterTracked}_$name", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
|
||||
|
||||
fun filterLewd() = this.preferenceStore.getInt(Keys.filterLewd, 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)
|
||||
@ -265,10 +211,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)
|
||||
@ -409,14 +351,8 @@ class PreferencesHelper(
|
||||
|
||||
fun webtoonEnableZoomOut() = this.preferenceStore.getBoolean("webtoon_enable_zoom_out", false)
|
||||
|
||||
fun startReadingButton() = this.preferenceStore.getBoolean("start_reading_button", true)
|
||||
|
||||
fun groupLibraryBy() = this.preferenceStore.getInt("group_library_by", LibraryGroup.BY_DEFAULT)
|
||||
|
||||
fun continuousVerticalTappingByPage() = this.preferenceStore.getBoolean("continuous_vertical_tapping_by_page", false)
|
||||
|
||||
fun groupLibraryUpdateType() = this.preferenceStore.getEnum("group_library_update_type", Values.GroupLibraryMode.GLOBAL)
|
||||
|
||||
fun useNewSourceNavigation() = this.preferenceStore.getBoolean("use_new_source_navigation", true)
|
||||
|
||||
fun preferredMangaDexId() = this.preferenceStore.getString("preferred_mangaDex_id", "0")
|
||||
@ -425,8 +361,6 @@ class PreferencesHelper(
|
||||
|
||||
fun allowLocalSourceHiddenFolders() = this.preferenceStore.getBoolean("allow_local_source_hidden_folders", false)
|
||||
|
||||
fun sortTagsForLibrary() = this.preferenceStore.getStringSet("sort_tags_for_library", mutableSetOf())
|
||||
|
||||
fun extensionRepos() = this.preferenceStore.getStringSet("extension_repos", emptySet())
|
||||
|
||||
fun cropBordersContinuousVertical() = this.preferenceStore.getBoolean("crop_borders_continues_vertical", false)
|
||||
|
@ -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.GetFlatMetadataById
|
||||
import eu.kanade.domain.manga.interactor.GetManga
|
||||
@ -35,6 +36,7 @@ import eu.kanade.domain.source.interactor.GetExhSavedSearch
|
||||
import eu.kanade.domain.source.interactor.GetRemoteManga
|
||||
import eu.kanade.domain.source.interactor.InsertSavedSearch
|
||||
import eu.kanade.domain.source.model.SourcePagingSourceType
|
||||
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
|
||||
@ -111,6 +113,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(),
|
||||
@ -133,7 +137,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()
|
||||
@ -146,7 +150,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)
|
||||
@ -342,7 +346,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 {
|
||||
|
@ -12,6 +12,7 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
import com.bluelinelabs.conductor.ControllerChangeType
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import eu.kanade.core.prefs.CheckboxState
|
||||
import eu.kanade.domain.library.model.LibraryGroup
|
||||
import eu.kanade.domain.manga.model.Manga
|
||||
import eu.kanade.domain.manga.model.isLocal
|
||||
import eu.kanade.domain.manga.model.toDbManga
|
||||
|
@ -26,6 +26,12 @@ import eu.kanade.domain.chapter.interactor.GetMergedChapterByMangaId
|
||||
import eu.kanade.domain.chapter.interactor.SetReadStatus
|
||||
import eu.kanade.domain.chapter.model.Chapter
|
||||
import eu.kanade.domain.chapter.model.toDbChapter
|
||||
import eu.kanade.domain.library.model.LibraryDisplayMode
|
||||
import eu.kanade.domain.library.model.LibraryGroup
|
||||
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.domain.manga.interactor.GetIdsOfFavoriteMangaWithMetadata
|
||||
import eu.kanade.domain.manga.interactor.GetLibraryManga
|
||||
import eu.kanade.domain.manga.interactor.GetMergedMangaById
|
||||
@ -58,10 +64,6 @@ import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
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.combineLatest
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchNonCancellableIO
|
||||
@ -130,6 +132,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(),
|
||||
@ -150,10 +153,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()
|
||||
@ -248,7 +251,7 @@ class LibraryPresenter(
|
||||
.asFlow()
|
||||
.collectLatest {
|
||||
// SY -->
|
||||
state.groupType = preferences.groupLibraryBy().get()
|
||||
state.groupType = libraryPreferences.groupLibraryBy().get()
|
||||
state.categories = it.categories
|
||||
// SY <--
|
||||
state.isLoading = false
|
||||
@ -265,17 +268,17 @@ 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).get())
|
||||
Pair(trackService.id, libraryPreferences.filterTracking(trackService.id.toInt()).get())
|
||||
}
|
||||
val isNotAnyLoggedIn = !loggedInServices.values.any()
|
||||
// SY -->
|
||||
val filterLewd = preferences.filterLewd().get()
|
||||
val filterLewd = libraryPreferences.filterLewd().get()
|
||||
// SY <--
|
||||
|
||||
val filterFnDownloaded: (LibraryItem) -> Boolean = downloaded@{ item ->
|
||||
@ -386,7 +389,7 @@ class LibraryPresenter(
|
||||
* @param map the map of manga.
|
||||
*/
|
||||
private fun setButtons(map: LibraryMap) {
|
||||
val startReadingButton = preferences.startReadingButton().get()
|
||||
val startReadingButton = libraryPreferences.startReadingButton().get()
|
||||
|
||||
for ((_, itemList) in map) {
|
||||
for (item in itemList) {
|
||||
@ -402,10 +405,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) {
|
||||
@ -485,7 +488,7 @@ class LibraryPresenter(
|
||||
|
||||
// SY -->
|
||||
val listOfTags by lazy {
|
||||
preferences.sortTagsForLibrary().get()
|
||||
libraryPreferences.sortTagsForLibrary().get()
|
||||
.asSequence()
|
||||
.mapNotNull {
|
||||
val list = it.split("|")
|
||||
@ -498,8 +501,8 @@ class LibraryPresenter(
|
||||
// SY <--
|
||||
|
||||
// SY -->
|
||||
val groupType = preferences.groupLibraryBy().get()
|
||||
val groupSort = preferences.librarySortingMode().get()
|
||||
val groupType = libraryPreferences.groupLibraryBy().get()
|
||||
val groupSort = libraryPreferences.librarySortingMode().get()
|
||||
// SY <--
|
||||
val sortModes = categories.associate { category ->
|
||||
// SY -->
|
||||
@ -614,7 +617,7 @@ class LibraryPresenter(
|
||||
|
||||
// SY -->
|
||||
private fun applyGrouping(map: LibraryMap, categories: List<Category>): Pair<LibraryMap, List<Category>> {
|
||||
val groupType = preferences.groupLibraryBy().get()
|
||||
val groupType = libraryPreferences.groupLibraryBy().get()
|
||||
var editedCategories = categories
|
||||
val items = when (groupType) {
|
||||
LibraryGroup.BY_DEFAULT -> map
|
||||
@ -899,7 +902,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
|
||||
@ -1114,7 +1117,7 @@ class LibraryPresenter(
|
||||
}
|
||||
}
|
||||
|
||||
private val libraryDisplayMode by preferences.libraryDisplayMode().asState()
|
||||
private val libraryDisplayMode by libraryPreferences.libraryDisplayMode().asState()
|
||||
// SY <--
|
||||
|
||||
@Composable
|
||||
|
@ -8,14 +8,16 @@ import eu.kanade.domain.category.interactor.GetCategories
|
||||
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.LibraryGroup
|
||||
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
|
||||
@ -141,18 +143,18 @@ 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).get()
|
||||
trackFilter.value.state = libraryPreferences.filterTracking(trackFilter.key.toInt()).get()
|
||||
}
|
||||
|
||||
// SY -->
|
||||
lewd.state = preferences.filterLewd().get()
|
||||
lewd.state = libraryPreferences.filterLewd().get()
|
||||
// SY <--
|
||||
}
|
||||
|
||||
@ -166,17 +168,17 @@ 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)
|
||||
// SY -->
|
||||
lewd -> preferences.filterLewd().set(newState)
|
||||
lewd -> libraryPreferences.filterLewd().set(newState)
|
||||
// SY <--
|
||||
else -> {
|
||||
trackFilters.forEach { trackFilter ->
|
||||
if (trackFilter.value == item) {
|
||||
preferences.filterTracking(trackFilter.key).set(newState)
|
||||
libraryPreferences.filterTracking(trackFilter.key.toInt()).set(newState)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -223,15 +225,15 @@ class LibrarySettingsSheet(
|
||||
override val header = null
|
||||
|
||||
override val items =
|
||||
listOf(alphabetically, lastRead, lastChecked, unread, total, latestChapter, chapterFetchDate, dateAdded /* SY --> */) + if (preferences.sortTagsForLibrary().get().isNotEmpty()) listOf(tagList) else emptyList() // SY <--
|
||||
listOf(alphabetically, lastRead, lastChecked, unread, total, latestChapter, chapterFetchDate, dateAdded /* SY --> */) + if (libraryPreferences.sortTagsForLibrary().get().isNotEmpty()) listOf(tagList) else emptyList() // SY <--
|
||||
override val footer = null
|
||||
|
||||
override fun initModels() {
|
||||
// SY -->
|
||||
val sort = if (preferences.groupLibraryBy().get() == LibraryGroup.BY_DEFAULT) {
|
||||
val sort = if (libraryPreferences.groupLibraryBy().get() == LibraryGroup.BY_DEFAULT) {
|
||||
currentCategory?.sort ?: LibrarySort.default
|
||||
} else {
|
||||
preferences.librarySortingMode().get()
|
||||
libraryPreferences.librarySortingMode().get()
|
||||
}
|
||||
// SY <--
|
||||
val order = if (sort.isAscending) Item.MultiSort.SORT_ASC else Item.MultiSort.SORT_DESC
|
||||
@ -349,10 +351,10 @@ class LibrarySettingsSheet(
|
||||
// Gets user preference of currently selected display mode at current category
|
||||
private fun getDisplayModePreference(): LibraryDisplayMode {
|
||||
// SY -->
|
||||
return if (preferences.groupLibraryBy().get() == LibraryGroup.BY_DEFAULT) {
|
||||
return if (libraryPreferences.groupLibraryBy().get() == LibraryGroup.BY_DEFAULT) {
|
||||
currentCategory?.display ?: LibraryDisplayMode.default
|
||||
} else {
|
||||
preferences.libraryDisplayMode().get()
|
||||
libraryPreferences.libraryDisplayMode().get()
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
@ -419,20 +421,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)
|
||||
@ -448,14 +450,14 @@ class LibrarySettingsSheet(
|
||||
override val footer = null
|
||||
|
||||
override fun initModels() {
|
||||
startReadingButton.checked = preferences.startReadingButton().get()
|
||||
startReadingButton.checked = libraryPreferences.startReadingButton().get()
|
||||
}
|
||||
|
||||
override fun onItemClicked(item: Item) {
|
||||
item as Item.CheckboxGroup
|
||||
item.checked = !item.checked
|
||||
when (item) {
|
||||
startReadingButton -> preferences.startReadingButton().set((item.checked))
|
||||
startReadingButton -> libraryPreferences.startReadingButton().set((item.checked))
|
||||
else -> Unit
|
||||
}
|
||||
adapter.notifyItemChanged(item)
|
||||
@ -472,16 +474,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)
|
||||
@ -531,7 +533,7 @@ class LibrarySettingsSheet(
|
||||
override val footer = null
|
||||
|
||||
override fun initModels() {
|
||||
val groupType = preferences.groupLibraryBy().get()
|
||||
val groupType = libraryPreferences.groupLibraryBy().get()
|
||||
|
||||
items.forEach {
|
||||
it.state = if (it.id == groupType) {
|
||||
@ -550,7 +552,7 @@ class LibrarySettingsSheet(
|
||||
}
|
||||
item.state = Item.DrawableSelection.SELECTED
|
||||
|
||||
preferences.groupLibraryBy().set(item.id)
|
||||
libraryPreferences.groupLibraryBy().set(item.id)
|
||||
|
||||
item.group.items.forEach { adapter.notifyItemChanged(it) }
|
||||
}
|
||||
@ -562,6 +564,7 @@ class LibrarySettingsSheet(
|
||||
ExtendedNavigationView(context, attrs) {
|
||||
|
||||
val preferences: PreferencesHelper by injectLazy()
|
||||
val libraryPreferences: LibraryPreferences by injectLazy()
|
||||
lateinit var adapter: Adapter
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,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.R
|
||||
@ -88,6 +89,7 @@ import java.util.LinkedList
|
||||
class MainActivity : BaseActivity() {
|
||||
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
private val libraryPreferences: LibraryPreferences by injectLazy()
|
||||
|
||||
lateinit var binding: MainActivityBinding
|
||||
|
||||
@ -144,6 +146,7 @@ class MainActivity : BaseActivity() {
|
||||
networkPreferences = Injekt.get(),
|
||||
sourcePreferences = sourcePreferences,
|
||||
securityPreferences = Injekt.get(),
|
||||
libraryPreferences = libraryPreferences,
|
||||
)
|
||||
} else {
|
||||
false
|
||||
@ -303,7 +306,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
// SY -->
|
||||
|
||||
merge(preferences.showUpdatesNavBadge().changes(), preferences.unreadUpdatesCount().changes())
|
||||
merge(libraryPreferences.showUpdatesNavBadge().changes(), libraryPreferences.unreadUpdatesCount().changes())
|
||||
.onEach { setUnreadUpdatesBadge() }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
@ -439,7 +442,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
|
||||
|
@ -16,6 +16,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.DeleteByMergeId
|
||||
import eu.kanade.domain.manga.interactor.DeleteMangaById
|
||||
import eu.kanade.domain.manga.interactor.GetDuplicateLibraryManga
|
||||
@ -125,6 +126,7 @@ class MangaPresenter(
|
||||
val isFromSource: Boolean,
|
||||
val smartSearched: 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(),
|
||||
@ -686,7 +688,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
|
||||
@ -19,15 +20,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,8 @@ 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.model.GroupLibraryMode
|
||||
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,8 +22,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.PreferenceValues.GroupLibraryMode
|
||||
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
|
||||
@ -57,6 +57,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
|
||||
@ -82,7 +83,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)
|
||||
@ -109,15 +110,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 ->
|
||||
@ -129,10 +130,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()
|
||||
@ -146,7 +147,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,
|
||||
@ -166,12 +167,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.
|
||||
@ -180,7 +181,7 @@ class SettingsLibraryController : SettingsController() {
|
||||
}
|
||||
|
||||
fun updateSummary() {
|
||||
val restrictions = preferences.libraryUpdateDeviceRestriction().get()
|
||||
val restrictions = libraryPreferences.libraryUpdateDeviceRestriction().get()
|
||||
.sorted()
|
||||
.map {
|
||||
when (it) {
|
||||
@ -200,18 +201,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)
|
||||
@ -229,12 +230,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 {
|
||||
@ -242,10 +243,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 }
|
||||
|
||||
@ -272,16 +273,16 @@ class SettingsLibraryController : SettingsController() {
|
||||
}
|
||||
}
|
||||
|
||||
preferences.libraryUpdateCategories().changes()
|
||||
libraryPreferences.libraryUpdateCategories().changes()
|
||||
.onEach { updateSummary() }
|
||||
.launchIn(viewScope)
|
||||
preferences.libraryUpdateCategoriesExclude().changes()
|
||||
libraryPreferences.libraryUpdateCategoriesExclude().changes()
|
||||
.onEach { updateSummary() }
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
// SY -->
|
||||
listPreference {
|
||||
bindTo(preferences.groupLibraryUpdateType())
|
||||
bindTo(libraryPreferences.groupLibraryUpdateType())
|
||||
titleRes = R.string.library_group_updates
|
||||
entriesRes = arrayOf(
|
||||
R.string.library_group_updates_global,
|
||||
@ -318,7 +319,7 @@ class SettingsLibraryController : SettingsController() {
|
||||
preference {
|
||||
key = "pref_tag_sorting"
|
||||
titleRes = R.string.pref_tag_sorting
|
||||
val count = preferences.sortTagsForLibrary().get().size
|
||||
val count = libraryPreferences.sortTagsForLibrary().get().size
|
||||
summary = context.resources.getQuantityString(R.plurals.pref_tag_sorting_desc, count, count)
|
||||
onClick {
|
||||
router.pushController(SortTagController())
|
||||
@ -344,7 +345,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()
|
||||
@ -387,7 +388,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 {
|
||||
|
@ -11,6 +11,7 @@ import eu.kanade.data.chapter.chapterMapper
|
||||
import eu.kanade.domain.chapter.interactor.DeleteChapters
|
||||
import eu.kanade.domain.chapter.interactor.UpdateChapter
|
||||
import eu.kanade.domain.chapter.model.ChapterUpdate
|
||||
import eu.kanade.domain.library.service.LibraryPreferences
|
||||
import eu.kanade.domain.manga.interactor.GetManga
|
||||
import eu.kanade.domain.manga.interactor.GetMangaBySource
|
||||
import eu.kanade.domain.manga.interactor.InsertMergedReference
|
||||
@ -25,7 +26,6 @@ import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
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
|
||||
@ -97,6 +97,7 @@ object EXHMigrations {
|
||||
networkPreferences: NetworkPreferences,
|
||||
sourcePreferences: SourcePreferences,
|
||||
securityPreferences: SecurityPreferences,
|
||||
libraryPreferences: LibraryPreferences,
|
||||
): Boolean {
|
||||
val oldVersion = preferences.ehLastVersionCode().get()
|
||||
try {
|
||||
@ -268,15 +269,15 @@ object EXHMigrations {
|
||||
if (readerTheme == 4) {
|
||||
preferences.readerTheme().set(3)
|
||||
}
|
||||
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 under 20) {
|
||||
try {
|
||||
val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0 /* ALPHABETICAL */)
|
||||
val oldSortingMode = prefs.getInt(libraryPreferences.librarySortingMode().key(), 0 /* ALPHABETICAL */)
|
||||
val oldSortingDirection = prefs.getBoolean("library_sorting_ascending", true)
|
||||
|
||||
val newSortingMode = when (oldSortingMode) {
|
||||
@ -299,12 +300,12 @@ object EXHMigrations {
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@ -321,16 +322,16 @@ object EXHMigrations {
|
||||
}
|
||||
if (oldVersion under 22) {
|
||||
// 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 under 23) {
|
||||
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 under 24) {
|
||||
@ -424,7 +425,7 @@ object EXHMigrations {
|
||||
if (oldVersion under 38) {
|
||||
// Handle renamed enum values
|
||||
@Suppress("DEPRECATION")
|
||||
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"
|
||||
@ -432,7 +433,7 @@ object EXHMigrations {
|
||||
else -> oldSortingMode
|
||||
}
|
||||
prefs.edit {
|
||||
putString(PreferenceKeys.librarySortingMode, newSortingMode)
|
||||
putString(libraryPreferences.librarySortingMode().key(), newSortingMode)
|
||||
}
|
||||
runBlocking {
|
||||
handler.await(true) {
|
||||
@ -451,9 +452,9 @@ object EXHMigrations {
|
||||
}
|
||||
if (oldVersion under 39) {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package exh.debug
|
||||
import android.app.Application
|
||||
import androidx.work.WorkManager
|
||||
import eu.kanade.data.DatabaseHandler
|
||||
import eu.kanade.domain.library.service.LibraryPreferences
|
||||
import eu.kanade.domain.manga.interactor.GetAllManga
|
||||
import eu.kanade.domain.manga.interactor.GetExhFavoriteMangaWithMetadata
|
||||
import eu.kanade.domain.manga.interactor.GetFavorites
|
||||
@ -36,6 +37,7 @@ object DebugFunctions {
|
||||
val networkPrefs: NetworkPreferences by injectLazy()
|
||||
val sourcePrefs: SourcePreferences by injectLazy()
|
||||
val securityPrefs: SecurityPreferences by injectLazy()
|
||||
val libraryPrefs: LibraryPreferences by injectLazy()
|
||||
val sourceManager: SourceManager by injectLazy()
|
||||
val updateManga: UpdateManga by injectLazy()
|
||||
val getFavorites: GetFavorites by injectLazy()
|
||||
@ -47,12 +49,12 @@ object DebugFunctions {
|
||||
|
||||
fun forceUpgradeMigration() {
|
||||
prefs.ehLastVersionCode().set(1)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs, securityPrefs)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs, securityPrefs, libraryPrefs)
|
||||
}
|
||||
|
||||
fun forceSetupJobs() {
|
||||
prefs.ehLastVersionCode().set(0)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs, securityPrefs)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs, securityPrefs, libraryPrefs)
|
||||
}
|
||||
|
||||
fun resetAgedFlagInEXHManga() {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user