Compare commits

..

No commits in common. "c6640aa645696362a0a6d66c611a7deac9bae3eb" and "5d8178cf9dc0e02abe22dfe2d01d08f24d01431b" have entirely different histories.

5 changed files with 51 additions and 17 deletions

View File

@ -435,8 +435,11 @@ bool Epub::generateThumbBmp(int height) const {
const auto coverImageHref = bookMetadataCache->coreMetadata.coverItemHref;
if (coverImageHref.empty()) {
Serial.printf("[%lu] [EBP] No known cover image for thumbnail\n", millis());
} else if (coverImageHref.substr(coverImageHref.length() - 4) == ".jpg" ||
coverImageHref.substr(coverImageHref.length() - 5) == ".jpeg") {
return false;
}
if (coverImageHref.substr(coverImageHref.length() - 4) == ".jpg" ||
coverImageHref.substr(coverImageHref.length() - 5) == ".jpeg") {
Serial.printf("[%lu] [EBP] Generating thumb BMP from JPG cover image\n", millis());
const auto coverJpgTempPath = getCachePath() + "/.cover.jpg";
@ -477,10 +480,6 @@ bool Epub::generateThumbBmp(int height) const {
Serial.printf("[%lu] [EBP] Cover image is not a JPG, skipping thumbnail\n", millis());
}
// Write an empty bmp file to avoid generation attempts in the future
FsFile thumbBmp;
SdMan.openFileForWrite("EBP", getThumbBmpPath(height), thumbBmp);
thumbBmp.close();
return false;
}

View File

@ -149,7 +149,7 @@ void HomeActivity::onEnter() {
updateRequired = true;
xTaskCreate(&HomeActivity::taskTrampoline, "HomeActivityTask",
8192, // Stack size
4096, // Stack size (increased for cover image rendering)
this, // Parameters
1, // Priority
&displayTaskHandle // Task handle

View File

@ -157,7 +157,6 @@ void MyLibraryActivity::loop() {
if (currentTab == Tab::Recent) {
if (!bookPaths.empty() && selectorIndex < static_cast<int>(bookPaths.size())) {
onSelectBook(bookPaths[selectorIndex], currentTab);
return;
}
} else {
if (files.empty()) {
@ -172,7 +171,6 @@ void MyLibraryActivity::loop() {
updateRequired = true;
} else {
onSelectBook(basepath + files[selectorIndex], currentTab);
return;
}
}
}
@ -209,20 +207,18 @@ void MyLibraryActivity::loop() {
updateRequired = true;
return;
}
int listSize = (currentTab == Tab::Recent) ? static_cast<int>(bookTitles.size()) : static_cast<int>(files.size());
if (upReleased) {
if (skipPage) {
selectorIndex = ((selectorIndex / pageItems - 1) * pageItems + listSize) % listSize;
selectorIndex = ((selectorIndex / pageItems - 1) * pageItems + files.size()) % files.size();
} else {
selectorIndex = (selectorIndex + listSize - 1) % listSize;
selectorIndex = (selectorIndex + files.size() - 1) % files.size();
}
updateRequired = true;
} else if (downReleased) {
if (skipPage) {
selectorIndex = ((selectorIndex / pageItems + 1) * pageItems) % listSize;
selectorIndex = ((selectorIndex / pageItems + 1) * pageItems) % files.size();
} else {
selectorIndex = (selectorIndex + 1) % listSize;
selectorIndex = (selectorIndex + 1) % files.size();
}
updateRequired = true;
}

View File

@ -285,6 +285,45 @@ void EpubReaderActivity::renderScreen() {
viewportHeight, SETTINGS.hyphenationEnabled)) {
Serial.printf("[%lu] [ERS] Cache not found, building...\n", millis());
// // Progress bar dimensions
// constexpr int barWidth = 200;
// constexpr int barHeight = 10;
// constexpr int boxMargin = 20;
// const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, "Indexing...");
// const int boxWidthWithBar = (barWidth > textWidth ? barWidth : textWidth) + boxMargin * 2;
// const int boxWidthNoBar = textWidth + boxMargin * 2;
// const int boxHeightWithBar = renderer.getLineHeight(UI_12_FONT_ID) + barHeight + boxMargin * 3;
// const int boxHeightNoBar = renderer.getLineHeight(UI_12_FONT_ID) + boxMargin * 2;
// const int boxXWithBar = (renderer.getScreenWidth() - boxWidthWithBar) / 2;
// const int boxXNoBar = (renderer.getScreenWidth() - boxWidthNoBar) / 2;
// constexpr int boxY = 50;
// const int barX = boxXWithBar + (boxWidthWithBar - barWidth) / 2;
// const int barY = boxY + renderer.getLineHeight(UI_12_FONT_ID) + boxMargin * 2;
// // Always show "Indexing..." text first
// {
// renderer.fillRect(boxXNoBar, boxY, boxWidthNoBar, boxHeightNoBar, false);
// renderer.drawText(UI_12_FONT_ID, boxXNoBar + boxMargin, boxY + boxMargin, "Indexing...");
// renderer.drawRect(boxXNoBar + 5, boxY + 5, boxWidthNoBar - 10, boxHeightNoBar - 10);
// renderer.displayBuffer();
// pagesUntilFullRefresh = 0;
// }
// // Setup callback - only called for chapters >= 50KB, redraws with progress bar
// auto progressSetup = [this, boxXWithBar, boxWidthWithBar, boxHeightWithBar, barX, barY] {
// renderer.fillRect(boxXWithBar, boxY, boxWidthWithBar, boxHeightWithBar, false);
// renderer.drawText(UI_12_FONT_ID, boxXWithBar + boxMargin, boxY + boxMargin, "Indexing...");
// renderer.drawRect(boxXWithBar + 5, boxY + 5, boxWidthWithBar - 10, boxHeightWithBar - 10);
// renderer.drawRect(barX, barY, barWidth, barHeight);
// renderer.displayBuffer();
// };
// // Progress callback to update progress bar
// auto progressCallback = [this, barX, barY, barWidth, barHeight](int progress) {
// const int fillWidth = (barWidth - 2) * progress / 100;
// renderer.fillRect(barX + 1, barY + 1, fillWidth, barHeight - 2, true);
// renderer.displayBuffer(EInkDisplay::FAST_REFRESH);
// };
auto popupCallbacks = UITheme::drawPopupWithProgress(renderer, "Indexing...");
if (!section->createSectionFile(SETTINGS.getReaderFontId(), SETTINGS.getReaderLineCompression(),

View File

@ -319,7 +319,7 @@ void LyraTheme::drawButtonMenu(GfxRenderer& renderer, Rect rect, int buttonCount
}
void LyraTheme::drawPopup(GfxRenderer& renderer, const char* message) {
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::REGULAR);
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::BOLD);
constexpr int margin = 20;
const int x = (renderer.getScreenWidth() - textWidth - margin * 2) / 2;
constexpr int y = 117;
@ -328,6 +328,6 @@ void LyraTheme::drawPopup(GfxRenderer& renderer, const char* message) {
renderer.fillRect(x - 5, y - 5, w + 10, h + 10, false);
renderer.drawRect(x + 5, y + 5, w - 10, h - 10, true);
renderer.drawText(UI_12_FONT_ID, x + margin, y + margin, message, true, EpdFontFamily::REGULAR);
renderer.drawText(UI_12_FONT_ID, x + margin, y + margin, message, true, EpdFontFamily::BOLD);
renderer.displayBuffer();
}