[EGD-6855] Add no modem notification on tethering

This commit provides the implementation of functionality that blocks
sms/calls notifications on home screen when tethering is active.
Previously, the notifications could be visible if the notifications
were visible prior to tethering activation.

By the design, the functionality should not clear the notifications,
just temporary hide them. That is achieved by implementation ot the
functionality in NotificationModel which is an UI presenter.
This commit is contained in:
Michał Kamoń
2021-05-31 13:27:26 +02:00
committed by Michał Kamoń
parent 325f8696b8
commit 8078dd240b
2 changed files with 19 additions and 2 deletions

View File

@@ -20,6 +20,15 @@ namespace
item->setName(utils::translate(text), true);
}
}
bool hasTetheringNotification(app::manager::actions::NotificationsChangedParams *params)
{
const auto &notifications = params->getNotifications();
const auto it = std::find_if(std::begin(notifications), std::end(notifications), [](const auto &notification) {
return notification->getType() == notifications::NotificationType::Tethering;
});
return it != std::end(notifications);
}
} // namespace
unsigned int NotificationsModel::requestRecordsCount()
@@ -104,12 +113,13 @@ void NotificationsModel::updateData(app::manager::actions::NotificationsChangedP
delete item;
}
};
tetheringOn = hasTetheringNotification(params);
for (const auto &notification : params->getNotifications()) {
if (typeid(*notification) == typeid(notifications::NotSeenSMSNotification)) {
if (not tetheringOn && typeid(*notification) == typeid(notifications::NotSeenSMSNotification)) {
auto sms = static_cast<const notifications::NotSeenSMSNotification *>(notification.get());
internalData.push_back(create(sms));
}
else if (typeid(*notification) == typeid(notifications::NotSeenCallNotification)) {
else if (not tetheringOn && typeid(*notification) == typeid(notifications::NotSeenCallNotification)) {
auto call = static_cast<const notifications::NotSeenCallNotification *>(notification.get());
internalData.push_back(create(call));
}
@@ -128,3 +138,8 @@ void NotificationsModel::clearAll()
list->reset();
eraseInternalData();
}
bool NotificationsModel::isTetheringOn() const noexcept
{
return tetheringOn;
}