From f5a780c1c8ed174520d234c43497bdc596380f53 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Sat, 25 Oct 2025 23:10:13 +0200 Subject: [PATCH] better lockscreen notifications --- .../apps/lockscreen/src/lockscreen_app.cpp | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/Firmware/sdk/apps/lockscreen/src/lockscreen_app.cpp b/Firmware/sdk/apps/lockscreen/src/lockscreen_app.cpp index e9a955a..95b3afa 100644 --- a/Firmware/sdk/apps/lockscreen/src/lockscreen_app.cpp +++ b/Firmware/sdk/apps/lockscreen/src/lockscreen_app.cpp @@ -130,12 +130,14 @@ private: if (!notifications.empty() && (upPressed || downPressed)) { const std::size_t count = notifications.size(); lastNotificationInteractionMs = clock.millis(); - navPressed = true; if (count > 1) { - if (upPressed) - selectedNotification = (selectedNotification + count - 1) % count; - else if (downPressed) - selectedNotification = (selectedNotification + 1) % count; + if (upPressed && selectedNotification > 0) { + selectedNotification--; + navPressed = true; + } else if (downPressed && selectedNotification < count - 1) { + selectedNotification++; + navPressed = true; + } } } @@ -500,8 +502,10 @@ private: const int arrowsTotalWide = arrowWidth * 2 + arrowSpacing; const int arrowX = counterX + (counterWidth - arrowsTotalWide) / 2; const int arrowY = cardMarginTop + cardPadding + textLineHeight + 1; - drawArrow(framebuffer, arrowX, arrowY, true, scaleSmall); - drawArrow(framebuffer, arrowX + arrowWidth + arrowSpacing, arrowY, false, scaleSmall); + if (selectedNotification > 0) + drawArrow(framebuffer, arrowX, arrowY, true, scaleSmall); + if (selectedNotification < notifications.size() - 1) + drawArrow(framebuffer, arrowX + arrowWidth + arrowSpacing, arrowY, false, scaleSmall); const int arrowHeight = font16x8::kGlyphHeight * scaleSmall; cardHeight = std::max(cardHeight, arrowY + arrowHeight - cardMarginTop); } @@ -524,28 +528,13 @@ private: const int summaryX = (framebuffer.width() - summaryWidth) / 2; const int summaryY = cardMarginTop; font16x8::drawText(framebuffer, summaryX, summaryY, summary, scaleSmall, true, 1); - - if (notifications.size() > 1) { - const int arrowWidth = font16x8::kGlyphWidth * scaleSmall; - const int arrowSpacing = std::max(1, scaleSmall); - const int arrowsTotalWide = arrowWidth * 2 + arrowSpacing; - const int arrowX = (framebuffer.width() - arrowsTotalWide) / 2; - const int arrowY = summaryY + textLineHeight + 1; - drawArrow(framebuffer, arrowX, arrowY, true, scaleSmall); - drawArrow(framebuffer, arrowX + arrowWidth + arrowSpacing, arrowY, false, scaleSmall); - const int arrowHeight = font16x8::kGlyphHeight * scaleSmall; - cardHeight = std::max(cardHeight, arrowY + arrowHeight - cardMarginTop); - } } } - const int defaultTimeY = (framebuffer.height() - font16x8::kGlyphHeight * scaleTime) / 2 - 8; - int timeY = defaultTimeY; - if (cardHeight > 0) - timeY = cardMarginTop + cardHeight + 16; - const int minTimeY = (cardHeight > 0) ? (cardMarginTop + cardHeight + 12) : 16; - const int maxTimeY = std::max(minTimeY, framebuffer.height() - font16x8::kGlyphHeight * scaleTime - 48); - timeY = std::clamp(timeY, minTimeY, maxTimeY); + const int defaultTimeY = (framebuffer.height() - font16x8::kGlyphHeight * scaleTime) / 2 - 8; + const int minTimeY = (cardHeight > 0) ? (cardMarginTop + cardHeight + 12) : 16; + const int maxTimeY = std::max(minTimeY, framebuffer.height() - font16x8::kGlyphHeight * scaleTime - 48); + const int timeY = std::clamp(defaultTimeY, minTimeY, maxTimeY); char hoursMinutes[6]; std::snprintf(hoursMinutes, sizeof(hoursMinutes), "%02d:%02d", snap.hour24, snap.minute);