Proper override for bionic reading
This commit is contained in:
+1
-1
Submodule open-x4-sdk updated: 5f4a46ea3a...4d4c66787f
@@ -330,9 +330,7 @@ void EpubReaderActivity::onEnter() {
|
|||||||
bookFontFamilyOverride = currentBook.fontFamilyOverride;
|
bookFontFamilyOverride = currentBook.fontFamilyOverride;
|
||||||
bookSdFontFamilyOverride = currentBook.sdFontFamilyOverride;
|
bookSdFontFamilyOverride = currentBook.sdFontFamilyOverride;
|
||||||
bookFontSizeOverride = currentBook.fontSizeOverride;
|
bookFontSizeOverride = currentBook.fontSizeOverride;
|
||||||
bookBionicReadingOverride = (currentBook.bionicReadingOverride >= 0)
|
bookBionicReadingOverride = currentBook.bionicReadingOverride;
|
||||||
? static_cast<bool>(currentBook.bionicReadingOverride)
|
|
||||||
: static_cast<bool>(SETTINGS.bionicReading);
|
|
||||||
bookParagraphAlignmentOverride = currentBook.paragraphAlignmentOverride;
|
bookParagraphAlignmentOverride = currentBook.paragraphAlignmentOverride;
|
||||||
bookTextAntiAliasingOverride = currentBook.textAntiAliasingOverride;
|
bookTextAntiAliasingOverride = currentBook.textAntiAliasingOverride;
|
||||||
bookHyphenationOverride = currentBook.hyphenationOverride;
|
bookHyphenationOverride = currentBook.hyphenationOverride;
|
||||||
@@ -1375,11 +1373,11 @@ void EpubReaderActivity::applyBookReaderOverrides(
|
|||||||
normalizedFontFamilyOverride = -1;
|
normalizedFontFamilyOverride = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool bionicAsBool = bionicReadingOverride > 0;
|
|
||||||
if (bookEmbeddedStyleOverride == embeddedStyleOverride && bookImageRenderingOverride == imageRenderingOverride &&
|
if (bookEmbeddedStyleOverride == embeddedStyleOverride && bookImageRenderingOverride == imageRenderingOverride &&
|
||||||
bookFontFamilyOverride == normalizedFontFamilyOverride &&
|
bookFontFamilyOverride == normalizedFontFamilyOverride &&
|
||||||
bookSdFontFamilyOverride == normalizedSdFontFamilyOverride && bookFontSizeOverride == fontSizeOverride &&
|
bookSdFontFamilyOverride == normalizedSdFontFamilyOverride && bookFontSizeOverride == fontSizeOverride &&
|
||||||
bookBionicReadingOverride == bionicAsBool && bookParagraphAlignmentOverride == paragraphAlignmentOverride &&
|
bookBionicReadingOverride == bionicReadingOverride &&
|
||||||
|
bookParagraphAlignmentOverride == paragraphAlignmentOverride &&
|
||||||
bookTextAntiAliasingOverride == textAntiAliasingOverride && bookHyphenationOverride == hyphenationOverride) {
|
bookTextAntiAliasingOverride == textAntiAliasingOverride && bookHyphenationOverride == hyphenationOverride) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1389,7 +1387,7 @@ void EpubReaderActivity::applyBookReaderOverrides(
|
|||||||
bookFontFamilyOverride = normalizedFontFamilyOverride;
|
bookFontFamilyOverride = normalizedFontFamilyOverride;
|
||||||
bookSdFontFamilyOverride = normalizedSdFontFamilyOverride;
|
bookSdFontFamilyOverride = normalizedSdFontFamilyOverride;
|
||||||
bookFontSizeOverride = fontSizeOverride;
|
bookFontSizeOverride = fontSizeOverride;
|
||||||
bookBionicReadingOverride = bionicAsBool;
|
bookBionicReadingOverride = bionicReadingOverride;
|
||||||
bookParagraphAlignmentOverride = paragraphAlignmentOverride;
|
bookParagraphAlignmentOverride = paragraphAlignmentOverride;
|
||||||
bookTextAntiAliasingOverride = textAntiAliasingOverride;
|
bookTextAntiAliasingOverride = textAntiAliasingOverride;
|
||||||
bookHyphenationOverride = hyphenationOverride;
|
bookHyphenationOverride = hyphenationOverride;
|
||||||
@@ -1414,6 +1412,13 @@ bool EpubReaderActivity::getEffectiveEmbeddedStyle() const {
|
|||||||
return SETTINGS.embeddedStyle != 0;
|
return SETTINGS.embeddedStyle != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EpubReaderActivity::getEffectiveBionicReading() const {
|
||||||
|
if (bookBionicReadingOverride >= 0) {
|
||||||
|
return bookBionicReadingOverride > 0;
|
||||||
|
}
|
||||||
|
return SETTINGS.bionicReading;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t EpubReaderActivity::getEffectiveImageRendering() const {
|
uint8_t EpubReaderActivity::getEffectiveImageRendering() const {
|
||||||
if (bookImageRenderingOverride >= 0) {
|
if (bookImageRenderingOverride >= 0) {
|
||||||
return static_cast<uint8_t>(bookImageRenderingOverride);
|
return static_cast<uint8_t>(bookImageRenderingOverride);
|
||||||
@@ -1805,7 +1810,7 @@ void EpubReaderActivity::render(RenderLock&& lock) {
|
|||||||
|
|
||||||
if (!section->loadSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
if (!section->loadSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
||||||
SETTINGS.extraParagraphSpacing, getEffectiveParagraphAlignment(), viewportWidth,
|
SETTINGS.extraParagraphSpacing, getEffectiveParagraphAlignment(), viewportWidth,
|
||||||
viewportHeight, getEffectiveHyphenation(), embeddedStyle, bookBionicReadingOverride,
|
viewportHeight, getEffectiveHyphenation(), embeddedStyle, getEffectiveBionicReading(),
|
||||||
imageRendering)) {
|
imageRendering)) {
|
||||||
LOG_DBG("ERS", "Cache not found, building...");
|
LOG_DBG("ERS", "Cache not found, building...");
|
||||||
lastRenderStats.cacheRebuilt = true;
|
lastRenderStats.cacheRebuilt = true;
|
||||||
@@ -1828,7 +1833,7 @@ void EpubReaderActivity::render(RenderLock&& lock) {
|
|||||||
if (!section->createSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
if (!section->createSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
||||||
SETTINGS.extraParagraphSpacing, getEffectiveParagraphAlignment(), viewportWidth,
|
SETTINGS.extraParagraphSpacing, getEffectiveParagraphAlignment(), viewportWidth,
|
||||||
viewportHeight, getEffectiveHyphenation(), embeddedStyle,
|
viewportHeight, getEffectiveHyphenation(), embeddedStyle,
|
||||||
bookBionicReadingOverride, imageRendering, progressFn)) {
|
getEffectiveBionicReading(), imageRendering, progressFn)) {
|
||||||
LOG_ERR("ERS", "Failed to persist page data to SD");
|
LOG_ERR("ERS", "Failed to persist page data to SD");
|
||||||
section.reset();
|
section.reset();
|
||||||
return;
|
return;
|
||||||
@@ -1850,11 +1855,11 @@ void EpubReaderActivity::render(RenderLock&& lock) {
|
|||||||
if (!section->createSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
if (!section->createSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
||||||
SETTINGS.extraParagraphSpacing, getEffectiveParagraphAlignment(), viewportWidth,
|
SETTINGS.extraParagraphSpacing, getEffectiveParagraphAlignment(), viewportWidth,
|
||||||
viewportHeight, getEffectiveHyphenation(), embeddedStyle,
|
viewportHeight, getEffectiveHyphenation(), embeddedStyle,
|
||||||
bookBionicReadingOverride, imageRendering, progressFn)) {
|
getEffectiveBionicReading(), imageRendering, progressFn)) {
|
||||||
LOG_ERR("ERS", "Failed to rebuild CSS section cache; keeping fallback");
|
LOG_ERR("ERS", "Failed to rebuild CSS section cache; keeping fallback");
|
||||||
section->loadSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
section->loadSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
||||||
SETTINGS.extraParagraphSpacing, getEffectiveParagraphAlignment(), viewportWidth,
|
SETTINGS.extraParagraphSpacing, getEffectiveParagraphAlignment(), viewportWidth,
|
||||||
viewportHeight, getEffectiveHyphenation(), embeddedStyle, bookBionicReadingOverride,
|
viewportHeight, getEffectiveHyphenation(), embeddedStyle, getEffectiveBionicReading(),
|
||||||
imageRendering);
|
imageRendering);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1975,7 +1980,7 @@ void EpubReaderActivity::silentIndexNextChapterIfNeeded(const uint16_t viewportW
|
|||||||
Section nextSection(epub, nextSpineIndex, renderer);
|
Section nextSection(epub, nextSpineIndex, renderer);
|
||||||
if (nextSection.loadSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
if (nextSection.loadSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
||||||
SETTINGS.extraParagraphSpacing, SETTINGS.paragraphAlignment, viewportWidth,
|
SETTINGS.extraParagraphSpacing, SETTINGS.paragraphAlignment, viewportWidth,
|
||||||
viewportHeight, getEffectiveHyphenation(), embeddedStyle, bookBionicReadingOverride,
|
viewportHeight, getEffectiveHyphenation(), embeddedStyle, getEffectiveBionicReading(),
|
||||||
imageRendering)) {
|
imageRendering)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1986,7 +1991,7 @@ void EpubReaderActivity::silentIndexNextChapterIfNeeded(const uint16_t viewportW
|
|||||||
if (!nextSection.createSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
if (!nextSection.createSectionFile(getEffectiveReaderFontId(), getEffectiveReaderLineCompression(),
|
||||||
SETTINGS.extraParagraphSpacing, SETTINGS.paragraphAlignment, viewportWidth,
|
SETTINGS.extraParagraphSpacing, SETTINGS.paragraphAlignment, viewportWidth,
|
||||||
viewportHeight, getEffectiveHyphenation(), embeddedStyle,
|
viewportHeight, getEffectiveHyphenation(), embeddedStyle,
|
||||||
bookBionicReadingOverride, imageRendering)) {
|
getEffectiveBionicReading(), imageRendering)) {
|
||||||
LOG_ERR("ERS", "Failed silent indexing for chapter: %d", nextSpineIndex);
|
LOG_ERR("ERS", "Failed silent indexing for chapter: %d", nextSpineIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2610,8 +2615,8 @@ void EpubReaderActivity::openQuickOverrides() {
|
|||||||
startActivityForResult(
|
startActivityForResult(
|
||||||
std::make_unique<QuickOverridesActivity>(
|
std::make_unique<QuickOverridesActivity>(
|
||||||
renderer, mappedInput, bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
|
renderer, mappedInput, bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
|
||||||
bookSdFontFamilyOverride, bookFontSizeOverride, static_cast<int8_t>(bookBionicReadingOverride ? 1 : 0),
|
bookSdFontFamilyOverride, bookFontSizeOverride, bookBionicReadingOverride, bookParagraphAlignmentOverride,
|
||||||
bookParagraphAlignmentOverride, bookTextAntiAliasingOverride, bookHyphenationOverride),
|
bookTextAntiAliasingOverride, bookHyphenationOverride),
|
||||||
[this](const ActivityResult& result) {
|
[this](const ActivityResult& result) {
|
||||||
const auto& menu = std::get<MenuResult>(result.data);
|
const auto& menu = std::get<MenuResult>(result.data);
|
||||||
applyBookReaderOverrides(menu.embeddedStyleOverride, menu.imageRenderingOverride, menu.fontFamilyOverride,
|
applyBookReaderOverrides(menu.embeddedStyleOverride, menu.imageRenderingOverride, menu.fontFamilyOverride,
|
||||||
@@ -2637,7 +2642,7 @@ void EpubReaderActivity::openReaderMenu() {
|
|||||||
std::make_unique<EpubReaderMenuActivity>(
|
std::make_unique<EpubReaderMenuActivity>(
|
||||||
renderer, mappedInput, epub->getTitle(), currentPage, totalPages, bookProgressPercent, SETTINGS.orientation,
|
renderer, mappedInput, epub->getTitle(), currentPage, totalPages, bookProgressPercent, SETTINGS.orientation,
|
||||||
!currentPageFootnotes.empty(), bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
|
!currentPageFootnotes.empty(), bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
|
||||||
bookSdFontFamilyOverride, bookFontSizeOverride, SETTINGS.textDarkness, bookBionicReadingOverride,
|
bookSdFontFamilyOverride, bookFontSizeOverride, SETTINGS.textDarkness, getEffectiveBionicReading(),
|
||||||
bookParagraphAlignmentOverride, !bookmarkStore.isEmpty(), isCurrentPageStarred),
|
bookParagraphAlignmentOverride, !bookmarkStore.isEmpty(), isCurrentPageStarred),
|
||||||
[this](const ActivityResult& result) {
|
[this](const ActivityResult& result) {
|
||||||
const auto& menu = std::get<MenuResult>(result.data);
|
const auto& menu = std::get<MenuResult>(result.data);
|
||||||
@@ -2781,7 +2786,7 @@ void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION
|
|||||||
case BA::BTN_TOGGLE_BIONIC_READING:
|
case BA::BTN_TOGGLE_BIONIC_READING:
|
||||||
if (epub) {
|
if (epub) {
|
||||||
applyBookReaderOverrides(bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
|
applyBookReaderOverrides(bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
|
||||||
bookSdFontFamilyOverride, bookFontSizeOverride, !bookBionicReadingOverride,
|
bookSdFontFamilyOverride, bookFontSizeOverride, !getEffectiveBionicReading(),
|
||||||
bookParagraphAlignmentOverride);
|
bookParagraphAlignmentOverride);
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ class EpubReaderActivity final : public Activity {
|
|||||||
int8_t bookFontFamilyOverride = -1;
|
int8_t bookFontFamilyOverride = -1;
|
||||||
std::string bookSdFontFamilyOverride;
|
std::string bookSdFontFamilyOverride;
|
||||||
int8_t bookFontSizeOverride = -1;
|
int8_t bookFontSizeOverride = -1;
|
||||||
bool bookBionicReadingOverride = false;
|
int8_t bookBionicReadingOverride = -1;
|
||||||
int8_t bookParagraphAlignmentOverride = -1;
|
int8_t bookParagraphAlignmentOverride = -1;
|
||||||
int8_t bookTextAntiAliasingOverride = -1;
|
int8_t bookTextAntiAliasingOverride = -1;
|
||||||
int8_t bookHyphenationOverride = -1;
|
int8_t bookHyphenationOverride = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user