- Fix device freeze at end-of-book by deferring EndOfBookMenuActivity creation from render() to loop() (avoids RenderLock deadlock) in EpubReaderActivity and XtcReaderActivity - Add initialSkipRelease to BookManageMenuActivity to prevent stale Confirm release from triggering actions when opened via long-press - Add initialSkipRelease to MyLibraryActivity for long-press Browse Files -> archive navigation - Thread skip-release through HomeActivity callback and main.cpp - Fix HomeActivity stale cover buffer after archive/delete by fully resetting render state (freeCoverBuffer, firstRenderDone, etc.) - Swap short/long-press actions in .archive context: short-press opens manage menu, long-press unarchives and opens the book - Add deferred open pattern (pendingOpenPath) to wait for Confirm release before navigating to reader after unarchive - Add BookManager::cleanupEmptyArchiveDirs() to remove empty parent directories after unarchive/delete inside .archive - Add optional unarchivedPath output parameter to BookManager::unarchiveBook - Restyle EndOfBookMenuActivity to standard list layout with proper header, margins, and button hints matching other screens - Change EndOfBookMenuActivity back button hint to "« Back" - Add Table of Contents option to EndOfBookMenuActivity Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
1.7 KiB
C++
54 lines
1.7 KiB
C++
#pragma once
|
|
#include <functional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "../ActivityWithSubactivity.h"
|
|
#include "RecentBooksStore.h"
|
|
#include "util/ButtonNavigator.h"
|
|
|
|
class MyLibraryActivity final : public ActivityWithSubactivity {
|
|
private:
|
|
ButtonNavigator buttonNavigator;
|
|
|
|
size_t selectorIndex = 0;
|
|
|
|
// Files state
|
|
std::string basepath = "/";
|
|
std::vector<std::string> files;
|
|
|
|
// Long-press state
|
|
bool ignoreNextConfirmRelease = false;
|
|
static constexpr unsigned long LONG_PRESS_MS = 700;
|
|
|
|
// Deferred open: wait for Confirm release before navigating to book
|
|
std::string pendingOpenPath;
|
|
|
|
// Callbacks
|
|
const std::function<void(const std::string& path)> onSelectBook;
|
|
const std::function<void()> onGoHome;
|
|
|
|
// Data loading
|
|
void loadFiles();
|
|
size_t findEntry(const std::string& name) const;
|
|
bool isInArchive() const;
|
|
|
|
void openManageMenu(const std::string& bookPath);
|
|
void unarchiveAndOpen(const std::string& bookPath);
|
|
|
|
public:
|
|
explicit MyLibraryActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
|
const std::function<void()>& onGoHome,
|
|
const std::function<void(const std::string& path)>& onSelectBook,
|
|
std::string initialPath = "/", bool initialSkipRelease = false)
|
|
: ActivityWithSubactivity("MyLibrary", renderer, mappedInput),
|
|
basepath(initialPath.empty() ? "/" : std::move(initialPath)),
|
|
ignoreNextConfirmRelease(initialSkipRelease),
|
|
onSelectBook(onSelectBook),
|
|
onGoHome(onGoHome) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
void render(Activity::RenderLock&&) override;
|
|
};
|