feat: add post-download prompt with open book / back to listing options

After an OPDS download completes, show a prompt screen instead of
immediately returning to the catalog. The user can choose to open the
book for reading or go back to the listing. A live countdown (5s, fast
refresh) auto-selects the configured default; any button press cancels
the timer. A per-server "After Download" setting controls the default
action (back to listing for backward compatibility).

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-02 15:27:53 -05:00
parent f955cf2fb4
commit 7eaced602f
8 changed files with 127 additions and 11 deletions

View File

@@ -23,12 +23,18 @@ class OpdsBookBrowserActivity final : public ActivityWithSubactivity {
BROWSING, // Displaying entries (navigation or books)
PICKING_DIRECTORY, // Directory picker subactivity is active
DOWNLOADING, // Downloading selected EPUB
DOWNLOAD_COMPLETE, // Prompt: open book or go back to listing
ERROR // Error state with message
};
explicit OpdsBookBrowserActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
const std::function<void()>& onGoHome, const OpdsServer& server)
: ActivityWithSubactivity("OpdsBookBrowser", renderer, mappedInput), onGoHome(onGoHome), server(server) {}
const std::function<void()>& onGoHome,
const std::function<void(const std::string&)>& onGoToReader,
const OpdsServer& server)
: ActivityWithSubactivity("OpdsBookBrowser", renderer, mappedInput),
onGoHome(onGoHome),
onGoToReader(onGoToReader),
server(server) {}
void onEnter() override;
void onExit() override;
@@ -46,8 +52,14 @@ class OpdsBookBrowserActivity final : public ActivityWithSubactivity {
std::string statusMessage;
size_t downloadProgress = 0;
size_t downloadTotal = 0;
std::string downloadedFilePath;
unsigned long downloadCompleteTime = 0;
int promptSelection = 0; // 0 = back to listing, 1 = open book
bool countdownActive = false;
int lastCountdownSecond = -1;
const std::function<void()> onGoHome;
const std::function<void(const std::string&)> onGoToReader;
OpdsServer server; // Copied at construction — safe even if the store changes during browsing
void checkAndConnectWifi();
@@ -60,6 +72,7 @@ class OpdsBookBrowserActivity final : public ActivityWithSubactivity {
void onDirectorySelected(const std::string& directory);
void onDirectoryPickerCancelled();
void downloadBook(const OpdsEntry& book, const std::string& directory);
void executePromptAction(int action);
bool preventAutoSleep() override { return true; }
OpdsEntry pendingBook;