NotificationItem now also redefines the start of the timeout

This commit is contained in:
Florian Kraupa 2021-05-13 01:51:43 +02:00
parent 56af4a0b83
commit 9e8dd9a1e6
2 changed files with 16 additions and 8 deletions

View File

@ -30,7 +30,8 @@ Notifications::Notifications(DisplayApp* app,
mode, mode,
alertNotificationService, alertNotificationService,
motorController, motorController,
&timeoutTickCountEnd); &timeoutTickCountEnd,
&timeoutTickCountStart);
validDisplay = true; validDisplay = true;
} else { } else {
currentItem = std::make_unique<NotificationItem>("Notification", currentItem = std::make_unique<NotificationItem>("Notification",
@ -41,7 +42,8 @@ Notifications::Notifications(DisplayApp* app,
Modes::Preview, Modes::Preview,
alertNotificationService, alertNotificationService,
motorController, motorController,
&timeoutTickCountEnd); &timeoutTickCountEnd,
&timeoutTickCountStart);
} }
if (mode == Modes::Preview) { if (mode == Modes::Preview) {
@ -105,7 +107,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
mode, mode,
alertNotificationService, alertNotificationService,
motorController, motorController,
&timeoutTickCountEnd); &timeoutTickCountEnd,
&timeoutTickCountStart);
} }
return true; return true;
case Pinetime::Applications::TouchEvents::SwipeUp: { case Pinetime::Applications::TouchEvents::SwipeUp: {
@ -132,7 +135,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
mode, mode,
alertNotificationService, alertNotificationService,
motorController, motorController,
&timeoutTickCountEnd); &timeoutTickCountEnd,
&timeoutTickCountStart);
} }
return true; return true;
case Pinetime::Applications::TouchEvents::LongTap: { case Pinetime::Applications::TouchEvents::LongTap: {
@ -169,9 +173,10 @@ Notifications::NotificationItem::NotificationItem(const char* title,
Modes mode, Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService, Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Controllers::MotorController& motorController, Controllers::MotorController& motorController,
uint32_t* timeoutEnd) uint32_t* timeoutEnd,
uint32_t* timeoutStart)
: notifNr{notifNr}, notifNb{notifNb}, mode{mode}, alertNotificationService{alertNotificationService}, : notifNr{notifNr}, notifNb{notifNb}, mode{mode}, alertNotificationService{alertNotificationService},
motorController{motorController}, timeoutEnd{timeoutEnd} { motorController{motorController}, timeoutEnd{timeoutEnd}, timeoutStart{timeoutStart} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL); lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222)); lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
@ -286,7 +291,8 @@ void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) {
} }
inline void Notifications::NotificationItem::callPreviewInteraction() { inline void Notifications::NotificationItem::callPreviewInteraction() {
*timeoutEnd = xTaskGetTickCount() + (5 * 1024); *timeoutStart = xTaskGetTickCount();
*timeoutEnd = *timeoutStart + (5 * 1024);
timeoutOnHold = false; timeoutOnHold = false;
motorController.stopRunning(); motorController.stopRunning();
} }

View File

@ -37,7 +37,8 @@ namespace Pinetime {
Modes mode, Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService, Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Controllers::MotorController& motorController, Controllers::MotorController& motorController,
uint32_t* timeoutEnd); uint32_t* timeoutEnd,
uint32_t* timeoutStart);
~NotificationItem(); ~NotificationItem();
bool Refresh() { bool Refresh() {
return false; return false;
@ -66,6 +67,7 @@ namespace Pinetime {
lv_obj_t* label_reject; lv_obj_t* label_reject;
lv_obj_t* bottomPlaceholder; lv_obj_t* bottomPlaceholder;
uint32_t* timeoutEnd; uint32_t* timeoutEnd;
uint32_t* timeoutStart;
Modes mode; Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService; Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Controllers::MotorController& motorController; Controllers::MotorController& motorController;