pull/1625/head
kunfei 3 years ago
parent 314658b530
commit 02daa1a525
  1. 25
      app/src/main/java/io/legado/app/data/entities/Book.kt
  2. 14
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  3. 8
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  4. 6
      app/src/main/res/menu/book_info.xml
  5. 6
      app/src/main/res/menu/txt_toc_regex.xml
  6. 2
      app/src/main/res/values-es-rES/strings.xml
  7. 2
      app/src/main/res/values-ja-rJP/strings.xml
  8. 2
      app/src/main/res/values-pt-rBR/strings.xml
  9. 2
      app/src/main/res/values-zh-rHK/strings.xml
  10. 2
      app/src/main/res/values-zh-rTW/strings.xml
  11. 2
      app/src/main/res/values-zh/strings.xml
  12. 2
      app/src/main/res/values/strings.xml

@ -154,12 +154,16 @@ data class Book(
return config().useReplaceRule ?: AppConfig.replaceEnableDefault return config().useReplaceRule ?: AppConfig.replaceEnableDefault
} }
fun setReSegment(reSegment: Boolean) {
config().reSegment = reSegment
}
fun getReSegment(): Boolean { fun getReSegment(): Boolean {
return config().reSegment return config().reSegment
} }
fun setReSegment(reSegment: Boolean) { fun setPageAnim(pageAnim: Int?) {
config().reSegment = reSegment config().pageAnim = pageAnim
} }
fun getPageAnim(): Int { fun getPageAnim(): Int {
@ -170,18 +174,14 @@ data class Book(
return pageAnim return pageAnim
} }
fun setPageAnim(pageAnim: Int?) { fun setImageStyle(imageStyle: String?) {
config().pageAnim = pageAnim config().imageStyle = imageStyle
} }
fun getImageStyle(): String? { fun getImageStyle(): String? {
return config().imageStyle return config().imageStyle
} }
fun setImageStyle(imageStyle: String?) {
config().imageStyle = imageStyle
}
fun setTtsEngine(ttsEngine: String?) { fun setTtsEngine(ttsEngine: String?) {
config().ttsEngine = ttsEngine config().ttsEngine = ttsEngine
} }
@ -190,6 +190,14 @@ data class Book(
return config().ttsEngine return config().ttsEngine
} }
fun setSplitLongChapter(limitLongContent: Boolean) {
config().splitLongChapter = limitLongContent
}
fun getSplitLongChapter(): Boolean {
return config().splitLongChapter
}
fun getDelTag(tag: Long): Boolean { fun getDelTag(tag: Long): Boolean {
return config().delTag and tag == tag return config().delTag and tag == tag
} }
@ -288,6 +296,7 @@ data class Book(
var useReplaceRule: Boolean? = null,// 正文使用净化替换规则 var useReplaceRule: Boolean? = null,// 正文使用净化替换规则
var delTag: Long = 0L,//去除标签 var delTag: Long = 0L,//去除标签
var ttsEngine: String? = null, var ttsEngine: String? = null,
var splitLongChapter: Boolean = true
) : Parcelable ) : Parcelable
class Converters { class Converters {

@ -119,6 +119,8 @@ class BookInfoActivity :
override fun onMenuOpened(featureId: Int, menu: Menu): Boolean { override fun onMenuOpened(featureId: Int, menu: Menu): Boolean {
menu.findItem(R.id.menu_can_update)?.isChecked = menu.findItem(R.id.menu_can_update)?.isChecked =
viewModel.bookData.value?.canUpdate ?: true viewModel.bookData.value?.canUpdate ?: true
menu.findItem(R.id.menu_split_long_chapter)?.isChecked =
viewModel.bookData.value?.getSplitLongChapter() ?: true
menu.findItem(R.id.menu_login)?.isVisible = menu.findItem(R.id.menu_login)?.isVisible =
!viewModel.bookSource?.loginUrl.isNullOrBlank() !viewModel.bookSource?.loginUrl.isNullOrBlank()
menu.findItem(R.id.menu_set_source_variable)?.isVisible = menu.findItem(R.id.menu_set_source_variable)?.isVisible =
@ -127,6 +129,8 @@ class BookInfoActivity :
viewModel.bookSource != null viewModel.bookSource != null
menu.findItem(R.id.menu_can_update)?.isVisible = menu.findItem(R.id.menu_can_update)?.isVisible =
viewModel.bookSource != null viewModel.bookSource != null
menu.findItem(R.id.menu_split_long_chapter)?.isVisible =
viewModel.bookData.value?.isLocalTxt() ?: false
return super.onMenuOpened(featureId, menu) return super.onMenuOpened(featureId, menu)
} }
@ -186,6 +190,16 @@ class BookInfoActivity :
} }
R.id.menu_clear_cache -> viewModel.clearCache() R.id.menu_clear_cache -> viewModel.clearCache()
R.id.menu_log -> showDialogFragment<AppLogDialog>() R.id.menu_log -> showDialogFragment<AppLogDialog>()
R.id.menu_split_long_chapter -> {
upLoading(true)
tocChanged = true
viewModel.bookData.value?.let {
it.setSplitLongChapter(!item.isChecked)
viewModel.loadBookInfo(it, false)
}
item.isChecked = !item.isChecked
if (!item.isChecked) longToastOnUi(R.string.need_more_time_load_content)
}
} }
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }

@ -24,6 +24,7 @@ import io.legado.app.databinding.ItemTocRegexBinding
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.backgroundColor
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.model.ReadBook
import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.* import io.legado.app.utils.*
@ -58,6 +59,8 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
binding.toolBar.setTitle(R.string.txt_toc_regex) binding.toolBar.setTitle(R.string.txt_toc_regex)
binding.toolBar.inflateMenu(R.menu.txt_toc_regex) binding.toolBar.inflateMenu(R.menu.txt_toc_regex)
binding.toolBar.menu.applyTint(requireContext()) binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.menu.findItem(R.id.menu_split_long_chapter)
?.isChecked = ReadBook.book?.getSplitLongChapter() == true
binding.toolBar.setOnMenuItemClickListener(this) binding.toolBar.setOnMenuItemClickListener(this)
initView() initView()
initData() initData()
@ -112,6 +115,11 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
R.id.menu_add -> editRule() R.id.menu_add -> editRule()
R.id.menu_default -> viewModel.importDefault() R.id.menu_default -> viewModel.importDefault()
R.id.menu_import -> showImportDialog() R.id.menu_import -> showImportDialog()
R.id.menu_split_long_chapter -> {
ReadBook.book?.setSplitLongChapter(!item.isChecked)
item.isChecked = !item.isChecked
if (!item.isChecked) context?.longToastOnUi(R.string.need_more_time_load_content)
}
} }
return false return false
} }

@ -55,6 +55,12 @@
android:checkable="true" android:checkable="true"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_split_long_chapter"
android:title="@string/split_long_chapter"
android:checkable="true"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_clear_cache" android:id="@+id/menu_clear_cache"
android:title="@string/clear_cache" android:title="@string/clear_cache"

@ -20,4 +20,10 @@
android:title="@string/import_replace_rule_on_line" android:title="@string/import_replace_rule_on_line"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_split_long_chapter"
android:title="@string/split_long_chapter"
android:checkable="true"
app:showAsAction="never" />
</menu> </menu>

@ -332,7 +332,7 @@
<string name="tip_margin_change">Ajuste de margen</string> <string name="tip_margin_change">Ajuste de margen</string>
<string name="allow_update">Activar actualizaciones</string> <string name="allow_update">Activar actualizaciones</string>
<string name="disable_update">Desactivar actualizaciones</string> <string name="disable_update">Desactivar actualizaciones</string>
<string name="limit_content_length">限制正文长度</string> <string name="split_long_chapter">拆分超长章节</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string> <string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">Invertir</string> <string name="revert_selection">Invertir</string>
<string name="search_book_key">Buscar libro por nombre o autor</string> <string name="search_book_key">Buscar libro por nombre o autor</string>

@ -336,7 +336,7 @@
<string name="tip_margin_change">Margin adjustment</string> <string name="tip_margin_change">Margin adjustment</string>
<string name="allow_update">Enable update</string> <string name="allow_update">Enable update</string>
<string name="disable_update">Disable update</string> <string name="disable_update">Disable update</string>
<string name="limit_content_length">限制正文长度</string> <string name="split_long_chapter">拆分超长章节</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string> <string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">Inverse</string> <string name="revert_selection">Inverse</string>
<string name="search_book_key">Search book name/author</string> <string name="search_book_key">Search book name/author</string>

@ -918,7 +918,7 @@
<string name="select_book_folder">选择保存书籍的文件夹</string> <string name="select_book_folder">选择保存书籍的文件夹</string>
<string name="user_agent">用户代理</string> <string name="user_agent">用户代理</string>
<string name="bg_alpha">背景透明度</string> <string name="bg_alpha">背景透明度</string>
<string name="limit_content_length">限制正文长度</string> <string name="split_long_chapter">拆分超长章节</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string> <string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<!-- check source config string --> <!-- check source config string -->

@ -333,7 +333,7 @@
<string name="tip_margin_change">Tip 邊距跟隨邊距調整</string> <string name="tip_margin_change">Tip 邊距跟隨邊距調整</string>
<string name="allow_update">允許更新</string> <string name="allow_update">允許更新</string>
<string name="disable_update">禁止更新</string> <string name="disable_update">禁止更新</string>
<string name="limit_content_length">限制正文长度</string> <string name="split_long_chapter">拆分超长章节</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string> <string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">反選</string> <string name="revert_selection">反選</string>
<string name="search_book_key">搜索書名、作者</string> <string name="search_book_key">搜索書名、作者</string>

@ -335,7 +335,7 @@
<string name="tip_margin_change">Tip邊距跟隨邊距調整</string> <string name="tip_margin_change">Tip邊距跟隨邊距調整</string>
<string name="allow_update">允許更新</string> <string name="allow_update">允許更新</string>
<string name="disable_update">禁止更新</string> <string name="disable_update">禁止更新</string>
<string name="limit_content_length">限制正文长度</string> <string name="split_long_chapter">拆分超长章节</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string> <string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">反選</string> <string name="revert_selection">反選</string>
<string name="search_book_key">搜尋書名、作者</string> <string name="search_book_key">搜尋書名、作者</string>

@ -335,7 +335,7 @@
<string name="tip_margin_change">Tip边距跟随边距调整</string> <string name="tip_margin_change">Tip边距跟随边距调整</string>
<string name="allow_update">允许更新</string> <string name="allow_update">允许更新</string>
<string name="disable_update">禁止更新</string> <string name="disable_update">禁止更新</string>
<string name="limit_content_length">限制正文长度</string> <string name="split_long_chapter">拆分超长章节</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string> <string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">反选</string> <string name="revert_selection">反选</string>
<string name="search_book_key">搜索书名、作者</string> <string name="search_book_key">搜索书名、作者</string>

@ -336,7 +336,7 @@
<string name="tip_margin_change">Margin adjustment</string> <string name="tip_margin_change">Margin adjustment</string>
<string name="allow_update">Enable update</string> <string name="allow_update">Enable update</string>
<string name="disable_update">Disable update</string> <string name="disable_update">Disable update</string>
<string name="limit_content_length">限制正文长度</string> <string name="split_long_chapter">拆分超长章节</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string> <string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">Inverse</string> <string name="revert_selection">Inverse</string>
<string name="search_book_key">Search book name/author</string> <string name="search_book_key">Search book name/author</string>

Loading…
Cancel
Save