From ac0596a53d74561ad5174db1938c16049a65dd18 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 20 Mar 2023 08:41:55 -0400 Subject: [PATCH] Revert "Always attempt to split tall images when downloading" This partially reverts commit 2769525b2c12547b8dc29b1209ea3bc5d22f1e3f. Keeps the change to silently ignore spliting errors since it falls back to the original images in those cases. --- .../more/settings/screen/SettingsDownloadScreen.kt | 5 +++++ .../java/eu/kanade/tachiyomi/data/download/Downloader.kt | 2 ++ .../tachiyomi/domain/download/service/DownloadPreferences.kt | 2 ++ i18n/src/main/res/values/strings.xml | 1 + 4 files changed, 10 insertions(+) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt index 36bf6fe8e..fa6b0af2b 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt @@ -55,6 +55,11 @@ object SettingsDownloadScreen : SearchableSettings { pref = downloadPreferences.saveChaptersAsCBZ(), title = stringResource(R.string.save_chapter_as_cbz), ), + Preference.PreferenceItem.SwitchPreference( + pref = downloadPreferences.splitTallImages(), + title = stringResource(R.string.split_tall_images), + subtitle = stringResource(R.string.split_tall_images_summary), + ), getDeleteChaptersGroup( downloadPreferences = downloadPreferences, categories = allCategories, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index d42479e22..fe54e4264 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -495,6 +495,8 @@ class Downloader( } private fun splitTallImageIfNeeded(page: Page, tmpDir: UniFile) { + if (!downloadPreferences.splitTallImages().get()) return + try { val filenamePrefix = String.format("%03d", page.number) val imageFile = tmpDir.listFiles()?.firstOrNull { it.name.orEmpty().startsWith(filenamePrefix) } diff --git a/domain/src/main/java/tachiyomi/domain/download/service/DownloadPreferences.kt b/domain/src/main/java/tachiyomi/domain/download/service/DownloadPreferences.kt index 060963028..cc930cf51 100644 --- a/domain/src/main/java/tachiyomi/domain/download/service/DownloadPreferences.kt +++ b/domain/src/main/java/tachiyomi/domain/download/service/DownloadPreferences.kt @@ -14,6 +14,8 @@ class DownloadPreferences( fun saveChaptersAsCBZ() = preferenceStore.getBoolean("save_chapter_as_cbz", true) + fun splitTallImages() = preferenceStore.getBoolean("split_tall_images", false) + fun autoDownloadWhileReading() = preferenceStore.getInt("auto_download_while_reading", 0) fun removeAfterReadSlots() = preferenceStore.getInt("remove_after_read_slots", -1) diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index b6da8239f..78ed4d872 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -443,6 +443,7 @@ Only works on entries in library and if the current chapter plus the next one are already downloaded Save as CBZ archive + Split tall images Improves reader performance