diff options
Diffstat (limited to 'src/displayapp/screens/Notifications.cpp')
| -rw-r--r-- | src/displayapp/screens/Notifications.cpp | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index c903ed0..33cebe8 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -17,8 +17,8 @@ Notifications::Notifications(DisplayApp *app, auto notification = notificationManager.GetLastNotification(); if(notification.valid) { currentId = notification.id; - currentItem = std::make_unique<NotificationItem>("\nNotification", - notification.message.data(), + currentItem = std::make_unique<NotificationItem>(notification.Title(), + notification.Message(), notification.index, notification.category, notificationManager.NbNotifications(), @@ -26,13 +26,13 @@ Notifications::Notifications(DisplayApp *app, alertNotificationService); validDisplay = true; } else { - currentItem = std::make_unique<NotificationItem>("\nNotification", - "No notification to display", - 0, - notification.category, - notificationManager.NbNotifications(), - Modes::Preview, - alertNotificationService); + currentItem = std::make_unique<NotificationItem>("Notification", + "No notification to display", + 0, + notification.category, + notificationManager.NbNotifications(), + Modes::Preview, + alertNotificationService); } if(mode == Modes::Preview) { @@ -62,19 +62,16 @@ bool Notifications::Refresh() { timeoutLinePoints[1].x = pos; lv_line_set_points(timeoutLine, timeoutLinePoints, 2); - - if (!running) { - // Start clock app when exiting this one - app->StartApp(Apps::Clock); - } } return running; } bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { + if(mode != Modes::Normal) return true; + switch (event) { - case Pinetime::Applications::TouchEvents::SwipeUp: { + case Pinetime::Applications::TouchEvents::SwipeDown: { Controllers::NotificationManager::Notification previousNotification; if(validDisplay) previousNotification = notificationManager.GetPrevious(currentId); @@ -86,9 +83,9 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { validDisplay = true; currentId = previousNotification.id; currentItem.reset(nullptr); - app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up); - currentItem = std::make_unique<NotificationItem>("\nNotification", - previousNotification.message.data(), + app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down); + currentItem = std::make_unique<NotificationItem>(previousNotification.Title(), + previousNotification.Message(), previousNotification.index, previousNotification.category, notificationManager.NbNotifications(), @@ -96,21 +93,24 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { alertNotificationService); } return true; - case Pinetime::Applications::TouchEvents::SwipeDown: { + case Pinetime::Applications::TouchEvents::SwipeUp: { Controllers::NotificationManager::Notification nextNotification; if(validDisplay) nextNotification = notificationManager.GetNext(currentId); else nextNotification = notificationManager.GetLastNotification(); - if (!nextNotification.valid) return true; + if (!nextNotification.valid) { + running = false; + return false; + } validDisplay = true; currentId = nextNotification.id; currentItem.reset(nullptr); - app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down); - currentItem = std::make_unique<NotificationItem>("\nNotification", - nextNotification.message.data(), + app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up); + currentItem = std::make_unique<NotificationItem>(nextNotification.Title(), + nextNotification.Message(), nextNotification.index, nextNotification.category, notificationManager.NbNotifications(), @@ -119,7 +119,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } return true; case Pinetime::Applications::TouchEvents::LongTap: { - notificationManager.ToggleVibrations(); + //notificationManager.ToggleVibrations(); return true; } default: @@ -127,12 +127,6 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } } - -bool Notifications::OnButtonPushed() { - running = false; - return true; -} - namespace { static void AcceptIncomingCallEventHandler(lv_obj_t* obj, lv_event_t event) { auto* item = static_cast<Notifications::NotificationItem*>(obj->user_data); @@ -178,8 +172,9 @@ namespace { lv_obj_t* alert_type = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x888888)); + if(title == nullptr) title = "Notification"; lv_label_set_text(alert_type, title); - lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, -4); + lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16); ///////// switch(category) { @@ -222,6 +217,7 @@ namespace { lv_obj_set_size(bt_accept, (LV_HOR_RES / 3) - 5, 80); label_accept = lv_label_create(bt_accept, nullptr); lv_label_set_text(label_accept, Symbols::phone); + lv_obj_set_style_local_bg_color(bt_accept, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); bt_reject = lv_btn_create(callBtnContainer, nullptr); bt_reject->user_data = this; @@ -229,6 +225,7 @@ namespace { lv_obj_set_size(bt_reject, (LV_HOR_RES / 3) - 5, 80); label_reject = lv_label_create(bt_reject, nullptr); lv_label_set_text(label_reject, Symbols::phoneSlash); + lv_obj_set_style_local_bg_color(bt_reject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); bt_mute = lv_btn_create(callBtnContainer, nullptr); bt_mute->user_data = this; @@ -236,6 +233,7 @@ namespace { lv_obj_set_size(bt_mute, (LV_HOR_RES / 3) - 5, 80); label_mute = lv_label_create(bt_mute, nullptr); lv_label_set_text(label_mute, Symbols::volumMute); + lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); } break; } |
