diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index 4cb9530b..42d7703d 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -10,6 +10,7 @@ STR_BROWSE_FILES: "Browse Files" STR_FILE_TRANSFER: "File Transfer" STR_SETTINGS_TITLE: "Settings" STR_CONTINUE_READING: "Continue Reading" +STR_RESUME: "Resume" STR_NO_OPEN_BOOK: "No open book" STR_START_READING: "Start reading below" STR_NO_FILES_FOUND: "No files found" diff --git a/src/activities/home/HomeActivity.cpp b/src/activities/home/HomeActivity.cpp index 28743264..bc5a5c50 100644 --- a/src/activities/home/HomeActivity.cpp +++ b/src/activities/home/HomeActivity.cpp @@ -179,6 +179,17 @@ void HomeActivity::loop() { requestUpdate(); }); + if (mappedInput.wasPressed(MappedInputManager::Button::Back)) backPressSeen = true; + + // Back is otherwise unused on the home menu: open the most recently read + // book directly (recentBooks is most-recent-first and already pruned of + // files missing from the SD card). backPressSeen guards against the stale + // release of the Back press that closed the previous activity. + if (mappedInput.wasReleased(MappedInputManager::Button::Back) && backPressSeen && !recentBooks.empty()) { + onSelectBook(recentBooks[0].path); + return; + } + if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) { if (selectorIndex < recentBooks.size()) { onSelectBook(recentBooks[selectorIndex].path); @@ -256,7 +267,8 @@ void HomeActivity::render(RenderLock&&) { [&menuItems](int index) { return std::string(menuItems[index]); }, [&menuIcons](int index) { return menuIcons[index]; }); - const auto labels = mappedInput.mapLabels("", tr(STR_SELECT), tr(STR_DIR_UP), tr(STR_DIR_DOWN)); + const auto labels = mappedInput.mapLabels(recentBooks.empty() ? "" : tr(STR_RESUME), tr(STR_SELECT), tr(STR_DIR_UP), + tr(STR_DIR_DOWN)); GUI.drawButtonHints(renderer, labels.btn1, labels.btn2, labels.btn3, labels.btn4); renderer.displayBuffer(); diff --git a/src/activities/home/HomeActivity.h b/src/activities/home/HomeActivity.h index 6d170cdd..169bbbf4 100644 --- a/src/activities/home/HomeActivity.h +++ b/src/activities/home/HomeActivity.h @@ -18,6 +18,9 @@ class HomeActivity final : public Activity { bool hasOpdsServers = false; bool coverRendered = false; // Track if cover has been rendered once bool coverBufferStored = false; // Track if cover buffer is stored + // Home can be entered while Back is still held (e.g. leaving Settings with + // Back): ignore that stale release until a fresh press is seen here. + bool backPressSeen = false; uint8_t* coverBuffer = nullptr; // HomeActivity's own buffer for cover image size_t coverBufferSize = 0; // Bytes allocated to coverBuffer // Logical rect last passed to drawRecentBookCover. The cover snapshot only