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
|
package io.legado.app.help
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.webkit.WebSettings
|
||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
import cn.hutool.core.codec.Base64
|
import cn.hutool.core.codec.Base64
|
||||||
import cn.hutool.core.util.HexUtil
|
import cn.hutool.core.util.HexUtil
|
||||||
@ -490,6 +491,10 @@ interface JsExtensions : JsEncodeUtils {
|
|||||||
return ChineseUtils.s2t(text)
|
return ChineseUtils.s2t(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getWebViewUA(): String {
|
||||||
|
return WebSettings.getDefaultUserAgent(appCtx)
|
||||||
|
}
|
||||||
|
|
||||||
//****************文件操作******************//
|
//****************文件操作******************//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -629,24 +629,24 @@ object ChapterProvider {
|
|||||||
val charArray = text.toCharArray()
|
val charArray = text.toCharArray()
|
||||||
val strList = ArrayList<String>()
|
val strList = ArrayList<String>()
|
||||||
val textWidthList = ArrayList<Float>()
|
val textWidthList = ArrayList<Float>()
|
||||||
val lastIndex = text.lastIndex
|
val lastIndex = charArray.lastIndex
|
||||||
for (i in textWidths.indices) {
|
for (i in textWidths.indices) {
|
||||||
if (charArray[i].isLowSurrogate()) {
|
if (charArray[i].isLowSurrogate()) {
|
||||||
continue
|
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()
|
charArray[i].toString() + charArray[i + 1].toString()
|
||||||
} else {
|
} else {
|
||||||
charArray[i].toString()
|
charArray[i].toString()
|
||||||
}
|
}
|
||||||
strList.add(char)
|
|
||||||
val w = textWidths[i]
|
val w = textWidths[i]
|
||||||
if (w == 0f && i - 1 >= 0) {
|
if (w == 0f && textWidthList.size > 0) {
|
||||||
textWidthList[i - 1] = textPaint.measureText(strList[i - 1])
|
textWidthList[textWidthList.lastIndex] = textPaint.measureText(strList.last())
|
||||||
textWidthList.add(textPaint.measureText(char))
|
textWidthList.add(textPaint.measureText(char))
|
||||||
} else {
|
} else {
|
||||||
textWidthList.add(w)
|
textWidthList.add(w)
|
||||||
}
|
}
|
||||||
|
strList.add(char)
|
||||||
}
|
}
|
||||||
return strList to textWidthList
|
return strList to textWidthList
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user