From 76047b996dece29a27811af49e05b6a6e2b52069 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Fri, 5 May 2023 22:33:38 +0200 Subject: [PATCH 1/2] Show notification indicator when a notification is available - InfiniTimeOrg/InfiniTime PR#1234 --- src/displayapp/screens/WatchFaceAnalog.cpp | 10 +++++++++- .../screens/WatchFaceCasioStyleG7710.cpp | 10 +++++++++- src/displayapp/screens/WatchFaceDigital.cpp | 10 +++++++++- src/displayapp/screens/WatchFaceInfineat.cpp | 2 +- .../screens/WatchFacePineTimeStyle.cpp | 18 ++++++++++++++---- .../screens/WatchFacePineTimeStyle.h | 1 + src/displayapp/screens/WatchFaceTerminal.cpp | 4 ++++ 7 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 76d01cf1e0..0be987b8a8 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -219,7 +219,15 @@ void WatchFaceAnalog::Refresh() { notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { - lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); + if (notificationState.Get()) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(true)); + } else if (notificationManager.NbNotifications() > 0) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(true)); + } else { + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); + } } currentDateTime = dateTimeController.CurrentDateTime(); diff --git a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp b/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp index c468a4b1ec..29fc39a0d0 100644 --- a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp +++ b/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp @@ -219,7 +219,15 @@ void WatchFaceCasioStyleG7710::Refresh() { notificationState = notificatioManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { - lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); + if (notificationState.Get()) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(true)); + } else if (notificatioManager.NbNotifications() > 0) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(true)); + } else { + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); + } } currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index ca53691b12..74a6758275 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -82,7 +82,15 @@ void WatchFaceDigital::Refresh() { notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { - lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); + if (notificationState.Get()) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(true)); + } else if (notificationManager.NbNotifications() > 0) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(true)); + } else { + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); + } } currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index 3308303dcc..17ccc23d9b 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -393,7 +393,7 @@ void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) { void WatchFaceInfineat::Refresh() { notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { - lv_obj_set_hidden(notificationIcon, !notificationState.Get()); + lv_obj_set_hidden(notificationIcon, !(notificationState.Get() || (notificationManager.NbNotifications() > 0))); lv_obj_align(notificationIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); } diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp index fbdabc9ecb..d71a4cac16 100644 --- a/src/displayapp/screens/WatchFacePineTimeStyle.cpp +++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp @@ -404,10 +404,11 @@ void WatchFacePineTimeStyle::SetBatteryIcon() { } void WatchFacePineTimeStyle::AlignIcons() { - if (notificationState.Get() && bleState.Get()) { + bool notif = notificationState.Get() || notificationNbState.Get(); + if (notif && bleState.Get()) { lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 8, 25); lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, -8, 25); - } else if (notificationState.Get() && !bleState.Get()) { + } else if (notif && !bleState.Get()) { lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); } else { lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); @@ -441,8 +442,17 @@ void WatchFacePineTimeStyle::Refresh() { } notificationState = notificationManager.AreNewNotificationsAvailable(); - if (notificationState.IsUpdated()) { - lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); + notificationNbState = notificationManager.NbNotifications() > 0; + if (notificationState.IsUpdated() || notificationNbState.IsUpdated()) { + if (notificationState.Get()) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(true)); + } else if (notificationNbState.Get()) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(true)); + } else { + lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(true)); + } AlignIcons(); } diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.h b/src/displayapp/screens/WatchFacePineTimeStyle.h index a5c0690160..549b254984 100644 --- a/src/displayapp/screens/WatchFacePineTimeStyle.h +++ b/src/displayapp/screens/WatchFacePineTimeStyle.h @@ -58,6 +58,7 @@ namespace Pinetime { Utility::DirtyValue> currentDateTime {}; Utility::DirtyValue stepCount {}; Utility::DirtyValue notificationState {}; + Utility::DirtyValue notificationNbState {}; static Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color); static Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color); diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp index 723837299b..4c1488bac9 100644 --- a/src/displayapp/screens/WatchFaceTerminal.cpp +++ b/src/displayapp/screens/WatchFaceTerminal.cpp @@ -98,6 +98,10 @@ void WatchFaceTerminal::Refresh() { notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { if (notificationState.Get()) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); + lv_label_set_text_static(notificationIcon, "You have mail."); + } else if (notificationManager.NbNotifications() > 0) { + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); lv_label_set_text_static(notificationIcon, "You have mail."); } else { lv_label_set_text_static(notificationIcon, ""); From 059eaa24db53c1ecae9552fe135689bac2015143 Mon Sep 17 00:00:00 2001 From: tgc-dk Date: Tue, 27 Aug 2024 10:28:16 +0000 Subject: [PATCH 2/2] Removed unused variables --- src/displayapp/screens/WatchFacePineTimeStyle.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.h b/src/displayapp/screens/WatchFacePineTimeStyle.h index d85b695928..47a1dabf42 100644 --- a/src/displayapp/screens/WatchFacePineTimeStyle.h +++ b/src/displayapp/screens/WatchFacePineTimeStyle.h @@ -63,9 +63,6 @@ namespace Pinetime { Utility::DirtyValue notificationState {}; Utility::DirtyValue notificationNbState {}; Utility::DirtyValue> currentWeather {}; - Utility::DirtyValue nowTemp {}; - int16_t clouds = 0; - int16_t precip = 0; static Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color); static Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);