mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
bf3fcc7206
commit
ef104b9008
@ -1,6 +1,7 @@
|
||||
package io.legado.app.help
|
||||
|
||||
import android.net.Uri
|
||||
import android.webkit.WebSettings
|
||||
import androidx.annotation.Keep
|
||||
import cn.hutool.core.codec.Base64
|
||||
import cn.hutool.core.util.HexUtil
|
||||
@ -490,6 +491,10 @@ interface JsExtensions : JsEncodeUtils {
|
||||
return ChineseUtils.s2t(text)
|
||||
}
|
||||
|
||||
fun getWebViewUA(): String {
|
||||
return WebSettings.getDefaultUserAgent(appCtx)
|
||||
}
|
||||
|
||||
//****************文件操作******************//
|
||||
|
||||
/**
|
||||
|
@ -629,24 +629,24 @@ object ChapterProvider {
|
||||
val charArray = text.toCharArray()
|
||||
val strList = ArrayList<String>()
|
||||
val textWidthList = ArrayList<Float>()
|
||||
val lastIndex = text.lastIndex
|
||||
val lastIndex = charArray.lastIndex
|
||||
for (i in textWidths.indices) {
|
||||
if (charArray[i].isLowSurrogate()) {
|
||||
continue
|
||||
}
|
||||
val char = if (i + 1 < lastIndex && charArray[i + 1].isLowSurrogate()) {
|
||||
val char = if (i + 1 <= lastIndex && charArray[i + 1].isLowSurrogate()) {
|
||||
charArray[i].toString() + charArray[i + 1].toString()
|
||||
} else {
|
||||
charArray[i].toString()
|
||||
}
|
||||
strList.add(char)
|
||||
val w = textWidths[i]
|
||||
if (w == 0f && i - 1 >= 0) {
|
||||
textWidthList[i - 1] = textPaint.measureText(strList[i - 1])
|
||||
if (w == 0f && textWidthList.size > 0) {
|
||||
textWidthList[textWidthList.lastIndex] = textPaint.measureText(strList.last())
|
||||
textWidthList.add(textPaint.measureText(char))
|
||||
} else {
|
||||
textWidthList.add(w)
|
||||
}
|
||||
strList.add(char)
|
||||
}
|
||||
return strList to textWidthList
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user