-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the new Preferences API for EPUB #141
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
mickael-menu
force-pushed
the
feature/settings
branch
2 times, most recently
from
July 27, 2022 12:49
914dac8
to
5f69f9c
Compare
qnga
reviewed
Sep 4, 2022
test-app/src/main/java/org/readium/r2/testapp/reader/settings/UserSettings.kt
Show resolved
Hide resolved
readium/navigator/src/main/java/org/readium/r2/navigator/settings/Setting.kt
Outdated
Show resolved
Hide resolved
readium/navigator/src/main/java/org/readium/r2/navigator/settings/Setting.kt
Show resolved
Hide resolved
readium/navigator/src/main/java/org/readium/r2/navigator/settings/Setting.kt
Show resolved
Hide resolved
readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubSettings.kt
Show resolved
Hide resolved
readium/navigator/src/main/java/org/readium/r2/navigator/epub/css/Layout.kt
Show resolved
Hide resolved
readium/navigator/src/main/java/org/readium/r2/navigator/settings/Preferences.kt
Outdated
Show resolved
Hide resolved
readium/navigator/src/main/java/org/readium/r2/navigator/settings/Preferences.kt
Outdated
Show resolved
Hide resolved
readium/navigator/src/main/java/org/readium/r2/navigator/epub/css/Properties.kt
Outdated
Show resolved
Hide resolved
mickael-menu
commented
Sep 5, 2022
private fun onSettingsChange(previous: EpubSettings, new: EpubSettings) { | ||
if (new !is EpubSettings.Reflowable) return | ||
|
||
if ((previous as? EpubSettings.Reflowable)?.fontSize?.value != new.fontSize.value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The font size is not configured using Readium CSS, as it doesn't work well if we don't disable publisher styles. See readium/mobile#1 (comment)
Instead we use the native WebSettings.textZoom
.
mickael-menu
changed the title
Add the new Settings API for EPUB
Add the new Preferences API for EPUB
Jul 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog
Added
Navigator
backgroundColor
- Default page background color.textColor
- Default page text color.textNormalization
- Normalize font style, weight and variants using a specific strategy (force bold, accessibility).imageFilter
- Filter applied to images in dark theme (darken, invert colors)language
- Language of the publication content.readingProgression
- Direction of the reading progression across resources, e.g. RTL.typeScale
- Scale applied to all element font sizes.paragraphIndent
- Text indentation for paragraphs.paragraphSpacing
- Vertical margins for paragraphs.hyphens
- Enable hyphenation.ligatures
- Enable ligatures in Arabic.Changed
Navigator
Deprecated
Streamer
Screenshots
Review notes
The Settings API is split in three PRs to help the review. They should be merged into each other starting with 1/3, but should be reviewed in reverse order:
Start by checking out the documentation for an overview:
What happens when you change the user settings?
Preferences
to the EPUB navigator.EpubSettings
using the submittedPreferences
object.navigator.settings
, the user interface will be updated to reflect the changes.EpubSettings
are used to update the currentReadiumCss
properties and theViewPager
(e.g. if the reading progression changes).ReadiumCss
object changes, all the loadedWebView
s receive JavaScript instructions to update the CSS variables.Settings
typesThe
navigator/settings
package hosts the genericSetting
types and building blocks. It is not tied toNavigator
itself and could be used with other configurable components, such as the TTS synthesizer.Configurable
is to be implemented by a configurable component, such as theEpubNavigatorFragment
.List<Setting<*, *>>
, there's aSettings
empty marker interface that eachConfigurable
implementer is supposed to implement as adata class
holdingSetting
properties. This helps with discoverability of available settings, improve type-safety and two differentConfigurable
implementers probably offer very different settings anyways.Setting
object associates a settingkey
and its currentvalue
. It also has:coder
which converts the value from/to JSON. It's implicit if the value type is@Serializable
.extras
type-specific constraints (e.g. a range of values).validator
which is used to make sure only a validvalue
can be given (e.g. part of a range, or part of an enum).activator
which can be used to activate a setting when it has dependencies. For example, theletterSpacing
setting requires thepublisherStyles
setting to be disabled.EpubSettings
EpubSettings
is the EPUB-specific implementation ofConfigurable.Settings
. It's a sealed class split inReflowable
andFixedLayout
settings.To update an
EpubSettings
object, you can provide aPreferences
object toupdate()
which will return the new updatedEpubSettings
object.Each setting has an equivalent "prototype setting" which is a constant setting used as the template (default value, constraints) for creating or modifying a setting. For example, the
EpubSettings.Reflowable.FONT_SIZE
prototype setting is used to generate thesettings.fontSize
.Readium CSS adapter
The
ReadiumCss
is a type-safe representation of the Readium CSS API. EachReadiumCss
object represents a state of the CSS variables and is used to inject them in the HTML resources, as well as the stylesheets.The
ReadiumCss
object can be updated by passing the currentEpubSettings
object toupdate()
.This is a low level internal API. The app is expected to use the
Preferences
andEpubSettings
objects instead. However, the user can customize the--RS
variables withEpubNavigatorFragment.Configuration.readiumCssRsProperties
if the EPUB settings are too limited.Missing stuff
FontFamilySource
.