Compare commits

...

2 Commits

Author SHA1 Message Date
BookOasis Reader c9c119689d Show floating TTS control only in text reader
Build & Test / Build & Test App (push) Has been cancelled
Release / Extract tag name (push) Has been cancelled
Release / Build (push) Has been cancelled
Release / Build (FOSS) (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled
2026-09-27 01:11:17 +09:00
BookOasis Reader 38a327cdf6 Improve TTS highlight contrast
Build & Test / Build & Test App (push) Has been cancelled
Release / Extract tag name (push) Has been cancelled
Update website / update_website (release) Has been cancelled
Release / Build (push) Has been cancelled
Release / Build (FOSS) (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled
2026-09-27 00:55:01 +09:00
2 changed files with 20 additions and 6 deletions
@@ -306,7 +306,10 @@ class ReaderActivity : BaseActivity() {
AppBars(state = state)
if (ttsState.active) {
val showFloatingTts = ttsState.active &&
ttsState.readerChapterId == state.currentChapter?.chapter?.id &&
state.currentChapter?.pages?.any { it is TextReaderPage } == true
if (showFloatingTts) {
IconButton(
onClick = ::toggleTts,
modifier = Modifier
@@ -11,6 +11,7 @@ import android.text.SpannableString
import android.text.StaticLayout
import android.text.TextPaint
import android.text.style.BackgroundColorSpan
import android.text.style.ForegroundColorSpan
import android.text.style.LineHeightSpan
import eu.kanade.tachiyomi.ui.reader.setting.TextReaderStyle
import java.io.ByteArrayInputStream
@@ -274,13 +275,15 @@ internal object TextPageRenderer {
}
}
val darkBackground = resolveColors(style).first == Color.BLACK
val (_, baseTextColor) = resolveColors(style)
val darkTheme = baseTextColor == Color.WHITE
sentenceHighlightRange?.let { range ->
applyHighlightSpan(
spannable = spannable,
textLength = text.length,
range = range,
color = if (darkBackground) Color.rgb(72, 68, 40) else Color.rgb(255, 249, 196),
backgroundColor = if (darkTheme) Color.rgb(77, 66, 25) else Color.rgb(255, 243, 176),
foregroundColor = if (darkTheme) Color.WHITE else Color.BLACK,
)
}
activeHighlightRange?.let { range ->
@@ -288,7 +291,8 @@ internal object TextPageRenderer {
spannable = spannable,
textLength = text.length,
range = range,
color = if (darkBackground) Color.rgb(150, 117, 0) else Color.rgb(255, 193, 7),
backgroundColor = if (darkTheme) Color.rgb(255, 193, 7) else Color.rgb(255, 179, 0),
foregroundColor = Color.BLACK,
)
}
return spannable
@@ -298,14 +302,21 @@ internal object TextPageRenderer {
spannable: SpannableString,
textLength: Int,
range: IntRange,
color: Int,
backgroundColor: Int,
foregroundColor: Int,
) {
if (range.isEmpty()) return
val start = range.first.coerceIn(0, textLength)
val endExclusive = (range.last + 1).coerceIn(start, textLength)
if (start >= endExclusive) return
spannable.setSpan(
BackgroundColorSpan(color),
BackgroundColorSpan(backgroundColor),
start,
endExclusive,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
)
spannable.setSpan(
ForegroundColorSpan(foregroundColor),
start,
endExclusive,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,