2021-10-13 20:08:35 +00:00
|
|
|
#include "displayapp/screens/Notifications.h"
|
|
|
|
#include "displayapp/DisplayApp.h"
|
2021-01-24 16:22:39 +00:00
|
|
|
#include "components/ble/MusicService.h"
|
2021-02-23 20:18:59 +00:00
|
|
|
#include "components/ble/AlertNotificationService.h"
|
2021-10-13 20:08:35 +00:00
|
|
|
#include "displayapp/screens/Symbols.h"
|
2022-05-19 17:59:09 +00:00
|
|
|
#include <algorithm>
|
2022-08-16 05:21:23 +00:00
|
|
|
#include "displayapp/InfiniTimeTheme.h"
|
2020-10-18 15:35:36 +00:00
|
|
|
|
2020-10-20 18:57:39 +00:00
|
|
|
using namespace Pinetime::Applications::Screens;
|
2021-01-27 12:45:06 +00:00
|
|
|
extern lv_font_t jetbrains_mono_extrabold_compressed;
|
|
|
|
extern lv_font_t jetbrains_mono_bold_20;
|
2020-10-18 15:35:36 +00:00
|
|
|
|
2021-04-18 17:28:14 +00:00
|
|
|
Notifications::Notifications(DisplayApp* app,
|
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager,
|
2021-01-24 16:22:39 +00:00
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
2021-08-01 11:13:32 +00:00
|
|
|
Pinetime::Controllers::MotorController& motorController,
|
2022-01-01 14:22:35 +00:00
|
|
|
System::SystemTask& systemTask,
|
2021-04-18 17:28:14 +00:00
|
|
|
Modes mode)
|
2022-01-01 14:22:35 +00:00
|
|
|
: Screen(app),
|
|
|
|
notificationManager {notificationManager},
|
|
|
|
alertNotificationService {alertNotificationService},
|
2022-01-29 22:34:09 +00:00
|
|
|
motorController {motorController},
|
2022-01-01 14:22:35 +00:00
|
|
|
systemTask {systemTask},
|
|
|
|
mode {mode} {
|
2022-05-19 17:59:09 +00:00
|
|
|
|
2020-10-20 18:57:39 +00:00
|
|
|
notificationManager.ClearNewNotificationFlag();
|
|
|
|
auto notification = notificationManager.GetLastNotification();
|
2021-04-18 17:28:14 +00:00
|
|
|
if (notification.valid) {
|
2020-10-20 18:57:39 +00:00
|
|
|
currentId = notification.id;
|
2021-04-04 10:10:47 +00:00
|
|
|
currentItem = std::make_unique<NotificationItem>(notification.Title(),
|
2021-04-18 17:28:14 +00:00
|
|
|
notification.Message(),
|
2022-05-19 17:59:09 +00:00
|
|
|
1,
|
2021-04-18 17:28:14 +00:00
|
|
|
notification.category,
|
|
|
|
notificationManager.NbNotifications(),
|
2022-01-29 22:34:09 +00:00
|
|
|
alertNotificationService,
|
|
|
|
motorController);
|
2020-10-20 18:57:39 +00:00
|
|
|
validDisplay = true;
|
|
|
|
} else {
|
2022-05-19 17:59:09 +00:00
|
|
|
currentItem = std::make_unique<NotificationItem>(alertNotificationService, motorController);
|
|
|
|
validDisplay = false;
|
2020-10-20 18:57:39 +00:00
|
|
|
}
|
2021-04-18 17:28:14 +00:00
|
|
|
if (mode == Modes::Preview) {
|
2022-01-01 14:22:35 +00:00
|
|
|
systemTask.PushMessage(System::Messages::DisableSleeping);
|
2021-08-01 11:13:32 +00:00
|
|
|
if (notification.category == Controllers::NotificationManager::Categories::IncomingCall) {
|
|
|
|
motorController.StartRinging();
|
|
|
|
} else {
|
|
|
|
motorController.RunForDuration(35);
|
2022-01-01 14:22:35 +00:00
|
|
|
}
|
2020-10-20 18:57:39 +00:00
|
|
|
|
2022-01-01 14:22:35 +00:00
|
|
|
timeoutLine = lv_line_create(lv_scr_act(), nullptr);
|
2020-10-20 18:57:39 +00:00
|
|
|
|
2022-01-01 14:22:35 +00:00
|
|
|
lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
|
|
|
lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
|
|
|
lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
|
|
|
|
|
|
|
|
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
|
|
|
timeoutTickCountStart = xTaskGetTickCount();
|
|
|
|
interacted = false;
|
2020-10-20 18:57:39 +00:00
|
|
|
}
|
2021-07-19 13:26:12 +00:00
|
|
|
|
|
|
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
2020-10-18 15:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Notifications::~Notifications() {
|
2021-07-19 13:26:12 +00:00
|
|
|
lv_task_del(taskRefresh);
|
2021-08-01 10:05:48 +00:00
|
|
|
// make sure we stop any vibrations before exiting
|
2022-01-29 22:34:09 +00:00
|
|
|
motorController.StopRinging();
|
2022-01-01 14:22:35 +00:00
|
|
|
systemTask.PushMessage(System::Messages::EnableSleeping);
|
2020-10-18 15:35:36 +00:00
|
|
|
lv_obj_clean(lv_scr_act());
|
|
|
|
}
|
|
|
|
|
2021-07-19 13:26:12 +00:00
|
|
|
void Notifications::Refresh() {
|
2021-08-01 10:05:48 +00:00
|
|
|
if (mode == Modes::Preview && timeoutLine != nullptr) {
|
2022-01-01 14:22:35 +00:00
|
|
|
TickType_t tick = xTaskGetTickCount();
|
2022-05-19 17:59:09 +00:00
|
|
|
int32_t pos = LV_HOR_RES - ((tick - timeoutTickCountStart) / (timeoutLength / LV_HOR_RES));
|
2022-01-01 14:22:35 +00:00
|
|
|
if (pos <= 0) {
|
2020-10-20 18:57:39 +00:00
|
|
|
running = false;
|
2022-01-01 14:22:35 +00:00
|
|
|
} else {
|
|
|
|
timeoutLinePoints[1].x = pos;
|
|
|
|
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
|
|
|
}
|
|
|
|
}
|
2022-05-19 17:59:09 +00:00
|
|
|
|
|
|
|
if (dismissingNotification) {
|
|
|
|
dismissingNotification = false;
|
|
|
|
auto notification = notificationManager.Get(currentId);
|
|
|
|
if (!notification.valid) {
|
|
|
|
notification = notificationManager.GetLastNotification();
|
|
|
|
}
|
|
|
|
currentId = notification.id;
|
|
|
|
|
|
|
|
if (!notification.valid) {
|
|
|
|
validDisplay = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
currentItem.reset(nullptr);
|
|
|
|
if (afterDismissNextMessageFromAbove) {
|
|
|
|
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
|
|
|
|
} else {
|
|
|
|
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (validDisplay) {
|
|
|
|
Controllers::NotificationManager::Notification::Idx currentIdx = notificationManager.IndexOf(currentId);
|
|
|
|
currentItem = std::make_unique<NotificationItem>(notification.Title(),
|
|
|
|
notification.Message(),
|
|
|
|
currentIdx + 1,
|
|
|
|
notification.category,
|
|
|
|
notificationManager.NbNotifications(),
|
|
|
|
alertNotificationService,
|
|
|
|
motorController);
|
|
|
|
} else {
|
|
|
|
currentItem = std::make_unique<NotificationItem>(alertNotificationService, motorController);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-01 14:22:35 +00:00
|
|
|
running = currentItem->IsRunning() && running;
|
|
|
|
}
|
2020-10-20 18:57:39 +00:00
|
|
|
|
2022-01-01 14:22:35 +00:00
|
|
|
void Notifications::OnPreviewInteraction() {
|
|
|
|
systemTask.PushMessage(System::Messages::EnableSleeping);
|
2022-01-29 22:34:09 +00:00
|
|
|
motorController.StopRinging();
|
2022-01-01 14:22:35 +00:00
|
|
|
if (timeoutLine != nullptr) {
|
|
|
|
lv_obj_del(timeoutLine);
|
|
|
|
timeoutLine = nullptr;
|
2020-10-20 18:57:39 +00:00
|
|
|
}
|
2020-10-18 15:35:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 19:46:41 +00:00
|
|
|
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
2021-08-01 11:13:32 +00:00
|
|
|
if (mode != Modes::Normal) {
|
2022-01-01 14:22:35 +00:00
|
|
|
if (!interacted && event == TouchEvents::Tap) {
|
|
|
|
interacted = true;
|
|
|
|
OnPreviewInteraction();
|
|
|
|
return true;
|
|
|
|
}
|
2021-08-01 11:13:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-04-04 11:42:22 +00:00
|
|
|
|
2020-10-20 18:57:39 +00:00
|
|
|
switch (event) {
|
2022-05-19 17:59:09 +00:00
|
|
|
case Pinetime::Applications::TouchEvents::SwipeRight:
|
|
|
|
if (validDisplay) {
|
|
|
|
Controllers::NotificationManager::Notification previousNotification;
|
|
|
|
auto previousMessage = notificationManager.GetPrevious(currentId);
|
|
|
|
auto nextMessage = notificationManager.GetNext(currentId);
|
|
|
|
if (!previousMessage.valid) {
|
|
|
|
// dismissed last message (like 5/5), need to go one message down (like 4/4)
|
|
|
|
afterDismissNextMessageFromAbove = false; // show next message coming from below
|
|
|
|
} else {
|
|
|
|
afterDismissNextMessageFromAbove = true; // show next message coming from above
|
|
|
|
}
|
|
|
|
notificationManager.Dismiss(currentId);
|
|
|
|
if (previousMessage.valid) {
|
|
|
|
currentId = previousMessage.id;
|
|
|
|
} else if (nextMessage.valid) {
|
|
|
|
currentId = nextMessage.id;
|
|
|
|
} else {
|
|
|
|
// don't update id, won't be found be refresh and try to load latest message or no message box
|
|
|
|
}
|
|
|
|
currentItem.reset(nullptr);
|
|
|
|
app->SetFullRefresh(DisplayApp::FullRefreshDirections::RightAnim);
|
2022-06-27 20:32:03 +00:00
|
|
|
// create black transition screen to let the notification dismiss to blackness
|
|
|
|
lv_obj_t* blackBox = lv_obj_create(lv_scr_act(), nullptr);
|
|
|
|
lv_obj_set_size(blackBox, LV_HOR_RES, LV_VER_RES);
|
|
|
|
lv_obj_set_style_local_bg_color(blackBox, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2022-05-19 17:59:09 +00:00
|
|
|
dismissingNotification = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2021-04-04 02:08:51 +00:00
|
|
|
case Pinetime::Applications::TouchEvents::SwipeDown: {
|
2020-10-20 18:57:39 +00:00
|
|
|
Controllers::NotificationManager::Notification previousNotification;
|
2022-05-19 17:59:09 +00:00
|
|
|
if (validDisplay) {
|
2020-10-20 18:57:39 +00:00
|
|
|
previousNotification = notificationManager.GetPrevious(currentId);
|
2022-05-19 17:59:09 +00:00
|
|
|
} else {
|
2020-10-20 18:57:39 +00:00
|
|
|
previousNotification = notificationManager.GetLastNotification();
|
2022-05-19 17:59:09 +00:00
|
|
|
}
|
2020-10-20 18:57:39 +00:00
|
|
|
|
2022-05-19 17:59:09 +00:00
|
|
|
if (!previousNotification.valid) {
|
2021-04-18 17:28:14 +00:00
|
|
|
return true;
|
2022-05-19 17:59:09 +00:00
|
|
|
}
|
2020-10-20 18:57:39 +00:00
|
|
|
|
|
|
|
currentId = previousNotification.id;
|
2022-05-19 17:59:09 +00:00
|
|
|
Controllers::NotificationManager::Notification::Idx currentIdx = notificationManager.IndexOf(currentId);
|
|
|
|
validDisplay = true;
|
2020-10-20 18:57:39 +00:00
|
|
|
currentItem.reset(nullptr);
|
2021-04-04 02:08:51 +00:00
|
|
|
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
|
2021-04-04 10:10:47 +00:00
|
|
|
currentItem = std::make_unique<NotificationItem>(previousNotification.Title(),
|
2021-04-18 17:28:14 +00:00
|
|
|
previousNotification.Message(),
|
2022-05-19 17:59:09 +00:00
|
|
|
currentIdx + 1,
|
2021-04-18 17:28:14 +00:00
|
|
|
previousNotification.category,
|
|
|
|
notificationManager.NbNotifications(),
|
2022-01-29 22:34:09 +00:00
|
|
|
alertNotificationService,
|
|
|
|
motorController);
|
2020-10-20 18:57:39 +00:00
|
|
|
}
|
|
|
|
return true;
|
2021-04-04 02:08:51 +00:00
|
|
|
case Pinetime::Applications::TouchEvents::SwipeUp: {
|
2020-10-20 18:57:39 +00:00
|
|
|
Controllers::NotificationManager::Notification nextNotification;
|
2022-05-19 17:59:09 +00:00
|
|
|
if (validDisplay) {
|
2020-10-20 18:57:39 +00:00
|
|
|
nextNotification = notificationManager.GetNext(currentId);
|
2022-05-19 17:59:09 +00:00
|
|
|
} else {
|
2020-10-20 18:57:39 +00:00
|
|
|
nextNotification = notificationManager.GetLastNotification();
|
2022-05-19 17:59:09 +00:00
|
|
|
}
|
2020-10-20 18:57:39 +00:00
|
|
|
|
2021-04-04 02:08:51 +00:00
|
|
|
if (!nextNotification.valid) {
|
|
|
|
running = false;
|
|
|
|
return false;
|
|
|
|
}
|
2020-10-20 18:57:39 +00:00
|
|
|
|
|
|
|
currentId = nextNotification.id;
|
2022-05-19 17:59:09 +00:00
|
|
|
Controllers::NotificationManager::Notification::Idx currentIdx = notificationManager.IndexOf(currentId);
|
|
|
|
validDisplay = true;
|
2020-10-20 18:57:39 +00:00
|
|
|
currentItem.reset(nullptr);
|
2021-04-04 02:08:51 +00:00
|
|
|
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
|
2021-04-04 10:10:47 +00:00
|
|
|
currentItem = std::make_unique<NotificationItem>(nextNotification.Title(),
|
2021-04-18 17:28:14 +00:00
|
|
|
nextNotification.Message(),
|
2022-05-19 17:59:09 +00:00
|
|
|
currentIdx + 1,
|
2021-04-18 17:28:14 +00:00
|
|
|
nextNotification.category,
|
|
|
|
notificationManager.NbNotifications(),
|
2022-01-29 22:34:09 +00:00
|
|
|
alertNotificationService,
|
|
|
|
motorController);
|
2020-10-20 18:57:39 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2020-10-18 15:35:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-24 16:22:39 +00:00
|
|
|
namespace {
|
2021-08-01 10:05:48 +00:00
|
|
|
void CallEventHandler(lv_obj_t* obj, lv_event_t event) {
|
2021-04-18 17:28:14 +00:00
|
|
|
auto* item = static_cast<Notifications::NotificationItem*>(obj->user_data);
|
2021-08-01 10:05:48 +00:00
|
|
|
item->OnCallButtonEvent(obj, event);
|
2021-01-24 16:22:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-19 17:59:09 +00:00
|
|
|
Notifications::NotificationItem::NotificationItem(Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
2022-06-27 20:32:03 +00:00
|
|
|
Pinetime::Controllers::MotorController& motorController)
|
2022-05-19 17:59:09 +00:00
|
|
|
: NotificationItem("Notification",
|
|
|
|
"No notification to display",
|
|
|
|
0,
|
|
|
|
Controllers::NotificationManager::Categories::Unknown,
|
|
|
|
0,
|
|
|
|
alertNotificationService,
|
2022-06-27 20:32:03 +00:00
|
|
|
motorController) {
|
2022-05-19 17:59:09 +00:00
|
|
|
}
|
|
|
|
|
2021-04-18 17:28:14 +00:00
|
|
|
Notifications::NotificationItem::NotificationItem(const char* title,
|
|
|
|
const char* msg,
|
|
|
|
uint8_t notifNr,
|
|
|
|
Controllers::NotificationManager::Categories category,
|
|
|
|
uint8_t notifNb,
|
2022-01-29 22:34:09 +00:00
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
2022-06-27 20:32:03 +00:00
|
|
|
Pinetime::Controllers::MotorController& motorController)
|
2022-05-19 17:59:09 +00:00
|
|
|
: alertNotificationService {alertNotificationService}, motorController {motorController} {
|
|
|
|
container = lv_cont_create(lv_scr_act(), nullptr);
|
|
|
|
lv_obj_set_size(container, LV_HOR_RES, LV_VER_RES);
|
|
|
|
lv_obj_set_style_local_bg_color(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
|
|
|
lv_obj_set_style_local_pad_all(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_style_local_pad_inner(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_style_local_border_width(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
|
|
|
|
subject_container = lv_cont_create(container, nullptr);
|
2022-08-16 05:21:23 +00:00
|
|
|
lv_obj_set_style_local_bg_color(subject_container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
|
2022-05-19 17:59:09 +00:00
|
|
|
lv_obj_set_style_local_pad_all(subject_container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
|
|
|
|
lv_obj_set_style_local_pad_inner(subject_container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
|
|
|
|
lv_obj_set_style_local_border_width(subject_container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
|
|
|
|
lv_obj_set_pos(subject_container, 0, 50);
|
|
|
|
lv_obj_set_size(subject_container, LV_HOR_RES, LV_VER_RES - 50);
|
|
|
|
lv_cont_set_layout(subject_container, LV_LAYOUT_COLUMN_LEFT);
|
|
|
|
lv_cont_set_fit(subject_container, LV_FIT_NONE);
|
|
|
|
|
|
|
|
lv_obj_t* alert_count = lv_label_create(container, nullptr);
|
2021-01-28 17:13:28 +00:00
|
|
|
lv_label_set_text_fmt(alert_count, "%i/%i", notifNr, notifNb);
|
|
|
|
lv_obj_align(alert_count, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 16);
|
|
|
|
|
2022-05-19 17:59:09 +00:00
|
|
|
lv_obj_t* alert_type = lv_label_create(container, nullptr);
|
2022-08-16 05:21:23 +00:00
|
|
|
lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
|
2022-05-09 15:16:08 +00:00
|
|
|
if (title == nullptr) {
|
2022-01-29 22:30:03 +00:00
|
|
|
lv_label_set_text_static(alert_type, "Notification");
|
|
|
|
} else {
|
|
|
|
// copy title to label and replace newlines with spaces
|
|
|
|
lv_label_set_text(alert_type, title);
|
2022-05-09 15:16:08 +00:00
|
|
|
char* pchar = strchr(lv_label_get_text(alert_type), '\n');
|
2022-01-29 22:30:03 +00:00
|
|
|
while (pchar != nullptr) {
|
|
|
|
*pchar = ' ';
|
|
|
|
pchar = strchr(pchar + 1, '\n');
|
|
|
|
}
|
|
|
|
lv_label_refr_text(alert_type);
|
2021-05-14 13:11:15 +00:00
|
|
|
}
|
|
|
|
lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC);
|
|
|
|
lv_obj_set_width(alert_type, 180);
|
2021-04-04 10:10:47 +00:00
|
|
|
lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16);
|
2021-02-23 20:18:59 +00:00
|
|
|
|
2022-08-08 15:01:40 +00:00
|
|
|
lv_obj_t* alert_subject = lv_label_create(subject_container, nullptr);
|
|
|
|
lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK);
|
|
|
|
lv_obj_set_width(alert_subject, LV_HOR_RES - 20);
|
|
|
|
|
2021-04-18 17:28:14 +00:00
|
|
|
switch (category) {
|
2022-08-08 15:01:40 +00:00
|
|
|
default:
|
2021-02-23 20:18:59 +00:00
|
|
|
lv_label_set_text(alert_subject, msg);
|
2022-08-08 15:01:40 +00:00
|
|
|
break;
|
2021-01-24 16:22:39 +00:00
|
|
|
case Controllers::NotificationManager::Categories::IncomingCall: {
|
2022-05-19 17:59:09 +00:00
|
|
|
lv_obj_set_height(subject_container, 108);
|
2022-03-20 14:47:25 +00:00
|
|
|
lv_label_set_text_static(alert_subject, "Incoming call from");
|
2021-02-23 20:18:59 +00:00
|
|
|
|
2022-05-19 17:59:09 +00:00
|
|
|
lv_obj_t* alert_caller = lv_label_create(subject_container, nullptr);
|
2021-02-23 20:18:59 +00:00
|
|
|
lv_obj_align(alert_caller, alert_subject, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
|
|
|
lv_label_set_long_mode(alert_caller, LV_LABEL_LONG_BREAK);
|
|
|
|
lv_obj_set_width(alert_caller, LV_HOR_RES - 20);
|
|
|
|
lv_label_set_text(alert_caller, msg);
|
|
|
|
|
2022-05-19 17:59:09 +00:00
|
|
|
bt_accept = lv_btn_create(container, nullptr);
|
2021-01-24 16:22:39 +00:00
|
|
|
bt_accept->user_data = this;
|
2021-08-01 10:05:48 +00:00
|
|
|
lv_obj_set_event_cb(bt_accept, CallEventHandler);
|
2021-06-23 10:08:51 +00:00
|
|
|
lv_obj_set_size(bt_accept, 76, 76);
|
|
|
|
lv_obj_align(bt_accept, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
2021-01-24 16:22:39 +00:00
|
|
|
label_accept = lv_label_create(bt_accept, nullptr);
|
2022-03-20 14:47:25 +00:00
|
|
|
lv_label_set_text_static(label_accept, Symbols::phone);
|
2022-08-16 05:21:23 +00:00
|
|
|
lv_obj_set_style_local_bg_color(bt_accept, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::highlight);
|
2021-01-24 16:22:39 +00:00
|
|
|
|
2022-05-19 17:59:09 +00:00
|
|
|
bt_reject = lv_btn_create(container, nullptr);
|
2021-01-24 16:22:39 +00:00
|
|
|
bt_reject->user_data = this;
|
2021-08-01 10:05:48 +00:00
|
|
|
lv_obj_set_event_cb(bt_reject, CallEventHandler);
|
2021-06-23 10:08:51 +00:00
|
|
|
lv_obj_set_size(bt_reject, 76, 76);
|
|
|
|
lv_obj_align(bt_reject, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
2021-01-24 16:22:39 +00:00
|
|
|
label_reject = lv_label_create(bt_reject, nullptr);
|
2022-03-20 14:47:25 +00:00
|
|
|
lv_label_set_text_static(label_reject, Symbols::phoneSlash);
|
2021-04-04 12:51:22 +00:00
|
|
|
lv_obj_set_style_local_bg_color(bt_reject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
|
2021-02-14 13:19:30 +00:00
|
|
|
|
2022-05-19 17:59:09 +00:00
|
|
|
bt_mute = lv_btn_create(container, nullptr);
|
2021-01-27 12:45:06 +00:00
|
|
|
bt_mute->user_data = this;
|
2021-08-01 10:05:48 +00:00
|
|
|
lv_obj_set_event_cb(bt_mute, CallEventHandler);
|
2021-06-23 10:08:51 +00:00
|
|
|
lv_obj_set_size(bt_mute, 76, 76);
|
|
|
|
lv_obj_align(bt_mute, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
2021-01-27 12:45:06 +00:00
|
|
|
label_mute = lv_label_create(bt_mute, nullptr);
|
2022-03-20 14:47:25 +00:00
|
|
|
lv_label_set_text_static(label_mute, Symbols::volumMute);
|
2022-08-16 05:21:23 +00:00
|
|
|
lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
|
2021-04-18 17:28:14 +00:00
|
|
|
} break;
|
2021-01-24 16:22:39 +00:00
|
|
|
}
|
2020-10-19 19:46:41 +00:00
|
|
|
}
|
2020-10-18 15:35:36 +00:00
|
|
|
|
2021-08-01 10:05:48 +00:00
|
|
|
void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
|
|
|
if (event != LV_EVENT_CLICKED) {
|
2021-04-18 17:28:14 +00:00
|
|
|
return;
|
2021-08-01 10:05:48 +00:00
|
|
|
}
|
2021-01-27 12:45:06 +00:00
|
|
|
|
2022-01-29 22:34:09 +00:00
|
|
|
motorController.StopRinging();
|
2021-01-27 12:45:06 +00:00
|
|
|
|
2021-08-01 10:05:48 +00:00
|
|
|
if (obj == bt_accept) {
|
|
|
|
alertNotificationService.AcceptIncomingCall();
|
|
|
|
} else if (obj == bt_reject) {
|
|
|
|
alertNotificationService.RejectIncomingCall();
|
|
|
|
} else if (obj == bt_mute) {
|
|
|
|
alertNotificationService.MuteIncomingCall();
|
|
|
|
}
|
2021-01-24 16:22:39 +00:00
|
|
|
|
2021-08-01 10:05:48 +00:00
|
|
|
running = false;
|
2021-01-24 16:22:39 +00:00
|
|
|
}
|
2020-10-18 15:35:36 +00:00
|
|
|
|
2020-10-19 19:46:41 +00:00
|
|
|
Notifications::NotificationItem::~NotificationItem() {
|
|
|
|
lv_obj_clean(lv_scr_act());
|
2020-10-18 15:35:36 +00:00
|
|
|
}
|