Files
crosspoint-reader-mod/chat-summaries/2026-02-17_long-press-confirm-toc.md

38 lines
2.0 KiB
Markdown
Raw Normal View History

# Long-Press Confirm to Open Table of Contents
**Date**: 2026-02-17
**Branch**: mod/improve-home-screen
## Task
Add long-press detection on the Confirm button while reading an EPUB to directly open the Table of Contents (chapter selection), bypassing the reader menu. Short press retains existing behavior (opens menu).
## Changes Made
### `src/activities/reader/EpubReaderActivity.h`
- Added `bool ignoreNextConfirmRelease` member to suppress short-press after a long-press Confirm
- Added `void openChapterSelection()` private method declaration
### `src/activities/reader/EpubReaderActivity.cpp`
- Added `constexpr unsigned long longPressConfirmMs = 700` threshold constant
- Extracted `openChapterSelection()` helper method from the duplicated `EpubReaderChapterSelectionActivity` construction code
- Added long-press Confirm detection in `loop()` (before the existing short-press check): opens TOC directly if `epub->getTocItemsCount() > 0`
- Refactored `onReaderMenuConfirm(SELECT_CHAPTER)` to use the new helper (was ~35 lines of inline construction)
- Refactored `onReaderMenuConfirm(GO_TO_BOOKMARK)` fallback (no bookmarks + TOC available) to use the same helper
- Reset `ignoreNextConfirmRelease` when `skipNextButtonCheck` clears, to avoid stale state across subactivity transitions
### `src/activities/reader/EpubReaderChapterSelectionActivity.h`
- Added `bool ignoreNextConfirmRelease` member
- Added `initialSkipRelease` constructor parameter (default `false`) to consume stale Confirm release when opened via long-press
### `src/activities/reader/EpubReaderChapterSelectionActivity.cpp`
- Added guard in `loop()` to skip the first Confirm release when `ignoreNextConfirmRelease` is true
## Pattern Used
Follows the existing Back button short/long-press pattern: `isPressed() + getHeldTime() >= threshold` for long press, `wasReleased()` for short press, with `ignoreNextConfirmRelease` flag (same pattern as `EpubReaderMenuActivity`, `LookedUpWordsActivity`, and other activities).
## Follow-up Items
- None identified