Merge pull request #1 from 1991AcuraLegend/hide-status
Adding status bar display settings
This commit is contained in:
commit
5adcc46b8b
@ -24,6 +24,7 @@ bool CrossPointSettings::saveToFile() const {
|
||||
serialization::writePod(outputFile, SETTINGS_FILE_VERSION);
|
||||
serialization::writePod(outputFile, SETTINGS_COUNT);
|
||||
serialization::writePod(outputFile, sleepScreen);
|
||||
serialization::writePod(outputFile, statusBar);
|
||||
serialization::writePod(outputFile, extraParagraphSpacing);
|
||||
serialization::writePod(outputFile, shortPwrBtn);
|
||||
outputFile.close();
|
||||
@ -56,6 +57,8 @@ bool CrossPointSettings::loadFromFile() {
|
||||
do {
|
||||
serialization::readPod(inputFile, sleepScreen);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, statusBar);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, extraParagraphSpacing);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, shortPwrBtn);
|
||||
|
||||
@ -18,8 +18,13 @@ class CrossPointSettings {
|
||||
// Should match with SettingsActivity text
|
||||
enum SLEEP_SCREEN_MODE { DARK = 0, LIGHT = 1, CUSTOM = 2, COVER = 3 };
|
||||
|
||||
// Status bar display type enum
|
||||
enum STATUS_BAR_MODE { NONE = 0, BATTERY = 1, PROGRESS = 2, FULL = 3 };
|
||||
|
||||
// Sleep screen settings
|
||||
uint8_t sleepScreen = DARK;
|
||||
// Status bar settings
|
||||
uint8_t statusBar = FULL;
|
||||
// Text rendering settings
|
||||
uint8_t extraParagraphSpacing = 1;
|
||||
// Duration of the power button press
|
||||
|
||||
@ -332,6 +332,7 @@ void EpubReaderActivity::renderContents(std::unique_ptr<Page> page) {
|
||||
void EpubReaderActivity::renderStatusBar() const {
|
||||
constexpr auto textY = 776;
|
||||
|
||||
if (Settings.statusBar && CrossPointSettings::STATUS_BAR_MODE::PROGRESS) {
|
||||
// Calculate progress in book
|
||||
const float sectionChapterProg = static_cast<float>(section->currentPage) / section->pageCount;
|
||||
const uint8_t bookProgress = epub->calculateProgress(currentSpineIndex, sectionChapterProg);
|
||||
@ -342,7 +343,9 @@ void EpubReaderActivity::renderStatusBar() const {
|
||||
const auto progressTextWidth = renderer.getTextWidth(SMALL_FONT_ID, progress.c_str());
|
||||
renderer.drawText(SMALL_FONT_ID, GfxRenderer::getScreenWidth() - marginRight - progressTextWidth, textY,
|
||||
progress.c_str());
|
||||
}
|
||||
|
||||
if (Settings.statusBar && CrossPointSettings::STATUS_BAR_MODE::BATTERY) {
|
||||
// Left aligned battery icon and percentage
|
||||
const uint16_t percentage = battery.readPercentage();
|
||||
const auto percentageText = std::to_string(percentage) + "%";
|
||||
@ -374,6 +377,10 @@ void EpubReaderActivity::renderStatusBar() const {
|
||||
}
|
||||
renderer.fillRect(x + 1, y + 1, filledWidth, batteryHeight - 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (Settings.statusBar && CrossPointSettings::STATUS_BAR_MODE::FULL) {
|
||||
// Centered chatper title text
|
||||
// Page width minus existing content with 30px padding on each side
|
||||
const int titleMarginLeft = 20 + percentageTextWidth + 30 + marginLeft;
|
||||
@ -398,3 +405,4 @@ void EpubReaderActivity::renderStatusBar() const {
|
||||
|
||||
renderer.drawText(SMALL_FONT_ID, titleMarginLeft + (availableTextWidth - titleWidth) / 2, textY, title.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ constexpr int settingsCount = 4;
|
||||
const SettingInfo settingsList[settingsCount] = {
|
||||
// Should match with SLEEP_SCREEN_MODE
|
||||
{"Sleep Screen", SettingType::ENUM, &CrossPointSettings::sleepScreen, {"Dark", "Light", "Custom", "Cover"}},
|
||||
{"Status Bar", SettingType::ENUM, &CrossPointSettings::statusBar, {"None", "Battery", "Progress", "Full"}},
|
||||
{"Extra Paragraph Spacing", SettingType::TOGGLE, &CrossPointSettings::extraParagraphSpacing, {}},
|
||||
{"Short Power Button Click", SettingType::TOGGLE, &CrossPointSettings::shortPwrBtn, {}},
|
||||
{"Check for updates", SettingType::ACTION, nullptr, {}},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user