From 2c75e7aad8aa8d7b50dd3ea795bdc2938992aa69 Mon Sep 17 00:00:00 2001 From: Simon Willshire Date: Thu, 19 May 2022 13:59:09 -0400 Subject: Dismiss notifications by swiping right Add a new interface `NotificationManager::Dismiss(id)` to delete a notification with the specified `id`. The animate the notification dismiss the `RightAnim` transition to a black screen is used. After the dismiss the new message is swiped in from below or above. If we dismiss the oldest message (when we are at 5/5, or 3/3), then the new message after a dismiss should appear to come from below. Otherwise (when we are at 2/3) the new message after a dismiss should appear to come from above. Rework the index code to show the index of the currently viewed notification. Instead of calculating the index relative to the oldest `id` introduce a new interface `NotificationManager::IndexOf(id)`. This is done because the `id` of the notifications in the buffer aren't continuous anymore (as some messages could have been dismissed). Rework notification ring buffer to have a beginIdx and a size internally to make the dismissal of notifications easier. Fixes: https://github.com/InfiniTimeOrg/InfiniTime/issues/176 Co-authored-by: Simon Willshire Co-authored-by: Reinhold Gschweicher --- src/displayapp/screens/Notifications.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/displayapp/screens/Notifications.h') diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 74160356..d3088f80 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -33,14 +33,17 @@ namespace Pinetime { class NotificationItem { public: + NotificationItem(Pinetime::Controllers::AlertNotificationService& alertNotificationService, + Pinetime::Controllers::MotorController& motorController, + bool isTransition = false); NotificationItem(const char* title, const char* msg, uint8_t notifNr, Controllers::NotificationManager::Categories, uint8_t notifNb, - Modes mode, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::MotorController& motorController); + Pinetime::Controllers::MotorController& motorController, + bool isTransition = false); ~NotificationItem(); bool IsRunning() const { return running; @@ -48,16 +51,17 @@ namespace Pinetime { void OnCallButtonEvent(lv_obj_t*, lv_event_t event); private: - lv_obj_t* container1; + lv_obj_t* container; + lv_obj_t* subject_container; lv_obj_t* bt_accept; lv_obj_t* bt_mute; lv_obj_t* bt_reject; lv_obj_t* label_accept; lv_obj_t* label_mute; lv_obj_t* label_reject; - Modes mode; Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::MotorController& motorController; + bool running = true; }; @@ -68,15 +72,19 @@ namespace Pinetime { System::SystemTask& systemTask; Modes mode = Modes::Normal; std::unique_ptr currentItem; - Controllers::NotificationManager::Notification::Id currentId; + Pinetime::Controllers::NotificationManager::Notification::Id currentId; bool validDisplay = false; + bool afterDismissNextMessageFromAbove = false; lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}}; lv_obj_t* timeoutLine = nullptr; TickType_t timeoutTickCountStart; + static const TickType_t timeoutLength = pdMS_TO_TICKS(7000); bool interacted = true; + bool dismissingNotification = false; + lv_task_t* taskRefresh; }; } -- cgit v1.2.3-70-g09d2 From 12fad7411de43a6bc52fd7129a3edbd508fab6cc Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Mon, 27 Jun 2022 22:32:03 +0200 Subject: Notifications: no inTransition screen, simple blackbox is enough --- src/displayapp/screens/Notifications.cpp | 18 +++++++----------- src/displayapp/screens/Notifications.h | 6 ++---- 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'src/displayapp/screens/Notifications.h') diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 9c0d28a8..1479cf5d 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -157,8 +157,10 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } currentItem.reset(nullptr); app->SetFullRefresh(DisplayApp::FullRefreshDirections::RightAnim); - // create black "inTransition" screen - currentItem = std::make_unique(alertNotificationService, motorController, true); + // create black transition screen to let the notification dismiss to blackness + lv_obj_t* blackBox = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(blackBox, LV_HOR_RES, LV_VER_RES); + lv_obj_set_style_local_bg_color(blackBox, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); dismissingNotification = true; return true; } @@ -229,16 +231,14 @@ namespace { } Notifications::NotificationItem::NotificationItem(Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::MotorController& motorController, - bool isTransition) + Pinetime::Controllers::MotorController& motorController) : NotificationItem("Notification", "No notification to display", 0, Controllers::NotificationManager::Categories::Unknown, 0, alertNotificationService, - motorController, - isTransition) { + motorController) { } Notifications::NotificationItem::NotificationItem(const char* title, @@ -247,12 +247,8 @@ Notifications::NotificationItem::NotificationItem(const char* title, Controllers::NotificationManager::Categories category, uint8_t notifNb, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::MotorController& motorController, - bool isTransition) + Pinetime::Controllers::MotorController& motorController) : alertNotificationService {alertNotificationService}, motorController {motorController} { - if (isTransition) { - return; // nothing to do, just a black box - } 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 d3088f80..9d843a9b 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -34,16 +34,14 @@ namespace Pinetime { class NotificationItem { public: NotificationItem(Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::MotorController& motorController, - bool isTransition = false); + Pinetime::Controllers::MotorController& motorController); NotificationItem(const char* title, const char* msg, uint8_t notifNr, Controllers::NotificationManager::Categories, uint8_t notifNb, Pinetime::Controllers::AlertNotificationService& alertNotificationService, - Pinetime::Controllers::MotorController& motorController, - bool isTransition = false); + Pinetime::Controllers::MotorController& motorController); ~NotificationItem(); bool IsRunning() const { return running; -- cgit v1.2.3-70-g09d2