feat: wakeup target detection (#731)

## Summary

* If going to sleep was from the Reader view, wake up to the same book.
Otherwise, wakeup to the Home view
This commit is contained in:
Arthur Tazhitdinov
2026-02-08 21:01:30 +03:00
committed by GitHub
parent 5b90b68e99
commit 1caad578fc
5 changed files with 17 additions and 4 deletions

View File

@@ -194,6 +194,8 @@ void waitForPowerRelease() {
// Enter deep sleep mode
void enterDeepSleep() {
APP_STATE.lastSleepFromReader = currentActivity && currentActivity->isReaderActivity();
APP_STATE.saveToFile();
exitActivity();
enterNewActivity(new SleepActivity(renderer, mappedInputManager));
@@ -331,9 +333,10 @@ void setup() {
APP_STATE.loadFromFile();
RECENT_BOOKS.loadFromFile();
// Boot to home screen directly when back button is held or when reader activity crashes 3 times
if (APP_STATE.openEpubPath.empty() || mappedInputManager.isPressed(MappedInputManager::Button::Back) ||
APP_STATE.readerActivityLoadCount > 0) {
// Boot to home screen if no book is open, last sleep was not from reader, back button is held, or reader activity
// crashed (indicated by readerActivityLoadCount > 0)
if (APP_STATE.openEpubPath.empty() || !APP_STATE.lastSleepFromReader ||
mappedInputManager.isPressed(MappedInputManager::Button::Back) || APP_STATE.readerActivityLoadCount > 0) {
onGoHome();
} else {
// Clear app state to avoid getting into a boot loop if the epub doesn't load