diff --git a/src/activities/home/MyLibraryActivity.cpp b/src/activities/home/MyLibraryActivity.cpp index 81ab1049..f0e953e3 100644 --- a/src/activities/home/MyLibraryActivity.cpp +++ b/src/activities/home/MyLibraryActivity.cpp @@ -207,7 +207,7 @@ void MyLibraryActivity::loop() { if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) { if (currentTab == Tab::Recent) { if (!bookPaths.empty() && selectorIndex < static_cast(bookPaths.size())) { - onSelectBook(bookPaths[selectorIndex]); + onSelectBook(bookPaths[selectorIndex], currentTab); } } else { // Files tab @@ -221,7 +221,7 @@ void MyLibraryActivity::loop() { updateRequired = true; } else { // Open file - onSelectBook(basepath + files[selectorIndex]); + onSelectBook(basepath + files[selectorIndex], currentTab); } } } diff --git a/src/activities/home/MyLibraryActivity.h b/src/activities/home/MyLibraryActivity.h index 896209b4..c6c52b68 100644 --- a/src/activities/home/MyLibraryActivity.h +++ b/src/activities/home/MyLibraryActivity.h @@ -31,7 +31,7 @@ class MyLibraryActivity final : public Activity { // Callbacks const std::function onGoHome; - const std::function onSelectBook; + const std::function onSelectBook; // Number of items that fit on a page int getPageItems() const; @@ -54,7 +54,7 @@ class MyLibraryActivity final : public Activity { public: explicit MyLibraryActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::function& onGoHome, - const std::function& onSelectBook, + const std::function& onSelectBook, Tab initialTab = Tab::Recent, std::string initialPath = "/") : Activity("MyLibrary", renderer, mappedInput), currentTab(initialTab), diff --git a/src/activities/reader/ReaderActivity.cpp b/src/activities/reader/ReaderActivity.cpp index b45d3cca..f42bbf2f 100644 --- a/src/activities/reader/ReaderActivity.cpp +++ b/src/activities/reader/ReaderActivity.cpp @@ -119,7 +119,7 @@ void ReaderActivity::onSelectBookFile(const std::string& path) { void ReaderActivity::goToLibrary(const std::string& fromBookPath) { // If coming from a book, start in that book's folder; otherwise start from root const auto initialPath = fromBookPath.empty() ? "/" : extractFolderPath(fromBookPath); - onGoToLibrary(initialPath); + onGoToLibrary(initialPath, libraryTab); } void ReaderActivity::onGoToEpubReader(std::unique_ptr epub) { diff --git a/src/activities/reader/ReaderActivity.h b/src/activities/reader/ReaderActivity.h index 1ecd15b4..d31566ec 100644 --- a/src/activities/reader/ReaderActivity.h +++ b/src/activities/reader/ReaderActivity.h @@ -2,6 +2,7 @@ #include #include "../ActivityWithSubactivity.h" +#include "activities/home/MyLibraryActivity.h" class Epub; class Xtc; @@ -10,8 +11,9 @@ class Txt; class ReaderActivity final : public ActivityWithSubactivity { std::string initialBookPath; std::string currentBookPath; // Track current book path for navigation + MyLibraryActivity::Tab libraryTab; // Track which tab to return to const std::function onGoBack; - const std::function onGoToLibrary; + const std::function onGoToLibrary; static std::unique_ptr loadEpub(const std::string& path); static std::unique_ptr loadXtc(const std::string& path); static std::unique_ptr loadTxt(const std::string& path); @@ -27,10 +29,11 @@ class ReaderActivity final : public ActivityWithSubactivity { public: explicit ReaderActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::string initialBookPath, - const std::function& onGoBack, - const std::function& onGoToLibrary) + MyLibraryActivity::Tab libraryTab, const std::function& onGoBack, + const std::function& onGoToLibrary) : ActivityWithSubactivity("Reader", renderer, mappedInput), initialBookPath(std::move(initialBookPath)), + libraryTab(libraryTab), onGoBack(onGoBack), onGoToLibrary(onGoToLibrary) {} void onEnter() override; diff --git a/src/main.cpp b/src/main.cpp index e315fad7..96a466f0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -212,12 +212,13 @@ void enterDeepSleep() { } void onGoHome(); -void onGoToMyLibraryAtPath(const std::string& path); -void onGoToReader(const std::string& initialEpubPath) { +void onGoToMyLibraryWithTab(const std::string& path, MyLibraryActivity::Tab tab); +void onGoToReader(const std::string& initialEpubPath, MyLibraryActivity::Tab fromTab) { exitActivity(); - enterNewActivity(new ReaderActivity(renderer, mappedInputManager, initialEpubPath, onGoHome, onGoToMyLibraryAtPath)); + enterNewActivity( + new ReaderActivity(renderer, mappedInputManager, initialEpubPath, fromTab, onGoHome, onGoToMyLibraryWithTab)); } -void onContinueReading() { onGoToReader(APP_STATE.openEpubPath); } +void onContinueReading() { onGoToReader(APP_STATE.openEpubPath, MyLibraryActivity::Tab::Recent); } void onGoToFileTransfer() { exitActivity(); @@ -234,10 +235,9 @@ void onGoToMyLibrary() { enterNewActivity(new MyLibraryActivity(renderer, mappedInputManager, onGoHome, onGoToReader)); } -void onGoToMyLibraryAtPath(const std::string& path) { +void onGoToMyLibraryWithTab(const std::string& path, MyLibraryActivity::Tab tab) { exitActivity(); - enterNewActivity( - new MyLibraryActivity(renderer, mappedInputManager, onGoHome, onGoToReader, MyLibraryActivity::Tab::Files, path)); + enterNewActivity(new MyLibraryActivity(renderer, mappedInputManager, onGoHome, onGoToReader, tab, path)); } void onGoToBrowser() { @@ -325,7 +325,7 @@ void setup() { APP_STATE.openEpubPath = ""; APP_STATE.lastSleepImage = 0; APP_STATE.saveToFile(); - onGoToReader(path); + onGoToReader(path, MyLibraryActivity::Tab::Recent); } // Ensure we're not still holding the power button before leaving setup