mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-27 16:26:29 +03:00
Split source preferences from PreferencesHelper (#8029)
This commit is contained in:
parent
f3cecd3cde
commit
30b3b2d3ff
28 changed files with 111 additions and 93 deletions
|
@ -1,13 +1,13 @@
|
|||
package eu.kanade.domain.extension.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
|
||||
class GetExtensionLanguages(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
private val extensionManager: ExtensionManager,
|
||||
) {
|
||||
fun subscribe(): Flow<List<String>> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.kanade.domain.extension.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionSourceItem
|
||||
|
@ -8,7 +8,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
import kotlinx.coroutines.flow.map
|
||||
|
||||
class GetExtensionSources(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun subscribe(extension: Extension.Installed): Flow<List<ExtensionSourceItem>> {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package eu.kanade.domain.extension.interactor
|
||||
|
||||
import eu.kanade.domain.extension.model.Extensions
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
|
||||
class GetExtensionsByType(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
private val extensionManager: ExtensionManager,
|
||||
) {
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.kanade.domain.source.model.Pin
|
|||
import eu.kanade.domain.source.model.Pins
|
||||
import eu.kanade.domain.source.model.Source
|
||||
import eu.kanade.domain.source.repository.SourceRepository
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
|
@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
|||
|
||||
class GetEnabledSources(
|
||||
private val repository: SourceRepository,
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun subscribe(): Flow<List<Source>> {
|
||||
|
|
|
@ -2,14 +2,14 @@ package eu.kanade.domain.source.interactor
|
|||
|
||||
import eu.kanade.domain.source.model.Source
|
||||
import eu.kanade.domain.source.repository.SourceRepository
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
|
||||
class GetLanguagesWithSources(
|
||||
private val repository: SourceRepository,
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun subscribe(): Flow<Map<String, List<Source>>> {
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.kanade.domain.source.interactor
|
|||
|
||||
import eu.kanade.domain.source.model.Source
|
||||
import eu.kanade.domain.source.repository.SourceRepository
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import java.text.Collator
|
||||
|
@ -11,7 +11,7 @@ import java.util.Locale
|
|||
|
||||
class GetSourcesWithFavoriteCount(
|
||||
private val repository: SourceRepository,
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun subscribe(): Flow<List<Pair<Source, Long>>> {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
|
||||
class SetMigrateSorting(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun await(mode: Mode, direction: Direction) {
|
||||
|
@ -14,12 +14,10 @@ class SetMigrateSorting(
|
|||
enum class Mode {
|
||||
ALPHABETICAL,
|
||||
TOTAL,
|
||||
;
|
||||
}
|
||||
|
||||
enum class Direction {
|
||||
ASCENDING,
|
||||
DESCENDING,
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.getAndSet
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
|
||||
class ToggleLanguage(
|
||||
val preferences: PreferencesHelper,
|
||||
val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun await(language: String) {
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.domain.source.model.Source
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.getAndSet
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
|
||||
class ToggleSource(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun await(source: Source, enable: Boolean = source.id.toString() in preferences.disabledSources().get()) {
|
||||
fun await(source: Source, enable: Boolean = isEnabled(source.id)) {
|
||||
await(source.id, enable)
|
||||
}
|
||||
|
||||
fun await(sourceId: Long, enable: Boolean = sourceId.toString() in preferences.disabledSources().get()) {
|
||||
fun await(sourceId: Long, enable: Boolean = isEnabled(sourceId)) {
|
||||
preferences.disabledSources().getAndSet { disabled ->
|
||||
if (enable) disabled.minus("$sourceId") else disabled.plus("$sourceId")
|
||||
}
|
||||
}
|
||||
|
||||
private fun isEnabled(sourceId: Long): Boolean {
|
||||
return sourceId.toString() in preferences.disabledSources().get()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.domain.source.model.Source
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.getAndSet
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
|
||||
class ToggleSourcePin(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun await(source: Source) {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package eu.kanade.domain.source.service
|
||||
|
||||
import eu.kanade.domain.source.interactor.SetMigrateSorting
|
||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||
import eu.kanade.tachiyomi.core.preference.getEnum
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
|
||||
class SourcePreferences(
|
||||
private val preferenceStore: PreferenceStore,
|
||||
) {
|
||||
|
||||
fun enabledLanguages() = this.preferenceStore.getStringSet("source_languages", LocaleHelper.getDefaultEnabledLanguages())
|
||||
|
||||
fun disabledSources() = this.preferenceStore.getStringSet("hidden_catalogues", emptySet())
|
||||
|
||||
fun pinnedSources() = this.preferenceStore.getStringSet("pinned_catalogues", emptySet())
|
||||
|
||||
fun duplicatePinnedSources() = this.preferenceStore.getBoolean("duplicate_pinned_sources", false)
|
||||
|
||||
fun lastUsedSource() = this.preferenceStore.getLong("last_catalogue_source", -1)
|
||||
|
||||
fun showNsfwSource() = this.preferenceStore.getBoolean("show_nsfw_source", true)
|
||||
|
||||
fun migrationSortingMode() = this.preferenceStore.getEnum("pref_migration_sorting", SetMigrateSorting.Mode.ALPHABETICAL)
|
||||
|
||||
fun migrationSortingDirection() = this.preferenceStore.getEnum("pref_migration_direction", SetMigrateSorting.Direction.ASCENDING)
|
||||
|
||||
fun extensionUpdatesCount() = this.preferenceStore.getInt("ext_updates_count", 0)
|
||||
|
||||
fun trustedSignatures() = this.preferenceStore.getStringSet("trusted_signatures", emptySet())
|
||||
|
||||
fun searchPinnedSourcesOnly() = this.preferenceStore.getBoolean("search_pinned_sources_only", false)
|
||||
}
|
|
@ -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.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.AndroidPreferenceStore
|
||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
|
@ -130,6 +131,9 @@ class PreferenceModule(val application: Application) : InjektModule {
|
|||
verboseLogging = isDevFlavor,
|
||||
)
|
||||
}
|
||||
addSingletonFactory {
|
||||
SourcePreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
PreferencesHelper(
|
||||
context = application,
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||
import android.os.Build
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||
import eu.kanade.tachiyomi.data.preference.MANGA_NON_COMPLETED
|
||||
|
@ -37,6 +38,7 @@ object Migrations {
|
|||
context: Context,
|
||||
preferences: PreferencesHelper,
|
||||
networkPreferences: NetworkPreferences,
|
||||
sourcePreferences: SourcePreferences,
|
||||
): Boolean {
|
||||
val oldVersion = preferences.lastVersionCode().get()
|
||||
if (oldVersion < BuildConfig.VERSION_CODE) {
|
||||
|
@ -231,8 +233,8 @@ object Migrations {
|
|||
}
|
||||
}
|
||||
if (oldVersion < 70) {
|
||||
if (preferences.enabledLanguages().isSet()) {
|
||||
preferences.enabledLanguages() += "all"
|
||||
if (sourcePreferences.enabledLanguages().isSet()) {
|
||||
sourcePreferences.enabledLanguages() += "all"
|
||||
}
|
||||
}
|
||||
if (oldVersion < 71) {
|
||||
|
|
|
@ -37,9 +37,6 @@ object PreferenceKeys {
|
|||
|
||||
const val librarySortingMode = "library_sorting_mode"
|
||||
|
||||
const val migrationSortingMode = "pref_migration_sorting"
|
||||
const val migrationSortingDirection = "pref_migration_direction"
|
||||
|
||||
const val hideNotificationContent = "hide_notification_content"
|
||||
|
||||
const val autoUpdateMetadata = "auto_update_metadata"
|
||||
|
@ -54,8 +51,6 @@ object PreferenceKeys {
|
|||
|
||||
const val skipFiltered = "skip_filtered"
|
||||
|
||||
const val searchPinnedSourcesOnly = "search_pinned_sources_only"
|
||||
|
||||
const val defaultChapterFilterByRead = "default_chapter_filter_by_read"
|
||||
|
||||
const val defaultChapterFilterByDownloaded = "default_chapter_filter_by_downloaded"
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import androidx.core.net.toUri
|
||||
import eu.kanade.domain.source.interactor.SetMigrateSorting
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||
import eu.kanade.tachiyomi.core.preference.getEnum
|
||||
|
@ -16,7 +15,6 @@ 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.LocaleHelper
|
||||
import eu.kanade.tachiyomi.util.system.isDynamicColorAvailable
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView
|
||||
import java.io.File
|
||||
|
@ -166,16 +164,12 @@ class PreferencesHelper(
|
|||
|
||||
fun autoUpdateTrack() = this.preferenceStore.getBoolean(Keys.autoUpdateTrack, true)
|
||||
|
||||
fun lastUsedSource() = this.preferenceStore.getLong("last_catalogue_source", -1)
|
||||
|
||||
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 enabledLanguages() = this.preferenceStore.getStringSet("source_languages", LocaleHelper.getDefaultEnabledLanguages())
|
||||
|
||||
fun trackUsername(sync: TrackService) = this.preferenceStore.getString(Keys.trackUsername(sync.id), "")
|
||||
|
||||
fun trackPassword(sync: TrackService) = this.preferenceStore.getString(Keys.trackPassword(sync.id), "")
|
||||
|
@ -260,24 +254,11 @@ class PreferencesHelper(
|
|||
|
||||
fun librarySortingMode() = this.preferenceStore.getObject(Keys.librarySortingMode, LibrarySort.default, LibrarySort.Serializer::serialize, LibrarySort.Serializer::deserialize)
|
||||
|
||||
fun migrationSortingMode() = this.preferenceStore.getEnum(Keys.migrationSortingMode, SetMigrateSorting.Mode.ALPHABETICAL)
|
||||
fun migrationSortingDirection() = this.preferenceStore.getEnum(Keys.migrationSortingDirection, SetMigrateSorting.Direction.ASCENDING)
|
||||
|
||||
fun automaticExtUpdates() = this.preferenceStore.getBoolean("automatic_ext_updates", true)
|
||||
|
||||
fun showNsfwSource() = this.preferenceStore.getBoolean("show_nsfw_source", true)
|
||||
|
||||
fun extensionUpdatesCount() = this.preferenceStore.getInt("ext_updates_count", 0)
|
||||
|
||||
fun lastAppCheck() = this.preferenceStore.getLong("last_app_check", 0)
|
||||
fun lastExtCheck() = this.preferenceStore.getLong("last_ext_check", 0)
|
||||
|
||||
fun searchPinnedSourcesOnly() = this.preferenceStore.getBoolean(Keys.searchPinnedSourcesOnly, false)
|
||||
|
||||
fun disabledSources() = this.preferenceStore.getStringSet("hidden_catalogues", emptySet())
|
||||
|
||||
fun pinnedSources() = this.preferenceStore.getStringSet("pinned_catalogues", emptySet())
|
||||
|
||||
fun downloadNewChapters() = this.preferenceStore.getBoolean("download_new", false)
|
||||
|
||||
fun downloadNewChapterCategories() = this.preferenceStore.getStringSet("download_new_categories", emptySet())
|
||||
|
@ -295,8 +276,6 @@ class PreferencesHelper(
|
|||
|
||||
fun migrateFlags() = this.preferenceStore.getInt("migrate_flags", Int.MAX_VALUE)
|
||||
|
||||
fun trustedSignatures() = this.preferenceStore.getStringSet("trusted_signatures", emptySet())
|
||||
|
||||
fun filterChapterByRead() = this.preferenceStore.getInt(Keys.defaultChapterFilterByRead, DomainManga.SHOW_ALL.toInt())
|
||||
|
||||
fun filterChapterByDownloaded() = this.preferenceStore.getInt(Keys.defaultChapterFilterByDownloaded, DomainManga.SHOW_ALL.toInt())
|
||||
|
@ -320,8 +299,6 @@ class PreferencesHelper(
|
|||
|
||||
fun autoClearChapterCache() = this.preferenceStore.getBoolean(Keys.autoClearChapterCache, false)
|
||||
|
||||
fun duplicatePinnedSources() = this.preferenceStore.getBoolean("duplicate_pinned_sources", false)
|
||||
|
||||
fun setChapterSettingsDefault(manga: Manga) {
|
||||
filterChapterByRead().set(manga.readFilter)
|
||||
filterChapterByDownloaded().set(manga.downloadedFilter)
|
||||
|
|
|
@ -4,8 +4,8 @@ import android.content.Context
|
|||
import android.graphics.drawable.Drawable
|
||||
import com.jakewharton.rxrelay.BehaviorRelay
|
||||
import eu.kanade.domain.source.model.SourceData
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
|
||||
import eu.kanade.tachiyomi.extension.model.AvailableSources
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
|
@ -42,7 +42,7 @@ import java.util.Locale
|
|||
*/
|
||||
class ExtensionManager(
|
||||
private val context: Context,
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
private val preferences: SourcePreferences = Injekt.get(),
|
||||
) {
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.content.pm.PackageInfo
|
|||
import android.content.pm.PackageManager
|
||||
import androidx.core.content.pm.PackageInfoCompat
|
||||
import dalvik.system.PathClassLoader
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.extension.model.LoadResult
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
|
@ -26,7 +26,7 @@ import uy.kohesive.injekt.injectLazy
|
|||
@SuppressLint("PackageManagerGetSignatures")
|
||||
internal object ExtensionLoader {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val preferences: SourcePreferences by injectLazy()
|
||||
private val loadNsfwSource by lazy {
|
||||
preferences.showNsfwSource().get()
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source
|
|||
|
||||
import android.graphics.drawable.Drawable
|
||||
import eu.kanade.domain.source.model.SourceData
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -14,7 +14,7 @@ fun Source.getPreferenceKey(): String = "source_$id"
|
|||
fun Source.toSourceData(): SourceData = SourceData(id = id, lang = lang, name = name)
|
||||
|
||||
fun Source.getNameForMangaInfo(): String {
|
||||
val preferences = Injekt.get<PreferencesHelper>()
|
||||
val preferences = Injekt.get<SourcePreferences>()
|
||||
val enabledLanguages = preferences.enabledLanguages().get()
|
||||
.filterNot { it in listOf("all", "other") }
|
||||
val hasOneActiveLanguages = enabledLanguages.size == 1
|
||||
|
|
|
@ -3,9 +3,9 @@ package eu.kanade.tachiyomi.ui.browse.extension
|
|||
import android.os.Bundle
|
||||
import eu.kanade.domain.extension.interactor.GetExtensionLanguages
|
||||
import eu.kanade.domain.source.interactor.ToggleLanguage
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.browse.ExtensionFilterState
|
||||
import eu.kanade.presentation.browse.ExtensionFilterStateImpl
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
|
@ -21,7 +21,7 @@ class ExtensionFilterPresenter(
|
|||
private val state: ExtensionFilterStateImpl = ExtensionFilterState() as ExtensionFilterStateImpl,
|
||||
private val getExtensionLanguages: GetExtensionLanguages = Injekt.get(),
|
||||
private val toggleLanguage: ToggleLanguage = Injekt.get(),
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
private val preferences: SourcePreferences = Injekt.get(),
|
||||
) : BasePresenter<ExtensionFilterController>(), ExtensionFilterState by state {
|
||||
|
||||
private val _events = Channel<Event>(Int.MAX_VALUE)
|
||||
|
|
|
@ -3,11 +3,11 @@ package eu.kanade.tachiyomi.ui.browse.extension
|
|||
import android.app.Application
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.domain.extension.interactor.GetExtensionsByType
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.browse.ExtensionState
|
||||
import eu.kanade.presentation.browse.ExtensionsState
|
||||
import eu.kanade.presentation.browse.ExtensionsStateImpl
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.extension.model.InstallStep
|
||||
|
@ -31,7 +31,7 @@ import uy.kohesive.injekt.api.get
|
|||
class ExtensionsPresenter(
|
||||
private val presenterScope: CoroutineScope,
|
||||
private val state: ExtensionsStateImpl = ExtensionState() as ExtensionsStateImpl,
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
private val preferences: SourcePreferences = Injekt.get(),
|
||||
private val extensionManager: ExtensionManager = Injekt.get(),
|
||||
private val getExtensions: GetExtensionsByType = Injekt.get(),
|
||||
) : ExtensionsState by state {
|
||||
|
|
|
@ -150,7 +150,7 @@ class SearchController(
|
|||
}
|
||||
|
||||
override fun onTitleClick(source: CatalogueSource) {
|
||||
presenter.preferences.lastUsedSource().set(source.id)
|
||||
presenter.sourcePreferences.lastUsedSource().set(source.id)
|
||||
|
||||
router.pushController(SourceSearchController(manga, source, presenter.query))
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package eu.kanade.tachiyomi.ui.browse.migration.sources
|
|||
|
||||
import eu.kanade.domain.source.interactor.GetSourcesWithFavoriteCount
|
||||
import eu.kanade.domain.source.interactor.SetMigrateSorting
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.browse.MigrateSourceState
|
||||
import eu.kanade.presentation.browse.MigrateSourceStateImpl
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -21,7 +21,7 @@ import uy.kohesive.injekt.api.get
|
|||
class MigrationSourcesPresenter(
|
||||
private val presenterScope: CoroutineScope,
|
||||
private val state: MigrateSourceStateImpl = MigrateSourceState() as MigrateSourceStateImpl,
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
private val preferences: SourcePreferences = Injekt.get(),
|
||||
private val getSourcesWithFavoriteCount: GetSourcesWithFavoriteCount = Injekt.get(),
|
||||
private val setMigrateSorting: SetMigrateSorting = Injekt.get(),
|
||||
) : MigrateSourceState by state {
|
||||
|
|
|
@ -5,9 +5,9 @@ import eu.kanade.domain.source.interactor.GetLanguagesWithSources
|
|||
import eu.kanade.domain.source.interactor.ToggleLanguage
|
||||
import eu.kanade.domain.source.interactor.ToggleSource
|
||||
import eu.kanade.domain.source.model.Source
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.browse.SourcesFilterState
|
||||
import eu.kanade.presentation.browse.SourcesFilterStateImpl
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
|
@ -24,7 +24,7 @@ class SourcesFilterPresenter(
|
|||
private val getLanguagesWithSources: GetLanguagesWithSources = Injekt.get(),
|
||||
private val toggleSource: ToggleSource = Injekt.get(),
|
||||
private val toggleLanguage: ToggleLanguage = Injekt.get(),
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
private val preferences: SourcePreferences = Injekt.get(),
|
||||
) : BasePresenter<SourceFilterController>(), SourcesFilterState by state {
|
||||
|
||||
private val _events = Channel<Event>(Int.MAX_VALUE)
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.kanade.domain.source.interactor.ToggleSource
|
|||
import eu.kanade.domain.source.interactor.ToggleSourcePin
|
||||
import eu.kanade.domain.source.model.Pin
|
||||
import eu.kanade.domain.source.model.Source
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.browse.SourceUiModel
|
||||
import eu.kanade.presentation.browse.SourcesState
|
||||
import eu.kanade.presentation.browse.SourcesStateImpl
|
||||
|
@ -25,6 +26,7 @@ class SourcesPresenter(
|
|||
private val presenterScope: CoroutineScope,
|
||||
private val state: SourcesStateImpl = SourcesState() as SourcesStateImpl,
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
private val sourcePreferences: SourcePreferences = Injekt.get(),
|
||||
private val getEnabledSources: GetEnabledSources = Injekt.get(),
|
||||
private val toggleSource: ToggleSource = Injekt.get(),
|
||||
private val toggleSourcePin: ToggleSourcePin = Injekt.get(),
|
||||
|
@ -79,7 +81,7 @@ class SourcesPresenter(
|
|||
|
||||
fun onOpenSource(source: Source) {
|
||||
if (!preferences.incognitoMode().get()) {
|
||||
preferences.lastUsedSource().set(source.id)
|
||||
sourcePreferences.lastUsedSource().set(source.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import androidx.core.view.isVisible
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import dev.chrisbanes.insetter.applyInsetter
|
||||
import eu.kanade.domain.manga.model.Manga
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerBinding
|
||||
|
@ -34,6 +35,7 @@ open class GlobalSearchController(
|
|||
GlobalSearchAdapter.OnTitleClickListener {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
|
||||
/**
|
||||
* Adapter containing search results grouped by lang.
|
||||
|
@ -174,7 +176,7 @@ open class GlobalSearchController(
|
|||
* @param searchResult result of search.
|
||||
*/
|
||||
fun setItems(searchResult: List<GlobalSearchItem>) {
|
||||
if (searchResult.isEmpty() && preferences.searchPinnedSourcesOnly().get()) {
|
||||
if (searchResult.isEmpty() && sourcePreferences.searchPinnedSourcesOnly().get()) {
|
||||
binding.emptyView.show(R.string.no_pinned_sources)
|
||||
} else {
|
||||
binding.emptyView.hide()
|
||||
|
@ -205,7 +207,7 @@ open class GlobalSearchController(
|
|||
*/
|
||||
override fun onTitleClick(source: CatalogueSource) {
|
||||
if (!preferences.incognitoMode().get()) {
|
||||
preferences.lastUsedSource().set(source.id)
|
||||
sourcePreferences.lastUsedSource().set(source.id)
|
||||
}
|
||||
router.pushController(BrowseSourceController(source, presenter.query))
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import eu.kanade.domain.manga.interactor.InsertManga
|
|||
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.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
|
@ -35,6 +36,7 @@ open class GlobalSearchPresenter(
|
|||
private val initialExtensionFilter: String? = null,
|
||||
val sourceManager: SourceManager = Injekt.get(),
|
||||
val preferences: PreferencesHelper = Injekt.get(),
|
||||
val sourcePreferences: SourcePreferences = Injekt.get(),
|
||||
private val getManga: GetManga = Injekt.get(),
|
||||
private val insertManga: InsertManga = Injekt.get(),
|
||||
private val updateManga: UpdateManga = Injekt.get(),
|
||||
|
@ -96,9 +98,9 @@ open class GlobalSearchPresenter(
|
|||
* @return list containing enabled sources.
|
||||
*/
|
||||
protected open fun getEnabledSources(): List<CatalogueSource> {
|
||||
val languages = preferences.enabledLanguages().get()
|
||||
val disabledSourceIds = preferences.disabledSources().get()
|
||||
val pinnedSourceIds = preferences.pinnedSources().get()
|
||||
val languages = sourcePreferences.enabledLanguages().get()
|
||||
val disabledSourceIds = sourcePreferences.disabledSources().get()
|
||||
val pinnedSourceIds = sourcePreferences.pinnedSources().get()
|
||||
|
||||
return sourceManager.getCatalogueSources()
|
||||
.filter { it.lang in languages }
|
||||
|
@ -123,8 +125,8 @@ open class GlobalSearchPresenter(
|
|||
return filteredSources
|
||||
}
|
||||
|
||||
val onlyPinnedSources = preferences.searchPinnedSourcesOnly().get()
|
||||
val pinnedSourceIds = preferences.pinnedSources().get()
|
||||
val onlyPinnedSources = sourcePreferences.searchPinnedSourcesOnly().get()
|
||||
val pinnedSourceIds = sourcePreferences.pinnedSources().get()
|
||||
|
||||
return enabledSources
|
||||
.filter { if (onlyPinnedSources) it.id.toString() in pinnedSourceIds else true }
|
||||
|
@ -156,7 +158,7 @@ open class GlobalSearchPresenter(
|
|||
val initialItems = sources.map { createCatalogueSearchItem(it, null) }
|
||||
var items = initialItems
|
||||
|
||||
val pinnedSourceIds = preferences.pinnedSources().get()
|
||||
val pinnedSourceIds = sourcePreferences.pinnedSources().get()
|
||||
|
||||
fetchSourcesSubscription?.unsubscribe()
|
||||
fetchSourcesSubscription = Observable.from(sources)
|
||||
|
|
|
@ -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.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.Migrations
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -78,6 +79,8 @@ import uy.kohesive.injekt.injectLazy
|
|||
|
||||
class MainActivity : BaseActivity() {
|
||||
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
|
||||
lateinit var binding: MainActivityBinding
|
||||
|
||||
private lateinit var router: Router
|
||||
|
@ -112,6 +115,7 @@ class MainActivity : BaseActivity() {
|
|||
context = applicationContext,
|
||||
preferences = preferences,
|
||||
networkPreferences = Injekt.get(),
|
||||
sourcePreferences = sourcePreferences,
|
||||
)
|
||||
} else {
|
||||
false
|
||||
|
@ -254,7 +258,7 @@ class MainActivity : BaseActivity() {
|
|||
.onEach { setUnreadUpdatesBadge() }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.extensionUpdatesCount()
|
||||
sourcePreferences.extensionUpdatesCount()
|
||||
.asHotFlow { setExtensionsBadge() }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
|
@ -371,7 +375,7 @@ class MainActivity : BaseActivity() {
|
|||
this@MainActivity,
|
||||
fromAvailableExtensionList = true,
|
||||
)?.let { pendingUpdates ->
|
||||
preferences.extensionUpdatesCount().set(pendingUpdates.size)
|
||||
sourcePreferences.extensionUpdatesCount().set(pendingUpdates.size)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
|
@ -392,7 +396,7 @@ class MainActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
private fun setExtensionsBadge() {
|
||||
val updates = preferences.extensionUpdatesCount().get()
|
||||
val updates = sourcePreferences.extensionUpdatesCount().get()
|
||||
if (updates > 0) {
|
||||
nav.getOrCreateBadge(R.id.nav_browse).apply {
|
||||
number = updates
|
||||
|
|
|
@ -2,10 +2,10 @@ package eu.kanade.tachiyomi.ui.setting
|
|||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.infoPreference
|
||||
import eu.kanade.tachiyomi.util.preference.onChange
|
||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
|
@ -14,10 +14,12 @@ import eu.kanade.tachiyomi.util.preference.summaryRes
|
|||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupported
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class SettingsBrowseController : SettingsController() {
|
||||
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||
titleRes = R.string.browse
|
||||
|
||||
|
@ -25,7 +27,7 @@ class SettingsBrowseController : SettingsController() {
|
|||
titleRes = R.string.label_sources
|
||||
|
||||
switchPreference {
|
||||
bindTo(preferences.duplicatePinnedSources())
|
||||
bindTo(sourcePreferences.duplicatePinnedSources())
|
||||
titleRes = R.string.pref_duplicate_pinned_sources
|
||||
summaryRes = R.string.pref_duplicate_pinned_sources_summary
|
||||
}
|
||||
|
@ -50,9 +52,8 @@ class SettingsBrowseController : SettingsController() {
|
|||
titleRes = R.string.action_global_search
|
||||
|
||||
switchPreference {
|
||||
key = Keys.searchPinnedSourcesOnly
|
||||
bindTo(sourcePreferences.searchPinnedSourcesOnly())
|
||||
titleRes = R.string.pref_search_pinned_sources_only
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@ class SettingsBrowseController : SettingsController() {
|
|||
titleRes = R.string.pref_category_nsfw_content
|
||||
|
||||
switchPreference {
|
||||
bindTo(preferences.showNsfwSource())
|
||||
bindTo(sourcePreferences.showNsfwSource())
|
||||
titleRes = R.string.pref_show_nsfw_source
|
||||
summaryRes = R.string.requires_app_restart
|
||||
|
||||
|
|
Loading…
Reference in a new issue