Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
58ea478276
22 files changed
+72
-28
No files matched your search
@@ -163,7 +163,7 @@
|
||||
"id": -21,
|
||||
"enable": true,
|
||||
"name": "书名 括号 序号",
|
||||
"rule": "^.{1,20}[((][\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[))][ \t]{0,4}$",
|
||||
"rule": "^[一-龥]{1,20}[ \\t]{0,4}[((][\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[))][ \\t]{0,4}$",
|
||||
"example": "标题后面数字有括号(12)",
|
||||
"serialNumber": 20
|
||||
},
|
||||
@@ -171,7 +171,7 @@
|
||||
"id": -22,
|
||||
"enable": true,
|
||||
"name": "书名 序号",
|
||||
"rule": "^.{1,20}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[ \t]{0,4}$",
|
||||
"rule": "^[一-龥]{1,20}[ \\t]{0,4}[\\d〇零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[ \\t]{0,4}$",
|
||||
"example": "标题后面数字没有括号124",
|
||||
"serialNumber": 21
|
||||
},
|
||||
|
||||
@@ -138,6 +138,7 @@ object PreferKey {
|
||||
const val defaultHomePage = "defaultHomePage"
|
||||
const val showBookshelfFastScroller = "showBookshelfFastScroller"
|
||||
const val importKeepEnable = "importKeepEnable"
|
||||
const val previewImageByClick = "previewImageByClick"
|
||||
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
|
||||
@@ -26,7 +26,7 @@ object ReplaceAnalyzer {
|
||||
return runCatching {
|
||||
val replaceRule: ReplaceRule? =
|
||||
GSON.fromJsonObject<ReplaceRule>(json.trim()).getOrNull()
|
||||
if (replaceRule == null || replaceRule.pattern.isBlank()) {
|
||||
if (replaceRule == null || replaceRule.pattern.isEmpty()) {
|
||||
val jsonItem = jsonPath.parse(json.trim())
|
||||
val rule = ReplaceRule()
|
||||
rule.id = jsonItem.readLong("$.id") ?: System.currentTimeMillis()
|
||||
|
||||
@@ -426,6 +426,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
appCtx.putPrefBoolean(PreferKey.importKeepEnable, value)
|
||||
}
|
||||
|
||||
var previewImageByClick: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.previewImageByClick, false)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.previewImageByClick, value)
|
||||
}
|
||||
|
||||
var preDownloadNum
|
||||
get() = appCtx.getPrefInt(PreferKey.preDownloadNum, 10)
|
||||
set(value) {
|
||||
|
||||
@@ -28,7 +28,6 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB
|
||||
private var tasks = CompositeCoroutine()
|
||||
private var bookSourceList = arrayListOf<BookSource>()
|
||||
private var searchBooks = arrayListOf<SearchBook>()
|
||||
private val emptyBookSource = BookSource()
|
||||
|
||||
@Volatile
|
||||
private var searchIndex = -1
|
||||
@@ -77,7 +76,6 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB
|
||||
return
|
||||
}
|
||||
searchIndex++
|
||||
val searchIndex = searchIndex
|
||||
val source = bookSourceList[searchIndex]
|
||||
val searchPool = searchPool ?: return
|
||||
val task = WebBook.searchBook(
|
||||
@@ -93,7 +91,7 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB
|
||||
onSuccess(searchId, it)
|
||||
}
|
||||
.onFinally {
|
||||
onFinally(searchId, searchIndex)
|
||||
onFinally(searchId)
|
||||
}
|
||||
tasks.add(task)
|
||||
}
|
||||
@@ -109,15 +107,12 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun onFinally(searchId: Long, index: Int) {
|
||||
private fun onFinally(searchId: Long) {
|
||||
if (searchIndex < bookSourceList.lastIndex) {
|
||||
search(searchId)
|
||||
} else {
|
||||
searchIndex++
|
||||
}
|
||||
if (index <= bookSourceList.lastIndex) {
|
||||
bookSourceList[index] = emptyBookSource
|
||||
}
|
||||
if (searchIndex >= bookSourceList.lastIndex
|
||||
+ min(bookSourceList.size, threadCount)
|
||||
) {
|
||||
|
||||
@@ -141,6 +141,8 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
|
||||
AppConfig.importKeepName
|
||||
binding.toolBar.menu.findItem(R.id.menu_keep_group)?.isChecked =
|
||||
AppConfig.importKeepGroup
|
||||
binding.toolBar.menu.findItem(R.id.menu_keep_enable)?.isChecked =
|
||||
AppConfig.importKeepEnable
|
||||
binding.toolBar.menu.findItem(R.id.menu_select_new_source)?.isVisible = false
|
||||
binding.toolBar.menu.findItem(R.id.menu_select_update_source)?.isVisible = false
|
||||
}
|
||||
@@ -158,6 +160,11 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
|
||||
item.isChecked = !item.isChecked
|
||||
putPrefBoolean(PreferKey.importKeepGroup, item.isChecked)
|
||||
}
|
||||
|
||||
R.id.menu_keep_enable -> {
|
||||
item.isChecked = !item.isChecked
|
||||
AppConfig.importKeepEnable = item.isChecked
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
|
||||
val group = groupName?.trim()
|
||||
val keepName = AppConfig.importKeepName
|
||||
val keepGroup = AppConfig.importKeepGroup
|
||||
val keepEnable = AppConfig.importKeepEnable
|
||||
val selectSource = arrayListOf<RssSource>()
|
||||
selectStatus.forEachIndexed { index, b ->
|
||||
if (b) {
|
||||
@@ -72,6 +73,9 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
|
||||
if (keepGroup) {
|
||||
source.sourceGroup = it.sourceGroup
|
||||
}
|
||||
if (keepEnable) {
|
||||
source.enabled = it.enabled
|
||||
}
|
||||
source.customOrder = it.customOrder
|
||||
}
|
||||
if (!group.isNullOrEmpty()) {
|
||||
|
||||
@@ -1209,6 +1209,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
SelectItem(getString(R.string.show), "show"),
|
||||
SelectItem(getString(R.string.refresh), "refresh"),
|
||||
SelectItem(getString(R.string.action_save), "save"),
|
||||
SelectItem(getString(R.string.menu), "menu"),
|
||||
SelectItem(getString(R.string.select_folder), "selectFolder")
|
||||
)
|
||||
)
|
||||
@@ -1227,6 +1228,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
"menu" -> showActionMenu()
|
||||
"selectFolder" -> selectImageDir.launch()
|
||||
}
|
||||
popupAction.dismiss()
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.legado.app.ui.book.read.page.entities.TextPos
|
||||
import io.legado.app.ui.book.read.page.entities.column.*
|
||||
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
||||
import io.legado.app.ui.book.read.page.provider.TextPageFactory
|
||||
import io.legado.app.ui.widget.dialog.PhotoDialog
|
||||
import io.legado.app.utils.*
|
||||
import kotlin.math.min
|
||||
|
||||
@@ -348,6 +349,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
||||
context.toastOnUi("Button Pressed!")
|
||||
handled = true
|
||||
}
|
||||
|
||||
is ImageColumn -> if (AppConfig.previewImageByClick) {
|
||||
activity?.showDialogFragment(PhotoDialog(column.src))
|
||||
handled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return handled
|
||||
|
||||
@@ -558,7 +558,7 @@ object ChapterProvider {
|
||||
}
|
||||
val residualWidth = visibleWidth - desiredWidth
|
||||
val spaceSize = text.count { it == ' ' }
|
||||
val (words, widths) = getStringArrayAndTextWidths(text, textWidths)
|
||||
val (words, widths) = getStringArrayAndTextWidths(text, textWidths, textPaint)
|
||||
if (spaceSize > 1) {
|
||||
val d = residualWidth / spaceSize
|
||||
var x = startX
|
||||
@@ -589,7 +589,7 @@ object ChapterProvider {
|
||||
x = x1
|
||||
}
|
||||
}
|
||||
exceed(absStartX, textLine)
|
||||
exceed(absStartX, textLine, words)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -608,7 +608,7 @@ object ChapterProvider {
|
||||
) {
|
||||
val indentLength = ReadBookConfig.paragraphIndent.length
|
||||
var x = startX
|
||||
val (words, widths) = getStringArrayAndTextWidths(text, textWidths)
|
||||
val (words, widths) = getStringArrayAndTextWidths(text, textWidths, textPaint)
|
||||
words.forEachIndexed { index, char ->
|
||||
val cw = | ||||