Skip to content

Commit 5da6549

Browse files
committed
only activate the timeout on call notification previews after they have been interacted with
1 parent d13dd6d commit 5da6549

3 files changed

Lines changed: 31 additions & 14 deletions

File tree

src/displayapp/screens/Notifications.cpp

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Notifications::Notifications(DisplayApp* app,
2929
notificationManager.NbNotifications(),
3030
mode,
3131
alertNotificationService,
32-
motorController);
32+
motorController,
33+
&timeoutTickCountEnd);
3334
validDisplay = true;
3435
} else {
3536
currentItem = std::make_unique<NotificationItem>("Notification",
@@ -39,7 +40,8 @@ Notifications::Notifications(DisplayApp* app,
3940
notificationManager.NbNotifications(),
4041
Modes::Preview,
4142
alertNotificationService,
42-
motorController);
43+
motorController,
44+
&timeoutTickCountEnd);
4345
}
4446

4547
if (mode == Modes::Preview) {
@@ -63,7 +65,7 @@ Notifications::~Notifications() {
6365
}
6466

6567
bool Notifications::Refresh() {
66-
if (mode == Modes::Preview) {
68+
if (mode == Modes::Preview && !currentItem->timeoutOnHold) {
6769
auto tick = xTaskGetTickCount();
6870
int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
6971
if (pos < 0)
@@ -105,7 +107,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
105107
notificationManager.NbNotifications(),
106108
mode,
107109
alertNotificationService,
108-
motorController);
110+
motorController,
111+
&timeoutTickCountEnd);
109112
}
110113
return true;
111114
case Pinetime::Applications::TouchEvents::SwipeUp: {
@@ -131,7 +134,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
131134
notificationManager.NbNotifications(),
132135
mode,
133136
alertNotificationService,
134-
motorController);
137+
motorController,
138+
&timeoutTickCountEnd);
135139
}
136140
return true;
137141
case Pinetime::Applications::TouchEvents::LongTap: {
@@ -167,8 +171,10 @@ Notifications::NotificationItem::NotificationItem(const char* title,
167171
uint8_t notifNb,
168172
Modes mode,
169173
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
170-
Controllers::MotorController& motorController)
171-
: notifNr {notifNr}, notifNb {notifNb}, mode {mode}, alertNotificationService {alertNotificationService}, motorController{motorController} {
174+
Controllers::MotorController& motorController,
175+
uint32_t* timeoutEnd)
176+
: notifNr {notifNr}, notifNb {notifNb}, mode {mode}, alertNotificationService {alertNotificationService},
177+
motorController{motorController}, timeoutEnd{timeoutEnd} {
172178

173179
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
174180

@@ -251,7 +257,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
251257
label_mute = lv_label_create(bt_mute, nullptr);
252258
lv_label_set_text(label_mute, Symbols::volumMute);
253259
lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
254-
260+
timeoutOnHold = true;
255261
} break;
256262
}
257263

@@ -266,24 +272,31 @@ Notifications::NotificationItem::NotificationItem(const char* title,
266272
void Notifications::NotificationItem::OnAcceptIncomingCall(lv_event_t event) {
267273
if (event != LV_EVENT_CLICKED)
268274
return;
269-
motorController.stopRunning();
275+
callPreviewInteraction();
270276
alertNotificationService.AcceptIncomingCall();
271277
}
272278

273279
void Notifications::NotificationItem::OnMuteIncomingCall(lv_event_t event) {
274280
if (event != LV_EVENT_CLICKED)
275281
return;
276-
motorController.stopRunning();
282+
callPreviewInteraction();
277283
alertNotificationService.MuteIncomingCall();
278284
}
279285

280286
void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) {
281287
if (event != LV_EVENT_CLICKED)
282288
return;
283-
motorController.stopRunning();
289+
callPreviewInteraction();
284290
alertNotificationService.RejectIncomingCall();
285291
}
286292

293+
inline void Notifications::NotificationItem::callPreviewInteraction() {
294+
*timeoutEnd = xTaskGetTickCount() + (5 * 1024);
295+
timeoutOnHold = false;
296+
motorController.stopRunning();
297+
}
298+
299+
287300
Notifications::NotificationItem::~NotificationItem() {
288301
lv_obj_clean(lv_scr_act());
289302
}

src/displayapp/screens/Notifications.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ namespace Pinetime {
3636
uint8_t notifNb,
3737
Modes mode,
3838
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
39-
Controllers::MotorController& motorController);
39+
Controllers::MotorController& motorController,
40+
uint32_t* timeoutEnd);
4041
~NotificationItem();
4142
bool Refresh() {
4243
return false;
4344
}
4445
void OnAcceptIncomingCall(lv_event_t event);
4546
void OnMuteIncomingCall(lv_event_t event);
4647
void OnRejectIncomingCall(lv_event_t event);
47-
48+
bool timeoutOnHold = false;
4849
private:
50+
void callPreviewInteraction();
51+
4952
uint8_t notifNr = 0;
5053
uint8_t notifNb = 0;
5154
char pageText[4];
@@ -61,6 +64,7 @@ namespace Pinetime {
6164
lv_obj_t* label_mute;
6265
lv_obj_t* label_reject;
6366
lv_obj_t* bottomPlaceholder;
67+
uint32_t* timeoutEnd;
6468
Modes mode;
6569
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
6670
Controllers::MotorController& motorController;

src/systemtask/SystemTask.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void SystemTask::Work() {
226226
if (isSleeping && !isWakingUp)
227227
GoToRunning();
228228
if (notificationManager.GetLastNotification().category == Controllers::NotificationManager::Categories::IncomingCall) {
229-
motorController.startRunning(50);
229+
motorController.startRunning(500);
230230
} else {
231231
motorController.RunForDuration(35);
232232
}

0 commit comments

Comments
 (0)