下滑虚线
This commit is contained in:
@@ -388,6 +388,18 @@ object ReadBookConfig {
|
||||
config.dottedLine = value
|
||||
}
|
||||
|
||||
var dottedBase: Float
|
||||
get() = config.dottedBase
|
||||
set(value) {
|
||||
config.dottedBase = value
|
||||
}
|
||||
|
||||
var dottedRatio: Float
|
||||
get() = config.dottedRatio
|
||||
set(value) {
|
||||
config.dottedRatio = value
|
||||
}
|
||||
|
||||
var paddingBottom: Int
|
||||
get() = config.paddingBottom
|
||||
set(value) {
|
||||
@@ -607,6 +619,8 @@ object ReadBookConfig {
|
||||
var paragraphIndent: String = " ",//段落缩进
|
||||
var underline: Boolean = false, //下划线
|
||||
var dottedLine: Boolean = false, //虚线
|
||||
var dottedBase: Float = 6f, //长度
|
||||
var dottedRatio: Float = 6f,
|
||||
var paddingBottom: Int = 6,
|
||||
var paddingLeft: Int = 16,
|
||||
var paddingRight: Int = 16,
|
||||
|
||||
@@ -134,6 +134,12 @@ class BgTextConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_bg
|
||||
binding.swDottedline.isChecked = dottedLine
|
||||
binding.swDottedline.isEnabled = underline
|
||||
binding.sbBgAlpha.value = ReadBookConfig.bgAlpha.toFloat()
|
||||
binding.dottedRatio.valueFormat = {
|
||||
(ReadBookConfig.dottedRatio * 100).toInt().toString()
|
||||
}
|
||||
binding.dottedBase.valueFormat = {
|
||||
(ReadBookConfig.dottedBase * 100).toInt().toString()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@@ -239,6 +245,14 @@ class BgTextConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_bg
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(3))
|
||||
}
|
||||
})
|
||||
binding.dottedRatio.onChanged = {
|
||||
ReadBookConfig.dottedRatio = it / 100f
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(6, 9, 11))
|
||||
}
|
||||
binding.dottedBase.onChanged = {
|
||||
ReadBookConfig.dottedBase = it / 100f
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(6, 9, 11))
|
||||
}
|
||||
}
|
||||
|
||||
private fun exportConfig(uri: Uri) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.legado.app.ui.book.read.page.entities
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.DashPathEffect
|
||||
import android.graphics.Paint.FontMetrics
|
||||
import android.os.Build
|
||||
import androidx.annotation.Keep
|
||||
@@ -157,19 +156,15 @@ data class TextLine(
|
||||
if (checkFastDraw()) {
|
||||
fastDrawTextLine(view, canvas)
|
||||
} else {
|
||||
for (i in columns.indices) {
|
||||
columns[i].draw(view, canvas)
|
||||
}
|
||||
for (i in columns.indices) columns[i].draw(view, canvas)
|
||||
}
|
||||
// 墨水屏模式下的朗读和搜索下划线
|
||||
|
||||
if (AppConfig.isEInkMode && (isReadAloud || searchResultColumnCount > 0)) {
|
||||
val underlinePaint = PaintPool.obtain()
|
||||
underlinePaint.set(ChapterProvider.contentPaint)
|
||||
underlinePaint.strokeWidth = 1.dpToPx().toFloat()
|
||||
val linePaint = ChapterProvider.linePaint
|
||||
val lineY = height - 1.dpToPx()
|
||||
canvas.drawLine(lineStart + indentWidth, lineY, lineEnd, lineY, underlinePaint)
|
||||
PaintPool.recycle(underlinePaint)
|
||||
canvas.drawLine(lineStart + indentWidth, lineY, lineEnd, lineY, linePaint)
|
||||
}
|
||||
|
||||
if (ReadBookConfig.underline && !isImage && ReadBook.book?.isImage != true) {
|
||||
drawUnderline(canvas, ReadBookConfig.dottedLine)
|
||||
}
|
||||
@@ -215,20 +210,14 @@ data class TextLine(
|
||||
* 绘制下划线
|
||||
*/
|
||||
private fun drawUnderline(canvas: Canvas, dottedLine: Boolean) {
|
||||
val paint = ChapterProvider.linePaint
|
||||
paint.pathEffect =
|
||||
if (dottedLine && !AppConfig.isEInkMode)
|
||||
ChapterProvider.dashEffect
|
||||
else
|
||||
null
|
||||
val lineY = height - 1.dpToPx()
|
||||
val paint = ChapterProvider.contentPaint
|
||||
val oldEffect = paint.pathEffect
|
||||
if (dottedLine) {
|
||||
paint.pathEffect = DashPathEffect(floatArrayOf(6f, 6f), 0f)
|
||||
}
|
||||
canvas.drawLine(
|
||||
lineStart + indentWidth,
|
||||
lineY,
|
||||
lineEnd,
|
||||
lineY,
|
||||
paint
|
||||
)
|
||||
paint.pathEffect = oldEffect
|
||||
canvas.drawLine(lineStart + indentWidth, lineY, lineEnd, lineY, paint)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package io.legado.app.ui.book.read.page.provider
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.DashPathEffect
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Paint.FontMetrics
|
||||
import android.graphics.RectF
|
||||
import android.graphics.Typeface
|
||||
@@ -17,6 +19,8 @@ import io.legado.app.data.entities.BookChapter
|
||||
import io.legado.app.help.book.BookContent
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.config.ReadBookConfig
|
||||
import io.legado.app.help.config.ReadBookConfig.dottedBase
|
||||
import io.legado.app.help.config.ReadBookConfig.dottedRatio
|
||||
import io.legado.app.model.ImageProvider
|
||||
import io.legado.app.model.ReadBook
|
||||
import io.legado.app.ui.book.read.page.entities.TextChapter
|
||||
@@ -53,6 +57,17 @@ object ChapterProvider {
|
||||
|
||||
const val indentChar = " "
|
||||
|
||||
val linePaint: Paint by lazy {
|
||||
Paint(contentPaint).apply {
|
||||
clearShadowLayer()
|
||||
isAntiAlias = true
|
||||
strokeWidth = 1.dpToPx().toFloat()
|
||||
style = Paint.Style.STROKE
|
||||
}
|
||||
}
|
||||
|
||||
val dashEffect = DashPathEffect(floatArrayOf(dottedBase, dottedRatio), 0f)
|
||||
|
||||
@JvmStatic
|
||||
var viewWidth = 0
|
||||
private set
|
||||
|
||||
Reference in New Issue
Block a user