mirror of
https://github.com/crosspoint-reader/crosspoint-reader.git
synced 2026-04-29 10:26:52 -07:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user