Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. Take a look

#### Navigator

* The EPUB `backgroundColor` preference is now available with fixed-layout publications.
* New `EPUBNavigatorFragment.Configuration.useReadiumCssFontSize` option to revert to the 2.2.0 strategy for setting the font size of reflowable EPUB publications.
* The native font size strategy introduced in 2.3.0 uses the Android web view's [`WebSettings.textZoom`](https://developer.android.com/reference/android/webkit/WebSettings#setTextZoom(int)) property to adjust the font size. 2.2.0 was using Readium CSS's [`--USER__fontSize` variable](https://readium.org/readium-css/docs/CSS12-user_prefs.html#font-size).
* `WebSettings.textZoom` will work with more publications than `--USER__fontSize`, even the ones poorly authored. However the page width is not adjusted when changing the font size to keep the optimal line length.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,14 +508,15 @@ class EpubNavigatorFragment internal constructor(
}

private fun onSettingsChange(previous: EpubSettings, new: EpubSettings) {
if (viewModel.layout == EpubLayout.FIXED) return

if (previous.fontSize != new.fontSize) {
r2PagerAdapter?.setFontSize(new.fontSize)
}
if (previous.effectiveBackgroundColor != new.effectiveBackgroundColor) {
resourcePager.setBackgroundColor(new.effectiveBackgroundColor)
}

if (viewModel.layout == EpubLayout.REFLOWABLE) {
if (previous.fontSize != new.fontSize) {
r2PagerAdapter?.setFontSize(new.fontSize)
}
}
}

private fun R2PagerAdapter.setFontSize(fontSize: Double) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ class EpubPreferencesEditor internal constructor(
}

/**
* Default page background color.
* Default background color.
*
* For fixed-layout publications, it applies to the navigator background but not the publication
* pages.
*
* When unset, the current [theme] background color is effective.
* Only effective with fixed-layout publications.
*/
val backgroundColor: Preference<Color> =
PreferenceDelegate(
getValue = { preferences.backgroundColor },
getEffectiveValue = { state.settings.backgroundColor ?: Color((theme.value ?: theme.effectiveValue).backgroundColor) },
getIsEffective = { layout == EpubLayout.REFLOWABLE && preferences.backgroundColor != null },
getIsEffective = { preferences.backgroundColor != null },
updateValue = { value -> updateValues { it.copy(backgroundColor = value) } },
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ private fun <P : Configurable.Preferences<P>, E : PreferencesEditor<P>> UserPref
EpubLayout.FIXED ->
FixedLayoutUserPreferences(
commit = commit,
backgroundColor = editor.backgroundColor,
language = editor.language,
readingProgression = editor.readingProgression,
spread = editor.spread,
Expand All @@ -142,6 +143,7 @@ private fun ColumnScope.FixedLayoutUserPreferences(
commit: () -> Unit,
language: Preference<Language?>? = null,
readingProgression: EnumPreference<ReadingProgression>? = null,
backgroundColor: Preference<ReadiumColor>? = null,
scroll: Preference<Boolean>? = null,
scrollAxis: EnumPreference<Axis>? = null,
fit: EnumPreference<Fit>? = null,
Expand Down Expand Up @@ -175,6 +177,16 @@ private fun ColumnScope.FixedLayoutUserPreferences(
Divider()
}

if (backgroundColor != null) {
ColorItem(
title = "Background color",
preference = backgroundColor,
commit = commit
)

Divider()
}

if (scroll != null) {
SwitchItem(
title = "Scroll",
Expand Down