添加批量导出

pull/981/head
gedoor 4 years ago
parent 96fb68d083
commit c44da6be9e
  1. 64
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt
  2. 5
      app/src/main/res/menu/book_cache.xml
  3. 1
      app/src/main/res/values-zh-rHK/strings.xml
  4. 1
      app/src/main/res/values-zh-rTW/strings.xml
  5. 1
      app/src/main/res/values-zh/strings.xml
  6. 1
      app/src/main/res/values/strings.xml

@ -115,9 +115,13 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
CacheBook.stop(this@CacheActivity) CacheBook.stop(this@CacheActivity)
} }
} }
R.id.menu_export_all -> exportAll()
R.id.menu_enable_replace -> AppConfig.exportUseReplace = !item.isChecked R.id.menu_enable_replace -> AppConfig.exportUseReplace = !item.isChecked
R.id.menu_export_web_dav -> AppConfig.exportToWebDav = !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_type -> showExportTypeConfig()
R.id.menu_export_charset -> showCharsetConfig() R.id.menu_export_charset -> showCharsetConfig()
R.id.menu_log -> R.id.menu_log ->
@ -212,7 +216,17 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
override fun export(position: Int) { override fun export(position: Int) {
exportPosition = position exportPosition = position
val path = ACache.get(this@CacheActivity).getAsString(exportBookPathKey) 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() selectExportFolder()
} else { } else {
startExport(path) startExport(path)
@ -233,15 +247,45 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
} }
private fun startExport(path: String) { private fun startExport(path: String) {
adapter.getItem(exportPosition)?.let { book -> if (exportPosition == -10) {
Snackbar.make(binding.titleBar, R.string.exporting, Snackbar.LENGTH_INDEFINITE) if (adapter.getItems().isNotEmpty()) {
.show() Snackbar.make(binding.titleBar, R.string.exporting, Snackbar.LENGTH_INDEFINITE)
when (AppConfig.exportType) { .show()
1 -> viewModel.exportEPUB(path, book) { var exportSize = adapter.getItems().size
binding.titleBar.snackbar(it) 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) { } else {
binding.titleBar.snackbar(it) 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)
}
} }
} }
} }

@ -20,6 +20,11 @@
</item> </item>
<item
android:id="@+id/menu_export_all"
android:title="@string/export_all"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_enable_replace" android:id="@+id/menu_enable_replace"
android:title="@string/replace_purify" android:title="@string/replace_purify"

@ -822,5 +822,6 @@
<string name="url_already">此url已订阅</string> <string name="url_already">此url已订阅</string>
<string name="high_brush_title">高刷</string> <string name="high_brush_title">高刷</string>
<string name="high_brush_summary">使用屏幕最高刷新率</string> <string name="high_brush_summary">使用屏幕最高刷新率</string>
<string name="export_all">导出所有</string>
</resources> </resources>

@ -826,5 +826,6 @@
<string name="url_already">此url已訂閱</string> <string name="url_already">此url已訂閱</string>
<string name="high_brush_title">高刷</string> <string name="high_brush_title">高刷</string>
<string name="high_brush_summary">使用螢幕最高刷新率</string> <string name="high_brush_summary">使用螢幕最高刷新率</string>
<string name="export_all">导出所有</string>
</resources> </resources>

@ -826,5 +826,6 @@
<string name="url_already">此url已订阅</string> <string name="url_already">此url已订阅</string>
<string name="high_brush_title">高刷</string> <string name="high_brush_title">高刷</string>
<string name="high_brush_summary">使用屏幕最高刷新率</string> <string name="high_brush_summary">使用屏幕最高刷新率</string>
<string name="export_all">导出所有</string>
</resources> </resources>

@ -827,5 +827,6 @@
<string name="url_already">此url已订阅</string> <string name="url_already">此url已订阅</string>
<string name="high_brush_title">高刷</string> <string name="high_brush_title">高刷</string>
<string name="high_brush_summary">使用屏幕最高刷新率</string> <string name="high_brush_summary">使用屏幕最高刷新率</string>
<string name="export_all">export_all</string>
</resources> </resources>

Loading…
Cancel
Save