mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 13:37:29 +01:00
Add compress to CBZ on download (#6360)
This commit is contained in:
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader.loader
|
||||
|
||||
import android.app.Application
|
||||
import android.net.Uri
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
@@ -10,6 +11,7 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Loader used to load a chapter from the downloaded chapters.
|
||||
@@ -28,6 +30,20 @@ class DownloadPageLoader(
|
||||
* Returns an observable containing the pages found on this downloaded chapter.
|
||||
*/
|
||||
override fun getPages(): Observable<List<ReaderPage>> {
|
||||
val chapterPath = downloadManager.provider.findChapterDir(chapter.chapter, manga, source)
|
||||
return if (chapterPath?.isFile == true) {
|
||||
getPagesFromArchive(chapterPath)
|
||||
} else {
|
||||
getPagesFromDirectory()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPagesFromArchive(chapterPath: UniFile): Observable<List<ReaderPage>> {
|
||||
val loader = ZipPageLoader(File(chapterPath.filePath!!))
|
||||
return loader.getPages()
|
||||
}
|
||||
|
||||
private fun getPagesFromDirectory(): Observable<List<ReaderPage>> {
|
||||
return downloadManager.buildPageList(source, manga, chapter.chapter)
|
||||
.map { pages ->
|
||||
pages.map { page ->
|
||||
|
||||
@@ -68,6 +68,10 @@ class SettingsDownloadController : SettingsController() {
|
||||
titleRes = R.string.connected_to_wifi
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
bindTo(preferences.saveChaptersAsCBZ())
|
||||
titleRes = R.string.save_chapter_as_cbz
|
||||
}
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_delete_chapters
|
||||
|
||||
|
||||
Reference in New Issue
Block a user