Fixes
This commit is contained in:
@@ -20,6 +20,7 @@ STR_EMPTY_CHAPTER: "Empty chapter"
|
|||||||
STR_FINISHED_BOOK_HEADER: "Book finished!"
|
STR_FINISHED_BOOK_HEADER: "Book finished!"
|
||||||
STR_FINISHED_BOOK_HEADER_LINE1: "Congratulations, you finished this book."
|
STR_FINISHED_BOOK_HEADER_LINE1: "Congratulations, you finished this book."
|
||||||
STR_FINISHED_BOOK_HEADER_LINE2: "What do you want to do now?"
|
STR_FINISHED_BOOK_HEADER_LINE2: "What do you want to do now?"
|
||||||
|
STR_NEXT_BOOK_HEADER: "Next book to read:"
|
||||||
STR_GO_BACK_TO_HOME: "Go back to Home"
|
STR_GO_BACK_TO_HOME: "Go back to Home"
|
||||||
STR_GO_BACK_TO_HOME_DESC: "Return to the home screen"
|
STR_GO_BACK_TO_HOME_DESC: "Return to the home screen"
|
||||||
STR_OPEN_NEXT_BOOK: "Open the next book:"
|
STR_OPEN_NEXT_BOOK: "Open the next book:"
|
||||||
|
|||||||
@@ -324,6 +324,7 @@ STR_CHAPTER: "Rozdział"
|
|||||||
STR_EXAMPLE_CHAPTER: "Rozdział 21"
|
STR_EXAMPLE_CHAPTER: "Rozdział 21"
|
||||||
STR_EXAMPLE_BOOK: "Tytuł książki"
|
STR_EXAMPLE_BOOK: "Tytuł książki"
|
||||||
STR_PREVIEW: "Podgląd"
|
STR_PREVIEW: "Podgląd"
|
||||||
|
STR_NEXT_BOOK_HEADER: "Następna książka do przeczytania:"
|
||||||
STR_TITLE: "Tytuł"
|
STR_TITLE: "Tytuł"
|
||||||
STR_BATTERY: "Bateria"
|
STR_BATTERY: "Bateria"
|
||||||
STR_XTC_STATUS_BAR: "Pasek statusu XTC"
|
STR_XTC_STATUS_BAR: "Pasek statusu XTC"
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ bool JsonSettingsIO::saveSettings(const CrossPointSettings& s, const char* path)
|
|||||||
doc["sdFontFamilyName"] = s.sdFontFamilyName;
|
doc["sdFontFamilyName"] = s.sdFontFamilyName;
|
||||||
}
|
}
|
||||||
doc["moveFinishedBooksToCompleted"] = s.moveFinishedBooksToCompleted;
|
doc["moveFinishedBooksToCompleted"] = s.moveFinishedBooksToCompleted;
|
||||||
|
doc["removeFinishedBooksFromRecents"] = s.removeFinishedBooksFromRecents;
|
||||||
|
|
||||||
String json;
|
String json;
|
||||||
serializeJson(doc, json);
|
serializeJson(doc, json);
|
||||||
|
|||||||
@@ -472,8 +472,7 @@ void EpubReaderActivity::loop() {
|
|||||||
const std::string nextBookPath =
|
const std::string nextBookPath =
|
||||||
BookFinished::findNextBookInDirectory(epub->getPath(), epub->getSeries(), epub->getSeriesIndex());
|
BookFinished::findNextBookInDirectory(epub->getPath(), epub->getSeries(), epub->getSeriesIndex());
|
||||||
startActivityForResult(
|
startActivityForResult(
|
||||||
std::make_unique<FinishedBookActivity>(renderer, mappedInput, epub->getPath(), nextBookPath,
|
std::make_unique<FinishedBookActivity>(renderer, mappedInput, epub->getPath(), nextBookPath),
|
||||||
SETTINGS.moveFinishedBooksToCompleted),
|
|
||||||
[this, nextBookPath](const ActivityResult& result) {
|
[this, nextBookPath](const ActivityResult& result) {
|
||||||
if (result.isCancelled) {
|
if (result.isCancelled) {
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
@@ -722,8 +721,7 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction
|
|||||||
const std::string nextBookPath =
|
const std::string nextBookPath =
|
||||||
BookFinished::findNextBookInDirectory(epub->getPath(), epub->getSeries(), epub->getSeriesIndex());
|
BookFinished::findNextBookInDirectory(epub->getPath(), epub->getSeries(), epub->getSeriesIndex());
|
||||||
startActivityForResult(
|
startActivityForResult(
|
||||||
std::make_unique<FinishedBookActivity>(renderer, mappedInput, epub->getPath(), nextBookPath,
|
std::make_unique<FinishedBookActivity>(renderer, mappedInput, epub->getPath(), nextBookPath),
|
||||||
SETTINGS.moveFinishedBooksToCompleted),
|
|
||||||
[this, nextBookPath](const ActivityResult& result) {
|
[this, nextBookPath](const ActivityResult& result) {
|
||||||
if (result.isCancelled) {
|
if (result.isCancelled) {
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
@@ -1481,8 +1479,7 @@ void EpubReaderActivity::render(RenderLock&& lock) {
|
|||||||
BookFinished::findNextBookInDirectory(epub->getPath(), epub->getSeries(), epub->getSeriesIndex());
|
BookFinished::findNextBookInDirectory(epub->getPath(), epub->getSeries(), epub->getSeriesIndex());
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
startActivityForResult(
|
startActivityForResult(
|
||||||
std::make_unique<FinishedBookActivity>(renderer, mappedInput, epub->getPath(), nextBookPath,
|
std::make_unique<FinishedBookActivity>(renderer, mappedInput, epub->getPath(), nextBookPath),
|
||||||
SETTINGS.moveFinishedBooksToCompleted),
|
|
||||||
[this, nextBookPath](const ActivityResult& result) {
|
[this, nextBookPath](const ActivityResult& result) {
|
||||||
finishedBookActivityStarted_ = false;
|
finishedBookActivityStarted_ = false;
|
||||||
if (result.isCancelled) {
|
if (result.isCancelled) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ std::string getFilename(const std::string& filePath) {
|
|||||||
static constexpr int kFinishedBookCoverHeight = 240;
|
static constexpr int kFinishedBookCoverHeight = 240;
|
||||||
static constexpr int kFinishedBookCoverMaxWidth = 220;
|
static constexpr int kFinishedBookCoverMaxWidth = 220;
|
||||||
|
|
||||||
std::string findUniqueCompletedSidecarPath(const std::string& basePath) {
|
std::string findUniquePathWithSuffix(const std::string& basePath) {
|
||||||
if (!Storage.exists(basePath.c_str())) {
|
if (!Storage.exists(basePath.c_str())) {
|
||||||
return basePath;
|
return basePath;
|
||||||
}
|
}
|
||||||
@@ -63,6 +63,8 @@ std::string findUniqueCompletedSidecarPath(const std::string& basePath) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string findUniqueCompletedSidecarPath(const std::string& basePath) { return findUniquePathWithSuffix(basePath); }
|
||||||
|
|
||||||
std::string convertSidecarToBmp(const std::string& bookPath, const std::string& sidecarPath, int width, int height,
|
std::string convertSidecarToBmp(const std::string& bookPath, const std::string& sidecarPath, int width, int height,
|
||||||
const std::string& fileName) {
|
const std::string& fileName) {
|
||||||
const std::string cacheDir = "/.crosspoint/sidecar_" + std::to_string(std::hash<std::string>{}(bookPath));
|
const std::string cacheDir = "/.crosspoint/sidecar_" + std::to_string(std::hash<std::string>{}(bookPath));
|
||||||
@@ -391,22 +393,7 @@ std::string buildCompletedTargetPath(const std::string& currentBookPath) {
|
|||||||
return std::string("/COMPLETED/") + fileName;
|
return std::string("/COMPLETED/") + fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string findUniqueCompletedPath(const std::string& basePath) {
|
std::string findUniqueCompletedPath(const std::string& basePath) { return findUniquePathWithSuffix(basePath); }
|
||||||
if (!Storage.exists(basePath.c_str())) {
|
|
||||||
return basePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto dotPos = basePath.find_last_of('.');
|
|
||||||
const std::string base = (dotPos == std::string::npos) ? basePath : basePath.substr(0, dotPos);
|
|
||||||
const std::string ext = (dotPos == std::string::npos) ? std::string() : basePath.substr(dotPos);
|
|
||||||
for (int suffix = 1; suffix < 1000; ++suffix) {
|
|
||||||
const std::string candidate = base + " (" + std::to_string(suffix) + ")" + ext;
|
|
||||||
if (!Storage.exists(candidate.c_str())) {
|
|
||||||
return candidate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace BookFinished {
|
namespace BookFinished {
|
||||||
@@ -463,13 +450,11 @@ bool moveFinishedBookToCompleted(const std::string& currentBookPath, std::string
|
|||||||
} // namespace BookFinished
|
} // namespace BookFinished
|
||||||
|
|
||||||
FinishedBookActivity::FinishedBookActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
FinishedBookActivity::FinishedBookActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
||||||
std::string currentBookPath, std::string nextBookPath,
|
std::string currentBookPath, std::string nextBookPath)
|
||||||
bool moveFinishedBooksToCompleted)
|
|
||||||
: Activity("FinishedBook", renderer, mappedInput),
|
: Activity("FinishedBook", renderer, mappedInput),
|
||||||
currentBookPath_(std::move(currentBookPath)),
|
currentBookPath_(std::move(currentBookPath)),
|
||||||
nextBookPath_(std::move(nextBookPath)),
|
nextBookPath_(std::move(nextBookPath)),
|
||||||
nextBookAvailable_(!nextBookPath_.empty()),
|
nextBookAvailable_(!nextBookPath_.empty()) {
|
||||||
moveFinishedBooksToCompleted_(moveFinishedBooksToCompleted) {
|
|
||||||
nextBookName_ = nextBookAvailable_ ? getFilename(nextBookPath_) : tr(STR_NOT_SET);
|
nextBookName_ = nextBookAvailable_ ? getFilename(nextBookPath_) : tr(STR_NOT_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,12 +462,7 @@ void FinishedBookActivity::onEnter() {
|
|||||||
Activity::onEnter();
|
Activity::onEnter();
|
||||||
const bool canMoveToCompleted = !pathIsInCompleted(currentBookPath_);
|
const bool canMoveToCompleted = !pathIsInCompleted(currentBookPath_);
|
||||||
const int optionCount = 1 + (nextBookAvailable_ ? 1 : 0) + (canMoveToCompleted ? 1 : 0) + 1;
|
const int optionCount = 1 + (nextBookAvailable_ ? 1 : 0) + (canMoveToCompleted ? 1 : 0) + 1;
|
||||||
if (selectedIndex_ < 0 || selectedIndex_ >= optionCount) {
|
selectedIndex_ = std::clamp(selectedIndex_, 0, optionCount - 1);
|
||||||
selectedIndex_ = 0;
|
|
||||||
}
|
|
||||||
if (selectedIndex_ >= optionCount) {
|
|
||||||
selectedIndex_ = optionCount - 1;
|
|
||||||
}
|
|
||||||
moveFinishedBooksToCompleted_ = SETTINGS.moveFinishedBooksToCompleted;
|
moveFinishedBooksToCompleted_ = SETTINGS.moveFinishedBooksToCompleted;
|
||||||
removeFinishedBooksFromRecents_ = SETTINGS.removeFinishedBooksFromRecents;
|
removeFinishedBooksFromRecents_ = SETTINGS.removeFinishedBooksFromRecents;
|
||||||
|
|
||||||
@@ -607,7 +587,7 @@ void FinishedBookActivity::render(RenderLock&&) {
|
|||||||
y += yGap + 4;
|
y += yGap + 4;
|
||||||
|
|
||||||
if (nextBookAvailable_) {
|
if (nextBookAvailable_) {
|
||||||
renderer.drawText(UI_12_FONT_ID, contentRect.x + metrics.contentSidePadding, y, "Next book to read:", true,
|
renderer.drawText(UI_12_FONT_ID, contentRect.x + metrics.contentSidePadding, y, tr(STR_NEXT_BOOK_HEADER), true,
|
||||||
EpdFontFamily::BOLD);
|
EpdFontFamily::BOLD);
|
||||||
y += yGap + metrics.verticalSpacing;
|
y += yGap + metrics.verticalSpacing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ enum class FinishedBookAction {
|
|||||||
class FinishedBookActivity : public Activity {
|
class FinishedBookActivity : public Activity {
|
||||||
public:
|
public:
|
||||||
FinishedBookActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::string currentBookPath,
|
FinishedBookActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::string currentBookPath,
|
||||||
std::string nextBookPath, bool moveFinishedBooksToCompleted);
|
std::string nextBookPath);
|
||||||
|
|
||||||
void onEnter() override;
|
void onEnter() override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
|
|||||||
@@ -282,8 +282,7 @@ void MdReaderActivity::loop() {
|
|||||||
const std::string nextBookPath =
|
const std::string nextBookPath =
|
||||||
BookFinished::findNextBookInDirectory(currentBookPath, std::string(), std::string());
|
BookFinished::findNextBookInDirectory(currentBookPath, std::string(), std::string());
|
||||||
startActivityForResult(
|
startActivityForResult(
|
||||||
std::make_unique<FinishedBookActivity>(renderer, mappedInput, currentBookPath, nextBookPath,
|
std::make_unique<FinishedBookActivity>(renderer, mappedInput, currentBookPath, nextBookPath),
|
||||||
SETTINGS.moveFinishedBooksToCompleted),
|
|
||||||
[this, currentBookPath, nextBookPath](const ActivityResult& result) {
|
[this, currentBookPath, nextBookPath](const ActivityResult& result) {
|
||||||
if (result.isCancelled) {
|
if (result.isCancelled) {
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
|
|||||||
@@ -198,43 +198,7 @@ void TxtReaderActivity::loop() {
|
|||||||
currentPage++;
|
currentPage++;
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
} else {
|
} else {
|
||||||
saveProgress();
|
launchFinishedBookFlow();
|
||||||
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();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -255,36 +219,50 @@ void TxtReaderActivity::loop() {
|
|||||||
currentPage++;
|
currentPage++;
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
} else {
|
} else {
|
||||||
const std::string nextBookPath =
|
launchFinishedBookFlow();
|
||||||
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();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
void TxtReaderActivity::initializeReader() {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class TxtReaderActivity final : public Activity {
|
|||||||
// Consume a persisted bookmark-jump request (from GlobalBookmarksActivity) for
|
// Consume a persisted bookmark-jump request (from GlobalBookmarksActivity) for
|
||||||
// this TXT file. Rewrites progress.bin before initializeReader() reads it.
|
// this TXT file. Rewrites progress.bin before initializeReader() reads it.
|
||||||
void applyPendingBookmarkJump();
|
void applyPendingBookmarkJump();
|
||||||
|
void launchFinishedBookFlow();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TxtReaderActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::unique_ptr<Txt> txt)
|
explicit TxtReaderActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::unique_ptr<Txt> txt)
|
||||||
|
|||||||
@@ -140,8 +140,7 @@ void XtcReaderActivity::loop() {
|
|||||||
const std::string nextBookPath =
|
const std::string nextBookPath =
|
||||||
BookFinished::findNextBookInDirectory(currentBookPath, std::string(), std::string());
|
BookFinished::findNextBookInDirectory(currentBookPath, std::string(), std::string());
|
||||||
startActivityForResult(
|
startActivityForResult(
|
||||||
std::make_unique<FinishedBookActivity>(renderer, mappedInput, currentBookPath, nextBookPath,
|
std::make_unique<FinishedBookActivity>(renderer, mappedInput, currentBookPath, nextBookPath),
|
||||||
SETTINGS.moveFinishedBooksToCompleted),
|
|
||||||
[this, nextBookPath, currentBookPath](const ActivityResult& result) {
|
[this, nextBookPath, currentBookPath](const ActivityResult& result) {
|
||||||
if (result.isCancelled) {
|
if (result.isCancelled) {
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
|
|||||||
Reference in New Issue
Block a user