Replace preference getter functions with properties (#3091)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user