mod: Phase 2c-e — GfxRenderer, themes, SleepActivity, SettingsActivity, platformio
- Add drawPixelGray to GfxRenderer for letterbox fill rendering - Add PRERENDER_THUMB_HEIGHTS to UITheme for placeholder cover generation - Add [env:mod] build environment to platformio.ini - Implement sleep screen letterbox fill (solid/dithered) with edge caching in SleepActivity, including placeholder cover fallback - Add Clock settings category to SettingsActivity with timezone, NTP sync, and set-time actions; replace CalibreSettings with OpdsServerListActivity; add DynamicEnum rendering support - Add long-press book management to RecentBooksActivity Made-with: Cursor
This commit is contained in:
@@ -6,10 +6,13 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "BookManageMenuActivity.h"
|
||||
#include "MappedInputManager.h"
|
||||
#include "RecentBooksStore.h"
|
||||
#include "activities/ActivityResult.h"
|
||||
#include "components/UITheme.h"
|
||||
#include "fontIds.h"
|
||||
#include "util/BookManager.h"
|
||||
|
||||
namespace {
|
||||
constexpr unsigned long GO_HOME_MS = 1000;
|
||||
@@ -44,11 +47,64 @@ void RecentBooksActivity::onExit() {
|
||||
recentBooks.clear();
|
||||
}
|
||||
|
||||
void RecentBooksActivity::openManageMenu(const std::string& bookPath) {
|
||||
const bool isArchived = BookManager::isArchived(bookPath);
|
||||
const std::string capturedPath = bookPath;
|
||||
startActivityForResult(
|
||||
std::make_unique<BookManageMenuActivity>(renderer, mappedInput, capturedPath, isArchived, false),
|
||||
[this, capturedPath](const ActivityResult& result) {
|
||||
if (result.isCancelled) {
|
||||
requestUpdate();
|
||||
return;
|
||||
}
|
||||
const auto& menuResult = std::get<MenuResult>(result.data);
|
||||
auto action = static_cast<BookManageMenuActivity::Action>(menuResult.action);
|
||||
bool success = false;
|
||||
switch (action) {
|
||||
case BookManageMenuActivity::Action::ARCHIVE:
|
||||
success = BookManager::archiveBook(capturedPath);
|
||||
break;
|
||||
case BookManageMenuActivity::Action::UNARCHIVE:
|
||||
success = BookManager::unarchiveBook(capturedPath);
|
||||
break;
|
||||
case BookManageMenuActivity::Action::DELETE:
|
||||
success = BookManager::deleteBook(capturedPath);
|
||||
break;
|
||||
case BookManageMenuActivity::Action::DELETE_CACHE:
|
||||
success = BookManager::deleteBookCache(capturedPath);
|
||||
break;
|
||||
case BookManageMenuActivity::Action::REINDEX:
|
||||
success = BookManager::reindexBook(capturedPath, false);
|
||||
break;
|
||||
case BookManageMenuActivity::Action::REINDEX_FULL:
|
||||
success = BookManager::reindexBook(capturedPath, true);
|
||||
break;
|
||||
}
|
||||
{
|
||||
RenderLock lock(*this);
|
||||
GUI.drawPopup(renderer, success ? tr(STR_DONE) : tr(STR_ACTION_FAILED));
|
||||
}
|
||||
loadRecentBooks();
|
||||
selectorIndex = 0;
|
||||
requestUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
void RecentBooksActivity::loop() {
|
||||
const int pageItems = UITheme::getInstance().getNumberOfItemsPerPage(renderer, true, false, true, true);
|
||||
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
||||
if (mappedInput.isPressed(MappedInputManager::Button::Confirm) && mappedInput.getHeldTime() >= LONG_PRESS_MS) {
|
||||
if (!recentBooks.empty() && selectorIndex < static_cast<int>(recentBooks.size())) {
|
||||
ignoreNextConfirmRelease = true;
|
||||
openManageMenu(recentBooks[selectorIndex].path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
||||
if (ignoreNextConfirmRelease) {
|
||||
ignoreNextConfirmRelease = false;
|
||||
} else if (!recentBooks.empty() && selectorIndex < static_cast<int>(recentBooks.size())) {
|
||||
LOG_DBG("RBA", "Selected recent book: %s", recentBooks[selectorIndex].path.c_str());
|
||||
onSelectBook(recentBooks[selectorIndex].path);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user