From 078d9ef5350eef960fc49e388dc89e9310aab9d0 Mon Sep 17 00:00:00 2001 From: Justin Mitchell Date: Tue, 14 Jul 2026 04:47:48 -0400 Subject: [PATCH] Update status bar immediately on BLE connect/disconnect Previously the status bar showed 'BT connecting' until the next page turn. Now monitors connection state in loop() and redraws the status bar immediately when connection completes or disconnects, restoring the chapter/book title. The connecting message now takes over the entire title slot instead of prepending to it. --- src/activities/reader/EpubReaderActivity.cpp | 21 ++++++++++++++++++-- src/activities/reader/EpubReaderActivity.h | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index e00a3fb8..c72b3fca 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -208,6 +208,8 @@ void EpubReaderActivity::onEnter() { ImageBlock::clearSessionRenderFailures(); + statusBarBleConnected = BleHid.isConnected(); + // Configure screen orientation based on settings // NOTE: This affects layout math and must be applied before any render calls. ReaderUtils::applyOrientation(renderer, SETTINGS.orientation); @@ -341,6 +343,19 @@ void EpubReaderActivity::loop() { return; } + // Swap the "BT connecting" status bar placeholder back to the chapter/book + // title the moment the connection completes (and back on disconnect). Skips + // while a render is in flight or the framebuffer is lent to a build; the + // next page render shows the right state anyway. + if (SETTINGS.bluetoothEnabled && section && renderer.hasFrameBuffer() && !RenderLock::peek()) { + const bool connected = BleHid.isConnected(); + if (connected != statusBarBleConnected) { + statusBarBleConnected = connected; + renderStatusBar(); + renderer.displayBuffer(HalDisplay::FAST_REFRESH); + } + } + // Lazily resume a partial's extension build once the reader nears its watermark. Far from // it the rebuild is all cost (whole-chapter re-layout from page 0) and no benefit this // session, so reopening a partial deliberately does NOT start it (see the deferral in @@ -1790,8 +1805,10 @@ void EpubReaderActivity::renderStatusBar() const { } if (SETTINGS.bluetoothEnabled && !BleHid.isConnected()) { - const std::string btStatus = tr(STR_BT_CONNECTING_POPUP); - title = title.empty() ? btStatus : btStatus + " " + title; + // Take over the title slot entirely while connecting; the watcher in + // loop() redraws the bar on the connect/disconnect flip, restoring the + // chapter/book title. + title = tr(STR_BT_CONNECTING_POPUP); } GUI.drawStatusBar(renderer, bookProgress, currentPage, pageCount, title, 0, textYOffset, true, currentPageBookmarked, diff --git a/src/activities/reader/EpubReaderActivity.h b/src/activities/reader/EpubReaderActivity.h index 4855074e..3fff2364 100644 --- a/src/activities/reader/EpubReaderActivity.h +++ b/src/activities/reader/EpubReaderActivity.h @@ -41,6 +41,11 @@ class EpubReaderActivity final : public Activity { bool showBookmarkMessage = false; bool ignoreNextConfirmRelease = false; bool currentPageBookmarked = false; + // BLE connection state the status bar last rendered with; loop() watches for + // a flip and redraws the bar so the "BT connecting" placeholder swaps back + // to the chapter/book title the moment the connection completes (and + // returns on disconnect) instead of waiting for the next page turn. + bool statusBarBleConnected = false; bool bookmarkRemoved = false; // true when last toggle removed (controls popup text) std::vector cachedBookmarks; // Tracks whether this book is currently removed from Recent Books by the