Replace preference getter functions with properties (#3091)
This commit is contained in:
@@ -107,7 +107,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||
val scope = ProcessLifecycleOwner.get().lifecycleScope
|
||||
|
||||
// Show notification to disable Incognito Mode when it's enabled
|
||||
basePreferences.incognitoMode().changes()
|
||||
basePreferences.incognitoMode.changes()
|
||||
.onEach { enabled ->
|
||||
if (enabled) {
|
||||
disableIncognitoReceiver.register()
|
||||
@@ -135,32 +135,32 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||
}
|
||||
.launchIn(scope)
|
||||
|
||||
privacyPreferences.analytics()
|
||||
privacyPreferences.analytics
|
||||
.changes()
|
||||
.onEach(TelemetryConfig::setAnalyticsEnabled)
|
||||
.launchIn(scope)
|
||||
|
||||
privacyPreferences.crashlytics()
|
||||
privacyPreferences.crashlytics
|
||||
.changes()
|
||||
.onEach(TelemetryConfig::setCrashlyticsEnabled)
|
||||
.launchIn(scope)
|
||||
|
||||
basePreferences.hardwareBitmapThreshold().let { preference ->
|
||||
basePreferences.hardwareBitmapThreshold.let { preference ->
|
||||
if (!preference.isSet()) preference.set(GLUtil.DEVICE_TEXTURE_LIMIT)
|
||||
}
|
||||
|
||||
basePreferences.hardwareBitmapThreshold().changes()
|
||||
basePreferences.hardwareBitmapThreshold.changes()
|
||||
.onEach { ImageUtil.hardwareBitmapThreshold = it }
|
||||
.launchIn(scope)
|
||||
|
||||
setAppCompatDelegateThemeMode(Injekt.get<UiPreferences>().themeMode().get())
|
||||
setAppCompatDelegateThemeMode(Injekt.get<UiPreferences>().themeMode.get())
|
||||
|
||||
// Updates widget update
|
||||
WidgetManager(Injekt.get(), Injekt.get()).apply { init(scope) }
|
||||
|
||||
if (!LogcatLogger.isInstalled) {
|
||||
val minLogPriority = when {
|
||||
networkPreferences.verboseLogging().get() -> LogPriority.VERBOSE
|
||||
networkPreferences.verboseLogging.get() -> LogPriority.VERBOSE
|
||||
BuildConfig.DEBUG -> LogPriority.DEBUG
|
||||
else -> LogPriority.INFO
|
||||
}
|
||||
@@ -211,7 +211,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||
|
||||
crossfade((300 * this@App.animatorDurationScale).toInt())
|
||||
allowRgb565(DeviceUtil.isLowRamDevice(this@App))
|
||||
if (networkPreferences.verboseLogging().get()) logger(DebugLogger())
|
||||
if (networkPreferences.verboseLogging.get()) logger(DebugLogger())
|
||||
|
||||
// Coil spawns a new thread for every image load by default
|
||||
fetcherCoroutineContext(Dispatchers.IO.limitedParallelism(8))
|
||||
@@ -256,7 +256,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||
private var registered = false
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
basePreferences.incognitoMode().set(false)
|
||||
basePreferences.incognitoMode.set(false)
|
||||
}
|
||||
|
||||
fun register() {
|
||||
|
||||
@@ -101,7 +101,7 @@ class BackupNotifier(private val context: Context) {
|
||||
}
|
||||
setContentTitle(contentTitle)
|
||||
|
||||
if (!preferences.hideNotificationContent().get()) {
|
||||
if (!preferences.hideNotificationContent.get()) {
|
||||
setContentText(content)
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class BackupCreateJob(private val context: Context, workerParams: WorkerParamete
|
||||
|
||||
fun setupTask(context: Context, prefInterval: Int? = null) {
|
||||
val backupPreferences = Injekt.get<BackupPreferences>()
|
||||
val interval = prefInterval ?: backupPreferences.backupInterval().get()
|
||||
val interval = prefInterval ?: backupPreferences.backupInterval.get()
|
||||
if (interval > 0) {
|
||||
val constraints = Constraints(
|
||||
requiresBatteryNotLow = true,
|
||||
|
||||
@@ -108,7 +108,7 @@ class BackupCreator(
|
||||
BackupFileValidator(context).validate(fileUri)
|
||||
|
||||
if (isAutoBackup) {
|
||||
backupPreferences.lastAutoBackupTimestamp().set(Instant.now().toEpochMilli())
|
||||
backupPreferences.lastAutoBackupTimestamp.set(Instant.now().toEpochMilli())
|
||||
}
|
||||
|
||||
return fileUri.toString()
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ class CategoriesRestorer(
|
||||
.let { id -> it.toCategory(id).copy(order = order) }
|
||||
}
|
||||
|
||||
libraryPreferences.categorizedDisplaySettings().set(
|
||||
libraryPreferences.categorizedDisplaySettings.set(
|
||||
(dbCategories + categories)
|
||||
.distinctBy { it.flags }
|
||||
.size > 1,
|
||||
|
||||
@@ -56,7 +56,7 @@ class DownloadJob(context: Context, workerParams: WorkerParameters) : CoroutineW
|
||||
override suspend fun doWork(): Result {
|
||||
var networkCheck = checkNetworkState(
|
||||
applicationContext.activeNetworkState(),
|
||||
downloadPreferences.downloadOnlyOverWifi().get(),
|
||||
downloadPreferences.downloadOnlyOverWifi.get(),
|
||||
)
|
||||
var active = networkCheck && downloadManager.downloaderStart()
|
||||
|
||||
@@ -69,7 +69,7 @@ class DownloadJob(context: Context, workerParams: WorkerParameters) : CoroutineW
|
||||
coroutineScope {
|
||||
combineTransform(
|
||||
applicationContext.networkStateFlow(),
|
||||
downloadPreferences.downloadOnlyOverWifi().changes(),
|
||||
downloadPreferences.downloadOnlyOverWifi.changes(),
|
||||
transform = { a, b -> emit(checkNetworkState(a, b)) },
|
||||
)
|
||||
.onEach { networkCheck = it }
|
||||
|
||||
@@ -397,7 +397,7 @@ class DownloadManager(
|
||||
|
||||
private suspend fun getChaptersToDelete(chapters: List<Chapter>, manga: Manga): List<Chapter> {
|
||||
// Retrieve the categories that are set to exclude from being deleted on read
|
||||
val categoriesToExclude = downloadPreferences.removeExcludeCategories().get().map(String::toLong)
|
||||
val categoriesToExclude = downloadPreferences.removeExcludeCategories.get().map(String::toLong)
|
||||
|
||||
val categoriesForManga = getCategories.await(manga.id)
|
||||
.map { it.id }
|
||||
@@ -408,7 +408,7 @@ class DownloadManager(
|
||||
chapters
|
||||
}
|
||||
|
||||
return if (!downloadPreferences.removeBookmarkedChapters().get()) {
|
||||
return if (!downloadPreferences.removeBookmarkedChapters.get()) {
|
||||
filteredCategoryManga.filterNot { it.bookmark }
|
||||
} else {
|
||||
filteredCategoryManga
|
||||
|
||||
@@ -96,7 +96,7 @@ internal class DownloadNotifier(private val context: Context) {
|
||||
download.pages!!.size,
|
||||
)
|
||||
|
||||
if (preferences.hideNotificationContent().get()) {
|
||||
if (preferences.hideNotificationContent.get()) {
|
||||
setContentTitle(downloadingProgressText)
|
||||
setContentText(null)
|
||||
} else {
|
||||
|
||||
@@ -136,7 +136,7 @@ class DownloadProvider(
|
||||
fun getSourceDirName(source: Source): String {
|
||||
return DiskUtil.buildValidFilename(
|
||||
source.toString(),
|
||||
disallowNonAscii = libraryPreferences.disallowNonAsciiFilenames().get(),
|
||||
disallowNonAscii = libraryPreferences.disallowNonAsciiFilenames.get(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class DownloadProvider(
|
||||
fun getMangaDirName(mangaTitle: String): String {
|
||||
return DiskUtil.buildValidFilename(
|
||||
mangaTitle,
|
||||
disallowNonAscii = libraryPreferences.disallowNonAsciiFilenames().get(),
|
||||
disallowNonAscii = libraryPreferences.disallowNonAsciiFilenames.get(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class DownloadProvider(
|
||||
chapterName: String,
|
||||
chapterScanlator: String?,
|
||||
chapterUrl: String,
|
||||
disallowNonAsciiFilenames: Boolean = libraryPreferences.disallowNonAsciiFilenames().get(),
|
||||
disallowNonAsciiFilenames: Boolean = libraryPreferences.disallowNonAsciiFilenames.get(),
|
||||
): String {
|
||||
var dirName = sanitizeChapterName(chapterName)
|
||||
if (!chapterScanlator.isNullOrBlank()) {
|
||||
@@ -206,7 +206,7 @@ class DownloadProvider(
|
||||
chapterName,
|
||||
chapterScanlator,
|
||||
chapterUrl,
|
||||
!libraryPreferences.disallowNonAsciiFilenames().get(),
|
||||
!libraryPreferences.disallowNonAsciiFilenames.get(),
|
||||
)
|
||||
|
||||
return buildList(2) {
|
||||
|
||||
@@ -193,7 +193,7 @@ class Downloader(
|
||||
downloaderJob = scope.launch {
|
||||
val activeDownloadsFlow = combine(
|
||||
queueState,
|
||||
downloadPreferences.parallelSourceLimit().changes(),
|
||||
downloadPreferences.parallelSourceLimit.changes(),
|
||||
) { a, b -> a to b }.transformLatest { (queue, parallelCount) ->
|
||||
while (true) {
|
||||
val activeDownloads = queue.asSequence()
|
||||
@@ -369,7 +369,7 @@ class Downloader(
|
||||
download.status = Download.State.DOWNLOADING
|
||||
|
||||
// Start downloading images, consider we can have downloaded images already
|
||||
pageList.asFlow().flatMapMerge(concurrency = downloadPreferences.parallelPageLimit().get()) { page ->
|
||||
pageList.asFlow().flatMapMerge(concurrency = downloadPreferences.parallelPageLimit.get()) { page ->
|
||||
flow {
|
||||
// Fetch image URL if necessary
|
||||
if (page.imageUrl.isNullOrEmpty()) {
|
||||
@@ -406,7 +406,7 @@ class Downloader(
|
||||
)
|
||||
|
||||
// Only rename the directory if it's downloaded
|
||||
if (downloadPreferences.saveChaptersAsCBZ().get()) {
|
||||
if (downloadPreferences.saveChaptersAsCBZ.get()) {
|
||||
archiveChapter(mangaDir, chapterDirname, tmpDir)
|
||||
} else {
|
||||
tmpDir.renameTo(chapterDirname)
|
||||
@@ -545,7 +545,7 @@ class Downloader(
|
||||
}
|
||||
|
||||
private fun splitTallImageIfNeeded(page: Page, tmpDir: UniFile) {
|
||||
if (!downloadPreferences.splitTallImages().get()) return
|
||||
if (!downloadPreferences.splitTallImages.get()) return
|
||||
|
||||
try {
|
||||
val filenamePrefix = "%03d".format(Locale.ENGLISH, page.number)
|
||||
|
||||
@@ -99,7 +99,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||
if (tags.contains(WORK_NAME_AUTO)) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
val preferences = Injekt.get<LibraryPreferences>()
|
||||
val restrictions = preferences.autoUpdateDeviceRestrictions().get()
|
||||
val restrictions = preferences.autoUpdateDeviceRestrictions.get()
|
||||
if ((DEVICE_ONLY_ON_WIFI in restrictions) && !context.isConnectedToWifi()) {
|
||||
return Result.retry()
|
||||
}
|
||||
@@ -113,7 +113,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||
|
||||
setForegroundSafely()
|
||||
|
||||
libraryPreferences.lastUpdatedTimestamp().set(Instant.now().toEpochMilli())
|
||||
libraryPreferences.lastUpdatedTimestamp.set(Instant.now().toEpochMilli())
|
||||
|
||||
val categoryId = inputData.getLong(KEY_CATEGORY, -1L)
|
||||
addMangaToQueue(categoryId)
|
||||
@@ -160,8 +160,8 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||
val listToUpdate = if (categoryId != -1L) {
|
||||
libraryManga.filter { categoryId in it.categories }
|
||||
} else {
|
||||
val includedCategories = libraryPreferences.updateCategories().get().map { it.toLong() }
|
||||
val excludedCategories = libraryPreferences.updateCategoriesExclude().get().map { it.toLong() }
|
||||
val includedCategories = libraryPreferences.updateCategories.get().map { it.toLong() }
|
||||
val excludedCategories = libraryPreferences.updateCategoriesExclude.get().map { it.toLong() }
|
||||
|
||||
libraryManga.filter {
|
||||
val included = includedCategories.isEmpty() || it.categories.intersect(includedCategories).isNotEmpty()
|
||||
@@ -170,7 +170,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||
}
|
||||
}
|
||||
|
||||
val restrictions = libraryPreferences.autoUpdateMangaRestrictions().get()
|
||||
val restrictions = libraryPreferences.autoUpdateMangaRestrictions.get()
|
||||
val skippedUpdates = mutableListOf<Pair<Manga, String?>>()
|
||||
val (_, fetchWindowUpperBound) = fetchInterval.getWindow(ZonedDateTime.now())
|
||||
|
||||
@@ -272,7 +272,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||
hasDownloads.store(true)
|
||||
}
|
||||
|
||||
libraryPreferences.newUpdatesCount().getAndSet { it + newChapters.size }
|
||||
libraryPreferences.newUpdatesCount.getAndSet { it + newChapters.size }
|
||||
|
||||
// Convert to the manga that contains new chapters
|
||||
newUpdates.add(manga to newChapters.toTypedArray())
|
||||
@@ -332,7 +332,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||
val source = sourceManager.getOrStub(manga.source)
|
||||
|
||||
// Update manga metadata if needed
|
||||
if (libraryPreferences.autoUpdateMetadata().get()) {
|
||||
if (libraryPreferences.autoUpdateMetadata.get()) {
|
||||
val networkManga = source.getMangaDetails(manga.toSManga())
|
||||
updateManga.awaitUpdateFromSource(manga, networkManga, manualFetch = false, coverCache)
|
||||
}
|
||||
@@ -423,9 +423,9 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||
prefInterval: Int? = null,
|
||||
) {
|
||||
val preferences = Injekt.get<LibraryPreferences>()
|
||||
val interval = prefInterval ?: preferences.autoUpdateInterval().get()
|
||||
val interval = prefInterval ?: preferences.autoUpdateInterval.get()
|
||||
if (interval > 0) {
|
||||
val restrictions = preferences.autoUpdateDeviceRestrictions().get()
|
||||
val restrictions = preferences.autoUpdateDeviceRestrictions.get()
|
||||
val networkType = if (DEVICE_NETWORK_NOT_METERED in restrictions) {
|
||||
NetworkType.UNMETERED
|
||||
} else {
|
||||
|
||||
@@ -98,7 +98,7 @@ class LibraryUpdateNotifier(
|
||||
),
|
||||
)
|
||||
|
||||
if (!securityPreferences.hideNotificationContent().get()) {
|
||||
if (!securityPreferences.hideNotificationContent.get()) {
|
||||
val updatingText = manga.joinToString("\n") { it.title.chop(40) }
|
||||
progressNotificationBuilder.setStyle(NotificationCompat.BigTextStyle().bigText(updatingText))
|
||||
}
|
||||
@@ -173,7 +173,7 @@ class LibraryUpdateNotifier(
|
||||
Notifications.CHANNEL_NEW_CHAPTERS,
|
||||
) {
|
||||
setContentTitle(context.stringResource(MR.strings.notification_new_chapters))
|
||||
if (updates.size == 1 && !securityPreferences.hideNotificationContent().get()) {
|
||||
if (updates.size == 1 && !securityPreferences.hideNotificationContent.get()) {
|
||||
setContentText(updates.first().first.title.chop(NOTIF_TITLE_MAX_LEN))
|
||||
} else {
|
||||
setContentText(
|
||||
@@ -184,7 +184,7 @@ class LibraryUpdateNotifier(
|
||||
),
|
||||
)
|
||||
|
||||
if (!securityPreferences.hideNotificationContent().get()) {
|
||||
if (!securityPreferences.hideNotificationContent.get()) {
|
||||
setStyle(
|
||||
NotificationCompat.BigTextStyle().bigText(
|
||||
updates.joinToString("\n") {
|
||||
@@ -208,7 +208,7 @@ class LibraryUpdateNotifier(
|
||||
}
|
||||
|
||||
// Per-manga notification
|
||||
if (!securityPreferences.hideNotificationContent().get()) {
|
||||
if (!securityPreferences.hideNotificationContent.get()) {
|
||||
launchUI {
|
||||
context.notify(
|
||||
updates.map { (manga, chapters) ->
|
||||
|
||||
@@ -211,7 +211,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
val toUpdate = chapterUrls.mapNotNull { getChapter.await(it, mangaId) }
|
||||
.map {
|
||||
val chapter = it.copy(read = true)
|
||||
if (downloadPreferences.removeAfterMarkedAsRead().get()) {
|
||||
if (downloadPreferences.removeAfterMarkedAsRead.get()) {
|
||||
val manga = getManga.await(mangaId)
|
||||
if (manga != null) {
|
||||
val source = sourceManager.get(manga.source)
|
||||
|
||||
@@ -43,7 +43,7 @@ class Anilist(id: Long) : BaseTracker(id, "AniList"), DeletableTracker {
|
||||
|
||||
override val supportsPrivateTracking: Boolean = true
|
||||
|
||||
private val scorePreference = trackPreferences.anilistScoreType()
|
||||
private val scorePreference = trackPreferences.anilistScoreType
|
||||
|
||||
init {
|
||||
// If the preference is an int from APIv1, logout user to force using APIv2
|
||||
|
||||
@@ -17,7 +17,7 @@ fun Track.toApiStatus() = when (status) {
|
||||
|
||||
private val preferences: TrackPreferences by injectLazy()
|
||||
|
||||
fun DomainTrack.toApiScore(): String = when (preferences.anilistScoreType().get()) {
|
||||
fun DomainTrack.toApiScore(): String = when (preferences.anilistScoreType.get()) {
|
||||
// 10 point
|
||||
"POINT_10" -> (score.toInt() / 10).toString()
|
||||
// 100 point
|
||||
|
||||
@@ -32,7 +32,7 @@ class PreferenceModule(val app: Application) : InjektModule {
|
||||
addSingletonFactory {
|
||||
NetworkPreferences(
|
||||
preferenceStore = get(),
|
||||
verboseLogging = isDebugBuildType,
|
||||
verboseLoggingDefault = isDebugBuildType,
|
||||
)
|
||||
}
|
||||
addSingletonFactory {
|
||||
|
||||
@@ -77,7 +77,7 @@ class ExtensionManager(
|
||||
ExtensionInstallReceiver(InstallationListener()).register(context)
|
||||
}
|
||||
|
||||
private var subLanguagesEnabledOnFirstRun = preferences.enabledLanguages().isSet()
|
||||
private var subLanguagesEnabledOnFirstRun = preferences.enabledLanguages.isSet()
|
||||
|
||||
fun getExtensionPackage(sourceId: Long): String? {
|
||||
return installedExtensionsFlow.value.find { extension ->
|
||||
@@ -174,12 +174,12 @@ class ExtensionManager(
|
||||
.map(Extension.Available.Source::lang)
|
||||
|
||||
val deviceLanguage = Locale.getDefault().language
|
||||
val defaultLanguages = preferences.enabledLanguages().defaultValue()
|
||||
val defaultLanguages = preferences.enabledLanguages.defaultValue()
|
||||
val languagesToEnable = availableLanguages.filter {
|
||||
it != deviceLanguage && it.startsWith(deviceLanguage)
|
||||
}
|
||||
|
||||
preferences.enabledLanguages().set(defaultLanguages + languagesToEnable)
|
||||
preferences.enabledLanguages.set(defaultLanguages + languagesToEnable)
|
||||
subLanguagesEnabledOnFirstRun = true
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ class ExtensionManager(
|
||||
*/
|
||||
private fun updatedInstalledExtensionsStatuses(availableExtensions: List<Extension.Available>) {
|
||||
if (availableExtensions.isEmpty()) {
|
||||
preferences.extensionUpdatesCount().set(0)
|
||||
preferences.extensionUpdatesCount.set(0)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ class ExtensionManager(
|
||||
|
||||
private fun updatePendingUpdatesCount() {
|
||||
val pendingUpdateCount = installedExtensionMapFlow.value.values.count { it.hasUpdate }
|
||||
preferences.extensionUpdatesCount().set(pendingUpdateCount)
|
||||
preferences.extensionUpdatesCount.set(pendingUpdateCount)
|
||||
if (pendingUpdateCount == 0) {
|
||||
ExtensionUpdateNotifier(context).dismiss()
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class ExtensionUpdateNotifier(
|
||||
names.size,
|
||||
),
|
||||
)
|
||||
if (!securityPreferences.hideNotificationContent().get()) {
|
||||
if (!securityPreferences.hideNotificationContent.get()) {
|
||||
val extNames = names.joinToString(", ")
|
||||
setContentText(extNames)
|
||||
setStyle(NotificationCompat.BigTextStyle().bigText(extNames))
|
||||
|
||||
@@ -39,7 +39,7 @@ internal class ExtensionInstaller(
|
||||
private val scope = CoroutineScope(Dispatchers.IO)
|
||||
private val activeJobs = mutableMapOf<String, Job>()
|
||||
private val activeSteps = mutableMapOf<Long, MutableStateFlow<InstallStep>>()
|
||||
private val extensionInstaller = Injekt.get<BasePreferences>().extensionInstaller()
|
||||
private val extensionInstaller = Injekt.get<BasePreferences>().extensionInstaller
|
||||
|
||||
private val httpClient: OkHttpClient = Injekt.get<NetworkHelper>().client
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ internal object ExtensionLoader {
|
||||
private val preferences: SourcePreferences by injectLazy()
|
||||
private val trustExtension: TrustExtension by injectLazy()
|
||||
private val loadNsfwSource by lazy {
|
||||
preferences.showNsfwSource().get()
|
||||
preferences.showNsfwSource.get()
|
||||
}
|
||||
|
||||
private const val EXTENSION_FEATURE = "tachiyomi.extension"
|
||||
|
||||
@@ -8,7 +8,7 @@ import uy.kohesive.injekt.api.get
|
||||
|
||||
fun Source.getNameForMangaInfo(): String {
|
||||
val preferences = Injekt.get<SourcePreferences>()
|
||||
val enabledLanguages = preferences.enabledLanguages().get()
|
||||
val enabledLanguages = preferences.enabledLanguages.get()
|
||||
.filterNot { it in listOf("all", "other") }
|
||||
val hasOneActiveLanguages = enabledLanguages.size == 1
|
||||
val isInEnabledLanguages = lang in enabledLanguages
|
||||
|
||||
@@ -33,14 +33,14 @@ interface SecureActivityDelegate {
|
||||
|
||||
fun onApplicationStopped() {
|
||||
val preferences = Injekt.get<SecurityPreferences>()
|
||||
if (!preferences.useAuthenticator().get()) return
|
||||
if (!preferences.useAuthenticator.get()) return
|
||||
|
||||
if (!AuthenticatorUtil.isAuthenticating) {
|
||||
// Return if app is closed in locked state
|
||||
if (requireUnlock) return
|
||||
// Save app close time if lock is delayed
|
||||
if (preferences.lockAppAfter().get() > 0) {
|
||||
preferences.lastAppClosed().set(System.currentTimeMillis())
|
||||
if (preferences.lockAppAfter.get() > 0) {
|
||||
preferences.lastAppClosed.set(System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,13 +50,13 @@ interface SecureActivityDelegate {
|
||||
*/
|
||||
fun onApplicationStart() {
|
||||
val preferences = Injekt.get<SecurityPreferences>()
|
||||
if (!preferences.useAuthenticator().get()) return
|
||||
if (!preferences.useAuthenticator.get()) return
|
||||
|
||||
val lastClosedPref = preferences.lastAppClosed()
|
||||
val lastClosedPref = preferences.lastAppClosed
|
||||
|
||||
// `requireUnlock` can be true on process start or if app was closed in locked state
|
||||
if (!AuthenticatorUtil.isAuthenticating && !requireUnlock) {
|
||||
requireUnlock = when (val lockDelay = preferences.lockAppAfter().get()) {
|
||||
requireUnlock = when (val lockDelay = preferences.lockAppAfter.get()) {
|
||||
-1 -> false // Never
|
||||
0 -> true // Always
|
||||
else -> lastClosedPref.get() + lockDelay * 60_000 <= System.currentTimeMillis()
|
||||
@@ -93,8 +93,8 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser
|
||||
}
|
||||
|
||||
private fun setSecureScreen() {
|
||||
val secureScreenFlow = securityPreferences.secureScreen().changes()
|
||||
val incognitoModeFlow = preferences.incognitoMode().changes()
|
||||
val secureScreenFlow = securityPreferences.secureScreen.changes()
|
||||
val incognitoModeFlow = preferences.incognitoMode.changes()
|
||||
combine(secureScreenFlow, incognitoModeFlow) { secureScreen, incognitoMode ->
|
||||
secureScreen == SecurityPreferences.SecureScreenMode.ALWAYS ||
|
||||
(secureScreen == SecurityPreferences.SecureScreenMode.INCOGNITO && incognitoMode)
|
||||
@@ -104,7 +104,7 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser
|
||||
}
|
||||
|
||||
private fun setAppLock() {
|
||||
if (!securityPreferences.useAuthenticator().get()) return
|
||||
if (!securityPreferences.useAuthenticator.get()) return
|
||||
if (activity.isAuthenticationSupported()) {
|
||||
if (!SecureActivityDelegate.requireUnlock) return
|
||||
activity.startActivity(Intent(activity, UnlockActivity::class.java))
|
||||
@@ -115,7 +115,7 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser
|
||||
activity.overridePendingTransition(0, 0)
|
||||
}
|
||||
} else {
|
||||
securityPreferences.useAuthenticator().set(false)
|
||||
securityPreferences.useAuthenticator.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ interface ThemingDelegate {
|
||||
class ThemingDelegateImpl : ThemingDelegate {
|
||||
override fun applyAppTheme(activity: Activity) {
|
||||
val uiPreferences = Injekt.get<UiPreferences>()
|
||||
ThemingDelegate.getThemeResIds(uiPreferences.appTheme().get(), uiPreferences.themeDarkAmoled().get())
|
||||
ThemingDelegate.getThemeResIds(uiPreferences.appTheme.get(), uiPreferences.themeDarkAmoled.get())
|
||||
.forEach(activity::setTheme)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class ExtensionFilterScreenModel(
|
||||
screenModelScope.launch {
|
||||
combine(
|
||||
getExtensionLanguages.subscribe(),
|
||||
preferences.enabledLanguages().changes(),
|
||||
preferences.enabledLanguages.changes(),
|
||||
) { a, b -> a to b }
|
||||
.catch { throwable ->
|
||||
logcat(LogPriority.ERROR, throwable)
|
||||
|
||||
@@ -98,11 +98,11 @@ class ExtensionsScreenModel(
|
||||
|
||||
screenModelScope.launchIO { findAvailableExtensions() }
|
||||
|
||||
preferences.extensionUpdatesCount().changes()
|
||||
preferences.extensionUpdatesCount.changes()
|
||||
.onEach { mutableState.update { state -> state.copy(updates = it) } }
|
||||
.launchIn(screenModelScope)
|
||||
|
||||
basePreferences.extensionInstaller().changes()
|
||||
basePreferences.extensionInstaller.changes()
|
||||
.onEach { mutableState.update { state -> state.copy(installer = it) } }
|
||||
.launchIn(screenModelScope)
|
||||
}
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ class ExtensionDetailsScreenModel(
|
||||
}
|
||||
}
|
||||
launch {
|
||||
preferences.incognitoExtensions()
|
||||
preferences.incognitoExtensions
|
||||
.changes()
|
||||
.map { pkgName in it }
|
||||
.distinctUntilChanged()
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ class MigrateSearchScreenModel(
|
||||
private val sourcePreferences: SourcePreferences = Injekt.get(),
|
||||
) : SearchScreenModel() {
|
||||
|
||||
private val migrationSources by lazy { sourcePreferences.migrationSources().get() }
|
||||
private val migrationSources by lazy { sourcePreferences.migrationSources.get() }
|
||||
|
||||
override val sortComparator = { map: Map<CatalogueSource, SearchItemResult> ->
|
||||
compareBy<CatalogueSource>(
|
||||
|
||||
+2
-2
@@ -49,11 +49,11 @@ class MigrateSourceScreenModel(
|
||||
}
|
||||
}
|
||||
|
||||
preferences.migrationSortingDirection().changes()
|
||||
preferences.migrationSortingDirection.changes()
|
||||
.onEach { mutableState.update { state -> state.copy(sortingDirection = it) } }
|
||||
.launchIn(screenModelScope)
|
||||
|
||||
preferences.migrationSortingMode().changes()
|
||||
preferences.migrationSortingMode.changes()
|
||||
.onEach { mutableState.update { state -> state.copy(sortingMode = it) } }
|
||||
.launchIn(screenModelScope)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ class SourcesFilterScreenModel(
|
||||
screenModelScope.launch {
|
||||
combine(
|
||||
getLanguagesWithSources.subscribe(),
|
||||
preferences.enabledLanguages().changes(),
|
||||
preferences.disabledSources().changes(),
|
||||
preferences.enabledLanguages.changes(),
|
||||
preferences.disabledSources.changes(),
|
||||
) { a, b, c -> Triple(a, b, c) }
|
||||
.catch { throwable ->
|
||||
mutableState.update {
|
||||
|
||||
+6
-6
@@ -71,7 +71,7 @@ class BrowseSourceScreenModel(
|
||||
private val getIncognitoState: GetIncognitoState = Injekt.get(),
|
||||
) : StateScreenModel<BrowseSourceScreenModel.State>(State(Listing.valueOf(listingQuery))) {
|
||||
|
||||
var displayMode by sourcePreferences.sourceDisplayMode().asState(screenModelScope)
|
||||
var displayMode by sourcePreferences.sourceDisplayMode.asState(screenModelScope)
|
||||
|
||||
val source = sourceManager.getOrStub(sourceId)
|
||||
|
||||
@@ -95,14 +95,14 @@ class BrowseSourceScreenModel(
|
||||
}
|
||||
|
||||
if (!getIncognitoState.await(source.id)) {
|
||||
sourcePreferences.lastUsedSource().set(source.id)
|
||||
sourcePreferences.lastUsedSource.set(source.id)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flow of Pager flow tied to [State.listing]
|
||||
*/
|
||||
private val hideInLibraryItems = sourcePreferences.hideInLibraryItems().get()
|
||||
private val hideInLibraryItems = sourcePreferences.hideInLibraryItems.get()
|
||||
val mangaPagerFlowFlow = state.map { it.listing }
|
||||
.distinctUntilChanged()
|
||||
.map { listing ->
|
||||
@@ -123,9 +123,9 @@ class BrowseSourceScreenModel(
|
||||
fun getColumnsPreference(orientation: Int): GridCells {
|
||||
val isLandscape = orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
val columns = if (isLandscape) {
|
||||
libraryPreferences.landscapeColumns()
|
||||
libraryPreferences.landscapeColumns
|
||||
} else {
|
||||
libraryPreferences.portraitColumns()
|
||||
libraryPreferences.portraitColumns
|
||||
}.get()
|
||||
return if (columns == 0) GridCells.Adaptive(128.dp) else GridCells.Fixed(columns)
|
||||
}
|
||||
@@ -241,7 +241,7 @@ class BrowseSourceScreenModel(
|
||||
fun addFavorite(manga: Manga) {
|
||||
screenModelScope.launch {
|
||||
val categories = getCategories()
|
||||
val defaultCategoryId = libraryPreferences.defaultCategory().get()
|
||||
val defaultCategoryId = libraryPreferences.defaultCategory.get()
|
||||
val defaultCategory = categories.find { it.id == defaultCategoryId.toLong() }
|
||||
|
||||
when {
|
||||
|
||||
+5
-5
@@ -47,9 +47,9 @@ abstract class SearchScreenModel(
|
||||
private val coroutineDispatcher = Executors.newFixedThreadPool(5).asCoroutineDispatcher()
|
||||
private var searchJob: Job? = null
|
||||
|
||||
private val enabledLanguages = sourcePreferences.enabledLanguages().get()
|
||||
private val disabledSources = sourcePreferences.disabledSources().get()
|
||||
protected val pinnedSources = sourcePreferences.pinnedSources().get()
|
||||
private val enabledLanguages = sourcePreferences.enabledLanguages.get()
|
||||
private val disabledSources = sourcePreferences.disabledSources.get()
|
||||
protected val pinnedSources = sourcePreferences.pinnedSources.get()
|
||||
|
||||
private var lastQuery: String? = null
|
||||
private var lastSourceFilter: SourceFilter? = null
|
||||
@@ -66,7 +66,7 @@ abstract class SearchScreenModel(
|
||||
|
||||
init {
|
||||
screenModelScope.launch {
|
||||
preferences.globalSearchFilterState().changes().collectLatest { state ->
|
||||
preferences.globalSearchFilterState.changes().collectLatest { state ->
|
||||
mutableState.update { it.copy(onlyShowHasResults = state) }
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ abstract class SearchScreenModel(
|
||||
}
|
||||
|
||||
fun toggleFilterResults() {
|
||||
preferences.globalSearchFilterState().toggle()
|
||||
preferences.globalSearchFilterState.toggle()
|
||||
}
|
||||
|
||||
fun search() {
|
||||
|
||||
@@ -189,7 +189,7 @@ class HistoryScreenModel(
|
||||
screenModelScope.launchIO {
|
||||
// Move to default category if applicable
|
||||
val categories = getCategories()
|
||||
val defaultCategoryId = libraryPreferences.defaultCategory().get().toLong()
|
||||
val defaultCategoryId = libraryPreferences.defaultCategory.get().toLong()
|
||||
val defaultCategory = categories.find { it.id == defaultCategoryId }
|
||||
|
||||
when {
|
||||
|
||||
@@ -242,8 +242,8 @@ object HomeScreen : Screen() {
|
||||
val count by produceState(initialValue = 0) {
|
||||
val pref = Injekt.get<LibraryPreferences>()
|
||||
combine(
|
||||
pref.newShowUpdatesCount().changes(),
|
||||
pref.newUpdatesCount().changes(),
|
||||
pref.newShowUpdatesCount.changes(),
|
||||
pref.newUpdatesCount.changes(),
|
||||
) { show, count -> if (show) count else 0 }
|
||||
.collectLatest { value = it }
|
||||
}
|
||||
@@ -263,7 +263,7 @@ object HomeScreen : Screen() {
|
||||
}
|
||||
BrowseTab::class.isInstance(tab) -> {
|
||||
val count by produceState(initialValue = 0) {
|
||||
Injekt.get<SourcePreferences>().extensionUpdatesCount().changes()
|
||||
Injekt.get<SourcePreferences>().extensionUpdatesCount.changes()
|
||||
.collectLatest { value = it }
|
||||
}
|
||||
if (count > 0) {
|
||||
|
||||
@@ -89,7 +89,7 @@ class LibraryScreenModel(
|
||||
|
||||
init {
|
||||
mutableState.update { state ->
|
||||
state.copy(activeCategoryIndex = libraryPreferences.lastUsedCategory().get())
|
||||
state.copy(activeCategoryIndex = libraryPreferences.lastUsedCategory.get())
|
||||
}
|
||||
screenModelScope.launchIO {
|
||||
combine(
|
||||
@@ -142,9 +142,9 @@ class LibraryScreenModel(
|
||||
}
|
||||
|
||||
combine(
|
||||
libraryPreferences.categoryTabs().changes(),
|
||||
libraryPreferences.categoryNumberOfItems().changes(),
|
||||
libraryPreferences.showContinueReadingButton().changes(),
|
||||
libraryPreferences.categoryTabs.changes(),
|
||||
libraryPreferences.categoryNumberOfItems.changes(),
|
||||
libraryPreferences.showContinueReadingButton.changes(),
|
||||
) { a, b, c -> arrayOf(a, b, c) }
|
||||
.onEach { (showCategoryTabs, showMangaCount, showMangaContinueButton) ->
|
||||
mutableState.update { state ->
|
||||
@@ -337,7 +337,7 @@ class LibraryScreenModel(
|
||||
|
||||
return mapValues { (key, value) ->
|
||||
if (key.sort.type == LibrarySort.Type.Random) {
|
||||
return@mapValues value.shuffled(Random(libraryPreferences.randomSortSeed().get()))
|
||||
return@mapValues value.shuffled(Random(libraryPreferences.randomSortSeed.get()))
|
||||
}
|
||||
|
||||
val manga = value.mapNotNull { favoritesById[it] }
|
||||
@@ -352,19 +352,19 @@ class LibraryScreenModel(
|
||||
|
||||
private fun getLibraryItemPreferencesFlow(): Flow<ItemPreferences> {
|
||||
return combine(
|
||||
libraryPreferences.downloadBadge().changes(),
|
||||
libraryPreferences.unreadBadge().changes(),
|
||||
libraryPreferences.localBadge().changes(),
|
||||
libraryPreferences.languageBadge().changes(),
|
||||
libraryPreferences.autoUpdateMangaRestrictions().changes(),
|
||||
libraryPreferences.downloadBadge.changes(),
|
||||
libraryPreferences.unreadBadge.changes(),
|
||||
libraryPreferences.localBadge.changes(),
|
||||
libraryPreferences.languageBadge.changes(),
|
||||
libraryPreferences.autoUpdateMangaRestrictions.changes(),
|
||||
|
||||
preferences.downloadedOnly().changes(),
|
||||
libraryPreferences.filterDownloaded().changes(),
|
||||
libraryPreferences.filterUnread().changes(),
|
||||
libraryPreferences.filterStarted().changes(),
|
||||
libraryPreferences.filterBookmarked().changes(),
|
||||
libraryPreferences.filterCompleted().changes(),
|
||||
libraryPreferences.filterIntervalCustom().changes(),
|
||||
preferences.downloadedOnly.changes(),
|
||||
libraryPreferences.filterDownloaded.changes(),
|
||||
libraryPreferences.filterUnread.changes(),
|
||||
libraryPreferences.filterStarted.changes(),
|
||||
libraryPreferences.filterBookmarked.changes(),
|
||||
libraryPreferences.filterCompleted.changes(),
|
||||
libraryPreferences.filterIntervalCustom.changes(),
|
||||
) {
|
||||
ItemPreferences(
|
||||
downloadBadge = it[0] as Boolean,
|
||||
@@ -589,11 +589,11 @@ class LibraryScreenModel(
|
||||
}
|
||||
|
||||
fun getDisplayMode(): PreferenceMutableState<LibraryDisplayMode> {
|
||||
return libraryPreferences.displayMode().asState(screenModelScope)
|
||||
return libraryPreferences.displayMode.asState(screenModelScope)
|
||||
}
|
||||
|
||||
fun getColumnsForOrientation(isLandscape: Boolean): PreferenceMutableState<Int> {
|
||||
return (if (isLandscape) libraryPreferences.landscapeColumns() else libraryPreferences.portraitColumns())
|
||||
return (if (isLandscape) libraryPreferences.landscapeColumns else libraryPreferences.portraitColumns)
|
||||
.asState(screenModelScope)
|
||||
}
|
||||
|
||||
@@ -686,7 +686,7 @@ class LibraryScreenModel(
|
||||
}
|
||||
.coercedActiveCategoryIndex
|
||||
|
||||
libraryPreferences.lastUsedCategory().set(newIndex)
|
||||
libraryPreferences.lastUsedCategory.set(newIndex)
|
||||
}
|
||||
|
||||
fun openChangeCategoryDialog() {
|
||||
|
||||
@@ -146,7 +146,7 @@ class MainActivity : BaseActivity() {
|
||||
val context = LocalContext.current
|
||||
|
||||
var incognito by remember { mutableStateOf(getIncognitoState.await(null)) }
|
||||
val downloadOnly by preferences.downloadedOnly().collectAsState()
|
||||
val downloadOnly by preferences.downloadedOnly.collectAsState()
|
||||
val indexing by downloadCache.isInitializing.collectAsState()
|
||||
|
||||
val isSystemInDarkTheme = isSystemInDarkTheme()
|
||||
@@ -178,7 +178,7 @@ class MainActivity : BaseActivity() {
|
||||
handleIntentAction(intent, navigator)
|
||||
|
||||
// Reset Incognito Mode on relaunch
|
||||
preferences.incognitoMode().set(false)
|
||||
preferences.incognitoMode.set(false)
|
||||
}
|
||||
}
|
||||
LaunchedEffect(navigator.lastItem) {
|
||||
@@ -225,7 +225,7 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
// Pop source-related screens when incognito mode is turned off
|
||||
LaunchedEffect(Unit) {
|
||||
preferences.incognitoMode().changes()
|
||||
preferences.incognitoMode.changes()
|
||||
.drop(1)
|
||||
.filter { !it }
|
||||
.onEach {
|
||||
@@ -271,7 +271,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
setSplashScreenExitAnimation(splashScreen)
|
||||
|
||||
if (isLaunch && libraryPreferences.autoClearChapterCache().get()) {
|
||||
if (isLaunch && libraryPreferences.autoClearChapterCache.get()) {
|
||||
lifecycleScope.launchIO {
|
||||
chapterCache.clear()
|
||||
}
|
||||
@@ -340,7 +340,7 @@ class MainActivity : BaseActivity() {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
if (!preferences.shownOnboardingFlow().get() && navigator.lastItem !is OnboardingScreen) {
|
||||
if (!preferences.shownOnboardingFlow.get() && navigator.lastItem !is OnboardingScreen) {
|
||||
navigator.push(OnboardingScreen())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,14 +141,14 @@ class MangaScreenModel(
|
||||
private val filteredChapters: List<ChapterList.Item>?
|
||||
get() = successState?.processedChapters
|
||||
|
||||
val chapterSwipeStartAction = libraryPreferences.swipeToEndAction().get()
|
||||
val chapterSwipeEndAction = libraryPreferences.swipeToStartAction().get()
|
||||
var autoTrackState = trackPreferences.autoUpdateTrackOnMarkRead().get()
|
||||
val chapterSwipeStartAction = libraryPreferences.swipeToEndAction.get()
|
||||
val chapterSwipeEndAction = libraryPreferences.swipeToStartAction.get()
|
||||
var autoTrackState = trackPreferences.autoUpdateTrackOnMarkRead.get()
|
||||
|
||||
private val skipFiltered by readerPreferences.skipFiltered().asState(screenModelScope)
|
||||
private val skipFiltered by readerPreferences.skipFiltered.asState(screenModelScope)
|
||||
|
||||
val isUpdateIntervalEnabled =
|
||||
LibraryPreferences.MANGA_OUTSIDE_RELEASE_PERIOD in libraryPreferences.autoUpdateMangaRestrictions().get()
|
||||
LibraryPreferences.MANGA_OUTSIDE_RELEASE_PERIOD in libraryPreferences.autoUpdateMangaRestrictions.get()
|
||||
|
||||
private val selectedPositions: Array<Int> = arrayOf(-1, -1) // first and last selected index in list
|
||||
private val selectedChapterIds: HashSet<Long> = HashSet()
|
||||
@@ -230,7 +230,7 @@ class MangaScreenModel(
|
||||
excludedScanlators = getExcludedScanlators.await(mangaId),
|
||||
isRefreshingData = needRefreshInfo || needRefreshChapter,
|
||||
dialog = null,
|
||||
hideMissingChapters = libraryPreferences.hideMissingChapters().get(),
|
||||
hideMissingChapters = libraryPreferences.hideMissingChapters.get(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ class MangaScreenModel(
|
||||
|
||||
// Now check if user previously set categories, when available
|
||||
val categories = getCategories()
|
||||
val defaultCategoryId = libraryPreferences.defaultCategory().get().toLong()
|
||||
val defaultCategoryId = libraryPreferences.defaultCategory.get().toLong()
|
||||
val defaultCategory = categories.find { it.id == defaultCategoryId }
|
||||
when {
|
||||
// Default category set
|
||||
|
||||
@@ -99,7 +99,7 @@ data class TrackInfoDialogHomeScreen(
|
||||
val context = LocalContext.current
|
||||
val screenModel = rememberScreenModel { Model(mangaId, sourceId) }
|
||||
|
||||
val dateFormat = remember { UiPreferences.dateFormat(Injekt.get<UiPreferences>().dateFormat().get()) }
|
||||
val dateFormat = remember { UiPreferences.dateFormat(Injekt.get<UiPreferences>().dateFormat.get()) }
|
||||
val state by screenModel.state.collectAsState()
|
||||
|
||||
TrackInfoDialogHome(
|
||||
|
||||
@@ -82,8 +82,8 @@ private class MoreScreenModel(
|
||||
preferences: BasePreferences = Injekt.get(),
|
||||
) : ScreenModel {
|
||||
|
||||
var downloadedOnly by preferences.downloadedOnly().asState(screenModelScope)
|
||||
var incognitoMode by preferences.incognitoMode().asState(screenModelScope)
|
||||
var downloadedOnly by preferences.downloadedOnly.asState(screenModelScope)
|
||||
var incognitoMode by preferences.incognitoMode.asState(screenModelScope)
|
||||
|
||||
private var _downloadQueueState: MutableStateFlow<DownloadQueueState> = MutableStateFlow(DownloadQueueState.Stopped)
|
||||
val downloadQueueState: StateFlow<DownloadQueueState> = _downloadQueueState.asStateFlow()
|
||||
|
||||
@@ -24,10 +24,10 @@ class OnboardingScreen : Screen() {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
||||
val shownOnboardingFlow by basePreferences.shownOnboardingFlow().collectAsState()
|
||||
val shownOnboardingFlow by basePreferences.shownOnboardingFlow.collectAsState()
|
||||
|
||||
val finishOnboarding: () -> Unit = {
|
||||
basePreferences.shownOnboardingFlow().set(true)
|
||||
basePreferences.shownOnboardingFlow.set(true)
|
||||
navigator.pop()
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ class ReaderActivity : BaseActivity() {
|
||||
setMenuVisibility(viewModel.state.value.menuVisible)
|
||||
|
||||
// Finish when incognito mode is disabled
|
||||
preferences.incognitoMode().changes()
|
||||
preferences.incognitoMode.changes()
|
||||
.drop(1)
|
||||
.onEach { if (!it) finish() }
|
||||
.launchIn(lifecycleScope)
|
||||
@@ -248,7 +248,7 @@ class ReaderActivity : BaseActivity() {
|
||||
|
||||
private fun ReaderActivityBinding.setComposeOverlay(): Unit = composeOverlay.setComposeContent {
|
||||
val state by viewModel.state.collectAsState()
|
||||
val showPageNumber by readerPreferences.showPageNumber().collectAsState()
|
||||
val showPageNumber by readerPreferences.showPageNumber.collectAsState()
|
||||
val settingsScreenModel = remember {
|
||||
ReaderSettingsScreenModel(
|
||||
readerState = viewModel.state,
|
||||
@@ -304,7 +304,7 @@ class ReaderActivity : BaseActivity() {
|
||||
screenModel = settingsScreenModel,
|
||||
onChange = { stringRes ->
|
||||
menuToggleToast?.cancel()
|
||||
if (!readerPreferences.showReadingMode().get()) {
|
||||
if (!readerPreferences.showReadingMode.get()) {
|
||||
menuToggleToast = toast(stringRes)
|
||||
}
|
||||
},
|
||||
@@ -425,11 +425,11 @@ class ReaderActivity : BaseActivity() {
|
||||
|
||||
@Composable
|
||||
private fun ContentOverlay(state: ReaderViewModel.State) {
|
||||
val flashOnPageChange by readerPreferences.flashOnPageChange().collectAsState()
|
||||
val flashOnPageChange by readerPreferences.flashOnPageChange.collectAsState()
|
||||
|
||||
val colorOverlayEnabled by readerPreferences.colorFilter().collectAsState()
|
||||
val colorOverlay by readerPreferences.colorFilterValue().collectAsState()
|
||||
val colorOverlayMode by readerPreferences.colorFilterMode().collectAsState()
|
||||
val colorOverlayEnabled by readerPreferences.colorFilter.collectAsState()
|
||||
val colorOverlay by readerPreferences.colorFilterValue.collectAsState()
|
||||
val colorOverlayMode by readerPreferences.colorFilterMode.collectAsState()
|
||||
val colorOverlayBlendMode = remember(colorOverlayMode) {
|
||||
ReaderPreferences.ColorFilterMode.getOrNull(colorOverlayMode)?.second
|
||||
}
|
||||
@@ -453,8 +453,8 @@ class ReaderActivity : BaseActivity() {
|
||||
|
||||
val isHttpSource = viewModel.getSource() is HttpSource
|
||||
|
||||
val cropBorderPaged by readerPreferences.cropBorders().collectAsState()
|
||||
val cropBorderWebtoon by readerPreferences.cropBordersWebtoon().collectAsState()
|
||||
val cropBorderPaged by readerPreferences.cropBorders.collectAsState()
|
||||
val cropBorderWebtoon by readerPreferences.cropBordersWebtoon.collectAsState()
|
||||
val isPagerType = ReadingMode.isPagerType(viewModel.getMangaReadingMode())
|
||||
val cropEnabled = if (isPagerType) cropBorderPaged else cropBorderWebtoon
|
||||
|
||||
@@ -508,7 +508,7 @@ class ReaderActivity : BaseActivity() {
|
||||
viewModel.showMenus(visible)
|
||||
if (visible) {
|
||||
windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
|
||||
} else if (readerPreferences.fullscreen().get()) {
|
||||
} else if (readerPreferences.fullscreen.get()) {
|
||||
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
|
||||
}
|
||||
}
|
||||
@@ -535,10 +535,10 @@ class ReaderActivity : BaseActivity() {
|
||||
binding.viewerContainer.removeAllViews()
|
||||
}
|
||||
viewModel.onViewerLoaded(newViewer)
|
||||
updateViewerInset(readerPreferences.fullscreen().get(), readerPreferences.drawUnderCutout().get())
|
||||
updateViewerInset(readerPreferences.fullscreen.get(), readerPreferences.drawUnderCutout.get())
|
||||
binding.viewerContainer.addView(newViewer.getView())
|
||||
|
||||
if (readerPreferences.showReadingMode().get()) {
|
||||
if (readerPreferences.showReadingMode.get()) {
|
||||
showReadingModeToast(viewModel.getMangaReadingMode())
|
||||
}
|
||||
|
||||
@@ -839,7 +839,7 @@ class ReaderActivity : BaseActivity() {
|
||||
* Initializes the reader subscriptions.
|
||||
*/
|
||||
init {
|
||||
readerPreferences.readerTheme().changes()
|
||||
readerPreferences.readerTheme.changes()
|
||||
.onEach { theme ->
|
||||
binding.readerContainer.setBackgroundColor(
|
||||
when (theme) {
|
||||
@@ -852,21 +852,21 @@ class ReaderActivity : BaseActivity() {
|
||||
}
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.displayProfile().changes()
|
||||
preferences.displayProfile.changes()
|
||||
.onEach { setDisplayProfile(it) }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
readerPreferences.keepScreenOn().changes()
|
||||
readerPreferences.keepScreenOn.changes()
|
||||
.onEach(::setKeepScreenOn)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
readerPreferences.customBrightness().changes()
|
||||
readerPreferences.customBrightness.changes()
|
||||
.onEach(::setCustomBrightness)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
combine(
|
||||
readerPreferences.grayscale().changes(),
|
||||
readerPreferences.invertedColors().changes(),
|
||||
readerPreferences.grayscale.changes(),
|
||||
readerPreferences.invertedColors.changes(),
|
||||
) { grayscale, invertedColors -> grayscale to invertedColors }
|
||||
.onEach { (grayscale, invertedColors) ->
|
||||
setLayerPaint(grayscale, invertedColors)
|
||||
@@ -874,8 +874,8 @@ class ReaderActivity : BaseActivity() {
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
combine(
|
||||
readerPreferences.fullscreen().changes(),
|
||||
readerPreferences.drawUnderCutout().changes(),
|
||||
readerPreferences.fullscreen.changes(),
|
||||
readerPreferences.drawUnderCutout.changes(),
|
||||
) { fullscreen, drawUnderCutout -> fullscreen to drawUnderCutout }
|
||||
.onEach { (fullscreen, drawUnderCutout) ->
|
||||
updateViewerInset(fullscreen, drawUnderCutout)
|
||||
@@ -929,7 +929,7 @@ class ReaderActivity : BaseActivity() {
|
||||
*/
|
||||
private fun setCustomBrightness(enabled: Boolean) {
|
||||
if (enabled) {
|
||||
readerPreferences.customBrightnessValue().changes()
|
||||
readerPreferences.customBrightnessValue.changes()
|
||||
.sample(100)
|
||||
.onEach(::setCustomBrightnessValue)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
@@ -169,11 +169,11 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
?: error("Requested chapter of id $chapterId not found in chapter list")
|
||||
|
||||
val chaptersForReader = when {
|
||||
(readerPreferences.skipRead().get() || readerPreferences.skipFiltered().get()) -> {
|
||||
(readerPreferences.skipRead.get() || readerPreferences.skipFiltered.get()) -> {
|
||||
val filteredChapters = chapters.filterNot {
|
||||
when {
|
||||
readerPreferences.skipRead().get() && it.read -> true
|
||||
readerPreferences.skipFiltered().get() -> {
|
||||
readerPreferences.skipRead.get() && it.read -> true
|
||||
readerPreferences.skipFiltered.get() -> {
|
||||
(manga.unreadFilterRaw == Manga.CHAPTER_SHOW_READ && !it.read) ||
|
||||
(manga.unreadFilterRaw == Manga.CHAPTER_SHOW_UNREAD && it.read) ||
|
||||
(
|
||||
@@ -215,14 +215,14 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
val result = chaptersForReader
|
||||
.sortedWith(getChapterSort(manga, sortDescending = false))
|
||||
.run {
|
||||
if (readerPreferences.skipDupe().get()) {
|
||||
if (readerPreferences.skipDupe.get()) {
|
||||
removeDuplicates(selectedChapter)
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
.run {
|
||||
if (basePreferences.downloadedOnly().get()) {
|
||||
if (basePreferences.downloadedOnly.get()) {
|
||||
filterDownloaded(manga)
|
||||
} else {
|
||||
this
|
||||
@@ -235,7 +235,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private val incognitoMode: Boolean by lazy { getIncognitoState.await(manga?.source) }
|
||||
private val downloadAheadAmount = downloadPreferences.autoDownloadWhileReading().get()
|
||||
private val downloadAheadAmount = downloadPreferences.autoDownloadWhileReading.get()
|
||||
|
||||
init {
|
||||
// To save state
|
||||
@@ -492,7 +492,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
if (!isNextChapterDownloaded) return@launchIO
|
||||
|
||||
val chaptersToDownload = getNextChapters.await(manga.id, nextChapter.id!!).run {
|
||||
if (readerPreferences.skipDupe().get()) {
|
||||
if (readerPreferences.skipDupe.get()) {
|
||||
removeDuplicates(nextChapter.toDomainChapter()!!)
|
||||
} else {
|
||||
this
|
||||
@@ -522,7 +522,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
* @param currentChapter current chapter, which is going to be marked as read.
|
||||
*/
|
||||
private suspend fun deleteChapterIfNeeded(currentChapter: ReaderChapter) {
|
||||
val removeAfterReadSlots = downloadPreferences.removeAfterReadSlots().get()
|
||||
val removeAfterReadSlots = downloadPreferences.removeAfterReadSlots.get()
|
||||
if (removeAfterReadSlots == -1) return
|
||||
|
||||
// Determine which chapter should be deleted and enqueue
|
||||
@@ -573,7 +573,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
updateTrackChapterRead(readerChapter)
|
||||
deleteChapterIfNeeded(readerChapter)
|
||||
|
||||
val markDuplicateAsRead = libraryPreferences.markDuplicateReadChapterAsRead().get()
|
||||
val markDuplicateAsRead = libraryPreferences.markDuplicateReadChapterAsRead.get()
|
||||
.contains(LibraryPreferences.MARK_DUPLICATE_CHAPTER_READ_EXISTING)
|
||||
if (!markDuplicateAsRead) return
|
||||
|
||||
@@ -677,7 +677,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
* Returns the viewer position used by this manga or the default one.
|
||||
*/
|
||||
fun getMangaReadingMode(resolveDefault: Boolean = true): Int {
|
||||
val default = readerPreferences.defaultReadingMode().get()
|
||||
val default = readerPreferences.defaultReadingMode.get()
|
||||
val readingMode = ReadingMode.fromPreference(manga?.readingMode?.toInt())
|
||||
return when {
|
||||
resolveDefault && readingMode == ReadingMode.DEFAULT -> default
|
||||
@@ -713,7 +713,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
* Returns the orientation type used by this manga or the default one.
|
||||
*/
|
||||
fun getMangaOrientation(resolveDefault: Boolean = true): Int {
|
||||
val default = readerPreferences.defaultOrientationType().get()
|
||||
val default = readerPreferences.defaultOrientationType.get()
|
||||
val orientation = ReaderOrientation.fromPreference(manga?.readerOrientation?.toInt())
|
||||
return when {
|
||||
resolveDefault && orientation == ReaderOrientation.DEFAULT -> default
|
||||
@@ -749,9 +749,9 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
fun toggleCropBorders(): Boolean {
|
||||
val isPagerType = ReadingMode.isPagerType(getMangaReadingMode())
|
||||
return if (isPagerType) {
|
||||
readerPreferences.cropBorders().toggle()
|
||||
readerPreferences.cropBorders.toggle()
|
||||
} else {
|
||||
readerPreferences.cropBordersWebtoon().toggle()
|
||||
readerPreferences.cropBordersWebtoon.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,7 +818,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
val filename = generateFilename(manga, page)
|
||||
|
||||
// Pictures directory.
|
||||
val relativePath = if (readerPreferences.folderPerManga().get()) {
|
||||
val relativePath = if (readerPreferences.folderPerManga.get()) {
|
||||
DiskUtil.buildValidFilename(
|
||||
manga.title,
|
||||
)
|
||||
@@ -922,7 +922,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
*/
|
||||
private fun updateTrackChapterRead(readerChapter: ReaderChapter) {
|
||||
if (incognitoMode) return
|
||||
if (!trackPreferences.autoUpdateTrack().get()) return
|
||||
if (!trackPreferences.autoUpdateTrack.get()) return
|
||||
|
||||
val manga = manga ?: return
|
||||
val context = Injekt.get<Application>()
|
||||
|
||||
@@ -3,139 +3,173 @@ package eu.kanade.tachiyomi.ui.reader.setting
|
||||
import android.os.Build
|
||||
import androidx.compose.ui.graphics.BlendMode
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import tachiyomi.core.common.preference.Preference
|
||||
import tachiyomi.core.common.preference.PreferenceStore
|
||||
import tachiyomi.core.common.preference.getEnum
|
||||
import tachiyomi.i18n.MR
|
||||
|
||||
class ReaderPreferences(
|
||||
private val preferenceStore: PreferenceStore,
|
||||
preferenceStore: PreferenceStore,
|
||||
) {
|
||||
|
||||
// region General
|
||||
|
||||
fun pageTransitions() = preferenceStore.getBoolean("pref_enable_transitions_key", true)
|
||||
val pageTransitions: Preference<Boolean> = preferenceStore.getBoolean("pref_enable_transitions_key", true)
|
||||
|
||||
fun flashOnPageChange() = preferenceStore.getBoolean("pref_reader_flash", false)
|
||||
val flashOnPageChange: Preference<Boolean> = preferenceStore.getBoolean("pref_reader_flash", false)
|
||||
|
||||
fun flashDurationMillis() = preferenceStore.getInt("pref_reader_flash_duration", MILLI_CONVERSION)
|
||||
val flashDurationMillis: Preference<Int> = preferenceStore.getInt("pref_reader_flash_duration", MILLI_CONVERSION)
|
||||
|
||||
fun flashPageInterval() = preferenceStore.getInt("pref_reader_flash_interval", 1)
|
||||
val flashPageInterval: Preference<Int> = preferenceStore.getInt("pref_reader_flash_interval", 1)
|
||||
|
||||
fun flashColor() = preferenceStore.getEnum("pref_reader_flash_mode", FlashColor.BLACK)
|
||||
val flashColor: Preference<FlashColor> = preferenceStore.getEnum("pref_reader_flash_mode", FlashColor.BLACK)
|
||||
|
||||
fun doubleTapAnimSpeed() = preferenceStore.getInt("pref_double_tap_anim_speed", 500)
|
||||
val doubleTapAnimSpeed: Preference<Int> = preferenceStore.getInt("pref_double_tap_anim_speed", 500)
|
||||
|
||||
fun showPageNumber() = preferenceStore.getBoolean("pref_show_page_number_key", true)
|
||||
val showPageNumber: Preference<Boolean> = preferenceStore.getBoolean("pref_show_page_number_key", true)
|
||||
|
||||
fun showReadingMode() = preferenceStore.getBoolean("pref_show_reading_mode", true)
|
||||
val showReadingMode: Preference<Boolean> = preferenceStore.getBoolean("pref_show_reading_mode", true)
|
||||
|
||||
fun fullscreen() = preferenceStore.getBoolean("fullscreen", true)
|
||||
val fullscreen: Preference<Boolean> = preferenceStore.getBoolean("fullscreen", true)
|
||||
|
||||
fun drawUnderCutout() = preferenceStore.getBoolean("cutout_short", true)
|
||||
val drawUnderCutout: Preference<Boolean> = preferenceStore.getBoolean("cutout_short", true)
|
||||
|
||||
fun keepScreenOn() = preferenceStore.getBoolean("pref_keep_screen_on_key", false)
|
||||
val keepScreenOn: Preference<Boolean> = preferenceStore.getBoolean("pref_keep_screen_on_key", false)
|
||||
|
||||
fun defaultReadingMode() = preferenceStore.getInt(
|
||||
val defaultReadingMode: Preference<Int> = preferenceStore.getInt(
|
||||
"pref_default_reading_mode_key",
|
||||
ReadingMode.RIGHT_TO_LEFT.flagValue,
|
||||
)
|
||||
|
||||
fun defaultOrientationType() = preferenceStore.getInt(
|
||||
val defaultOrientationType: Preference<Int> = preferenceStore.getInt(
|
||||
"pref_default_orientation_type_key",
|
||||
ReaderOrientation.FREE.flagValue,
|
||||
)
|
||||
|
||||
fun webtoonDoubleTapZoomEnabled() = preferenceStore.getBoolean("pref_enable_double_tap_zoom_webtoon", true)
|
||||
val webtoonDoubleTapZoomEnabled: Preference<Boolean> = preferenceStore.getBoolean(
|
||||
"pref_enable_double_tap_zoom_webtoon",
|
||||
true,
|
||||
)
|
||||
|
||||
fun imageScaleType() = preferenceStore.getInt("pref_image_scale_type_key", 1)
|
||||
val imageScaleType: Preference<Int> = preferenceStore.getInt("pref_image_scale_type_key", 1)
|
||||
|
||||
fun zoomStart() = preferenceStore.getInt("pref_zoom_start_key", 1)
|
||||
val zoomStart: Preference<Int> = preferenceStore.getInt("pref_zoom_start_key", 1)
|
||||
|
||||
fun readerTheme() = preferenceStore.getInt("pref_reader_theme_key", 1)
|
||||
val readerTheme: Preference<Int> = preferenceStore.getInt("pref_reader_theme_key", 1)
|
||||
|
||||
fun alwaysShowChapterTransition() = preferenceStore.getBoolean("always_show_chapter_transition", true)
|
||||
val alwaysShowChapterTransition: Preference<Boolean> = preferenceStore.getBoolean(
|
||||
"always_show_chapter_transition",
|
||||
true,
|
||||
)
|
||||
|
||||
fun cropBorders() = preferenceStore.getBoolean("crop_borders", false)
|
||||
val cropBorders: Preference<Boolean> = preferenceStore.getBoolean("crop_borders", false)
|
||||
|
||||
fun navigateToPan() = preferenceStore.getBoolean("navigate_pan", true)
|
||||
val navigateToPan: Preference<Boolean> = preferenceStore.getBoolean("navigate_pan", true)
|
||||
|
||||
fun landscapeZoom() = preferenceStore.getBoolean("landscape_zoom", true)
|
||||
val landscapeZoom: Preference<Boolean> = preferenceStore.getBoolean("landscape_zoom", true)
|
||||
|
||||
fun cropBordersWebtoon() = preferenceStore.getBoolean("crop_borders_webtoon", false)
|
||||
val cropBordersWebtoon: Preference<Boolean> = preferenceStore.getBoolean("crop_borders_webtoon", false)
|
||||
|
||||
fun webtoonSidePadding() = preferenceStore.getInt("webtoon_side_padding", WEBTOON_PADDING_MIN)
|
||||
val webtoonSidePadding: Preference<Int> = preferenceStore.getInt("webtoon_side_padding", WEBTOON_PADDING_MIN)
|
||||
|
||||
fun readerHideThreshold() = preferenceStore.getEnum("reader_hide_threshold", ReaderHideThreshold.LOW)
|
||||
val readerHideThreshold: Preference<ReaderHideThreshold> = preferenceStore.getEnum(
|
||||
"reader_hide_threshold",
|
||||
ReaderHideThreshold.LOW,
|
||||
)
|
||||
|
||||
fun folderPerManga() = preferenceStore.getBoolean("create_folder_per_manga", false)
|
||||
val folderPerManga: Preference<Boolean> = preferenceStore.getBoolean("create_folder_per_manga", false)
|
||||
|
||||
fun skipRead() = preferenceStore.getBoolean("skip_read", false)
|
||||
val skipRead: Preference<Boolean> = preferenceStore.getBoolean("skip_read", false)
|
||||
|
||||
fun skipFiltered() = preferenceStore.getBoolean("skip_filtered", true)
|
||||
val skipFiltered: Preference<Boolean> = preferenceStore.getBoolean("skip_filtered", true)
|
||||
|
||||
fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false)
|
||||
val skipDupe: Preference<Boolean> = preferenceStore.getBoolean("skip_dupe", false)
|
||||
|
||||
fun webtoonDisableZoomOut() = preferenceStore.getBoolean("webtoon_disable_zoom_out", false)
|
||||
val webtoonDisableZoomOut: Preference<Boolean> = preferenceStore.getBoolean("webtoon_disable_zoom_out", false)
|
||||
|
||||
// endregion
|
||||
|
||||
// region Split two page spread
|
||||
// region Split two-page spread
|
||||
|
||||
fun dualPageSplitPaged() = preferenceStore.getBoolean("pref_dual_page_split", false)
|
||||
val dualPageSplitPaged: Preference<Boolean> = preferenceStore.getBoolean("pref_dual_page_split", false)
|
||||
|
||||
fun dualPageInvertPaged() = preferenceStore.getBoolean("pref_dual_page_invert", false)
|
||||
val dualPageInvertPaged: Preference<Boolean> = preferenceStore.getBoolean("pref_dual_page_invert", false)
|
||||
|
||||
fun dualPageSplitWebtoon() = preferenceStore.getBoolean("pref_dual_page_split_webtoon", false)
|
||||
val dualPageSplitWebtoon: Preference<Boolean> = preferenceStore.getBoolean("pref_dual_page_split_webtoon", false)
|
||||
|
||||
fun dualPageInvertWebtoon() = preferenceStore.getBoolean("pref_dual_page_invert_webtoon", false)
|
||||
val dualPageInvertWebtoon: Preference<Boolean> = preferenceStore.getBoolean("pref_dual_page_invert_webtoon", false)
|
||||
|
||||
fun dualPageRotateToFit() = preferenceStore.getBoolean("pref_dual_page_rotate", false)
|
||||
val dualPageRotateToFit: Preference<Boolean> = preferenceStore.getBoolean("pref_dual_page_rotate", false)
|
||||
|
||||
fun dualPageRotateToFitInvert() = preferenceStore.getBoolean("pref_dual_page_rotate_invert", false)
|
||||
val dualPageRotateToFitInvert: Preference<Boolean> = preferenceStore.getBoolean(
|
||||
"pref_dual_page_rotate_invert",
|
||||
false,
|
||||
)
|
||||
|
||||
fun dualPageRotateToFitWebtoon() = preferenceStore.getBoolean("pref_dual_page_rotate_webtoon", false)
|
||||
val dualPageRotateToFitWebtoon: Preference<Boolean> = preferenceStore.getBoolean(
|
||||
"pref_dual_page_rotate_webtoon",
|
||||
false,
|
||||
)
|
||||
|
||||
fun dualPageRotateToFitInvertWebtoon() = preferenceStore.getBoolean("pref_dual_page_rotate_invert_webtoon", false)
|
||||
val dualPageRotateToFitInvertWebtoon: Preference<Boolean> = preferenceStore.getBoolean(
|
||||
"pref_dual_page_rotate_invert_webtoon",
|
||||
false,
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
// region Color filter
|
||||
|
||||
fun customBrightness() = preferenceStore.getBoolean("pref_custom_brightness_key", false)
|
||||
val customBrightness: Preference<Boolean> = preferenceStore.getBoolean("pref_custom_brightness_key", false)
|
||||
|
||||
fun customBrightnessValue() = preferenceStore.getInt("custom_brightness_value", 0)
|
||||
val customBrightnessValue: Preference<Int> = preferenceStore.getInt("custom_brightness_value", 0)
|
||||
|
||||
fun colorFilter() = preferenceStore.getBoolean("pref_color_filter_key", false)
|
||||
val colorFilter: Preference<Boolean> = preferenceStore.getBoolean("pref_color_filter_key", false)
|
||||
|
||||
fun colorFilterValue() = preferenceStore.getInt("color_filter_value", 0)
|
||||
val colorFilterValue: Preference<Int> = preferenceStore.getInt("color_filter_value", 0)
|
||||
|
||||
fun colorFilterMode() = preferenceStore.getInt("color_filter_mode", 0)
|
||||
val colorFilterMode: Preference<Int> = preferenceStore.getInt("color_filter_mode", 0)
|
||||
|
||||
fun grayscale() = preferenceStore.getBoolean("pref_grayscale", false)
|
||||
val grayscale: Preference<Boolean> = preferenceStore.getBoolean("pref_grayscale", false)
|
||||
|
||||
fun invertedColors() = preferenceStore.getBoolean("pref_inverted_colors", false)
|
||||
val invertedColors: Preference<Boolean> = preferenceStore.getBoolean("pref_inverted_colors", false)
|
||||
|
||||
// endregion
|
||||
|
||||
// region Controls
|
||||
|
||||
fun readWithLongTap() = preferenceStore.getBoolean("reader_long_tap", true)
|
||||
val readWithLongTap: Preference<Boolean> = preferenceStore.getBoolean("reader_long_tap", true)
|
||||
|
||||
fun readWithVolumeKeys() = preferenceStore.getBoolean("reader_volume_keys", false)
|
||||
val readWithVolumeKeys: Preference<Boolean> = preferenceStore.getBoolean("reader_volume_keys", false)
|
||||
|
||||
fun readWithVolumeKeysInverted() = preferenceStore.getBoolean("reader_volume_keys_inverted", false)
|
||||
val readWithVolumeKeysInverted: Preference<Boolean> = preferenceStore.getBoolean(
|
||||
"reader_volume_keys_inverted",
|
||||
false,
|
||||
)
|
||||
|
||||
fun navigationModePager() = preferenceStore.getInt("reader_navigation_mode_pager", 0)
|
||||
val navigationModePager: Preference<Int> = preferenceStore.getInt("reader_navigation_mode_pager", 0)
|
||||
|
||||
fun navigationModeWebtoon() = preferenceStore.getInt("reader_navigation_mode_webtoon", 0)
|
||||
val navigationModeWebtoon: Preference<Int> = preferenceStore.getInt("reader_navigation_mode_webtoon", 0)
|
||||
|
||||
fun pagerNavInverted() = preferenceStore.getEnum("reader_tapping_inverted", TappingInvertMode.NONE)
|
||||
val pagerNavInverted: Preference<TappingInvertMode> = preferenceStore.getEnum(
|
||||
"reader_tapping_inverted",
|
||||
TappingInvertMode.NONE,
|
||||
)
|
||||
|
||||
fun webtoonNavInverted() = preferenceStore.getEnum("reader_tapping_inverted_webtoon", TappingInvertMode.NONE)
|
||||
val webtoonNavInverted: Preference<TappingInvertMode> = preferenceStore.getEnum(
|
||||
"reader_tapping_inverted_webtoon",
|
||||
TappingInvertMode.NONE,
|
||||
)
|
||||
|
||||
fun showNavigationOverlayNewUser() = preferenceStore.getBoolean("reader_navigation_overlay_new_user", true)
|
||||
val showNavigationOverlayNewUser: Preference<Boolean> = preferenceStore.getBoolean(
|
||||
"reader_navigation_overlay_new_user",
|
||||
true,
|
||||
)
|
||||
|
||||
fun showNavigationOverlayOnStart() = preferenceStore.getBoolean("reader_navigation_overlay_on_start", false)
|
||||
val showNavigationOverlayOnStart: Preference<Boolean> = preferenceStore.getBoolean(
|
||||
"reader_navigation_overlay_on_start",
|
||||
false,
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ open class ReaderPageImageView @JvmOverloads constructor(
|
||||
) : FrameLayout(context, attrs, defStyleAttrs, defStyleRes) {
|
||||
|
||||
private val alwaysDecodeLongStripWithSSIV by lazy {
|
||||
Injekt.get<BasePreferences>().alwaysDecodeLongStripWithSSIV().get()
|
||||
Injekt.get<BasePreferences>().alwaysDecodeLongStripWithSSIV.get()
|
||||
}
|
||||
|
||||
private var pageView: View? = null
|
||||
|
||||
@@ -46,30 +46,30 @@ abstract class ViewerConfig(readerPreferences: ReaderPreferences, private val sc
|
||||
protected set
|
||||
|
||||
init {
|
||||
readerPreferences.readWithLongTap()
|
||||
readerPreferences.readWithLongTap
|
||||
.register({ longTapEnabled = it })
|
||||
|
||||
readerPreferences.pageTransitions()
|
||||
readerPreferences.pageTransitions
|
||||
.register({ usePageTransitions = it })
|
||||
|
||||
readerPreferences.doubleTapAnimSpeed()
|
||||
readerPreferences.doubleTapAnimSpeed
|
||||
.register({ doubleTapAnimDuration = it })
|
||||
|
||||
readerPreferences.readWithVolumeKeys()
|
||||
readerPreferences.readWithVolumeKeys
|
||||
.register({ volumeKeysEnabled = it })
|
||||
|
||||
readerPreferences.readWithVolumeKeysInverted()
|
||||
readerPreferences.readWithVolumeKeysInverted
|
||||
.register({ volumeKeysInverted = it })
|
||||
|
||||
readerPreferences.alwaysShowChapterTransition()
|
||||
readerPreferences.alwaysShowChapterTransition
|
||||
.register({ alwaysShowChapterTransition = it })
|
||||
|
||||
forceNavigationOverlay = readerPreferences.showNavigationOverlayNewUser().get()
|
||||
forceNavigationOverlay = readerPreferences.showNavigationOverlayNewUser.get()
|
||||
if (forceNavigationOverlay) {
|
||||
readerPreferences.showNavigationOverlayNewUser().set(false)
|
||||
readerPreferences.showNavigationOverlayNewUser.set(false)
|
||||
}
|
||||
|
||||
readerPreferences.showNavigationOverlayOnStart()
|
||||
readerPreferences.showNavigationOverlayOnStart
|
||||
.register({ navigationOverlayOnStart = it })
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class PagerConfig(
|
||||
readerPreferences: ReaderPreferences = Injekt.get(),
|
||||
) : ViewerConfig(readerPreferences, scope) {
|
||||
|
||||
var theme = readerPreferences.readerTheme().get()
|
||||
var theme = readerPreferences.readerTheme.get()
|
||||
private set
|
||||
|
||||
var automaticBackground = false
|
||||
@@ -49,7 +49,7 @@ class PagerConfig(
|
||||
private set
|
||||
|
||||
init {
|
||||
readerPreferences.readerTheme()
|
||||
readerPreferences.readerTheme
|
||||
.register(
|
||||
{
|
||||
theme = it
|
||||
@@ -58,32 +58,32 @@ class PagerConfig(
|
||||
{ imagePropertyChangedListener?.invoke() },
|
||||
)
|
||||
|
||||
readerPreferences.imageScaleType()
|
||||
readerPreferences.imageScaleType
|
||||
.register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
readerPreferences.zoomStart()
|
||||
readerPreferences.zoomStart
|
||||
.register({ zoomTypeFromPreference(it) }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
readerPreferences.cropBorders()
|
||||
readerPreferences.cropBorders
|
||||
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
readerPreferences.navigateToPan()
|
||||
readerPreferences.navigateToPan
|
||||
.register({ navigateToPan = it })
|
||||
|
||||
readerPreferences.landscapeZoom()
|
||||
readerPreferences.landscapeZoom
|
||||
.register({ landscapeZoom = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
readerPreferences.navigationModePager()
|
||||
readerPreferences.navigationModePager
|
||||
.register({ navigationMode = it }, { updateNavigation(navigationMode) })
|
||||
|
||||
readerPreferences.pagerNavInverted()
|
||||
readerPreferences.pagerNavInverted
|
||||
.register({ tappingInverted = it }, { navigator.invertMode = it })
|
||||
readerPreferences.pagerNavInverted().changes()
|
||||
readerPreferences.pagerNavInverted.changes()
|
||||
.drop(1)
|
||||
.onEach { navigationModeChangedListener?.invoke() }
|
||||
.launchIn(scope)
|
||||
|
||||
readerPreferences.dualPageSplitPaged()
|
||||
readerPreferences.dualPageSplitPaged
|
||||
.register(
|
||||
{ dualPageSplit = it },
|
||||
{
|
||||
@@ -92,16 +92,16 @@ class PagerConfig(
|
||||
},
|
||||
)
|
||||
|
||||
readerPreferences.dualPageInvertPaged()
|
||||
readerPreferences.dualPageInvertPaged
|
||||
.register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
readerPreferences.dualPageRotateToFit()
|
||||
readerPreferences.dualPageRotateToFit
|
||||
.register(
|
||||
{ dualPageRotateToFit = it },
|
||||
{ imagePropertyChangedListener?.invoke() },
|
||||
)
|
||||
|
||||
readerPreferences.dualPageRotateToFitInvert()
|
||||
readerPreferences.dualPageRotateToFitInvert
|
||||
.register(
|
||||
{ dualPageRotateToFitInvert = it },
|
||||
{ imagePropertyChangedListener?.invoke() },
|
||||
|
||||
@@ -42,56 +42,56 @@ class WebtoonConfig(
|
||||
|
||||
var doubleTapZoomChangedListener: ((Boolean) -> Unit)? = null
|
||||
|
||||
val theme = readerPreferences.readerTheme().get()
|
||||
val theme = readerPreferences.readerTheme.get()
|
||||
|
||||
init {
|
||||
readerPreferences.cropBordersWebtoon()
|
||||
readerPreferences.cropBordersWebtoon
|
||||
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
readerPreferences.webtoonSidePadding()
|
||||
readerPreferences.webtoonSidePadding
|
||||
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
readerPreferences.navigationModeWebtoon()
|
||||
readerPreferences.navigationModeWebtoon
|
||||
.register({ navigationMode = it }, { updateNavigation(it) })
|
||||
|
||||
readerPreferences.webtoonNavInverted()
|
||||
readerPreferences.webtoonNavInverted
|
||||
.register({ tappingInverted = it }, { navigator.invertMode = it })
|
||||
readerPreferences.webtoonNavInverted().changes()
|
||||
readerPreferences.webtoonNavInverted.changes()
|
||||
.drop(1)
|
||||
.onEach { navigationModeChangedListener?.invoke() }
|
||||
.launchIn(scope)
|
||||
|
||||
readerPreferences.dualPageSplitWebtoon()
|
||||
readerPreferences.dualPageSplitWebtoon
|
||||
.register({ dualPageSplit = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
readerPreferences.dualPageInvertWebtoon()
|
||||
readerPreferences.dualPageInvertWebtoon
|
||||
.register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
readerPreferences.dualPageRotateToFitWebtoon()
|
||||
readerPreferences.dualPageRotateToFitWebtoon
|
||||
.register(
|
||||
{ dualPageRotateToFit = it },
|
||||
{ imagePropertyChangedListener?.invoke() },
|
||||
)
|
||||
|
||||
readerPreferences.dualPageRotateToFitInvertWebtoon()
|
||||
readerPreferences.dualPageRotateToFitInvertWebtoon
|
||||
.register(
|
||||
{ dualPageRotateToFitInvert = it },
|
||||
{ imagePropertyChangedListener?.invoke() },
|
||||
)
|
||||
|
||||
readerPreferences.webtoonDisableZoomOut()
|
||||
readerPreferences.webtoonDisableZoomOut
|
||||
.register(
|
||||
{ zoomOutDisabled = it },
|
||||
{ zoomPropertyChangedListener?.invoke(it) },
|
||||
)
|
||||
|
||||
readerPreferences.webtoonDoubleTapZoomEnabled()
|
||||
readerPreferences.webtoonDoubleTapZoomEnabled
|
||||
.register(
|
||||
{ doubleTapZoom = it },
|
||||
{ doubleTapZoomChangedListener?.invoke(it) },
|
||||
)
|
||||
|
||||
readerPreferences.readerTheme().changes()
|
||||
readerPreferences.readerTheme.changes()
|
||||
.drop(1)
|
||||
.distinctUntilChanged()
|
||||
.onEach { themeChangedListener?.invoke() }
|
||||
|
||||
@@ -74,7 +74,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
|
||||
private val threshold: Int =
|
||||
Injekt.get<ReaderPreferences>()
|
||||
.readerHideThreshold()
|
||||
.readerHideThreshold
|
||||
.get()
|
||||
.threshold
|
||||
|
||||
|
||||
@@ -85,9 +85,9 @@ class StatsScreenModel(
|
||||
}
|
||||
|
||||
private fun getGlobalUpdateItemCount(libraryManga: List<LibraryManga>): Int {
|
||||
val includedCategories = preferences.updateCategories().get().map { it.toLong() }
|
||||
val excludedCategories = preferences.updateCategoriesExclude().get().map { it.toLong() }
|
||||
val updateRestrictions = preferences.autoUpdateMangaRestrictions().get()
|
||||
val includedCategories = preferences.updateCategories.get().map { it.toLong() }
|
||||
val excludedCategories = preferences.updateCategoriesExclude.get().map { it.toLong() }
|
||||
val updateRestrictions = preferences.autoUpdateMangaRestrictions.get()
|
||||
|
||||
return libraryManga.filter {
|
||||
val included = includedCategories.isEmpty() || it.categories.intersect(includedCategories).isNotEmpty()
|
||||
|
||||
@@ -72,7 +72,7 @@ class UpdatesScreenModel(
|
||||
private val _events: Channel<Event> = Channel(Int.MAX_VALUE)
|
||||
val events: Flow<Event> = _events.receiveAsFlow()
|
||||
|
||||
val lastUpdated by libraryPreferences.lastUpdatedTimestamp().asState(screenModelScope)
|
||||
val lastUpdated by libraryPreferences.lastUpdatedTimestamp.asState(screenModelScope)
|
||||
|
||||
// First and last selected index in list
|
||||
private val selectedPositions: Array<Int> = arrayOf(-1, -1)
|
||||
@@ -415,16 +415,16 @@ class UpdatesScreenModel(
|
||||
}
|
||||
|
||||
fun resetNewUpdatesCount() {
|
||||
libraryPreferences.newUpdatesCount().set(0)
|
||||
libraryPreferences.newUpdatesCount.set(0)
|
||||
}
|
||||
|
||||
private fun getUpdatesItemPreferenceFlow(): Flow<ItemPreferences> {
|
||||
return combine(
|
||||
updatesPreferences.filterDownloaded().changes(),
|
||||
updatesPreferences.filterUnread().changes(),
|
||||
updatesPreferences.filterStarted().changes(),
|
||||
updatesPreferences.filterBookmarked().changes(),
|
||||
updatesPreferences.filterExcludedScanlators().changes(),
|
||||
updatesPreferences.filterDownloaded.changes(),
|
||||
updatesPreferences.filterUnread.changes(),
|
||||
updatesPreferences.filterStarted.changes(),
|
||||
updatesPreferences.filterBookmarked.changes(),
|
||||
updatesPreferences.filterExcludedScanlators.changes(),
|
||||
) { downloaded, unread, started, bookmarked, excludedScanlators ->
|
||||
ItemPreferences(
|
||||
filterDownloaded = downloaded,
|
||||
|
||||
@@ -44,7 +44,7 @@ class CrashLogUtil(
|
||||
return """
|
||||
App ID: ${BuildConfig.APPLICATION_ID}
|
||||
App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE}, ${BuildConfig.BUILD_TIME})
|
||||
Installation ID: ${preferences.installationId().get()}
|
||||
Installation ID: ${preferences.installationId.get()}
|
||||
Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT}; build ${Build.DISPLAY})
|
||||
Device brand: ${Build.BRAND}
|
||||
Device manufacturer: ${Build.MANUFACTURER}
|
||||
|
||||
@@ -107,8 +107,8 @@ fun Context.createFileInCacheDir(name: String): File {
|
||||
fun Context.createReaderThemeContext(): Context {
|
||||
val preferences = Injekt.get<UiPreferences>()
|
||||
val readerPreferences = Injekt.get<ReaderPreferences>()
|
||||
val themeMode = preferences.themeMode().get()
|
||||
val isDarkBackground = when (readerPreferences.readerTheme().get()) {
|
||||
val themeMode = preferences.themeMode.get()
|
||||
val isDarkBackground = when (readerPreferences.readerTheme.get()) {
|
||||
1, 2 -> true // Black, Gray
|
||||
3 -> when (themeMode) { // Automatic bg uses activity background by default
|
||||
ThemeMode.SYSTEM -> applicationContext.isNightMode()
|
||||
@@ -124,7 +124,7 @@ fun Context.createReaderThemeContext(): Context {
|
||||
|
||||
val wrappedContext = ContextThemeWrapper(this, R.style.Theme_Tachiyomi)
|
||||
wrappedContext.applyOverrideConfiguration(overrideConf)
|
||||
ThemingDelegate.getThemeResIds(preferences.appTheme().get(), preferences.themeDarkAmoled().get())
|
||||
ThemingDelegate.getThemeResIds(preferences.appTheme.get(), preferences.themeDarkAmoled.get())
|
||||
.forEach { wrappedContext.theme.applyStyle(it, true) }
|
||||
return wrappedContext
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ fun Configuration.isTabletUi(): Boolean {
|
||||
// TODO: move the logic to `isTabletUi()` when main activity is rewritten in Compose
|
||||
fun Context.prepareTabletUiContext(): Context {
|
||||
val configuration = resources.configuration
|
||||
val expected = when (Injekt.get<UiPreferences>().tabletUiMode().get()) {
|
||||
val expected = when (Injekt.get<UiPreferences>().tabletUiMode.get()) {
|
||||
TabletUiMode.AUTOMATIC ->
|
||||
configuration.smallestScreenWidthDp >= when (configuration.orientation) {
|
||||
Configuration.ORIENTATION_PORTRAIT -> TABLET_UI_MIN_SCREEN_WIDTH_PORTRAIT_DP
|
||||
|
||||
@@ -49,7 +49,7 @@ class TachiyomiTextInputEditText @JvmOverloads constructor(
|
||||
* if [BasePreferences.incognitoMode] is true. Some IMEs may not respect this flag.
|
||||
*/
|
||||
fun EditText.setIncognito(viewScope: CoroutineScope) {
|
||||
Injekt.get<BasePreferences>().incognitoMode().changes()
|
||||
Injekt.get<BasePreferences>().incognitoMode.changes()
|
||||
.onEach {
|
||||
imeOptions = if (it) {
|
||||
imeOptions or EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING
|
||||
|
||||
Reference in New Issue
Block a user