|
|
@ -16,6 +16,7 @@ import io.legado.app.ui.book.read.page.entities.TextPage |
|
|
|
import io.legado.app.utils.dp |
|
|
|
import io.legado.app.utils.dp |
|
|
|
import io.legado.app.utils.getPrefString |
|
|
|
import io.legado.app.utils.getPrefString |
|
|
|
import io.legado.app.utils.removePref |
|
|
|
import io.legado.app.utils.removePref |
|
|
|
|
|
|
|
import io.legado.app.utils.toStringArray |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Suppress("DEPRECATION") |
|
|
|
@Suppress("DEPRECATION") |
|
|
@ -177,10 +178,10 @@ object ChapterProvider { |
|
|
|
var x = 0f |
|
|
|
var x = 0f |
|
|
|
val bodyIndent = ReadBookConfig.bodyIndent |
|
|
|
val bodyIndent = ReadBookConfig.bodyIndent |
|
|
|
val icw = StaticLayout.getDesiredWidth(bodyIndent, textPaint) / bodyIndent.length |
|
|
|
val icw = StaticLayout.getDesiredWidth(bodyIndent, textPaint) / bodyIndent.length |
|
|
|
for (i in 0..bodyIndent.lastIndex) { |
|
|
|
bodyIndent.toStringArray().forEach { |
|
|
|
val x1 = x + icw |
|
|
|
val x1 = x + icw |
|
|
|
textLine.addTextChar( |
|
|
|
textLine.addTextChar( |
|
|
|
charData = bodyIndent[i].toString(), |
|
|
|
charData = it, |
|
|
|
start = paddingLeft + x, |
|
|
|
start = paddingLeft + x, |
|
|
|
end = paddingLeft + x1 |
|
|
|
end = paddingLeft + x1 |
|
|
|
) |
|
|
|
) |
|
|
@ -203,12 +204,11 @@ object ChapterProvider { |
|
|
|
val gapCount: Int = words.length - 1 |
|
|
|
val gapCount: Int = words.length - 1 |
|
|
|
val d = (visibleWidth - desiredWidth) / gapCount |
|
|
|
val d = (visibleWidth - desiredWidth) / gapCount |
|
|
|
var x = startX |
|
|
|
var x = startX |
|
|
|
for (i in words.indices) { |
|
|
|
for ((i, char) in words.toStringArray().withIndex()) { |
|
|
|
val char = words[i] |
|
|
|
val cw = StaticLayout.getDesiredWidth(char, textPaint) |
|
|
|
val cw = StaticLayout.getDesiredWidth(char.toString(), textPaint) |
|
|
|
|
|
|
|
val x1 = if (i != words.lastIndex) (x + cw + d) else (x + cw) |
|
|
|
val x1 = if (i != words.lastIndex) (x + cw + d) else (x + cw) |
|
|
|
textLine.addTextChar( |
|
|
|
textLine.addTextChar( |
|
|
|
charData = char.toString(), |
|
|
|
charData = char, |
|
|
|
start = paddingLeft + x, |
|
|
|
start = paddingLeft + x, |
|
|
|
end = paddingLeft + x1 |
|
|
|
end = paddingLeft + x1 |
|
|
|
) |
|
|
|
) |
|
|
@ -230,12 +230,11 @@ object ChapterProvider { |
|
|
|
stringBuilder.append("\n") |
|
|
|
stringBuilder.append("\n") |
|
|
|
textLine.text = "$words\n" |
|
|
|
textLine.text = "$words\n" |
|
|
|
var x = startX |
|
|
|
var x = startX |
|
|
|
for (i in words.indices) { |
|
|
|
words.toStringArray().forEach { |
|
|
|
val char = words.substring(i, i + 1) |
|
|
|
val cw = StaticLayout.getDesiredWidth(it, textPaint) |
|
|
|
val cw = StaticLayout.getDesiredWidth(char, textPaint) |
|
|
|
|
|
|
|
val x1 = x + cw |
|
|
|
val x1 = x + cw |
|
|
|
textLine.addTextChar( |
|
|
|
textLine.addTextChar( |
|
|
|
charData = char, |
|
|
|
charData = it, |
|
|
|
start = paddingLeft + x, |
|
|
|
start = paddingLeft + x, |
|
|
|
end = paddingLeft + x1 |
|
|
|
end = paddingLeft + x1 |
|
|
|
) |
|
|
|
) |
|
|
|