diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index e4ebc982..1f2abb41 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -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" \ No newline at end of file diff --git a/src/CrossPointSettings.h b/src/CrossPointSettings.h index d7da625b..1797a31c 100644 --- a/src/CrossPointSettings.h +++ b/src/CrossPointSettings.h @@ -290,6 +290,7 @@ class CrossPointSettings { BTN_TOGGLE_BIONIC_READING, BTN_KOREADER_SYNC, BTN_CYCLE_FONT_SIZE, + BTN_CYCLE_ORIENTATION, BUTTON_ACTION_COUNT }; diff --git a/src/SettingsList.h b/src/SettingsList.h index 2157048b..c2ad45b0 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -147,7 +147,7 @@ inline const std::vector 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}, diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 4d2f14c3..844fe9a5 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -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((SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT); + applyOrientation(nextOrientation); + requestUpdate(); + } + break; case BA::BTN_KOREADER_SYNC: launchKOReaderSync(SyncLaunchMode::COMPARE); break; diff --git a/src/activities/reader/MdReaderActivity.cpp b/src/activities/reader/MdReaderActivity.cpp index c35babbc..3b0a7f65 100644 --- a/src/activities/reader/MdReaderActivity.cpp +++ b/src/activities/reader/MdReaderActivity.cpp @@ -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((SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT); + SETTINGS.orientation = nextOrientation; + SETTINGS.saveToFile(); + ReaderUtils::applyOrientation(renderer, SETTINGS.orientation); + initialized = false; + initializeReader(); + requestUpdate(); + break; + } default: break; } diff --git a/src/activities/reader/TxtReaderActivity.cpp b/src/activities/reader/TxtReaderActivity.cpp index a88d6549..4ba4f35a 100644 --- a/src/activities/reader/TxtReaderActivity.cpp +++ b/src/activities/reader/TxtReaderActivity.cpp @@ -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((SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT); + SETTINGS.orientation = nextOrientation; + SETTINGS.saveToFile(); + ReaderUtils::applyOrientation(renderer, SETTINGS.orientation); + initialized = false; + initializeReader(); + requestUpdate(); + break; + } default: break; } diff --git a/src/main.cpp b/src/main.cpp index 59af5978..dbc530ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; } diff --git a/src/network/HttpDownloader.cpp b/src/network/HttpDownloader.cpp index 7f8aec68..d8b15a22 100644 --- a/src/network/HttpDownloader.cpp +++ b/src/network/HttpDownloader.cpp @@ -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);