A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: rename MyLibrary to FileBrowser (#1260)

## Summary

* Renames MyLibrary component to FileBrowser, as it better reflects what
it is, in my opinion

## Additional Context

* Frees the Library name for possible future library component that can
cache metadata, provide other ways of browsing than filesystem
structure, etc
---

### AI Usage

Did you use AI tools to help write this code? _**< YES >**_

authored by

Arthur Tazhitdinov and committed by
GitHub
f0a549b6 7dc51862

+33 -33
+3 -3
src/activities/ActivityManager.cpp
··· 5 5 #include "boot_sleep/BootActivity.h" 6 6 #include "boot_sleep/SleepActivity.h" 7 7 #include "browser/OpdsBookBrowserActivity.h" 8 + #include "home/FileBrowserActivity.h" 8 9 #include "home/HomeActivity.h" 9 - #include "home/MyLibraryActivity.h" 10 10 #include "home/RecentBooksActivity.h" 11 11 #include "network/CrossPointWebServerActivity.h" 12 12 #include "reader/ReaderActivity.h" ··· 169 169 170 170 void ActivityManager::goToSettings() { replaceActivity(std::make_unique<SettingsActivity>(renderer, mappedInput)); } 171 171 172 - void ActivityManager::goToMyLibrary(std::string path) { 173 - replaceActivity(std::make_unique<MyLibraryActivity>(renderer, mappedInput, std::move(path))); 172 + void ActivityManager::goToFileBrowser(std::string path) { 173 + replaceActivity(std::make_unique<FileBrowserActivity>(renderer, mappedInput, std::move(path))); 174 174 } 175 175 176 176 void ActivityManager::goToRecentBooks() {
+1 -1
src/activities/ActivityManager.h
··· 79 79 // goTo... functions are convenient wrapper for replaceActivity() 80 80 void goToFileTransfer(); 81 81 void goToSettings(); 82 - void goToMyLibrary(std::string path = {}); 82 + void goToFileBrowser(std::string path = {}); 83 83 void goToRecentBooks(); 84 84 void goToBrowser(); 85 85 void goToReader(std::string path);
+6 -6
src/activities/home/HomeActivity.cpp
··· 20 20 #include "util/StringUtils.h" 21 21 22 22 int HomeActivity::getMenuItemCount() const { 23 - int count = 4; // My Library, Recents, File transfer, Settings 23 + int count = 4; // File Browser, Recents, File transfer, Settings 24 24 if (!recentBooks.empty()) { 25 25 count += recentBooks.size(); 26 26 } ··· 189 189 // Calculate dynamic indices based on which options are available 190 190 int idx = 0; 191 191 int menuSelectedIndex = selectorIndex - static_cast<int>(recentBooks.size()); 192 - const int myLibraryIdx = idx++; 192 + const int fileBrowserIdx = idx++; 193 193 const int recentsIdx = idx++; 194 194 const int opdsLibraryIdx = hasOpdsUrl ? idx++ : -1; 195 195 const int fileTransferIdx = idx++; ··· 197 197 198 198 if (selectorIndex < recentBooks.size()) { 199 199 onSelectBook(recentBooks[selectorIndex].path); 200 - } else if (menuSelectedIndex == myLibraryIdx) { 201 - onMyLibraryOpen(); 200 + } else if (menuSelectedIndex == fileBrowserIdx) { 201 + onFileBrowserOpen(); 202 202 } else if (menuSelectedIndex == recentsIdx) { 203 203 onRecentsOpen(); 204 204 } else if (menuSelectedIndex == opdsLibraryIdx) { ··· 231 231 std::vector<UIIcon> menuIcons = {Folder, Recent, Transfer, Settings}; 232 232 233 233 if (hasOpdsUrl) { 234 - // Insert OPDS Browser after My Library 234 + // Insert OPDS Browser after File Browser 235 235 menuItems.insert(menuItems.begin() + 2, tr(STR_OPDS_BROWSER)); 236 236 menuIcons.insert(menuIcons.begin() + 2, Library); 237 237 } ··· 261 261 262 262 void HomeActivity::onSelectBook(const std::string& path) { activityManager.goToReader(path); } 263 263 264 - void HomeActivity::onMyLibraryOpen() { activityManager.goToMyLibrary(); } 264 + void HomeActivity::onFileBrowserOpen() { activityManager.goToFileBrowser(); } 265 265 266 266 void HomeActivity::onRecentsOpen() { activityManager.goToRecentBooks(); } 267 267
+2 -2
src/activities/home/HomeActivity.h
··· 3 3 #include <vector> 4 4 5 5 #include "../Activity.h" 6 - #include "./MyLibraryActivity.h" 6 + #include "./FileBrowserActivity.h" 7 7 #include "util/ButtonNavigator.h" 8 8 9 9 struct RecentBook; ··· 21 21 uint8_t* coverBuffer = nullptr; // HomeActivity's own buffer for cover image 22 22 std::vector<RecentBook> recentBooks; 23 23 void onSelectBook(const std::string& path); 24 - void onMyLibraryOpen(); 24 + void onFileBrowserOpen(); 25 25 void onRecentsOpen(); 26 26 void onSettingsOpen(); 27 27 void onFileTransferOpen();
+13 -13
src/activities/home/MyLibraryActivity.cpp src/activities/home/FileBrowserActivity.cpp
··· 1 - #include "MyLibraryActivity.h" 1 + #include "FileBrowserActivity.h" 2 2 3 3 #include <Epub.h> 4 4 #include <GfxRenderer.h> ··· 69 69 }); 70 70 } 71 71 72 - void MyLibraryActivity::loadFiles() { 72 + void FileBrowserActivity::loadFiles() { 73 73 files.clear(); 74 74 75 75 auto root = Storage.open(basepath.c_str()); ··· 104 104 sortFileList(files); 105 105 } 106 106 107 - void MyLibraryActivity::onEnter() { 107 + void FileBrowserActivity::onEnter() { 108 108 Activity::onEnter(); 109 109 110 110 loadFiles(); ··· 113 113 requestUpdate(); 114 114 } 115 115 116 - void MyLibraryActivity::onExit() { 116 + void FileBrowserActivity::onExit() { 117 117 Activity::onExit(); 118 118 files.clear(); 119 119 } 120 120 121 - void MyLibraryActivity::clearFileMetadata(const std::string& fullPath) { 121 + void FileBrowserActivity::clearFileMetadata(const std::string& fullPath) { 122 122 // Only clear cache for .epub files 123 123 if (StringUtils::checkFileExtension(fullPath, ".epub")) { 124 124 Epub(fullPath, "/.crosspoint").clearCache(); 125 - LOG_DBG("MyLibrary", "Cleared metadata cache for: %s", fullPath.c_str()); 125 + LOG_DBG("FileBrowser", "Cleared metadata cache for: %s", fullPath.c_str()); 126 126 } 127 127 } 128 128 129 - void MyLibraryActivity::loop() { 129 + void FileBrowserActivity::loop() { 130 130 // Long press BACK (1s+) goes to root folder 131 131 if (mappedInput.isPressed(MappedInputManager::Button::Back) && mappedInput.getHeldTime() >= GO_HOME_MS && 132 132 basepath != "/") { ··· 152 152 153 153 auto handler = [this, fullPath](const ActivityResult& res) { 154 154 if (!res.isCancelled) { 155 - LOG_DBG("MyLibrary", "Attempting to delete: %s", fullPath.c_str()); 155 + LOG_DBG("FileBrowser", "Attempting to delete: %s", fullPath.c_str()); 156 156 clearFileMetadata(fullPath); 157 157 if (Storage.remove(fullPath.c_str())) { 158 - LOG_DBG("MyLibrary", "Deleted successfully"); 158 + LOG_DBG("FileBrowser", "Deleted successfully"); 159 159 loadFiles(); 160 160 if (files.empty()) { 161 161 selectorIndex = 0; ··· 166 166 167 167 requestUpdate(true); 168 168 } else { 169 - LOG_ERR("MyLibrary", "Failed to delete file: %s", fullPath.c_str()); 169 + LOG_ERR("FileBrowser", "Failed to delete file: %s", fullPath.c_str()); 170 170 } 171 171 } else { 172 - LOG_DBG("MyLibrary", "Delete cancelled by user"); 172 + LOG_DBG("FileBrowser", "Delete cancelled by user"); 173 173 } 174 174 }; 175 175 ··· 244 244 return filename.substr(0, pos); 245 245 } 246 246 247 - void MyLibraryActivity::render(RenderLock&&) { 247 + void FileBrowserActivity::render(RenderLock&&) { 248 248 renderer.clearScreen(); 249 249 250 250 const auto pageWidth = renderer.getScreenWidth(); ··· 274 274 renderer.displayBuffer(); 275 275 } 276 276 277 - size_t MyLibraryActivity::findEntry(const std::string& name) const { 277 + size_t FileBrowserActivity::findEntry(const std::string& name) const { 278 278 for (size_t i = 0; i < files.size(); i++) 279 279 if (files[i] == name) return i; 280 280 return 0;
+3 -3
src/activities/home/MyLibraryActivity.h src/activities/home/FileBrowserActivity.h
··· 8 8 #include "RecentBooksStore.h" 9 9 #include "util/ButtonNavigator.h" 10 10 11 - class MyLibraryActivity final : public Activity { 11 + class FileBrowserActivity final : public Activity { 12 12 private: 13 13 // Deletion 14 14 void clearFileMetadata(const std::string& fullPath); ··· 26 26 size_t findEntry(const std::string& name) const; 27 27 28 28 public: 29 - explicit MyLibraryActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::string initialPath = "/") 30 - : Activity("MyLibrary", renderer, mappedInput), basepath(initialPath.empty() ? "/" : std::move(initialPath)) {} 29 + explicit FileBrowserActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::string initialPath = "/") 30 + : Activity("FileBrowser", renderer, mappedInput), basepath(initialPath.empty() ? "/" : std::move(initialPath)) {} 31 31 void onEnter() override; 32 32 void onExit() override; 33 33 void loop() override;
+1 -1
src/activities/reader/EpubReaderActivity.cpp
··· 180 180 181 181 // Long press BACK (1s+) goes to file selection 182 182 if (mappedInput.isPressed(MappedInputManager::Button::Back) && mappedInput.getHeldTime() >= goHomeMs) { 183 - activityManager.goToMyLibrary(epub ? epub->getPath() : ""); 183 + activityManager.goToFileBrowser(epub ? epub->getPath() : ""); 184 184 return; 185 185 } 186 186
+1 -1
src/activities/reader/ReaderActivity.cpp
··· 80 80 void ReaderActivity::goToLibrary(const std::string& fromBookPath) { 81 81 // If coming from a book, start in that book's folder; otherwise start from root 82 82 auto initialPath = fromBookPath.empty() ? "/" : extractFolderPath(fromBookPath); 83 - activityManager.goToMyLibrary(std::move(initialPath)); 83 + activityManager.goToFileBrowser(std::move(initialPath)); 84 84 } 85 85 86 86 void ReaderActivity::onGoToEpubReader(std::unique_ptr<Epub> epub) {
+1 -1
src/activities/reader/ReaderActivity.h
··· 2 2 #include <memory> 3 3 4 4 #include "../Activity.h" 5 - #include "activities/home/MyLibraryActivity.h" 5 + #include "activities/home/FileBrowserActivity.h" 6 6 7 7 class Epub; 8 8 class Xtc;
+1 -1
src/activities/reader/TxtReaderActivity.cpp
··· 76 76 void TxtReaderActivity::loop() { 77 77 // Long press BACK (1s+) goes to file selection 78 78 if (mappedInput.isPressed(MappedInputManager::Button::Back) && mappedInput.getHeldTime() >= goHomeMs) { 79 - activityManager.goToMyLibrary(txt ? txt->getPath() : ""); 79 + activityManager.goToFileBrowser(txt ? txt->getPath() : ""); 80 80 return; 81 81 } 82 82
+1 -1
src/activities/reader/XtcReaderActivity.cpp
··· 70 70 71 71 // Long press BACK (1s+) goes to file selection 72 72 if (mappedInput.isPressed(MappedInputManager::Button::Back) && mappedInput.getHeldTime() >= goHomeMs) { 73 - activityManager.goToMyLibrary(xtc ? xtc->getPath() : ""); 73 + activityManager.goToFileBrowser(xtc ? xtc->getPath() : ""); 74 74 return; 75 75 } 76 76