mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 02:34:39 +00:00
refactor: Migrate to upstream's preference abstraction
This commit is contained in:
parent
9a2815d277
commit
af87ccf8f1
61 changed files with 388 additions and 432 deletions
|
@ -82,6 +82,8 @@ android {
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding = true
|
viewBinding = true
|
||||||
compose = true
|
compose = true
|
||||||
|
// If you're here because there's not BuildConfig, build the app first, it'll generate it for you
|
||||||
|
buildConfig = true
|
||||||
|
|
||||||
// Disable some unused things
|
// Disable some unused things
|
||||||
aidl = false
|
aidl = false
|
||||||
|
@ -108,7 +110,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
composeOptions {
|
composeOptions {
|
||||||
kotlinCompilerExtensionVersion = "1.5.3"
|
kotlinCompilerExtensionVersion = compose.versions.compose.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
@ -179,9 +181,6 @@ dependencies {
|
||||||
implementation(libs.rxjava)
|
implementation(libs.rxjava)
|
||||||
implementation(libs.rxrelay)
|
implementation(libs.rxrelay)
|
||||||
|
|
||||||
// Coroutines
|
|
||||||
implementation(libs.flow.preferences)
|
|
||||||
|
|
||||||
// Network client
|
// Network client
|
||||||
implementation(libs.okhttp)
|
implementation(libs.okhttp)
|
||||||
implementation(libs.okhttp.logging.interceptor)
|
implementation(libs.okhttp.logging.interceptor)
|
||||||
|
|
|
@ -24,7 +24,6 @@ import eu.kanade.tachiyomi.appwidget.TachiyomiWidgetManager
|
||||||
import eu.kanade.tachiyomi.data.image.coil.CoilSetup
|
import eu.kanade.tachiyomi.data.image.coil.CoilSetup
|
||||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
||||||
import eu.kanade.tachiyomi.ui.recents.RecentsPresenter
|
import eu.kanade.tachiyomi.ui.recents.RecentsPresenter
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
|
@ -64,6 +63,7 @@ open class App : Application(), DefaultLifecycleObserver {
|
||||||
if (packageName != process) WebView.setDataDirectorySuffix(process)
|
if (packageName != process) WebView.setDataDirectorySuffix(process)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Injekt.importModule(PreferenceModule(this))
|
||||||
Injekt.importModule(AppModule(this))
|
Injekt.importModule(AppModule(this))
|
||||||
|
|
||||||
CoilSetup(this)
|
CoilSetup(this)
|
||||||
|
@ -72,8 +72,8 @@ open class App : Application(), DefaultLifecycleObserver {
|
||||||
ProcessLifecycleOwner.get().lifecycle.addObserver(this)
|
ProcessLifecycleOwner.get().lifecycle.addObserver(this)
|
||||||
|
|
||||||
MangaCoverMetadata.load()
|
MangaCoverMetadata.load()
|
||||||
preferences.nightMode()
|
preferences.nightMode().changes()
|
||||||
.asImmediateFlow { AppCompatDelegate.setDefaultNightMode(it) }
|
.onEach { AppCompatDelegate.setDefaultNightMode(it) }
|
||||||
.launchIn(ProcessLifecycleOwner.get().lifecycleScope)
|
.launchIn(ProcessLifecycleOwner.get().lifecycleScope)
|
||||||
|
|
||||||
ProcessLifecycleOwner.get().lifecycleScope.launchIO {
|
ProcessLifecycleOwner.get().lifecycleScope.launchIO {
|
||||||
|
@ -81,7 +81,7 @@ open class App : Application(), DefaultLifecycleObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show notification to disable Incognito Mode when it's enabled
|
// Show notification to disable Incognito Mode when it's enabled
|
||||||
preferences.incognitoMode().asFlow()
|
preferences.incognitoMode().changes()
|
||||||
.onEach { enabled ->
|
.onEach { enabled ->
|
||||||
val notificationManager = NotificationManagerCompat.from(this)
|
val notificationManager = NotificationManagerCompat.from(this)
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
|
|
@ -7,8 +7,8 @@ import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.library.CustomMangaManager
|
import eu.kanade.tachiyomi.data.library.CustomMangaManager
|
||||||
import eu.kanade.tachiyomi.data.preference.AndroidPreferenceStore
|
import eu.kanade.tachiyomi.core.preference.AndroidPreferenceStore
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceStore
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.data.track.TrackPreferences
|
import eu.kanade.tachiyomi.data.track.TrackPreferences
|
||||||
|
@ -34,8 +34,6 @@ class AppModule(val app: Application) : InjektModule {
|
||||||
AndroidPreferenceStore(app)
|
AndroidPreferenceStore(app)
|
||||||
}
|
}
|
||||||
|
|
||||||
addSingletonFactory { PreferencesHelper(app) }
|
|
||||||
|
|
||||||
addSingletonFactory { TrackPreferences(get()) }
|
addSingletonFactory { TrackPreferences(get()) }
|
||||||
|
|
||||||
addSingletonFactory { DatabaseHelper(app) }
|
addSingletonFactory { DatabaseHelper(app) }
|
||||||
|
@ -71,8 +69,6 @@ class AppModule(val app: Application) : InjektModule {
|
||||||
// Asynchronously init expensive components for a faster cold start
|
// Asynchronously init expensive components for a faster cold start
|
||||||
|
|
||||||
ContextCompat.getMainExecutor(app).execute {
|
ContextCompat.getMainExecutor(app).execute {
|
||||||
get<PreferencesHelper>()
|
|
||||||
|
|
||||||
get<NetworkHelper>()
|
get<NetworkHelper>()
|
||||||
|
|
||||||
get<SourceManager>()
|
get<SourceManager>()
|
||||||
|
@ -85,3 +81,19 @@ class AppModule(val app: Application) : InjektModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class PreferenceModule(val application: Application) : InjektModule {
|
||||||
|
override fun InjektRegistrar.registerInjectables() {
|
||||||
|
addSingletonFactory<PreferenceStore> {
|
||||||
|
AndroidPreferenceStore(application)
|
||||||
|
}
|
||||||
|
|
||||||
|
addSingletonFactory {
|
||||||
|
PreferencesHelper(
|
||||||
|
context = application,
|
||||||
|
preferenceStore = get(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@ import androidx.preference.PreferenceManager
|
||||||
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.preference.Preference
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceStore
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.plusAssign
|
import eu.kanade.tachiyomi.core.preference.plusAssign
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.data.updater.AppDownloadInstallJob
|
import eu.kanade.tachiyomi.data.updater.AppDownloadInstallJob
|
||||||
import eu.kanade.tachiyomi.data.updater.AppUpdateJob
|
import eu.kanade.tachiyomi.data.updater.AppUpdateJob
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.kanade.tachiyomi.data.preference
|
package eu.kanade.tachiyomi.core.preference
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.SharedPreferences.Editor
|
import android.content.SharedPreferences.Editor
|
|
@ -1,15 +1,15 @@
|
||||||
package eu.kanade.tachiyomi.data.preference
|
package eu.kanade.tachiyomi.core.preference
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import eu.kanade.tachiyomi.data.preference.AndroidPreference.BooleanPrimitive
|
import eu.kanade.tachiyomi.core.preference.AndroidPreference.BooleanPrimitive
|
||||||
import eu.kanade.tachiyomi.data.preference.AndroidPreference.FloatPrimitive
|
import eu.kanade.tachiyomi.core.preference.AndroidPreference.FloatPrimitive
|
||||||
import eu.kanade.tachiyomi.data.preference.AndroidPreference.IntPrimitive
|
import eu.kanade.tachiyomi.core.preference.AndroidPreference.IntPrimitive
|
||||||
import eu.kanade.tachiyomi.data.preference.AndroidPreference.LongPrimitive
|
import eu.kanade.tachiyomi.core.preference.AndroidPreference.LongPrimitive
|
||||||
import eu.kanade.tachiyomi.data.preference.AndroidPreference.Object
|
import eu.kanade.tachiyomi.core.preference.AndroidPreference.Object
|
||||||
import eu.kanade.tachiyomi.data.preference.AndroidPreference.StringPrimitive
|
import eu.kanade.tachiyomi.core.preference.AndroidPreference.StringPrimitive
|
||||||
import eu.kanade.tachiyomi.data.preference.AndroidPreference.StringSetPrimitive
|
import eu.kanade.tachiyomi.core.preference.AndroidPreference.StringSetPrimitive
|
||||||
import kotlinx.coroutines.channels.awaitClose
|
import kotlinx.coroutines.channels.awaitClose
|
||||||
import kotlinx.coroutines.flow.callbackFlow
|
import kotlinx.coroutines.flow.callbackFlow
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.kanade.tachiyomi.data.preference
|
package eu.kanade.tachiyomi.core.preference
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
@ -22,21 +22,29 @@ interface Preference<T> {
|
||||||
|
|
||||||
fun stateIn(scope: CoroutineScope): StateFlow<T>
|
fun stateIn(scope: CoroutineScope): StateFlow<T>
|
||||||
|
|
||||||
val isPrivate: Boolean
|
|
||||||
get() = key().startsWith(PRIVATE_PREFIX)
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/**
|
/**
|
||||||
* A preference that should not be exposed in places like backups.
|
* A preference that should not be exposed in places like backups without user consent.
|
||||||
*/
|
*/
|
||||||
fun isPrivate(key: String): Boolean {
|
fun isPrivate(key: String): Boolean {
|
||||||
return key.startsWith(PRIVATE_PREFIX)
|
return key.startsWith(PRIVATE_PREFIX)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun privateKey(key: String): String {
|
fun privateKey(key: String): String {
|
||||||
return "$PRIVATE_PREFIX$key"
|
return "${PRIVATE_PREFIX}$key"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preference used for internal app state that isn't really a user preference
|
||||||
|
* and therefore should not be in places like backups.
|
||||||
|
*/
|
||||||
|
fun isAppState(key: String): Boolean {
|
||||||
|
return key.startsWith(APP_STATE_PREFIX)
|
||||||
|
}
|
||||||
|
fun appStateKey(key: String): String {
|
||||||
|
return "${APP_STATE_PREFIX}$key"
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val APP_STATE_PREFIX = "__APP_STATE_"
|
||||||
private const val PRIVATE_PREFIX = "__PRIVATE_"
|
private const val PRIVATE_PREFIX = "__PRIVATE_"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +53,14 @@ inline fun <reified T, R : T> Preference<T>.getAndSet(crossinline block: (T) ->
|
||||||
block(get()),
|
block(get()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
operator fun <T> Preference<Set<T>>.plusAssign(item: Collection<T>) {
|
||||||
|
get() + item
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun <T> Preference<Set<T>>.minusAssign(item: Collection<T>) {
|
||||||
|
get() - item
|
||||||
|
}
|
||||||
|
|
||||||
operator fun <T> Preference<Set<T>>.plusAssign(item: T) {
|
operator fun <T> Preference<Set<T>>.plusAssign(item: T) {
|
||||||
set(get() + item)
|
set(get() + item)
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.kanade.tachiyomi.data.preference
|
package eu.kanade.tachiyomi.core.preference
|
||||||
|
|
||||||
interface PreferenceStore {
|
interface PreferenceStore {
|
||||||
|
|
|
@ -39,8 +39,8 @@ import eu.kanade.tachiyomi.data.backup.models.StringSetPreferenceValue
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.library.CustomMangaManager
|
import eu.kanade.tachiyomi.data.library.CustomMangaManager
|
||||||
import eu.kanade.tachiyomi.data.preference.Preference
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceStore
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
|
|
@ -23,8 +23,8 @@ import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.database.models.Track
|
import eu.kanade.tachiyomi.data.database.models.Track
|
||||||
import eu.kanade.tachiyomi.data.library.CustomMangaManager
|
import eu.kanade.tachiyomi.data.library.CustomMangaManager
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.preference.AndroidPreferenceStore
|
import eu.kanade.tachiyomi.core.preference.AndroidPreferenceStore
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceStore
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.sourcePreferences
|
import eu.kanade.tachiyomi.source.sourcePreferences
|
||||||
|
@ -34,7 +34,6 @@ import eu.kanade.tachiyomi.util.system.createFileInCacheDir
|
||||||
import kotlinx.coroutines.coroutineScope
|
import kotlinx.coroutines.coroutineScope
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.serialization.protobuf.ProtoBuf
|
import kotlinx.serialization.protobuf.ProtoBuf
|
||||||
import okio.source
|
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
|
@ -80,7 +80,7 @@ class ChapterCache(private val context: Context) {
|
||||||
get() = Formatter.formatFileSize(context, realSize)
|
get() = Formatter.formatFileSize(context, realSize)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
preferences.preloadSize().asFlow()
|
preferences.preloadSize().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
// Save old cache for destruction later
|
// Save old cache for destruction later
|
||||||
|
|
|
@ -54,7 +54,7 @@ class DownloadCache(
|
||||||
val scope = CoroutineScope(Job() + Dispatchers.IO)
|
val scope = CoroutineScope(Job() + Dispatchers.IO)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
preferences.downloadsDirectory().asFlow()
|
preferences.downloadsDirectory().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach { lastRenew = 0L } // invalidate cache
|
.onEach { lastRenew = 0L } // invalidate cache
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
|
@ -44,7 +44,7 @@ class DownloadProvider(private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
preferences.downloadsDirectory().asFlow().drop(1).onEach {
|
preferences.downloadsDirectory().changes().drop(1).onEach {
|
||||||
downloadsDir = UniFile.fromUri(context, it.toUri())
|
downloadsDir = UniFile.fromUri(context, it.toUri())
|
||||||
}.launchIn(scope)
|
}.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ class DelayedLibrarySuggestionsJob(context: Context, workerParams: WorkerParamet
|
||||||
|
|
||||||
override suspend fun doWork(): Result {
|
override suspend fun doWork(): Result {
|
||||||
val preferences = Injekt.get<PreferencesHelper>()
|
val preferences = Injekt.get<PreferencesHelper>()
|
||||||
if (preferences.showLibrarySearchSuggestions().isNotSet()) {
|
if (!preferences.showLibrarySearchSuggestions().isSet()) {
|
||||||
preferences.showLibrarySearchSuggestions().set(true)
|
preferences.showLibrarySearchSuggestions().set(true)
|
||||||
LibraryPresenter.setSearchSuggestion(preferences, Injekt.get(), Injekt.get())
|
LibraryPresenter.setSearchSuggestion(preferences, Injekt.get(), Injekt.get())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
package eu.kanade.tachiyomi.data.preference
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceDataStore
|
|
||||||
|
|
||||||
class EmptyPreferenceDataStore : PreferenceDataStore() {
|
|
||||||
|
|
||||||
override fun getBoolean(key: String?, defValue: Boolean): Boolean {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun putBoolean(key: String?, value: Boolean) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getInt(key: String?, defValue: Int): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun putInt(key: String?, value: Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getLong(key: String?, defValue: Long): Long {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun putLong(key: String?, value: Long) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getFloat(key: String?, defValue: Float): Float {
|
|
||||||
return 0f
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun putFloat(key: String?, value: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getString(key: String?, defValue: String?): String? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun putString(key: String?, value: String?) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getStringSet(key: String?, defValues: Set<String>?): Set<String>? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun putStringSet(key: String?, values: Set<String>?) {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,11 +5,12 @@ import android.net.Uri
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.fredporciuncula.flow.preferences.FlowSharedPreferences
|
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
|
||||||
import com.google.android.material.color.DynamicColors
|
import com.google.android.material.color.DynamicColors
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
|
import eu.kanade.tachiyomi.core.preference.getEnum
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.updater.AppDownloadInstallJob
|
import eu.kanade.tachiyomi.data.updater.AppDownloadInstallJob
|
||||||
import eu.kanade.tachiyomi.extension.model.InstalledExtensionsOrder
|
import eu.kanade.tachiyomi.extension.model.InstalledExtensionsOrder
|
||||||
|
@ -27,25 +28,18 @@ import eu.kanade.tachiyomi.ui.recents.RecentsPresenter
|
||||||
import eu.kanade.tachiyomi.util.system.Themes
|
import eu.kanade.tachiyomi.util.system.Themes
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.*
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
||||||
|
|
||||||
fun <T> Preference<T>.asImmediateFlow(block: (value: T) -> Unit): Flow<T> {
|
fun <T> Preference<T>.changesIn(scope: CoroutineScope, block: (value: T) -> Unit): Job {
|
||||||
block(get())
|
block(get())
|
||||||
return asFlow()
|
return changes()
|
||||||
.onEach { block(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T> Preference<T>.asImmediateFlowIn(scope: CoroutineScope, block: (value: T) -> Unit): Job {
|
|
||||||
block(get())
|
|
||||||
return asFlow()
|
|
||||||
.onEach { block(it) }
|
.onEach { block(it) }
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
@ -68,10 +62,9 @@ operator fun <T> Preference<Set<T>>.minusAssign(item: Collection<T>) {
|
||||||
set(get() - item)
|
set(get() - item)
|
||||||
}
|
}
|
||||||
|
|
||||||
class PreferencesHelper(val context: Context) {
|
class PreferencesHelper(val context: Context, val preferenceStore: PreferenceStore) {
|
||||||
|
|
||||||
private val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
private val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
private val flowPrefs = FlowSharedPreferences(prefs)
|
|
||||||
|
|
||||||
private val defaultDownloadsDir = Uri.fromFile(
|
private val defaultDownloadsDir = Uri.fromFile(
|
||||||
File(
|
File(
|
||||||
|
@ -89,236 +82,236 @@ class PreferencesHelper(val context: Context) {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
fun getInt(key: String, default: Int) = flowPrefs.getInt(key, default)
|
fun getInt(key: String, default: Int) = preferenceStore.getInt(key, default)
|
||||||
fun getStringPref(key: String, default: String = "") = flowPrefs.getString(key, default)
|
fun getStringPref(key: String, default: String = "") = preferenceStore.getString(key, default)
|
||||||
fun getStringSet(key: String, default: Set<String>) = flowPrefs.getStringSet(key, default)
|
fun getStringSet(key: String, default: Set<String>) = preferenceStore.getStringSet(key, default)
|
||||||
|
|
||||||
fun startingTab() = flowPrefs.getInt(Keys.startingTab, 0)
|
fun startingTab() = preferenceStore.getInt(Keys.startingTab, 0)
|
||||||
fun backReturnsToStart() = flowPrefs.getBoolean(Keys.backToStart, true)
|
fun backReturnsToStart() = preferenceStore.getBoolean(Keys.backToStart, true)
|
||||||
|
|
||||||
fun hasShownNotifPermission() = flowPrefs.getBoolean("has_shown_notification_permission", false)
|
fun hasShownNotifPermission() = preferenceStore.getBoolean("has_shown_notification_permission", false)
|
||||||
|
|
||||||
fun hasDeniedA11FilePermission() = flowPrefs.getBoolean(Keys.deniedA11FilePermission, false)
|
fun hasDeniedA11FilePermission() = preferenceStore.getBoolean(Keys.deniedA11FilePermission, false)
|
||||||
|
|
||||||
fun clear() = prefs.edit().clear().apply()
|
fun clear() = prefs.edit().clear().apply()
|
||||||
|
|
||||||
fun nightMode() = flowPrefs.getInt(Keys.nightMode, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
fun nightMode() = preferenceStore.getInt(Keys.nightMode, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||||
|
|
||||||
fun themeDarkAmoled() = flowPrefs.getBoolean(Keys.themeDarkAmoled, false)
|
fun themeDarkAmoled() = preferenceStore.getBoolean(Keys.themeDarkAmoled, false)
|
||||||
|
|
||||||
private val supportsDynamic = DynamicColors.isDynamicColorAvailable()
|
private val supportsDynamic = DynamicColors.isDynamicColorAvailable()
|
||||||
fun lightTheme() = flowPrefs.getEnum(Keys.lightTheme, if (supportsDynamic) Themes.MONET else Themes.DEFAULT)
|
fun lightTheme() = preferenceStore.getEnum(Keys.lightTheme, if (supportsDynamic) Themes.MONET else Themes.DEFAULT)
|
||||||
fun darkTheme() = flowPrefs.getEnum(Keys.darkTheme, if (supportsDynamic) Themes.MONET else Themes.DEFAULT)
|
fun darkTheme() = preferenceStore.getEnum(Keys.darkTheme, if (supportsDynamic) Themes.MONET else Themes.DEFAULT)
|
||||||
|
|
||||||
fun pageTransitions() = flowPrefs.getBoolean(Keys.enableTransitions, true)
|
fun pageTransitions() = preferenceStore.getBoolean(Keys.enableTransitions, true)
|
||||||
|
|
||||||
fun pagerCutoutBehavior() = flowPrefs.getInt(Keys.pagerCutoutBehavior, 0)
|
fun pagerCutoutBehavior() = preferenceStore.getInt(Keys.pagerCutoutBehavior, 0)
|
||||||
|
|
||||||
fun landscapeCutoutBehavior() = flowPrefs.getInt("landscape_cutout_behavior", 0)
|
fun landscapeCutoutBehavior() = preferenceStore.getInt("landscape_cutout_behavior", 0)
|
||||||
|
|
||||||
fun doubleTapAnimSpeed() = flowPrefs.getInt(Keys.doubleTapAnimationSpeed, 500)
|
fun doubleTapAnimSpeed() = preferenceStore.getInt(Keys.doubleTapAnimationSpeed, 500)
|
||||||
|
|
||||||
fun showPageNumber() = flowPrefs.getBoolean(Keys.showPageNumber, true)
|
fun showPageNumber() = preferenceStore.getBoolean(Keys.showPageNumber, true)
|
||||||
|
|
||||||
fun trueColor() = flowPrefs.getBoolean(Keys.trueColor, false)
|
fun trueColor() = preferenceStore.getBoolean(Keys.trueColor, false)
|
||||||
|
|
||||||
fun fullscreen() = flowPrefs.getBoolean(Keys.fullscreen, true)
|
fun fullscreen() = preferenceStore.getBoolean(Keys.fullscreen, true)
|
||||||
|
|
||||||
fun keepScreenOn() = flowPrefs.getBoolean(Keys.keepScreenOn, true)
|
fun keepScreenOn() = preferenceStore.getBoolean(Keys.keepScreenOn, true)
|
||||||
|
|
||||||
fun customBrightness() = flowPrefs.getBoolean(Keys.customBrightness, false)
|
fun customBrightness() = preferenceStore.getBoolean(Keys.customBrightness, false)
|
||||||
|
|
||||||
fun customBrightnessValue() = flowPrefs.getInt(Keys.customBrightnessValue, 0)
|
fun customBrightnessValue() = preferenceStore.getInt(Keys.customBrightnessValue, 0)
|
||||||
|
|
||||||
fun colorFilter() = flowPrefs.getBoolean(Keys.colorFilter, false)
|
fun colorFilter() = preferenceStore.getBoolean(Keys.colorFilter, false)
|
||||||
|
|
||||||
fun colorFilterValue() = flowPrefs.getInt(Keys.colorFilterValue, 0)
|
fun colorFilterValue() = preferenceStore.getInt(Keys.colorFilterValue, 0)
|
||||||
|
|
||||||
fun colorFilterMode() = flowPrefs.getInt(Keys.colorFilterMode, 0)
|
fun colorFilterMode() = preferenceStore.getInt(Keys.colorFilterMode, 0)
|
||||||
|
|
||||||
fun defaultReadingMode() = prefs.getInt(Keys.defaultReadingMode, ReadingModeType.RIGHT_TO_LEFT.flagValue)
|
fun defaultReadingMode() = prefs.getInt(Keys.defaultReadingMode, ReadingModeType.RIGHT_TO_LEFT.flagValue)
|
||||||
|
|
||||||
fun defaultOrientationType() = flowPrefs.getInt(Keys.defaultOrientationType, OrientationType.FREE.flagValue)
|
fun defaultOrientationType() = preferenceStore.getInt(Keys.defaultOrientationType, OrientationType.FREE.flagValue)
|
||||||
|
|
||||||
fun imageScaleType() = flowPrefs.getInt(Keys.imageScaleType, 1)
|
fun imageScaleType() = preferenceStore.getInt(Keys.imageScaleType, 1)
|
||||||
|
|
||||||
fun zoomStart() = flowPrefs.getInt(Keys.zoomStart, 1)
|
fun zoomStart() = preferenceStore.getInt(Keys.zoomStart, 1)
|
||||||
|
|
||||||
fun readerTheme() = flowPrefs.getInt(Keys.readerTheme, 2)
|
fun readerTheme() = preferenceStore.getInt(Keys.readerTheme, 2)
|
||||||
|
|
||||||
fun cropBorders() = flowPrefs.getBoolean(Keys.cropBorders, false)
|
fun cropBorders() = preferenceStore.getBoolean(Keys.cropBorders, false)
|
||||||
|
|
||||||
fun cropBordersWebtoon() = flowPrefs.getBoolean(Keys.cropBordersWebtoon, false)
|
fun cropBordersWebtoon() = preferenceStore.getBoolean(Keys.cropBordersWebtoon, false)
|
||||||
|
|
||||||
fun navigateToPan() = flowPrefs.getBoolean("navigate_pan", true)
|
fun navigateToPan() = preferenceStore.getBoolean("navigate_pan", true)
|
||||||
|
|
||||||
fun landscapeZoom() = flowPrefs.getBoolean("landscape_zoom", false)
|
fun landscapeZoom() = preferenceStore.getBoolean("landscape_zoom", false)
|
||||||
|
|
||||||
fun grayscale() = flowPrefs.getBoolean("pref_grayscale", false)
|
fun grayscale() = preferenceStore.getBoolean("pref_grayscale", false)
|
||||||
|
|
||||||
fun invertedColors() = flowPrefs.getBoolean("pref_inverted_colors", false)
|
fun invertedColors() = preferenceStore.getBoolean("pref_inverted_colors", false)
|
||||||
|
|
||||||
fun webtoonSidePadding() = flowPrefs.getInt(Keys.webtoonSidePadding, 0)
|
fun webtoonSidePadding() = preferenceStore.getInt(Keys.webtoonSidePadding, 0)
|
||||||
|
|
||||||
fun webtoonEnableZoomOut() = flowPrefs.getBoolean(Keys.webtoonEnableZoomOut, false)
|
fun webtoonEnableZoomOut() = preferenceStore.getBoolean(Keys.webtoonEnableZoomOut, false)
|
||||||
|
|
||||||
fun readWithLongTap() = flowPrefs.getBoolean(Keys.readWithLongTap, true)
|
fun readWithLongTap() = preferenceStore.getBoolean(Keys.readWithLongTap, true)
|
||||||
|
|
||||||
fun readWithVolumeKeys() = flowPrefs.getBoolean(Keys.readWithVolumeKeys, false)
|
fun readWithVolumeKeys() = preferenceStore.getBoolean(Keys.readWithVolumeKeys, false)
|
||||||
|
|
||||||
fun readWithVolumeKeysInverted() = flowPrefs.getBoolean(Keys.readWithVolumeKeysInverted, false)
|
fun readWithVolumeKeysInverted() = preferenceStore.getBoolean(Keys.readWithVolumeKeysInverted, false)
|
||||||
|
|
||||||
fun navigationModePager() = flowPrefs.getInt(Keys.navigationModePager, 0)
|
fun navigationModePager() = preferenceStore.getInt(Keys.navigationModePager, 0)
|
||||||
|
|
||||||
fun navigationModeWebtoon() = flowPrefs.getInt(Keys.navigationModeWebtoon, 0)
|
fun navigationModeWebtoon() = preferenceStore.getInt(Keys.navigationModeWebtoon, 0)
|
||||||
|
|
||||||
fun pagerNavInverted() = flowPrefs.getEnum(Keys.pagerNavInverted, ViewerNavigation.TappingInvertMode.NONE)
|
fun pagerNavInverted() = preferenceStore.getEnum(Keys.pagerNavInverted, ViewerNavigation.TappingInvertMode.NONE)
|
||||||
|
|
||||||
fun webtoonNavInverted() = flowPrefs.getEnum(Keys.webtoonNavInverted, ViewerNavigation.TappingInvertMode.NONE)
|
fun webtoonNavInverted() = preferenceStore.getEnum(Keys.webtoonNavInverted, ViewerNavigation.TappingInvertMode.NONE)
|
||||||
|
|
||||||
fun pageLayout() = flowPrefs.getInt(Keys.pageLayout, PageLayout.AUTOMATIC.value)
|
fun pageLayout() = preferenceStore.getInt(Keys.pageLayout, PageLayout.AUTOMATIC.value)
|
||||||
|
|
||||||
fun automaticSplitsPage() = flowPrefs.getBoolean(Keys.automaticSplitsPage, false)
|
fun automaticSplitsPage() = preferenceStore.getBoolean(Keys.automaticSplitsPage, false)
|
||||||
|
|
||||||
fun invertDoublePages() = flowPrefs.getBoolean(Keys.invertDoublePages, false)
|
fun invertDoublePages() = preferenceStore.getBoolean(Keys.invertDoublePages, false)
|
||||||
|
|
||||||
fun webtoonPageLayout() = flowPrefs.getInt(Keys.webtoonPageLayout, PageLayout.SINGLE_PAGE.value)
|
fun webtoonPageLayout() = preferenceStore.getInt(Keys.webtoonPageLayout, PageLayout.SINGLE_PAGE.value)
|
||||||
|
|
||||||
fun webtoonReaderHideThreshold() = flowPrefs.getEnum("reader_hide_threshold", Values.ReaderHideThreshold.LOW)
|
fun webtoonReaderHideThreshold() = preferenceStore.getEnum("reader_hide_threshold", Values.ReaderHideThreshold.LOW)
|
||||||
|
|
||||||
fun webtoonInvertDoublePages() = flowPrefs.getBoolean(Keys.webtoonInvertDoublePages, false)
|
fun webtoonInvertDoublePages() = preferenceStore.getBoolean(Keys.webtoonInvertDoublePages, false)
|
||||||
|
|
||||||
fun readerBottomButtons() = flowPrefs.getStringSet(
|
fun readerBottomButtons() = preferenceStore.getStringSet(
|
||||||
Keys.readerBottomButtons,
|
Keys.readerBottomButtons,
|
||||||
ReaderBottomButton.BUTTONS_DEFAULTS,
|
ReaderBottomButton.BUTTONS_DEFAULTS,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun showNavigationOverlayNewUser() = flowPrefs.getBoolean(Keys.showNavigationOverlayNewUser, true)
|
fun showNavigationOverlayNewUser() = preferenceStore.getBoolean(Keys.showNavigationOverlayNewUser, true)
|
||||||
|
|
||||||
fun showNavigationOverlayNewUserWebtoon() = flowPrefs.getBoolean(Keys.showNavigationOverlayNewUserWebtoon, true)
|
fun showNavigationOverlayNewUserWebtoon() = preferenceStore.getBoolean(Keys.showNavigationOverlayNewUserWebtoon, true)
|
||||||
|
|
||||||
fun preloadSize() = flowPrefs.getInt(Keys.preloadSize, 6)
|
fun preloadSize() = preferenceStore.getInt(Keys.preloadSize, 6)
|
||||||
|
|
||||||
fun autoUpdateTrack() = prefs.getBoolean(Keys.autoUpdateTrack, true)
|
fun autoUpdateTrack() = prefs.getBoolean(Keys.autoUpdateTrack, true)
|
||||||
|
|
||||||
fun trackMarkedAsRead() = prefs.getBoolean(Keys.trackMarkedAsRead, false)
|
fun trackMarkedAsRead() = prefs.getBoolean(Keys.trackMarkedAsRead, false)
|
||||||
|
|
||||||
fun trackingsToAddOnline() = flowPrefs.getStringSet(Keys.trackingsToAddOnline, emptySet())
|
fun trackingsToAddOnline() = preferenceStore.getStringSet(Keys.trackingsToAddOnline, emptySet())
|
||||||
|
|
||||||
fun lastUsedCatalogueSource() = flowPrefs.getLong(Keys.lastUsedCatalogueSource, -1)
|
fun lastUsedCatalogueSource() = preferenceStore.getLong(Keys.lastUsedCatalogueSource, -1)
|
||||||
|
|
||||||
fun lastUsedCategory() = flowPrefs.getInt(Keys.lastUsedCategory, 0)
|
fun lastUsedCategory() = preferenceStore.getInt(Keys.lastUsedCategory, 0)
|
||||||
|
|
||||||
fun lastUsedSources() = flowPrefs.getStringSet("last_used_sources", emptySet())
|
fun lastUsedSources() = preferenceStore.getStringSet("last_used_sources", emptySet())
|
||||||
|
|
||||||
fun lastVersionCode() = flowPrefs.getInt("last_version_code", 0)
|
fun lastVersionCode() = preferenceStore.getInt("last_version_code", 0)
|
||||||
|
|
||||||
fun browseAsList() = flowPrefs.getBoolean(Keys.catalogueAsList, false)
|
fun browseAsList() = preferenceStore.getBoolean(Keys.catalogueAsList, false)
|
||||||
|
|
||||||
fun enabledLanguages() = flowPrefs.getStringSet(
|
fun enabledLanguages() = preferenceStore.getStringSet(
|
||||||
Keys.enabledLanguages,
|
Keys.enabledLanguages,
|
||||||
setOfNotNull("all", "en", Locale.getDefault().language.takeIf { !it.startsWith("en") }),
|
setOfNotNull("all", "en", Locale.getDefault().language.takeIf { !it.startsWith("en") }),
|
||||||
)
|
)
|
||||||
|
|
||||||
fun sourceSorting() = flowPrefs.getInt(Keys.sourcesSort, 0)
|
fun sourceSorting() = preferenceStore.getInt(Keys.sourcesSort, 0)
|
||||||
|
|
||||||
fun anilistScoreType() = flowPrefs.getString("anilist_score_type", "POINT_10")
|
fun anilistScoreType() = preferenceStore.getString("anilist_score_type", "POINT_10")
|
||||||
|
|
||||||
fun backupsDirectory() = flowPrefs.getString(Keys.backupDirectory, defaultBackupDir.toString())
|
fun backupsDirectory() = preferenceStore.getString(Keys.backupDirectory, defaultBackupDir.toString())
|
||||||
|
|
||||||
fun dateFormat(format: String = flowPrefs.getString(Keys.dateFormat, "").get()): DateFormat = when (format) {
|
fun dateFormat(format: String = preferenceStore.getString(Keys.dateFormat, "").get()): DateFormat = when (format) {
|
||||||
"" -> DateFormat.getDateInstance(DateFormat.SHORT)
|
"" -> DateFormat.getDateInstance(DateFormat.SHORT)
|
||||||
else -> SimpleDateFormat(format, Locale.getDefault())
|
else -> SimpleDateFormat(format, Locale.getDefault())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun appLanguage() = flowPrefs.getString("app_language", "")
|
fun appLanguage() = preferenceStore.getString("app_language", "")
|
||||||
|
|
||||||
fun downloadsDirectory() = flowPrefs.getString(Keys.downloadsDirectory, defaultDownloadsDir.toString())
|
fun downloadsDirectory() = preferenceStore.getString(Keys.downloadsDirectory, defaultDownloadsDir.toString())
|
||||||
|
|
||||||
fun downloadOnlyOverWifi() = prefs.getBoolean(Keys.downloadOnlyOverWifi, true)
|
fun downloadOnlyOverWifi() = prefs.getBoolean(Keys.downloadOnlyOverWifi, true)
|
||||||
|
|
||||||
fun folderPerManga() = flowPrefs.getBoolean("create_folder_per_manga", false)
|
fun folderPerManga() = preferenceStore.getBoolean("create_folder_per_manga", false)
|
||||||
|
|
||||||
fun librarySearchSuggestion() = flowPrefs.getString(Keys.librarySearchSuggestion, "")
|
fun librarySearchSuggestion() = preferenceStore.getString(Keys.librarySearchSuggestion, "")
|
||||||
|
|
||||||
fun showLibrarySearchSuggestions() = flowPrefs.getBoolean(Keys.showLibrarySearchSuggestions, false)
|
fun showLibrarySearchSuggestions() = preferenceStore.getBoolean(Keys.showLibrarySearchSuggestions, false)
|
||||||
|
|
||||||
fun lastLibrarySuggestion() = flowPrefs.getLong("last_library_suggestion", 0L)
|
fun lastLibrarySuggestion() = preferenceStore.getLong("last_library_suggestion", 0L)
|
||||||
|
|
||||||
fun numberOfBackups() = flowPrefs.getInt(Keys.numberOfBackups, 2)
|
fun numberOfBackups() = preferenceStore.getInt(Keys.numberOfBackups, 2)
|
||||||
|
|
||||||
fun backupInterval() = flowPrefs.getInt(Keys.backupInterval, 0)
|
fun backupInterval() = preferenceStore.getInt(Keys.backupInterval, 0)
|
||||||
fun removeAfterReadSlots() = flowPrefs.getInt(Keys.removeAfterReadSlots, -1)
|
fun removeAfterReadSlots() = preferenceStore.getInt(Keys.removeAfterReadSlots, -1)
|
||||||
|
|
||||||
fun removeAfterMarkedAsRead() = prefs.getBoolean(Keys.removeAfterMarkedAsRead, false)
|
fun removeAfterMarkedAsRead() = prefs.getBoolean(Keys.removeAfterMarkedAsRead, false)
|
||||||
|
|
||||||
fun libraryUpdateInterval() = flowPrefs.getInt(Keys.libraryUpdateInterval, 24)
|
fun libraryUpdateInterval() = preferenceStore.getInt(Keys.libraryUpdateInterval, 24)
|
||||||
|
|
||||||
fun libraryUpdateLastTimestamp() = flowPrefs.getLong("library_update_last_timestamp", 0L)
|
fun libraryUpdateLastTimestamp() = preferenceStore.getLong("library_update_last_timestamp", 0L)
|
||||||
|
|
||||||
fun libraryUpdateDeviceRestriction() = flowPrefs.getStringSet("library_update_restriction", setOf(DEVICE_ONLY_ON_WIFI))
|
fun libraryUpdateDeviceRestriction() = preferenceStore.getStringSet("library_update_restriction", setOf(DEVICE_ONLY_ON_WIFI))
|
||||||
|
|
||||||
fun libraryUpdateMangaRestriction() = flowPrefs.getStringSet("library_update_manga_restriction", setOf(MANGA_HAS_UNREAD, MANGA_NON_COMPLETED, MANGA_NON_READ))
|
fun libraryUpdateMangaRestriction() = preferenceStore.getStringSet("library_update_manga_restriction", setOf(MANGA_HAS_UNREAD, MANGA_NON_COMPLETED, MANGA_NON_READ))
|
||||||
|
|
||||||
fun libraryUpdateCategories() = flowPrefs.getStringSet("library_update_categories", emptySet())
|
fun libraryUpdateCategories() = preferenceStore.getStringSet("library_update_categories", emptySet())
|
||||||
fun libraryUpdateCategoriesExclude() = flowPrefs.getStringSet("library_update_categories_exclude", emptySet())
|
fun libraryUpdateCategoriesExclude() = preferenceStore.getStringSet("library_update_categories_exclude", emptySet())
|
||||||
|
|
||||||
fun libraryLayout() = flowPrefs.getInt(Keys.libraryLayout, LibraryItem.LAYOUT_COMFORTABLE_GRID)
|
fun libraryLayout() = preferenceStore.getInt(Keys.libraryLayout, LibraryItem.LAYOUT_COMFORTABLE_GRID)
|
||||||
|
|
||||||
fun gridSize() = flowPrefs.getFloat(Keys.gridSize, 1f)
|
fun gridSize() = preferenceStore.getFloat(Keys.gridSize, 1f)
|
||||||
|
|
||||||
fun uniformGrid() = flowPrefs.getBoolean(Keys.uniformGrid, true)
|
fun uniformGrid() = preferenceStore.getBoolean(Keys.uniformGrid, true)
|
||||||
|
|
||||||
fun outlineOnCovers() = flowPrefs.getBoolean(Keys.outlineOnCovers, true)
|
fun outlineOnCovers() = preferenceStore.getBoolean(Keys.outlineOnCovers, true)
|
||||||
|
|
||||||
fun downloadBadge() = flowPrefs.getBoolean(Keys.downloadBadge, false)
|
fun downloadBadge() = preferenceStore.getBoolean(Keys.downloadBadge, false)
|
||||||
|
|
||||||
fun languageBadge() = flowPrefs.getBoolean(Keys.languageBadge, false)
|
fun languageBadge() = preferenceStore.getBoolean(Keys.languageBadge, false)
|
||||||
|
|
||||||
fun filterDownloaded() = flowPrefs.getInt(Keys.filterDownloaded, 0)
|
fun filterDownloaded() = preferenceStore.getInt(Keys.filterDownloaded, 0)
|
||||||
|
|
||||||
fun filterUnread() = flowPrefs.getInt(Keys.filterUnread, 0)
|
fun filterUnread() = preferenceStore.getInt(Keys.filterUnread, 0)
|
||||||
|
|
||||||
fun filterCompleted() = flowPrefs.getInt(Keys.filterCompleted, 0)
|
fun filterCompleted() = preferenceStore.getInt(Keys.filterCompleted, 0)
|
||||||
|
|
||||||
fun filterBookmarked() = flowPrefs.getInt("pref_filter_bookmarked_key", 0)
|
fun filterBookmarked() = preferenceStore.getInt("pref_filter_bookmarked_key", 0)
|
||||||
|
|
||||||
fun filterTracked() = flowPrefs.getInt(Keys.filterTracked, 0)
|
fun filterTracked() = preferenceStore.getInt(Keys.filterTracked, 0)
|
||||||
|
|
||||||
fun filterMangaType() = flowPrefs.getInt(Keys.filterMangaType, 0)
|
fun filterMangaType() = preferenceStore.getInt(Keys.filterMangaType, 0)
|
||||||
|
|
||||||
fun showEmptyCategoriesWhileFiltering() = flowPrefs.getBoolean(Keys.showEmptyCategoriesFiltering, false)
|
fun showEmptyCategoriesWhileFiltering() = preferenceStore.getBoolean(Keys.showEmptyCategoriesFiltering, false)
|
||||||
|
|
||||||
fun librarySortingMode() = flowPrefs.getInt("library_sorting_mode", 0)
|
fun librarySortingMode() = preferenceStore.getInt("library_sorting_mode", 0)
|
||||||
|
|
||||||
fun librarySortingAscending() = flowPrefs.getBoolean("library_sorting_ascending", true)
|
fun librarySortingAscending() = preferenceStore.getBoolean("library_sorting_ascending", true)
|
||||||
|
|
||||||
fun automaticExtUpdates() = flowPrefs.getBoolean(Keys.automaticExtUpdates, true)
|
fun automaticExtUpdates() = preferenceStore.getBoolean(Keys.automaticExtUpdates, true)
|
||||||
|
|
||||||
fun installedExtensionsOrder() = flowPrefs.getInt(Keys.installedExtensionsOrder, InstalledExtensionsOrder.Name.value)
|
fun installedExtensionsOrder() = preferenceStore.getInt(Keys.installedExtensionsOrder, InstalledExtensionsOrder.Name.value)
|
||||||
|
|
||||||
fun migrationSourceOrder() = flowPrefs.getInt("migration_source_order", Values.MigrationSourceOrder.Alphabetically.value)
|
fun migrationSourceOrder() = preferenceStore.getInt("migration_source_order", Values.MigrationSourceOrder.Alphabetically.value)
|
||||||
|
|
||||||
fun collapsedCategories() = flowPrefs.getStringSet("collapsed_categories", mutableSetOf())
|
fun collapsedCategories() = preferenceStore.getStringSet("collapsed_categories", mutableSetOf())
|
||||||
|
|
||||||
fun collapsedDynamicCategories() = flowPrefs.getStringSet("collapsed_dynamic_categories", mutableSetOf())
|
fun collapsedDynamicCategories() = preferenceStore.getStringSet("collapsed_dynamic_categories", mutableSetOf())
|
||||||
|
|
||||||
fun collapsedDynamicAtBottom() = flowPrefs.getBoolean("collapsed_dynamic_at_bottom", false)
|
fun collapsedDynamicAtBottom() = preferenceStore.getBoolean("collapsed_dynamic_at_bottom", false)
|
||||||
|
|
||||||
fun hiddenSources() = flowPrefs.getStringSet("hidden_catalogues", mutableSetOf())
|
fun hiddenSources() = preferenceStore.getStringSet("hidden_catalogues", mutableSetOf())
|
||||||
|
|
||||||
fun pinnedCatalogues() = flowPrefs.getStringSet("pinned_catalogues", mutableSetOf())
|
fun pinnedCatalogues() = preferenceStore.getStringSet("pinned_catalogues", mutableSetOf())
|
||||||
|
|
||||||
fun saveChaptersAsCBZ() = flowPrefs.getBoolean("save_chapter_as_cbz", true)
|
fun saveChaptersAsCBZ() = preferenceStore.getBoolean("save_chapter_as_cbz", true)
|
||||||
|
|
||||||
fun splitTallImages() = flowPrefs.getBoolean("split_tall_images", false)
|
fun splitTallImages() = preferenceStore.getBoolean("split_tall_images", false)
|
||||||
|
|
||||||
fun downloadNewChapters() = flowPrefs.getBoolean(Keys.downloadNew, false)
|
fun downloadNewChapters() = preferenceStore.getBoolean(Keys.downloadNew, false)
|
||||||
|
|
||||||
fun downloadNewChaptersInCategories() = flowPrefs.getStringSet("download_new_categories", emptySet())
|
fun downloadNewChaptersInCategories() = preferenceStore.getStringSet("download_new_categories", emptySet())
|
||||||
fun excludeCategoriesInDownloadNew() = flowPrefs.getStringSet("download_new_categories_exclude", emptySet())
|
fun excludeCategoriesInDownloadNew() = preferenceStore.getStringSet("download_new_categories_exclude", emptySet())
|
||||||
|
|
||||||
fun autoDownloadWhileReading() = flowPrefs.getInt("auto_download_while_reading", 0)
|
fun autoDownloadWhileReading() = preferenceStore.getInt("auto_download_while_reading", 0)
|
||||||
|
|
||||||
fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -2)
|
fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -2)
|
||||||
|
|
||||||
|
@ -326,159 +319,159 @@ class PreferencesHelper(val context: Context) {
|
||||||
|
|
||||||
fun skipFiltered() = prefs.getBoolean(Keys.skipFiltered, true)
|
fun skipFiltered() = prefs.getBoolean(Keys.skipFiltered, true)
|
||||||
|
|
||||||
fun skipDupe() = flowPrefs.getBoolean("skip_dupe", false)
|
fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false)
|
||||||
|
|
||||||
fun useBiometrics() = flowPrefs.getBoolean(Keys.useBiometrics, false)
|
fun useBiometrics() = preferenceStore.getBoolean(Keys.useBiometrics, false)
|
||||||
|
|
||||||
fun lockAfter() = flowPrefs.getInt(Keys.lockAfter, 0)
|
fun lockAfter() = preferenceStore.getInt(Keys.lockAfter, 0)
|
||||||
|
|
||||||
fun lastUnlock() = flowPrefs.getLong(Keys.lastUnlock, 0)
|
fun lastUnlock() = preferenceStore.getLong(Keys.lastUnlock, 0)
|
||||||
|
|
||||||
fun secureScreen() = flowPrefs.getEnum("secure_screen_v2", Values.SecureScreenMode.INCOGNITO)
|
fun secureScreen() = preferenceStore.getEnum("secure_screen_v2", Values.SecureScreenMode.INCOGNITO)
|
||||||
|
|
||||||
fun hideNotificationContent() = prefs.getBoolean(Keys.hideNotificationContent, false)
|
fun hideNotificationContent() = prefs.getBoolean(Keys.hideNotificationContent, false)
|
||||||
|
|
||||||
fun removeArticles() = flowPrefs.getBoolean(Keys.removeArticles, false)
|
fun removeArticles() = preferenceStore.getBoolean(Keys.removeArticles, false)
|
||||||
|
|
||||||
fun migrateFlags() = flowPrefs.getInt("migrate_flags", Int.MAX_VALUE)
|
fun migrateFlags() = preferenceStore.getInt("migrate_flags", Int.MAX_VALUE)
|
||||||
|
|
||||||
fun trustedSignatures() = flowPrefs.getStringSet("trusted_signatures", emptySet())
|
fun trustedSignatures() = preferenceStore.getStringSet("trusted_signatures", emptySet())
|
||||||
|
|
||||||
// using string instead of set so it is ordered
|
// using string instead of set so it is ordered
|
||||||
fun migrationSources() = flowPrefs.getString("migrate_sources", "")
|
fun migrationSources() = preferenceStore.getString("migrate_sources", "")
|
||||||
|
|
||||||
fun useSourceWithMost() = flowPrefs.getBoolean("use_source_with_most", false)
|
fun useSourceWithMost() = preferenceStore.getBoolean("use_source_with_most", false)
|
||||||
|
|
||||||
fun skipPreMigration() = flowPrefs.getBoolean(Keys.skipPreMigration, false)
|
fun skipPreMigration() = preferenceStore.getBoolean(Keys.skipPreMigration, false)
|
||||||
|
|
||||||
fun defaultMangaOrder() = flowPrefs.getString("default_manga_order", "")
|
fun defaultMangaOrder() = preferenceStore.getString("default_manga_order", "")
|
||||||
|
|
||||||
fun refreshCoversToo() = flowPrefs.getBoolean(Keys.refreshCoversToo, true)
|
fun refreshCoversToo() = preferenceStore.getBoolean(Keys.refreshCoversToo, true)
|
||||||
|
|
||||||
fun extensionUpdatesCount() = flowPrefs.getInt("ext_updates_count", 0)
|
fun extensionUpdatesCount() = preferenceStore.getInt("ext_updates_count", 0)
|
||||||
|
|
||||||
fun recentsViewType() = flowPrefs.getInt("recents_view_type", 0)
|
fun recentsViewType() = preferenceStore.getInt("recents_view_type", 0)
|
||||||
|
|
||||||
fun showRecentsDownloads() = flowPrefs.getEnum(Keys.showDLsInRecents, RecentMangaAdapter.ShowRecentsDLs.All)
|
fun showRecentsDownloads() = preferenceStore.getEnum(Keys.showDLsInRecents, RecentMangaAdapter.ShowRecentsDLs.All)
|
||||||
|
|
||||||
fun showRecentsRemHistory() = flowPrefs.getBoolean(Keys.showRemHistoryInRecents, true)
|
fun showRecentsRemHistory() = preferenceStore.getBoolean(Keys.showRemHistoryInRecents, true)
|
||||||
|
|
||||||
fun showReadInAllRecents() = flowPrefs.getBoolean(Keys.showReadInAllRecents, false)
|
fun showReadInAllRecents() = preferenceStore.getBoolean(Keys.showReadInAllRecents, false)
|
||||||
|
|
||||||
fun showUpdatedTime() = flowPrefs.getBoolean(Keys.showUpdatedTime, false)
|
fun showUpdatedTime() = preferenceStore.getBoolean(Keys.showUpdatedTime, false)
|
||||||
|
|
||||||
fun sortFetchedTime() = flowPrefs.getBoolean("sort_fetched_time", false)
|
fun sortFetchedTime() = preferenceStore.getBoolean("sort_fetched_time", false)
|
||||||
|
|
||||||
fun collapseGroupedUpdates() = flowPrefs.getBoolean("group_chapters_updates", false)
|
fun collapseGroupedUpdates() = preferenceStore.getBoolean("group_chapters_updates", false)
|
||||||
|
|
||||||
fun groupChaptersHistory() = flowPrefs.getEnum("group_chapters_history_type", RecentsPresenter.GroupType.ByWeek)
|
fun groupChaptersHistory() = preferenceStore.getEnum("group_chapters_history_type", RecentsPresenter.GroupType.ByWeek)
|
||||||
|
|
||||||
fun collapseGroupedHistory() = flowPrefs.getBoolean("collapse_group_history", true)
|
fun collapseGroupedHistory() = preferenceStore.getBoolean("collapse_group_history", true)
|
||||||
|
|
||||||
fun showTitleFirstInRecents() = flowPrefs.getBoolean(Keys.showTitleFirstInRecents, false)
|
fun showTitleFirstInRecents() = preferenceStore.getBoolean(Keys.showTitleFirstInRecents, false)
|
||||||
|
|
||||||
fun lastExtCheck() = flowPrefs.getLong("last_ext_check", 0)
|
fun lastExtCheck() = preferenceStore.getLong("last_ext_check", 0)
|
||||||
|
|
||||||
fun lastAppCheck() = flowPrefs.getLong("last_app_check", 0)
|
fun lastAppCheck() = preferenceStore.getLong("last_app_check", 0)
|
||||||
|
|
||||||
fun checkForBetas() = flowPrefs.getBoolean("check_for_betas", BuildConfig.BETA)
|
fun checkForBetas() = preferenceStore.getBoolean("check_for_betas", BuildConfig.BETA)
|
||||||
|
|
||||||
fun unreadBadgeType() = flowPrefs.getInt("unread_badge_type", 2)
|
fun unreadBadgeType() = preferenceStore.getInt("unread_badge_type", 2)
|
||||||
|
|
||||||
fun categoryNumberOfItems() = flowPrefs.getBoolean(Keys.categoryNumberOfItems, false)
|
fun categoryNumberOfItems() = preferenceStore.getBoolean(Keys.categoryNumberOfItems, false)
|
||||||
|
|
||||||
fun hideStartReadingButton() = flowPrefs.getBoolean("hide_reading_button", false)
|
fun hideStartReadingButton() = preferenceStore.getBoolean("hide_reading_button", false)
|
||||||
|
|
||||||
fun alwaysShowChapterTransition() = flowPrefs.getBoolean(Keys.alwaysShowChapterTransition, true)
|
fun alwaysShowChapterTransition() = preferenceStore.getBoolean(Keys.alwaysShowChapterTransition, true)
|
||||||
|
|
||||||
fun deleteRemovedChapters() = flowPrefs.getInt(Keys.deleteRemovedChapters, 0)
|
fun deleteRemovedChapters() = preferenceStore.getInt(Keys.deleteRemovedChapters, 0)
|
||||||
|
|
||||||
fun removeBookmarkedChapters() = flowPrefs.getBoolean("pref_remove_bookmarked", false)
|
fun removeBookmarkedChapters() = preferenceStore.getBoolean("pref_remove_bookmarked", false)
|
||||||
|
|
||||||
fun removeExcludeCategories() = flowPrefs.getStringSet("remove_exclude_categories", emptySet())
|
fun removeExcludeCategories() = preferenceStore.getStringSet("remove_exclude_categories", emptySet())
|
||||||
|
|
||||||
fun showAllCategories() = flowPrefs.getBoolean("show_all_categories", true)
|
fun showAllCategories() = preferenceStore.getBoolean("show_all_categories", true)
|
||||||
|
|
||||||
fun showAllCategoriesWhenSearchingSingleCategory() = flowPrefs.getBoolean("show_all_categories_when_searching_single_category", false)
|
fun showAllCategoriesWhenSearchingSingleCategory() = preferenceStore.getBoolean("show_all_categories_when_searching_single_category", false)
|
||||||
|
|
||||||
fun hopperGravity() = flowPrefs.getInt("hopper_gravity", 1)
|
fun hopperGravity() = preferenceStore.getInt("hopper_gravity", 1)
|
||||||
|
|
||||||
fun filterOrder() = flowPrefs.getString("filter_order", FilterBottomSheet.Filters.DEFAULT_ORDER)
|
fun filterOrder() = preferenceStore.getString("filter_order", FilterBottomSheet.Filters.DEFAULT_ORDER)
|
||||||
|
|
||||||
fun hopperLongPressAction() = flowPrefs.getInt(Keys.hopperLongPress, 0)
|
fun hopperLongPressAction() = preferenceStore.getInt(Keys.hopperLongPress, 0)
|
||||||
|
|
||||||
fun hideHopper() = flowPrefs.getBoolean("hide_hopper", false)
|
fun hideHopper() = preferenceStore.getBoolean("hide_hopper", false)
|
||||||
|
|
||||||
fun autohideHopper() = flowPrefs.getBoolean(Keys.autoHideHopper, true)
|
fun autohideHopper() = preferenceStore.getBoolean(Keys.autoHideHopper, true)
|
||||||
|
|
||||||
fun groupLibraryBy() = flowPrefs.getInt("group_library_by", 0)
|
fun groupLibraryBy() = preferenceStore.getInt("group_library_by", 0)
|
||||||
|
|
||||||
fun showCategoryInTitle() = flowPrefs.getBoolean("category_in_title", false)
|
fun showCategoryInTitle() = preferenceStore.getBoolean("category_in_title", false)
|
||||||
|
|
||||||
fun onlySearchPinned() = flowPrefs.getBoolean(Keys.onlySearchPinned, false)
|
fun onlySearchPinned() = preferenceStore.getBoolean(Keys.onlySearchPinned, false)
|
||||||
|
|
||||||
fun hideInLibraryItems() = flowPrefs.getBoolean("browse_hide_in_library_items", false)
|
fun hideInLibraryItems() = preferenceStore.getBoolean("browse_hide_in_library_items", false)
|
||||||
|
|
||||||
// Tutorial preferences
|
// Tutorial preferences
|
||||||
fun shownFilterTutorial() = flowPrefs.getBoolean("shown_filter_tutorial", false)
|
fun shownFilterTutorial() = preferenceStore.getBoolean("shown_filter_tutorial", false)
|
||||||
|
|
||||||
fun shownChapterSwipeTutorial() = flowPrefs.getBoolean("shown_swipe_tutorial", false)
|
fun shownChapterSwipeTutorial() = preferenceStore.getBoolean("shown_swipe_tutorial", false)
|
||||||
|
|
||||||
fun shownDownloadQueueTutorial() = flowPrefs.getBoolean("shown_download_queue", false)
|
fun shownDownloadQueueTutorial() = preferenceStore.getBoolean("shown_download_queue", false)
|
||||||
|
|
||||||
fun shownLongPressCategoryTutorial() = flowPrefs.getBoolean("shown_long_press_category", false)
|
fun shownLongPressCategoryTutorial() = preferenceStore.getBoolean("shown_long_press_category", false)
|
||||||
|
|
||||||
fun shownHopperSwipeTutorial() = flowPrefs.getBoolean("shown_hopper_swipe", false)
|
fun shownHopperSwipeTutorial() = preferenceStore.getBoolean("shown_hopper_swipe", false)
|
||||||
|
|
||||||
fun shownDownloadSwipeTutorial() = flowPrefs.getBoolean("shown_download_tutorial", false)
|
fun shownDownloadSwipeTutorial() = preferenceStore.getBoolean("shown_download_tutorial", false)
|
||||||
|
|
||||||
fun hideBottomNavOnScroll() = flowPrefs.getBoolean(Keys.hideBottomNavOnScroll, true)
|
fun hideBottomNavOnScroll() = preferenceStore.getBoolean(Keys.hideBottomNavOnScroll, true)
|
||||||
|
|
||||||
fun sideNavIconAlignment() = flowPrefs.getInt(Keys.sideNavIconAlignment, 1)
|
fun sideNavIconAlignment() = preferenceStore.getInt(Keys.sideNavIconAlignment, 1)
|
||||||
|
|
||||||
fun showNsfwSources() = flowPrefs.getBoolean(Keys.showNsfwSource, true)
|
fun showNsfwSources() = preferenceStore.getBoolean(Keys.showNsfwSource, true)
|
||||||
|
|
||||||
fun themeMangaDetails() = prefs.getBoolean(Keys.themeMangaDetails, true)
|
fun themeMangaDetails() = prefs.getBoolean(Keys.themeMangaDetails, true)
|
||||||
|
|
||||||
fun useLargeToolbar() = flowPrefs.getBoolean("use_large_toolbar", true)
|
fun useLargeToolbar() = preferenceStore.getBoolean("use_large_toolbar", true)
|
||||||
|
|
||||||
fun dohProvider() = prefs.getInt(Keys.dohProvider, -1)
|
fun dohProvider() = prefs.getInt(Keys.dohProvider, -1)
|
||||||
|
|
||||||
fun defaultUserAgent() = flowPrefs.getString("default_user_agent", NetworkHelper.DEFAULT_USER_AGENT)
|
fun defaultUserAgent() = preferenceStore.getString("default_user_agent", NetworkHelper.DEFAULT_USER_AGENT)
|
||||||
|
|
||||||
fun showSeriesInShortcuts() = prefs.getBoolean(Keys.showSeriesInShortcuts, true)
|
fun showSeriesInShortcuts() = prefs.getBoolean(Keys.showSeriesInShortcuts, true)
|
||||||
fun showSourcesInShortcuts() = prefs.getBoolean(Keys.showSourcesInShortcuts, true)
|
fun showSourcesInShortcuts() = prefs.getBoolean(Keys.showSourcesInShortcuts, true)
|
||||||
fun openChapterInShortcuts() = prefs.getBoolean(Keys.openChapterInShortcuts, true)
|
fun openChapterInShortcuts() = prefs.getBoolean(Keys.openChapterInShortcuts, true)
|
||||||
|
|
||||||
fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false)
|
fun incognitoMode() = preferenceStore.getBoolean(Keys.incognitoMode, false)
|
||||||
|
|
||||||
fun hasPromptedBeforeUpdateAll() = flowPrefs.getBoolean("has_prompted_update_all", false)
|
fun hasPromptedBeforeUpdateAll() = preferenceStore.getBoolean("has_prompted_update_all", false)
|
||||||
|
|
||||||
fun sideNavMode() = flowPrefs.getInt(Keys.sideNavMode, 0)
|
fun sideNavMode() = preferenceStore.getInt(Keys.sideNavMode, 0)
|
||||||
|
|
||||||
fun appShouldAutoUpdate() = prefs.getInt(Keys.shouldAutoUpdate, AppDownloadInstallJob.ONLY_ON_UNMETERED)
|
fun appShouldAutoUpdate() = prefs.getInt(Keys.shouldAutoUpdate, AppDownloadInstallJob.ONLY_ON_UNMETERED)
|
||||||
|
|
||||||
fun autoUpdateExtensions() = prefs.getInt(Keys.autoUpdateExtensions, AppDownloadInstallJob.ONLY_ON_UNMETERED)
|
fun autoUpdateExtensions() = prefs.getInt(Keys.autoUpdateExtensions, AppDownloadInstallJob.ONLY_ON_UNMETERED)
|
||||||
|
|
||||||
fun extensionInstaller() = flowPrefs.getInt("extension_installer", ExtensionInstaller.PACKAGE_INSTALLER)
|
fun extensionInstaller() = preferenceStore.getInt("extension_installer", ExtensionInstaller.PACKAGE_INSTALLER)
|
||||||
|
|
||||||
fun filterChapterByRead() = flowPrefs.getInt(Keys.defaultChapterFilterByRead, Manga.SHOW_ALL)
|
fun filterChapterByRead() = preferenceStore.getInt(Keys.defaultChapterFilterByRead, Manga.SHOW_ALL)
|
||||||
|
|
||||||
fun filterChapterByDownloaded() = flowPrefs.getInt(Keys.defaultChapterFilterByDownloaded, Manga.SHOW_ALL)
|
fun filterChapterByDownloaded() = preferenceStore.getInt(Keys.defaultChapterFilterByDownloaded, Manga.SHOW_ALL)
|
||||||
|
|
||||||
fun filterChapterByBookmarked() = flowPrefs.getInt(Keys.defaultChapterFilterByBookmarked, Manga.SHOW_ALL)
|
fun filterChapterByBookmarked() = preferenceStore.getInt(Keys.defaultChapterFilterByBookmarked, Manga.SHOW_ALL)
|
||||||
|
|
||||||
fun sortChapterOrder() = flowPrefs.getInt(Keys.defaultChapterSortBySourceOrNumber, Manga.CHAPTER_SORTING_SOURCE)
|
fun sortChapterOrder() = preferenceStore.getInt(Keys.defaultChapterSortBySourceOrNumber, Manga.CHAPTER_SORTING_SOURCE)
|
||||||
|
|
||||||
fun hideChapterTitlesByDefault() = flowPrefs.getBoolean(Keys.hideChapterTitles, false)
|
fun hideChapterTitlesByDefault() = preferenceStore.getBoolean(Keys.hideChapterTitles, false)
|
||||||
|
|
||||||
fun chaptersDescAsDefault() = flowPrefs.getBoolean(Keys.chaptersDescAsDefault, true)
|
fun chaptersDescAsDefault() = preferenceStore.getBoolean(Keys.chaptersDescAsDefault, true)
|
||||||
|
|
||||||
fun sortChapterByAscendingOrDescending() = prefs.getInt(Keys.defaultChapterSortByAscendingOrDescending, Manga.CHAPTER_SORT_DESC)
|
fun sortChapterByAscendingOrDescending() = prefs.getInt(Keys.defaultChapterSortByAscendingOrDescending, Manga.CHAPTER_SORT_DESC)
|
||||||
|
|
||||||
fun coverRatios() = flowPrefs.getStringSet(Keys.coverRatios, emptySet())
|
fun coverRatios() = preferenceStore.getStringSet(Keys.coverRatios, emptySet())
|
||||||
|
|
||||||
fun coverColors() = flowPrefs.getStringSet(Keys.coverColors, emptySet())
|
fun coverColors() = preferenceStore.getStringSet(Keys.coverColors, emptySet())
|
||||||
|
|
||||||
fun useStaggeredGrid() = flowPrefs.getBoolean("use_staggered_grid", false)
|
fun useStaggeredGrid() = preferenceStore.getBoolean("use_staggered_grid", false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.data.track
|
package eu.kanade.tachiyomi.data.track
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.Preference
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceStore
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
import eu.kanade.tachiyomi.data.track.anilist.Anilist
|
import eu.kanade.tachiyomi.data.track.anilist.Anilist
|
||||||
|
|
||||||
class TrackPreferences(
|
class TrackPreferences(
|
||||||
|
|
|
@ -163,7 +163,7 @@ class ExtensionManager(
|
||||||
.map(Extension.AvailableSource::lang)
|
.map(Extension.AvailableSource::lang)
|
||||||
|
|
||||||
val deviceLanguage = Locale.getDefault().language
|
val deviceLanguage = Locale.getDefault().language
|
||||||
val defaultLanguages = preferences.enabledLanguages().defaultValue
|
val defaultLanguages = preferences.enabledLanguages().defaultValue()
|
||||||
val languagesToEnable = availableLanguages.filter {
|
val languagesToEnable = availableLanguages.filter {
|
||||||
it != deviceLanguage && it.startsWith(deviceLanguage) && !it.startsWith("en")
|
it != deviceLanguage && it.startsWith(deviceLanguage) && !it.startsWith("en")
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.decodeFromString
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.CacheControl
|
import okhttp3.CacheControl
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
|
|
@ -6,9 +6,9 @@ import android.content.DialogInterface
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.addTextChangedListener
|
import androidx.core.widget.addTextChangedListener
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
|
|
|
@ -3,14 +3,13 @@ package eu.kanade.tachiyomi.ui.extension
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.minusAssign
|
import eu.kanade.tachiyomi.core.preference.minusAssign
|
||||||
import eu.kanade.tachiyomi.data.preference.plusAssign
|
import eu.kanade.tachiyomi.core.preference.plusAssign
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||||
import eu.kanade.tachiyomi.ui.setting.onChange
|
import eu.kanade.tachiyomi.ui.setting.onChange
|
||||||
import eu.kanade.tachiyomi.ui.setting.titleRes
|
import eu.kanade.tachiyomi.ui.setting.titleRes
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class ExtensionFilterController : SettingsController() {
|
class ExtensionFilterController : SettingsController() {
|
||||||
|
|
|
@ -24,8 +24,8 @@ import com.google.android.material.snackbar.Snackbar
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.SharedPreferencesDataStore
|
import eu.kanade.tachiyomi.data.preference.SharedPreferencesDataStore
|
||||||
import eu.kanade.tachiyomi.data.preference.minusAssign
|
import eu.kanade.tachiyomi.core.preference.minusAssign
|
||||||
import eu.kanade.tachiyomi.data.preference.plusAssign
|
import eu.kanade.tachiyomi.core.preference.plusAssign
|
||||||
import eu.kanade.tachiyomi.databinding.ExtensionDetailControllerBinding
|
import eu.kanade.tachiyomi.databinding.ExtensionDetailControllerBinding
|
||||||
import eu.kanade.tachiyomi.extension.model.Extension
|
import eu.kanade.tachiyomi.extension.model.Extension
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
|
@ -267,7 +267,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
||||||
}
|
}
|
||||||
|
|
||||||
// React to enable/disable all changes
|
// React to enable/disable all changes
|
||||||
preferences.hiddenSources().asFlow()
|
preferences.hiddenSources().changes()
|
||||||
.onEach {
|
.onEach {
|
||||||
val enabled = source.isEnabled()
|
val enabled = source.isEnabled()
|
||||||
isChecked = enabled
|
isChecked = enabled
|
||||||
|
|
|
@ -48,7 +48,6 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
|
||||||
import com.github.florent37.viewtooltip.ViewTooltip
|
import com.github.florent37.viewtooltip.ViewTooltip
|
||||||
import com.google.android.material.snackbar.BaseTransientBottomBar
|
import com.google.android.material.snackbar.BaseTransientBottomBar
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
@ -58,6 +57,7 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.davidea.flexibleadapter.items.IHeader
|
import eu.davidea.flexibleadapter.items.IHeader
|
||||||
import eu.davidea.flexibleadapter.items.ISectionable
|
import eu.davidea.flexibleadapter.items.ISectionable
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
@ -1003,7 +1003,7 @@ open class LibraryController(
|
||||||
preferences.gridSize(),
|
preferences.gridSize(),
|
||||||
preferences.useStaggeredGrid(),
|
preferences.useStaggeredGrid(),
|
||||||
).forEach {
|
).forEach {
|
||||||
it.asFlow()
|
it.changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
reattachAdapter()
|
reattachAdapter()
|
||||||
|
@ -1017,7 +1017,7 @@ open class LibraryController(
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
private fun <T> Preference<T>.register(onChanged: ((T) -> Unit)? = null) {
|
private fun <T> Preference<T>.register(onChanged: ((T) -> Unit)? = null) {
|
||||||
asFlow()
|
changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
onChanged?.invoke(it)
|
onChanged?.invoke(it)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.ui.library
|
package eu.kanade.tachiyomi.ui.library
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.core.preference.getAndSet
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
|
@ -13,8 +14,8 @@ import eu.kanade.tachiyomi.data.database.models.Track
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.preference.DelayedLibrarySuggestionsJob
|
import eu.kanade.tachiyomi.data.preference.DelayedLibrarySuggestionsJob
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.minusAssign
|
import eu.kanade.tachiyomi.core.preference.minusAssign
|
||||||
import eu.kanade.tachiyomi.data.preference.plusAssign
|
import eu.kanade.tachiyomi.core.preference.plusAssign
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
@ -145,7 +146,7 @@ class LibraryPresenter(
|
||||||
lastAllLibraryItems = null
|
lastAllLibraryItems = null
|
||||||
}
|
}
|
||||||
getLibrary()
|
getLibrary()
|
||||||
if (preferences.showLibrarySearchSuggestions().isNotSet()) {
|
if (!preferences.showLibrarySearchSuggestions().isSet()) {
|
||||||
DelayedLibrarySuggestionsJob.setupTask(context, true)
|
DelayedLibrarySuggestionsJob.setupTask(context, true)
|
||||||
} else if (preferences.showLibrarySearchSuggestions().get() &&
|
} else if (preferences.showLibrarySearchSuggestions().get() &&
|
||||||
Date().time >= preferences.lastLibrarySuggestion().get() + TimeUnit.HOURS.toMillis(2)
|
Date().time >= preferences.lastLibrarySuggestion().get() + TimeUnit.HOURS.toMillis(2)
|
||||||
|
@ -1415,7 +1416,7 @@ class LibraryPresenter(
|
||||||
} ?: "",
|
} ?: "",
|
||||||
)
|
)
|
||||||
|
|
||||||
if (preferences.showLibrarySearchSuggestions().isNotSet()) {
|
if (!preferences.showLibrarySearchSuggestions().isSet()) {
|
||||||
preferences.showLibrarySearchSuggestions().set(true)
|
preferences.showLibrarySearchSuggestions().set(true)
|
||||||
}
|
}
|
||||||
preferences.lastLibrarySuggestion().set(Date().time)
|
preferences.lastLibrarySuggestion().set(Date().time)
|
||||||
|
|
|
@ -204,7 +204,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||||
|
|
||||||
setExpandText(controller.canCollapseOrExpandCategory(), false)
|
setExpandText(controller.canCollapseOrExpandCategory(), false)
|
||||||
|
|
||||||
preferences.filterOrder().asFlow()
|
preferences.filterOrder().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
filterOrder = it
|
filterOrder = it
|
||||||
|
|
|
@ -6,8 +6,8 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.databinding.FilterTagGroupBinding
|
import eu.kanade.tachiyomi.databinding.FilterTagGroupBinding
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
|
|
|
@ -78,7 +78,7 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.data.updater.AppUpdateChecker
|
import eu.kanade.tachiyomi.data.updater.AppUpdateChecker
|
||||||
import eu.kanade.tachiyomi.data.updater.AppUpdateNotifier
|
import eu.kanade.tachiyomi.data.updater.AppUpdateNotifier
|
||||||
import eu.kanade.tachiyomi.data.updater.AppUpdateResult
|
import eu.kanade.tachiyomi.data.updater.AppUpdateResult
|
||||||
|
@ -641,17 +641,17 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
||||||
getExtensionUpdates(true)
|
getExtensionUpdates(true)
|
||||||
|
|
||||||
preferences.extensionUpdatesCount()
|
preferences.extensionUpdatesCount()
|
||||||
.asImmediateFlowIn(lifecycleScope) {
|
.changesIn(lifecycleScope) {
|
||||||
setExtensionsBadge()
|
setExtensionsBadge()
|
||||||
}
|
}
|
||||||
preferences.incognitoMode()
|
preferences.incognitoMode()
|
||||||
.asImmediateFlowIn(lifecycleScope) {
|
.changesIn(lifecycleScope) {
|
||||||
binding.toolbar.setIncognitoMode(it)
|
binding.toolbar.setIncognitoMode(it)
|
||||||
binding.searchToolbar.setIncognitoMode(it)
|
binding.searchToolbar.setIncognitoMode(it)
|
||||||
SecureActivityDelegate.setSecure(this)
|
SecureActivityDelegate.setSecure(this)
|
||||||
}
|
}
|
||||||
preferences.sideNavIconAlignment()
|
preferences.sideNavIconAlignment()
|
||||||
.asImmediateFlowIn(lifecycleScope) {
|
.changesIn(lifecycleScope) {
|
||||||
binding.sideNav?.menuGravity = when (it) {
|
binding.sideNav?.menuGravity = when (it) {
|
||||||
1 -> Gravity.CENTER
|
1 -> Gravity.CENTER
|
||||||
2 -> Gravity.BOTTOM
|
2 -> Gravity.BOTTOM
|
||||||
|
|
|
@ -18,8 +18,8 @@ import androidx.core.view.children
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.databinding.MigrationBottomSheetBinding
|
import eu.kanade.tachiyomi.databinding.MigrationBottomSheetBinding
|
||||||
import eu.kanade.tachiyomi.ui.migration.MigrationFlags
|
import eu.kanade.tachiyomi.ui.migration.MigrationFlags
|
||||||
|
|
|
@ -13,7 +13,7 @@ import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.toggle
|
import eu.kanade.tachiyomi.core.preference.toggle
|
||||||
import eu.kanade.tachiyomi.databinding.TachiOverflowLayoutBinding
|
import eu.kanade.tachiyomi.databinding.TachiOverflowLayoutBinding
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.util.lang.addBetaTag
|
import eu.kanade.tachiyomi.util.lang.addBetaTag
|
||||||
|
|
|
@ -37,7 +37,6 @@ import android.view.animation.AnimationUtils
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.activity.BackEventCompat
|
import androidx.activity.BackEventCompat
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.addCallback
|
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
@ -76,8 +75,8 @@ import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.core.preference.toggle
|
||||||
import eu.kanade.tachiyomi.data.preference.toggle
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.data.track.TrackService
|
import eu.kanade.tachiyomi.data.track.TrackService
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderActivityBinding
|
import eu.kanade.tachiyomi.databinding.ReaderActivityBinding
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
|
@ -371,7 +370,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
||||||
initializeMenu()
|
initializeMenu()
|
||||||
|
|
||||||
preferences.incognitoMode()
|
preferences.incognitoMode()
|
||||||
.asImmediateFlowIn(lifecycleScope) {
|
.changesIn(lifecycleScope) {
|
||||||
SecureActivityDelegate.setSecure(this)
|
SecureActivityDelegate.setSecure(this)
|
||||||
}
|
}
|
||||||
reEnableBackPressedCallBack()
|
reEnableBackPressedCallBack()
|
||||||
|
@ -524,7 +523,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun canShowSplitAtBottom(): Boolean {
|
private fun canShowSplitAtBottom(): Boolean {
|
||||||
return if (preferences.readerBottomButtons().isNotSet()) {
|
return if (!preferences.readerBottomButtons().isSet()) {
|
||||||
isTablet()
|
isTablet()
|
||||||
} else {
|
} else {
|
||||||
ReaderBottomButton.ShiftDoublePage.isIn(preferences.readerBottomButtons().get())
|
ReaderBottomButton.ShiftDoublePage.isIn(preferences.readerBottomButtons().get())
|
||||||
|
@ -842,7 +841,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
||||||
|
|
||||||
listOf(preferences.cropBorders(), preferences.cropBordersWebtoon())
|
listOf(preferences.cropBorders(), preferences.cropBordersWebtoon())
|
||||||
.forEach { pref ->
|
.forEach { pref ->
|
||||||
pref.asFlow()
|
pref.changes()
|
||||||
.onEach { updateCropBordersShortcut() }
|
.onEach { updateCropBordersShortcut() }
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
@ -1899,7 +1898,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
||||||
* Initializes the reader subscriptions.
|
* Initializes the reader subscriptions.
|
||||||
*/
|
*/
|
||||||
init {
|
init {
|
||||||
preferences.defaultOrientationType().asFlow()
|
preferences.defaultOrientationType().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
delay(250)
|
delay(250)
|
||||||
|
@ -1907,38 +1906,38 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
preferences.showPageNumber().asImmediateFlowIn(scope) { setPageNumberVisibility(it) }
|
preferences.showPageNumber().changesIn(scope) { setPageNumberVisibility(it) }
|
||||||
|
|
||||||
preferences.landscapeCutoutBehavior().asFlow()
|
preferences.landscapeCutoutBehavior().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach { setCutoutMode() }
|
.onEach { setCutoutMode() }
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
preferences.trueColor().asImmediateFlowIn(scope) { setTrueColor(it) }
|
preferences.trueColor().changesIn(scope) { setTrueColor(it) }
|
||||||
|
|
||||||
preferences.fullscreen().asImmediateFlowIn(scope) { setFullscreen(it) }
|
preferences.fullscreen().changesIn(scope) { setFullscreen(it) }
|
||||||
|
|
||||||
preferences.keepScreenOn().asImmediateFlowIn(scope) { setKeepScreenOn(it) }
|
preferences.keepScreenOn().changesIn(scope) { setKeepScreenOn(it) }
|
||||||
|
|
||||||
preferences.customBrightness().asImmediateFlowIn(scope) { setCustomBrightness(it) }
|
preferences.customBrightness().changesIn(scope) { setCustomBrightness(it) }
|
||||||
|
|
||||||
preferences.colorFilter().asImmediateFlowIn(scope) { setColorFilter(it) }
|
preferences.colorFilter().changesIn(scope) { setColorFilter(it) }
|
||||||
|
|
||||||
preferences.colorFilterMode().asImmediateFlowIn(scope) {
|
preferences.colorFilterMode().changesIn(scope) {
|
||||||
setColorFilter(preferences.colorFilter().get())
|
setColorFilter(preferences.colorFilter().get())
|
||||||
}
|
}
|
||||||
|
|
||||||
merge(preferences.grayscale().asFlow(), preferences.invertedColors().asFlow())
|
merge(preferences.grayscale().changes(), preferences.invertedColors().changes())
|
||||||
.onEach { setLayerPaint(preferences.grayscale().get(), preferences.invertedColors().get()) }
|
.onEach { setLayerPaint(preferences.grayscale().get(), preferences.invertedColors().get()) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.alwaysShowChapterTransition().asImmediateFlowIn(scope) {
|
preferences.alwaysShowChapterTransition().changesIn(scope) {
|
||||||
showNewChapter = it
|
showNewChapter = it
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.pageLayout().asImmediateFlowIn(scope) { setBottomNavButtons(it) }
|
preferences.pageLayout().changesIn(scope) { setBottomNavButtons(it) }
|
||||||
|
|
||||||
preferences.automaticSplitsPage().asFlow()
|
preferences.automaticSplitsPage().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
val isPaused = !this@ReaderActivity.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)
|
val isPaused = !this@ReaderActivity.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)
|
||||||
|
@ -1950,7 +1949,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
preferences.readerBottomButtons().asImmediateFlowIn(scope) { updateBottomShortcuts() }
|
preferences.readerBottomButtons().changesIn(scope) { updateBottomShortcuts() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1996,7 +1995,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
||||||
*/
|
*/
|
||||||
private fun setCustomBrightness(enabled: Boolean) {
|
private fun setCustomBrightness(enabled: Boolean) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
preferences.customBrightnessValue().asFlow()
|
preferences.customBrightnessValue().changes()
|
||||||
.sample(100)
|
.sample(100)
|
||||||
.onEach { setCustomBrightnessValue(it) }
|
.onEach { setCustomBrightnessValue(it) }
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
@ -2010,7 +2009,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
||||||
*/
|
*/
|
||||||
private fun setColorFilter(enabled: Boolean) {
|
private fun setColorFilter(enabled: Boolean) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
preferences.colorFilterValue().asFlow()
|
preferences.colorFilterValue().changes()
|
||||||
.sample(100)
|
.sample(100)
|
||||||
.onEach { setColorFilterValue(it) }
|
.onEach { setColorFilterValue(it) }
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
|
@ -26,15 +26,15 @@ class ReaderFilterView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||||
override fun inflateBinding() = ReaderColorFilterBinding.bind(this)
|
override fun inflateBinding() = ReaderColorFilterBinding.bind(this)
|
||||||
override fun initGeneralPreferences() {
|
override fun initGeneralPreferences() {
|
||||||
activity = context as? ReaderActivity ?: return
|
activity = context as? ReaderActivity ?: return
|
||||||
preferences.colorFilter().asFlow()
|
preferences.colorFilter().changes()
|
||||||
.onEach { setColorFilter(it) }
|
.onEach { setColorFilter(it) }
|
||||||
.launchIn(activity.scope)
|
.launchIn(activity.scope)
|
||||||
|
|
||||||
preferences.colorFilterMode().asFlow()
|
preferences.colorFilterMode().changes()
|
||||||
.onEach { setColorFilter(preferences.colorFilter().get()) }
|
.onEach { setColorFilter(preferences.colorFilter().get()) }
|
||||||
.launchIn(activity.scope)
|
.launchIn(activity.scope)
|
||||||
|
|
||||||
preferences.customBrightness().asFlow()
|
preferences.customBrightness().changes()
|
||||||
.onEach { setCustomBrightness(it) }
|
.onEach { setCustomBrightness(it) }
|
||||||
.launchIn(activity.scope)
|
.launchIn(activity.scope)
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class ReaderFilterView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||||
*/
|
*/
|
||||||
private fun setCustomBrightness(enabled: Boolean) {
|
private fun setCustomBrightness(enabled: Boolean) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
preferences.customBrightnessValue().asFlow()
|
preferences.customBrightnessValue().changes()
|
||||||
.sample(100)
|
.sample(100)
|
||||||
.onEach { setCustomBrightnessValue(it) }
|
.onEach { setCustomBrightnessValue(it) }
|
||||||
.launchIn(activity.scope)
|
.launchIn(activity.scope)
|
||||||
|
@ -189,7 +189,7 @@ class ReaderFilterView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||||
*/
|
*/
|
||||||
private fun setColorFilter(enabled: Boolean) {
|
private fun setColorFilter(enabled: Boolean) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
preferences.colorFilterValue().asFlow()
|
preferences.colorFilterValue().changes()
|
||||||
.sample(100)
|
.sample(100)
|
||||||
.onEach { setColorFilterValue(it) }
|
.onEach { setColorFilterValue(it) }
|
||||||
.launchIn(activity.scope)
|
.launchIn(activity.scope)
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package eu.kanade.tachiyomi.ui.reader.viewer
|
package eu.kanade.tachiyomi.ui.reader.viewer
|
||||||
|
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import kotlinx.coroutines.flow.onEach
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common configuration for all viewers.
|
* Common configuration for all viewers.
|
||||||
|
@ -52,12 +51,10 @@ abstract class ViewerConfig(preferences: PreferencesHelper, protected val scope:
|
||||||
valueAssignment: (T) -> Unit,
|
valueAssignment: (T) -> Unit,
|
||||||
onChanged: (T) -> Unit = {},
|
onChanged: (T) -> Unit = {},
|
||||||
) {
|
) {
|
||||||
asFlow()
|
changesIn(scope) {
|
||||||
.onEach {
|
valueAssignment(it)
|
||||||
valueAssignment(it)
|
onChanged(it)
|
||||||
onChanged(it)
|
}
|
||||||
}
|
|
||||||
.launchIn(scope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun defaultNavigation(): ViewerNavigation
|
protected abstract fun defaultNavigation(): ViewerNavigation
|
||||||
|
|
|
@ -92,7 +92,7 @@ class PagerConfig(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
preferences.pagerNavInverted().asFlow()
|
preferences.pagerNavInverted().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
navigationModeInvertedListener?.invoke()
|
navigationModeInvertedListener?.invoke()
|
||||||
|
@ -121,7 +121,7 @@ class PagerConfig(
|
||||||
.register({ invertDoublePages = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ invertDoublePages = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.pageLayout()
|
preferences.pageLayout()
|
||||||
.asFlow()
|
.changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
autoDoublePages = it == PageLayout.AUTOMATIC.value
|
autoDoublePages = it == PageLayout.AUTOMATIC.value
|
||||||
|
|
|
@ -57,7 +57,7 @@ class WebtoonConfig(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
preferences.webtoonNavInverted().asFlow()
|
preferences.webtoonNavInverted().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
navigationModeInvertedListener?.invoke()
|
navigationModeInvertedListener?.invoke()
|
||||||
|
|
|
@ -2,12 +2,12 @@ package eu.kanade.tachiyomi.ui.recents
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.ChapterHistory
|
import eu.kanade.tachiyomi.data.database.models.ChapterHistory
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterAdapter
|
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterAdapter
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.drop
|
import kotlinx.coroutines.flow.drop
|
||||||
|
@ -63,19 +63,19 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
||||||
preferences.uniformGrid().register { uniformCovers = it }
|
preferences.uniformGrid().register { uniformCovers = it }
|
||||||
preferences.collapseGroupedUpdates().register { collapseGroupedUpdates = it }
|
preferences.collapseGroupedUpdates().register { collapseGroupedUpdates = it }
|
||||||
preferences.collapseGroupedHistory().register { collapseGroupedHistory = it }
|
preferences.collapseGroupedHistory().register { collapseGroupedHistory = it }
|
||||||
preferences.sortFetchedTime().asImmediateFlowIn(delegate.scope()) { sortByFetched = it }
|
preferences.sortFetchedTime().changesIn(delegate.scope()) { sortByFetched = it }
|
||||||
preferences.outlineOnCovers().register(false) {
|
preferences.outlineOnCovers().register(false) {
|
||||||
showOutline = it
|
showOutline = it
|
||||||
(0 until itemCount).forEach { i ->
|
(0 until itemCount).forEach { i ->
|
||||||
(recyclerView.findViewHolderForAdapterPosition(i) as? RecentMangaHolder)?.updateCards()
|
(recyclerView.findViewHolderForAdapterPosition(i) as? RecentMangaHolder)?.updateCards()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preferences.libraryUpdateLastTimestamp().asFlow().onEach {
|
preferences.libraryUpdateLastTimestamp().changesIn(delegate.scope()) {
|
||||||
lastUpdatedTime = it
|
lastUpdatedTime = it
|
||||||
if (viewType.isUpdates) {
|
if (viewType.isUpdates) {
|
||||||
notifyItemChanged(0)
|
notifyItemChanged(0)
|
||||||
}
|
}
|
||||||
}.launchIn(delegate.scope())
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getItemByChapterId(id: Long): RecentMangaItem? {
|
fun getItemByChapterId(id: Long): RecentMangaItem? {
|
||||||
|
@ -86,7 +86,7 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <T> Preference<T>.register(notify: Boolean = true, onChanged: (T) -> Unit) {
|
private fun <T> Preference<T>.register(notify: Boolean = true, onChanged: (T) -> Unit) {
|
||||||
asFlow()
|
changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
onChanged(it)
|
onChanged(it)
|
||||||
|
|
|
@ -101,7 +101,7 @@ class RecentsPresenter(
|
||||||
preferences.showReadInAllRecents(),
|
preferences.showReadInAllRecents(),
|
||||||
preferences.sortFetchedTime(),
|
preferences.sortFetchedTime(),
|
||||||
).forEach {
|
).forEach {
|
||||||
it.asFlow()
|
it.changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
resetOffsets()
|
resetOffsets()
|
||||||
|
|
|
@ -28,7 +28,6 @@ import eu.kanade.tachiyomi.widget.preference.IntListMatPreference
|
||||||
import eu.kanade.tachiyomi.widget.preference.ListMatPreference
|
import eu.kanade.tachiyomi.widget.preference.ListMatPreference
|
||||||
import eu.kanade.tachiyomi.widget.preference.MultiListMatPreference
|
import eu.kanade.tachiyomi.widget.preference.MultiListMatPreference
|
||||||
import eu.kanade.tachiyomi.widget.preference.TriStateListPreference
|
import eu.kanade.tachiyomi.widget.preference.TriStateListPreference
|
||||||
import com.fredporciuncula.flow.preferences.Preference as FlowPreference
|
|
||||||
|
|
||||||
@DslMarker
|
@DslMarker
|
||||||
@Target(AnnotationTarget.TYPE)
|
@Target(AnnotationTarget.TYPE)
|
||||||
|
@ -156,24 +155,24 @@ inline fun Preference.onChange(crossinline block: (Any?) -> Boolean) {
|
||||||
setOnPreferenceChangeListener { _, newValue -> block(newValue) }
|
setOnPreferenceChangeListener { _, newValue -> block(newValue) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Preference.bindTo(preference: FlowPreference<T>) {
|
fun <T> Preference.bindTo(preference: eu.kanade.tachiyomi.core.preference.Preference<T>) {
|
||||||
key = preference.key
|
key = preference.key()
|
||||||
defaultValue = preference.defaultValue
|
defaultValue = preference.defaultValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> ListPreference.bindTo(preference: FlowPreference<T>) {
|
fun <T> ListPreference.bindTo(preference: eu.kanade.tachiyomi.core.preference.Preference<T>) {
|
||||||
key = preference.key
|
key = preference.key()
|
||||||
defaultValue = preference.defaultValue.toString()
|
defaultValue = preference.defaultValue().toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> EditTextPreference.bindTo(preference: FlowPreference<T>) {
|
fun <T> EditTextPreference.bindTo(preference: eu.kanade.tachiyomi.core.preference.Preference<T>) {
|
||||||
key = preference.key
|
key = preference.key()
|
||||||
defaultValue = preference.defaultValue.toString()
|
defaultValue = preference.defaultValue().toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> ListMatPreference.bindTo(preference: FlowPreference<T>) {
|
fun <T> ListMatPreference.bindTo(preference: eu.kanade.tachiyomi.core.preference.Preference<T>) {
|
||||||
key = preference.key
|
key = preference.key()
|
||||||
val defValue = preference.defaultValue
|
val defValue = preference.defaultValue()
|
||||||
defaultValue = if (defValue is Set<*>) defValue else defValue.toString()
|
defaultValue = if (defValue is Set<*>) defValue else defValue.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,20 +181,20 @@ fun <T> ListMatPreference.bindTo(preference: FlowPreference<T>) {
|
||||||
ReplaceWith("bindTo(preference, excludePreference = )"),
|
ReplaceWith("bindTo(preference, excludePreference = )"),
|
||||||
DeprecationLevel.ERROR,
|
DeprecationLevel.ERROR,
|
||||||
)
|
)
|
||||||
fun <T> TriStateListPreference.bindTo(preference: FlowPreference<T>) { key = preference.key }
|
fun <T> TriStateListPreference.bindTo(preference: eu.kanade.tachiyomi.core.preference.Preference<T>) { key = preference.key() }
|
||||||
|
|
||||||
fun TriStateListPreference.bindTo(
|
fun TriStateListPreference.bindTo(
|
||||||
includePreference: FlowPreference<Set<String>>,
|
includePreference: eu.kanade.tachiyomi.core.preference.Preference<Set<String>>,
|
||||||
excludePreference: FlowPreference<Set<String>>,
|
excludePreference: eu.kanade.tachiyomi.core.preference.Preference<Set<String>>,
|
||||||
) {
|
) {
|
||||||
key = includePreference.key
|
key = includePreference.key()
|
||||||
excludeKey = excludePreference.key
|
excludeKey = excludePreference.key()
|
||||||
defaultValue = includePreference.defaultValue to excludePreference.defaultValue
|
defaultValue = includePreference.defaultValue() to excludePreference.defaultValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> IntListMatPreference.bindTo(preference: FlowPreference<T>) {
|
fun <T> IntListMatPreference.bindTo(preference: eu.kanade.tachiyomi.core.preference.Preference<T>) {
|
||||||
key = preference.key
|
key = preference.key()
|
||||||
defaultValue = preference.defaultValue
|
defaultValue = preference.defaultValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SwitchPreferenceCompat.requireAuthentication(
|
fun SwitchPreferenceCompat.requireAuthentication(
|
||||||
|
|
|
@ -26,7 +26,7 @@ import eu.kanade.tachiyomi.data.download.DownloadProvider
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob.Target
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob.Target
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.extension.ShizukuInstaller
|
import eu.kanade.tachiyomi.extension.ShizukuInstaller
|
||||||
import eu.kanade.tachiyomi.extension.util.ExtensionInstaller
|
import eu.kanade.tachiyomi.extension.util.ExtensionInstaller
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
|
@ -364,7 +364,7 @@ class SettingsAdvancedController : SettingsController() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infoPreference(R.string.ext_installer_summary).apply {
|
infoPreference(R.string.ext_installer_summary).apply {
|
||||||
preferences.extensionInstaller().asImmediateFlowIn(viewScope) {
|
preferences.extensionInstaller().changesIn(viewScope) {
|
||||||
isVisible =
|
isVisible =
|
||||||
it != ExtensionInstaller.PACKAGE_INSTALLER && Build.VERSION.SDK_INT < Build.VERSION_CODES.S
|
it != ExtensionInstaller.PACKAGE_INSTALLER && Build.VERSION.SDK_INT < Build.VERSION_CODES.S
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,7 @@ import androidx.core.view.doOnNextLayout
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
|
||||||
import eu.kanade.tachiyomi.util.system.SideNavMode
|
import eu.kanade.tachiyomi.util.system.SideNavMode
|
||||||
import eu.kanade.tachiyomi.util.system.appDelegateNightMode
|
import eu.kanade.tachiyomi.util.system.appDelegateNightMode
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
|
@ -18,6 +17,7 @@ import eu.kanade.tachiyomi.util.system.isInNightMode
|
||||||
import eu.kanade.tachiyomi.util.view.activityBinding
|
import eu.kanade.tachiyomi.util.view.activityBinding
|
||||||
import eu.kanade.tachiyomi.util.view.moveRecyclerViewUp
|
import eu.kanade.tachiyomi.util.view.moveRecyclerViewUp
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class SettingsAppearanceController : SettingsController() {
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
preferences.nightMode().asImmediateFlow { mode ->
|
preferences.nightMode().changes().onEach { mode ->
|
||||||
isChecked = mode == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
isChecked = mode == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
}.launchIn(viewScope)
|
}.launchIn(viewScope)
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ class SettingsAppearanceController : SettingsController() {
|
||||||
titleRes = R.string.pure_black_dark_mode
|
titleRes = R.string.pure_black_dark_mode
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
|
|
||||||
preferences.nightMode().asImmediateFlowIn(viewScope) { mode ->
|
preferences.nightMode().changesIn(viewScope) { mode ->
|
||||||
isVisible = mode != AppCompatDelegate.MODE_NIGHT_NO
|
isVisible = mode != AppCompatDelegate.MODE_NIGHT_NO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,10 +122,11 @@ class SettingsBackupController : SettingsController() {
|
||||||
|
|
||||||
visibleIf(preferences.backupInterval()) { it > 0 }
|
visibleIf(preferences.backupInterval()) { it > 0 }
|
||||||
|
|
||||||
preferences.backupsDirectory().asFlow()
|
preferences.backupsDirectory().changes()
|
||||||
.onEach { path ->
|
.onEach { path ->
|
||||||
val dir = UniFile.fromUri(context, path.toUri())
|
val dir = UniFile.fromUri(context, path.toUri())
|
||||||
summary = dir.filePath + "/automatic"
|
val filePath = dir.filePath
|
||||||
|
summary = if (filePath != null) "$filePath/automatic" else "Invalid directory: $dir"
|
||||||
}
|
}
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.data.updater.AppDownloadInstallJob
|
import eu.kanade.tachiyomi.data.updater.AppDownloadInstallJob
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||||
|
@ -95,7 +95,7 @@ class SettingsBrowseController : SettingsController() {
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
preferences.automaticExtUpdates().asImmediateFlowIn(viewScope) { value ->
|
preferences.automaticExtUpdates().changesIn(viewScope) { value ->
|
||||||
arrayOf(intPref, infoPref, switchPref).forEach { it?.isVisible = value }
|
arrayOf(intPref, infoPref, switchPref).forEach { it?.isVisible = value }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||||
import eu.kanade.tachiyomi.ui.main.FloatingSearchInterface
|
import eu.kanade.tachiyomi.ui.main.FloatingSearchInterface
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
|
@ -136,7 +136,7 @@ abstract class SettingsController : PreferenceController(), BackHandlerControlle
|
||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <T> Preference.visibleIf(preference: com.fredporciuncula.flow.preferences.Preference<T>, crossinline block: (T) -> Boolean) {
|
inline fun <T> Preference.visibleIf(preference: eu.kanade.tachiyomi.core.preference.Preference<T>, crossinline block: (T) -> Boolean) {
|
||||||
preference.asImmediateFlowIn(viewScope) { isVisible = block(it) }
|
preference.changesIn(viewScope) { isVisible = block(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.util.system.withOriginalWidth
|
import eu.kanade.tachiyomi.util.system.withOriginalWidth
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
@ -35,7 +35,7 @@ class SettingsDownloadController : SettingsController() {
|
||||||
DownloadDirectoriesDialog(this@SettingsDownloadController).show()
|
DownloadDirectoriesDialog(this@SettingsDownloadController).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.downloadsDirectory().asImmediateFlowIn(viewScope) { path ->
|
preferences.downloadsDirectory().changesIn(viewScope) { path ->
|
||||||
val dir = UniFile.fromUri(context, path.toUri())
|
val dir = UniFile.fromUri(context, path.toUri())
|
||||||
summary = dir.filePath ?: path
|
summary = dir.filePath ?: path
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ class SettingsDownloadController : SettingsController() {
|
||||||
entries = categories.map { it.name }
|
entries = categories.map { it.name }
|
||||||
entryValues = categories.map { it.id.toString() }
|
entryValues = categories.map { it.id.toString() }
|
||||||
noSelectionRes = R.string.none
|
noSelectionRes = R.string.none
|
||||||
preferences.removeAfterReadSlots().asImmediateFlowIn(viewScope) { isVisible = it != -1 }
|
preferences.removeAfterReadSlots().changesIn(viewScope) { isVisible = it != -1 }
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.removeBookmarkedChapters())
|
bindTo(preferences.removeBookmarkedChapters())
|
||||||
|
@ -110,7 +110,7 @@ class SettingsDownloadController : SettingsController() {
|
||||||
entryValues = categories.map { it.id.toString() }
|
entryValues = categories.map { it.id.toString() }
|
||||||
allSelectionRes = R.string.all
|
allSelectionRes = R.string.all
|
||||||
|
|
||||||
preferences.downloadNewChapters().asImmediateFlowIn(viewScope) { isVisible = it }
|
preferences.downloadNewChapters().changesIn(viewScope) { isVisible = it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,7 @@ import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.preference.DEVICE_BATTERY_NOT_LOW
|
import eu.kanade.tachiyomi.data.preference.*
|
||||||
import eu.kanade.tachiyomi.data.preference.DEVICE_CHARGING
|
|
||||||
import eu.kanade.tachiyomi.data.preference.DEVICE_ONLY_ON_WIFI
|
|
||||||
import eu.kanade.tachiyomi.data.preference.DelayedLibrarySuggestionsJob
|
|
||||||
import eu.kanade.tachiyomi.data.preference.MANGA_HAS_UNREAD
|
|
||||||
import eu.kanade.tachiyomi.data.preference.MANGA_NON_COMPLETED
|
|
||||||
import eu.kanade.tachiyomi.data.preference.MANGA_NON_READ
|
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
|
||||||
import eu.kanade.tachiyomi.ui.category.CategoryController
|
import eu.kanade.tachiyomi.ui.category.CategoryController
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
||||||
import eu.kanade.tachiyomi.ui.library.display.TabbedLibraryDisplaySheet
|
import eu.kanade.tachiyomi.ui.library.display.TabbedLibraryDisplaySheet
|
||||||
|
@ -145,7 +138,7 @@ class SettingsLibraryController : SettingsController() {
|
||||||
preSummaryRes = R.string.restrictions_
|
preSummaryRes = R.string.restrictions_
|
||||||
noSelectionRes = R.string.none
|
noSelectionRes = R.string.none
|
||||||
|
|
||||||
preferences.libraryUpdateInterval().asImmediateFlowIn(viewScope) {
|
preferences.libraryUpdateInterval().changesIn(viewScope) {
|
||||||
isVisible = it > 0
|
isVisible = it > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,7 @@ import androidx.core.content.getSystemService
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBackgroundColor
|
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBackgroundColor
|
||||||
|
@ -277,19 +276,19 @@ class SettingsReaderController : SettingsController() {
|
||||||
defaultValue = PageLayout.AUTOMATIC.value
|
defaultValue = PageLayout.AUTOMATIC.value
|
||||||
}
|
}
|
||||||
infoPreference(R.string.automatic_can_still_switch).apply {
|
infoPreference(R.string.automatic_can_still_switch).apply {
|
||||||
preferences.pageLayout().asImmediateFlowIn(viewScope) { isVisible = it == PageLayout.AUTOMATIC.value }
|
preferences.pageLayout().changesIn(viewScope) { isVisible = it == PageLayout.AUTOMATIC.value }
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.automaticSplitsPage
|
key = Keys.automaticSplitsPage
|
||||||
titleRes = R.string.split_double_pages_portrait
|
titleRes = R.string.split_double_pages_portrait
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
preferences.pageLayout().asImmediateFlowIn(viewScope) { isVisible = it == PageLayout.AUTOMATIC.value }
|
preferences.pageLayout().changesIn(viewScope) { isVisible = it == PageLayout.AUTOMATIC.value }
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.invertDoublePages
|
key = Keys.invertDoublePages
|
||||||
titleRes = R.string.invert_double_pages
|
titleRes = R.string.invert_double_pages
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
preferences.pageLayout().asImmediateFlowIn(viewScope) { isVisible = it != PageLayout.SINGLE_PAGE.value }
|
preferences.pageLayout().changesIn(viewScope) { isVisible = it != PageLayout.SINGLE_PAGE.value }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preferenceCategory {
|
preferenceCategory {
|
||||||
|
@ -383,7 +382,7 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.invert_volume_keys
|
titleRes = R.string.invert_volume_keys
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
|
|
||||||
preferences.readWithVolumeKeys().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
preferences.readWithVolumeKeys().changesIn(viewScope) { isVisible = it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupported
|
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupported
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class SettingsSecurityController : SettingsController() {
|
||||||
entryValues = values
|
entryValues = values
|
||||||
defaultValue = 0
|
defaultValue = 0
|
||||||
|
|
||||||
preferences.useBiometrics().asImmediateFlowIn(viewScope) { isVisible = it }
|
preferences.useBiometrics().changesIn(viewScope) { isVisible = it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ import androidx.preference.CheckBoxPreference
|
||||||
import androidx.preference.PreferenceGroup
|
import androidx.preference.PreferenceGroup
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.minusAssign
|
import eu.kanade.tachiyomi.core.preference.minusAssign
|
||||||
import eu.kanade.tachiyomi.data.preference.plusAssign
|
import eu.kanade.tachiyomi.core.preference.plusAssign
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.icon
|
import eu.kanade.tachiyomi.source.icon
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
|
|
|
@ -4,7 +4,7 @@ import android.app.Activity
|
||||||
import androidx.preference.PreferenceGroup
|
import androidx.preference.PreferenceGroup
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.data.track.TrackPreferences
|
import eu.kanade.tachiyomi.data.track.TrackPreferences
|
||||||
|
@ -62,7 +62,7 @@ class SettingsTrackingController :
|
||||||
title = context.getString(R.string.update_tracking_scoring_type, context.getString(R.string.anilist))
|
title = context.getString(R.string.update_tracking_scoring_type, context.getString(R.string.anilist))
|
||||||
|
|
||||||
preferences.getStringPref(trackManager.aniList.getUsername())
|
preferences.getStringPref(trackManager.aniList.getUsername())
|
||||||
.asImmediateFlowIn(viewScope) {
|
.changesIn(viewScope) {
|
||||||
isVisible = it.isNotEmpty()
|
isVisible = it.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ class BrowseController :
|
||||||
requestFilePermissionsSafe(301, preferences)
|
requestFilePermissionsSafe(301, preferences)
|
||||||
binding.bottomSheet.root.onCreate(this)
|
binding.bottomSheet.root.onCreate(this)
|
||||||
|
|
||||||
preferences.extensionInstaller().asFlow()
|
preferences.extensionInstaller().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
binding.bottomSheet.root.setCanInstallPrivately(it == ExtensionInstaller.PRIVATE)
|
binding.bottomSheet.root.setCanInstallPrivately(it == ExtensionInstaller.PRIVATE)
|
||||||
|
|
|
@ -96,7 +96,7 @@ class SourcePresenter(
|
||||||
|
|
||||||
private fun loadLastUsedSource() {
|
private fun loadLastUsedSource() {
|
||||||
lastUsedJob?.cancel()
|
lastUsedJob?.cancel()
|
||||||
lastUsedJob = preferences.lastUsedCatalogueSource().asFlow()
|
lastUsedJob = preferences.lastUsedCatalogueSource().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
lastUsedItem = getLastUsedSource(it)
|
lastUsedItem = getLastUsedSource(it)
|
||||||
|
|
|
@ -8,11 +8,11 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.databinding.MangaGridItemBinding
|
import eu.kanade.tachiyomi.databinding.MangaGridItemBinding
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||||
|
|
|
@ -27,7 +27,7 @@ import androidx.core.view.updateLayoutParams
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import eu.kanade.tachiyomi.databinding.WebviewActivityBinding
|
import eu.kanade.tachiyomi.databinding.WebviewActivityBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
|
@ -151,7 +151,7 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.incognitoMode()
|
preferences.incognitoMode()
|
||||||
.asImmediateFlowIn(lifecycleScope) {
|
.changesIn(lifecycleScope) {
|
||||||
SecureActivityDelegate.setSecure(this)
|
SecureActivityDelegate.setSecure(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import android.widget.CompoundButton
|
||||||
import android.widget.RadioButton
|
import android.widget.RadioButton
|
||||||
import android.widget.RadioGroup
|
import android.widget.RadioGroup
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||||
|
|
||||||
inline fun <reified T> SharedPreferences.getItem(key: String, default: T): T {
|
inline fun <reified T> SharedPreferences.getItem(key: String, default: T): T {
|
||||||
|
|
|
@ -820,7 +820,7 @@ fun Controller.requestFilePermissionsSafe(
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.show()
|
.show()
|
||||||
} else if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.R || Environment.isExternalStorageManager()) && preferences.backupInterval().isNotSet()) {
|
} else if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.R || Environment.isExternalStorageManager()) && !preferences.backupInterval().isSet()) {
|
||||||
preferences.backupInterval().set(24)
|
preferences.backupInterval().set(24)
|
||||||
BackupCreatorJob.setupTask(activity, 24)
|
BackupCreatorJob.setupTask(activity, 24)
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ class AutofitRecyclerView @JvmOverloads constructor(context: Context, attrs: Att
|
||||||
|
|
||||||
fun setGridSize(preferences: PreferencesHelper) {
|
fun setGridSize(preferences: PreferencesHelper) {
|
||||||
// Migrate to float for grid size
|
// Migrate to float for grid size
|
||||||
if (preferences.gridSize().isNotSet()) {
|
if (!preferences.gridSize().isSet()) {
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val oldGridSize = prefs.getInt("grid_size", -1)
|
val oldGridSize = prefs.getInt("grid_size", -1)
|
||||||
if (oldGridSize != -1) {
|
if (oldGridSize != -1) {
|
||||||
|
|
|
@ -16,8 +16,8 @@ import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import androidx.core.view.forEach
|
import androidx.core.view.forEach
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.databinding.MaterialSpinnerViewBinding
|
import eu.kanade.tachiyomi.databinding.MaterialSpinnerViewBinding
|
||||||
import eu.kanade.tachiyomi.util.lang.tintText
|
import eu.kanade.tachiyomi.util.lang.tintText
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
|
|
|
@ -7,12 +7,11 @@ import androidx.core.view.inputmethod.EditorInfoCompat
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.data.preference.changesIn
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
|
@ -49,13 +48,13 @@ class TachiyomiTextInputEditText @JvmOverloads constructor(
|
||||||
*/
|
*/
|
||||||
fun EditText.setIncognito(viewScope: CoroutineScope) {
|
fun EditText.setIncognito(viewScope: CoroutineScope) {
|
||||||
try {
|
try {
|
||||||
Injekt.get<PreferencesHelper>().incognitoMode().asImmediateFlow {
|
Injekt.get<PreferencesHelper>().incognitoMode().changesIn(viewScope) {
|
||||||
imeOptions = if (it) {
|
imeOptions = if (it) {
|
||||||
imeOptions or EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING
|
imeOptions or EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING
|
||||||
} else {
|
} else {
|
||||||
imeOptions and EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING.inv()
|
imeOptions and EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING.inv()
|
||||||
}
|
}
|
||||||
}.launchIn(viewScope)
|
}
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[versions]
|
[versions]
|
||||||
activity = "1.8.0"
|
activity = "1.8.2"
|
||||||
lifecycle = "2.6.2"
|
lifecycle = "2.6.2"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
@ -20,7 +20,7 @@ lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.r
|
||||||
lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
|
lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
|
||||||
multidex = { module = "androidx.multidex:multidex", version = "2.0.1" }
|
multidex = { module = "androidx.multidex:multidex", version = "2.0.1" }
|
||||||
palette = { module = "androidx.palette:palette", version = "1.0.0" }
|
palette = { module = "androidx.palette:palette", version = "1.0.0" }
|
||||||
preference = { module = "androidx.preference:preference", version = "1.2.1" }
|
preference = { module = "androidx.preference:preference-ktx", version = "1.2.1" }
|
||||||
recyclerview = { module = "androidx.recyclerview:recyclerview", version = "1.3.1" }
|
recyclerview = { module = "androidx.recyclerview:recyclerview", version = "1.3.1" }
|
||||||
sqlite = { module = "androidx.sqlite:sqlite", version = "2.3.1" }
|
sqlite = { module = "androidx.sqlite:sqlite", version = "2.3.1" }
|
||||||
swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version = "1.1.0" }
|
swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version = "1.1.0" }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[versions]
|
[versions]
|
||||||
compose = "1.5.1"
|
compose = "1.5.3"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
animation = { module = "androidx.compose.animation:animation", version.ref = "compose" }
|
animation = { module = "androidx.compose.animation:animation", version.ref = "compose" }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[versions]
|
[versions]
|
||||||
kotlin = "1.9.20"
|
kotlin = "1.9.10"
|
||||||
coroutines = "1.7.3"
|
coroutines = "1.7.3"
|
||||||
serialization = "1.6.0"
|
serialization = "1.6.0"
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ firebase-crashlytics-gradle = { module = "com.google.firebase:firebase-crashlyti
|
||||||
flexbox = { module = "com.google.android.flexbox:flexbox", version = "3.0.0" }
|
flexbox = { module = "com.google.android.flexbox:flexbox", version = "3.0.0" }
|
||||||
flexible-adapter-ui = { module = "com.github.arkon.FlexibleAdapter:flexible-adapter-ui", version.ref = "flexible-adapter" }
|
flexible-adapter-ui = { module = "com.github.arkon.FlexibleAdapter:flexible-adapter-ui", version.ref = "flexible-adapter" }
|
||||||
flexible-adapter = { module = "com.github.arkon.FlexibleAdapter:flexible-adapter", version.ref = "flexible-adapter" }
|
flexible-adapter = { module = "com.github.arkon.FlexibleAdapter:flexible-adapter", version.ref = "flexible-adapter" }
|
||||||
flow-preferences = { module = "com.fredporciuncula:flow-preferences", version = "1.6.0" }
|
|
||||||
google-services = { module = "com.google.gms:google-services", version = "4.3.15" }
|
google-services = { module = "com.google.gms:google-services", version = "4.3.15" }
|
||||||
gradle = { module = "com.android.tools.build:gradle", version = "8.1.4" }
|
gradle = { module = "com.android.tools.build:gradle", version = "8.1.4" }
|
||||||
guava = { module = "com.google.guava:guava", version = "31.1-android" }
|
guava = { module = "com.google.guava:guava", version = "31.1-android" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue