Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c622f74c62 | |||
| 95b1199f1d | |||
| eca7a3b886 |
@@ -90,6 +90,21 @@ internal fun ColumnScope.TextSettingsPage(viewModel: ReaderSettingsViewModel) {
|
|||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val horizontalMarginPref = viewModel.preferences.textHorizontalMargin
|
||||||
|
val horizontalMargin by horizontalMarginPref.collectAsState()
|
||||||
|
SliderItem(
|
||||||
|
label = stringResource(MR.strings.pref_text_reader_horizontal_margin),
|
||||||
|
value = horizontalMargin,
|
||||||
|
valueRange = 0..64,
|
||||||
|
steps = 15,
|
||||||
|
valueString = "$horizontalMargin dp",
|
||||||
|
onChange = { value ->
|
||||||
|
horizontalMarginPref.set(value)
|
||||||
|
viewModel.previewAndRequestTextSettingsReload()
|
||||||
|
},
|
||||||
|
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
||||||
|
)
|
||||||
|
|
||||||
val fontFamilyPref = viewModel.preferences.textFontFamily
|
val fontFamilyPref = viewModel.preferences.textFontFamily
|
||||||
val fontFamily by fontFamilyPref.collectAsState()
|
val fontFamily by fontFamilyPref.collectAsState()
|
||||||
SettingsChipRow(MR.strings.pref_text_reader_font_family) {
|
SettingsChipRow(MR.strings.pref_text_reader_font_family) {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import android.view.WindowManager
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
|
import androidx.compose.animation.core.animateDpAsState
|
||||||
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@@ -310,11 +312,16 @@ class ReaderActivity : BaseActivity() {
|
|||||||
ttsState.readerChapterId == state.currentChapter?.chapter?.id &&
|
ttsState.readerChapterId == state.currentChapter?.chapter?.id &&
|
||||||
state.currentChapter?.pages?.any { it is TextReaderPage } == true
|
state.currentChapter?.pages?.any { it is TextReaderPage } == true
|
||||||
if (showFloatingTts) {
|
if (showFloatingTts) {
|
||||||
|
val floatingTtsBottomPadding by animateDpAsState(
|
||||||
|
targetValue = if (state.menuVisible) 144.dp else 72.dp,
|
||||||
|
animationSpec = tween(durationMillis = 200),
|
||||||
|
label = "floatingTtsBottomPadding",
|
||||||
|
)
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.BottomEnd)
|
.align(Alignment.BottomEnd)
|
||||||
.navigationBarsPadding()
|
.navigationBarsPadding()
|
||||||
.padding(end = 18.dp, bottom = 72.dp),
|
.padding(end = 18.dp, bottom = floatingTtsBottomPadding),
|
||||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ internal data class PaginatedTextPage(
|
|||||||
)
|
)
|
||||||
|
|
||||||
internal object TextPageRenderer {
|
internal object TextPageRenderer {
|
||||||
private const val MARGIN_DP = 32f
|
private const val VERTICAL_MARGIN_DP = 32f
|
||||||
private const val STREAM_BUFFER_CHARS = 64 * 1024
|
private const val STREAM_BUFFER_CHARS = 64 * 1024
|
||||||
private const val STREAM_READ_CHARS = 8 * 1024
|
private const val STREAM_READ_CHARS = 8 * 1024
|
||||||
|
|
||||||
@@ -220,9 +220,12 @@ internal object TextPageRenderer {
|
|||||||
private fun resolveLayoutMetrics(style: TextReaderStyle): LayoutMetrics {
|
private fun resolveLayoutMetrics(style: TextReaderStyle): LayoutMetrics {
|
||||||
val pageWidth = style.pageWidthPx.coerceAtLeast(1)
|
val pageWidth = style.pageWidthPx.coerceAtLeast(1)
|
||||||
val pageHeight = style.pageHeightPx.coerceAtLeast(1)
|
val pageHeight = style.pageHeightPx.coerceAtLeast(1)
|
||||||
val requestedMargin = (MARGIN_DP * style.density).roundToInt().coerceAtLeast(1)
|
val requestedHorizontalMargin = (style.horizontalMarginDp * style.density)
|
||||||
val horizontalMargin = requestedMargin.coerceAtMost(((pageWidth - 1) / 2).coerceAtLeast(0))
|
.roundToInt()
|
||||||
val verticalMargin = requestedMargin.coerceAtMost(((pageHeight - 1) / 2).coerceAtLeast(0))
|
.coerceAtLeast(0)
|
||||||
|
val requestedVerticalMargin = (VERTICAL_MARGIN_DP * style.density).roundToInt().coerceAtLeast(1)
|
||||||
|
val horizontalMargin = requestedHorizontalMargin.coerceAtMost(((pageWidth - 1) / 2).coerceAtLeast(0))
|
||||||
|
val verticalMargin = requestedVerticalMargin.coerceAtMost(((pageHeight - 1) / 2).coerceAtLeast(0))
|
||||||
|
|
||||||
return LayoutMetrics(
|
return LayoutMetrics(
|
||||||
pageWidth = pageWidth,
|
pageWidth = pageWidth,
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ class ReaderPreferences(
|
|||||||
|
|
||||||
val textParagraphSpacing: Preference<Int> = preferenceStore.getInt("reader_text_paragraph_spacing", 4)
|
val textParagraphSpacing: Preference<Int> = preferenceStore.getInt("reader_text_paragraph_spacing", 4)
|
||||||
|
|
||||||
|
val textHorizontalMargin: Preference<Int> = preferenceStore.getInt("reader_text_horizontal_margin", 32)
|
||||||
|
|
||||||
val textFontFamily: Preference<TextFontFamily> = preferenceStore.getEnum(
|
val textFontFamily: Preference<TextFontFamily> = preferenceStore.getEnum(
|
||||||
"reader_text_font_family",
|
"reader_text_font_family",
|
||||||
TextFontFamily.SYSTEM,
|
TextFontFamily.SYSTEM,
|
||||||
@@ -161,6 +163,7 @@ class ReaderPreferences(
|
|||||||
fontSize = textFontSize.get(),
|
fontSize = textFontSize.get(),
|
||||||
lineSpacingPercent = textLineSpacing.get(),
|
lineSpacingPercent = textLineSpacing.get(),
|
||||||
paragraphSpacing = textParagraphSpacing.get(),
|
paragraphSpacing = textParagraphSpacing.get(),
|
||||||
|
horizontalMarginDp = textHorizontalMargin.get(),
|
||||||
fontFamily = textFontFamily.get(),
|
fontFamily = textFontFamily.get(),
|
||||||
readerTheme = readerTheme.get(),
|
readerTheme = readerTheme.get(),
|
||||||
automaticDark = (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
automaticDark = (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
||||||
@@ -435,6 +438,7 @@ data class TextReaderStyle(
|
|||||||
val fontSize: Int,
|
val fontSize: Int,
|
||||||
val lineSpacingPercent: Int,
|
val lineSpacingPercent: Int,
|
||||||
val paragraphSpacing: Int,
|
val paragraphSpacing: Int,
|
||||||
|
val horizontalMarginDp: Int,
|
||||||
val fontFamily: ReaderPreferences.TextFontFamily,
|
val fontFamily: ReaderPreferences.TextFontFamily,
|
||||||
val readerTheme: Int,
|
val readerTheme: Int,
|
||||||
val automaticDark: Boolean,
|
val automaticDark: Boolean,
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ class ReaderSettingsViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun previewAndRequestTextSettingsReload() {
|
||||||
|
onTextSettingsPreview()
|
||||||
|
requestTextSettingsReload()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Theme-only changes do not affect page boundaries, so avoid an unnecessary
|
* Theme-only changes do not affect page boundaries, so avoid an unnecessary
|
||||||
* full repagination.
|
* full repagination.
|
||||||
|
|||||||
@@ -1113,6 +1113,7 @@
|
|||||||
<string name="reader_tts_stop">Stop TTS</string>
|
<string name="reader_tts_stop">Stop TTS</string>
|
||||||
<string name="pref_text_reader_line_spacing">Line spacing</string>
|
<string name="pref_text_reader_line_spacing">Line spacing</string>
|
||||||
<string name="pref_text_reader_paragraph_spacing">Paragraph spacing</string>
|
<string name="pref_text_reader_paragraph_spacing">Paragraph spacing</string>
|
||||||
|
<string name="pref_text_reader_horizontal_margin">Side margins</string>
|
||||||
<string name="pref_text_reader_font_family">Font</string>
|
<string name="pref_text_reader_font_family">Font</string>
|
||||||
<string name="pref_text_reader_font_system">System</string>
|
<string name="pref_text_reader_font_system">System</string>
|
||||||
<string name="pref_text_reader_font_sans">Sans-serif</string>
|
<string name="pref_text_reader_font_sans">Sans-serif</string>
|
||||||
|
|||||||
@@ -921,6 +921,7 @@
|
|||||||
<string name="reader_tts_stop">TTS 정지</string>
|
<string name="reader_tts_stop">TTS 정지</string>
|
||||||
<string name="pref_text_reader_line_spacing">행간</string>
|
<string name="pref_text_reader_line_spacing">행간</string>
|
||||||
<string name="pref_text_reader_paragraph_spacing">문단 간격</string>
|
<string name="pref_text_reader_paragraph_spacing">문단 간격</string>
|
||||||
|
<string name="pref_text_reader_horizontal_margin">좌우 여백</string>
|
||||||
<string name="pref_text_reader_font_family">글꼴</string>
|
<string name="pref_text_reader_font_family">글꼴</string>
|
||||||
<string name="pref_text_reader_font_system">시스템</string>
|
<string name="pref_text_reader_font_system">시스템</string>
|
||||||
<string name="pref_text_reader_font_sans">고딕</string>
|
<string name="pref_text_reader_font_sans">고딕</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user