diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt index fbdae644b..87e52de40 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt @@ -115,9 +115,13 @@ class CacheActivity : VMBaseActivity() CacheBook.stop(this@CacheActivity) } } + R.id.menu_export_all -> exportAll() R.id.menu_enable_replace -> AppConfig.exportUseReplace = !item.isChecked R.id.menu_export_web_dav -> AppConfig.exportToWebDav = !item.isChecked - R.id.menu_export_folder -> export(-1) + R.id.menu_export_folder -> { + exportPosition = -1 + selectExportFolder() + } R.id.menu_export_type -> showExportTypeConfig() R.id.menu_export_charset -> showCharsetConfig() R.id.menu_log -> @@ -212,7 +216,17 @@ class CacheActivity : VMBaseActivity() override fun export(position: Int) { exportPosition = position val path = ACache.get(this@CacheActivity).getAsString(exportBookPathKey) - if (path.isNullOrEmpty() || position < 0) { + if (path.isNullOrEmpty()) { + selectExportFolder() + } else { + startExport(path) + } + } + + private fun exportAll() { + exportPosition = -10 + val path = ACache.get(this@CacheActivity).getAsString(exportBookPathKey) + if (path.isNullOrEmpty()) { selectExportFolder() } else { startExport(path) @@ -233,15 +247,45 @@ class CacheActivity : VMBaseActivity() } private fun startExport(path: String) { - adapter.getItem(exportPosition)?.let { book -> - Snackbar.make(binding.titleBar, R.string.exporting, Snackbar.LENGTH_INDEFINITE) - .show() - when (AppConfig.exportType) { - 1 -> viewModel.exportEPUB(path, book) { - binding.titleBar.snackbar(it) + if (exportPosition == -10) { + if (adapter.getItems().isNotEmpty()) { + Snackbar.make(binding.titleBar, R.string.exporting, Snackbar.LENGTH_INDEFINITE) + .show() + var exportSize = adapter.getItems().size + adapter.getItems().forEach { book -> + when (AppConfig.exportType) { + 1 -> viewModel.exportEPUB(path, book) { + exportSize-- + if (exportSize <= 0) { + binding.titleBar.snackbar(it) + } else { + toastOnUi(it) + } + } + else -> viewModel.export(path, book) { + exportSize-- + if (exportSize <= 0) { + binding.titleBar.snackbar(it) + } else { + toastOnUi(it) + } + } + } } - else -> viewModel.export(path, book) { - binding.titleBar.snackbar(it) + } else { + toastOnUi(R.string.no_book) + } + } else if (exportPosition > 0) { + adapter.getItem(exportPosition)?.let { book -> + Snackbar.make(binding.titleBar, R.string.exporting, Snackbar.LENGTH_INDEFINITE) + .show() + when (AppConfig.exportType) { + 1 -> viewModel.exportEPUB(path, book) { + binding.titleBar.snackbar(it) + } + else -> viewModel.export(path, book) { + binding.titleBar.snackbar(it) + } } } } diff --git a/app/src/main/res/menu/book_cache.xml b/app/src/main/res/menu/book_cache.xml index 42c873c82..71598a744 100644 --- a/app/src/main/res/menu/book_cache.xml +++ b/app/src/main/res/menu/book_cache.xml @@ -20,6 +20,11 @@ + + 此url已订阅 高刷 使用屏幕最高刷新率 + 导出所有 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index de3414c63..1899df105 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -826,5 +826,6 @@ 此url已訂閱 高刷 使用螢幕最高刷新率 + 导出所有 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index e25c7283c..238ed1a32 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -826,5 +826,6 @@ 此url已订阅 高刷 使用屏幕最高刷新率 + 导出所有 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2b302583a..73982b13e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -827,5 +827,6 @@ 此url已订阅 高刷 使用屏幕最高刷新率 + export_all