diff --git a/CHANGELOG.md b/CHANGELOG.md index cc5d814d1e..09ef5a7a1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt index 0af8de803b..8a3fb9804b 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt @@ -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) { diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubPreferencesEditor.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubPreferencesEditor.kt index a93324c4d6..f045ea843e 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubPreferencesEditor.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubPreferencesEditor.kt @@ -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 = 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) } }, ) diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferences.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferences.kt index 6cc167d785..c44be733b5 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferences.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/preferences/UserPreferences.kt @@ -125,6 +125,7 @@ private fun

, E : PreferencesEditor

> UserPref EpubLayout.FIXED -> FixedLayoutUserPreferences( commit = commit, + backgroundColor = editor.backgroundColor, language = editor.language, readingProgression = editor.readingProgression, spread = editor.spread, @@ -142,6 +143,7 @@ private fun ColumnScope.FixedLayoutUserPreferences( commit: () -> Unit, language: Preference? = null, readingProgression: EnumPreference? = null, + backgroundColor: Preference? = null, scroll: Preference? = null, scrollAxis: EnumPreference? = null, fit: EnumPreference? = null, @@ -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",