add mute button and functionality for call notification + new button icons
This commit is contained in:
parent
523398d24a
commit
d4c31bcbbe
|
@ -118,3 +118,16 @@ void AlertNotificationService::RejectIncomingCall() {
|
||||||
|
|
||||||
ble_gattc_notify_custom(connectionHandle, eventHandle, om);
|
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);
|
||||||
|
}
|
|
@ -29,10 +29,12 @@ namespace Pinetime {
|
||||||
|
|
||||||
void AcceptIncomingCall();
|
void AcceptIncomingCall();
|
||||||
void RejectIncomingCall();
|
void RejectIncomingCall();
|
||||||
|
void MuteIncomingCall();
|
||||||
|
|
||||||
enum class IncomingCallResponses : uint8_t {
|
enum class IncomingCallResponses : uint8_t {
|
||||||
Reject = 0x00,
|
Reject = 0x00,
|
||||||
Answer = 0x01
|
Answer = 0x01,
|
||||||
|
Mute = 0x02
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
#include "Notifications.h"
|
#include "Notifications.h"
|
||||||
#include <displayapp/DisplayApp.h>
|
#include <displayapp/DisplayApp.h>
|
||||||
#include "components/ble/MusicService.h"
|
#include "components/ble/MusicService.h"
|
||||||
|
#include "Symbols.h"
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
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,
|
Notifications::Notifications(DisplayApp *app,
|
||||||
Pinetime::Controllers::NotificationManager ¬ificationManager,
|
Pinetime::Controllers::NotificationManager ¬ificationManager,
|
||||||
|
@ -132,6 +135,11 @@ namespace {
|
||||||
auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data);
|
auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data);
|
||||||
item->OnAcceptIncomingCall(event);
|
item->OnAcceptIncomingCall(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MuteIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) {
|
||||||
|
auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data);
|
||||||
|
item->OnMuteIncomingCall(event);
|
||||||
|
}
|
||||||
|
|
||||||
static void RejectIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) {
|
static void RejectIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) {
|
||||||
auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data);
|
auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data);
|
||||||
|
@ -225,19 +233,28 @@ Notifications::NotificationItem::NotificationItem(const char *title,
|
||||||
lv_label_set_text(l2, msg);
|
lv_label_set_text(l2, msg);
|
||||||
|
|
||||||
bt_accept = lv_btn_create(container1, nullptr);
|
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;
|
bt_accept->user_data = this;
|
||||||
lv_obj_set_event_cb(bt_accept, AcceptIncomingCallEventHandler);
|
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);
|
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);
|
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;
|
bt_reject->user_data = this;
|
||||||
lv_obj_set_event_cb(bt_reject, RejectIncomingCallEventHandler);
|
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);
|
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();
|
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) {
|
void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) {
|
||||||
if (event != LV_EVENT_CLICKED) return;
|
if (event != LV_EVENT_CLICKED) return;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace Pinetime {
|
||||||
~NotificationItem();
|
~NotificationItem();
|
||||||
bool Refresh() {return false;}
|
bool Refresh() {return false;}
|
||||||
void OnAcceptIncomingCall(lv_event_t event);
|
void OnAcceptIncomingCall(lv_event_t event);
|
||||||
|
void OnMuteIncomingCall(lv_event_t event);
|
||||||
void OnRejectIncomingCall(lv_event_t event);
|
void OnRejectIncomingCall(lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -41,8 +42,10 @@ namespace Pinetime {
|
||||||
lv_obj_t* l1;
|
lv_obj_t* l1;
|
||||||
lv_obj_t* l2;
|
lv_obj_t* l2;
|
||||||
lv_obj_t* bt_accept;
|
lv_obj_t* bt_accept;
|
||||||
|
lv_obj_t* bt_mute;
|
||||||
lv_obj_t* bt_reject;
|
lv_obj_t* bt_reject;
|
||||||
lv_obj_t* label_accept;
|
lv_obj_t* label_accept;
|
||||||
|
lv_obj_t* label_mute;
|
||||||
lv_obj_t* label_reject;
|
lv_obj_t* label_reject;
|
||||||
lv_obj_t* bottomPlaceholder;
|
lv_obj_t* bottomPlaceholder;
|
||||||
Modes mode;
|
Modes mode;
|
||||||
|
|
Loading…
Reference in a new issue