Merge pull request #2130 from 52fisher/master

更新默认Txt目录规则 Txt目录正则页面增加标题示例
pull/2135/head
kunfei 2 years ago committed by GitHub
commit 041bea23f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1680
      app/schemas/io.legado.app.data.AppDatabase/52.json
  2. 74
      app/src/main/assets/defaultData/txtTocRule.json
  3. 5
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  4. 2
      app/src/main/java/io/legado/app/data/entities/TxtTocRule.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleActivity.kt
  6. 1
      app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleAdapter.kt
  7. 13
      app/src/main/res/layout/dialog_toc_regex_edit.xml
  8. 90
      app/src/main/res/layout/item_txt_toc_rule.xml
  9. 5
      app/src/main/res/values-es-rES/strings.xml
  10. 3
      app/src/main/res/values-ja-rJP/strings.xml
  11. 5
      app/src/main/res/values-pt-rBR/strings.xml
  12. 1
      app/src/main/res/values-zh-rHK/strings.xml
  13. 1
      app/src/main/res/values-zh-rTW/strings.xml
  14. 1
      app/src/main/res/values-zh/strings.xml
  15. 1
      app/src/main/res/values/strings.xml

File diff suppressed because it is too large Load Diff

@ -3,21 +3,24 @@
"id": -1,
"enable": true,
"name": "目录(去空白)",
"rule": "(?<=[ \\s])(?:序章|序言|卷首语|扉页|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?![分赛游])|篇(?!张))).{0,30}$",
"rule": "(?<=[ \\s])(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和]))).{0,30}$",
"example":"第一章 假装第一章前面有空白但我不要",
"serialNumber": 0
},
{
"id": -2,
"enable": true,
"name": "目录",
"rule": "^[  \\t]{0,4}(?:序章|序言|卷首语|扉页|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?![分赛游])|篇(?!张))).{0,30}$",
"rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?![分赛游])|篇(?!张))).{0,30}$",
"example":"第一章 标准的粤语就是这样",
"serialNumber": 1
},
{
"id": -3,
"enable": false,
"name": "目录(匹配简介)",
"rule": "(?<=[ \\s])(?:(?:内容|文章)?简介|文案|前言|序章|序言|卷首语|扉页|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?![分赛游])|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$",
"rule": "(?<=[ \\s])(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?![分赛游])|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$",
"example": "简介 老夫诸葛村夫",
"serialNumber": 2
},
{
@ -25,6 +28,7 @@
"enable": false,
"name": "目录(古典、轻小说备用)",
"rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?![分赛游])|回(?![合来事去])|场(?![和合比电是])|话|篇(?!张))).{0,30}$",
"example": "第一章 比上面只多了回和话",
"serialNumber": 3
},
{
@ -32,97 +36,127 @@
"enable": false,
"name": "数字(纯数字标题)",
"rule": "(?<=[ \\s])\\d+\\.?[  \\t]{0,4}$",
"example": "12",
"serialNumber": 4
},
{
"id": -6,
"enable": false,
"name": "大写数字(纯数字标题)",
"rule": "(?<=[ \\s])[〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,12}[  \\t]{0,4}$",
"example": "一百七十",
"serialNumber": 4
},
{
"id": -7,
"enable": true,
"name": "数字 分隔符 标题名称",
"rule": "^[  \\t]{0,4}\\d{1,5}[::,., 、_—\\-].{1,30}$",
"rule": "^[  \\t]{0,4}\\d{1,5}[::,., 、_—\\-].{1,30}$",
"example": "1、这个就是标题",
"serialNumber": 5
},
{
"id": -7,
"id": -8,
"enable": true,
"name": "大写数字 分隔符 标题名称",
"rule": "^[  \\t]{0,4}(?:序章|序言|卷首语|扉页|楔子|正文(?!完|结)|终章|后记|尾声|番外|[〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[ 、_—\\-].{1,30}$",
"rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|[〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[ 、_—\\-].{1,30}$",
"example": "一、只有前面的数字有差别",
"serialNumber": 6
},
{
"id": -8,
"id": -9,
"enable": true,
"name": "正文 标题/序号",
"rule": "^[  \\t]{0,4}正文[  ]{1,4}.{0,20}$",
"example": "正文 我奶常山赵子龙",
"serialNumber": 7
},
{
"id": -9,
"id": -10,
"enable": true,
"name": "Chapter/Section/Part/Episode 序号 标题",
"rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Nn][oO]\\.|[Ee]pisode|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)\\s{0,4}\\d{1,4}.{0,30}$",
"example": "Chapter 1 MyGrandmaIsNB",
"serialNumber": 8
},
{
"id": -10,
"id": -11,
"enable": false,
"name": "Chapter(去简介)",
"rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Nn][Oo]\\.|[Ee]pisode)\\s{0,4}\\d{1,4}.{0,30}$",
"example": "Chapter 1 MyGrandmaIsNB",
"serialNumber": 9
},
{
"id": -11,
"id": -12,
"enable": true,
"name": "特殊符号 序号 标题",
"rule": "(?<=[\\s ])[【〔〖「『〈[\\[](?:第|[Cc]hapter)[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节].{0,20}$",
"example": "【第一章 后面的符号可以没有",
"serialNumber": 10
},
{
"id": -12,
"id": -13,
"enable": false,
"name": "特殊符号 标题(成对)",
"rule": "(?<=[\\s ]{0,4})(?:[\\[〈「『〖〔《(【\\(].{1,30}[\\)】)》〕〗』」〉\\]]?|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$",
"example": "『加个直角引号更专业』",
"serialNumber": 11
},
{
"id": -13,
"id": -14,
"enable":true,
"name": "特殊符号 标题(单个)",
"rule": "(?<=[\\s ]{0,4})(?:[☆★✦✧].{1,30}|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$",
"example": "☆、晋江作者最喜欢的格式",
"serialNumber": 12
},
{
"id": -14,
"id": -15,
"enable": true,
"name": "章/卷 序号 标题",
"rule": "^[ \\t ]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|序言|卷首语|扉页|楔子|正文(?!完|结)|终章|后记|尾声|番外|[卷章][\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[  ]{0,4}.{0,30}$",
"rule": "^[ \\t ]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|[卷章][\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[  ]{0,4}.{0,30}$",
"example": "卷五 开源盛世",
"serialNumber": 13
},
{
"id": -15,
"id": -16,
"enable":false,
"name": "顶格标题",
"rule": "^\\S.{1,20}$",
"example": "不超过20个字顶格写的都是标题",
"serialNumber": 14
},
{
"id": -16,
"id": -17,
"enable":false,
"name": "双标题(前向)",
"rule": "(?m)(?<=[ \\t ]{0,4})第[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$(?=[\\s ]{0,8}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章)",
"example": "第一章 真正的标题并假装换行第一章 这个不要",
"serialNumber": 15
},
{
"id": -17,
"id": -18,
"enable":false,
"name": "双标题(后向)",
"rule": "(?m)(?<=[ \\t ]{0,4}第[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$[\\s ]{0,8})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$",
"example": "第一章 这个标题不要并假装换行第一章真正的标题",
"serialNumber": 16
},
{
"id":-18,
"id":-19,
"enable": true,
"name": "标题 特殊符号 序号",
"name": "书名 括号 序号",
"rule": "^.{1,20}[((][\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[))][  \t]{0,4}$",
"example": "标题后面数字有括号(12)",
"serialNumber": 17
},
{
"id":-20,
"enable": true,
"name": "书名 序号",
"rule": "^.{1,20}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[  \t]{0,4}$",
"example": "标题后面数字没有括号124",
"serialNumber": 18
}
]
]

@ -20,7 +20,7 @@ val appDb by lazy {
}
@Database(
version = 51,
version = 52,
exportSchema = true,
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
@ -35,7 +35,8 @@ val appDb by lazy {
AutoMigration(from = 47, to = 48),
AutoMigration(from = 48, to = 49),
AutoMigration(from = 49, to = 50),
AutoMigration(from = 50, to = 51)
AutoMigration(from = 50, to = 51),
AutoMigration(from = 51, to = 52)
]
)
abstract class AppDatabase : RoomDatabase() {

@ -11,6 +11,7 @@ data class TxtTocRule(
var id: Long = System.currentTimeMillis(),
var name: String = "",
var rule: String = "",
var example: String? = null,
var serialNumber: Int = -1,
var enable: Boolean = true
) {
@ -25,6 +26,7 @@ data class TxtTocRule(
return id == other.id
&& name == other.name
&& rule == other.rule
&& example == other.example
&& serialNumber == other.serialNumber
&& enable == other.enable
}

@ -97,12 +97,14 @@ class TxtTocRuleActivity : VMBaseActivity<ActivityTxtTocRuleBinding, TxtTocRuleV
alertBinding.apply {
tvRuleName.setText(source.name)
tvRuleRegex.setText(source.rule)
tvRuleExample.setText(source.example)
}
customView { alertBinding.root }
okButton {
alertBinding.apply {
source.name = tvRuleName.text.toString()
source.rule = tvRuleRegex.text.toString()
source.example = tvRuleExample.text.toString()
viewModel.save(source)
}
}

@ -45,6 +45,7 @@ class TxtTocRuleAdapter(context: Context, private val callBack: CallBack) :
cbSource.text = item.name
swtEnabled.isChecked = item.enable
cbSource.isChecked = selected.contains(item)
titleExample.text = item.example
} else {
bundle.keySet().map {
when (it) {

@ -34,4 +34,17 @@
</io.legado.app.ui.widget.text.TextInputLayout>
<io.legado.app.ui.widget.text.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/example">
<io.legado.app.lib.theme.view.ThemeEditText
android:id="@+id/tv_rule_example"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" />
</io.legado.app.ui.widget.text.TextInputLayout>
</LinearLayout>

@ -5,47 +5,59 @@
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:orientation="vertical"
android:padding="16dp">
<io.legado.app.lib.theme.view.ThemeCheckBox
android:id="@+id/cb_source"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:singleLine="true"
android:textColor="@color/primaryText"
tools:ignore="TouchTargetSizeCheck,DuplicateSpeakableTextCheck" />
<io.legado.app.lib.theme.view.ThemeSwitch
android:id="@+id/swt_enabled"
android:name="@string/enable"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.legado.app.lib.theme.view.ThemeCheckBox
android:id="@+id/cb_source"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:singleLine="true"
android:textColor="@color/primaryText"
tools:ignore="TouchTargetSizeCheck,DuplicateSpeakableTextCheck" />
<io.legado.app.lib.theme.view.ThemeSwitch
android:id="@+id/swt_enabled"
android:name="@string/enable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
tools:ignore="RtlSymmetry,TouchTargetSizeCheck" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_edit"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/edit"
android:padding="6dp"
android:src="@drawable/ic_edit"
android:tint="@color/primaryText" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_menu_more"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="6dp"
android:src="@drawable/ic_more_vert"
android:tint="@color/primaryText"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<TextView
android:id="@+id/title_example"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
tools:ignore="RtlSymmetry,TouchTargetSizeCheck" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_edit"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/edit"
android:padding="6dp"
android:src="@drawable/ic_edit"
android:tint="@color/primaryText" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_menu_more"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="6dp"
android:src="@drawable/ic_more_vert"
android:tint="@color/primaryText"
tools:ignore="RtlHardcoded" />
android:textSize="12sp" />
</LinearLayout>

@ -333,7 +333,7 @@
<string name="tip_margin_change">Ajuste de margen</string>
<string name="allow_update">Activar actualizaciones</string>
<string name="disable_update">Desactivar actualizaciones</string>
<string name="split_long_chapter">拆分超长章节</string>
<string name="split_long_chapter">Dividir secciones largas</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">Invertir</string>
<string name="search_book_key">Buscar libro por nombre o autor</string>
@ -970,7 +970,7 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<string name="all_bookmark">Todos los marcadores</string>
<string name="change_source_batch">批量换源</string>
<string name="book_type_different">书籍类型不一样</string>
<string name="soure_change_source">是否确认换源</string>
@ -1006,4 +1006,5 @@
<string name="page_touch_slop_title">滑动翻页阈值</string>
<string name="page_touch_slop_dialog_title">滑动翻页阈值(0 = 系统默认值)</string>
<string name="page_touch_slop_summary">滑动多长距离才会触发滑动翻页(系统默认值 %s px)</string>
<string name="example">Ejemplo</string>
</resources>

@ -973,7 +973,7 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<string name="all_bookmark">すべてのブックマーク</string>
<string name="change_source_batch">批量换源</string>
<string name="book_type_different">书籍类型不一样</string>
<string name="soure_change_source">是否确认换源</string>
@ -1009,4 +1009,5 @@
<string name="page_touch_slop_title">滑动翻页阈值</string>
<string name="page_touch_slop_dialog_title">滑动翻页阈值(0 = 系统默认值)</string>
<string name="page_touch_slop_summary">滑动多长距离才会触发滑动翻页(系统默认值 %s px)</string>
<string name="example"></string>
</resources>

@ -924,7 +924,7 @@
<string name="select_book_folder">选择保存书籍的文件夹</string>
<string name="user_agent">用户代理</string>
<string name="bg_alpha">背景透明度</string>
<string name="split_long_chapter">拆分超长章节</string>
<string name="split_long_chapter">Dividir capítulos longos</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<!-- check source config string -->
@ -973,7 +973,7 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<string name="all_bookmark">Todos os marcadores</string>
<string name="change_source_batch">批量换源</string>
<string name="book_type_different">书籍类型不一样</string>
<string name="soure_change_source">是否确认换源</string>
@ -1009,4 +1009,5 @@
<string name="page_touch_slop_title">滑动翻页阈值</string>
<string name="page_touch_slop_dialog_title">滑动翻页阈值(0 = 系统默认值)</string>
<string name="page_touch_slop_summary">滑动多长距离才会触发滑动翻页(系统默认值 %s px)</string>
<string name="example">Exemplo</string>
</resources>

@ -1006,4 +1006,5 @@
<string name="page_touch_slop_title">滑动翻页阈值</string>
<string name="page_touch_slop_dialog_title">滑动翻页阈值(0 = 系统默认值)</string>
<string name="page_touch_slop_summary">滑动多长距离才会触发滑动翻页(系统默认值 %s px)</string>
<string name="example">示例</string>
</resources>

@ -1008,4 +1008,5 @@
<string name="page_touch_slop_title">滑动翻页阈值</string>
<string name="page_touch_slop_dialog_title">滑动翻页阈值(0 = 系统默认值)</string>
<string name="page_touch_slop_summary">滑动多长距离才会触发滑动翻页(系统默认值 %s px)</string>
<string name="example">示例</string>
</resources>

@ -1008,4 +1008,5 @@
<string name="page_touch_slop_title">滑动翻页阈值</string>
<string name="page_touch_slop_dialog_title">滑动翻页阈值(0 = 系统默认值)</string>
<string name="page_touch_slop_summary">滑动多长距离才会触发滑动翻页(系统默认值 %s px)</string>
<string name="example">示例</string>
</resources>

@ -660,6 +660,7 @@
<string name="import_default_rule">Import default rules</string>
<string name="name">Name</string>
<string name="regex">Regex</string>
<string name="example">Example</string>
<string name="more_menu">More menu</string>
<string name="reduce">Minus</string>
<string name="plus">Plus</string>

Loading…
Cancel
Save