Always attempt to split tall images when downloading
This commit is contained in:
parent
843e748de3
commit
2769525b2c
@ -55,11 +55,6 @@ 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,
|
||||
|
@ -410,10 +410,8 @@ class Downloader(
|
||||
}
|
||||
|
||||
// When the page is ready, set page path, progress (just in case) and status
|
||||
val success = splitTallImageIfNeeded(page, tmpDir)
|
||||
if (!success) {
|
||||
notifier.onError(context.getString(R.string.download_notifier_split_failed), download.chapter.name, download.manga.title)
|
||||
}
|
||||
splitTallImageIfNeeded(page, tmpDir)
|
||||
|
||||
page.uri = file.uri
|
||||
page.progress = 100
|
||||
page.status = Page.State.READY
|
||||
@ -501,21 +499,18 @@ class Downloader(
|
||||
return ImageUtil.getExtensionFromMimeType(mime)
|
||||
}
|
||||
|
||||
private fun splitTallImageIfNeeded(page: Page, tmpDir: UniFile): Boolean {
|
||||
if (!downloadPreferences.splitTallImages().get()) return true
|
||||
|
||||
private fun splitTallImageIfNeeded(page: Page, tmpDir: UniFile) {
|
||||
try {
|
||||
val filenamePrefix = String.format("%03d", page.number)
|
||||
val imageFile = tmpDir.listFiles()?.firstOrNull { it.name.orEmpty().startsWith(filenamePrefix) }
|
||||
?: throw Error(context.getString(R.string.download_notifier_split_page_not_found, page.number))
|
||||
?: error(context.getString(R.string.download_notifier_split_page_not_found, page.number))
|
||||
|
||||
// If the original page was previously split, then skip
|
||||
if (imageFile.name.orEmpty().startsWith("${filenamePrefix}__")) return true
|
||||
if (imageFile.name.orEmpty().startsWith("${filenamePrefix}__")) return
|
||||
|
||||
return try {
|
||||
ImageUtil.splitTallImage(tmpDir, imageFile, filenamePrefix)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
false
|
||||
logcat(LogPriority.ERROR, e) { "Failed to split downloaded image" }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,6 @@ 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)
|
||||
|
@ -444,7 +444,6 @@
|
||||
</plurals>
|
||||
<string name="download_ahead_info">Only works on entries in library and if the current chapter plus the next one are already downloaded</string>
|
||||
<string name="save_chapter_as_cbz">Save as CBZ archive</string>
|
||||
<string name="split_tall_images">Split tall images</string>
|
||||
<string name="split_tall_images_summary">Improves reader performance</string>
|
||||
|
||||
<!-- Tracking section -->
|
||||
@ -898,7 +897,6 @@
|
||||
<string name="download_notifier_download_paused">Downloads paused</string>
|
||||
<string name="download_notifier_split_page_not_found">Page %d not found while splitting</string>
|
||||
<string name="download_notifier_split_page_path_not_found">Couldn\'t find file path of page %d</string>
|
||||
<string name="download_notifier_split_failed">Couldn\'t split downloaded image</string>
|
||||
<string name="download_notifier_cache_renewal">Checking downloads</string>
|
||||
|
||||
<!-- Notification channels -->
|
||||
|
Loading…
Reference in New Issue
Block a user