2020-10-18 15:35:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-11-15 15:49:36 +00:00
|
|
|
#include <lvgl/lvgl.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
2020-10-18 15:35:36 +00:00
|
|
|
#include "Screen.h"
|
2020-11-15 15:49:36 +00:00
|
|
|
#include "components/ble/NotificationManager.h"
|
2021-05-12 18:23:04 +00:00
|
|
|
#include "components/motor/MotorController.h"
|
2020-10-18 15:35:36 +00:00
|
|
|
|
|
|
|
namespace Pinetime {
|
2021-01-24 16:27:48 +00:00
|
|
|
namespace Controllers {
|
|
|
|
class AlertNotificationService;
|
|
|
|
}
|
2020-10-18 15:35:36 +00:00
|
|
|
namespace Applications {
|
|
|
|
namespace Screens {
|
2021-01-24 16:27:48 +00:00
|
|
|
|
2020-10-18 15:35:36 +00:00
|
|
|
class Notifications : public Screen {
|
2021-04-24 09:00:45 +00:00
|
|
|
public:
|
2021-04-18 17:28:14 +00:00
|
|
|
enum class Modes { Normal, Preview };
|
|
|
|
explicit Notifications(DisplayApp* app,
|
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager,
|
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
2021-05-12 18:23:04 +00:00
|
|
|
Controllers::MotorController& motorController,
|
2021-04-18 17:28:14 +00:00
|
|
|
Modes mode);
|
|
|
|
~Notifications() override;
|
2020-10-18 15:35:36 +00:00
|
|
|
|
2021-04-18 17:28:14 +00:00
|
|
|
bool Refresh() override;
|
|
|
|
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
2020-10-18 15:35:36 +00:00
|
|
|
|
2021-01-24 16:22:39 +00:00
|
|
|
class NotificationItem {
|
2021-04-24 09:00:45 +00:00
|
|
|
public:
|
2021-04-18 17:28:14 +00:00
|
|
|
NotificationItem(const char* title,
|
|
|
|
const char* msg,
|
|
|
|
uint8_t notifNr,
|
|
|
|
Controllers::NotificationManager::Categories,
|
|
|
|
uint8_t notifNb,
|
|
|
|
Modes mode,
|
2021-05-12 18:23:04 +00:00
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
2021-05-12 22:08:40 +00:00
|
|
|
Controllers::MotorController& motorController,
|
2021-05-12 23:51:43 +00:00
|
|
|
uint32_t* timeoutEnd,
|
|
|
|
uint32_t* timeoutStart);
|
2021-01-24 16:22:39 +00:00
|
|
|
~NotificationItem();
|
2021-04-18 17:28:14 +00:00
|
|
|
bool Refresh() {
|
|
|
|
return false;
|
|
|
|
}
|
2021-01-24 16:22:39 +00:00
|
|
|
void OnAcceptIncomingCall(lv_event_t event);
|
2021-01-27 12:45:06 +00:00
|
|
|
void OnMuteIncomingCall(lv_event_t event);
|
2021-01-24 16:22:39 +00:00
|
|
|
void OnRejectIncomingCall(lv_event_t event);
|
2021-05-12 22:35:36 +00:00
|
|
|
|
2021-05-12 22:08:40 +00:00
|
|
|
bool timeoutOnHold = false;
|
2021-04-24 09:00:45 +00:00
|
|
|
private:
|
2021-05-12 22:08:40 +00:00
|
|
|
void callPreviewInteraction();
|
|
|
|
|
2021-01-24 16:22:39 +00:00
|
|
|
uint8_t notifNr = 0;
|
|
|
|
uint8_t notifNb = 0;
|
|
|
|
char pageText[4];
|
2020-10-19 19:46:41 +00:00
|
|
|
|
2021-01-24 16:22:39 +00:00
|
|
|
lv_obj_t* container1;
|
|
|
|
lv_obj_t* t1;
|
|
|
|
lv_obj_t* l1;
|
|
|
|
lv_obj_t* l2;
|
|
|
|
lv_obj_t* bt_accept;
|
2021-01-27 12:45:06 +00:00
|
|
|
lv_obj_t* bt_mute;
|
2021-01-24 16:22:39 +00:00
|
|
|
lv_obj_t* bt_reject;
|
|
|
|
lv_obj_t* label_accept;
|
2021-01-27 12:45:06 +00:00
|
|
|
lv_obj_t* label_mute;
|
2021-01-24 16:22:39 +00:00
|
|
|
lv_obj_t* label_reject;
|
|
|
|
lv_obj_t* bottomPlaceholder;
|
2021-05-12 22:08:40 +00:00
|
|
|
uint32_t* timeoutEnd;
|
2021-05-12 23:51:43 +00:00
|
|
|
uint32_t* timeoutStart;
|
2021-01-24 16:22:39 +00:00
|
|
|
Modes mode;
|
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
|
2021-05-12 18:23:04 +00:00
|
|
|
Controllers::MotorController& motorController;
|
2021-01-24 16:22:39 +00:00
|
|
|
};
|
|
|
|
|
2021-04-24 09:00:45 +00:00
|
|
|
private:
|
2021-04-18 17:28:14 +00:00
|
|
|
struct NotificationData {
|
|
|
|
const char* title;
|
|
|
|
const char* text;
|
|
|
|
};
|
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
|
|
|
|
Modes mode = Modes::Normal;
|
|
|
|
std::unique_ptr<NotificationItem> currentItem;
|
|
|
|
Controllers::NotificationManager::Notification::Id currentId;
|
2021-05-12 18:23:04 +00:00
|
|
|
Controllers::MotorController& motorController;
|
2021-04-18 17:28:14 +00:00
|
|
|
bool validDisplay = false;
|
2020-10-20 18:57:39 +00:00
|
|
|
|
2021-04-18 17:28:14 +00:00
|
|
|
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
|
|
|
|
lv_obj_t* timeoutLine;
|
|
|
|
uint32_t timeoutTickCountStart;
|
|
|
|
uint32_t timeoutTickCountEnd;
|
2020-10-18 15:35:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|