This commit is contained in:
jpirnay
2026-05-12 18:51:31 +02:00
parent a91c151979
commit adb5bcdbd6
10 changed files with 59 additions and 102 deletions
+41 -63
View File
@@ -198,43 +198,7 @@ void TxtReaderActivity::loop() {
currentPage++;
requestUpdate();
} else {
saveProgress();
const std::string nextBookPath =
BookFinished::findNextBookInDirectory(txt->getPath(), std::string(), std::string());
startActivityForResult(
std::make_unique<FinishedBookActivity>(renderer, mappedInput, txt->getPath(), nextBookPath,
SETTINGS.moveFinishedBooksToCompleted),
[this, nextBookPath](const ActivityResult& result) {
if (result.isCancelled) {
requestUpdate();
return;
}
const auto& menuResult = std::get<MenuResult>(result.data);
if (menuResult.action == static_cast<int>(BookFinished::FinishedBookAction::GoHome)) {
if (SETTINGS.moveFinishedBooksToCompleted) {
std::string movedPath;
BookFinished::moveFinishedBookToCompleted(txt->getPath(), movedPath);
}
if (SETTINGS.removeFinishedBooksFromRecents) {
RECENT_BOOKS.removeBook(txt->getPath());
}
activityManager.goHome();
return;
}
if (menuResult.action == static_cast<int>(BookFinished::FinishedBookAction::OpenNextBook) &&
!nextBookPath.empty()) {
if (SETTINGS.moveFinishedBooksToCompleted) {
std::string movedPath;
BookFinished::moveFinishedBookToCompleted(txt->getPath(), movedPath);
}
if (SETTINGS.removeFinishedBooksFromRecents) {
RECENT_BOOKS.removeBook(txt->getPath());
}
activityManager.goToReader(nextBookPath);
return;
}
requestUpdate();
});
launchFinishedBookFlow();
}
return;
}
@@ -255,36 +219,50 @@ void TxtReaderActivity::loop() {
currentPage++;
requestUpdate();
} else {
const std::string nextBookPath =
BookFinished::findNextBookInDirectory(txt->getPath(), std::string(), std::string());
startActivityForResult(
std::make_unique<FinishedBookActivity>(renderer, mappedInput, txt->getPath(), nextBookPath,
SETTINGS.moveFinishedBooksToCompleted),
[this, nextBookPath](const ActivityResult& result) {
if (result.isCancelled) {
requestUpdate();
return;
}
const auto& menuResult = std::get<MenuResult>(result.data);
if (menuResult.action == static_cast<int>(BookFinished::FinishedBookAction::GoHome)) {
activityManager.goHome();
return;
}
if (menuResult.action == static_cast<int>(BookFinished::FinishedBookAction::OpenNextBook) &&
!nextBookPath.empty()) {
if (SETTINGS.moveFinishedBooksToCompleted) {
std::string movedPath;
BookFinished::moveFinishedBookToCompleted(txt->getPath(), movedPath);
}
activityManager.goToReader(nextBookPath);
return;
}
requestUpdate();
});
launchFinishedBookFlow();
}
}
}
void TxtReaderActivity::launchFinishedBookFlow() {
saveProgress();
const std::string currentBookPath = txt->getPath();
const std::string nextBookPath = BookFinished::findNextBookInDirectory(currentBookPath, std::string(), std::string());
startActivityForResult(std::make_unique<FinishedBookActivity>(renderer, mappedInput, currentBookPath, nextBookPath),
[this, currentBookPath, nextBookPath](const ActivityResult& result) {
if (result.isCancelled) {
requestUpdate();
return;
}
const auto& menuResult = std::get<MenuResult>(result.data);
if (menuResult.action == static_cast<int>(BookFinished::FinishedBookAction::GoHome)) {
if (SETTINGS.moveFinishedBooksToCompleted) {
std::string movedPath;
BookFinished::moveFinishedBookToCompleted(currentBookPath, movedPath);
}
if (SETTINGS.removeFinishedBooksFromRecents) {
RECENT_BOOKS.removeBook(currentBookPath);
}
activityManager.goHome();
return;
}
if (menuResult.action == static_cast<int>(BookFinished::FinishedBookAction::OpenNextBook) &&
!nextBookPath.empty()) {
if (SETTINGS.moveFinishedBooksToCompleted) {
std::string movedPath;
BookFinished::moveFinishedBookToCompleted(currentBookPath, movedPath);
}
if (SETTINGS.removeFinishedBooksFromRecents) {
RECENT_BOOKS.removeBook(currentBookPath);
}
activityManager.goToReader(nextBookPath);
return;
}
requestUpdate();
});
}
void TxtReaderActivity::initializeReader() {
if (initialized) {
return;