Use new method to decide button press
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "../ActivityManager.h"
|
||||
#include "../reader/ReaderUtils.h"
|
||||
#include "../util/ConfirmationActivity.h"
|
||||
#include "BookInfoActivity.h"
|
||||
#include "CrossPointState.h"
|
||||
@@ -54,11 +53,16 @@ void RecentBooksActivity::onExit() {
|
||||
void RecentBooksActivity::loop() {
|
||||
const int pageItems = UITheme::getInstance().getNumberOfItemsPerPage(renderer, true, false, true, true);
|
||||
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm) && !recentBooks.empty() &&
|
||||
selectorIndex < static_cast<int>(recentBooks.size())) {
|
||||
ButtonEventManager::ButtonEvent ev;
|
||||
while (buttonEvents.consumeEvent(ev)) {
|
||||
if (ev.button == MappedInputManager::Button::Confirm &&
|
||||
(ev.type == ButtonEventManager::PressType::Short || ev.type == ButtonEventManager::PressType::Long)) {
|
||||
if (recentBooks.empty() || selectorIndex >= recentBooks.size()) {
|
||||
return;
|
||||
}
|
||||
// Long-press Confirm signals "open with KOReader sync" only for EPUBs.
|
||||
// Short-press is unchanged direct open.
|
||||
const bool longPress = mappedInput.getHeldTime() >= ReaderUtils::GO_HOME_MS && KOREADER_STORE.hasCredentials();
|
||||
const bool longPress = (ev.type == ButtonEventManager::PressType::Long) && KOREADER_STORE.hasCredentials();
|
||||
const std::string& selectedPath = recentBooks[selectorIndex].path;
|
||||
const bool isEpubBook = FsHelpers::hasEpubExtension(selectedPath);
|
||||
LOG_DBG("RBA", "Selected recent book: %s (sync=%d epub=%d)", selectedPath.c_str(), longPress ? 1 : 0,
|
||||
@@ -76,13 +80,13 @@ void RecentBooksActivity::loop() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
|
||||
if (ev.button == MappedInputManager::Button::Back && ev.type == ButtonEventManager::PressType::Short) {
|
||||
onGoHome();
|
||||
return;
|
||||
}
|
||||
|
||||
// Left button: remove selected book from recent list
|
||||
if (!recentBooks.empty() && selectorIndex < recentBooks.size() &&
|
||||
mappedInput.wasReleased(MappedInputManager::Button::Left)) {
|
||||
if (ev.button == MappedInputManager::Button::Left && ev.type == ButtonEventManager::PressType::Short) {
|
||||
if (recentBooks.empty() || selectorIndex >= recentBooks.size()) return;
|
||||
const std::string bookPath = recentBooks[selectorIndex].path;
|
||||
const std::string bookTitle = recentBooks[selectorIndex].title;
|
||||
|
||||
@@ -103,12 +107,13 @@ void RecentBooksActivity::loop() {
|
||||
};
|
||||
|
||||
std::string heading = tr(STR_REMOVE) + std::string("? ");
|
||||
startActivityForResult(std::make_unique<ConfirmationActivity>(renderer, mappedInput, heading, bookTitle), handler);
|
||||
startActivityForResult(std::make_unique<ConfirmationActivity>(renderer, mappedInput, heading, bookTitle),
|
||||
handler);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Right) && !recentBooks.empty() &&
|
||||
selectorIndex < static_cast<int>(recentBooks.size())) {
|
||||
if (ev.button == MappedInputManager::Button::Right && ev.type == ButtonEventManager::PressType::Short) {
|
||||
if (recentBooks.empty() || selectorIndex >= recentBooks.size()) return;
|
||||
const std::string& path = recentBooks[selectorIndex].path;
|
||||
if (FsHelpers::hasEpubExtension(path) || FsHelpers::hasXtcExtension(path)) {
|
||||
startActivityForResult(std::make_unique<BookInfoActivity>(renderer, mappedInput, path),
|
||||
@@ -116,6 +121,7 @@ void RecentBooksActivity::loop() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int listSize = static_cast<int>(recentBooks.size());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user