Files
crosspoint-reader-mod/src/activities/reader/EpubReaderMenuActivity.h
cottongin bd2cea8b8d mod: Phase 2b - adapt HomeActivity, EpubReaderMenuActivity, EpubReaderActivity
HomeActivity: Add mod features on top of upstream ActivityManager pattern:
- Multi-server OPDS support (OpdsServerStore instead of single URL)
- Long-press recent book for BookManageMenuActivity
- Long-press Browse Files to open archive folder
- Placeholder cover generation for books without covers
- startActivityForResult pattern for manage menu

EpubReaderMenuActivity: Replace upstream menu items with mod menu:
- Add/Remove Bookmark, Lookup Word, Go to Bookmark, Lookup History
- Table of Contents, Toggle Orientation, Toggle Font Size
- Close Book, Delete Dictionary Cache
- Pass isBookmarked and currentFontSize to constructor
- Show current orientation/font size value inline

EpubReaderActivity: Add mod action handlers:
- Bookmark add/remove via BookmarkStore
- Go to Bookmark via EpubReaderBookmarkSelectionActivity
- Dictionary word lookup via DictionaryWordSelectActivity
- Lookup history via LookedUpWordsActivity
- Delete dictionary cache
- Font size toggle with section re-layout
- Close Book action

ActivityResult: Add fontSize field to MenuResult
Made-with: Cursor
2026-03-07 15:38:53 -05:00

74 lines
2.1 KiB
C++

#pragma once
#include <Epub.h>
#include <I18n.h>
#include <string>
#include <vector>
#include "../Activity.h"
#include "util/ButtonNavigator.h"
class EpubReaderMenuActivity final : public Activity {
public:
// Menu actions available from the reader menu.
enum class MenuAction {
SELECT_CHAPTER,
FOOTNOTES,
GO_TO_PERCENT,
AUTO_PAGE_TURN,
ROTATE_SCREEN,
SCREENSHOT,
DISPLAY_QR,
GO_HOME,
SYNC,
DELETE_CACHE,
// Mod-specific actions
ADD_BOOKMARK,
REMOVE_BOOKMARK,
LOOKUP_WORD,
LOOKUP_HISTORY,
GO_TO_BOOKMARK,
TABLE_OF_CONTENTS,
TOGGLE_ORIENTATION,
TOGGLE_FONT_SIZE,
CLOSE_BOOK,
DELETE_DICT_CACHE
};
explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& title,
const int currentPage, const int totalPages, const int bookProgressPercent,
const uint8_t currentOrientation, const bool hasFootnotes,
bool isBookmarked = false, uint8_t currentFontSize = 0);
void onEnter() override;
void onExit() override;
void loop() override;
void render(RenderLock&&) override;
private:
struct MenuItem {
MenuAction action;
StrId labelId;
};
static std::vector<MenuItem> buildMenuItems(bool hasFootnotes, bool isBookmarked);
// Fixed menu layout
const std::vector<MenuItem> menuItems;
int selectedIndex = 0;
ButtonNavigator buttonNavigator;
std::string title = "Reader Menu";
uint8_t pendingOrientation = 0;
uint8_t pendingFontSize = 0;
uint8_t selectedPageTurnOption = 0;
const std::vector<StrId> orientationLabels = {StrId::STR_PORTRAIT, StrId::STR_LANDSCAPE_CW, StrId::STR_INVERTED,
StrId::STR_LANDSCAPE_CCW};
const std::vector<StrId> fontSizeLabels = {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE};
const std::vector<const char*> pageTurnLabels = {I18N.get(StrId::STR_STATE_OFF), "1", "3", "6", "12"};
int currentPage = 0;
int totalPages = 0;
int bookProgressPercent = 0;
};