优化
This commit is contained in:
1 parent
ca8bc26451
commit
a2d990213c
4 files changed
+24
-13
No files matched your search
@@ -154,7 +154,15 @@ object ReadBookConfig {
|
|||||||
appCtx.putPrefBoolean(PreferKey.shareLayout, value)
|
appCtx.putPrefBoolean(PreferKey.shareLayout, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 两端对齐
|
||||||
|
*/
|
||||||
val textFullJustify get() = appCtx.getPrefBoolean(PreferKey.textFullJustify, true)
|
val textFullJustify get() = appCtx.getPrefBoolean(PreferKey.textFullJustify, true)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 底部对齐
|
||||||
|
*/
|
||||||
val textBottomJustify get() = appCtx.getPrefBoolean(PreferKey.textBottomJustify, true)
|
val textBottomJustify get() = appCtx.getPrefBoolean(PreferKey.textBottomJustify, true)
|
||||||
var hideStatusBar = appCtx.getPrefBoolean(PreferKey.hideStatusBar)
|
var hideStatusBar = appCtx.getPrefBoolean(PreferKey.hideStatusBar)
|
||||||
var hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
var hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
||||||
|
|||||||
@@ -300,10 +300,11 @@ object ChapterProvider {
|
|||||||
srcList: LinkedList<String>? = null
|
srcList: LinkedList<String>? = null
|
||||||
): Pair<Int, Float> {
|
): Pair<Int, Float> {
|
||||||
var absStartX = x
|
var absStartX = x
|
||||||
val layout = if (ReadBookConfig.useZhLayout) ZhLayout(text, textPaint, visibleWidth)
|
val layout = if (ReadBookConfig.useZhLayout) {
|
||||||
else StaticLayout(
|
ZhLayout(text, textPaint, visibleWidth)
|
||||||
text, textPaint, visibleWidth, Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true
|
} else {
|
||||||
)
|
StaticLayout(text, textPaint, visibleWidth, Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true)
|
||||||
|
}
|
||||||
var durY = when {
|
var durY = when {
|
||||||
//标题y轴居中
|
//标题y轴居中
|
||||||
isTitleWithNoContent && textPages.size == 1 -> {
|
isTitleWithNoContent && textPages.size == 1 -> {
|
||||||
@@ -375,7 +376,7 @@ object ChapterProvider {
|
|||||||
} else {
|
} else {
|
||||||
0f
|
0f
|
||||||
}
|
}
|
||||||
addCharsToLineLast(
|
addCharsToLineNatural(
|
||||||
book, absStartX, textLine, words.toStringArray(),
|
book, absStartX, textLine, words.toStringArray(),
|
||||||
textPaint, startX, srcList
|
textPaint, startX, srcList
|
||||||
)
|
)
|
||||||
@@ -416,7 +417,7 @@ object ChapterProvider {
|
|||||||
) {
|
) {
|
||||||
var x = 0f
|
var x = 0f
|
||||||
if (!ReadBookConfig.textFullJustify) {
|
if (!ReadBookConfig.textFullJustify) {
|
||||||
addCharsToLineLast(book, absStartX, textLine, words, textPaint, x, srcList)
|
addCharsToLineNatural(book, absStartX, textLine, words, textPaint, x, srcList)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val bodyIndent = ReadBookConfig.paragraphIndent
|
val bodyIndent = ReadBookConfig.paragraphIndent
|
||||||
@@ -454,7 +455,7 @@ object ChapterProvider {
|
|||||||
srcList: LinkedList<String>?
|
srcList: LinkedList<String>?
|
||||||
) {
|
) {
|
||||||
if (!ReadBookConfig.textFullJustify) {
|
if (!ReadBookConfig.textFullJustify) {
|
||||||
addCharsToLineLast(book, absStartX, textLine, words, textPaint, startX, srcList)
|
addCharsToLineNatural(book, absStartX, textLine, words, textPaint, startX, srcList)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val gapCount: Int = words.lastIndex
|
val gapCount: Int = words.lastIndex
|
||||||
@@ -470,9 +471,9 @@ object ChapterProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最后一行,自然排列
|
* 自然排列
|
||||||
*/
|
*/
|
||||||
private suspend fun addCharsToLineLast(
|
private suspend fun addCharsToLineNatural(
|
||||||
book: Book,
|
book: Book,
|
||||||
absStartX: Int,
|
absStartX: Int,
|
||||||
textLine: TextLine,
|
textLine: TextLine,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import kotlin.math.max
|
|||||||
* */
|
* */
|
||||||
@Suppress("MemberVisibilityCanBePrivate", "unused")
|
@Suppress("MemberVisibilityCanBePrivate", "unused")
|
||||||
class ZhLayout(
|
class ZhLayout(
|
||||||
text: String,
|
text: CharSequence,
|
||||||
textPaint: TextPaint,
|
textPaint: TextPaint,
|
||||||
width: Int
|
width: Int
|
||||||
) : Layout(text, textPaint, width, Alignment.ALIGN_NORMAL, 0f, 0f) {
|
) : Layout(text, textPaint, width, Alignment.ALIGN_NORMAL, 0f, 0f) {
|
||||||