格式化代码
This commit is contained in:
@@ -10,6 +10,7 @@ object AppPattern {
|
|||||||
|
|
||||||
//匹配格式化后的图片格式
|
//匹配格式化后的图片格式
|
||||||
val imgPattern: Pattern = Pattern.compile("<img[^>]*src=\"([^\"]*(?:\"[^>]+\\})?)\"[^>]*>")
|
val imgPattern: Pattern = Pattern.compile("<img[^>]*src=\"([^\"]*(?:\"[^>]+\\})?)\"[^>]*>")
|
||||||
|
|
||||||
//dataURL图片类型
|
//dataURL图片类型
|
||||||
val dataUriRegex = Regex("data:.*?;base64,(.*)")
|
val dataUriRegex = Regex("data:.*?;base64,(.*)")
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# 存储数据用
|
# 存储数据用
|
||||||
|
|
||||||
* dao 数据操作
|
* dao 数据操作
|
||||||
* entities 数据模型
|
* entities 数据模型
|
||||||
* \Book 书籍信息
|
* \Book 书籍信息
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
package io.legado.app.help
|
package io.legado.app.help
|
||||||
|
|
||||||
|
|
||||||
|
@Suppress("RegExpRedundantEscape")
|
||||||
object RuleComplete {
|
object RuleComplete {
|
||||||
// 需要补全
|
// 需要补全
|
||||||
private val needComplete = Regex(
|
private val needComplete = Regex(
|
||||||
"""(?<!(@|/|^|[|%&]{2})(attr|text|ownText|textNodes|href|content|html|alt|all|value|src)(\(\))?)(?<seq>\&{2}|%%|\|{2}|$)""")
|
"""(?<!(@|/|^|[|%&]{2})(attr|text|ownText|textNodes|href|content|html|alt|all|value|src)(\(\))?)(?<seq>\&{2}|%%|\|{2}|$)"""
|
||||||
|
)
|
||||||
|
|
||||||
// 不能补全 存在js/json/{{xx}}的复杂情况
|
// 不能补全 存在js/json/{{xx}}的复杂情况
|
||||||
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:")
|
||||||
|
|
||||||
@@ -31,20 +34,25 @@ object RuleComplete {
|
|||||||
preRule: String? = null,
|
preRule: String? = null,
|
||||||
type: Int = 1
|
type: Int = 1
|
||||||
): String? {
|
): String? {
|
||||||
if (rules.isNullOrEmpty()||rules.contains(notComplete) || preRule?.contains(notComplete) ?: false){
|
if (rules.isNullOrEmpty() || rules.contains(notComplete) || preRule?.contains(notComplete) == true) {
|
||||||
return rules
|
return rules
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 尾部##分割的正则或由,分割的参数 */
|
/** 尾部##分割的正则或由,分割的参数 */
|
||||||
val tailStr: String
|
val tailStr: String
|
||||||
|
|
||||||
/** 分割字符 */
|
/** 分割字符 */
|
||||||
val splitStr: String
|
val splitStr: String
|
||||||
|
|
||||||
/** 用于获取文字时添加的规则 */
|
/** 用于获取文字时添加的规则 */
|
||||||
val textRule: String
|
val textRule: String
|
||||||
|
|
||||||
/** 用于获取链接时添加的规则 */
|
/** 用于获取链接时添加的规则 */
|
||||||
val linkRule: String
|
val linkRule: String
|
||||||
|
|
||||||
/** 用于获取图片时添加的规则 */
|
/** 用于获取图片时添加的规则 */
|
||||||
val imgRule: String
|
val imgRule: String
|
||||||
|
|
||||||
/** 用于获取图片alt属性时添加的规则 */
|
/** 用于获取图片alt属性时添加的规则 */
|
||||||
val imgText: String
|
val imgText: String
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
|
|||||||
private var cpuAbi: String? = null
|
private var cpuAbi: String? = null
|
||||||
private var md5: String
|
private var md5: String
|
||||||
var download = false
|
var download = false
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var cacheInstall = false
|
private var cacheInstall = false
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# 放置一些copy过来的库
|
# 放置一些copy过来的库
|
||||||
|
|
||||||
* dialogs 弹出框
|
* dialogs 弹出框
|
||||||
* icu4j 编码识别库
|
* icu4j 编码识别库
|
||||||
* permission 权限申请库
|
* permission 权限申请库
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import splitties.init.appCtx
|
|||||||
|
|
||||||
object CheckSource {
|
object CheckSource {
|
||||||
var keyword = "我的"
|
var keyword = "我的"
|
||||||
|
|
||||||
//校验设置
|
//校验设置
|
||||||
var timeout = CacheManager.getLong("checkSourceTimeout") ?: 180000L
|
var timeout = CacheManager.getLong("checkSourceTimeout") ?: 180000L
|
||||||
var checkSearch = CacheManager.get("checkSearch")?.toBoolean() ?: true
|
var checkSearch = CacheManager.get("checkSearch")?.toBoolean() ?: true
|
||||||
@@ -53,6 +54,10 @@ object CheckSource {
|
|||||||
if (checkInfo) checkItem = "$checkItem ${appCtx.getString(R.string.source_tab_info)}"
|
if (checkInfo) checkItem = "$checkItem ${appCtx.getString(R.string.source_tab_info)}"
|
||||||
if (checkCategory) checkItem = "$checkItem ${appCtx.getString(R.string.chapter_list)}"
|
if (checkCategory) checkItem = "$checkItem ${appCtx.getString(R.string.chapter_list)}"
|
||||||
if (checkContent) checkItem = "$checkItem ${appCtx.getString(R.string.main_body)}"
|
if (checkContent) checkItem = "$checkItem ${appCtx.getString(R.string.main_body)}"
|
||||||
return appCtx.getString(R.string.check_source_config_summary, (timeout / 1000).toString(), checkItem)
|
return appCtx.getString(
|
||||||
|
R.string.check_source_config_summary,
|
||||||
|
(timeout / 1000).toString(),
|
||||||
|
checkItem
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,8 @@ object Debug {
|
|||||||
fun updateFinalMessage(sourceUrl: String, state: String) {
|
fun updateFinalMessage(sourceUrl: String, state: String) {
|
||||||
if (debugTimeMap[sourceUrl] != null && debugMessageMap[sourceUrl] != null) {
|
if (debugTimeMap[sourceUrl] != null && debugMessageMap[sourceUrl] != null) {
|
||||||
val spendingTime = System.currentTimeMillis() - debugTimeMap[sourceUrl]!!
|
val spendingTime = System.currentTimeMillis() - debugTimeMap[sourceUrl]!!
|
||||||
debugTimeMap[sourceUrl] = if (state == "校验成功") spendingTime else CheckSource.timeout + spendingTime
|
debugTimeMap[sourceUrl] =
|
||||||
|
if (state == "校验成功") spendingTime else CheckSource.timeout + spendingTime
|
||||||
val printTime = debugTimeFormat.format(Date(spendingTime))
|
val printTime = debugTimeFormat.format(Date(spendingTime))
|
||||||
debugMessageMap[sourceUrl] = "$printTime $state"
|
debugMessageMap[sourceUrl] = "$printTime $state"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# 放置一些模块类
|
# 放置一些模块类
|
||||||
|
|
||||||
* analyzeRule 书源规则解析
|
* analyzeRule 书源规则解析
|
||||||
* localBook 本地书籍解析
|
* localBook 本地书籍解析
|
||||||
* rss 订阅规则解析
|
* rss 订阅规则解析
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# android服务
|
# android服务
|
||||||
|
|
||||||
* AudioPlayService 音频播放服务
|
* AudioPlayService 音频播放服务
|
||||||
* CheckSourceService 书源检测服务
|
* CheckSourceService 书源检测服务
|
||||||
* DownloadService 缓存服务
|
* DownloadService 缓存服务
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ fun TimerDialog(state: MutableState<Boolean>, parent: View) {
|
|||||||
Card(Modifier.fillMaxWidth()) {
|
Card(Modifier.fillMaxWidth()) {
|
||||||
Slider(
|
Slider(
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
modifier = Modifier.padding(horizontal = 16.dp),
|
||||||
value = timeMinute.value.toFloat(), onValueChange = {
|
value = timeMinute.value.toFloat(),
|
||||||
|
onValueChange = {
|
||||||
timeMinute.value = it.toInt()
|
timeMinute.value = it.toInt()
|
||||||
AudioPlay.setTimer(it.toInt())
|
AudioPlay.setTimer(it.toInt())
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ class SearchContentViewModel(application: Application) : BaseViewModel(applicati
|
|||||||
else -> chapter.title
|
else -> chapter.title
|
||||||
}
|
}
|
||||||
mContent = contentProcessor!!.getContent(
|
mContent = contentProcessor!!.getContent(
|
||||||
book, chapter, chapterContent, chineseConvert = false, reSegment = false, useReplace = false
|
book, chapter, chapterContent,
|
||||||
|
chineseConvert = false,
|
||||||
|
reSegment = false,
|
||||||
|
useReplace = false
|
||||||
).joinToString("")
|
).joinToString("")
|
||||||
}
|
}
|
||||||
val positions = searchPosition(query)
|
val positions = searchPosition(query)
|
||||||
@@ -90,7 +93,11 @@ class SearchContentViewModel(application: Application) : BaseViewModel(applicati
|
|||||||
return position
|
return position
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getResultAndQueryIndex(content: String, queryIndexInContent: Int, query: String): Pair<Int, String> {
|
private fun getResultAndQueryIndex(
|
||||||
|
content: String,
|
||||||
|
queryIndexInContent: Int,
|
||||||
|
query: String
|
||||||
|
): Pair<Int, String> {
|
||||||
// 左右移动20个字符,构建关键词周边文字,在搜索结果里显示
|
// 左右移动20个字符,构建关键词周边文字,在搜索结果里显示
|
||||||
// todo: 判断段落,只在关键词所在段落内分割
|
// todo: 判断段落,只在关键词所在段落内分割
|
||||||
// todo: 利用标点符号分割完整的句
|
// todo: 利用标点符号分割完整的句
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ data class SearchResult(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.colorTextForHtml(textColor: String) = "<font color=#${textColor}>$this</font>"
|
private fun String.colorTextForHtml(textColor: String) =
|
||||||
|
"<font color=#${textColor}>$this</font>"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,7 @@ import splitties.views.onClick
|
|||||||
class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config) {
|
class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config) {
|
||||||
|
|
||||||
private val binding by viewBinding(DialogCheckSourceConfigBinding::bind)
|
private val binding by viewBinding(DialogCheckSourceConfigBinding::bind)
|
||||||
|
|
||||||
//允许的最小超时时间,秒
|
//允许的最小超时时间,秒
|
||||||
private val minTimeout = 0L
|
private val minTimeout = 0L
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,10 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
|
|||||||
* @param saveTime 保存的时间,单位:秒
|
* @param saveTime 保存的时间,单位:秒
|
||||||
*/
|
*/
|
||||||
fun put(key: String, value: String, saveTime: Int) {
|
fun put(key: String, value: String, saveTime: Int) {
|
||||||
if (saveTime == 0) put(key, value) else put(key, Utils.newStringWithDateInfo(saveTime, value))
|
if (saveTime == 0) put(key, value) else put(
|
||||||
|
key,
|
||||||
|
Utils.newStringWithDateInfo(saveTime, value)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -245,7 +248,8 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
|
|||||||
* @param saveTime 保存的时间,单位:秒
|
* @param saveTime 保存的时间,单位:秒
|
||||||
*/
|
*/
|
||||||
fun put(key: String, value: ByteArray, saveTime: Int) {
|
fun put(key: String, value: ByteArray, saveTime: Int) {
|
||||||
if (saveTime == 0) put(key, value) else put(key, Utils.newByteArrayWithDateInfo(saveTime, value))
|
if (saveTime == 0) put(key, value)
|
||||||
|
else put(key, Utils.newByteArrayWithDateInfo(saveTime, value))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ fun Context.openFileUri(uri: Uri, type: String? = null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
val Context.isWifiConnect: Boolean
|
val Context.isWifiConnect: Boolean
|
||||||
get() {
|
get() {
|
||||||
val info = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
|
val info = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
|
||||||
|
|||||||
Reference in New Issue
Block a user