Setting for pre-load cover's library color
This commit is contained in:
parent
314ced0e8d
commit
c7bab00379
3 changed files with 18 additions and 3 deletions
|
|
@ -29,6 +29,8 @@ class UiPreferences(
|
||||||
fun themeCoverBased() = preferenceStore.getBoolean("pref_theme_cover_based_key", true)
|
fun themeCoverBased() = preferenceStore.getBoolean("pref_theme_cover_based_key", true)
|
||||||
|
|
||||||
fun themeCoverBasedStyle() = preferenceStore.getEnum("pref_theme_cover_based_style_key", PaletteStyle.Vibrant)
|
fun themeCoverBasedStyle() = preferenceStore.getEnum("pref_theme_cover_based_style_key", PaletteStyle.Vibrant)
|
||||||
|
|
||||||
|
fun preloadLibraryColor() = preferenceStore.getBoolean("pref_preload_library_color_key", true)
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
||||||
fun relativeTime() = preferenceStore.getBoolean("relative_time_v2", true)
|
fun relativeTime() = preferenceStore.getBoolean("relative_time_v2", true)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import eu.kanade.domain.base.BasePreferences
|
||||||
import eu.kanade.domain.extension.interactor.TrustExtension
|
import eu.kanade.domain.extension.interactor.TrustExtension
|
||||||
import eu.kanade.domain.source.service.SourcePreferences
|
import eu.kanade.domain.source.service.SourcePreferences
|
||||||
import eu.kanade.domain.source.service.SourcePreferences.DataSaver
|
import eu.kanade.domain.source.service.SourcePreferences.DataSaver
|
||||||
|
import eu.kanade.domain.ui.UiPreferences
|
||||||
import eu.kanade.presentation.more.settings.Preference
|
import eu.kanade.presentation.more.settings.Preference
|
||||||
import eu.kanade.presentation.more.settings.screen.advanced.ClearDatabaseScreen
|
import eu.kanade.presentation.more.settings.screen.advanced.ClearDatabaseScreen
|
||||||
import eu.kanade.presentation.more.settings.screen.debug.DebugInfoScreen
|
import eu.kanade.presentation.more.settings.screen.debug.DebugInfoScreen
|
||||||
|
|
@ -100,6 +101,8 @@ import uy.kohesive.injekt.api.get
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
object SettingsAdvancedScreen : SearchableSettings {
|
object SettingsAdvancedScreen : SearchableSettings {
|
||||||
|
@Suppress("unused")
|
||||||
|
private fun readResolve(): Any = SettingsAdvancedScreen
|
||||||
|
|
||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -333,6 +336,9 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||||
private fun getLibraryGroup(): Preference.PreferenceGroup {
|
private fun getLibraryGroup(): Preference.PreferenceGroup {
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
// KMK -->
|
||||||
|
val uiPreferences = remember { Injekt.get<UiPreferences>() }
|
||||||
|
// KMK <--
|
||||||
|
|
||||||
return Preference.PreferenceGroup(
|
return Preference.PreferenceGroup(
|
||||||
title = stringResource(MR.strings.label_library),
|
title = stringResource(MR.strings.label_library),
|
||||||
|
|
@ -341,6 +347,12 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||||
title = stringResource(MR.strings.pref_refresh_library_covers),
|
title = stringResource(MR.strings.pref_refresh_library_covers),
|
||||||
onClick = { LibraryUpdateJob.startNow(context, target = LibraryUpdateJob.Target.COVERS) },
|
onClick = { LibraryUpdateJob.startNow(context, target = LibraryUpdateJob.Target.COVERS) },
|
||||||
),
|
),
|
||||||
|
// KMK -->
|
||||||
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
|
pref = uiPreferences.preloadLibraryColor(),
|
||||||
|
title = "Preload library's cover color",
|
||||||
|
),
|
||||||
|
// KMK <--
|
||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
title = stringResource(MR.strings.pref_reset_viewer_flags),
|
title = stringResource(MR.strings.pref_reset_viewer_flags),
|
||||||
subtitle = stringResource(MR.strings.pref_reset_viewer_flags_summary),
|
subtitle = stringResource(MR.strings.pref_reset_viewer_flags_summary),
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.network.await
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
import okhttp3.CacheControl
|
import okhttp3.CacheControl
|
||||||
|
|
@ -72,9 +71,10 @@ class MangaCoverFetcher(
|
||||||
) : Fetcher {
|
) : Fetcher {
|
||||||
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
private val fileScope by lazy { CoroutineScope(Job() + Dispatchers.IO) }
|
private val scope by lazy { CoroutineScope(Dispatchers.IO) }
|
||||||
private val uiPreferences = Injekt.get<UiPreferences>()
|
private val uiPreferences = Injekt.get<UiPreferences>()
|
||||||
private val themeCoverBased = uiPreferences.themeCoverBased().get()
|
private val themeCoverBased = uiPreferences.themeCoverBased().get()
|
||||||
|
private val preloadLibraryColor = uiPreferences.preloadLibraryColor().get()
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
||||||
private val diskCacheKey: String
|
private val diskCacheKey: String
|
||||||
|
|
@ -351,7 +351,8 @@ class MangaCoverFetcher(
|
||||||
onlyFavorite: Boolean = !themeCoverBased,
|
onlyFavorite: Boolean = !themeCoverBased,
|
||||||
force: Boolean = false,
|
force: Boolean = false,
|
||||||
) {
|
) {
|
||||||
fileScope.launch {
|
if (!preloadLibraryColor) return
|
||||||
|
scope.launch {
|
||||||
MangaCoverMetadata.setRatioAndColors(mangaCover, bufferedSource, ogFile, onlyFavorite, force)
|
MangaCoverMetadata.setRatioAndColors(mangaCover, bufferedSource, ogFile, onlyFavorite, force)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue