Merge pull request #168 from jpirnay/feat-cycleorientation
feat: Add orientation change to user defined button actions
This commit is contained in:
@@ -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_KB_HINT_URL_SNIPPETS: "Press URL for snippets"
|
||||||
STR_BIONIC_READING: "Bionic Reading"
|
STR_BIONIC_READING: "Bionic Reading"
|
||||||
STR_BTN_ACT_TOGGLE_BIONIC_READING: "Toggle 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"
|
STR_RESTART_DEVICE: "Restart Device"
|
||||||
@@ -290,6 +290,7 @@ class CrossPointSettings {
|
|||||||
BTN_TOGGLE_BIONIC_READING,
|
BTN_TOGGLE_BIONIC_READING,
|
||||||
BTN_KOREADER_SYNC,
|
BTN_KOREADER_SYNC,
|
||||||
BTN_CYCLE_FONT_SIZE,
|
BTN_CYCLE_FONT_SIZE,
|
||||||
|
BTN_CYCLE_ORIENTATION,
|
||||||
BUTTON_ACTION_COUNT
|
BUTTON_ACTION_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -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_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_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_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
|
// 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},
|
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();
|
requestUpdate();
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case BA::BTN_KOREADER_SYNC:
|
||||||
launchKOReaderSync(SyncLaunchMode::COMPARE);
|
launchKOReaderSync(SyncLaunchMode::COMPARE);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -995,6 +995,17 @@ void MdReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION ac
|
|||||||
ReaderUtils::enforceExitFullRefresh(renderer);
|
ReaderUtils::enforceExitFullRefresh(renderer);
|
||||||
finish();
|
finish();
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -833,6 +833,17 @@ void TxtReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
|
|||||||
ReaderUtils::enforceExitFullRefresh(renderer);
|
ReaderUtils::enforceExitFullRefresh(renderer);
|
||||||
finish();
|
finish();
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -545,6 +545,9 @@ void loop() {
|
|||||||
case BA::BTN_CYCLE_FONT_SIZE:
|
case BA::BTN_CYCLE_FONT_SIZE:
|
||||||
activityManager.dispatchButtonAction(BA::BTN_CYCLE_FONT_SIZE);
|
activityManager.dispatchButtonAction(BA::BTN_CYCLE_FONT_SIZE);
|
||||||
break;
|
break;
|
||||||
|
case BA::BTN_CYCLE_ORIENTATION:
|
||||||
|
activityManager.dispatchButtonAction(BA::BTN_CYCLE_ORIENTATION);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,9 +82,7 @@ bool HttpDownloader::fetchUrl(const std::string& url, Stream& outContent, const
|
|||||||
if (httpCode != HTTP_CODE_OK) {
|
if (httpCode != HTTP_CODE_OK) {
|
||||||
LOG_ERR("HTTP", "Fetch failed: %d", httpCode);
|
LOG_ERR("HTTP", "Fetch failed: %d", httpCode);
|
||||||
http.end();
|
http.end();
|
||||||
if (client) {
|
client->stop();
|
||||||
client->stop();
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,9 +140,7 @@ HttpDownloader::DownloadError HttpDownloader::downloadToFile(const std::string&
|
|||||||
if (httpCode != HTTP_CODE_OK) {
|
if (httpCode != HTTP_CODE_OK) {
|
||||||
LOG_ERR("HTTP", "Download failed: %d", httpCode);
|
LOG_ERR("HTTP", "Download failed: %d", httpCode);
|
||||||
http.end();
|
http.end();
|
||||||
if (client) {
|
client->stop();
|
||||||
client->stop();
|
|
||||||
}
|
|
||||||
return HTTP_ERROR;
|
return HTTP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,9 +217,7 @@ HttpDownloader::DownloadError HttpDownloader::downloadToFile(const std::string&
|
|||||||
file.flush();
|
file.flush();
|
||||||
file.close();
|
file.close();
|
||||||
http.end();
|
http.end();
|
||||||
if (client) {
|
client->stop();
|
||||||
client->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (writeResult < 0) {
|
if (writeResult < 0) {
|
||||||
LOG_ERR("HTTP", "writeToStream error: %d", writeResult);
|
LOG_ERR("HTTP", "writeToStream error: %d", writeResult);
|
||||||
|
|||||||
Reference in New Issue
Block a user