From 03de1c67393fcb99b5987514be6f470349c57c0f Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 4 Apr 2021 12:10:47 +0200 Subject: Add support for notification title. The notification buffer must contain the title and the message separated by a '\0' character. If the buffer does not contain any \0, the whole buffer is considered to be the message of the notification. A default title will be displayed in the notification app. --- src/displayapp/screens/Notifications.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/displayapp/screens/Notifications.cpp') diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index c903ed0f..457d1e06 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("\nNotification", - notification.message.data(), + currentItem = std::make_unique(notification.Title(), + notification.Message(), notification.index, notification.category, notificationManager.NbNotifications(), @@ -87,8 +87,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { currentId = previousNotification.id; currentItem.reset(nullptr); app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up); - currentItem = std::make_unique("\nNotification", - previousNotification.message.data(), + currentItem = std::make_unique(previousNotification.Title(), + previousNotification.Message(), previousNotification.index, previousNotification.category, notificationManager.NbNotifications(), @@ -109,8 +109,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { currentId = nextNotification.id; currentItem.reset(nullptr); app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down); - currentItem = std::make_unique("\nNotification", - nextNotification.message.data(), + currentItem = std::make_unique(nextNotification.Title(), + nextNotification.Message(), nextNotification.index, nextNotification.category, notificationManager.NbNotifications(), @@ -178,8 +178,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) { -- cgit v1.2.3-70-g09d2 From 1b71a10bebb63a1b93583d20d657d7accb6b3ddf Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 4 Apr 2021 13:42:22 +0200 Subject: Notification app : disable swipe when the app is in 'preview' mode. In this mode, only the new notification should be displayed, there is no point to allow navigating to past notifications. Works as a workaround for the crash that occurs when you swipe the notification app in preview mode (https://github.com/JF002/InfiniTime/issues/250). --- src/displayapp/screens/Notifications.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/displayapp/screens/Notifications.cpp') diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 457d1e06..5600c0ec 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -73,6 +73,8 @@ bool Notifications::Refresh() { } bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { + if(mode != Modes::Normal) return true; + switch (event) { case Pinetime::Applications::TouchEvents::SwipeUp: { Controllers::NotificationManager::Notification previousNotification; -- cgit v1.2.3-70-g09d2