#pragma once #include #include #include "../ActivityWithSubactivity.h" #include "./MyLibraryActivity.h" #include "util/ButtonNavigator.h" struct RecentBook; struct Rect; class HomeActivity final : public ActivityWithSubactivity { ButtonNavigator buttonNavigator; int selectorIndex = 0; bool recentsLoading = false; bool recentsLoaded = false; bool firstRenderDone = false; bool hasOpdsUrl = false; bool coverRendered = false; // Track if cover has been rendered once bool coverBufferStored = false; // Track if cover buffer is stored uint8_t* coverBuffer = nullptr; // HomeActivity's own buffer for cover image std::vector recentBooks; // Long-press state bool ignoreNextConfirmRelease = false; static constexpr unsigned long LONG_PRESS_MS = 700; const std::function onSelectBook; const std::function onMyLibraryOpen; const std::function onMyLibraryOpenWithPath; const std::function onRecentsOpen; const std::function onSettingsOpen; const std::function onFileTransferOpen; const std::function onOpdsBrowserOpen; int getMenuItemCount() const; bool storeCoverBuffer(); // Store frame buffer for cover image bool restoreCoverBuffer(); // Restore frame buffer from stored cover void freeCoverBuffer(); // Free the stored cover buffer void loadRecentBooks(int maxBooks); void loadRecentCovers(int coverHeight); void openManageMenu(const std::string& bookPath); public: explicit HomeActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::function& onSelectBook, const std::function& onMyLibraryOpen, const std::function& onMyLibraryOpenWithPath, const std::function& onRecentsOpen, const std::function& onSettingsOpen, const std::function& onFileTransferOpen, const std::function& onOpdsBrowserOpen) : ActivityWithSubactivity("Home", renderer, mappedInput), onSelectBook(onSelectBook), onMyLibraryOpen(onMyLibraryOpen), onMyLibraryOpenWithPath(onMyLibraryOpenWithPath), onRecentsOpen(onRecentsOpen), onSettingsOpen(onSettingsOpen), onFileTransferOpen(onFileTransferOpen), onOpdsBrowserOpen(onOpdsBrowserOpen) {} void onEnter() override; void onExit() override; void loop() override; void render(Activity::RenderLock&&) override; };