summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/Notifications.cpp
diff options
context:
space:
mode:
authorMax Friedrich <minacode@users.noreply.github.com>2022-04-18 22:40:29 (GMT)
committerGitHub <noreply@github.com>2022-04-18 22:40:29 (GMT)
commitf84a0a38972e6b6d9a537dc9de2e2c416312f882 (patch)
tree3ce9dab83f8b6af8e9df1c8d3aa0219f5a67acbe /src/displayapp/screens/Notifications.cpp
parenta1db9fca136493eef38e536abaa660dd6ce23e57 (diff)
parented91b5a9981898078ad8e4cf105b5d52c7b63dfe (diff)
Merge branch 'develop' into remove-nm-reference
Diffstat (limited to 'src/displayapp/screens/Notifications.cpp')
-rw-r--r--src/displayapp/screens/Notifications.cpp53
1 files changed, 31 insertions, 22 deletions
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 8fe08a8..600f748 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -17,6 +17,7 @@ Notifications::Notifications(DisplayApp* app,
: Screen(app),
notificationManager {notificationManager},
alertNotificationService {alertNotificationService},
+ motorController {motorController},
systemTask {systemTask},
mode {mode} {
notificationManager.ClearNewNotificationFlag();
@@ -29,7 +30,8 @@ Notifications::Notifications(DisplayApp* app,
notification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
validDisplay = true;
} else {
currentItem = std::make_unique<NotificationItem>("Notification",
@@ -38,7 +40,8 @@ Notifications::Notifications(DisplayApp* app,
notification.category,
notificationManager.NbNotifications(),
Modes::Preview,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
if (mode == Modes::Preview) {
@@ -66,7 +69,7 @@ Notifications::Notifications(DisplayApp* app,
Notifications::~Notifications() {
lv_task_del(taskRefresh);
// make sure we stop any vibrations before exiting
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
systemTask.PushMessage(System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
@@ -87,7 +90,7 @@ void Notifications::Refresh() {
void Notifications::OnPreviewInteraction() {
systemTask.PushMessage(System::Messages::EnableSleeping);
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
if (timeoutLine != nullptr) {
lv_obj_del(timeoutLine);
timeoutLine = nullptr;
@@ -125,7 +128,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
previousNotification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
return true;
case Pinetime::Applications::TouchEvents::SwipeUp: {
@@ -150,7 +154,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
nextNotification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
return true;
default:
@@ -171,8 +176,9 @@ Notifications::NotificationItem::NotificationItem(const char* title,
Controllers::NotificationManager::Categories category,
uint8_t notifNb,
Modes mode,
- Pinetime::Controllers::AlertNotificationService& alertNotificationService)
- : mode {mode}, alertNotificationService {alertNotificationService} {
+ Pinetime::Controllers::AlertNotificationService& alertNotificationService,
+ Pinetime::Controllers::MotorController& motorController)
+ : mode {mode}, alertNotificationService {alertNotificationService}, motorController {motorController} {
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));
@@ -192,15 +198,18 @@ Notifications::NotificationItem::NotificationItem(const char* title,
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";
- char* pchar;
- pchar = strchr(title, '\n');
- while (pchar != nullptr) {
- *pchar = ' ';
- pchar = strchr(pchar + 1, '\n');
+ if(title == nullptr) {
+ 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);
+ char *pchar = strchr(lv_label_get_text(alert_type), '\n');
+ while (pchar != nullptr) {
+ *pchar = ' ';
+ pchar = strchr(pchar + 1, '\n');
+ }
+ lv_label_refr_text(alert_type);
}
- lv_label_set_text(alert_type, title);
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);
@@ -220,7 +229,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK);
lv_obj_set_width(alert_subject, LV_HOR_RES - 20);
- lv_label_set_text(alert_subject, "Incoming call from");
+ lv_label_set_text_static(alert_subject, "Incoming call from");
lv_obj_t* alert_caller = lv_label_create(container1, nullptr);
lv_obj_align(alert_caller, alert_subject, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
@@ -234,7 +243,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_set_size(bt_accept, 76, 76);
lv_obj_align(bt_accept, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
label_accept = lv_label_create(bt_accept, nullptr);
- lv_label_set_text(label_accept, Symbols::phone);
+ lv_label_set_text_static(label_accept, Symbols::phone);
lv_obj_set_style_local_bg_color(bt_accept, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
bt_reject = lv_btn_create(lv_scr_act(), nullptr);
@@ -243,7 +252,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_set_size(bt_reject, 76, 76);
lv_obj_align(bt_reject, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
label_reject = lv_label_create(bt_reject, nullptr);
- lv_label_set_text(label_reject, Symbols::phoneSlash);
+ lv_label_set_text_static(label_reject, Symbols::phoneSlash);
lv_obj_set_style_local_bg_color(bt_reject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
bt_mute = lv_btn_create(lv_scr_act(), nullptr);
@@ -252,7 +261,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_set_size(bt_mute, 76, 76);
lv_obj_align(bt_mute, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
label_mute = lv_label_create(bt_mute, nullptr);
- lv_label_set_text(label_mute, Symbols::volumMute);
+ lv_label_set_text_static(label_mute, Symbols::volumMute);
lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
} break;
}
@@ -261,7 +270,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
}
void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_t event) {
@@ -269,7 +278,7 @@ void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_
return;
}
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
if (obj == bt_accept) {
alertNotificationService.AcceptIncomingCall();