Skip to content

Commit ba1327f

Browse files
committed
Merge feature/tap-menu-sleep: v0.12.1 fixes
2 parents de24390 + 19a7354 commit ba1327f

2 files changed

Lines changed: 49 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [v0.12.1] - 2026-03-29
6+
7+
### Fixed
8+
- **Aggressive sleep wake cycles no longer flash the log screen.** The app now renders the new image before sleeping, so you see the image instead of status text.
9+
- Screen timeout is always restored if you navigate away or the app exits mid-sleep.
10+
11+
---
12+
513
## [v0.12.0] - 2026-03-29
614

715
### Fixed

src/com/bpmct/trmnl_nook_simple_touch/DisplayActivity.java

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -551,15 +551,24 @@ private void applyIntentState(Intent intent) {
551551
@Override
552552
protected void onPause() {
553553
super.onPause();
554+
// Restore screen timeout whenever we leave — user is navigating around the device.
555+
try {
556+
android.provider.Settings.System.putInt(
557+
getContentResolver(),
558+
android.provider.Settings.System.SCREEN_OFF_TIMEOUT,
559+
120000);
560+
} catch (Throwable t) { /* ignore */ }
554561
if (refreshRunnable != null) {
555562
refreshHandler.removeCallbacks(refreshRunnable);
556563
}
557564
if (pendingSleepRunnable != null) {
558565
refreshHandler.removeCallbacks(pendingSleepRunnable);
559566
pendingSleepRunnable = null;
560567
}
561-
// Don't cancel pendingScreenOffRunnable on pause — it needs to fire
562-
// even after the menu-dismiss causes a brief onPause/onResume cycle.
568+
if (pendingScreenOffRunnable != null) {
569+
refreshHandler.removeCallbacks(pendingScreenOffRunnable);
570+
pendingScreenOffRunnable = null;
571+
}
563572
if (pendingWifiWarmupRunnable != null) {
564573
refreshHandler.removeCallbacks(pendingWifiWarmupRunnable);
565574
pendingWifiWarmupRunnable = null;
@@ -570,6 +579,13 @@ protected void onPause() {
570579
@Override
571580
protected void onDestroy() {
572581
cancelConnectivityWait();
582+
// Safety net: always restore screen timeout in case the app dies before onResume
583+
try {
584+
android.provider.Settings.System.putInt(
585+
getContentResolver(),
586+
android.provider.Settings.System.SCREEN_OFF_TIMEOUT,
587+
120000);
588+
} catch (Throwable t) { /* ignore */ }
573589
try {
574590
if (alarmReceiver != null) {
575591
unregisterReceiver(alarmReceiver);
@@ -785,8 +801,15 @@ private void startFetch() {
785801
}
786802
fetchInProgress = true;
787803
fetchStartedFromMenu = menuVisible;
788-
setBootStatus("Fetching...");
789-
appendLogLine("Fetching...");
804+
// Silent background fetch when aggressive sleep is on — no boot status,
805+
// no log churn, screen stays dark/on screensaver until the new image renders.
806+
boolean silentFetch = ApiPrefs.isSuperSleep(this)
807+
&& ApiPrefs.isAllowSleep(this)
808+
&& !menuVisible;
809+
if (!silentFetch) {
810+
setBootStatus("Fetching...");
811+
appendLogLine("Fetching...");
812+
}
790813
// Only show Loading in the dialog when user tapped Next. Resume/alarm wake: keep previous display, fetch in background.
791814
if (menuVisible) {
792815
showMenuStatus("Loading...", false);
@@ -1577,30 +1600,27 @@ protected void onPostExecute(Object result) {
15771600
a.lastDisplayedImage = ar.bitmap;
15781601
// Always write screensaver immediately so TRMNL appears in NOOK's screensaver list
15791602
a.writeScreenshotToScreensaver(ar.bitmap);
1603+
boolean superSleep = ApiPrefs.isSuperSleep(a);
1604+
boolean allowSleep = ApiPrefs.isAllowSleep(a);
1605+
a.logD("super-sleep check: superSleep=" + superSleep + " allowSleep=" + allowSleep + " fromMenu=" + fromMenu);
1606+
// Always render the image in-app — hides the boot/log UI
1607+
// and ensures errors still surface via the normal error path.
15801608
a.imageView.setVisibility(View.VISIBLE);
15811609
if (a.imageRotateLayout != null) a.imageRotateLayout.setVisibility(View.VISIBLE);
1582-
if (a.contentScroll != null) {
1583-
a.contentScroll.setVisibility(View.GONE);
1584-
}
1585-
if (a.logView != null) {
1586-
a.logView.setVisibility(View.GONE);
1587-
}
1610+
if (a.contentScroll != null) a.contentScroll.setVisibility(View.GONE);
1611+
if (a.logView != null) a.logView.setVisibility(View.GONE);
15881612
a.hideMenu();
1589-
if (ar.imageUrl != null) {
1590-
a.logD("image url: " + ar.imageUrl);
1591-
}
1592-
a.forceFullRefresh();
1613+
if (ar.imageUrl != null) a.logD("image url: " + ar.imageUrl);
15931614
a.logD("displayed image");
1594-
a.logD("next display in " + (a.refreshMs / 1000L) + "s");
1595-
// Super Sleep: sleep immediately after every background image render.
1596-
// Skip only if user tapped Next from the menu.
1597-
boolean superSleep = ApiPrefs.isSuperSleep(a);
1598-
boolean allowSleep = ApiPrefs.isAllowSleep(a);
1599-
a.logD("super-sleep check: superSleep=" + superSleep + " allowSleep=" + allowSleep + " fromMenu=" + fromMenu);
16001615
if (superSleep && allowSleep && !fromMenu) {
1601-
a.logD("super sleep: sleeping immediately after image load");
1616+
// Aggressive sleep: image is visible, screensaver already written.
1617+
// Sleep immediately — no forceFullRefresh, no scheduleNextCycle.
1618+
// The NOOK screensaver renders the single EPD flash on timeout.
1619+
a.logD("super sleep: sleeping after image render");
16021620
a.sleepNow();
16031621
} else {
1622+
a.logD("next display in " + (a.refreshMs / 1000L) + "s");
1623+
a.forceFullRefresh();
16041624
a.scheduleNextCycle();
16051625
}
16061626
int pct = getBatteryPercent(a);

0 commit comments

Comments
 (0)