aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/Notifications.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens/Notifications.cpp')
-rw-r--r--src/displayapp/screens/Notifications.cpp55
1 files changed, 34 insertions, 21 deletions
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 90a010f5..6c68c70d 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -79,9 +79,12 @@ void Notifications::Refresh() {
timeoutLinePoints[1].x = pos;
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
}
- }
- if (dismissingNotification) {
+ } else if (mode == Modes::Preview && dismissingNotification) {
+ running = false;
+ currentItem = std::make_unique<NotificationItem>(alertNotificationService, motorController);
+
+ } else if (dismissingNotification) {
dismissingNotification = false;
auto notification = notificationManager.Get(currentId);
if (!notification.valid) {
@@ -126,12 +129,34 @@ void Notifications::OnPreviewInteraction() {
}
}
+void Notifications::DismissToBlack() {
+ currentItem.reset(nullptr);
+ app->SetFullRefresh(DisplayApp::FullRefreshDirections::RightAnim);
+ // 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;
+}
+
+void Notifications::OnPreviewDismiss() {
+ notificationManager.Dismiss(currentId);
+ if (timeoutLine != nullptr) {
+ lv_obj_del(timeoutLine);
+ timeoutLine = nullptr;
+ }
+ DismissToBlack();
+}
+
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
if (mode != Modes::Normal) {
if (!interacted && event == TouchEvents::Tap) {
interacted = true;
OnPreviewInteraction();
return true;
+ } else if (event == Pinetime::Applications::TouchEvents::SwipeRight) {
+ OnPreviewDismiss();
+ return true;
}
return false;
}
@@ -139,15 +164,9 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
case Pinetime::Applications::TouchEvents::SwipeRight:
if (validDisplay) {
- Controllers::NotificationManager::Notification previousNotification;
auto previousMessage = notificationManager.GetPrevious(currentId);
auto nextMessage = notificationManager.GetNext(currentId);
- if (!previousMessage.valid) {
- // dismissed last message (like 5/5), need to go one message down (like 4/4)
- afterDismissNextMessageFromAbove = false; // show next message coming from below
- } else {
- afterDismissNextMessageFromAbove = true; // show next message coming from above
- }
+ afterDismissNextMessageFromAbove = previousMessage.valid;
notificationManager.Dismiss(currentId);
if (previousMessage.valid) {
currentId = previousMessage.id;
@@ -156,13 +175,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
} else {
// don't update id, won't be found be refresh and try to load latest message or no message box
}
- currentItem.reset(nullptr);
- app->SetFullRefresh(DisplayApp::FullRefreshDirections::RightAnim);
- // 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;
+ DismissToBlack();
return true;
}
return false;
@@ -270,7 +283,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
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, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 16);
+ lv_obj_align(alert_count, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 16);
lv_obj_t* 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);
@@ -288,7 +301,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
}
lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC);
lv_obj_set_width(alert_type, 180);
- lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16);
+ lv_obj_align(alert_type, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 16);
lv_obj_t* alert_subject = lv_label_create(subject_container, nullptr);
lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK);
@@ -312,7 +325,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
bt_accept->user_data = this;
lv_obj_set_event_cb(bt_accept, CallEventHandler);
lv_obj_set_size(bt_accept, 76, 76);
- lv_obj_align(bt_accept, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
+ lv_obj_align(bt_accept, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
label_accept = lv_label_create(bt_accept, nullptr);
lv_label_set_text_static(label_accept, Symbols::phone);
lv_obj_set_style_local_bg_color(bt_accept, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::highlight);
@@ -321,7 +334,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
bt_reject->user_data = this;
lv_obj_set_event_cb(bt_reject, CallEventHandler);
lv_obj_set_size(bt_reject, 76, 76);
- lv_obj_align(bt_reject, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ lv_obj_align(bt_reject, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
label_reject = lv_label_create(bt_reject, nullptr);
lv_label_set_text_static(label_reject, Symbols::phoneSlash);
lv_obj_set_style_local_bg_color(bt_reject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
@@ -330,7 +343,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
bt_mute->user_data = this;
lv_obj_set_event_cb(bt_mute, CallEventHandler);
lv_obj_set_size(bt_mute, 76, 76);
- lv_obj_align(bt_mute, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
+ lv_obj_align(bt_mute, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
label_mute = lv_label_create(bt_mute, nullptr);
lv_label_set_text_static(label_mute, Symbols::volumMute);
lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);