|
|
|
@ -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<ActivityCacheBookBinding, CacheViewModel>() |
|
|
|
|
override val viewModel by viewModels<CacheViewModel>() |
|
|
|
|
|
|
|
|
|
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<ActivityCacheBookBinding, CacheViewModel>() |
|
|
|
|
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<ActivityCacheBookBinding, CacheViewModel>() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged") |
|
|
|
|
private fun initGroupData() { |
|
|
|
|
launch { |
|
|
|
|
appDb.bookGroupDao.flowAll().collect { |
|
|
|
@ -309,8 +316,14 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>() |
|
|
|
|
}.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 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|