|
|
@ -20,6 +20,7 @@ import io.legado.app.ui.widget.dialog.PhotoDialog |
|
|
|
import io.legado.app.utils.activity |
|
|
|
import io.legado.app.utils.activity |
|
|
|
import io.legado.app.utils.getCompatColor |
|
|
|
import io.legado.app.utils.getCompatColor |
|
|
|
import io.legado.app.utils.getPrefBoolean |
|
|
|
import io.legado.app.utils.getPrefBoolean |
|
|
|
|
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, attrs) { |
|
|
|
class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, attrs) { |
|
|
@ -105,7 +106,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
private fun draw( |
|
|
|
private fun draw( |
|
|
|
canvas: Canvas, |
|
|
|
canvas: Canvas, |
|
|
|
textLine: TextLine, |
|
|
|
textLine: TextLine, |
|
|
|
relativeOffset: Float |
|
|
|
relativeOffset: Float, |
|
|
|
) { |
|
|
|
) { |
|
|
|
val lineTop = textLine.lineTop + relativeOffset |
|
|
|
val lineTop = textLine.lineTop + relativeOffset |
|
|
|
val lineBase = textLine.lineBase + relativeOffset |
|
|
|
val lineBase = textLine.lineBase + relativeOffset |
|
|
@ -135,7 +136,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
lineBase: Float, |
|
|
|
lineBase: Float, |
|
|
|
lineBottom: Float, |
|
|
|
lineBottom: Float, |
|
|
|
isTitle: Boolean, |
|
|
|
isTitle: Boolean, |
|
|
|
isReadAloud: Boolean |
|
|
|
isReadAloud: Boolean, |
|
|
|
) { |
|
|
|
) { |
|
|
|
val textPaint = if (isTitle) ChapterProvider.titlePaint else ChapterProvider.contentPaint |
|
|
|
val textPaint = if (isTitle) ChapterProvider.titlePaint else ChapterProvider.contentPaint |
|
|
|
textPaint.color = |
|
|
|
textPaint.color = |
|
|
@ -155,16 +156,14 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
canvas: Canvas, |
|
|
|
canvas: Canvas, |
|
|
|
textLine: TextLine, |
|
|
|
textLine: TextLine, |
|
|
|
lineTop: Float, |
|
|
|
lineTop: Float, |
|
|
|
lineBottom: Float |
|
|
|
lineBottom: Float, |
|
|
|
) { |
|
|
|
) { |
|
|
|
textLine.textChars.forEach { textChar -> |
|
|
|
textLine.textChars.forEach { textChar -> |
|
|
|
val rectF = RectF(textChar.start, lineTop, textChar.end, lineBottom) |
|
|
|
val rectF = RectF(textChar.start, lineTop, textChar.end, lineBottom) |
|
|
|
ImageProvider.getImage( |
|
|
|
ImageProvider.getImage(ReadBook.book!!, |
|
|
|
ReadBook.book!!, |
|
|
|
|
|
|
|
textPage.chapterIndex, |
|
|
|
textPage.chapterIndex, |
|
|
|
textChar.charData, |
|
|
|
textChar.charData, |
|
|
|
true |
|
|
|
true)?.let { |
|
|
|
)?.let { |
|
|
|
|
|
|
|
canvas.drawBitmap(it, null, rectF, null) |
|
|
|
canvas.drawBitmap(it, null, rectF, null) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -211,7 +210,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
fun selectText( |
|
|
|
fun selectText( |
|
|
|
x: Float, |
|
|
|
x: Float, |
|
|
|
y: Float, |
|
|
|
y: Float, |
|
|
|
select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit |
|
|
|
select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit, |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (!selectAble) return |
|
|
|
if (!selectAble) return |
|
|
|
if (!visibleRect.contains(x, y)) return |
|
|
|
if (!visibleRect.contains(x, y)) return |
|
|
@ -257,7 +256,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
lineIndex: Int, |
|
|
|
lineIndex: Int, |
|
|
|
charIndex: Int, |
|
|
|
charIndex: Int, |
|
|
|
relativeOffset: Float, |
|
|
|
relativeOffset: Float, |
|
|
|
select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit |
|
|
|
select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit, |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (textChar.isImage) { |
|
|
|
if (textChar.isImage) { |
|
|
|
activity?.supportFragmentManager?.let { |
|
|
|
activity?.supportFragmentManager?.let { |
|
|
@ -613,5 +612,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
fun onCancelSelect() |
|
|
|
fun onCancelSelect() |
|
|
|
val headerHeight: Int |
|
|
|
val headerHeight: Int |
|
|
|
val pageFactory: TextPageFactory |
|
|
|
val pageFactory: TextPageFactory |
|
|
|
|
|
|
|
val scope: CoroutineScope |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|