导出TXT时可不导出章节名

pull/1238/head
fisher 3 years ago
parent 9906247ba7
commit a08b6e3b7c
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 6
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt
  4. 5
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt
  5. 5
      app/src/main/res/menu/book_cache.xml
  6. 1
      app/src/main/res/values-ja-rJP/strings.xml
  7. 1
      app/src/main/res/values-zh-rHK/strings.xml
  8. 1
      app/src/main/res/values-zh-rTW/strings.xml
  9. 1
      app/src/main/res/values-zh/strings.xml
  10. 1
      app/src/main/res/values/strings.xml

@ -47,6 +47,7 @@ object PreferKey {
const val webDavPassword = "web_dav_password" const val webDavPassword = "web_dav_password"
const val webDavCreateDir = "webDavCreateDir" const val webDavCreateDir = "webDavCreateDir"
const val exportToWebDav = "webDavCacheBackup" const val exportToWebDav = "webDavCacheBackup"
const val exportNoChapterName = "exportNoChapterName"
const val exportType = "exportType" const val exportType = "exportType"
const val changeSourceCheckAuthor = "changeSourceCheckAuthor" const val changeSourceCheckAuthor = "changeSourceCheckAuthor"
const val changeSourceLoadToc = "changeSourceLoadToc" const val changeSourceLoadToc = "changeSourceLoadToc"

@ -205,7 +205,11 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
set(value) { set(value) {
appCtx.putPrefBoolean(PreferKey.exportToWebDav, value) appCtx.putPrefBoolean(PreferKey.exportToWebDav, value)
} }
var exportNoChapterName: Boolean
get() = appCtx.getPrefBoolean(PreferKey.exportNoChapterName)
set(value) {
appCtx.putPrefBoolean(PreferKey.exportNoChapterName, value)
}
var exportType: Int var exportType: Int
get() = appCtx.getPrefInt(PreferKey.exportType) get() = appCtx.getPrefInt(PreferKey.exportType)
set(value) { set(value) {

@ -90,6 +90,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
override fun onMenuOpened(featureId: Int, menu: Menu): Boolean { override fun onMenuOpened(featureId: Int, menu: Menu): Boolean {
menu.findItem(R.id.menu_enable_replace)?.isChecked = AppConfig.exportUseReplace menu.findItem(R.id.menu_enable_replace)?.isChecked = AppConfig.exportUseReplace
menu.findItem(R.id.menu_export_no_chapter_name)?.isChecked = AppConfig.exportNoChapterName
menu.findItem(R.id.menu_export_web_dav)?.isChecked = AppConfig.exportToWebDav menu.findItem(R.id.menu_export_web_dav)?.isChecked = AppConfig.exportToWebDav
return super.onMenuOpened(featureId, menu) return super.onMenuOpened(featureId, menu)
} }
@ -121,6 +122,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
} }
R.id.menu_export_all -> exportAll() 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_no_chapter_name -> AppConfig.exportNoChapterName = !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 -> { R.id.menu_export_folder -> {
exportPosition = -1 exportPosition = -1

@ -138,7 +138,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
) )
appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter -> appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter ->
BookHelp.getContent(book, chapter).let { content -> BookHelp.getContent(book, chapter).let { content ->
val content1 = contentProcessor var content1 = contentProcessor
.getContent( .getContent(
book, book,
chapter.title.replace("\\r?\\n".toRegex(), " "), chapter.title.replace("\\r?\\n".toRegex(), " "),
@ -147,6 +147,9 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
useReplace useReplace
) )
.joinToString("\n") .joinToString("\n")
if(AppConfig.exportNoChapterName){
content1 = content.toString()
}
append.invoke("\n\n$content1") append.invoke("\n\n$content1")
} }
} }

@ -36,6 +36,11 @@
android:title="@string/export_to_web_dav" android:title="@string/export_to_web_dav"
android:checkable="true" android:checkable="true"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_export_no_chapter_name"
android:title="@string/export_no_chapter_name"
android:checkable="true"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_export_folder" android:id="@+id/menu_export_folder"

@ -847,4 +847,5 @@
<string name="null_url">url为空</string> <string name="null_url">url为空</string>
<string name="dict">字典</string> <string name="dict">字典</string>
<string name="unknown_error">未知错误</string> <string name="unknown_error">未知错误</string>
<string name="export_no_chapter_name">No export chapter names</string>
</resources> </resources>

@ -845,5 +845,6 @@
<string name="null_url">url为空</string> <string name="null_url">url为空</string>
<string name="dict">字典</string> <string name="dict">字典</string>
<string name="unknown_error">未知错误</string> <string name="unknown_error">未知错误</string>
<string name="export_no_chapter_name">TXT不導出章節名</string>
</resources> </resources>

@ -846,5 +846,6 @@
<string name="null_url">url为空</string> <string name="null_url">url为空</string>
<string name="dict">字典</string> <string name="dict">字典</string>
<string name="unknown_error">未知错误</string> <string name="unknown_error">未知错误</string>
<string name="export_no_chapter_name">TXT不匯出章節名</string>
</resources> </resources>

@ -809,6 +809,7 @@
<string name="background_image">背景图片</string> <string name="background_image">背景图片</string>
<string name="export_folder">导出文件夹</string> <string name="export_folder">导出文件夹</string>
<string name="export_charset">导出编码</string> <string name="export_charset">导出编码</string>
<string name="export_no_chapter_name">TXT不导出章节名</string>
<string name="export_to_web_dav">导出到WebDav</string> <string name="export_to_web_dav">导出到WebDav</string>
<string name="reverse_content">反转内容</string> <string name="reverse_content">反转内容</string>
<string name="debug">调试</string> <string name="debug">调试</string>

@ -848,5 +848,6 @@
<string name="null_url">Null url</string> <string name="null_url">Null url</string>
<string name="dict">字典</string> <string name="dict">字典</string>
<string name="unknown_error">未知错误</string> <string name="unknown_error">未知错误</string>
<string name="export_no_chapter_name">No export chapter names</string>
</resources> </resources>

Loading…
Cancel
Save