feat: replace Delete Book Cache with Manage Book in reader menu
EpubReaderMenuActivity now shows "Manage Book" instead of "Delete Book Cache". Selecting it opens BookManageMenuActivity as a sub-activity with Archive, Delete, Delete Cache, and Reindex options. New menu actions (ARCHIVE_BOOK, DELETE_BOOK, REINDEX_BOOK, REINDEX_BOOK_FULL) are forwarded to EpubReaderActivity and handled via BookManager. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include "RecentBooksStore.h"
|
#include "RecentBooksStore.h"
|
||||||
#include "components/UITheme.h"
|
#include "components/UITheme.h"
|
||||||
#include "fontIds.h"
|
#include "fontIds.h"
|
||||||
|
#include "util/BookManager.h"
|
||||||
#include "util/BookmarkStore.h"
|
#include "util/BookmarkStore.h"
|
||||||
#include "util/Dictionary.h"
|
#include "util/Dictionary.h"
|
||||||
|
|
||||||
@@ -264,7 +265,7 @@ void EpubReaderActivity::loop() {
|
|||||||
exitActivity();
|
exitActivity();
|
||||||
enterNewActivity(new EpubReaderMenuActivity(
|
enterNewActivity(new EpubReaderMenuActivity(
|
||||||
this->renderer, this->mappedInput, epub->getTitle(), currentPage, totalPages, bookProgressPercent,
|
this->renderer, this->mappedInput, epub->getTitle(), currentPage, totalPages, bookProgressPercent,
|
||||||
SETTINGS.orientation, SETTINGS.fontSize, hasDictionary, isBookmarked, epub->getCachePath(),
|
SETTINGS.orientation, SETTINGS.fontSize, hasDictionary, isBookmarked, epub->getCachePath(), epub->getPath(),
|
||||||
[this](const uint8_t orientation, const uint8_t fontSize) { onReaderMenuBack(orientation, fontSize); },
|
[this](const uint8_t orientation, const uint8_t fontSize) { onReaderMenuBack(orientation, fontSize); },
|
||||||
[this](EpubReaderMenuActivity::MenuAction action) { onReaderMenuConfirm(action); }));
|
[this](EpubReaderMenuActivity::MenuAction action) { onReaderMenuConfirm(action); }));
|
||||||
}
|
}
|
||||||
@@ -712,6 +713,36 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction
|
|||||||
pendingGoHome = true;
|
pendingGoHome = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case EpubReaderMenuActivity::MenuAction::ARCHIVE_BOOK: {
|
||||||
|
if (epub) {
|
||||||
|
BookManager::archiveBook(epub->getPath());
|
||||||
|
}
|
||||||
|
pendingGoHome = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EpubReaderMenuActivity::MenuAction::DELETE_BOOK: {
|
||||||
|
if (epub) {
|
||||||
|
BookManager::deleteBook(epub->getPath());
|
||||||
|
}
|
||||||
|
pendingGoHome = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EpubReaderMenuActivity::MenuAction::MANAGE_BOOK:
|
||||||
|
break;
|
||||||
|
case EpubReaderMenuActivity::MenuAction::REINDEX_BOOK: {
|
||||||
|
if (epub) {
|
||||||
|
BookManager::reindexBook(epub->getPath(), false);
|
||||||
|
}
|
||||||
|
pendingGoHome = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EpubReaderMenuActivity::MenuAction::REINDEX_BOOK_FULL: {
|
||||||
|
if (epub) {
|
||||||
|
BookManager::reindexBook(epub->getPath(), true);
|
||||||
|
}
|
||||||
|
pendingGoHome = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case EpubReaderMenuActivity::MenuAction::SYNC: {
|
case EpubReaderMenuActivity::MenuAction::SYNC: {
|
||||||
if (KOREADER_STORE.hasCredentials()) {
|
if (KOREADER_STORE.hasCredentials()) {
|
||||||
const int currentPage = section ? section->currentPage : 0;
|
const int currentPage = section ? section->currentPage : 0;
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
#include <GfxRenderer.h>
|
#include <GfxRenderer.h>
|
||||||
#include <I18n.h>
|
#include <I18n.h>
|
||||||
|
|
||||||
|
#include "../home/BookManageMenuActivity.h"
|
||||||
#include "CrossPointSettings.h"
|
#include "CrossPointSettings.h"
|
||||||
#include "MappedInputManager.h"
|
#include "MappedInputManager.h"
|
||||||
#include "components/UITheme.h"
|
#include "components/UITheme.h"
|
||||||
#include "fontIds.h"
|
#include "fontIds.h"
|
||||||
|
#include "util/BookManager.h"
|
||||||
|
|
||||||
void EpubReaderMenuActivity::onEnter() {
|
void EpubReaderMenuActivity::onEnter() {
|
||||||
ActivityWithSubactivity::onEnter();
|
ActivityWithSubactivity::onEnter();
|
||||||
@@ -116,6 +118,42 @@ void EpubReaderMenuActivity::loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selectedAction == MenuAction::MANAGE_BOOK) {
|
||||||
|
const bool isArchived = BookManager::isArchived(bookFilePath);
|
||||||
|
enterNewActivity(new BookManageMenuActivity(
|
||||||
|
renderer, mappedInput, bookFilePath, isArchived,
|
||||||
|
[this](BookManageMenuActivity::Action action) {
|
||||||
|
exitActivity();
|
||||||
|
auto cb = onAction;
|
||||||
|
switch (action) {
|
||||||
|
case BookManageMenuActivity::Action::ARCHIVE:
|
||||||
|
cb(MenuAction::ARCHIVE_BOOK);
|
||||||
|
break;
|
||||||
|
case BookManageMenuActivity::Action::DELETE:
|
||||||
|
cb(MenuAction::DELETE_BOOK);
|
||||||
|
break;
|
||||||
|
case BookManageMenuActivity::Action::DELETE_CACHE:
|
||||||
|
cb(MenuAction::DELETE_CACHE);
|
||||||
|
break;
|
||||||
|
case BookManageMenuActivity::Action::REINDEX:
|
||||||
|
cb(MenuAction::REINDEX_BOOK);
|
||||||
|
break;
|
||||||
|
case BookManageMenuActivity::Action::REINDEX_FULL:
|
||||||
|
cb(MenuAction::REINDEX_BOOK_FULL);
|
||||||
|
break;
|
||||||
|
case BookManageMenuActivity::Action::UNARCHIVE:
|
||||||
|
// Unarchive from within reader is unusual but handle gracefully
|
||||||
|
cb(MenuAction::GO_HOME);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[this] {
|
||||||
|
exitActivity();
|
||||||
|
requestUpdate();
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 1. Capture the callback and action locally
|
// 1. Capture the callback and action locally
|
||||||
auto actionCallback = onAction;
|
auto actionCallback = onAction;
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,18 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
|||||||
GO_HOME,
|
GO_HOME,
|
||||||
SYNC,
|
SYNC,
|
||||||
DELETE_CACHE,
|
DELETE_CACHE,
|
||||||
|
MANAGE_BOOK,
|
||||||
|
ARCHIVE_BOOK,
|
||||||
|
DELETE_BOOK,
|
||||||
|
REINDEX_BOOK,
|
||||||
|
REINDEX_BOOK_FULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& title,
|
explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& title,
|
||||||
const int currentPage, const int totalPages, const int bookProgressPercent,
|
const int currentPage, const int totalPages, const int bookProgressPercent,
|
||||||
const uint8_t currentOrientation, const uint8_t currentFontSize,
|
const uint8_t currentOrientation, const uint8_t currentFontSize,
|
||||||
const bool hasDictionary, const bool isBookmarked, const std::string& bookCachePath,
|
const bool hasDictionary, const bool isBookmarked, const std::string& bookCachePath,
|
||||||
|
const std::string& bookFilePath,
|
||||||
const std::function<void(uint8_t, uint8_t)>& onBack,
|
const std::function<void(uint8_t, uint8_t)>& onBack,
|
||||||
const std::function<void(MenuAction)>& onAction)
|
const std::function<void(MenuAction)>& onAction)
|
||||||
: ActivityWithSubactivity("EpubReaderMenu", renderer, mappedInput),
|
: ActivityWithSubactivity("EpubReaderMenu", renderer, mappedInput),
|
||||||
@@ -42,6 +48,7 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
|||||||
pendingOrientation(currentOrientation),
|
pendingOrientation(currentOrientation),
|
||||||
pendingFontSize(currentFontSize),
|
pendingFontSize(currentFontSize),
|
||||||
bookCachePath(bookCachePath),
|
bookCachePath(bookCachePath),
|
||||||
|
bookFilePath(bookFilePath),
|
||||||
currentPage(currentPage),
|
currentPage(currentPage),
|
||||||
totalPages(totalPages),
|
totalPages(totalPages),
|
||||||
bookProgressPercent(bookProgressPercent),
|
bookProgressPercent(bookProgressPercent),
|
||||||
@@ -75,6 +82,7 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
|||||||
StrId::STR_LANDSCAPE_CCW};
|
StrId::STR_LANDSCAPE_CCW};
|
||||||
const std::vector<StrId> fontSizeLabels = {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE};
|
const std::vector<StrId> fontSizeLabels = {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE};
|
||||||
std::string bookCachePath;
|
std::string bookCachePath;
|
||||||
|
std::string bookFilePath;
|
||||||
// Letterbox fill override: 0xFF = Default (use global), 0 = Dithered, 1 = Solid, 2 = None
|
// Letterbox fill override: 0xFF = Default (use global), 0 = Dithered, 1 = Solid, 2 = None
|
||||||
uint8_t pendingLetterboxFill = BookSettings::USE_GLOBAL;
|
uint8_t pendingLetterboxFill = BookSettings::USE_GLOBAL;
|
||||||
static constexpr int LETTERBOX_FILL_OPTION_COUNT = 4; // Default + 3 modes
|
static constexpr int LETTERBOX_FILL_OPTION_COUNT = 4; // Default + 3 modes
|
||||||
@@ -132,7 +140,7 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
|||||||
items.push_back({MenuAction::GO_TO_PERCENT, StrId::STR_GO_TO_PERCENT});
|
items.push_back({MenuAction::GO_TO_PERCENT, StrId::STR_GO_TO_PERCENT});
|
||||||
items.push_back({MenuAction::GO_HOME, StrId::STR_CLOSE_BOOK});
|
items.push_back({MenuAction::GO_HOME, StrId::STR_CLOSE_BOOK});
|
||||||
items.push_back({MenuAction::SYNC, StrId::STR_SYNC_PROGRESS});
|
items.push_back({MenuAction::SYNC, StrId::STR_SYNC_PROGRESS});
|
||||||
items.push_back({MenuAction::DELETE_CACHE, StrId::STR_DELETE_CACHE});
|
items.push_back({MenuAction::MANAGE_BOOK, StrId::STR_MANAGE_BOOK});
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user