2020-10-18 11:35:36 -04:00
|
|
|
#pragma once
|
|
|
|
|
2020-11-15 10:49:36 -05:00
|
|
|
#include <lvgl/lvgl.h>
|
2022-01-01 09:22:35 -05:00
|
|
|
#include <FreeRTOS.h>
|
2020-11-15 10:49:36 -05:00
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/screens/Screen.h"
|
2020-11-15 10:49:36 -05:00
|
|
|
#include "components/ble/NotificationManager.h"
|
2021-08-01 07:13:32 -04:00
|
|
|
#include "components/motor/MotorController.h"
|
2022-01-01 09:22:35 -05:00
|
|
|
#include "systemtask/SystemTask.h"
|
2020-10-18 11:35:36 -04:00
|
|
|
|
|
|
|
namespace Pinetime {
|
2021-01-24 11:27:48 -05:00
|
|
|
namespace Controllers {
|
|
|
|
class AlertNotificationService;
|
|
|
|
}
|
2023-01-07 15:23:15 -05:00
|
|
|
|
2020-10-18 11:35:36 -04:00
|
|
|
namespace Applications {
|
|
|
|
namespace Screens {
|
2021-01-24 11:27:48 -05:00
|
|
|
|
2020-10-18 11:35:36 -04:00
|
|
|
class Notifications : public Screen {
|
2021-04-24 05:00:45 -04:00
|
|
|
public:
|
2021-04-18 13:28:14 -04:00
|
|
|
enum class Modes { Normal, Preview };
|
|
|
|
explicit Notifications(DisplayApp* app,
|
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager,
|
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
2021-08-01 07:13:32 -04:00
|
|
|
Pinetime::Controllers::MotorController& motorController,
|
2022-01-01 09:22:35 -05:00
|
|
|
System::SystemTask& systemTask,
|
2021-04-18 13:28:14 -04:00
|
|
|
Modes mode);
|
|
|
|
~Notifications() override;
|
2020-10-18 11:35:36 -04:00
|
|
|
|
2021-07-19 09:26:12 -04:00
|
|
|
void Refresh() override;
|
2021-04-18 13:28:14 -04:00
|
|
|
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
2022-09-21 01:33:20 -04:00
|
|
|
void DismissToBlack();
|
2022-01-01 09:22:35 -05:00
|
|
|
void OnPreviewInteraction();
|
2022-09-14 16:10:00 -04:00
|
|
|
void OnPreviewDismiss();
|
2020-10-18 11:35:36 -04:00
|
|
|
|
2021-01-24 11:22:39 -05:00
|
|
|
class NotificationItem {
|
2021-04-24 05:00:45 -04:00
|
|
|
public:
|
2022-05-19 13:59:09 -04:00
|
|
|
NotificationItem(Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
2022-06-27 16:32:03 -04:00
|
|
|
Pinetime::Controllers::MotorController& motorController);
|
2021-04-18 13:28:14 -04:00
|
|
|
NotificationItem(const char* title,
|
|
|
|
const char* msg,
|
|
|
|
uint8_t notifNr,
|
|
|
|
Controllers::NotificationManager::Categories,
|
|
|
|
uint8_t notifNb,
|
2022-01-29 17:34:09 -05:00
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
|
2022-06-27 16:32:03 -04:00
|
|
|
Pinetime::Controllers::MotorController& motorController);
|
2021-01-24 11:22:39 -05:00
|
|
|
~NotificationItem();
|
2023-01-07 15:23:15 -05:00
|
|
|
|
2021-08-01 06:05:48 -04:00
|
|
|
bool IsRunning() const {
|
|
|
|
return running;
|
2021-04-18 13:28:14 -04:00
|
|
|
}
|
2023-01-07 15:23:15 -05:00
|
|
|
|
2021-08-01 06:05:48 -04:00
|
|
|
void OnCallButtonEvent(lv_obj_t*, lv_event_t event);
|
2021-01-24 11:22:39 -05:00
|
|
|
|
2021-04-24 05:00:45 -04:00
|
|
|
private:
|
2022-05-19 13:59:09 -04:00
|
|
|
lv_obj_t* container;
|
|
|
|
lv_obj_t* subject_container;
|
2021-01-24 11:22:39 -05:00
|
|
|
lv_obj_t* bt_accept;
|
2021-01-27 07:45:06 -05:00
|
|
|
lv_obj_t* bt_mute;
|
2021-01-24 11:22:39 -05:00
|
|
|
lv_obj_t* bt_reject;
|
|
|
|
lv_obj_t* label_accept;
|
2021-01-27 07:45:06 -05:00
|
|
|
lv_obj_t* label_mute;
|
2021-01-24 11:22:39 -05:00
|
|
|
lv_obj_t* label_reject;
|
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
|
2022-01-29 17:34:09 -05:00
|
|
|
Pinetime::Controllers::MotorController& motorController;
|
2022-05-19 13:59:09 -04:00
|
|
|
|
2021-08-01 06:05:48 -04:00
|
|
|
bool running = true;
|
2021-01-24 11:22:39 -05:00
|
|
|
};
|
|
|
|
|
2021-04-24 05:00:45 -04:00
|
|
|
private:
|
2021-04-18 13:28:14 -04:00
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
|
|
|
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
|
2022-01-29 17:34:09 -05:00
|
|
|
Pinetime::Controllers::MotorController& motorController;
|
2022-01-01 09:22:35 -05:00
|
|
|
System::SystemTask& systemTask;
|
2021-04-18 13:28:14 -04:00
|
|
|
Modes mode = Modes::Normal;
|
|
|
|
std::unique_ptr<NotificationItem> currentItem;
|
2022-05-19 13:59:09 -04:00
|
|
|
Pinetime::Controllers::NotificationManager::Notification::Id currentId;
|
2021-04-18 13:28:14 -04:00
|
|
|
bool validDisplay = false;
|
2022-05-19 13:59:09 -04:00
|
|
|
bool afterDismissNextMessageFromAbove = false;
|
2020-10-20 14:57:39 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
|
2021-08-01 06:05:48 -04:00
|
|
|
lv_obj_t* timeoutLine = nullptr;
|
2022-01-01 09:22:35 -05:00
|
|
|
TickType_t timeoutTickCountStart;
|
2022-05-19 13:59:09 -04:00
|
|
|
|
2022-01-01 09:22:35 -05:00
|
|
|
static const TickType_t timeoutLength = pdMS_TO_TICKS(7000);
|
|
|
|
bool interacted = true;
|
2021-07-19 09:26:12 -04:00
|
|
|
|
2022-05-19 13:59:09 -04:00
|
|
|
bool dismissingNotification = false;
|
|
|
|
|
2021-07-19 09:26:12 -04:00
|
|
|
lv_task_t* taskRefresh;
|
2020-10-18 11:35:36 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|