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 9fed01921..038a6c8b0 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 @@ -1,5 +1,6 @@ package io.legado.app.ui.book.cache +import android.annotation.SuppressLint import android.os.Bundle import android.view.Menu import android.view.MenuItem @@ -44,6 +45,7 @@ class CacheActivity : VMBaseActivity() override val viewModel by viewModels() private val exportBookPathKey = "exportBookPath" + private val exportTypes = arrayListOf("txt", "epub") lateinit var adapter: CacheAdapter private var booksFlowJob: Job? = null private var menu: Menu? = null @@ -91,6 +93,10 @@ class CacheActivity : VMBaseActivity() override fun onMenuOpened(featureId: Int, menu: Menu): Boolean { menu.findItem(R.id.menu_enable_replace)?.isChecked = AppConfig.exportUseReplace menu.findItem(R.id.menu_export_web_dav)?.isChecked = AppConfig.exportToWebDav + menu.findItem(R.id.menu_export_type)?.title = + "${getString(R.string.export_type)}(${getTypeName()})" + menu.findItem(R.id.menu_export_charset)?.title = + "${getString(R.string.export_charset)}(${AppConfig.exportCharset})" return super.onMenuOpened(featureId, menu) } @@ -173,6 +179,7 @@ class CacheActivity : VMBaseActivity() } } + @SuppressLint("NotifyDataSetChanged") private fun initGroupData() { launch { appDb.bookGroupDao.flowAll().collect { @@ -309,8 +316,14 @@ class CacheActivity : VMBaseActivity() }.show() } + private fun getTypeName(): String { + return exportTypes.getOrElse(AppConfig.exportType) { + exportTypes[0] + } + } + private fun showExportTypeConfig() { - selector(R.string.export_type, arrayListOf("txt", "epub")) { _, i -> + selector(R.string.export_type, exportTypes) { _, i -> AppConfig.exportType = i } }