From 219bafb01ac11a2dc0591d37f00e1acc6d478b54 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 24 Jan 2021 17:22:39 +0100 Subject: Handle call notification the same way than other notifications. Display the call notifications in the Notification app, with buttons to accept/reject the call. --- src/displayapp/screens/Notifications.h | 46 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'src/displayapp/screens/Notifications.h') diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index f5c6a860..4305c796 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -19,26 +19,36 @@ namespace Pinetime { bool OnButtonPushed() override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; + class NotificationItem { + public: + NotificationItem(const char* title, const char* msg, uint8_t notifNr, Controllers::NotificationManager::Categories, uint8_t notifNb, Modes mode, Pinetime::Controllers::AlertNotificationService& alertNotificationService); + ~NotificationItem(); + bool Refresh() {return false;} + void OnAcceptIncomingCall(lv_event_t event); + void OnRejectIncomingCall(lv_event_t event); + private: - bool running = true; + uint8_t notifNr = 0; + uint8_t notifNb = 0; + char pageText[4]; - class NotificationItem { - public: - NotificationItem(const char* title, const char* msg, uint8_t notifNr, uint8_t notifNb, Modes mode); - ~NotificationItem(); - bool Refresh() {return false;} - - private: - uint8_t notifNr = 0; - uint8_t notifNb = 0; - char pageText[4]; - - lv_obj_t* container1; - lv_obj_t* t1; - lv_obj_t* l1; - lv_obj_t* bottomPlaceholder; - Modes mode; - }; + lv_obj_t* container1; + lv_obj_t* t1; + lv_obj_t* l1; + lv_obj_t* l2; + lv_obj_t* bt_accept; + lv_obj_t* bt_reject; + lv_obj_t* label_accept; + lv_obj_t* label_reject; + lv_obj_t* bottomPlaceholder; + Modes mode; + Pinetime::Controllers::AlertNotificationService& alertNotificationService; + + + }; + + private: + bool running = true; struct NotificationData { const char* title; -- cgit v1.2.3-70-g09d2 From 3d1881c5ab39fb5caf1cbb217fd227d0897b4ed1 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 24 Jan 2021 17:27:48 +0100 Subject: Revert invalid changes in Navigation.h and add missing changes in Notifications.h. --- src/displayapp/screens/Navigation.h | 4 ++-- src/displayapp/screens/Notifications.h | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/displayapp/screens/Notifications.h') diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h index ab622496..9fdd37d9 100644 --- a/src/displayapp/screens/Navigation.h +++ b/src/displayapp/screens/Navigation.h @@ -145,7 +145,7 @@ namespace Pinetime { const lv_img_dsc_t* iconForName(std::string icon); - std::array, 89 > m_iconMap;/* = { { + std::array, 89 > m_iconMap = { { {"arrive-left", &arrive_left}, {"arrive-right", &arrive_right}, {"arrive-straight", &arrive_straight}, @@ -231,7 +231,7 @@ namespace Pinetime { {"turn-slight-right", &turn_slight_right}, {"turn-straight", &turn_straight}, {"updown", &updown}, - {"uturn", &uturn} } };*/ + {"uturn", &uturn} } }; }; } } diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 4305c796..aafd3e33 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -7,12 +7,16 @@ #include "components/ble/NotificationManager.h" namespace Pinetime { + namespace Controllers { + class AlertNotificationService; + } namespace Applications { namespace Screens { + class Notifications : public Screen { public: enum class Modes {Normal, Preview}; - explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Modes mode); + explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::AlertNotificationService& alertNotificationService, Modes mode); ~Notifications() override; bool Refresh() override; @@ -55,6 +59,7 @@ namespace Pinetime { const char* text; }; Pinetime::Controllers::NotificationManager& notificationManager; + Pinetime::Controllers::AlertNotificationService& alertNotificationService; Modes mode = Modes::Normal; std::unique_ptr currentItem; Controllers::NotificationManager::Notification::Id currentId; -- cgit v1.2.3-70-g09d2 From d4c31bcbbe2f8b6d2e6c45203193745f9cb2a41b Mon Sep 17 00:00:00 2001 From: petter <39340152+petterhs@users.noreply.github.com> Date: Wed, 27 Jan 2021 13:45:06 +0100 Subject: add mute button and functionality for call notification + new button icons --- src/components/ble/AlertNotificationService.cpp | 13 ++++++++++ src/components/ble/AlertNotificationService.h | 4 ++- src/displayapp/screens/Notifications.cpp | 33 +++++++++++++++++++++---- src/displayapp/screens/Notifications.h | 3 +++ 4 files changed, 47 insertions(+), 6 deletions(-) (limited to 'src/displayapp/screens/Notifications.h') diff --git a/src/components/ble/AlertNotificationService.cpp b/src/components/ble/AlertNotificationService.cpp index 5fb8338b..0639119c 100644 --- a/src/components/ble/AlertNotificationService.cpp +++ b/src/components/ble/AlertNotificationService.cpp @@ -118,3 +118,16 @@ void AlertNotificationService::RejectIncomingCall() { ble_gattc_notify_custom(connectionHandle, eventHandle, om); } + +void AlertNotificationService::MuteIncomingCall() { + auto response = IncomingCallResponses::Mute; + auto *om = ble_hs_mbuf_from_flat(&response, 1); + + uint16_t connectionHandle = systemTask.nimble().connHandle(); + + if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) { + return; + } + + ble_gattc_notify_custom(connectionHandle, eventHandle, om); +} \ No newline at end of file diff --git a/src/components/ble/AlertNotificationService.h b/src/components/ble/AlertNotificationService.h index 612a8a32..caad7a2b 100644 --- a/src/components/ble/AlertNotificationService.h +++ b/src/components/ble/AlertNotificationService.h @@ -29,10 +29,12 @@ namespace Pinetime { void AcceptIncomingCall(); void RejectIncomingCall(); + void MuteIncomingCall(); enum class IncomingCallResponses : uint8_t { Reject = 0x00, - Answer = 0x01 + Answer = 0x01, + Mute = 0x02 }; private: diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 79189164..7ca91cfb 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -1,8 +1,11 @@ #include "Notifications.h" #include #include "components/ble/MusicService.h" +#include "Symbols.h" using namespace Pinetime::Applications::Screens; +extern lv_font_t jetbrains_mono_extrabold_compressed; +extern lv_font_t jetbrains_mono_bold_20; Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::NotificationManager ¬ificationManager, @@ -132,6 +135,11 @@ namespace { auto* item = static_cast(obj->user_data); item->OnAcceptIncomingCall(event); } + + static void MuteIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) { + auto* item = static_cast(obj->user_data); + item->OnMuteIncomingCall(event); + } static void RejectIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) { auto* item = static_cast(obj->user_data); @@ -225,19 +233,28 @@ Notifications::NotificationItem::NotificationItem(const char *title, lv_label_set_text(l2, msg); bt_accept = lv_btn_create(container1, nullptr); - lv_obj_align(bt_accept, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, -20); bt_accept->user_data = this; lv_obj_set_event_cb(bt_accept, AcceptIncomingCallEventHandler); - + lv_obj_set_size(bt_accept, LV_HOR_RES / 3, 80); + lv_obj_align(bt_accept, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, -20); label_accept = lv_label_create(bt_accept, nullptr); - lv_label_set_text(label_accept, "Accept"); + lv_label_set_text(label_accept, Symbols::phone); bt_reject = lv_btn_create(container1, nullptr); - lv_obj_align(bt_reject, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, -20); bt_reject->user_data = this; lv_obj_set_event_cb(bt_reject, RejectIncomingCallEventHandler); + lv_obj_set_size(bt_reject, LV_HOR_RES / 3, 80); + lv_obj_align(bt_reject, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, -20); label_reject = lv_label_create(bt_reject, nullptr); - lv_label_set_text(label_reject, "Reject"); + lv_label_set_text(label_reject, Symbols::phoneSlash); + + bt_mute = lv_btn_create(container1, nullptr); + bt_mute->user_data = this; + lv_obj_set_event_cb(bt_mute, MuteIncomingCallEventHandler); + lv_obj_set_size(bt_mute, LV_HOR_RES / 3, 80); + lv_obj_align(bt_mute, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, -20); + label_mute = lv_label_create(bt_mute, nullptr); + lv_label_set_text(label_mute, Symbols::volumMute); } } @@ -260,6 +277,12 @@ void Notifications::NotificationItem::OnAcceptIncomingCall(lv_event_t event) { alertNotificationService.AcceptIncomingCall(); } +void Notifications::NotificationItem::OnMuteIncomingCall(lv_event_t event) { + if (event != LV_EVENT_CLICKED) return; + + alertNotificationService.MuteIncomingCall(); +} + void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) { if (event != LV_EVENT_CLICKED) return; diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index aafd3e33..c40e7002 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -29,6 +29,7 @@ namespace Pinetime { ~NotificationItem(); bool Refresh() {return false;} void OnAcceptIncomingCall(lv_event_t event); + void OnMuteIncomingCall(lv_event_t event); void OnRejectIncomingCall(lv_event_t event); private: @@ -41,8 +42,10 @@ namespace Pinetime { lv_obj_t* l1; lv_obj_t* l2; lv_obj_t* bt_accept; + lv_obj_t* bt_mute; lv_obj_t* bt_reject; lv_obj_t* label_accept; + lv_obj_t* label_mute; lv_obj_t* label_reject; lv_obj_t* bottomPlaceholder; Modes mode; -- cgit v1.2.3-70-g09d2