From a4be63837642afd37c423a32a53849389de8db1f Mon Sep 17 00:00:00 2001 From: jspkay Date: Tue, 15 Nov 2022 12:39:01 +0100 Subject: [PATCH] Generalized the concept on NotificationItem rather than Notifictaions --- src/displayapp/screens/Notifications.cpp | 17 +++++++++++------ src/displayapp/screens/Notifications.h | 11 ++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 2a85fa95..73c6572c 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -79,12 +79,6 @@ void Notifications::Refresh() { timeoutLinePoints[1].x = pos; lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } - - if(!this->isTitleScrolling && tick >= timeoutTickCountStart + timeoutStartTitleScrolling){ - currentItem->StartTitleScroll(); - this->isTitleScrolling = true; - } - } if (dismissingNotification) { @@ -141,6 +135,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } return false; } + switch (event) { case Pinetime::Applications::TouchEvents::SwipeRight: if (validDisplay) { @@ -341,6 +336,15 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray); } break; } + refreshTask = lv_task_create(Notifications::NotificationItem::Refresh, 1000, LV_TASK_PRIO_MID, this); + //lv_task_once(refreshTask); // The documentation says it exists, but I was unable to compile +} + +void Notifications::NotificationItem::Refresh(lv_task_t* tsk) { + static_cast(tsk->user_data)->StartTitleScroll(); + lv_task_del(tsk); // This substitutes the call to lv_task_once + // This method can be updated in the future for implementing other features. + // For now it is executed one single time after 1 second and then deleted. } void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_t event) { @@ -363,6 +367,7 @@ void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_ Notifications::NotificationItem::~NotificationItem() { lv_obj_clean(lv_scr_act()); + lv_task_del(refreshTask); } void Notifications::NotificationItem::StartTitleScroll(){ diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 0bc96b5e..19561db2 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -47,7 +47,7 @@ namespace Pinetime { return running; } void OnCallButtonEvent(lv_obj_t*, lv_event_t event); - void StartTitleScroll(); + static void Refresh(lv_task_t* tsk); private: lv_obj_t* container; @@ -58,8 +58,11 @@ namespace Pinetime { lv_obj_t* label_accept; lv_obj_t* label_mute; lv_obj_t* label_reject; - lv_obj_t *alert_type; - + lv_obj_t* alert_type; + + void StartTitleScroll(); + lv_task_t* refreshTask; + Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::MotorController& motorController; @@ -82,9 +85,7 @@ namespace Pinetime { TickType_t timeoutTickCountStart; static const TickType_t timeoutLength = pdMS_TO_TICKS(7000); - static const TickType_t timeoutStartTitleScrolling = pdMS_TO_TICKS(1000); bool interacted = true; - bool isTitleScrolling = false; bool dismissingNotification = false;