Notifications : Fix display of notification index/number.
This commit is contained in:
parent
440ae412b9
commit
cabf1168d4
|
@ -28,6 +28,7 @@ void NotificationManager::Push(Pinetime::Controllers::NotificationManager::Categ
|
||||||
|
|
||||||
NotificationManager::Notification NotificationManager::GetLastNotification() {
|
NotificationManager::Notification NotificationManager::GetLastNotification() {
|
||||||
NotificationManager::Notification notification = notifications[readIndex];
|
NotificationManager::Notification notification = notifications[readIndex];
|
||||||
|
notification.index = 1;
|
||||||
return notification;
|
return notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,3 +82,7 @@ bool NotificationManager::ClearNewNotificationFlag() {
|
||||||
return newNotification.exchange(false);
|
return newNotification.exchange(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t NotificationManager::NbNotifications() const {
|
||||||
|
return std::count_if(notifications.begin(), notifications.end(), [](const Notification& n){ return n.valid;});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace Pinetime {
|
||||||
Id id;
|
Id id;
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
uint8_t number = TotalNbNotifications;
|
|
||||||
std::array<char, MessageSize+1> message;
|
std::array<char, MessageSize+1> message;
|
||||||
Categories category = Categories::Unknown;
|
Categories category = Categories::Unknown;
|
||||||
};
|
};
|
||||||
|
@ -29,6 +28,7 @@ namespace Pinetime {
|
||||||
bool AreNewNotificationsAvailable();
|
bool AreNewNotificationsAvailable();
|
||||||
|
|
||||||
static constexpr uint8_t MaximumMessageSize() { return MessageSize; };
|
static constexpr uint8_t MaximumMessageSize() { return MessageSize; };
|
||||||
|
size_t NbNotifications() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Notification::Id GetNextId();
|
Notification::Id GetNextId();
|
||||||
|
|
|
@ -11,10 +11,10 @@ Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::Notificatio
|
||||||
auto notification = notificationManager.GetLastNotification();
|
auto notification = notificationManager.GetLastNotification();
|
||||||
if(notification.valid) {
|
if(notification.valid) {
|
||||||
currentId = notification.id;
|
currentId = notification.id;
|
||||||
currentItem.reset(new NotificationItem("Notification", notification.message.data(), notification.index, notification.number, mode));
|
currentItem.reset(new NotificationItem("Notification", notification.message.data(), notification.index, notificationManager.NbNotifications(), mode));
|
||||||
validDisplay = true;
|
validDisplay = true;
|
||||||
} else {
|
} else {
|
||||||
currentItem.reset(new NotificationItem("Notification", "No notification to display", 0, 0, mode));
|
currentItem.reset(new NotificationItem("Notification", "No notification to display", 0, notificationManager.NbNotifications(), Modes::Preview));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode == Modes::Preview) {
|
if(mode == Modes::Preview) {
|
||||||
|
@ -71,7 +71,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
currentId = previousNotification.id;
|
currentId = previousNotification.id;
|
||||||
currentItem.reset(nullptr);
|
currentItem.reset(nullptr);
|
||||||
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
|
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
|
||||||
currentItem.reset(new NotificationItem("Notification", previousNotification.message.data(), previousNotification.index, previousNotification.number, mode));
|
currentItem.reset(new NotificationItem("Notification", previousNotification.message.data(), previousNotification.index, notificationManager.NbNotifications(), mode));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case Pinetime::Applications::TouchEvents::SwipeDown: {
|
case Pinetime::Applications::TouchEvents::SwipeDown: {
|
||||||
|
@ -87,7 +87,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
currentId = nextNotification.id;
|
currentId = nextNotification.id;
|
||||||
currentItem.reset(nullptr);
|
currentItem.reset(nullptr);
|
||||||
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
|
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
|
||||||
currentItem.reset(new NotificationItem("Notification", nextNotification.message.data(), nextNotification.index, nextNotification.number, mode));
|
currentItem.reset(new NotificationItem("Notification", nextNotification.message.data(), nextNotification.index, notificationManager.NbNotifications(), mode));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue