Merge pull request #168 from jpirnay/feat-cycleorientation

feat: Add orientation change to user defined button actions
This commit is contained in:
jpirnay
2026-05-04 14:00:44 +02:00
committed by GitHub
8 changed files with 40 additions and 11 deletions
+2 -1
View File
@@ -615,5 +615,6 @@ STR_KB_HINT_LOWER_SECONDARY: "Hold SELECT for lowercase or secondary char"
STR_KB_HINT_URL_SNIPPETS: "Press URL for snippets"
STR_BIONIC_READING: "Bionic Reading"
STR_BTN_ACT_TOGGLE_BIONIC_READING: "Toggle Bionic Reading"
STR_BTN_ACT_CYCLE_FONT_SIZE: "Cycle Font Size"
STR_BTN_ACT_CYCLE_FONT_SIZE: "Change Font Size"
STR_BTN_ACT_CYCLE_ORIENTATION: "Change Orientation"
STR_RESTART_DEVICE: "Restart Device"
+1
View File
@@ -290,6 +290,7 @@ class CrossPointSettings {
BTN_TOGGLE_BIONIC_READING,
BTN_KOREADER_SYNC,
BTN_CYCLE_FONT_SIZE,
BTN_CYCLE_ORIENTATION,
BUTTON_ACTION_COUNT
};
+1 -1
View File
@@ -147,7 +147,7 @@ inline const std::vector<SettingInfo> list = {
StrId::STR_BTN_ACT_OPEN_BOOKMARKS, StrId::STR_BTN_ACT_STAR_PAGE, StrId::STR_BTN_ACT_FOOTNOTES, \
StrId::STR_BTN_ACT_NEXT_SECTION, StrId::STR_BTN_ACT_PREV_SECTION, StrId::STR_BTN_ACT_EXIT_READER, \
StrId::STR_BTN_ACT_READER_MENU, StrId::STR_BTN_ACT_TOGGLE_BIONIC_READING, StrId::STR_BTN_ACT_KOREADER_SYNC, \
StrId::STR_BTN_ACT_CYCLE_FONT_SIZE
StrId::STR_BTN_ACT_CYCLE_FONT_SIZE, StrId::STR_BTN_ACT_CYCLE_ORIENTATION
// Back button: short=exit reader, double=ignore, long=go home
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortBack, {StrId::STR_BTN_DEF_EXIT_READER},
@@ -2016,6 +2016,14 @@ void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION
requestUpdate();
}
break;
case BA::BTN_CYCLE_ORIENTATION:
if (epub) {
const uint8_t nextOrientation =
static_cast<uint8_t>((SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT);
applyOrientation(nextOrientation);
requestUpdate();
}
break;
case BA::BTN_KOREADER_SYNC:
launchKOReaderSync(SyncLaunchMode::COMPARE);
break;
@@ -995,6 +995,17 @@ void MdReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION ac
ReaderUtils::enforceExitFullRefresh(renderer);
finish();
break;
case BA::BTN_CYCLE_ORIENTATION: {
const uint8_t nextOrientation =
static_cast<uint8_t>((SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT);
SETTINGS.orientation = nextOrientation;
SETTINGS.saveToFile();
ReaderUtils::applyOrientation(renderer, SETTINGS.orientation);
initialized = false;
initializeReader();
requestUpdate();
break;
}
default:
break;
}
@@ -833,6 +833,17 @@ void TxtReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
ReaderUtils::enforceExitFullRefresh(renderer);
finish();
break;
case BA::BTN_CYCLE_ORIENTATION: {
const uint8_t nextOrientation =
static_cast<uint8_t>((SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT);
SETTINGS.orientation = nextOrientation;
SETTINGS.saveToFile();
ReaderUtils::applyOrientation(renderer, SETTINGS.orientation);
initialized = false;
initializeReader();
requestUpdate();
break;
}
default:
break;
}
+3
View File
@@ -545,6 +545,9 @@ void loop() {
case BA::BTN_CYCLE_FONT_SIZE:
activityManager.dispatchButtonAction(BA::BTN_CYCLE_FONT_SIZE);
break;
case BA::BTN_CYCLE_ORIENTATION:
activityManager.dispatchButtonAction(BA::BTN_CYCLE_ORIENTATION);
break;
default:
break;
}
+3 -9
View File
@@ -82,9 +82,7 @@ bool HttpDownloader::fetchUrl(const std::string& url, Stream& outContent, const
if (httpCode != HTTP_CODE_OK) {
LOG_ERR("HTTP", "Fetch failed: %d", httpCode);
http.end();
if (client) {
client->stop();
}
client->stop();
return false;
}
@@ -142,9 +140,7 @@ HttpDownloader::DownloadError HttpDownloader::downloadToFile(const std::string&
if (httpCode != HTTP_CODE_OK) {
LOG_ERR("HTTP", "Download failed: %d", httpCode);
http.end();
if (client) {
client->stop();
}
client->stop();
return HTTP_ERROR;
}
@@ -221,9 +217,7 @@ HttpDownloader::DownloadError HttpDownloader::downloadToFile(const std::string&
file.flush();
file.close();
http.end();
if (client) {
client->stop();
}
client->stop();
if (writeResult < 0) {
LOG_ERR("HTTP", "writeToStream error: %d", writeResult);