## Summary * **What is the goal of this PR?** Add a "Continue Reading" feature to improve user experience when returning to a previously opened book. * **What changes are included?** - Add dynamic "Continue: <book name>" menu item in Home screen when a book was previously opened - File browser now starts from the folder of the last opened book instead of always starting from root directory - Menu dynamically shows 3 or 4 items based on reading history: - Without history: `Browse`, `File transfer`, `Settings` - With history: `Continue: <book>`, `Browse`, `File transfer`, `Settings` ## Additional Context * This feature leverages the existing `APP_STATE.openEpubPath` which already persists the last opened book path * The Continue Reading menu only appears if the book file still exists on the SD card * Book name in the menu is truncated to 25 characters with "..." suffix if too long * If the last book's folder was deleted, the file browser gracefully falls back to root directory * No new dependencies or significant memory overhead - reuses existing state management
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
#pragma once
|
|
#include <Epub.h>
|
|
#include <Epub/Section.h>
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/semphr.h>
|
|
#include <freertos/task.h>
|
|
|
|
#include "activities/ActivityWithSubactivity.h"
|
|
|
|
class EpubReaderActivity final : public ActivityWithSubactivity {
|
|
std::shared_ptr<Epub> epub;
|
|
std::unique_ptr<Section> section = nullptr;
|
|
TaskHandle_t displayTaskHandle = nullptr;
|
|
SemaphoreHandle_t renderingMutex = nullptr;
|
|
int currentSpineIndex = 0;
|
|
int nextPageNumber = 0;
|
|
int pagesUntilFullRefresh = 0;
|
|
bool updateRequired = false;
|
|
const std::function<void()> onGoBack;
|
|
const std::function<void()> onGoHome;
|
|
|
|
static void taskTrampoline(void* param);
|
|
[[noreturn]] void displayTaskLoop();
|
|
void renderScreen();
|
|
void renderContents(std::unique_ptr<Page> p);
|
|
void renderStatusBar() const;
|
|
|
|
public:
|
|
explicit EpubReaderActivity(GfxRenderer& renderer, InputManager& inputManager, std::unique_ptr<Epub> epub,
|
|
const std::function<void()>& onGoBack, const std::function<void()>& onGoHome)
|
|
: ActivityWithSubactivity("EpubReader", renderer, inputManager),
|
|
epub(std::move(epub)),
|
|
onGoBack(onGoBack),
|
|
onGoHome(onGoHome) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
};
|