Compare commits

...

5 commits

Author SHA1 Message Date
jspkay 772617a18b
Merge a4be638376 into ad3bf49c7b 2024-09-22 11:37:39 +02:00
jspkay a4be638376 Generalized the concept on NotificationItem rather than Notifictaions 2022-11-15 12:39:01 +01:00
jspkay d084d5c54e Fixed variable name 2022-11-13 20:22:17 +01:00
jspkay 988a91ef51 Notification title in preview stay fixed for one second then starts
scrolling
2022-11-13 20:18:32 +01:00
jspkay 7bc4234d6f Notifications are better displayed 2022-11-12 14:52:39 +01:00
2 changed files with 22 additions and 2 deletions

View file

@ -285,7 +285,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_label_set_text_fmt(alert_count, "%i/%i", notifNr, notifNb);
lv_obj_align(alert_count, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 16);
lv_obj_t* alert_type = lv_label_create(container, nullptr);
alert_type = lv_label_create(container, nullptr);
lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
if (title == nullptr) {
lv_label_set_text_static(alert_type, "Notification");
@ -299,7 +299,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
}
lv_label_refr_text(alert_type);
}
lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC);
lv_label_set_long_mode(alert_type, LV_LABEL_LONG_CROP);
lv_obj_set_width(alert_type, 180);
lv_obj_align(alert_type, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 16);
@ -349,6 +349,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<Notifications::NotificationItem*>(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) {
@ -371,4 +380,9 @@ 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(){
lv_label_set_long_mode(this->alert_type, LV_LABEL_LONG_SROLL_CIRC);
}

View file

@ -53,6 +53,7 @@ namespace Pinetime {
}
void OnCallButtonEvent(lv_obj_t*, lv_event_t event);
static void Refresh(lv_task_t* tsk);
private:
lv_obj_t* container;
@ -63,6 +64,11 @@ namespace Pinetime {
lv_obj_t* label_accept;
lv_obj_t* label_mute;
lv_obj_t* label_reject;
lv_obj_t* alert_type;
void StartTitleScroll();
lv_task_t* refreshTask;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Pinetime::Controllers::MotorController& motorController;