Merge pull request #1238 from 52fisher/master

导出txt时可不导出章节名称(见详细说明)
pull/1251/head
kunfei 3 years ago committed by GitHub
commit 538cd9cf15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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. 2
      app/src/main/res/values-zh-rHK/strings.xml
  8. 2
      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) {

@ -92,6 +92,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
menu.findItem(R.id.menu_export_type)?.title = menu.findItem(R.id.menu_export_type)?.title =
"${getString(R.string.export_type)}(${getTypeName()})" "${getString(R.string.export_type)}(${getTypeName()})"
@ -127,6 +128,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

@ -139,7 +139,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(), " "),
@ -148,6 +148,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,6 +847,7 @@
<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>
<string name="end">end</string> <string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string> <string name="custom_group_summary">关闭替换分组/开启添加分组</string>
</resources> </resources>

@ -847,6 +847,8 @@
<string name="reset">重置</string> <string name="reset">重置</string>
<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="export_no_chapter_name">TXT不導出章節名</string>
<string name="unknown_error">未知錯誤</string> <string name="unknown_error">未知錯誤</string>
<string name="end">end</string> <string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string> <string name="custom_group_summary">关闭替换分组/开启添加分组</string>

@ -848,6 +848,8 @@
<string name="reset">重設</string> <string name="reset">重設</string>
<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="export_no_chapter_name">TXT不匯出章節名</string>
<string name="unknown_error">未知錯誤</string> <string name="unknown_error">未知錯誤</string>
<string name="end">end</string> <string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string> <string name="custom_group_summary">关闭替换分组/开启添加分组</string>

@ -812,6 +812,7 @@
<string name="background_image_hint">0为停用,启用范围1~25\n半径数值越大,虚化效果越高</string> <string name="background_image_hint">0为停用,启用范围1~25\n半径数值越大,虚化效果越高</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>

@ -851,6 +851,7 @@
<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>
<string name="autobackup_fail">Autobackup failed</string> <string name="autobackup_fail">Autobackup failed</string>
<string name="end">end</string> <string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string> <string name="custom_group_summary">关闭替换分组/开启添加分组</string>

Loading…
Cancel
Save