Merge remote-tracking branch 'origin/develop' into feat-touch
# Conflicts: # freeink-sdk # lib/I18n/translations/slovak.yaml # platformio.ini # src/components/icons/bookmark.h
This commit is contained in:
@@ -39,14 +39,6 @@ void EpubReaderBookmarksActivity::onEnter() {
|
||||
bookmarks.shrink_to_fit();
|
||||
} else {
|
||||
JsonSettingsIO::loadBookmarks(bookmarks, json.c_str());
|
||||
|
||||
// pre-compute bookmark page values for quicker rendering
|
||||
for (auto& bookmark : bookmarks) {
|
||||
CrossPointPosition pos = ProgressMapper::toCrossPoint(epub, {bookmark.xpath, bookmark.percentage}, renderer);
|
||||
bookmark.computedSpineIndex = pos.spineIndex;
|
||||
bookmark.computedChapterPageCount = pos.totalPages;
|
||||
bookmark.computedChapterProgress = pos.pageNumber;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG_DBG("EPB", "No bookmark file found at %s, starting with empty bookmarks", path.c_str());
|
||||
@@ -93,6 +85,14 @@ void EpubReaderBookmarksActivity::loop() {
|
||||
selectorIndex--;
|
||||
}
|
||||
|
||||
if (bookmarks.empty()) {
|
||||
ActivityResult result;
|
||||
result.isCancelled = true;
|
||||
setResult(std::move(result));
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
requestUpdate();
|
||||
confirmingDelete = DELETE_MODE_OFF;
|
||||
return;
|
||||
@@ -203,9 +203,12 @@ void EpubReaderBookmarksActivity::render(RenderLock&&) {
|
||||
auto bookmark = bookmarks.at(confirmingDelete >= DELETE_MODE_DISPLAY ? selectorIndex : index);
|
||||
auto tocIndex = epub->getTocIndexForSpineIndex(bookmark.computedSpineIndex);
|
||||
auto tocTitle = (tocIndex >= 0) ? (epub->getTocItem(tocIndex)).title : tr(STR_UNNAMED);
|
||||
return std::to_string((int)(std::clamp(bookmark.percentage, 0.0f, 1.0f) * 100.0f + 0.5f)) + "% - " +
|
||||
std::to_string(bookmark.computedChapterProgress + 1) + "/" +
|
||||
std::to_string(bookmark.computedChapterPageCount) + " - " + tocTitle;
|
||||
std::string subtitle = std::to_string((int)(std::clamp(bookmark.percentage, 0.0f, 1.0f) * 100.0f + 0.5f)) + "% - ";
|
||||
if (bookmark.computedChapterPageCount > 0) {
|
||||
subtitle += std::to_string(bookmark.computedChapterProgress + 1) + "/" +
|
||||
std::to_string(bookmark.computedChapterPageCount) + " - ";
|
||||
}
|
||||
return subtitle + tocTitle;
|
||||
};
|
||||
const auto getBookmarkIcon = [isPortrait](int index) {
|
||||
// only enabled icon in portrait mode due to limitation with rotating icons for other orientations
|
||||
@@ -225,11 +228,8 @@ void EpubReaderBookmarksActivity::render(RenderLock&&) {
|
||||
getBookmarkTitle, getBookmarkSubtitle, getBookmarkIcon);
|
||||
|
||||
GUI.drawHelpText(renderer, Rect{contentX, pageHeight - hintGutterBottom, contentWidth, LINE_HEIGHT},
|
||||
tr(STR_HOLD_CONFIRM_TO_DELETE));
|
||||
tr(STR_HOLD_OPEN_TO_DELETE));
|
||||
}
|
||||
} else {
|
||||
GUI.drawHelpText(renderer, Rect{contentX, LINE_HEIGHT * 2, contentWidth, LINE_HEIGHT},
|
||||
tr(STR_BOOKMARK_INSTRUCTIONS));
|
||||
}
|
||||
|
||||
const auto backLabel = confirmingDelete >= DELETE_MODE_DISPLAY ? tr(STR_CANCEL) : tr(STR_BACK);
|
||||
|
||||
Reference in New Issue
Block a user