|
|
@ -10,7 +10,6 @@ import io.legado.app.R |
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
import io.legado.app.data.entities.Bookmark |
|
|
|
import io.legado.app.data.entities.Bookmark |
|
|
|
import io.legado.app.help.config.ReadBookConfig |
|
|
|
import io.legado.app.help.config.ReadBookConfig |
|
|
|
import io.legado.app.help.coroutine.Coroutine |
|
|
|
|
|
|
|
import io.legado.app.lib.theme.accentColor |
|
|
|
import io.legado.app.lib.theme.accentColor |
|
|
|
import io.legado.app.model.ReadBook |
|
|
|
import io.legado.app.model.ReadBook |
|
|
|
import io.legado.app.ui.book.read.PhotoDialog |
|
|
|
import io.legado.app.ui.book.read.PhotoDialog |
|
|
@ -134,7 +133,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
val textColor = if (textLine.isReadAloud) context.accentColor else ReadBookConfig.textColor |
|
|
|
val textColor = if (textLine.isReadAloud) context.accentColor else ReadBookConfig.textColor |
|
|
|
textLine.textChars.forEach { |
|
|
|
textLine.textChars.forEach { |
|
|
|
if (it.isImage) { |
|
|
|
if (it.isImage) { |
|
|
|
drawImage(canvas, textPage, textLine, it, lineTop, lineBottom, textLine.isImage) |
|
|
|
drawImage(canvas, textPage, textLine, it, lineTop, lineBottom) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
textPaint.color = textColor |
|
|
|
textPaint.color = textColor |
|
|
|
if (it.isSearchResult) { |
|
|
|
if (it.isSearchResult) { |
|
|
@ -157,23 +156,20 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
textLine: TextLine, |
|
|
|
textLine: TextLine, |
|
|
|
textChar: TextChar, |
|
|
|
textChar: TextChar, |
|
|
|
lineTop: Float, |
|
|
|
lineTop: Float, |
|
|
|
lineBottom: Float, |
|
|
|
lineBottom: Float |
|
|
|
isImageLine: Boolean |
|
|
|
|
|
|
|
) { |
|
|
|
) { |
|
|
|
val book = ReadBook.book ?: return |
|
|
|
val book = ReadBook.book ?: return |
|
|
|
Coroutine.async { |
|
|
|
val bitmap = ImageProvider.getImage( |
|
|
|
ImageProvider.getImage( |
|
|
|
|
|
|
|
book, |
|
|
|
book, |
|
|
|
textChar.charData, |
|
|
|
textChar.charData, |
|
|
|
ReadBook.bookSource, |
|
|
|
ReadBook.bookSource, |
|
|
|
(textChar.end - textChar.start).toInt(), |
|
|
|
(textChar.end - textChar.start).toInt(), |
|
|
|
(lineBottom - lineTop).toInt() |
|
|
|
(lineBottom - lineTop).toInt() |
|
|
|
) |
|
|
|
) |
|
|
|
}.onSuccess { bitmap -> |
|
|
|
|
|
|
|
relativeOffset(textPage)?.let { relativeOffset -> |
|
|
|
relativeOffset(textPage)?.let { relativeOffset -> |
|
|
|
val lineTopNow = textLine.lineTop + relativeOffset |
|
|
|
val lineTopNow = textLine.lineTop + relativeOffset |
|
|
|
val lineBottomNow = textLine.lineBottom + relativeOffset |
|
|
|
val lineBottomNow = textLine.lineBottom + relativeOffset |
|
|
|
val rectF = if (isImageLine) { |
|
|
|
val rectF = if (textLine.isImage) { |
|
|
|
RectF(textChar.start, lineTopNow, textChar.end, lineBottomNow) |
|
|
|
RectF(textChar.start, lineTopNow, textChar.end, lineBottomNow) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
/*以宽度为基准保持图片的原始比例叠加,当div为负数时,允许高度比字符更高*/ |
|
|
|
/*以宽度为基准保持图片的原始比例叠加,当div为负数时,允许高度比字符更高*/ |
|
|
@ -188,7 +184,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 滚动事件 |
|
|
|
* 滚动事件 |
|
|
|