mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor: Completely remove direct usage of SharedPreferences
This commit is contained in:
parent
4a7077a9b5
commit
84e91712c6
23 changed files with 58 additions and 64 deletions
|
@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.util.system.notificationBuilder
|
||||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.*
|
||||||
|
|
||||||
class BackupNotifier(private val context: Context) {
|
class BackupNotifier(private val context: Context) {
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class BackupNotifier(private val context: Context) {
|
||||||
val builder = with(progressNotificationBuilder) {
|
val builder = with(progressNotificationBuilder) {
|
||||||
setContentTitle(context.getString(R.string.restoring_backup))
|
setContentTitle(context.getString(R.string.restoring_backup))
|
||||||
|
|
||||||
if (!preferences.hideNotificationContent()) {
|
if (!preferences.hideNotificationContent().get()) {
|
||||||
setContentText(content)
|
setContentText(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ class DownloadJob(val context: Context, workerParams: WorkerParameters) : Corout
|
||||||
private fun checkConnectivity(): Boolean {
|
private fun checkConnectivity(): Boolean {
|
||||||
return with(applicationContext) {
|
return with(applicationContext) {
|
||||||
if (isOnline()) {
|
if (isOnline()) {
|
||||||
val noWifi = preferences.downloadOnlyOverWifi() && !isConnectedToWifi()
|
val noWifi = preferences.downloadOnlyOverWifi().get() && !isConnectedToWifi()
|
||||||
if (noWifi) {
|
if (noWifi) {
|
||||||
downloadManager.stopDownloads(applicationContext.getString(R.string.no_wifi_connection))
|
downloadManager.stopDownloads(applicationContext.getString(R.string.no_wifi_connection))
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ internal class DownloadNotifier(private val context: Context) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (download != null && !preferences.hideNotificationContent()) {
|
if (download != null && !preferences.hideNotificationContent().get()) {
|
||||||
val title = download.manga.title.chop(15)
|
val title = download.manga.title.chop(15)
|
||||||
val quotedTitle = Pattern.quote(title)
|
val quotedTitle = Pattern.quote(title)
|
||||||
val name = download.chapter.preferredChapterName(context, download.manga, preferences)
|
val name = download.chapter.preferredChapterName(context, download.manga, preferences)
|
||||||
|
@ -138,7 +138,7 @@ internal class DownloadNotifier(private val context: Context) {
|
||||||
context.localeContext.getString(R.string.downloading_progress)
|
context.localeContext.getString(R.string.downloading_progress)
|
||||||
.format(download.downloadedImages, download.pages!!.size)
|
.format(download.downloadedImages, download.pages!!.size)
|
||||||
|
|
||||||
if (preferences.hideNotificationContent()) {
|
if (preferences.hideNotificationContent().get()) {
|
||||||
setContentTitle(downloadingProgressText)
|
setContentTitle(downloadingProgressText)
|
||||||
} else {
|
} else {
|
||||||
val title = download.manga.title.chop(15)
|
val title = download.manga.title.chop(15)
|
||||||
|
|
|
@ -84,7 +84,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
||||||
Notifications.ID_LIBRARY_PROGRESS,
|
Notifications.ID_LIBRARY_PROGRESS,
|
||||||
progressNotificationBuilder
|
progressNotificationBuilder
|
||||||
.setContentTitle("${context.getString(R.string.updating_library)} (${current + 1}/$total)")
|
.setContentTitle("${context.getString(R.string.updating_library)} (${current + 1}/$total)")
|
||||||
.setContentText(if (preferences.hideNotificationContent()) null else manga.title)
|
.setContentText(if (preferences.hideNotificationContent().get()) null else manga.title)
|
||||||
.setProgress(total, current, false)
|
.setProgress(total, current, false)
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
|
@ -176,7 +176,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
||||||
val updates = newUpdates.toMap()
|
val updates = newUpdates.toMap()
|
||||||
GlobalScope.launch {
|
GlobalScope.launch {
|
||||||
val notifications = ArrayList<Pair<Notification, Int>>()
|
val notifications = ArrayList<Pair<Notification, Int>>()
|
||||||
if (!preferences.hideNotificationContent()) {
|
if (!preferences.hideNotificationContent().get()) {
|
||||||
updates.forEach {
|
updates.forEach {
|
||||||
val manga = it.key
|
val manga = it.key
|
||||||
val chapters = it.value
|
val chapters = it.value
|
||||||
|
@ -272,7 +272,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
||||||
updates.size,
|
updates.size,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if (!preferences.hideNotificationContent()) {
|
if (!preferences.hideNotificationContent().get()) {
|
||||||
setStyle(
|
setStyle(
|
||||||
NotificationCompat.BigTextStyle()
|
NotificationCompat.BigTextStyle()
|
||||||
.bigText(
|
.bigText(
|
||||||
|
@ -282,7 +282,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (!preferences.hideNotificationContent()) {
|
} else if (!preferences.hideNotificationContent().get()) {
|
||||||
setContentText(updates.keys.first().title.chop(45))
|
setContentText(updates.keys.first().title.chop(45))
|
||||||
}
|
}
|
||||||
priority = NotificationCompat.PRIORITY_HIGH
|
priority = NotificationCompat.PRIORITY_HIGH
|
||||||
|
|
|
@ -211,7 +211,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||||
val chapter = db.getChapter(it, mangaId).executeAsBlocking() ?: return
|
val chapter = db.getChapter(it, mangaId).executeAsBlocking() ?: return
|
||||||
chapter.read = true
|
chapter.read = true
|
||||||
db.updateChapterProgress(chapter).executeAsBlocking()
|
db.updateChapterProgress(chapter).executeAsBlocking()
|
||||||
if (preferences.removeAfterMarkedAsRead()) {
|
if (preferences.removeAfterMarkedAsRead().get()) {
|
||||||
val sourceManager: SourceManager = Injekt.get()
|
val sourceManager: SourceManager = Injekt.get()
|
||||||
val source = sourceManager.get(manga.source) ?: return
|
val source = sourceManager.get(manga.source) ?: return
|
||||||
downloadManager.deleteChapters(listOf(chapter), manga, source)
|
downloadManager.deleteChapters(listOf(chapter), manga, source)
|
||||||
|
|
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.preference
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
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.core.preference.Preference
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
|
@ -57,9 +56,6 @@ operator fun <T> Preference<Set<T>>.minusAssign(item: Collection<T>) {
|
||||||
|
|
||||||
class PreferencesHelper(val context: Context, val preferenceStore: PreferenceStore) {
|
class PreferencesHelper(val context: Context, val preferenceStore: PreferenceStore) {
|
||||||
|
|
||||||
@Deprecated("Use [preferenceStore] instead")
|
|
||||||
private val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
|
|
||||||
fun getInt(key: String, default: Int) = preferenceStore.getInt(key, default)
|
fun getInt(key: String, default: Int) = preferenceStore.getInt(key, default)
|
||||||
fun getStringPref(key: String, default: String = "") = preferenceStore.getString(key, default)
|
fun getStringPref(key: String, default: String = "") = preferenceStore.getString(key, default)
|
||||||
fun getStringSet(key: String, default: Set<String>) = preferenceStore.getStringSet(key, default)
|
fun getStringSet(key: String, default: Set<String>) = preferenceStore.getStringSet(key, default)
|
||||||
|
@ -71,8 +67,6 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun hasDeniedA11FilePermission() = preferenceStore.getBoolean(Keys.deniedA11FilePermission, false)
|
fun hasDeniedA11FilePermission() = preferenceStore.getBoolean(Keys.deniedA11FilePermission, false)
|
||||||
|
|
||||||
fun clear() = prefs.edit().clear().apply()
|
|
||||||
|
|
||||||
fun nightMode() = preferenceStore.getInt(Keys.nightMode, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
fun nightMode() = preferenceStore.getInt(Keys.nightMode, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||||
|
|
||||||
fun themeDarkAmoled() = preferenceStore.getBoolean(Keys.themeDarkAmoled, false)
|
fun themeDarkAmoled() = preferenceStore.getBoolean(Keys.themeDarkAmoled, false)
|
||||||
|
@ -101,7 +95,7 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun colorFilterMode() = preferenceStore.getInt(Keys.colorFilterMode, 0)
|
fun colorFilterMode() = preferenceStore.getInt(Keys.colorFilterMode, 0)
|
||||||
|
|
||||||
fun defaultReadingMode() = prefs.getInt(Keys.defaultReadingMode, ReadingModeType.RIGHT_TO_LEFT.flagValue)
|
fun defaultReadingMode() = preferenceStore.getInt(Keys.defaultReadingMode, ReadingModeType.RIGHT_TO_LEFT.flagValue)
|
||||||
|
|
||||||
fun defaultOrientationType() = preferenceStore.getInt(Keys.defaultOrientationType, OrientationType.FREE.flagValue)
|
fun defaultOrientationType() = preferenceStore.getInt(Keys.defaultOrientationType, OrientationType.FREE.flagValue)
|
||||||
|
|
||||||
|
@ -164,9 +158,9 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun preloadSize() = preferenceStore.getInt(Keys.preloadSize, 6)
|
fun preloadSize() = preferenceStore.getInt(Keys.preloadSize, 6)
|
||||||
|
|
||||||
fun autoUpdateTrack() = prefs.getBoolean(Keys.autoUpdateTrack, true)
|
fun autoUpdateTrack() = preferenceStore.getBoolean(Keys.autoUpdateTrack, true)
|
||||||
|
|
||||||
fun trackMarkedAsRead() = prefs.getBoolean(Keys.trackMarkedAsRead, false)
|
fun trackMarkedAsRead() = preferenceStore.getBoolean(Keys.trackMarkedAsRead, false)
|
||||||
|
|
||||||
fun trackingsToAddOnline() = preferenceStore.getStringSet(Keys.trackingsToAddOnline, emptySet())
|
fun trackingsToAddOnline() = preferenceStore.getStringSet(Keys.trackingsToAddOnline, emptySet())
|
||||||
|
|
||||||
|
@ -200,7 +194,7 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun appLanguage() = preferenceStore.getString("app_language", "")
|
fun appLanguage() = preferenceStore.getString("app_language", "")
|
||||||
|
|
||||||
fun downloadOnlyOverWifi() = prefs.getBoolean(Keys.downloadOnlyOverWifi, true)
|
fun downloadOnlyOverWifi() = preferenceStore.getBoolean(Keys.downloadOnlyOverWifi, true)
|
||||||
|
|
||||||
fun folderPerManga() = preferenceStore.getBoolean("create_folder_per_manga", false)
|
fun folderPerManga() = preferenceStore.getBoolean("create_folder_per_manga", false)
|
||||||
|
|
||||||
|
@ -215,7 +209,7 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
fun backupInterval() = preferenceStore.getInt(Keys.backupInterval, 0)
|
fun backupInterval() = preferenceStore.getInt(Keys.backupInterval, 0)
|
||||||
fun removeAfterReadSlots() = preferenceStore.getInt(Keys.removeAfterReadSlots, -1)
|
fun removeAfterReadSlots() = preferenceStore.getInt(Keys.removeAfterReadSlots, -1)
|
||||||
|
|
||||||
fun removeAfterMarkedAsRead() = prefs.getBoolean(Keys.removeAfterMarkedAsRead, false)
|
fun removeAfterMarkedAsRead() = preferenceStore.getBoolean(Keys.removeAfterMarkedAsRead, false)
|
||||||
|
|
||||||
fun libraryUpdateInterval() = preferenceStore.getInt(Keys.libraryUpdateInterval, 24)
|
fun libraryUpdateInterval() = preferenceStore.getInt(Keys.libraryUpdateInterval, 24)
|
||||||
|
|
||||||
|
@ -287,11 +281,11 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun autoDownloadWhileReading() = preferenceStore.getInt("auto_download_while_reading", 0)
|
fun autoDownloadWhileReading() = preferenceStore.getInt("auto_download_while_reading", 0)
|
||||||
|
|
||||||
fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -2)
|
fun defaultCategory() = preferenceStore.getInt(Keys.defaultCategory, -2)
|
||||||
|
|
||||||
fun skipRead() = prefs.getBoolean(Keys.skipRead, false)
|
fun skipRead() = preferenceStore.getBoolean(Keys.skipRead, false)
|
||||||
|
|
||||||
fun skipFiltered() = prefs.getBoolean(Keys.skipFiltered, true)
|
fun skipFiltered() = preferenceStore.getBoolean(Keys.skipFiltered, true)
|
||||||
|
|
||||||
fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false)
|
fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false)
|
||||||
|
|
||||||
|
@ -301,7 +295,7 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun secureScreen() = preferenceStore.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() = preferenceStore.getBoolean(Keys.hideNotificationContent, false)
|
||||||
|
|
||||||
fun removeArticles() = preferenceStore.getBoolean(Keys.removeArticles, false)
|
fun removeArticles() = preferenceStore.getBoolean(Keys.removeArticles, false)
|
||||||
|
|
||||||
|
@ -395,13 +389,13 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
// TODO: SourcePref
|
// TODO: SourcePref
|
||||||
fun showNsfwSources() = preferenceStore.getBoolean(Keys.showNsfwSource, true)
|
fun showNsfwSources() = preferenceStore.getBoolean(Keys.showNsfwSource, true)
|
||||||
|
|
||||||
fun themeMangaDetails() = prefs.getBoolean(Keys.themeMangaDetails, true)
|
fun themeMangaDetails() = preferenceStore.getBoolean(Keys.themeMangaDetails, true)
|
||||||
|
|
||||||
fun useLargeToolbar() = preferenceStore.getBoolean("use_large_toolbar", true)
|
fun useLargeToolbar() = preferenceStore.getBoolean("use_large_toolbar", true)
|
||||||
|
|
||||||
fun showSeriesInShortcuts() = prefs.getBoolean(Keys.showSeriesInShortcuts, true)
|
fun showSeriesInShortcuts() = preferenceStore.getBoolean(Keys.showSeriesInShortcuts, true)
|
||||||
fun showSourcesInShortcuts() = prefs.getBoolean(Keys.showSourcesInShortcuts, true)
|
fun showSourcesInShortcuts() = preferenceStore.getBoolean(Keys.showSourcesInShortcuts, true)
|
||||||
fun openChapterInShortcuts() = prefs.getBoolean(Keys.openChapterInShortcuts, true)
|
fun openChapterInShortcuts() = preferenceStore.getBoolean(Keys.openChapterInShortcuts, true)
|
||||||
|
|
||||||
fun incognitoMode() = preferenceStore.getBoolean(Keys.incognitoMode, false)
|
fun incognitoMode() = preferenceStore.getBoolean(Keys.incognitoMode, false)
|
||||||
|
|
||||||
|
@ -409,10 +403,10 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun sideNavMode() = preferenceStore.getInt(Keys.sideNavMode, 0)
|
fun sideNavMode() = preferenceStore.getInt(Keys.sideNavMode, 0)
|
||||||
|
|
||||||
fun appShouldAutoUpdate() = prefs.getInt(Keys.shouldAutoUpdate, AppDownloadInstallJob.ONLY_ON_UNMETERED)
|
fun appShouldAutoUpdate() = preferenceStore.getInt(Keys.shouldAutoUpdate, AppDownloadInstallJob.ONLY_ON_UNMETERED)
|
||||||
|
|
||||||
// TODO: SourcePref
|
// TODO: SourcePref
|
||||||
fun autoUpdateExtensions() = prefs.getInt(Keys.autoUpdateExtensions, AppDownloadInstallJob.ONLY_ON_UNMETERED)
|
fun autoUpdateExtensions() = preferenceStore.getInt(Keys.autoUpdateExtensions, AppDownloadInstallJob.ONLY_ON_UNMETERED)
|
||||||
|
|
||||||
fun filterChapterByRead() = preferenceStore.getInt(Keys.defaultChapterFilterByRead, Manga.SHOW_ALL)
|
fun filterChapterByRead() = preferenceStore.getInt(Keys.defaultChapterFilterByRead, Manga.SHOW_ALL)
|
||||||
|
|
||||||
|
@ -426,7 +420,7 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun chaptersDescAsDefault() = preferenceStore.getBoolean(Keys.chaptersDescAsDefault, true)
|
fun chaptersDescAsDefault() = preferenceStore.getBoolean(Keys.chaptersDescAsDefault, true)
|
||||||
|
|
||||||
fun sortChapterByAscendingOrDescending() = prefs.getInt(Keys.defaultChapterSortByAscendingOrDescending, Manga.CHAPTER_SORT_DESC)
|
fun sortChapterByAscendingOrDescending() = preferenceStore.getInt(Keys.defaultChapterSortByAscendingOrDescending, Manga.CHAPTER_SORT_DESC)
|
||||||
|
|
||||||
fun coverRatios() = preferenceStore.getStringSet(Keys.coverRatios, emptySet())
|
fun coverRatios() = preferenceStore.getStringSet(Keys.coverRatios, emptySet())
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ class AppDownloadInstallJob(private val context: Context, workerParams: WorkerPa
|
||||||
) {
|
) {
|
||||||
return Result.failure()
|
return Result.failure()
|
||||||
}
|
}
|
||||||
if (preferences.appShouldAutoUpdate() == ONLY_ON_UNMETERED &&
|
if (preferences.appShouldAutoUpdate().get() == ONLY_ON_UNMETERED &&
|
||||||
context.connectivityManager.isActiveNetworkMetered
|
context.connectivityManager.isActiveNetworkMetered
|
||||||
) {
|
) {
|
||||||
return Result.retry()
|
return Result.retry()
|
||||||
|
@ -262,7 +262,7 @@ class AppDownloadInstallJob(private val context: Context, workerParams: WorkerPa
|
||||||
.apply {
|
.apply {
|
||||||
if (waitUntilIdle) {
|
if (waitUntilIdle) {
|
||||||
data.putBoolean(IDLE_RUN, true)
|
data.putBoolean(IDLE_RUN, true)
|
||||||
val shouldAutoUpdate = Injekt.get<PreferencesHelper>().appShouldAutoUpdate()
|
val shouldAutoUpdate = Injekt.get<PreferencesHelper>().appShouldAutoUpdate().get()
|
||||||
val constraints = Constraints.Builder()
|
val constraints = Constraints.Builder()
|
||||||
.setRequiredNetworkType(
|
.setRequiredNetworkType(
|
||||||
if (shouldAutoUpdate == ALWAYS) {
|
if (shouldAutoUpdate == ALWAYS) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ class AppUpdateChecker(
|
||||||
}
|
}
|
||||||
if (doExtrasAfterNewUpdate && result is AppUpdateResult.NewUpdate) {
|
if (doExtrasAfterNewUpdate && result is AppUpdateResult.NewUpdate) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
preferences.appShouldAutoUpdate() != AppDownloadInstallJob.NEVER
|
preferences.appShouldAutoUpdate().get() != AppDownloadInstallJob.NEVER
|
||||||
) {
|
) {
|
||||||
AppDownloadInstallJob.start(context, null, false, waitUntilIdle = true)
|
AppDownloadInstallJob.start(context, null, false, waitUntilIdle = true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ class ExtensionInstallerJob(val context: Context, workerParams: WorkerParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showUpdatedNotification && installedExtensions.size > 0) {
|
if (showUpdatedNotification && installedExtensions.size > 0) {
|
||||||
notifier.showUpdatedNotification(installedExtensions, preferences.hideNotificationContent())
|
notifier.showUpdatedNotification(installedExtensions, preferences.hideNotificationContent().get())
|
||||||
}
|
}
|
||||||
if (reRunUpdateCheck || installedExtensions.size != list.size) {
|
if (reRunUpdateCheck || installedExtensions.size != list.size) {
|
||||||
ExtensionUpdateJob.runJobAgain(context, NetworkType.CONNECTED, false)
|
ExtensionUpdateJob.runJobAgain(context, NetworkType.CONNECTED, false)
|
||||||
|
|
|
@ -84,7 +84,7 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
||||||
}
|
}
|
||||||
if (ExtensionManager.canAutoInstallUpdates(true) &&
|
if (ExtensionManager.canAutoInstallUpdates(true) &&
|
||||||
inputData.getBoolean(RUN_AUTO, true) &&
|
inputData.getBoolean(RUN_AUTO, true) &&
|
||||||
preferences.autoUpdateExtensions() != AppDownloadInstallJob.NEVER &&
|
preferences.autoUpdateExtensions().get() != AppDownloadInstallJob.NEVER &&
|
||||||
!ExtensionInstallerJob.isRunning(context) &&
|
!ExtensionInstallerJob.isRunning(context) &&
|
||||||
extensionsInstalledByApp.isNotEmpty()
|
extensionsInstalledByApp.isNotEmpty()
|
||||||
) {
|
) {
|
||||||
|
@ -92,7 +92,7 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
||||||
val libraryServiceRunning = LibraryUpdateJob.isRunning(context)
|
val libraryServiceRunning = LibraryUpdateJob.isRunning(context)
|
||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
preferences.autoUpdateExtensions() == AppDownloadInstallJob.ALWAYS ||
|
preferences.autoUpdateExtensions().get() == AppDownloadInstallJob.ALWAYS ||
|
||||||
!cm.isActiveNetworkMetered
|
!cm.isActiveNetworkMetered
|
||||||
) && !libraryServiceRunning
|
) && !libraryServiceRunning
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1665,7 +1665,7 @@ class LibraryPresenter(
|
||||||
mangaList: HashMap<Manga, List<Chapter>>,
|
mangaList: HashMap<Manga, List<Chapter>>,
|
||||||
markRead: Boolean,
|
markRead: Boolean,
|
||||||
) {
|
) {
|
||||||
if (preferences.removeAfterMarkedAsRead() && markRead) {
|
if (preferences.removeAfterMarkedAsRead().get() && markRead) {
|
||||||
mangaList.forEach { (manga, oldChapters) ->
|
mangaList.forEach { (manga, oldChapters) ->
|
||||||
deleteChapters(manga, oldChapters)
|
deleteChapters(manga, oldChapters)
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ class SearchActivity : MainActivity() {
|
||||||
}
|
}
|
||||||
SHORTCUT_MANGA, SHORTCUT_MANGA_BACK -> {
|
SHORTCUT_MANGA, SHORTCUT_MANGA_BACK -> {
|
||||||
val extras = intent.extras ?: return false
|
val extras = intent.extras ?: return false
|
||||||
if (intent.action == SHORTCUT_MANGA_BACK && preferences.openChapterInShortcuts()) {
|
if (intent.action == SHORTCUT_MANGA_BACK && preferences.openChapterInShortcuts().get()) {
|
||||||
val mangaId = extras.getLong(MangaDetailsController.MANGA_EXTRA)
|
val mangaId = extras.getLong(MangaDetailsController.MANGA_EXTRA)
|
||||||
if (mangaId != 0L) {
|
if (mangaId != 0L) {
|
||||||
val db = Injekt.get<DatabaseHelper>()
|
val db = Injekt.get<DatabaseHelper>()
|
||||||
|
|
|
@ -249,7 +249,7 @@ class MangaDetailsController :
|
||||||
binding.swipeRefresh.isRefreshing = presenter.isLoading
|
binding.swipeRefresh.isRefreshing = presenter.isLoading
|
||||||
binding.swipeRefresh.setOnRefreshListener { presenter.refreshAll() }
|
binding.swipeRefresh.setOnRefreshListener { presenter.refreshAll() }
|
||||||
updateToolbarTitleAlpha()
|
updateToolbarTitleAlpha()
|
||||||
if (presenter.preferences.themeMangaDetails()) {
|
if (presenter.preferences.themeMangaDetails().get()) {
|
||||||
setItemColors()
|
setItemColors()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ class MangaDetailsController :
|
||||||
private fun setAccentColorValue(colorToUse: Int? = null) {
|
private fun setAccentColorValue(colorToUse: Int? = null) {
|
||||||
val context = view?.context ?: return
|
val context = view?.context ?: return
|
||||||
setCoverColorValue(colorToUse)
|
setCoverColorValue(colorToUse)
|
||||||
accentColor = if (presenter.preferences.themeMangaDetails()) {
|
accentColor = if (presenter.preferences.themeMangaDetails().get()) {
|
||||||
(colorToUse ?: manga?.vibrantCoverColor)?.let {
|
(colorToUse ?: manga?.vibrantCoverColor)?.let {
|
||||||
val luminance = ColorUtils.calculateLuminance(it).toFloat()
|
val luminance = ColorUtils.calculateLuminance(it).toFloat()
|
||||||
if (if (!context.isInNightMode()) luminance > 0.4 else luminance <= 0.6) {
|
if (if (!context.isInNightMode()) luminance > 0.4 else luminance <= 0.6) {
|
||||||
|
@ -281,7 +281,7 @@ class MangaDetailsController :
|
||||||
val colorBack = context.getResourceColor(R.attr.background)
|
val colorBack = context.getResourceColor(R.attr.background)
|
||||||
coverColor =
|
coverColor =
|
||||||
(
|
(
|
||||||
if (presenter.preferences.themeMangaDetails()) {
|
if (presenter.preferences.themeMangaDetails().get()) {
|
||||||
(colorToUse ?: manga?.vibrantCoverColor)
|
(colorToUse ?: manga?.vibrantCoverColor)
|
||||||
} else {
|
} else {
|
||||||
ColorUtils.blendARGB(
|
ColorUtils.blendARGB(
|
||||||
|
@ -306,7 +306,7 @@ class MangaDetailsController :
|
||||||
|
|
||||||
private fun setRefreshStyle() {
|
private fun setRefreshStyle() {
|
||||||
with(binding.swipeRefresh) {
|
with(binding.swipeRefresh) {
|
||||||
if (presenter.preferences.themeMangaDetails() && accentColor != null && headerColor != null) {
|
if (presenter.preferences.themeMangaDetails().get() && accentColor != null && headerColor != null) {
|
||||||
val newColor = makeColorFrom(
|
val newColor = makeColorFrom(
|
||||||
hueOf = accentColor!!,
|
hueOf = accentColor!!,
|
||||||
satAndLumOf = context.getResourceColor(R.attr.actionBarTintColor),
|
satAndLumOf = context.getResourceColor(R.attr.actionBarTintColor),
|
||||||
|
@ -321,7 +321,7 @@ class MangaDetailsController :
|
||||||
|
|
||||||
private fun setHeaderColorValue(colorToUse: Int? = null) {
|
private fun setHeaderColorValue(colorToUse: Int? = null) {
|
||||||
val context = view?.context ?: return
|
val context = view?.context ?: return
|
||||||
headerColor = if (presenter.preferences.themeMangaDetails()) {
|
headerColor = if (presenter.preferences.themeMangaDetails().get()) {
|
||||||
(colorToUse ?: manga?.vibrantCoverColor)?.let { color ->
|
(colorToUse ?: manga?.vibrantCoverColor)?.let { color ->
|
||||||
val newColor =
|
val newColor =
|
||||||
makeColorFrom(color, context.getResourceColor(R.attr.colorPrimaryVariant))
|
makeColorFrom(color, context.getResourceColor(R.attr.colorPrimaryVariant))
|
||||||
|
@ -591,7 +591,7 @@ class MangaDetailsController :
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
Palette.from(bitmap).generate {
|
Palette.from(bitmap).generate {
|
||||||
if (it == null) return@generate
|
if (it == null) return@generate
|
||||||
if (presenter.preferences.themeMangaDetails()) {
|
if (presenter.preferences.themeMangaDetails().get()) {
|
||||||
launchUI {
|
launchUI {
|
||||||
view.context.getResourceColor(R.attr.colorSecondary)
|
view.context.getResourceColor(R.attr.colorSecondary)
|
||||||
val vibrantColor = it.getBestColor() ?: return@launchUI
|
val vibrantColor = it.getBestColor() ?: return@launchUI
|
||||||
|
@ -1023,7 +1023,7 @@ class MangaDetailsController :
|
||||||
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
|
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
|
||||||
super.onDismissed(transientBottomBar, event)
|
super.onDismissed(transientBottomBar, event)
|
||||||
if (!undoing && !read) {
|
if (!undoing && !read) {
|
||||||
if (preferences.removeAfterMarkedAsRead()) {
|
if (preferences.removeAfterMarkedAsRead().get()) {
|
||||||
presenter.deleteChapters(listOf(item))
|
presenter.deleteChapters(listOf(item))
|
||||||
}
|
}
|
||||||
updateTrackChapterMarkedAsRead(db, preferences, chapter, manga?.id) {
|
updateTrackChapterMarkedAsRead(db, preferences, chapter, manga?.id) {
|
||||||
|
|
|
@ -536,7 +536,7 @@ class MangaDetailsPresenter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.updateChaptersProgress(selectedChapters).executeAsBlocking()
|
db.updateChaptersProgress(selectedChapters).executeAsBlocking()
|
||||||
if (read && deleteNow && preferences.removeAfterMarkedAsRead()) {
|
if (read && deleteNow && preferences.removeAfterMarkedAsRead().get()) {
|
||||||
deleteChapters(selectedChapters, false)
|
deleteChapters(selectedChapters, false)
|
||||||
}
|
}
|
||||||
getChapters()
|
getChapters()
|
||||||
|
|
|
@ -302,7 +302,7 @@ class MangaHeaderHolder(
|
||||||
chapterBinding.chaptersTitle.text =
|
chapterBinding.chaptersTitle.text =
|
||||||
itemView.resources.getQuantityString(R.plurals.chapters_plural, count, count)
|
itemView.resources.getQuantityString(R.plurals.chapters_plural, count, count)
|
||||||
chapterBinding.filtersText.text = presenter.currentFilters()
|
chapterBinding.filtersText.text = presenter.currentFilters()
|
||||||
if (adapter.preferences.themeMangaDetails()) {
|
if (adapter.preferences.themeMangaDetails().get()) {
|
||||||
val accentColor = adapter.delegate.accentColor() ?: return
|
val accentColor = adapter.delegate.accentColor() ?: return
|
||||||
chapterBinding.filterButton.imageTintList = ColorStateList.valueOf(accentColor)
|
chapterBinding.filterButton.imageTintList = ColorStateList.valueOf(accentColor)
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ class MangaHeaderHolder(
|
||||||
|
|
||||||
if (!manga.initialized) return
|
if (!manga.initialized) return
|
||||||
updateCover(manga)
|
updateCover(manga)
|
||||||
if (adapter.preferences.themeMangaDetails()) {
|
if (adapter.preferences.themeMangaDetails().get()) {
|
||||||
updateColors(false)
|
updateColors(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1224,7 +1224,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noDefault && viewModel.manga?.readingModeType!! > 0 &&
|
if (noDefault && viewModel.manga?.readingModeType!! > 0 &&
|
||||||
viewModel.manga?.readingModeType!! != preferences.defaultReadingMode()
|
viewModel.manga?.readingModeType!! != preferences.defaultReadingMode().get()
|
||||||
) {
|
) {
|
||||||
snackbar = binding.readerLayout.snack(
|
snackbar = binding.readerLayout.snack(
|
||||||
getString(
|
getString(
|
||||||
|
|
|
@ -667,7 +667,7 @@ class ReaderViewModel(
|
||||||
* Returns the viewer position used by this manga or the default one.
|
* Returns the viewer position used by this manga or the default one.
|
||||||
*/
|
*/
|
||||||
fun getMangaReadingMode(): Int {
|
fun getMangaReadingMode(): Int {
|
||||||
val default = preferences.defaultReadingMode()
|
val default = preferences.defaultReadingMode().get()
|
||||||
val manga = manga ?: return default
|
val manga = manga ?: return default
|
||||||
val readerType = manga.defaultReaderType()
|
val readerType = manga.defaultReaderType()
|
||||||
if (manga.viewer_flags == -1) {
|
if (manga.viewer_flags == -1) {
|
||||||
|
@ -955,7 +955,7 @@ class ReaderViewModel(
|
||||||
* will run in a background thread and errors are ignored.
|
* will run in a background thread and errors are ignored.
|
||||||
*/
|
*/
|
||||||
private fun updateTrackChapterAfterReading(readerChapter: ReaderChapter) {
|
private fun updateTrackChapterAfterReading(readerChapter: ReaderChapter) {
|
||||||
if (!preferences.autoUpdateTrack()) return
|
if (!preferences.autoUpdateTrack().get()) return
|
||||||
|
|
||||||
launchIO {
|
launchIO {
|
||||||
val newChapterRead = readerChapter.chapter.chapter_number
|
val newChapterRead = readerChapter.chapter.chapter_number
|
||||||
|
|
|
@ -870,7 +870,7 @@ class RecentsController(bundle: Bundle? = null) :
|
||||||
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
|
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
|
||||||
super.onDismissed(transientBottomBar, event)
|
super.onDismissed(transientBottomBar, event)
|
||||||
if (!undoing && !wasRead) {
|
if (!undoing && !wasRead) {
|
||||||
if (preferences.removeAfterMarkedAsRead()) {
|
if (preferences.removeAfterMarkedAsRead().get()) {
|
||||||
lastChapterId = chapter.id
|
lastChapterId = chapter.id
|
||||||
presenter.deleteChapter(chapter, manga)
|
presenter.deleteChapter(chapter, manga)
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,11 +113,11 @@ class SettingsLibraryController : SettingsLegacyController() {
|
||||||
when (catId) {
|
when (catId) {
|
||||||
-2 -> context.getString(R.string.last_used)
|
-2 -> context.getString(R.string.last_used)
|
||||||
-1 -> context.getString(R.string.always_ask)
|
-1 -> context.getString(R.string.always_ask)
|
||||||
else -> categories.find { it.id == preferences.defaultCategory() }?.name
|
else -> categories.find { it.id == preferences.defaultCategory().get() }?.name
|
||||||
?: context.getString(R.string.last_used)
|
?: context.getString(R.string.last_used)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
summary = categoryName(preferences.defaultCategory())
|
summary = categoryName(preferences.defaultCategory().get())
|
||||||
onChange { newValue ->
|
onChange { newValue ->
|
||||||
summary = categoryName(newValue as Int)
|
summary = categoryName(newValue as Int)
|
||||||
true
|
true
|
||||||
|
|
|
@ -182,7 +182,7 @@ fun Manga.addOrRemoveToFavorites(
|
||||||
}
|
}
|
||||||
|
|
||||||
val categories = db.getCategories().executeAsBlocking()
|
val categories = db.getCategories().executeAsBlocking()
|
||||||
val defaultCategoryId = preferences.defaultCategory()
|
val defaultCategoryId = preferences.defaultCategory().get()
|
||||||
val defaultCategory = categories.find { it.id == defaultCategoryId }
|
val defaultCategory = categories.find { it.id == defaultCategoryId }
|
||||||
val lastUsedCategories = Category.lastCategoriesAddedTo.mapNotNull { catId ->
|
val lastUsedCategories = Category.lastCategoriesAddedTo.mapNotNull { catId ->
|
||||||
categories.find { it.id == catId }
|
categories.find { it.id == catId }
|
||||||
|
|
|
@ -42,14 +42,14 @@ class ChapterFilter(val preferences: PreferencesHelper = Injekt.get(), val downl
|
||||||
fun <T : Chapter> filterChaptersForReader(chapters: List<T>, manga: Manga, selectedChapter: T? = null): List<T> {
|
fun <T : Chapter> filterChaptersForReader(chapters: List<T>, manga: Manga, selectedChapter: T? = null): List<T> {
|
||||||
var filteredChapters = chapters
|
var filteredChapters = chapters
|
||||||
// if filter prefs aren't enabled don't even filter
|
// if filter prefs aren't enabled don't even filter
|
||||||
if (!preferences.skipRead() && !preferences.skipFiltered() && !preferences.skipDupe().get()) {
|
if (!preferences.skipRead().get() && !preferences.skipFiltered().get() && !preferences.skipDupe().get()) {
|
||||||
return filteredChapters
|
return filteredChapters
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.skipRead()) {
|
if (preferences.skipRead().get()) {
|
||||||
filteredChapters = filteredChapters.filter { !it.read }
|
filteredChapters = filteredChapters.filter { !it.read }
|
||||||
}
|
}
|
||||||
if (preferences.skipFiltered()) {
|
if (preferences.skipFiltered().get()) {
|
||||||
filteredChapters = filterChapters(filteredChapters, manga)
|
filteredChapters = filterChapters(filteredChapters, manga)
|
||||||
}
|
}
|
||||||
if (preferences.skipDupe().get()) {
|
if (preferences.skipDupe().get()) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ fun updateTrackChapterMarkedAsRead(
|
||||||
delay: Long = 3000,
|
delay: Long = 3000,
|
||||||
fetchTracks: (suspend () -> Unit)? = null,
|
fetchTracks: (suspend () -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
if (!preferences.trackMarkedAsRead()) return
|
if (!preferences.trackMarkedAsRead().get()) return
|
||||||
mangaId ?: return
|
mangaId ?: return
|
||||||
|
|
||||||
val newChapterRead = newLastChapter?.chapter_number ?: 0f
|
val newChapterRead = newLastChapter?.chapter_number ?: 0f
|
||||||
|
|
|
@ -39,19 +39,19 @@ class MangaShortcutManager(
|
||||||
launchIO {
|
launchIO {
|
||||||
with(TachiyomiWidgetManager()) { context.init() }
|
with(TachiyomiWidgetManager()) { context.init() }
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
|
||||||
if (!preferences.showSeriesInShortcuts() && !preferences.showSourcesInShortcuts()) {
|
if (!preferences.showSeriesInShortcuts().get() && !preferences.showSourcesInShortcuts().get()) {
|
||||||
val shortcutManager = context.getSystemService(ShortcutManager::class.java)
|
val shortcutManager = context.getSystemService(ShortcutManager::class.java)
|
||||||
shortcutManager.removeAllDynamicShortcuts()
|
shortcutManager.removeAllDynamicShortcuts()
|
||||||
return@launchIO
|
return@launchIO
|
||||||
}
|
}
|
||||||
val shortcutManager = context.getSystemService(ShortcutManager::class.java)
|
val shortcutManager = context.getSystemService(ShortcutManager::class.java)
|
||||||
|
|
||||||
val recentManga = if (preferences.showSeriesInShortcuts()) {
|
val recentManga = if (preferences.showSeriesInShortcuts().get()) {
|
||||||
RecentsPresenter.getRecentManga()
|
RecentsPresenter.getRecentManga()
|
||||||
} else {
|
} else {
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
val recentSources = if (preferences.showSourcesInShortcuts()) {
|
val recentSources = if (preferences.showSourcesInShortcuts().get()) {
|
||||||
preferences.lastUsedSources().get().mapNotNull {
|
preferences.lastUsedSources().get().mapNotNull {
|
||||||
val splitS = it.split(":")
|
val splitS = it.split(":")
|
||||||
splitS.first().toLongOrNull()?.let { id ->
|
splitS.first().toLongOrNull()?.let { id ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue