Split source preferences from PreferencesHelper (#8029)
(cherry picked from commit 30b3b2d3ffd5d90aee293e9ae22b3cb2a4924c2b) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/AppModule.kt # app/src/main/java/eu/kanade/tachiyomi/source/SourceExtensions.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterPresenter.kt
This commit is contained in:
parent
41c9c20e26
commit
5d1dfb5290
@ -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,
|
||||
) {
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
|
||||
class CreateSourceCategory(private val preferences: PreferencesHelper) {
|
||||
class CreateSourceCategory(private val preferences: SourcePreferences) {
|
||||
|
||||
fun await(category: String): Result {
|
||||
// Do not allow duplicate categories.
|
||||
|
@ -1,16 +1,15 @@
|
||||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.getAndSet
|
||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||
|
||||
class DeleteSourceCategory(private val preferences: PreferencesHelper) {
|
||||
class DeleteSourceCategory(private val preferences: SourcePreferences) {
|
||||
|
||||
fun await(category: String) {
|
||||
preferences.sourcesTabSourcesInCategories().set(
|
||||
preferences.sourcesTabSourcesInCategories().get()
|
||||
.filterNot { it.substringAfter("|") == category }
|
||||
.toSet(),
|
||||
)
|
||||
preferences.sourcesTabSourcesInCategories().getAndSet { sourcesInCategories ->
|
||||
sourcesInCategories.filterNot { it.substringAfter("|") == category }.toSet()
|
||||
}
|
||||
preferences.sourcesTabCategories() -= category
|
||||
}
|
||||
}
|
||||
|
@ -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 exh.source.BlacklistedSources
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@ -13,7 +13,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,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 eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import exh.source.BlacklistedSources
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@ -10,7 +10,7 @@ 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>>> {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
class GetSourceCategories(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun subscribe(): Flow<List<String>> {
|
||||
|
@ -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,10 @@
|
||||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.getAndSet
|
||||
|
||||
class RenameSourceCategory(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
private val createSourceCategory: CreateSourceCategory,
|
||||
) {
|
||||
|
||||
@ -14,23 +15,19 @@ class RenameSourceCategory(
|
||||
CreateSourceCategory.Result.Success -> {}
|
||||
}
|
||||
|
||||
preferences.sourcesTabSourcesInCategories().set(
|
||||
preferences.sourcesTabSourcesInCategories().get()
|
||||
.map {
|
||||
val index = it.indexOf('|')
|
||||
if (index != -1 && it.substring(index + 1) == categoryOld) {
|
||||
it.substring(0, index + 1) + categoryNew
|
||||
} else {
|
||||
it
|
||||
}
|
||||
preferences.sourcesTabSourcesInCategories().getAndSet { sourcesInCategories ->
|
||||
sourcesInCategories.map {
|
||||
val index = it.indexOf('|')
|
||||
if (index != -1 && it.substring(index + 1) == categoryOld) {
|
||||
it.substring(0, index + 1) + categoryNew
|
||||
} else {
|
||||
it
|
||||
}
|
||||
.toSet(),
|
||||
)
|
||||
preferences.sourcesTabCategories().set(
|
||||
preferences.sourcesTabCategories().get()
|
||||
.minus(categoryOld)
|
||||
.plus(categoryNew),
|
||||
)
|
||||
}.toSet()
|
||||
}
|
||||
preferences.sourcesTabCategories().getAndSet {
|
||||
it.minus(categoryOld).plus(categoryNew)
|
||||
}
|
||||
|
||||
return CreateSourceCategory.Result.Success
|
||||
}
|
||||
|
@ -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,22 +1,23 @@
|
||||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.domain.source.model.Source
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.getAndSet
|
||||
|
||||
class SetSourceCategories(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun await(source: Source, sourceCategories: List<String>) {
|
||||
val sourceIdString = source.id.toString()
|
||||
val currentSourceCategories = preferences.sourcesTabSourcesInCategories().get().filterNot {
|
||||
it.substringBefore('|') == sourceIdString
|
||||
preferences.sourcesTabSourcesInCategories().getAndSet { sourcesInCategories ->
|
||||
val currentSourceCategories = sourcesInCategories.filterNot {
|
||||
it.substringBefore('|') == sourceIdString
|
||||
}
|
||||
val newSourceCategories = currentSourceCategories + sourceCategories.map {
|
||||
"$sourceIdString|$it"
|
||||
}
|
||||
newSourceCategories.toSet()
|
||||
}
|
||||
val newSourceCategories = currentSourceCategories + sourceCategories.map {
|
||||
"$sourceIdString|$it"
|
||||
}
|
||||
preferences.sourcesTabSourcesInCategories().set(newSourceCategories.toSet())
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
package eu.kanade.domain.source.interactor
|
||||
|
||||
import eu.kanade.domain.source.model.Source
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.getAndSet
|
||||
|
||||
class ToggleExcludeFromDataSaver(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun await(source: Source) {
|
||||
val isExcluded = source.id.toString() in preferences.dataSaverExcludedSources().get()
|
||||
if (isExcluded) {
|
||||
preferences.dataSaverExcludedSources() -= source.id.toString()
|
||||
} else {
|
||||
preferences.dataSaverExcludedSources() += source.id.toString()
|
||||
preferences.dataSaverExcludedSources().getAndSet {
|
||||
if (source.id.toString() in it) {
|
||||
it - source.id.toString()
|
||||
} else {
|
||||
it + source.id.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -1,11 +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
|
||||
|
||||
class ToggleSources(
|
||||
private val preferences: PreferencesHelper,
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
fun await(isEnable: Boolean, sources: List<Source>) {
|
||||
|
@ -0,0 +1,61 @@
|
||||
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)
|
||||
|
||||
// SY -->
|
||||
fun enableSourceBlacklist() = this.preferenceStore.getBoolean("eh_enable_source_blacklist", true)
|
||||
|
||||
fun sourcesTabCategories() = this.preferenceStore.getStringSet("sources_tab_categories", mutableSetOf())
|
||||
|
||||
fun sourcesTabCategoriesFilter() = this.preferenceStore.getBoolean("sources_tab_categories_filter", false)
|
||||
|
||||
fun sourcesTabSourcesInCategories() = this.preferenceStore.getStringSet("sources_tab_source_categories", mutableSetOf())
|
||||
|
||||
fun dataSaver() = this.preferenceStore.getBoolean("data_saver", false)
|
||||
|
||||
fun dataSaverIgnoreJpeg() = this.preferenceStore.getBoolean("ignore_jpeg", false)
|
||||
|
||||
fun dataSaverIgnoreGif() = this.preferenceStore.getBoolean("ignore_gif", true)
|
||||
|
||||
fun dataSaverImageQuality() = this.preferenceStore.getInt("data_saver_image_quality", 80)
|
||||
|
||||
fun dataSaverImageFormatJpeg() = this.preferenceStore.getBoolean("data_saver_image_format_jpeg", false)
|
||||
|
||||
fun dataSaverServer() = this.preferenceStore.getString("data_saver_server", "")
|
||||
|
||||
fun dataSaverColorBW() = this.preferenceStore.getBoolean("data_saver_color_bw", false)
|
||||
|
||||
fun dataSaverExcludedSources() = this.preferenceStore.getStringSet("data_saver_excluded", emptySet())
|
||||
|
||||
fun dataSaverDownloader() = this.preferenceStore.getBoolean("data_saver_downloader", true)
|
||||
// SY <--
|
||||
}
|
@ -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.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.AndroidPreferenceStore
|
||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
@ -33,7 +34,6 @@ import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
||||
import exh.eh.EHentaiUpdateHelper
|
||||
import exh.pref.SourcePreferences
|
||||
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
|
||||
import kotlinx.serialization.json.Json
|
||||
import uy.kohesive.injekt.api.InjektModule
|
||||
@ -157,6 +157,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
|
||||
@ -39,6 +40,7 @@ object Migrations {
|
||||
context: Context,
|
||||
preferences: PreferencesHelper,
|
||||
networkPreferences: NetworkPreferences,
|
||||
sourcePreferences: SourcePreferences,
|
||||
): Boolean {
|
||||
val oldVersion = preferences.lastVersionCode().get()
|
||||
if (oldVersion < BuildConfig.VERSION_CODE) {
|
||||
@ -234,8 +236,8 @@ object Migrations {
|
||||
}
|
||||
}
|
||||
if (oldVersion < 70) {
|
||||
if (preferences.enabledLanguages().isSet()) {
|
||||
preferences.enabledLanguages() += "all"
|
||||
if (sourcePreferences.enabledLanguages().isSet()) {
|
||||
sourcePreferences.enabledLanguages() += "all"
|
||||
}
|
||||
}
|
||||
if (oldVersion < 71) {
|
||||
|
@ -5,6 +5,7 @@ import com.hippo.unifile.UniFile
|
||||
import com.jakewharton.rxrelay.BehaviorRelay
|
||||
import com.jakewharton.rxrelay.PublishRelay
|
||||
import eu.kanade.domain.manga.model.Manga
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
@ -65,6 +66,9 @@ class Downloader(
|
||||
private val sourceManager: SourceManager = Injekt.get(),
|
||||
private val chapterCache: ChapterCache = Injekt.get(),
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
// SY -->
|
||||
private val sourcePreferences: SourcePreferences = Injekt.get(),
|
||||
// SY <--
|
||||
) {
|
||||
|
||||
/**
|
||||
@ -329,8 +333,8 @@ class Downloader(
|
||||
Observable.just(download.pages!!)
|
||||
}
|
||||
|
||||
val dataSaver = if (preferences.dataSaverDownloader().get()) {
|
||||
DataSaver(download.source, preferences)
|
||||
val dataSaver = if (sourcePreferences.dataSaverDownloader().get()) {
|
||||
DataSaver(download.source, sourcePreferences)
|
||||
} else {
|
||||
DataSaver.NoOp
|
||||
}
|
||||
|
@ -700,7 +700,7 @@ class LibraryUpdateService(
|
||||
*/
|
||||
private suspend fun syncFollows() {
|
||||
var count = 0
|
||||
val mangaDex = MdUtil.getEnabledMangaDex(preferences, sourceManager) ?: return
|
||||
val mangaDex = MdUtil.getEnabledMangaDex(preferences, sourceManager = sourceManager) ?: return
|
||||
val syncFollowStatusInts = preferences.mangadexSyncToLibraryIndexes().get().map { it.toInt() }
|
||||
|
||||
val size: Int
|
||||
|
@ -39,9 +39,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"
|
||||
@ -56,8 +53,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
|
||||
@ -19,7 +18,6 @@ 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.LocaleHelper
|
||||
import eu.kanade.tachiyomi.util.system.isDynamicColorAvailable
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView
|
||||
import java.io.File
|
||||
@ -175,16 +173,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), "")
|
||||
@ -273,24 +267,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())
|
||||
@ -308,8 +289,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())
|
||||
@ -333,8 +312,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)
|
||||
@ -410,8 +387,6 @@ class PreferencesHelper(
|
||||
|
||||
fun logLevel() = this.preferenceStore.getInt(Keys.eh_logLevel, 0)
|
||||
|
||||
fun enableSourceBlacklist() = this.preferenceStore.getBoolean("eh_enable_source_blacklist", true)
|
||||
|
||||
fun exhAutoUpdateFrequency() = this.preferenceStore.getInt("eh_auto_update_frequency", 1)
|
||||
|
||||
fun exhAutoUpdateRequirements() = this.preferenceStore.getStringSet("eh_auto_update_restrictions", emptySet())
|
||||
@ -438,12 +413,6 @@ class PreferencesHelper(
|
||||
|
||||
fun feedTabInFront() = this.preferenceStore.getBoolean("latest_tab_position", false)
|
||||
|
||||
fun sourcesTabCategories() = this.preferenceStore.getStringSet("sources_tab_categories", mutableSetOf())
|
||||
|
||||
fun sourcesTabCategoriesFilter() = this.preferenceStore.getBoolean("sources_tab_categories_filter", false)
|
||||
|
||||
fun sourcesTabSourcesInCategories() = this.preferenceStore.getStringSet("sources_tab_source_categories", mutableSetOf())
|
||||
|
||||
fun sourceSorting() = this.preferenceStore.getInt("sources_sort", 0)
|
||||
|
||||
fun recommendsInOverflow() = this.preferenceStore.getBoolean("recommends_in_overflow", false)
|
||||
@ -468,24 +437,6 @@ class PreferencesHelper(
|
||||
|
||||
fun mangadexSyncToLibraryIndexes() = this.preferenceStore.getStringSet("pref_mangadex_sync_to_library_indexes", emptySet())
|
||||
|
||||
fun dataSaver() = this.preferenceStore.getBoolean("data_saver", false)
|
||||
|
||||
fun dataSaverIgnoreJpeg() = this.preferenceStore.getBoolean("ignore_jpeg", false)
|
||||
|
||||
fun dataSaverIgnoreGif() = this.preferenceStore.getBoolean("ignore_gif", true)
|
||||
|
||||
fun dataSaverImageQuality() = this.preferenceStore.getInt("data_saver_image_quality", 80)
|
||||
|
||||
fun dataSaverImageFormatJpeg() = this.preferenceStore.getBoolean("data_saver_image_format_jpeg", false)
|
||||
|
||||
fun dataSaverServer() = this.preferenceStore.getString("data_saver_server", "")
|
||||
|
||||
fun dataSaverColorBW() = this.preferenceStore.getBoolean("data_saver_color_bw", false)
|
||||
|
||||
fun dataSaverExcludedSources() = this.preferenceStore.getStringSet("data_saver_excluded", emptySet())
|
||||
|
||||
fun dataSaverDownloader() = this.preferenceStore.getBoolean("data_saver_downloader", true)
|
||||
|
||||
fun allowLocalSourceHiddenFolders() = this.preferenceStore.getBoolean("allow_local_source_hidden_folders", false)
|
||||
|
||||
fun authenticatorTimeRanges() = this.preferenceStore.getStringSet("biometric_time_ranges", mutableSetOf())
|
||||
|
@ -5,8 +5,8 @@ import android.graphics.drawable.Drawable
|
||||
import androidx.core.content.ContextCompat
|
||||
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
|
||||
@ -48,7 +48,7 @@ import java.util.Locale
|
||||
*/
|
||||
class ExtensionManager(
|
||||
private val context: Context,
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
private val preferences: SourcePreferences = Injekt.get(),
|
||||
) {
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.extension.api
|
||||
|
||||
import android.content.Context
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.model.AvailableSources
|
||||
@ -26,6 +27,10 @@ internal class ExtensionGithubApi {
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val extensionManager: ExtensionManager by injectLazy()
|
||||
|
||||
// SY -->
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
// SY <--
|
||||
|
||||
private var requiresFallbackSource = false
|
||||
|
||||
suspend fun findExtensions(): List<Extension.Available> {
|
||||
@ -91,7 +96,7 @@ internal class ExtensionGithubApi {
|
||||
}
|
||||
|
||||
// SY -->
|
||||
val blacklistEnabled = preferences.enableSourceBlacklist().get()
|
||||
val blacklistEnabled = sourcePreferences.enableSourceBlacklist().get()
|
||||
// SY <--
|
||||
|
||||
val installedExtensions = ExtensionLoader.loadExtensions(context)
|
||||
@ -172,7 +177,7 @@ internal class ExtensionGithubApi {
|
||||
|
||||
// SY -->
|
||||
private fun Extension.isBlacklisted(
|
||||
blacklistEnabled: Boolean = preferences.enableSourceBlacklist().get(),
|
||||
blacklistEnabled: Boolean = sourcePreferences.enableSourceBlacklist().get(),
|
||||
): Boolean {
|
||||
return pkgName in BlacklistedSources.BLACKLISTED_EXTENSIONS && blacklistEnabled
|
||||
}
|
||||
|
@ -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(mergeSources: List<Source>?): 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 {
|
||||
|
@ -14,6 +14,7 @@ import eu.kanade.domain.source.interactor.GetFeedSavedSearchGlobal
|
||||
import eu.kanade.domain.source.interactor.GetSavedSearchBySourceId
|
||||
import eu.kanade.domain.source.interactor.GetSavedSearchGlobalFeed
|
||||
import eu.kanade.domain.source.interactor.InsertFeedSavedSearch
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.browse.FeedItemUI
|
||||
import eu.kanade.presentation.browse.FeedState
|
||||
import eu.kanade.presentation.browse.FeedStateImpl
|
||||
@ -64,6 +65,7 @@ open class FeedPresenter(
|
||||
private val state: FeedStateImpl = FeedState() as FeedStateImpl,
|
||||
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(),
|
||||
@ -124,8 +126,8 @@ open class FeedPresenter(
|
||||
}
|
||||
|
||||
fun getEnabledSources(): List<CatalogueSource> {
|
||||
val languages = preferences.enabledLanguages().get()
|
||||
val pinnedSources = preferences.pinnedSources().get()
|
||||
val languages = sourcePreferences.enabledLanguages().get()
|
||||
val pinnedSources = sourcePreferences.pinnedSources().get()
|
||||
|
||||
val list = sourceManager.getVisibleCatalogueSources()
|
||||
.filter { it.lang in languages }
|
||||
|
@ -39,11 +39,11 @@ fun feedTab(
|
||||
presenter.createFeed(source, savedSearch)
|
||||
},
|
||||
onClickSavedSearch = { savedSearch, source ->
|
||||
presenter.preferences.lastUsedSource().set(savedSearch.source)
|
||||
presenter.sourcePreferences.lastUsedSource().set(savedSearch.source)
|
||||
router?.pushController(BrowseSourceController(source, savedSearch = savedSearch.id))
|
||||
},
|
||||
onClickSource = { source ->
|
||||
presenter.preferences.lastUsedSource().set(source.id)
|
||||
presenter.sourcePreferences.lastUsedSource().set(source.id)
|
||||
router?.pushController(BrowseSourceController(source, GetRemoteManga.QUERY_LATEST))
|
||||
},
|
||||
onClickDelete = {
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.migration.advanced.design
|
||||
|
||||
import android.os.Bundle
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@ -16,6 +17,10 @@ class MigrationSourceAdapter(
|
||||
val preferences: PreferencesHelper by injectLazy()
|
||||
val sourceManager: SourceManager by injectLazy()
|
||||
|
||||
// SY _->
|
||||
val sourcePreferences: SourcePreferences by injectLazy()
|
||||
// SY <--
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
|
||||
|
@ -16,7 +16,7 @@ class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
||||
}
|
||||
|
||||
fun bind(source: HttpSource, sourceEnabled: Boolean) {
|
||||
val isMultiLanguage = adapter.preferences.enabledLanguages().get().size > 1
|
||||
val isMultiLanguage = adapter.sourcePreferences.enabledLanguages().get().size > 1
|
||||
// Set capitalized title.
|
||||
val sourceName = if (isMultiLanguage) source.toString() else source.name.capitalize()
|
||||
binding.title.text = sourceName
|
||||
|
@ -39,6 +39,7 @@ import androidx.core.view.updatePadding
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.bluelinelabs.conductor.Router
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.components.AppBar
|
||||
import eu.kanade.presentation.components.DropdownMenu
|
||||
import eu.kanade.presentation.components.ExtendedFloatingActionButton
|
||||
@ -69,6 +70,7 @@ class PreMigrationController(bundle: Bundle? = null) :
|
||||
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
private val prefs: PreferencesHelper by injectLazy()
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
|
||||
private var adapter: MigrationSourceAdapter? = null
|
||||
|
||||
@ -274,10 +276,10 @@ class PreMigrationController(bundle: Bundle? = null) :
|
||||
* @return list containing enabled sources.
|
||||
*/
|
||||
private fun getEnabledSources(): List<MigrationSourceItem> {
|
||||
val languages = prefs.enabledLanguages().get()
|
||||
val languages = sourcePreferences.enabledLanguages().get()
|
||||
val sourcesSaved = prefs.migrationSources().get().split("/")
|
||||
.mapNotNull { it.toLongOrNull() }
|
||||
val disabledSources = prefs.disabledSources().get()
|
||||
val disabledSources = sourcePreferences.disabledSources().get()
|
||||
.mapNotNull { it.toLongOrNull() }
|
||||
val sources = sourceManager.getVisibleCatalogueSources()
|
||||
.filterIsInstance<HttpSource>()
|
||||
@ -323,9 +325,9 @@ class PreMigrationController(bundle: Bundle? = null) :
|
||||
private fun matchSelection(matchEnabled: Boolean) {
|
||||
val adapter = adapter ?: return
|
||||
val enabledSources = if (matchEnabled) {
|
||||
prefs.disabledSources().get().mapNotNull { it.toLongOrNull() }
|
||||
sourcePreferences.disabledSources().get().mapNotNull { it.toLongOrNull() }
|
||||
} else {
|
||||
prefs.pinnedSources().get().mapNotNull { it.toLongOrNull() }
|
||||
sourcePreferences.pinnedSources().get().mapNotNull { it.toLongOrNull() }
|
||||
}
|
||||
val items = adapter.currentItems.toList()
|
||||
items.forEach {
|
||||
|
@ -110,7 +110,7 @@ class SearchController(
|
||||
}
|
||||
|
||||
override fun onTitleClick(source: CatalogueSource) {
|
||||
presenter.preferences.lastUsedSource().set(source.id)
|
||||
presenter.sourcePreferences.lastUsedSource().set(source.id)
|
||||
|
||||
router.pushController(SourceSearchController(targetController as? MigrationListController ?: return, 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 {
|
||||
|
@ -6,9 +6,9 @@ import eu.kanade.domain.source.interactor.ToggleLanguage
|
||||
import eu.kanade.domain.source.interactor.ToggleSource
|
||||
import eu.kanade.domain.source.interactor.ToggleSources
|
||||
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
|
||||
@ -25,7 +25,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(),
|
||||
// SY -->
|
||||
private val toggleSources: ToggleSources = Injekt.get(),
|
||||
// SY <--
|
||||
|
@ -9,6 +9,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
|
||||
@ -32,6 +33,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(),
|
||||
@ -115,7 +117,7 @@ class SourcesPresenter(
|
||||
|
||||
fun onOpenSource(source: Source) {
|
||||
if (!preferences.incognitoMode().get()) {
|
||||
preferences.lastUsedSource().set(source.id)
|
||||
sourcePreferences.lastUsedSource().set(source.id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,6 +149,7 @@ class SourcesPresenter(
|
||||
companion object {
|
||||
const val PINNED_KEY = "pinned"
|
||||
const val LAST_USED_KEY = "last_used"
|
||||
|
||||
// SY -->
|
||||
const val CATEGORY_KEY_PREFIX = "category-"
|
||||
// SY <--
|
||||
|
@ -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
|
||||
@ -35,6 +36,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.
|
||||
@ -180,7 +182,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()
|
||||
@ -211,7 +213,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
|
||||
@ -36,6 +37,7 @@ open class GlobalSearchPresenter(
|
||||
private val sourcesToUse: List<CatalogueSource>? = 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(),
|
||||
@ -97,9 +99,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.getVisibleCatalogueSources()
|
||||
.filter { it.lang in languages }
|
||||
@ -125,8 +127,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 }
|
||||
@ -158,7 +160,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)
|
||||
|
@ -35,6 +35,7 @@ import eu.kanade.domain.manga.interactor.UpdateManga
|
||||
import eu.kanade.domain.manga.model.Manga
|
||||
import eu.kanade.domain.manga.model.MangaUpdate
|
||||
import eu.kanade.domain.manga.model.isLocal
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.domain.track.interactor.GetTracks
|
||||
import eu.kanade.domain.track.model.Track
|
||||
import eu.kanade.presentation.category.visualName
|
||||
@ -134,6 +135,7 @@ class LibraryPresenter(
|
||||
private val downloadManager: DownloadManager = Injekt.get(),
|
||||
private val trackManager: TrackManager = Injekt.get(),
|
||||
// SY -->
|
||||
private val sourcePreferences: SourcePreferences = Injekt.get(),
|
||||
private val searchEngine: SearchEngine = SearchEngine(),
|
||||
private val customMangaManager: CustomMangaManager = Injekt.get(),
|
||||
private val getMergedMangaById: GetMergedMangaById = Injekt.get(),
|
||||
@ -201,7 +203,7 @@ class LibraryPresenter(
|
||||
// SY -->
|
||||
combine(
|
||||
preferences.isHentaiEnabled().changes(),
|
||||
preferences.disabledSources().changes(),
|
||||
sourcePreferences.disabledSources().changes(),
|
||||
preferences.enableExhentai().changes(),
|
||||
) { isHentaiEnabled, disabledSources, enableExhentai ->
|
||||
state.showSyncExh = isHentaiEnabled && (EH_SOURCE_ID.toString() !in disabledSources || enableExhentai)
|
||||
@ -801,7 +803,7 @@ class LibraryPresenter(
|
||||
|
||||
fun syncMangaToDex(mangaList: List<DbManga>) {
|
||||
launchIO {
|
||||
MdUtil.getEnabledMangaDex(preferences, sourceManager)?.let { mdex ->
|
||||
MdUtil.getEnabledMangaDex(preferences, sourcePreferences, sourceManager)?.let { mdex ->
|
||||
mangaList.forEach {
|
||||
mdex.updateFollowStatus(MdUtil.getMangaId(it.url), FollowStatus.READING)
|
||||
}
|
||||
|
@ -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.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
@ -86,6 +87,8 @@ import java.util.LinkedList
|
||||
|
||||
class MainActivity : BaseActivity() {
|
||||
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
|
||||
lateinit var binding: MainActivityBinding
|
||||
|
||||
private lateinit var router: Router
|
||||
@ -139,6 +142,7 @@ class MainActivity : BaseActivity() {
|
||||
context = applicationContext,
|
||||
preferences = preferences,
|
||||
networkPreferences = Injekt.get(),
|
||||
sourcePreferences = sourcePreferences,
|
||||
)
|
||||
} else {
|
||||
false
|
||||
@ -302,7 +306,7 @@ class MainActivity : BaseActivity() {
|
||||
.onEach { setUnreadUpdatesBadge() }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.extensionUpdatesCount()
|
||||
sourcePreferences.extensionUpdatesCount()
|
||||
.asHotFlow { setExtensionsBadge() }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
@ -425,7 +429,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)
|
||||
@ -446,7 +450,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
|
||||
|
@ -1,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.loader
|
||||
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
import eu.kanade.tachiyomi.data.database.models.toDomainChapter
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
@ -34,7 +35,8 @@ class HttpPageLoader(
|
||||
private val chapterCache: ChapterCache = Injekt.get(),
|
||||
// SY -->
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
// SY <--
|
||||
private val sourcePreferences: SourcePreferences = Injekt.get(),
|
||||
// SY <--
|
||||
) : PageLoader() {
|
||||
|
||||
/**
|
||||
@ -50,7 +52,7 @@ class HttpPageLoader(
|
||||
private val preloadSize = /* SY --> */ preferences.preloadSize().get() // SY <--
|
||||
|
||||
// SY -->
|
||||
private val dataSaver = DataSaver(source, preferences)
|
||||
private val dataSaver = DataSaver(source, sourcePreferences)
|
||||
// SY <--
|
||||
|
||||
init {
|
||||
|
@ -18,6 +18,7 @@ import eu.kanade.domain.chapter.interactor.GetChapterByMangaId
|
||||
import eu.kanade.domain.chapter.model.toDbChapter
|
||||
import eu.kanade.domain.manga.interactor.GetAllManga
|
||||
import eu.kanade.domain.manga.repository.MangaRepository
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
import eu.kanade.tachiyomi.data.cache.PagePreviewCache
|
||||
@ -71,7 +72,7 @@ import eu.kanade.tachiyomi.util.system.setDefaultSettings
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.debug.SettingsDebugController
|
||||
import exh.log.EHLogLevel
|
||||
import exh.pref.SourcePreferences
|
||||
import exh.pref.DelegateSourcePreferences
|
||||
import exh.source.BlacklistedSources
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
@ -93,6 +94,7 @@ class SettingsAdvancedController(
|
||||
private val trackManager: TrackManager by injectLazy()
|
||||
private val networkPreferences: NetworkPreferences by injectLazy()
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
private val delegateSourcePreferences: DelegateSourcePreferences by injectLazy()
|
||||
private val getAllManga: GetAllManga by injectLazy()
|
||||
private val getChapterByMangaId: GetChapterByMangaId by injectLazy()
|
||||
private val pagePreviewCache: PagePreviewCache by injectLazy()
|
||||
@ -388,64 +390,64 @@ class SettingsAdvancedController(
|
||||
titleRes = R.string.data_saver
|
||||
|
||||
switchPreference {
|
||||
bindTo(preferences.dataSaver())
|
||||
bindTo(sourcePreferences.dataSaver())
|
||||
titleRes = R.string.data_saver
|
||||
summaryRes = R.string.data_saver_summary
|
||||
}
|
||||
|
||||
editTextPreference {
|
||||
bindTo(preferences.dataSaverServer())
|
||||
bindTo(sourcePreferences.dataSaverServer())
|
||||
titleRes = R.string.data_saver_server
|
||||
summaryRes = R.string.data_saver_server_summary
|
||||
|
||||
visibleIf(preferences.dataSaver()) { it }
|
||||
visibleIf(sourcePreferences.dataSaver()) { it }
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
bindTo(preferences.dataSaverDownloader())
|
||||
bindTo(sourcePreferences.dataSaverDownloader())
|
||||
titleRes = R.string.data_saver_downloader
|
||||
|
||||
visibleIf(preferences.dataSaver()) { it }
|
||||
visibleIf(sourcePreferences.dataSaver()) { it }
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
bindTo(preferences.dataSaverIgnoreJpeg())
|
||||
bindTo(sourcePreferences.dataSaverIgnoreJpeg())
|
||||
titleRes = R.string.data_saver_ignore_jpeg
|
||||
|
||||
visibleIf(preferences.dataSaver()) { it }
|
||||
visibleIf(sourcePreferences.dataSaver()) { it }
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
bindTo(preferences.dataSaverIgnoreGif())
|
||||
bindTo(sourcePreferences.dataSaverIgnoreGif())
|
||||
titleRes = R.string.data_saver_ignore_gif
|
||||
|
||||
visibleIf(preferences.dataSaver()) { it }
|
||||
visibleIf(sourcePreferences.dataSaver()) { it }
|
||||
}
|
||||
|
||||
intListPreference {
|
||||
bindTo(preferences.dataSaverImageQuality())
|
||||
bindTo(sourcePreferences.dataSaverImageQuality())
|
||||
titleRes = R.string.data_saver_image_quality
|
||||
entries = arrayOf("10%", "20%", "40%", "50%", "70%", "80%", "90%", "95%")
|
||||
entryValues = entries.map { it.trimEnd('%') }.toTypedArray()
|
||||
summaryRes = R.string.data_saver_image_quality_summary
|
||||
|
||||
visibleIf(preferences.dataSaver()) { it }
|
||||
visibleIf(sourcePreferences.dataSaver()) { it }
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
bindTo(preferences.dataSaverImageFormatJpeg())
|
||||
bindTo(sourcePreferences.dataSaverImageFormatJpeg())
|
||||
titleRes = R.string.data_saver_image_format
|
||||
summaryOn = context.getString(R.string.data_saver_image_format_summary_on)
|
||||
summaryOff = context.getString(R.string.data_saver_image_format_summary_off)
|
||||
|
||||
visibleIf(preferences.dataSaver()) { it }
|
||||
visibleIf(sourcePreferences.dataSaver()) { it }
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
bindTo(preferences.dataSaverColorBW())
|
||||
bindTo(sourcePreferences.dataSaverColorBW())
|
||||
titleRes = R.string.data_saver_color_bw
|
||||
|
||||
visibleIf(preferences.dataSaver()) { it }
|
||||
visibleIf(sourcePreferences.dataSaver()) { it }
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,7 +473,7 @@ class SettingsAdvancedController(
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
bindTo(sourcePreferences.delegateSources())
|
||||
bindTo(delegateSourcePreferences.delegateSources())
|
||||
titleRes = R.string.toggle_delegated_sources
|
||||
summary = context.getString(R.string.toggle_delegated_sources_summary, context.getString(R.string.app_name), DELEGATED_SOURCES.values.map { it.sourceName }.distinct().joinToString())
|
||||
}
|
||||
@ -489,7 +491,7 @@ class SettingsAdvancedController(
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
bindTo(preferences.enableSourceBlacklist())
|
||||
bindTo(sourcePreferences.enableSourceBlacklist())
|
||||
titleRes = R.string.enable_source_blacklist
|
||||
summary = context.getString(R.string.enable_source_blacklist_summary, context.getString(R.string.app_name))
|
||||
}
|
||||
|
@ -2,13 +2,13 @@ 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.ui.base.controller.pushController
|
||||
import eu.kanade.tachiyomi.ui.category.repos.RepoController
|
||||
import eu.kanade.tachiyomi.ui.category.sources.SourceCategoryController
|
||||
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.onClick
|
||||
@ -19,10 +19,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
|
||||
|
||||
@ -34,7 +36,7 @@ class SettingsBrowseController : SettingsController() {
|
||||
key = "pref_edit_source_categories"
|
||||
titleRes = R.string.action_edit_categories
|
||||
|
||||
val catCount = preferences.sourcesTabCategories().get().count()
|
||||
val catCount = sourcePreferences.sourcesTabCategories().get().count()
|
||||
summary = context.resources.getQuantityString(R.plurals.num_categories, catCount, catCount)
|
||||
|
||||
onClick {
|
||||
@ -42,7 +44,7 @@ class SettingsBrowseController : SettingsController() {
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
bindTo(preferences.sourcesTabCategoriesFilter())
|
||||
bindTo(sourcePreferences.sourcesTabCategoriesFilter())
|
||||
titleRes = R.string.pref_source_source_filtering
|
||||
summaryRes = R.string.pref_source_source_filtering_summery
|
||||
}
|
||||
@ -73,7 +75,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
|
||||
}
|
||||
@ -111,9 +113,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
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +122,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
|
||||
|
||||
|
@ -13,6 +13,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.more.settings.SettingsMainScreen
|
||||
import eu.kanade.presentation.more.settings.SettingsSection
|
||||
import eu.kanade.tachiyomi.R
|
||||
@ -27,6 +28,10 @@ class SettingsMainController : BasicFullComposeController() {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
// SY -->
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
// SY <--
|
||||
|
||||
@Composable
|
||||
override fun ComposeContent() {
|
||||
val settingsSections = listOfNotNull(
|
||||
@ -85,7 +90,7 @@ class SettingsMainController : BasicFullComposeController() {
|
||||
} else {
|
||||
null
|
||||
},
|
||||
if (remember { MdUtil.getEnabledMangaDexs(preferences).isNotEmpty() }) {
|
||||
if (remember { MdUtil.getEnabledMangaDexs(sourcePreferences).isNotEmpty() }) {
|
||||
SettingsSection(
|
||||
titleRes = R.string.pref_category_mangadex,
|
||||
painter = painterResource(R.drawable.ic_tracker_mangadex_logo_24dp),
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
@ -15,6 +16,7 @@ import exh.md.utils.MdUtil
|
||||
import exh.widget.preference.MangaDexLoginPreference
|
||||
import exh.widget.preference.MangadexLoginDialog
|
||||
import exh.widget.preference.MangadexLogoutDialog
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class SettingsMangaDexController :
|
||||
SettingsController(),
|
||||
@ -22,6 +24,7 @@ class SettingsMangaDexController :
|
||||
MangadexLogoutDialog.Listener {
|
||||
|
||||
private val mdex by lazy { MdUtil.getEnabledMangaDex(preferences) }
|
||||
private val sourcePreferences: SourcePreferences by injectLazy()
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||
titleRes = R.string.mangadex_specific_settings
|
||||
@ -48,7 +51,7 @@ class SettingsMangaDexController :
|
||||
bindTo(preferences.preferredMangaDexId())
|
||||
titleRes = R.string.mangadex_preffered_source
|
||||
summaryRes = R.string.mangadex_preffered_source_summary
|
||||
val mangaDexs = MdUtil.getEnabledMangaDexs(preferences)
|
||||
val mangaDexs = MdUtil.getEnabledMangaDexs(sourcePreferences)
|
||||
entries = mangaDexs.map { it.toString() }.toTypedArray()
|
||||
entryValues = mangaDexs.map { it.id.toString() }.toTypedArray()
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import androidx.preference.PreferenceGroup
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.preference.forEach
|
||||
import androidx.preference.get
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsAdvancedController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsAppearanceController
|
||||
@ -52,7 +53,8 @@ object SettingsSearchHelper {
|
||||
SettingsTrackingController::class,
|
||||
)
|
||||
val preferences = Injekt.get<PreferencesHelper>()
|
||||
if (MdUtil.getEnabledMangaDexs(preferences).isNotEmpty()) {
|
||||
val sourcePreferences = Injekt.get<SourcePreferences>()
|
||||
if (MdUtil.getEnabledMangaDexs(sourcePreferences).isNotEmpty()) {
|
||||
controllers += SettingsMangaDexController::class
|
||||
}
|
||||
if (preferences.isHentaiEnabled().get()) {
|
||||
|
@ -18,6 +18,7 @@ import eu.kanade.domain.manga.interactor.UpdateManga
|
||||
import eu.kanade.domain.manga.model.MangaUpdate
|
||||
import eu.kanade.domain.source.interactor.InsertFeedSavedSearch
|
||||
import eu.kanade.domain.source.interactor.InsertSavedSearch
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
@ -93,6 +94,7 @@ object EXHMigrations {
|
||||
context: Context,
|
||||
preferences: PreferencesHelper,
|
||||
networkPreferences: NetworkPreferences,
|
||||
sourcePreferences: SourcePreferences,
|
||||
): Boolean {
|
||||
val oldVersion = preferences.ehLastVersionCode().get()
|
||||
try {
|
||||
|
@ -9,8 +9,8 @@ import eu.kanade.domain.manga.interactor.GetManga
|
||||
import eu.kanade.domain.manga.interactor.InsertManga
|
||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
||||
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.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.UrlImportableSource
|
||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||
@ -28,7 +28,7 @@ class GalleryAdder(
|
||||
private val sourceManager: SourceManager = Injekt.get(),
|
||||
) {
|
||||
|
||||
private val filters: Pair<Set<String>, Set<Long>> = Injekt.get<PreferencesHelper>().run {
|
||||
private val filters: Pair<Set<String>, Set<Long>> = Injekt.get<SourcePreferences>().run {
|
||||
enabledLanguages().get() to disabledSources().get().map { it.toLong() }.toSet()
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import eu.kanade.domain.manga.interactor.GetFlatMetadataById
|
||||
import eu.kanade.domain.manga.interactor.GetSearchMetadata
|
||||
import eu.kanade.domain.manga.interactor.InsertFlatMetadata
|
||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
@ -32,6 +33,7 @@ object DebugFunctions {
|
||||
val handler: DatabaseHandler by injectLazy()
|
||||
val prefs: PreferencesHelper by injectLazy()
|
||||
val networkPrefs: NetworkPreferences by injectLazy()
|
||||
val sourcePrefs: SourcePreferences by injectLazy()
|
||||
val sourceManager: SourceManager by injectLazy()
|
||||
val updateManga: UpdateManga by injectLazy()
|
||||
val getFavorites: GetFavorites by injectLazy()
|
||||
@ -43,12 +45,12 @@ object DebugFunctions {
|
||||
|
||||
fun forceUpgradeMigration() {
|
||||
prefs.ehLastVersionCode().set(1)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs)
|
||||
}
|
||||
|
||||
fun forceSetupJobs() {
|
||||
prefs.ehLastVersionCode().set(0)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs)
|
||||
}
|
||||
|
||||
fun resetAgedFlagInEXHManga() {
|
||||
|
@ -8,16 +8,16 @@ import android.widget.TextView
|
||||
import androidx.core.text.HtmlCompat
|
||||
import com.ms_square.debugoverlay.DataObserver
|
||||
import com.ms_square.debugoverlay.OverlayModule
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
class EHDebugModeOverlay(private val context: Context) : OverlayModule<String>(null, null) {
|
||||
private var textView: TextView? = null
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val preferences: SourcePreferences by injectLazy()
|
||||
|
||||
override fun start() {}
|
||||
override fun stop() {}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package exh.md.utils
|
||||
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.mdlist.MdList
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
@ -337,8 +338,8 @@ class MdUtil {
|
||||
"Bearer " + (sessionToken(preferences, mdList) ?: throw NoSessionException()),
|
||||
).build()
|
||||
|
||||
fun getEnabledMangaDex(preferences: PreferencesHelper, sourceManager: SourceManager = Injekt.get()): MangaDex? {
|
||||
return getEnabledMangaDexs(preferences, sourceManager).let { mangadexs ->
|
||||
fun getEnabledMangaDex(preferences: PreferencesHelper, sourcePreferences: SourcePreferences = Injekt.get(), sourceManager: SourceManager = Injekt.get()): MangaDex? {
|
||||
return getEnabledMangaDexs(sourcePreferences, sourceManager).let { mangadexs ->
|
||||
preferences.preferredMangaDexId().get().toLongOrNull()?.nullIfZero()
|
||||
?.let { preferredMangaDexId ->
|
||||
mangadexs.firstOrNull { it.id == preferredMangaDexId }
|
||||
@ -347,7 +348,7 @@ class MdUtil {
|
||||
}
|
||||
}
|
||||
|
||||
fun getEnabledMangaDexs(preferences: PreferencesHelper, sourceManager: SourceManager = Injekt.get()): List<MangaDex> {
|
||||
fun getEnabledMangaDexs(preferences: SourcePreferences, sourceManager: SourceManager = Injekt.get()): List<MangaDex> {
|
||||
val languages = preferences.enabledLanguages().get()
|
||||
val disabledSourceIds = preferences.disabledSources().get()
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package exh.util
|
||||
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.Preference
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
@ -30,7 +30,7 @@ interface DataSaver {
|
||||
}
|
||||
}
|
||||
|
||||
fun DataSaver(source: Source, preferences: PreferencesHelper): DataSaver {
|
||||
fun DataSaver(source: Source, preferences: SourcePreferences): DataSaver {
|
||||
return if (preferences.dataSaver().get() && source.id.toString() !in preferences.dataSaverExcludedSources().get()) {
|
||||
return DataSaverImpl(preferences)
|
||||
} else {
|
||||
@ -38,7 +38,7 @@ fun DataSaver(source: Source, preferences: PreferencesHelper): DataSaver {
|
||||
}
|
||||
}
|
||||
|
||||
private class DataSaverImpl(preferences: PreferencesHelper) : DataSaver {
|
||||
private class DataSaverImpl(preferences: SourcePreferences) : DataSaver {
|
||||
private val dataSavedServer = preferences.dataSaverServer().get().trimEnd('/')
|
||||
|
||||
private val ignoreJpg = preferences.dataSaverIgnoreJpeg().get()
|
||||
|
@ -3,7 +3,7 @@ package exh.pref
|
||||
import eu.kanade.tachiyomi.core.preference.Preference
|
||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||
|
||||
class SourcePreferences(
|
||||
class DelegateSourcePreferences(
|
||||
private val preferenceStore: PreferenceStore,
|
||||
) {
|
||||
|
@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import exh.log.maybeInjectEHLogger
|
||||
import exh.pref.SourcePreferences
|
||||
import exh.pref.DelegateSourcePreferences
|
||||
import exh.source.DelegatedHttpSource
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
@ -410,7 +410,7 @@ abstract class HttpSource : CatalogueSource {
|
||||
|
||||
// EXH -->
|
||||
private var delegate: DelegatedHttpSource? = null
|
||||
get() = if (Injekt.get<SourcePreferences>().delegateSources().get()) {
|
||||
get() = if (Injekt.get<DelegateSourcePreferences>().delegateSources().get()) {
|
||||
field
|
||||
} else {
|
||||
null
|
||||
|
@ -7,7 +7,7 @@ import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.model.copy
|
||||
import exh.metadata.MetadataUtil
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||
import exh.pref.SourcePreferences
|
||||
import exh.pref.DelegateSourcePreferences
|
||||
import kotlinx.serialization.Serializable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
@ -53,7 +53,7 @@ class EHentaiSearchMetadata : RaisedSearchMetadata() {
|
||||
|
||||
// No title bug?
|
||||
val title = altTitle
|
||||
?.takeIf { Injekt.get<SourcePreferences>().useJapaneseTitle().get() } // todo
|
||||
?.takeIf { Injekt.get<DelegateSourcePreferences>().useJapaneseTitle().get() } // todo
|
||||
?: title
|
||||
|
||||
// Set artist (if we can find one)
|
||||
|
@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import exh.pref.SourcePreferences
|
||||
import exh.pref.DelegateSourcePreferences
|
||||
import okhttp3.Response
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
@ -249,7 +249,7 @@ class EnhancedHttpSource(
|
||||
override fun getFilterList() = source().getFilterList()
|
||||
|
||||
fun source(): HttpSource {
|
||||
return if (Injekt.get<SourcePreferences>().delegateSources().get()) {
|
||||
return if (Injekt.get<DelegateSourcePreferences>().delegateSources().get()) {
|
||||
enhancedSource
|
||||
} else {
|
||||
originalSource
|
||||
|
Loading…
x
Reference in New Issue
Block a user