【功能】为墨水屏模式增加自动下划线高亮 (#5207)
* Feat: Auto add underline for highlight in E-Ink mode * Feat: Unify search result highlight to underline in E-Ink mode * Feat: Create a simplified workflow for building signed release APK * Fix: Restore original signing method for release build * Feat: Create final workflow to build and release signed APK with custom body * Feat: Finalized custom release workflow * Chore: Revert workflow file to original version * Fix: Adjust underline vertical position for visual perfection
This commit is contained in:
@@ -160,6 +160,17 @@ data class TextLine(
|
|||||||
columns[i].draw(view, canvas)
|
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 lineY = height - 1.dpToPx()
|
||||||
|
canvas.drawLine(lineStart + indentWidth, lineY, lineEnd, lineY, underlinePaint)
|
||||||
|
PaintPool.recycle(underlinePaint)
|
||||||
|
}
|
||||||
|
|
||||||
if (ReadBookConfig.underline && !isImage && ReadBook.book?.isImage != true) {
|
if (ReadBookConfig.underline && !isImage && ReadBook.book?.isImage != true) {
|
||||||
drawUnderline(canvas)
|
drawUnderline(canvas)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.legado.app.ui.book.searchContent
|
|||||||
|
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
|
import io.legado.app.help.config.AppConfig
|
||||||
|
|
||||||
data class SearchResult(
|
data class SearchResult(
|
||||||
val resultCount: Int = 0,
|
val resultCount: Int = 0,
|
||||||
@@ -22,19 +23,35 @@ data class SearchResult(
|
|||||||
val leftString = resultText.substring(0, queryIndexInSurrounding)
|
val leftString = resultText.substring(0, queryIndexInSurrounding)
|
||||||
val rightString =
|
val rightString =
|
||||||
resultText.substring(queryIndexInSurrounding + query.length, resultText.length)
|
resultText.substring(queryIndexInSurrounding + query.length, resultText.length)
|
||||||
val html = buildString {
|
|
||||||
append(chapterTitle.colorTextForHtml(accentColor))
|
// 检查是否为墨水屏模式
|
||||||
append("<br>")
|
val html = if (AppConfig.isEInkMode) {
|
||||||
append(leftString.colorTextForHtml(textColor))
|
// 墨水屏模式:使用下划线
|
||||||
append(query.colorTextForHtml(accentColor))
|
buildString {
|
||||||
append(rightString.colorTextForHtml(textColor))
|
append("<u>${chapterTitle}</u>")
|
||||||
|
append("<br>")
|
||||||
|
append(leftString)
|
||||||
|
append("<u>${query}</u>")
|
||||||
|
append(rightString)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 普通模式:使用颜色
|
||||||
|
buildString {
|
||||||
|
append(chapterTitle.colorTextForHtml(accentColor))
|
||||||
|
append("<br>")
|
||||||
|
append(leftString.colorTextForHtml(textColor))
|
||||||
|
append(query.colorTextForHtml(accentColor))
|
||||||
|
append(rightString.colorTextForHtml(textColor))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||||
} else {
|
} else {
|
||||||
HtmlCompat.fromHtml(
|
val html = if (AppConfig.isEInkMode) {
|
||||||
resultText.colorTextForHtml(textColor),
|
resultText
|
||||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
} else {
|
||||||
)
|
resultText.colorTextForHtml(textColor)
|
||||||
|
}
|
||||||
|
HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user