Reformatted all the files according to clang-format style
This commit is contained in:
parent
e56ebb8bd6
commit
40d45d923b
179 changed files with 10119 additions and 10688 deletions
|
|
@ -6,15 +6,15 @@ using namespace Pinetime::Controllers;
|
|||
|
||||
constexpr uint8_t NotificationManager::MessageSize;
|
||||
|
||||
|
||||
void NotificationManager::Push(NotificationManager::Notification &¬if) {
|
||||
void NotificationManager::Push(NotificationManager::Notification&& notif) {
|
||||
notif.id = GetNextId();
|
||||
notif.valid = true;
|
||||
notifications[writeIndex] = std::move(notif);
|
||||
writeIndex = (writeIndex + 1 < TotalNbNotifications) ? writeIndex + 1 : 0;
|
||||
if(!empty)
|
||||
if (!empty)
|
||||
readIndex = (readIndex + 1 < TotalNbNotifications) ? readIndex + 1 : 0;
|
||||
else empty = false;
|
||||
else
|
||||
empty = false;
|
||||
|
||||
newNotification = true;
|
||||
}
|
||||
|
|
@ -30,40 +30,48 @@ NotificationManager::Notification::Id NotificationManager::GetNextId() {
|
|||
}
|
||||
|
||||
NotificationManager::Notification NotificationManager::GetNext(NotificationManager::Notification::Id id) {
|
||||
auto currentIterator = std::find_if(notifications.begin(), notifications.end(), [id](const Notification& n){return n.valid && n.id == id;});
|
||||
if(currentIterator == notifications.end() || currentIterator->id != id) return Notification{};
|
||||
auto currentIterator = std::find_if(notifications.begin(), notifications.end(), [id](const Notification& n) {
|
||||
return n.valid && n.id == id;
|
||||
});
|
||||
if (currentIterator == notifications.end() || currentIterator->id != id)
|
||||
return Notification {};
|
||||
|
||||
auto& lastNotification = notifications[readIndex];
|
||||
|
||||
NotificationManager::Notification result;
|
||||
|
||||
if(currentIterator == (notifications.end()-1))
|
||||
if (currentIterator == (notifications.end() - 1))
|
||||
result = *(notifications.begin());
|
||||
else
|
||||
result = *(currentIterator+1);
|
||||
result = *(currentIterator + 1);
|
||||
|
||||
if(result.id <= id) return {};
|
||||
if (result.id <= id)
|
||||
return {};
|
||||
|
||||
result.index = (lastNotification.id - result.id)+1;
|
||||
result.index = (lastNotification.id - result.id) + 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
NotificationManager::Notification NotificationManager::GetPrevious(NotificationManager::Notification::Id id) {
|
||||
auto currentIterator = std::find_if(notifications.begin(), notifications.end(), [id](const Notification& n){return n.valid && n.id == id;});
|
||||
if(currentIterator == notifications.end() || currentIterator->id != id) return Notification{};
|
||||
auto currentIterator = std::find_if(notifications.begin(), notifications.end(), [id](const Notification& n) {
|
||||
return n.valid && n.id == id;
|
||||
});
|
||||
if (currentIterator == notifications.end() || currentIterator->id != id)
|
||||
return Notification {};
|
||||
|
||||
auto& lastNotification = notifications[readIndex];
|
||||
|
||||
NotificationManager::Notification result;
|
||||
|
||||
if(currentIterator == notifications.begin())
|
||||
result = *(notifications.end()-1);
|
||||
if (currentIterator == notifications.begin())
|
||||
result = *(notifications.end() - 1);
|
||||
else
|
||||
result = *(currentIterator-1);
|
||||
result = *(currentIterator - 1);
|
||||
|
||||
if(result.id >= id) return {};
|
||||
if (result.id >= id)
|
||||
return {};
|
||||
|
||||
result.index = (lastNotification.id - result.id)+1;
|
||||
result.index = (lastNotification.id - result.id) + 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +84,7 @@ bool NotificationManager::IsVibrationEnabled() {
|
|||
}
|
||||
|
||||
void NotificationManager::ToggleVibrations() {
|
||||
vibrationEnabled = !vibrationEnabled;
|
||||
vibrationEnabled = !vibrationEnabled;
|
||||
}
|
||||
|
||||
bool NotificationManager::ClearNewNotificationFlag() {
|
||||
|
|
@ -84,21 +92,23 @@ bool NotificationManager::ClearNewNotificationFlag() {
|
|||
}
|
||||
|
||||
size_t NotificationManager::NbNotifications() const {
|
||||
return std::count_if(notifications.begin(), notifications.end(), [](const Notification& n){ return n.valid;});
|
||||
return std::count_if(notifications.begin(), notifications.end(), [](const Notification& n) {
|
||||
return n.valid;
|
||||
});
|
||||
}
|
||||
|
||||
const char* NotificationManager::Notification::Message() const {
|
||||
const char* itField = std::find(message.begin(), message.begin()+size-1, '\0');
|
||||
if(itField != message.begin()+size-1) {
|
||||
const char* ptr = (itField)+1;
|
||||
const char* itField = std::find(message.begin(), message.begin() + size - 1, '\0');
|
||||
if (itField != message.begin() + size - 1) {
|
||||
const char* ptr = (itField) + 1;
|
||||
return ptr;
|
||||
}
|
||||
return const_cast<char*>(message.data());
|
||||
}
|
||||
|
||||
const char* NotificationManager::Notification::Title() const {
|
||||
const char * itField = std::find(message.begin(), message.begin()+size-1, '\0');
|
||||
if(itField != message.begin()+size-1) {
|
||||
const char* itField = std::find(message.begin(), message.begin() + size - 1, '\0');
|
||||
if (itField != message.begin() + size - 1) {
|
||||
return message.data();
|
||||
}
|
||||
return {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue