A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add orientation-aware popups for reader activities (#1428)

## Summary

Make popups (like "Going to sleep") respect the current screen
orientation when shown from reader activities.

**What changes are included?**

- Apply reader orientation in SleepActivity before showing popup when
`lastSleepFromReader` is true
- Make popup Y-position proportional to screen height (7.5% for
BaseTheme, 16.5% for LyraTheme) instead of hardcoded pixel values,
ensuring correct positioning in both portrait and landscape modes.
- Add `isReaderActivity()` override to all reader sub-screens (menu,
chapter selection, percent selection, footnotes, QR display, KOReader
sync), so sleep popups rotate correctly when entering sleep from any
reader context.

## Additional Context

<img
src="https://github.com/user-attachments/assets/47d88c2c-ffc5-41a7-b3f2-af272ea0150e"
width="400" height="240">

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_ (Claude Opus
4.5)

authored by

Егор Мартынов and committed by
GitHub
cced7778 1bd7a1de

+20 -3
+10 -1
src/activities/boot_sleep/SleepActivity.cpp
··· 10 10 11 11 #include "CrossPointSettings.h" 12 12 #include "CrossPointState.h" 13 + #include "activities/reader/ReaderUtils.h" 13 14 #include "components/UITheme.h" 14 15 #include "fontIds.h" 15 16 #include "images/Logo120.h" 16 17 17 18 void SleepActivity::onEnter() { 18 19 Activity::onEnter(); 19 - GUI.drawPopup(renderer, tr(STR_ENTERING_SLEEP)); 20 + 21 + // Show popup with reader orientation only when going to sleep from reader 22 + if (APP_STATE.lastSleepFromReader) { 23 + ReaderUtils::applyOrientation(renderer, SETTINGS.orientation); 24 + GUI.drawPopup(renderer, tr(STR_ENTERING_SLEEP)); 25 + renderer.setOrientation(GfxRenderer::Orientation::Portrait); 26 + } else { 27 + GUI.drawPopup(renderer, tr(STR_ENTERING_SLEEP)); 28 + } 20 29 21 30 switch (SETTINGS.sleepScreen) { 22 31 case (CrossPointSettings::SLEEP_SCREEN_MODE::BLANK):
+1
src/activities/reader/EpubReaderChapterSelectionActivity.h
··· 32 32 void onExit() override; 33 33 void loop() override; 34 34 void render(RenderLock&&) override; 35 + bool isReaderActivity() const override { return true; } 35 36 };
+1
src/activities/reader/EpubReaderFootnotesActivity.h
··· 19 19 void onExit() override; 20 20 void loop() override; 21 21 void render(RenderLock&&) override; 22 + bool isReaderActivity() const override { return true; } 22 23 23 24 private: 24 25 const std::vector<FootnoteEntry>& footnotes;
+1
src/activities/reader/EpubReaderMenuActivity.h
··· 32 32 void onExit() override; 33 33 void loop() override; 34 34 void render(RenderLock&&) override; 35 + bool isReaderActivity() const override { return true; } 35 36 36 37 private: 37 38 struct MenuItem {
+1
src/activities/reader/EpubReaderPercentSelectionActivity.h
··· 15 15 void onExit() override; 16 16 void loop() override; 17 17 void render(RenderLock&&) override; 18 + bool isReaderActivity() const override { return true; } 18 19 19 20 private: 20 21 // Current percent value (0-100) shown on the slider.
+1
src/activities/reader/KOReaderSyncActivity.h
··· 38 38 void loop() override; 39 39 void render(RenderLock&&) override; 40 40 bool preventAutoSleep() override { return state == CONNECTING || state == SYNCING; } 41 + bool isReaderActivity() const override { return true; } 41 42 42 43 private: 43 44 enum State {
+1
src/activities/reader/QrDisplayActivity.h
··· 14 14 void onExit() override; 15 15 void loop() override; 16 16 void render(RenderLock&&) override; 17 + bool isReaderActivity() const override { return true; } 17 18 18 19 private: 19 20 std::string textPayload;
+2 -1
src/components/themes/BaseTheme.cpp
··· 648 648 649 649 Rect BaseTheme::drawPopup(const GfxRenderer& renderer, const char* message) const { 650 650 constexpr int margin = 15; 651 - constexpr int y = 60; 651 + // Scale y position proportionally to screen height (7.5% from top) 652 + const int y = static_cast<int>(renderer.getScreenHeight() * 0.075f); 652 653 const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::BOLD); 653 654 const int textHeight = renderer.getLineHeight(UI_12_FONT_ID); 654 655 const int w = textWidth + margin * 2;
+2 -1
src/components/themes/lyra/LyraTheme.cpp
··· 541 541 } 542 542 543 543 Rect LyraTheme::drawPopup(const GfxRenderer& renderer, const char* message) const { 544 - constexpr int y = 132; 544 + // Scale y position proportionally to screen height (16.5% from top) 545 + const int y = static_cast<int>(renderer.getScreenHeight() * 0.165f); 545 546 constexpr int outline = 2; 546 547 const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::REGULAR); 547 548 const int textHeight = renderer.getLineHeight(UI_12_FONT_ID);