Add Continue Reading menu and remember last book folder (#129)
## 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
This commit is contained in:
@@ -12,6 +12,8 @@ class HomeActivity final : public Activity {
|
||||
SemaphoreHandle_t renderingMutex = nullptr;
|
||||
int selectorIndex = 0;
|
||||
bool updateRequired = false;
|
||||
bool hasContinueReading = false;
|
||||
const std::function<void()> onContinueReading;
|
||||
const std::function<void()> onReaderOpen;
|
||||
const std::function<void()> onSettingsOpen;
|
||||
const std::function<void()> onFileTransferOpen;
|
||||
@@ -19,11 +21,14 @@ class HomeActivity final : public Activity {
|
||||
static void taskTrampoline(void* param);
|
||||
[[noreturn]] void displayTaskLoop();
|
||||
void render() const;
|
||||
int getMenuItemCount() const;
|
||||
|
||||
public:
|
||||
explicit HomeActivity(GfxRenderer& renderer, InputManager& inputManager, const std::function<void()>& onReaderOpen,
|
||||
explicit HomeActivity(GfxRenderer& renderer, InputManager& inputManager,
|
||||
const std::function<void()>& onContinueReading, const std::function<void()>& onReaderOpen,
|
||||
const std::function<void()>& onSettingsOpen, const std::function<void()>& onFileTransferOpen)
|
||||
: Activity("Home", renderer, inputManager),
|
||||
onContinueReading(onContinueReading),
|
||||
onReaderOpen(onReaderOpen),
|
||||
onSettingsOpen(onSettingsOpen),
|
||||
onFileTransferOpen(onFileTransferOpen) {}
|
||||
|
||||
Reference in New Issue
Block a user