From d29b8ee2f9f053e10fcd8831e79ab72e6da3344b Mon Sep 17 00:00:00 2001 From: nscheung <6036668+nscheung@users.noreply.github.com> Date: Wed, 8 Apr 2026 11:09:28 -0700 Subject: [PATCH] feat: Adjust Navigation at End of Book (#1425) ## Summary * **What is the goal of this PR? (e.g., Implements the new feature for file uploading.)** Currently, pressing forward at the end of a book loops back to the last page. This change will instead sends you to the home page instead. * **What changes are included?** Applies the change to the three supported format: EPUB, XTC, TXT ## Additional Context * This is more of a QOL improvement than a new feature. If there's interest, we could extend this to track a completed state for ebooks. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**YES**_ --- src/activities/reader/EpubReaderActivity.cpp | 12 ++++++++---- src/activities/reader/TxtReaderActivity.cpp | 10 +++++++--- src/activities/reader/XtcReaderActivity.cpp | 10 +++++++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 16d403aaa..65dbe17c8 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -181,11 +181,15 @@ void EpubReaderActivity::loop() { return; } - // any botton press when at end of the book goes back to the last page + // At end of the book, forward button goes home and back button returns to last page if (currentSpineIndex > 0 && currentSpineIndex >= epub->getSpineItemsCount()) { - currentSpineIndex = epub->getSpineItemsCount() - 1; - nextPageNumber = UINT16_MAX; - requestUpdate(); + if (nextTriggered) { + onGoHome(); + } else { + currentSpineIndex = epub->getSpineItemsCount() - 1; + nextPageNumber = UINT16_MAX; + requestUpdate(); + } return; } diff --git a/src/activities/reader/TxtReaderActivity.cpp b/src/activities/reader/TxtReaderActivity.cpp index c723bcb15..6bc3ba5ad 100644 --- a/src/activities/reader/TxtReaderActivity.cpp +++ b/src/activities/reader/TxtReaderActivity.cpp @@ -79,9 +79,13 @@ void TxtReaderActivity::loop() { if (prevTriggered && currentPage > 0) { currentPage--; requestUpdate(); - } else if (nextTriggered && currentPage < totalPages - 1) { - currentPage++; - requestUpdate(); + } else if (nextTriggered) { + if (currentPage < totalPages - 1) { + currentPage++; + requestUpdate(); + } else { + onGoHome(); + } } } diff --git a/src/activities/reader/XtcReaderActivity.cpp b/src/activities/reader/XtcReaderActivity.cpp index 84cc51da2..d2b6f18ea 100644 --- a/src/activities/reader/XtcReaderActivity.cpp +++ b/src/activities/reader/XtcReaderActivity.cpp @@ -98,10 +98,14 @@ void XtcReaderActivity::loop() { return; } - // Handle end of book + // At end of the book, forward button goes home and back button returns to last page if (currentPage >= xtc->getPageCount()) { - currentPage = xtc->getPageCount() - 1; - requestUpdate(); + if (nextTriggered) { + onGoHome(); + } else { + currentPage = xtc->getPageCount() - 1; + requestUpdate(); + } return; }