From 7bc4234d6ffcd147e55d7ffaa371d729308fe4c0 Mon Sep 17 00:00:00 2001 From: jspkay Date: Sat, 12 Nov 2022 14:52:39 +0100 Subject: [PATCH 1/4] Notifications are better displayed --- src/displayapp/DisplayApp.cpp | 11 +++++++++++ src/displayapp/screens/Notifications.cpp | 17 ++++++++++++++--- src/displayapp/screens/Notifications.h | 4 ++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 108e380d69..2c4bf9e9fb 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -165,11 +165,18 @@ void DisplayApp::Refresh() { brightnessController.Lower(); vTaskDelay(100); } + PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping); state = States::Idle; break; case Messages::GoToRunning: ApplyBrightness(); + + // reload main display app if we are notifications or quicksettings or app menu + if(currentApp == Apps::Launcher || currentApp == Apps::Notifications || currentApp == Apps::QuickSettings){ + LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::Up); + } + state = States::Running; break; case Messages::UpdateTimeOut: @@ -302,6 +309,7 @@ void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction } void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) { + NRF_LOG_INFO("Loading app...") touchHandler.CancelTap(); ApplyBrightness(); @@ -319,6 +327,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) break; case Apps::None: case Apps::Clock: + NRF_LOG_INFO("Loading clock") currentScreen = std::make_unique(this, dateTimeController, batteryController, @@ -328,6 +337,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) heartRateController, motionController, filesystem); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::Error: @@ -480,6 +490,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique(this, motionController, settingsController); break; } + NRF_LOG_INFO("DONE") currentApp = app; } diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 90a010f5fc..3e8523236f 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -79,6 +79,12 @@ void Notifications::Refresh() { timeoutLinePoints[1].x = pos; lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } + + if(!this->scrolling && tick >= timeoutTickCountStart + timeoutStartScrolling){ + this->scrolling = true; + lv_label_set_long_mode(currentItem->alert_type, LV_LABEL_LONG_SROLL_CIRC); + } + } if (dismissingNotification) { @@ -127,13 +133,18 @@ void Notifications::OnPreviewInteraction() { } bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - if (mode != Modes::Normal) { + /*if (mode != Modes::Normal) { if (!interacted && event == TouchEvents::Tap) { interacted = true; OnPreviewInteraction(); return true; } return false; + }*/ + + if(mode == Modes::Preview){ + interacted=true; + OnPreviewInteraction(); } switch (event) { @@ -272,7 +283,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, 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_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"); @@ -286,7 +297,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, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16); diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 9d843a9b13..656579f33b 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -47,6 +47,7 @@ namespace Pinetime { return running; } void OnCallButtonEvent(lv_obj_t*, lv_event_t event); + lv_obj_t *alert_type; private: lv_obj_t* container; @@ -57,6 +58,7 @@ namespace Pinetime { lv_obj_t* label_accept; lv_obj_t* label_mute; lv_obj_t* label_reject; + Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::MotorController& motorController; @@ -79,7 +81,9 @@ namespace Pinetime { TickType_t timeoutTickCountStart; static const TickType_t timeoutLength = pdMS_TO_TICKS(7000); + static const TickType_t timeoutStartScrolling = pdMS_TO_TICKS(1000); bool interacted = true; + bool scrolling = false; bool dismissingNotification = false; From 9a0f60b69dde97c115b44832a4964ad36c9ac726 Mon Sep 17 00:00:00 2001 From: jspkay Date: Sun, 13 Nov 2022 19:37:03 +0100 Subject: [PATCH 2/4] Automatically returns to clock when necessary --- src/displayapp/screens/Notifications.cpp | 7 +------ src/displayapp/screens/Notifications.h | 3 --- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 3e8523236f..2808672b98 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -133,18 +133,13 @@ void Notifications::OnPreviewInteraction() { } bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - /*if (mode != Modes::Normal) { + if (mode != Modes::Normal) { if (!interacted && event == TouchEvents::Tap) { interacted = true; OnPreviewInteraction(); return true; } return false; - }*/ - - if(mode == Modes::Preview){ - interacted=true; - OnPreviewInteraction(); } switch (event) { diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 656579f33b..8fccda75e1 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -47,7 +47,6 @@ namespace Pinetime { return running; } void OnCallButtonEvent(lv_obj_t*, lv_event_t event); - lv_obj_t *alert_type; private: lv_obj_t* container; @@ -81,9 +80,7 @@ namespace Pinetime { TickType_t timeoutTickCountStart; static const TickType_t timeoutLength = pdMS_TO_TICKS(7000); - static const TickType_t timeoutStartScrolling = pdMS_TO_TICKS(1000); bool interacted = true; - bool scrolling = false; bool dismissingNotification = false; From 6076ed00dcd2fcfa8427706f86740efebdcd9b05 Mon Sep 17 00:00:00 2001 From: jspkay Date: Sun, 13 Nov 2022 19:40:51 +0100 Subject: [PATCH 3/4] Cleaned unrelated files --- src/displayapp/DisplayApp.cpp | 7 +------ src/displayapp/screens/Notifications.cpp | 10 ++-------- src/displayapp/screens/Notifications.h | 1 - 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 2c4bf9e9fb..5cd123aa0b 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -165,18 +165,15 @@ void DisplayApp::Refresh() { brightnessController.Lower(); vTaskDelay(100); } - PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping); state = States::Idle; break; case Messages::GoToRunning: ApplyBrightness(); - // reload main display app if we are notifications or quicksettings or app menu if(currentApp == Apps::Launcher || currentApp == Apps::Notifications || currentApp == Apps::QuickSettings){ LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::Up); } - state = States::Running; break; case Messages::UpdateTimeOut: @@ -309,7 +306,6 @@ void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction } void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) { - NRF_LOG_INFO("Loading app...") touchHandler.CancelTap(); ApplyBrightness(); @@ -327,7 +323,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) break; case Apps::None: case Apps::Clock: - NRF_LOG_INFO("Loading clock") currentScreen = std::make_unique(this, dateTimeController, batteryController, @@ -337,7 +332,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) heartRateController, motionController, filesystem); - ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); // We don't want to load a different app when in the clock break; case Apps::Error: diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 2808672b98..90a010f5fc 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->scrolling && tick >= timeoutTickCountStart + timeoutStartScrolling){ - this->scrolling = true; - lv_label_set_long_mode(currentItem->alert_type, LV_LABEL_LONG_SROLL_CIRC); - } - } if (dismissingNotification) { @@ -278,7 +272,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_label_set_text_fmt(alert_count, "%i/%i", notifNr, notifNb); lv_obj_align(alert_count, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 16); - alert_type = lv_label_create(container, nullptr); + 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); if (title == nullptr) { lv_label_set_text_static(alert_type, "Notification"); @@ -292,7 +286,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, } lv_label_refr_text(alert_type); } - lv_label_set_long_mode(alert_type, LV_LABEL_LONG_CROP); + 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); diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 8fccda75e1..9d843a9b13 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -57,7 +57,6 @@ namespace Pinetime { lv_obj_t* label_accept; lv_obj_t* label_mute; lv_obj_t* label_reject; - Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::MotorController& motorController; From 9766a47279bf33f3de4f9a2e193680eb7cfff22a Mon Sep 17 00:00:00 2001 From: jspkay Date: Sun, 13 Nov 2022 19:41:38 +0100 Subject: [PATCH 4/4] Deleted unnecessary log --- src/displayapp/DisplayApp.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 5cd123aa0b..bcc5435ebb 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -485,7 +485,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique(this, motionController, settingsController); break; } - NRF_LOG_INFO("DONE") currentApp = app; }