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**_
This commit is contained in:
nscheung
2026-04-08 21:09:28 +03:00
committed by GitHub
parent b898d53f7b
commit d29b8ee2f9
3 changed files with 22 additions and 10 deletions
+8 -4
View File
@@ -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;
}
+7 -3
View File
@@ -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();
}
}
}
+7 -3
View File
@@ -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;
}