Reformatted all the files according to clang-format style

This commit is contained in:
Avamander
2021-04-18 20:28:14 +03:00
parent e56ebb8bd6
commit 40d45d923b
179 changed files with 10119 additions and 10688 deletions

View File

@@ -8,34 +8,34 @@ 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 &notificationManager,
Notifications::Notifications(DisplayApp* app,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Modes mode) :
Screen(app), notificationManager{notificationManager}, alertNotificationService{alertNotificationService}, mode{mode} {
Modes mode)
: Screen(app), notificationManager {notificationManager}, alertNotificationService {alertNotificationService}, mode {mode} {
notificationManager.ClearNewNotificationFlag();
auto notification = notificationManager.GetLastNotification();
if(notification.valid) {
if (notification.valid) {
currentId = notification.id;
currentItem = std::make_unique<NotificationItem>(notification.Title(),
notification.Message(),
notification.index,
notification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService);
notification.Message(),
notification.index,
notification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService);
validDisplay = true;
} else {
currentItem = std::make_unique<NotificationItem>("Notification",
"No notification to display",
0,
notification.category,
notificationManager.NbNotifications(),
Modes::Preview,
alertNotificationService);
"No notification to display",
0,
notification.category,
notificationManager.NbNotifications(),
Modes::Preview,
alertNotificationService);
}
if(mode == Modes::Preview) {
if (mode == Modes::Preview) {
timeoutLine = lv_line_create(lv_scr_act(), nullptr);
@@ -45,7 +45,7 @@ Notifications::Notifications(DisplayApp *app,
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
timeoutTickCountStart = xTaskGetTickCount();
timeoutTickCountEnd = timeoutTickCountStart + (5*1024);
timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
}
}
@@ -68,34 +68,36 @@ bool Notifications::Refresh() {
}
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
if(mode != Modes::Normal) return true;
if (mode != Modes::Normal)
return true;
switch (event) {
case Pinetime::Applications::TouchEvents::SwipeDown: {
Controllers::NotificationManager::Notification previousNotification;
if(validDisplay)
if (validDisplay)
previousNotification = notificationManager.GetPrevious(currentId);
else
previousNotification = notificationManager.GetLastNotification();
if (!previousNotification.valid) return true;
if (!previousNotification.valid)
return true;
validDisplay = true;
currentId = previousNotification.id;
currentItem.reset(nullptr);
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
currentItem = std::make_unique<NotificationItem>(previousNotification.Title(),
previousNotification.Message(),
previousNotification.index,
previousNotification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService);
previousNotification.Message(),
previousNotification.index,
previousNotification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService);
}
return true;
case Pinetime::Applications::TouchEvents::SwipeUp: {
Controllers::NotificationManager::Notification nextNotification;
if(validDisplay)
if (validDisplay)
nextNotification = notificationManager.GetNext(currentId);
else
nextNotification = notificationManager.GetLastNotification();
@@ -110,16 +112,16 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
currentItem.reset(nullptr);
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
currentItem = std::make_unique<NotificationItem>(nextNotification.Title(),
nextNotification.Message(),
nextNotification.index,
nextNotification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService);
nextNotification.Message(),
nextNotification.index,
nextNotification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService);
}
return true;
case Pinetime::Applications::TouchEvents::LongTap: {
//notificationManager.ToggleVibrations();
// notificationManager.ToggleVibrations();
return true;
}
default:
@@ -138,20 +140,20 @@ namespace {
item->OnMuteIncomingCall(event);
}
static void RejectIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) {
auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data);
static void RejectIncomingCallEventHandler(lv_obj_t* obj, lv_event_t event) {
auto* item = static_cast<Notifications::NotificationItem*>(obj->user_data);
item->OnRejectIncomingCall(event);
}
}
Notifications::NotificationItem::NotificationItem(const char *title,
const char *msg,
uint8_t notifNr,
Controllers::NotificationManager::Categories category,
uint8_t notifNb,
Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService)
: notifNr{notifNr}, notifNb{notifNb}, mode{mode}, alertNotificationService{alertNotificationService} {
Notifications::NotificationItem::NotificationItem(const char* title,
const char* msg,
uint8_t notifNr,
Controllers::NotificationManager::Categories category,
uint8_t notifNb,
Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService)
: notifNr {notifNr}, notifNb {notifNb}, mode {mode}, alertNotificationService {alertNotificationService} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
@@ -172,20 +174,20 @@ namespace {
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";
if (title == nullptr)
title = "Notification";
lv_label_set_text(alert_type, title);
lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16);
/////////
switch(category) {
switch (category) {
default: {
lv_obj_t* alert_subject = lv_label_create(container1, nullptr);
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, msg);
}
break;
} break;
case Controllers::NotificationManager::Categories::IncomingCall: {
lv_obj_t* alert_subject = lv_label_create(container1, nullptr);
lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
@@ -234,8 +236,7 @@ namespace {
label_mute = lv_label_create(bt_mute, nullptr);
lv_label_set_text(label_mute, Symbols::volumMute);
lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
}
break;
} break;
}
lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
@@ -246,19 +247,22 @@ namespace {
}
void Notifications::NotificationItem::OnAcceptIncomingCall(lv_event_t event) {
if (event != LV_EVENT_CLICKED) return;
if (event != LV_EVENT_CLICKED)
return;
alertNotificationService.AcceptIncomingCall();
}
void Notifications::NotificationItem::OnMuteIncomingCall(lv_event_t event) {
if (event != LV_EVENT_CLICKED) return;
if (event != LV_EVENT_CLICKED)
return;
alertNotificationService.MuteIncomingCall();
}
void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) {
if (event != LV_EVENT_CLICKED) return;
if (event != LV_EVENT_CLICKED)
return;
alertNotificationService.RejectIncomingCall();
}