Add background TTS for EPUB and TXT reader
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
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
This commit is contained in:
@@ -73,6 +73,9 @@ fun ReaderAppBars(
|
||||
onClickOrientation: () -> Unit,
|
||||
cropEnabled: Boolean,
|
||||
onClickCropBorder: () -> Unit,
|
||||
ttsAvailable: Boolean,
|
||||
ttsPlaying: Boolean,
|
||||
onClickTts: () -> Unit,
|
||||
onClickSettings: () -> Unit,
|
||||
) {
|
||||
val backgroundColor = MaterialTheme.colorScheme
|
||||
@@ -172,6 +175,9 @@ fun ReaderAppBars(
|
||||
onClickOrientation = onClickOrientation,
|
||||
cropEnabled = cropEnabled,
|
||||
onClickCropBorder = onClickCropBorder,
|
||||
ttsAvailable = ttsAvailable,
|
||||
ttsPlaying = ttsPlaying,
|
||||
onClickTts = onClickTts,
|
||||
onClickSettings = onClickSettings,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ fun ReaderBottomBar(
|
||||
onClickOrientation: () -> Unit,
|
||||
cropEnabled: Boolean,
|
||||
onClickCropBorder: () -> Unit,
|
||||
ttsAvailable: Boolean,
|
||||
ttsPlaying: Boolean,
|
||||
onClickTts: () -> Unit,
|
||||
onClickSettings: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
@@ -55,6 +58,17 @@ fun ReaderBottomBar(
|
||||
)
|
||||
}
|
||||
|
||||
if (ttsAvailable) {
|
||||
IconButton(onClick = onClickTts) {
|
||||
Icon(
|
||||
painter = painterResource(if (ttsPlaying) R.drawable.ic_pause_24dp else R.drawable.ic_play_arrow_24dp),
|
||||
contentDescription = stringResource(
|
||||
if (ttsPlaying) MR.strings.reader_tts_pause else MR.strings.reader_tts_start,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
IconButton(onClick = onClickSettings) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Settings,
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
package eu.kanade.presentation.reader.settings
|
||||
|
||||
import android.content.Intent
|
||||
import android.speech.tts.TextToSpeech
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsViewModel
|
||||
import eu.kanade.tachiyomi.ui.reader.tts.ReaderTtsController
|
||||
import eu.kanade.tachiyomi.ui.reader.tts.ReaderTtsService
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.SettingsChipRow
|
||||
import tachiyomi.presentation.core.components.SliderItem
|
||||
@@ -26,6 +33,8 @@ private val fontFamilies = listOf(
|
||||
|
||||
@Composable
|
||||
internal fun ColumnScope.TextSettingsPage(viewModel: ReaderSettingsViewModel) {
|
||||
val context = LocalContext.current
|
||||
|
||||
val fontSizePref = viewModel.preferences.textFontSize
|
||||
val fontSize by fontSizePref.collectAsState()
|
||||
SliderItem(
|
||||
@@ -86,6 +95,69 @@ internal fun ColumnScope.TextSettingsPage(viewModel: ReaderSettingsViewModel) {
|
||||
}
|
||||
}
|
||||
|
||||
val ttsSpeedPref = viewModel.preferences.textTtsSpeedStep
|
||||
val ttsSpeedStep by ttsSpeedPref.collectAsState()
|
||||
SliderItem(
|
||||
label = stringResource(MR.strings.pref_text_reader_tts_speed),
|
||||
value = ttsSpeedStep,
|
||||
valueRange = 6..15,
|
||||
steps = 8,
|
||||
valueString = String.format("%.1fx", ttsSpeedStep / 5f),
|
||||
onChange = { value ->
|
||||
ttsSpeedPref.set(value)
|
||||
ReaderTtsController.setSpeed(context, value / 5f)
|
||||
},
|
||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
||||
)
|
||||
|
||||
val enginePref = viewModel.preferences.textTtsEnginePackage
|
||||
val selectedEngine by enginePref.collectAsState()
|
||||
val installedEngines = remember {
|
||||
@Suppress("DEPRECATION")
|
||||
context.packageManager.queryIntentServices(
|
||||
Intent(TextToSpeech.Engine.INTENT_ACTION_TTS_SERVICE),
|
||||
0,
|
||||
)
|
||||
.mapNotNull { info ->
|
||||
val serviceInfo = info.serviceInfo ?: return@mapNotNull null
|
||||
val packageName = serviceInfo.packageName ?: return@mapNotNull null
|
||||
packageName to info.loadLabel(context.packageManager).toString()
|
||||
}
|
||||
.distinctBy { it.first }
|
||||
.sortedBy { it.second.lowercase() }
|
||||
}
|
||||
|
||||
SettingsChipRow(MR.strings.pref_text_reader_tts_engine) {
|
||||
FilterChip(
|
||||
selected = selectedEngine == ReaderTtsService.AUTO_ENGINE,
|
||||
onClick = { enginePref.set(ReaderTtsService.AUTO_ENGINE) },
|
||||
label = { Text(stringResource(MR.strings.pref_text_reader_tts_engine_auto)) },
|
||||
)
|
||||
FilterChip(
|
||||
selected = selectedEngine == ReaderTtsService.SYSTEM_DEFAULT_ENGINE,
|
||||
onClick = { enginePref.set(ReaderTtsService.SYSTEM_DEFAULT_ENGINE) },
|
||||
label = { Text(stringResource(MR.strings.pref_text_reader_tts_engine_system)) },
|
||||
)
|
||||
installedEngines.forEach { (packageName, label) ->
|
||||
FilterChip(
|
||||
selected = selectedEngine == packageName,
|
||||
onClick = { enginePref.set(packageName) },
|
||||
label = { Text(label) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
TextButton(
|
||||
onClick = {
|
||||
runCatching {
|
||||
context.startActivity(Intent("com.android.settings.TTS_SETTINGS"))
|
||||
}
|
||||
},
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
) {
|
||||
Text(stringResource(MR.strings.pref_text_reader_tts_voice_settings))
|
||||
}
|
||||
|
||||
Text(
|
||||
text = stringResource(MR.strings.pref_text_reader_pdf_note),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
|
||||
Reference in New Issue
Block a user