From 2512dc60371e56f5b3fa4c25a93c4a1e885fb633 Mon Sep 17 00:00:00 2001 From: Brod8362 Date: Fri, 17 Mar 2023 16:48:52 -0500 Subject: [PATCH 1/6] Add basic notification stack functionality --- src/displayapp/screens/Notifications.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 037c43a7f6..1e2a2b88cf 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -281,6 +281,16 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_cont_set_layout(subject_container, LV_LAYOUT_COLUMN_LEFT); lv_cont_set_fit(subject_container, LV_FIT_NONE); + // draw notification stack + for (int i = 0; i < notifNb; i++) { + lv_obj_t* alert_icon = lv_label_create(container, nullptr); + if (i+1 == notifNr) { //currently selected should be orange + lv_obj_set_style_local_text_color(alert_icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange); + } + lv_label_set_text_fmt(alert_icon, Symbols::info); + lv_obj_align(alert_icon, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -22*i); + } + lv_obj_t* alert_count = lv_label_create(container, nullptr); lv_label_set_text_fmt(alert_count, "%i/%i", notifNr, notifNb); lv_obj_align(alert_count, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 16); From f31b1db79df8b287402d074418bb1816b13465cb Mon Sep 17 00:00:00 2001 From: Brod8362 Date: Fri, 17 Mar 2023 16:57:44 -0500 Subject: [PATCH 2/6] Add GetCategoryIcon to NotificationIcon --- src/displayapp/screens/NotificationIcon.cpp | 9 +++++++++ src/displayapp/screens/NotificationIcon.h | 2 ++ src/displayapp/screens/Notifications.cpp | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/displayapp/screens/NotificationIcon.cpp b/src/displayapp/screens/NotificationIcon.cpp index 0e913ae764..93347e8b4b 100644 --- a/src/displayapp/screens/NotificationIcon.cpp +++ b/src/displayapp/screens/NotificationIcon.cpp @@ -7,4 +7,13 @@ const char* NotificationIcon::GetIcon(bool newNotificationAvailable) { return Symbols::info; else return ""; +} + +//TODO: does this really belong here? +const char* NotificationIcon::GetCategoryIcon(Pinetime::Controllers::NotificationManager::Categories category) { + switch (category) { + //TODO add symbols for each category + default: + return Symbols::info; + } } \ No newline at end of file diff --git a/src/displayapp/screens/NotificationIcon.h b/src/displayapp/screens/NotificationIcon.h index dc34c3f083..3ec3805b4c 100644 --- a/src/displayapp/screens/NotificationIcon.h +++ b/src/displayapp/screens/NotificationIcon.h @@ -1,4 +1,5 @@ #pragma once +#include "components/ble/NotificationManager.h" namespace Pinetime { namespace Applications { @@ -6,6 +7,7 @@ namespace Pinetime { class NotificationIcon { public: static const char* GetIcon(bool newNotificationAvailable); + static const char* GetCategoryIcon(Pinetime::Controllers::NotificationManager::Categories category); }; } } diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 1e2a2b88cf..9fb0f74edc 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -1,4 +1,5 @@ #include "displayapp/screens/Notifications.h" +#include "displayapp/screens/NotificationIcon.h" #include "displayapp/DisplayApp.h" #include "components/ble/MusicService.h" #include "components/ble/AlertNotificationService.h" @@ -287,7 +288,8 @@ Notifications::NotificationItem::NotificationItem(const char* title, if (i+1 == notifNr) { //currently selected should be orange lv_obj_set_style_local_text_color(alert_icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange); } - lv_label_set_text_fmt(alert_icon, Symbols::info); + //TODO: get categories for the other notifications + lv_label_set_text_fmt(alert_icon, NotificationIcon::GetCategoryIcon(category)); lv_obj_align(alert_icon, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -22*i); } From 585efa46b1964f43c98549cd13d5704ab1c16d77 Mon Sep 17 00:00:00 2001 From: Brod8362 Date: Fri, 17 Mar 2023 17:02:51 -0500 Subject: [PATCH 3/6] Pass notification manager to Notifications screen --- src/displayapp/screens/Notifications.cpp | 29 +++++++++++++++--------- src/displayapp/screens/Notifications.h | 7 ++++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 9fb0f74edc..e567780ef1 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -34,10 +34,11 @@ Notifications::Notifications(DisplayApp* app, notification.category, notificationManager.NbNotifications(), alertNotificationService, - motorController); + motorController, + notificationManager); validDisplay = true; } else { - currentItem = std::make_unique(alertNotificationService, motorController); + currentItem = std::make_unique(alertNotificationService, motorController, notificationManager); validDisplay = false; } if (mode == Modes::Preview) { @@ -83,7 +84,7 @@ void Notifications::Refresh() { } else if (mode == Modes::Preview && dismissingNotification) { running = false; - currentItem = std::make_unique(alertNotificationService, motorController); + currentItem = std::make_unique(alertNotificationService, motorController, notificationManager); } else if (dismissingNotification) { dismissingNotification = false; @@ -112,9 +113,10 @@ void Notifications::Refresh() { notification.category, notificationManager.NbNotifications(), alertNotificationService, - motorController); + motorController, + notificationManager); } else { - currentItem = std::make_unique(alertNotificationService, motorController); + currentItem = std::make_unique(alertNotificationService, motorController, notificationManager); } } @@ -203,7 +205,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { previousNotification.category, notificationManager.NbNotifications(), alertNotificationService, - motorController); + motorController, + notificationManager); } return true; case Pinetime::Applications::TouchEvents::SwipeUp: { @@ -230,7 +233,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { nextNotification.category, notificationManager.NbNotifications(), alertNotificationService, - motorController); + motorController, + notificationManager); } return true; default: @@ -246,14 +250,16 @@ namespace { } Notifications::NotificationItem::NotificationItem(Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::MotorController& motorController) + Pinetime::Controllers::MotorController& motorController, + Pinetime::Controllers::NotificationManager& notificationManager) : NotificationItem("Notification", "No notification to display", 0, Controllers::NotificationManager::Categories::Unknown, 0, alertNotificationService, - motorController) { + motorController, + notificationManager) { } Notifications::NotificationItem::NotificationItem(const char* title, @@ -262,8 +268,9 @@ Notifications::NotificationItem::NotificationItem(const char* title, Controllers::NotificationManager::Categories category, uint8_t notifNb, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::MotorController& motorController) - : alertNotificationService {alertNotificationService}, motorController {motorController} { + Pinetime::Controllers::MotorController& motorController, + Pinetime::Controllers::NotificationManager& notificationManager) + : alertNotificationService {alertNotificationService}, motorController {motorController}, notificationManager {notificationManager} { container = lv_cont_create(lv_scr_act(), nullptr); lv_obj_set_size(container, LV_HOR_RES, LV_VER_RES); lv_obj_set_style_local_bg_color(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 114316b35b..9ea42acd44 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -37,14 +37,16 @@ namespace Pinetime { class NotificationItem { public: NotificationItem(Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::MotorController& motorController); + Pinetime::Controllers::MotorController& motorController, + Pinetime::Controllers::NotificationManager& notificationManager); NotificationItem(const char* title, const char* msg, uint8_t notifNr, Controllers::NotificationManager::Categories, uint8_t notifNb, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::MotorController& motorController); + Pinetime::Controllers::MotorController& motorController, + Pinetime::Controllers::NotificationManager& notificationManager); ~NotificationItem(); bool IsRunning() const { @@ -64,6 +66,7 @@ namespace Pinetime { lv_obj_t* label_reject; Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::MotorController& motorController; + Pinetime::Controllers::NotificationManager& notificationManager; bool running = true; }; From 669978ab0cc38df485484bf9f2893fa024f6e1e8 Mon Sep 17 00:00:00 2001 From: Brod8362 Date: Fri, 17 Mar 2023 17:08:34 -0500 Subject: [PATCH 4/6] Get category for each notification in stack --- src/components/ble/NotificationManager.cpp | 7 +++++++ src/components/ble/NotificationManager.h | 1 + src/displayapp/screens/Notifications.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/ble/NotificationManager.cpp b/src/components/ble/NotificationManager.cpp index 223f6221af..da9236357b 100644 --- a/src/components/ble/NotificationManager.cpp +++ b/src/components/ble/NotificationManager.cpp @@ -61,6 +61,13 @@ NotificationManager::Notification::Idx NotificationManager::IndexOf(Notification return size; } +NotificationManager::Categories NotificationManager::CategoryAt(Notification::Idx idx) const { + if (idx < 0 || idx >= this->size) { + return NotificationManager::Categories::Unknown; + } + return this->At(idx).category; +} + NotificationManager::Notification NotificationManager::Get(NotificationManager::Notification::Id id) const { NotificationManager::Notification::Idx idx = this->IndexOf(id); if (idx == this->size) { diff --git a/src/components/ble/NotificationManager.h b/src/components/ble/NotificationManager.h index 09b5a5610e..d3847759af 100644 --- a/src/components/ble/NotificationManager.h +++ b/src/components/ble/NotificationManager.h @@ -44,6 +44,7 @@ namespace Pinetime { Notification GetPrevious(Notification::Id id) const; // Return the index of the notification with the specified id, if not found return NbNotifications() Notification::Idx IndexOf(Notification::Id id) const; + Categories CategoryAt(Notification::Idx idx) const; bool ClearNewNotificationFlag(); bool AreNewNotificationsAvailable() const; void Dismiss(Notification::Id id); diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index e567780ef1..61577c6211 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -296,7 +296,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_obj_set_style_local_text_color(alert_icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange); } //TODO: get categories for the other notifications - lv_label_set_text_fmt(alert_icon, NotificationIcon::GetCategoryIcon(category)); + lv_label_set_text_fmt(alert_icon, NotificationIcon::GetCategoryIcon(notificationManager.CategoryAt(i))); lv_obj_align(alert_icon, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -22*i); } From 9e3be1d98730582134df305bdaa91a46f5f65a73 Mon Sep 17 00:00:00 2001 From: Brod8362 Date: Fri, 17 Mar 2023 17:22:04 -0500 Subject: [PATCH 5/6] Add notification icons to Symbols --- src/displayapp/fonts/fonts.json | 2 +- src/displayapp/screens/NotificationIcon.cpp | 23 ++++++++++++++++++++- src/displayapp/screens/Symbols.h | 13 ++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/displayapp/fonts/fonts.json b/src/displayapp/fonts/fonts.json index 914ba16314..ee798f68bf 100644 --- a/src/displayapp/fonts/fonts.json +++ b/src/displayapp/fonts/fonts.json @@ -7,7 +7,7 @@ }, { "file": "FontAwesome5-Solid+Brands+Regular.woff", - "range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c" + "range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf059, 0xf0f3, 0xf0e0, 0xf1ea, 0xf7cd, 0xf071, 0xf075" } ], "bpp": 1, diff --git a/src/displayapp/screens/NotificationIcon.cpp b/src/displayapp/screens/NotificationIcon.cpp index 93347e8b4b..dc5087696b 100644 --- a/src/displayapp/screens/NotificationIcon.cpp +++ b/src/displayapp/screens/NotificationIcon.cpp @@ -13,7 +13,28 @@ const char* NotificationIcon::GetIcon(bool newNotificationAvailable) { const char* NotificationIcon::GetCategoryIcon(Pinetime::Controllers::NotificationManager::Categories category) { switch (category) { //TODO add symbols for each category + case Pinetime::Controllers::NotificationManager::Categories::SimpleAlert: + return Symbols::bell; + case Pinetime::Controllers::NotificationManager::Categories::Email: + return Symbols::envelope; + case Pinetime::Controllers::NotificationManager::Categories::News: + return Symbols::newspaper; + case Pinetime::Controllers::NotificationManager::Categories::IncomingCall: + return Symbols::phone; + case Pinetime::Controllers::NotificationManager::Categories::MissedCall: + return Symbols::phoneSlash; + case Pinetime::Controllers::NotificationManager::Categories::Sms: + return Symbols::smsBubble; + case Pinetime::Controllers::NotificationManager::Categories::VoiceMail: + return Symbols::voicemail; + case Pinetime::Controllers::NotificationManager::Categories::Schedule: + return Symbols::clock; + case Pinetime::Controllers::NotificationManager::Categories::HighProriotyAlert: + return Symbols::warningTriangle; + case Pinetime::Controllers::NotificationManager::Categories::InstantMessage: + return Symbols::messageBubble; + case Pinetime::Controllers::NotificationManager::Categories::Unknown: default: - return Symbols::info; + return Symbols::questionCircle; } } \ No newline at end of file diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h index 934cdc3f65..5635a2d511 100644 --- a/src/displayapp/screens/Symbols.h +++ b/src/displayapp/screens/Symbols.h @@ -50,6 +50,19 @@ namespace Pinetime { static constexpr const char* flashlight = "\xEF\x80\x8B"; static constexpr const char* paintbrushLg = "\xEE\x90\x8A"; + + // used for notification stack icons + static constexpr const char* questionCircle = "\xEF\x81\x99"; //F059 + static constexpr const char* bell = "\xEF\x83\xB3"; // F0F3 + static constexpr const char* envelope = "\xEF\x83\xA0"; // F0E0 + static constexpr const char* newspaper = "\xEF\x87\xAA"; // F1EA + static constexpr const char* smsBubble = "\xEE\x9F\x8D"; // F7CD + // TODO codepoint F897 should exist in fontawesome 5, but our version doesn't have it + // need to do something about that + // static constexpr const char* voicemail = "\xEF\xA2\x97"; // F897 + static constexpr const char* voicemail = questionCircle; //TODO revert to above once fontaweosme issue is resolved + static constexpr const char* warningTriangle = "\xEF\x81\xB1"; // F071 + static constexpr const char* messageBubble = "\xEF\x81\xB5"; // F075 } } } From b0f1953e96a9ba852a4b3eada5b88c9f3df3cbb8 Mon Sep 17 00:00:00 2001 From: Brod8362 Date: Fri, 17 Mar 2023 17:42:43 -0500 Subject: [PATCH 6/6] Hide notification stack for incoming calls --- src/displayapp/screens/NotificationIcon.cpp | 5 ++--- src/displayapp/screens/Notifications.cpp | 16 +++++++++------- src/displayapp/screens/Symbols.h | 14 +++++++------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/displayapp/screens/NotificationIcon.cpp b/src/displayapp/screens/NotificationIcon.cpp index dc5087696b..14cf51ac62 100644 --- a/src/displayapp/screens/NotificationIcon.cpp +++ b/src/displayapp/screens/NotificationIcon.cpp @@ -9,10 +9,9 @@ const char* NotificationIcon::GetIcon(bool newNotificationAvailable) { return ""; } -//TODO: does this really belong here? +// TODO: does this really belong here? const char* NotificationIcon::GetCategoryIcon(Pinetime::Controllers::NotificationManager::Categories category) { switch (category) { - //TODO add symbols for each category case Pinetime::Controllers::NotificationManager::Categories::SimpleAlert: return Symbols::bell; case Pinetime::Controllers::NotificationManager::Categories::Email: @@ -36,5 +35,5 @@ const char* NotificationIcon::GetCategoryIcon(Pinetime::Controllers::Notificatio case Pinetime::Controllers::NotificationManager::Categories::Unknown: default: return Symbols::questionCircle; - } + } } \ No newline at end of file diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 61577c6211..a06477af9b 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -290,14 +290,16 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_cont_set_fit(subject_container, LV_FIT_NONE); // draw notification stack - for (int i = 0; i < notifNb; i++) { - lv_obj_t* alert_icon = lv_label_create(container, nullptr); - if (i+1 == notifNr) { //currently selected should be orange - lv_obj_set_style_local_text_color(alert_icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange); + if (category != Pinetime::Controllers::NotificationManager::Categories::IncomingCall) { + for (int i = 0; i < notifNb; i++) { + lv_obj_t* alert_icon = lv_label_create(container, nullptr); + if (i + 1 == notifNr) { // currently selected should be orange + lv_obj_set_style_local_text_color(alert_icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange); + } + // TODO: get categories for the other notifications + lv_label_set_text_fmt(alert_icon, NotificationIcon::GetCategoryIcon(notificationManager.CategoryAt(i))); + lv_obj_align(alert_icon, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -22 * i); } - //TODO: get categories for the other notifications - lv_label_set_text_fmt(alert_icon, NotificationIcon::GetCategoryIcon(notificationManager.CategoryAt(i))); - lv_obj_align(alert_icon, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -22*i); } lv_obj_t* alert_count = lv_label_create(container, nullptr); diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h index 5635a2d511..e208b556ba 100644 --- a/src/displayapp/screens/Symbols.h +++ b/src/displayapp/screens/Symbols.h @@ -52,17 +52,17 @@ namespace Pinetime { static constexpr const char* paintbrushLg = "\xEE\x90\x8A"; // used for notification stack icons - static constexpr const char* questionCircle = "\xEF\x81\x99"; //F059 - static constexpr const char* bell = "\xEF\x83\xB3"; // F0F3 - static constexpr const char* envelope = "\xEF\x83\xA0"; // F0E0 - static constexpr const char* newspaper = "\xEF\x87\xAA"; // F1EA - static constexpr const char* smsBubble = "\xEE\x9F\x8D"; // F7CD + static constexpr const char* questionCircle = "\xEF\x81\x99"; // F059 + static constexpr const char* bell = "\xEF\x83\xB3"; // F0F3 + static constexpr const char* envelope = "\xEF\x83\xA0"; // F0E0 + static constexpr const char* newspaper = "\xEF\x87\xAA"; // F1EA + static constexpr const char* smsBubble = "\xEF\x9F\x8D"; // F7CD // TODO codepoint F897 should exist in fontawesome 5, but our version doesn't have it // need to do something about that // static constexpr const char* voicemail = "\xEF\xA2\x97"; // F897 - static constexpr const char* voicemail = questionCircle; //TODO revert to above once fontaweosme issue is resolved + static constexpr const char* voicemail = questionCircle; // TODO revert to above once fontaweosme issue is resolved static constexpr const char* warningTriangle = "\xEF\x81\xB1"; // F071 - static constexpr const char* messageBubble = "\xEF\x81\xB5"; // F075 + static constexpr const char* messageBubble = "\xEF\x81\xB5"; // F075 } } }