Merge branch 'master' into master

pull/1688/head
Xwite 3 years ago committed by GitHub
commit 4a35c78921
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/assets/defaultData/readConfig.json
  2. 5
      app/src/main/assets/updateLog.md
  3. 2
      app/src/main/assets/web/bookshelf/css/detail.508547d2.css
  4. 4
      app/src/main/assets/web/bookshelf/index.html
  5. 0
      app/src/main/assets/web/bookshelf/js/about.3de69a08.js
  6. 2
      app/src/main/assets/web/bookshelf/js/app.cf266357.js
  7. 1
      app/src/main/assets/web/bookshelf/js/detail.4e45d3b6.js
  8. 1
      app/src/main/assets/web/bookshelf/js/detail.fdc516bb.js
  9. 30
      app/src/main/java/io/legado/app/help/RuleComplete.kt
  10. 2
      app/src/main/java/io/legado/app/model/localBook/TextFile.kt
  11. 42
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  12. 2
      app/src/main/java/io/legado/app/ui/book/local/ImportBookViewModel.kt
  13. 10
      app/src/main/res/drawable/ic_sort.xml
  14. 38
      app/src/main/res/menu/import_book.xml
  15. 1
      app/src/main/res/values-es-rES/strings.xml
  16. 1
      app/src/main/res/values-ja-rJP/strings.xml
  17. 1
      app/src/main/res/values-pt-rBR/strings.xml
  18. 3
      app/src/main/res/values-zh-rHK/strings.xml
  19. 1
      app/src/main/res/values-zh-rTW/strings.xml
  20. 1
      app/src/main/res/values-zh/strings.xml
  21. 3
      app/src/main/res/values/strings.xml

@ -26,8 +26,6 @@
"paddingLeft": 22, "paddingLeft": 22,
"paddingRight": 22, "paddingRight": 22,
"paddingTop": 5, "paddingTop": 5,
"pageAnim": 3,
"pageAnimEInk": 3,
"paragraphIndent": "  ", "paragraphIndent": "  ",
"paragraphSpacing": 6, "paragraphSpacing": 6,
"showFooterLine": true, "showFooterLine": true,

@ -11,6 +11,11 @@
* 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。 * 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。
* 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源!
**2022/03/06**
* 导入本地书籍界面添加排序功能
* 修复txt最后一句不显示的bug
**2022/03/04** **2022/03/04**
* 更新cronet: 99.0.4844.48 * 更新cronet: 99.0.4844.48

@ -1,3 +1,3 @@
<!DOCTYPE html><html lang="en" style="padding: 0;height:100%"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="../favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"><title>Legado Bookshelf</title><link href="css/about.af6c5045.css" rel="prefetch"><link href="css/detail.f410d97f.css" rel="prefetch"><link href="js/about.ee7b2200.js" rel="prefetch"><link href="js/detail.4e45d3b6.js" rel="prefetch"><link href="css/app.e4c919b7.css" rel="preload" as="style"><link href="css/chunk-vendors.5f0f4fba.css" rel="preload" as="style"><link href="js/app.ff27f6a9.js" rel="preload" as="script"><link href="js/chunk-vendors.d2b07f8f.js" rel="preload" as="script"><link href="css/chunk-vendors.5f0f4fba.css" rel="stylesheet"><link href="css/app.e4c919b7.css" rel="stylesheet"></head><style>body::-webkit-scrollbar { <!DOCTYPE html><html lang="en" style="padding: 0;height:100%"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="../favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"><title>Legado Bookshelf</title><link href="css/about.af6c5045.css" rel="prefetch"><link href="css/detail.508547d2.css" rel="prefetch"><link href="js/about.3de69a08.js" rel="prefetch"><link href="js/detail.fdc516bb.js" rel="prefetch"><link href="css/app.e4c919b7.css" rel="preload" as="style"><link href="css/chunk-vendors.5f0f4fba.css" rel="preload" as="style"><link href="js/app.cf266357.js" rel="preload" as="script"><link href="js/chunk-vendors.d2b07f8f.js" rel="preload" as="script"><link href="css/chunk-vendors.5f0f4fba.css" rel="stylesheet"><link href="css/app.e4c919b7.css" rel="stylesheet"></head><style>body::-webkit-scrollbar {
display: none; display: none;
}</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.d2b07f8f.js"></script><script src="js/app.ff27f6a9.js"></script></body></html> }</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.d2b07f8f.js"></script><script src="js/app.cf266357.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -10,7 +10,7 @@ object RuleComplete {
private val notComplete = Regex("""^:|^##|\{\{|@js:|<js>|@Json:|\$\.""") private val notComplete = Regex("""^:|^##|\{\{|@js:|<js>|@Json:|\$\.""")
// 修正从图片获取信息 // 修正从图片获取信息
private val fixImgInfo = Regex("""(?<=(^|tag\.|[\+/@>~| &]))img(?<at>\[@?.+\]|\.[-\w]+)?[@/]+text(\(\))?(?<seq>\&{2}|%%|\|{2}|$)""") private val fixImgInfo = Regex("""(?<=(^|tag\.|[\+/@>~| &]))img(?<at>(\[@?.+\]|\.[-\w]+)?)[@/]+text(\(\))?(?<seq>\&{2}|%%|\|{2}|$)""")
private val isXpath= Regex("^//|^@Xpath:") private val isXpath= Regex("^//|^@Xpath:")
@ -34,15 +34,29 @@ object RuleComplete {
if (rules.isNullOrEmpty()||rules.contains(notComplete) || preRule?.contains(notComplete) ?: false){ if (rules.isNullOrEmpty()||rules.contains(notComplete) || preRule?.contains(notComplete) ?: false){
return rules return rules
} }
// 分离正则
val regexSplit=rules.split("##".toRegex(),2)
val cleanedRule=regexSplit[0]
val regexRule=if (regexSplit.size>1) "##"+regexSplit[1] else ""
/** 尾部##分割的正则或由,分割的参数 */
val tailStr: String
/** 分割字符 */
val splitStr:String
/** 用于获取文字时添加的规则 */
val textRule: String val textRule: String
/** 用于获取链接时添加的规则 */
val linkRule: String val linkRule: String
/** 用于获取图片时添加的规则 */
val imgRule: String val imgRule: String
/** 用于获取图片alt属性时添加的规则 */
val imgText: String val imgText: String
// 分离尾部规则
val regexSplit=rules.split("""##|,\{""".toRegex(),2)
val cleanedRule=regexSplit[0]
if (regexSplit.size>1){
splitStr="""##|,\{""".toRegex().find(rules)?.value ?: ""
tailStr = splitStr + regexSplit[1]
}else{
tailStr = ""
}
if (cleanedRule.contains(isXpath)){ if (cleanedRule.contains(isXpath)){
textRule = "//text()\${seq}" textRule = "//text()\${seq}"
linkRule = "//@href\${seq}" linkRule = "//@href\${seq}"
@ -55,9 +69,9 @@ object RuleComplete {
imgText = "img\${at}@alt\${seq}" imgText = "img\${at}@alt\${seq}"
} }
return when (type) { return when (type) {
1 -> needComplete.replace(cleanedRule, textRule).replace(fixImgInfo, imgText) + regexRule 1 -> needComplete.replace(cleanedRule, textRule).replace(fixImgInfo, imgText) + tailStr
2 -> needComplete.replace(cleanedRule, linkRule) + regexRule 2 -> needComplete.replace(cleanedRule, linkRule) + tailStr
3 -> needComplete.replace(cleanedRule, imgRule) + regexRule 3 -> needComplete.replace(cleanedRule, imgRule) + tailStr
else -> rules else -> rules
} }
} }

@ -114,12 +114,14 @@ class TextFile(private val book: Book) {
).also { length = it } > 0 ).also { length = it } > 0
) { ) {
var end = bufferStart + length var end = bufferStart + length
if (end == bufferSize) {
for (i in bufferStart + length - 1 downTo 0) { for (i in bufferStart + length - 1 downTo 0) {
if (buffer[i] == blank) { if (buffer[i] == blank) {
end = i end = i
break break
} }
} }
}
//将数据转换成String, 不能超过length //将数据转换成String, 不能超过length
blockContent = String(buffer, 0, end, charset) blockContent = String(buffer, 0, end, charset)
buffer.copyInto(buffer, 0, end, bufferStart + length) buffer.copyInto(buffer, 0, end, bufferStart + length)

@ -70,11 +70,30 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
return super.onCompatCreateOptionsMenu(menu) return super.onCompatCreateOptionsMenu(menu)
} }
override fun onMenuOpened(featureId: Int, menu: Menu): Boolean {
menu.findItem(R.id.menu_sort_name)?.isChecked = viewModel.sort == 0
menu.findItem(R.id.menu_sort_size)?.isChecked = viewModel.sort == 1
menu.findItem(R.id.menu_sort_time)?.isChecked = viewModel.sort == 2
return super.onMenuOpened(featureId, menu)
}
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_select_folder -> selectFolder.launch() R.id.menu_select_folder -> selectFolder.launch()
R.id.menu_scan_folder -> scanFolder() R.id.menu_scan_folder -> scanFolder()
R.id.menu_import_file_name -> alertImportFileName() R.id.menu_import_file_name -> alertImportFileName()
R.id.menu_sort_name -> {
viewModel.sort = 0
upPath()
}
R.id.menu_sort_size -> {
viewModel.sort = 1
upPath()
}
R.id.menu_sort_time -> {
viewModel.sort = 2
upPath()
}
} }
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }
@ -205,7 +224,28 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
else -> item.name.matches(bookFileRegex) else -> item.name.matches(bookFileRegex)
} }
} }
docList.sortWith(compareBy({ !it.isDir }, { it.name })) when (viewModel.sort) {
2 -> docList.sortWith(
compareBy(
{ !it.isDir },
{ it.date },
{ it.name }
)
)
1 -> docList.sortWith(
compareBy(
{ !it.isDir },
{ it.size },
{ it.name }
)
)
else -> docList.sortWith(
compareBy(
{ !it.isDir },
{ it.name }
)
)
}
withContext(Main) { withContext(Main) {
adapter.setItems(docList) adapter.setItems(docList)
} }

@ -14,6 +14,8 @@ import java.io.File
class ImportBookViewModel(application: Application) : BaseViewModel(application) { class ImportBookViewModel(application: Application) : BaseViewModel(application) {
var sort = 0
fun addToBookshelf(uriList: HashSet<String>, finally: () -> Unit) { fun addToBookshelf(uriList: HashSet<String>, finally: () -> Unit) {
execute { execute {
uriList.forEach { uriList.forEach {

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M14.94,4.66h-4.72l2.36,-2.36zM10.25,19.37h4.66l-2.33,2.33zM6.1,6.27L1.6,17.73h1.84l0.92,-2.45h5.11l0.92,2.45h1.84L7.74,6.27L6.1,6.27zM4.97,13.64l1.94,-5.18 1.94,5.18L4.97,13.64zM15.73,16.14h6.12v1.59h-8.53v-1.29l5.92,-8.56h-5.88v-1.6h8.3v1.26l-5.93,8.6z" />
</vector>

@ -1,12 +1,44 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="AlwaysShowAction">
<item <item
android:id="@+id/menu_select_folder" android:id="@+id/menu_select_folder"
android:title="@string/select_folder"
android:icon="@drawable/ic_folder_open" android:icon="@drawable/ic_folder_open"
app:showAsAction="ifRoom" /> android:title="@string/select_folder"
app:showAsAction="always" />
<item
android:id="@+id/menu_sort"
android:title="@string/sort"
android:icon="@drawable/ic_sort"
app:showAsAction="always">
<menu>
<item
android:id="@+id/menu_sort_name"
android:checkable="true"
android:title="@string/sort_by_name"
app:showAsAction="never" />
<item
android:id="@+id/menu_sort_size"
android:checkable="true"
android:title="@string/sort_by_size"
app:showAsAction="never" />
<item
android:id="@+id/menu_sort_time"
android:checkable="true"
android:title="@string/sort_by_time"
app:showAsAction="never" />
</menu>
</item>
<item <item
android:id="@+id/menu_scan_folder" android:id="@+id/menu_scan_folder"

@ -945,5 +945,6 @@
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string> <string name="copy_all">拷贝所有</string>
<string name="auto_complete">自动补全</string> <string name="auto_complete">自动补全</string>
<string name="sort_by_size">大小排序</string>
<!-- string end --> <!-- string end -->
</resources> </resources>

@ -948,5 +948,6 @@
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string> <string name="copy_all">拷贝所有</string>
<string name="auto_complete">自动补全</string> <string name="auto_complete">自动补全</string>
<string name="sort_by_size">大小排序</string>
<!-- string end --> <!-- string end -->
</resources> </resources>

@ -948,5 +948,6 @@
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string> <string name="copy_all">拷贝所有</string>
<string name="auto_complete">自动补全</string> <string name="auto_complete">自动补全</string>
<string name="sort_by_size">大小排序</string>
<!-- string end --> <!-- string end -->
</resources> </resources>

@ -941,9 +941,10 @@
<string name="edit_content">编辑内容</string> <string name="edit_content">编辑内容</string>
<string name="chapter_change_source">单章换源</string> <string name="chapter_change_source">单章换源</string>
<string name="book_change_source">整书换源</string> <string name="book_change_source">整书换源</string>
<string name="sort_by_time">时间排序</string> <string name="sort_by_time">时间排序</string>
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string> <string name="copy_all">拷贝所有</string>
<string name="auto_complete">自动补全</string> <string name="auto_complete">自动补全</string>
<string name="sort_by_size">大小排序</string>
<!-- string end --> <!-- string end -->
</resources> </resources>

@ -947,5 +947,6 @@
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string> <string name="copy_all">拷贝所有</string>
<string name="auto_complete">自动补全</string> <string name="auto_complete">自动补全</string>
<string name="sort_by_size">大小排序</string>
<!-- string end --> <!-- string end -->
</resources> </resources>

@ -947,5 +947,6 @@
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string> <string name="copy_all">拷贝所有</string>
<string name="auto_complete">自动补全</string> <string name="auto_complete">自动补全</string>
<string name="sort_by_size">大小排序</string>
<!-- string end --> <!-- string end -->
</resources> </resources>

@ -944,9 +944,10 @@
<string name="edit_content">Edit Content</string> <string name="edit_content">Edit Content</string>
<string name="chapter_change_source">单章换源</string> <string name="chapter_change_source">单章换源</string>
<string name="book_change_source">整书换源</string> <string name="book_change_source">整书换源</string>
<string name="sort_by_time">时间排序</string> <string name="sort_by_time">Sort by time</string>
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string> <string name="copy_all">拷贝所有</string>
<string name="auto_complete">自动补全</string> <string name="auto_complete">自动补全</string>
<string name="sort_by_size">Sort by size</string>
<!-- string end --> <!-- string end -->
</resources> </resources>

Loading…
Cancel
Save