feat: Back on home menu opens the most recent book (#2619)

Co-authored-by: kira <rammah@tuta.io>
This commit is contained in:
rxmmah
2026-07-15 23:50:22 +03:00
committed by GitHub
co-authored by kira
parent a4ac3b2788
commit 63093e606c
3 changed files with 17 additions and 1 deletions
+1
View File
@@ -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"
+13 -1
View File
@@ -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();
+3
View File
@@ -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