M module-apps/Application.cpp => module-apps/Application.cpp +10 -8
@@ 2,10 2,10 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "Application.hpp"
-#include "Common.hpp" // for RefreshModes
-#include "GuiTimer.hpp" // for GuiTimer
-#include "Item.hpp" // for Item
-#include "MessageType.hpp" // for MessageType
+#include "Common.hpp" // for RefreshModes
+#include "GuiTimer.hpp" // for GuiTimer
+#include "Item.hpp" // for Item
+#include "MessageType.hpp" // for MessageType
#include "module-sys/Timers/TimerFactory.hpp" // for Timer
#include "TopBar.hpp"
#include "TopBar/Time.hpp"
@@ 146,8 146,7 @@ namespace app
return actionHandled();
});
addActionReceiver(app::manager::actions::NotificationsChanged, [this](auto &¶ms) {
- auto notificationParams = static_cast<manager::actions::NotificationsChangedParams *>(params.get());
- handle(notificationParams);
+ handleNotificationsChanged(std::move(params));
return actionHandled();
});
}
@@ 903,9 902,12 @@ namespace app
receivers.insert_or_assign(actionId, std::move(callback));
}
- void Application::handle(manager::actions::NotificationsChangedParams *params)
+ void Application::handleNotificationsChanged(std::unique_ptr<gui::SwitchData> notificationsParams)
{
- LOG_DEBUG("To be implemented by Pop-up based Locked-Screen [EGD-5884]");
+ if (auto window = getCurrentWindow()->getName(); window == gui::popup::window::phone_lock_window) {
+
+ updateWindow(window, std::move(notificationsParams));
+ }
}
void Application::cancelCallbacks(AsyncCallbackReceiver::Ptr receiver)
M module-apps/Application.hpp => module-apps/Application.hpp +1 -5
@@ 37,10 37,6 @@ namespace app
{
class WindowsStack;
- namespace manager::actions
- {
- class NotificationsChangedParams;
- }
} // namespace app
namespace gui
{
@@ 390,7 386,7 @@ namespace app
const gui::InputEvent &event);
void addActionReceiver(manager::actions::ActionId actionId, OnActionReceived &&callback);
- virtual void handle(manager::actions::NotificationsChangedParams *params);
+ virtual void handleNotificationsChanged(std::unique_ptr<gui::SwitchData> notificationsParams);
std::unique_ptr<TopBarManager> topBarManager;
M module-apps/InternalModel.hpp => module-apps/InternalModel.hpp +0 -2
@@ 6,8 6,6 @@
#include <module-gui/gui/widgets/ListItemProvider.hpp>
#include <vector>
-#include "Application.hpp"
-
namespace app
{
M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +8 -9
@@ 24,7 24,6 @@
#include "AppWindow.hpp"
#include "data/DesktopData.hpp"
-#include "models/ActiveNotificationsModel.hpp"
#include <service-db/DBServiceAPI.hpp>
#include <application-settings-new/ApplicationSettings.hpp>
@@ 70,8 69,7 @@ namespace app
std::string parent,
sys::phone_modes::PhoneMode mode,
StartInBackground startInBackground)
- : Application(std::move(name), std::move(parent), mode, startInBackground),
- lockHandler(this), notificationsModel{std::make_shared<gui::ActiveNotificationsModel>()}
+ : Application(std::move(name), std::move(parent), mode, startInBackground), lockHandler(this)
{
using namespace gui::top_bar;
topBarManager->enableIndicators({Indicator::Signal,
@@ 253,11 251,12 @@ namespace app
return true;
}
- void ApplicationDesktop::handle(manager::actions::NotificationsChangedParams *params)
+ void ApplicationDesktop::handleNotificationsChanged(std::unique_ptr<gui::SwitchData> notificationsParams)
{
- if (getCurrentWindow()->getName() == app::window::name::desktop_main_window) {
- notificationsModel->updateData(params);
- refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
+ if (auto window = getCurrentWindow()->getName();
+ window == app::window::name::desktop_main_window || window == gui::popup::window::phone_lock_window) {
+
+ updateWindow(window, std::move(notificationsParams));
}
}
@@ 458,8 457,8 @@ namespace app
void ApplicationDesktop::createUserInterface()
{
using namespace app::window::name;
- windowsFactory.attach(desktop_main_window, [this](Application *app, const std::string &name) {
- return std::make_unique<gui::DesktopMainWindow>(app, notificationsModel);
+ windowsFactory.attach(desktop_main_window, [](Application *app, const std::string &name) {
+ return std::make_unique<gui::DesktopMainWindow>(app);
});
windowsFactory.attach(desktop_pin_lock, [&](Application *app, const std::string newname) {
return std::make_unique<gui::PinLockWindow>(app, desktop_pin_lock);
M module-apps/application-desktop/ApplicationDesktop.hpp => module-apps/application-desktop/ApplicationDesktop.hpp +1 -3
@@ 14,7 14,6 @@
#include <endpoints/update/UpdateMuditaOS.hpp>
#include <service-desktop/ServiceDesktop.hpp>
#include <service-desktop/DesktopMessages.hpp>
-#include <notifications/NotificationListItem.hpp>
namespace cellular
{
@@ 82,7 81,7 @@ namespace app
auto handle(db::query::CalllogGetCountResult *msg) -> bool;
auto handle(sdesktop::UpdateOsMessage *msg) -> bool;
auto handle(sdesktop::developerMode::ScreenlockCheckEvent *event) -> bool;
- void handle(manager::actions::NotificationsChangedParams *params) override;
+ void handleNotificationsChanged(std::unique_ptr<gui::SwitchData> notificationsParams) override;
/**
* This static method will be used to lock the phone
*/
@@ 113,7 112,6 @@ namespace app
void osCurrentVersionChanged(const std::string &value);
std::string osUpdateVersion{updateos::initSysVer};
std::string osCurrentVersion{updateos::initSysVer};
- std::shared_ptr<gui::NotificationsModel> notificationsModel;
};
template <> struct ManifestTraits<ApplicationDesktop>
M module-apps/application-desktop/models/ActiveNotificationsModel.cpp => module-apps/application-desktop/models/ActiveNotificationsModel.cpp +12 -11
@@ 10,6 10,9 @@
using namespace gui;
+ActiveNotificationsModel::ActiveNotificationsModel(AppWindow *parent) : parent(parent)
+{}
+
void ActiveNotificationsModel::setParentBottomBar(const UTF8 &left, const UTF8 ¢er, const UTF8 &right)
{
parent->setBottomBarText(left, BottomBar::Side::LEFT);
@@ 32,17 35,15 @@ auto ActiveNotificationsModel::create(const notifications::NotSeenSMSNotificatio
app::manager::actions::Launch,
std::make_unique<app::ApplicationLaunchData>(app::name_messages));
};
- item->inputCallback =
- [this]([[maybe_unused]] Item &item, const InputEvent &inputEvent) {
- if (inputEvent.isShortRelease(KeyCode::KEY_RF)) {
- DBServiceAPI::GetQuery(
- parent->getApplication(),
- db::Interface::Name::Notifications,
- std::make_unique<db::query::notifications::Clear>(NotificationsRecord::Key::Sms));
- return true;
- }
- return false;
- };
+ item->inputCallback = [this]([[maybe_unused]] Item &item, const InputEvent &inputEvent) {
+ if (inputEvent.isShortRelease(KeyCode::KEY_RF)) {
+ DBServiceAPI::GetQuery(parent->getApplication(),
+ db::Interface::Name::Notifications,
+ std::make_unique<db::query::notifications::Clear>(NotificationsRecord::Key::Sms));
+ return true;
+ }
+ return false;
+ };
item->setDismissible(true);
return item;
}
M module-apps/application-desktop/models/ActiveNotificationsModel.hpp => module-apps/application-desktop/models/ActiveNotificationsModel.hpp +5 -0
@@ 9,6 9,11 @@ namespace gui
{
class ActiveNotificationsModel : public gui::NotificationsModel
{
+ private:
+ AppWindow *parent = nullptr;
+
+ public:
+ explicit ActiveNotificationsModel(AppWindow *parent);
void setParentBottomBar(const UTF8 &left, const UTF8 ¢er, const UTF8 &right);
auto create(const notifications::NotSeenSMSNotification *notification) -> NotificationListItem * override;
auto create(const notifications::NotSeenCallNotification *notification) -> NotificationListItem * override;
M module-apps/application-desktop/windows/DesktopMainWindow.cpp => module-apps/application-desktop/windows/DesktopMainWindow.cpp +12 -12
@@ 71,8 71,8 @@ namespace gui
void DesktopMainWindow::invalidate() noexcept
{
- time = nullptr;
- dayText = nullptr;
+ time = nullptr;
+ dayText = nullptr;
}
top_bar::Configuration DesktopMainWindow::configureTopBar(top_bar::Configuration appConfiguration)
@@ 82,10 82,10 @@ namespace gui
return appConfiguration;
}
- DesktopMainWindow::DesktopMainWindow(app::Application *app, std::shared_ptr<NotificationsModel> model)
- : AppWindow(app, app::window::name::desktop_main_window), notificationsModel(std::move(model))
+ DesktopMainWindow::DesktopMainWindow(app::Application *app)
+ : AppWindow(app, app::window::name::desktop_main_window),
+ notificationsModel(std::make_shared<ActiveNotificationsModel>(this))
{
- notificationsModel->setParentWindow(this);
osUpdateVer = getAppDesktop()->getOsUpdateVersion();
osCurrentVer = getAppDesktop()->getOsCurrentVersion();
@@ 94,12 94,6 @@ namespace gui
preBuildDrawListHook = [this](std::list<Command> &cmd) { updateTime(); };
}
- DesktopMainWindow::~DesktopMainWindow()
- {
- notificationsModel->clearAll();
- notificationsModel->list = nullptr;
- }
-
void DesktopMainWindow::setVisibleState()
{
auto app = getAppDesktop();
@@ 123,7 117,13 @@ namespace gui
void DesktopMainWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
- app::manager::Controller::requestNotifications(application);
+ if (auto notificationData = dynamic_cast<app::manager::actions::NotificationsChangedParams *>(data)) {
+ notificationsModel->updateData(notificationData);
+ }
+ else {
+ app::manager::Controller::requestNotifications(application);
+ }
+
setVisibleState();
}
M module-apps/application-desktop/windows/DesktopMainWindow.hpp => module-apps/application-desktop/windows/DesktopMainWindow.hpp +7 -7
@@ 3,10 3,11 @@
#pragma once
+#include <application-desktop/models/ActiveNotificationsModel.hpp>
+
#include <AppWindow.hpp>
#include <gui/widgets/Label.hpp>
#include <Translator.hpp>
-#include <notifications/NotificationsModel.hpp>
#include <ListView.hpp>
namespace app
@@ 19,11 20,11 @@ namespace gui
class DesktopMainWindow : public AppWindow
{
protected:
- gui::Label *time = nullptr;
- gui::Label *dayText = nullptr;
+ gui::Label *time = nullptr;
+ gui::Label *dayText = nullptr;
- gui::ListView *notificationsList = nullptr;
- std::shared_ptr<gui::NotificationsModel> notificationsModel = nullptr;
+ gui::ListView *notificationsList = nullptr;
+ std::shared_ptr<gui::ActiveNotificationsModel> notificationsModel = nullptr;
// method hides or show widgets and sets bars according to provided state
void setVisibleState();
@@ 33,8 34,7 @@ namespace gui
app::ApplicationDesktop *getAppDesktop() const;
public:
- DesktopMainWindow(app::Application *app, std::shared_ptr<NotificationsModel> model);
- ~DesktopMainWindow();
+ explicit DesktopMainWindow(app::Application *app);
// virtual methods gui::Window
bool onInput(const InputEvent &inputEvent) override;
M module-apps/application-meditation/widgets/MeditationModel.hpp => module-apps/application-meditation/widgets/MeditationModel.hpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 6,6 6,7 @@
#include "ListItemProvider.hpp"
#include "InternalModel.hpp"
#include "MeditationListItems.hpp"
+#include "Application.hpp"
namespace gui
{
M module-apps/application-notes/model/SearchResultsListModel.hpp => module-apps/application-notes/model/SearchResultsListModel.hpp +5 -8
@@ 1,16 1,13 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
-#include <cstdint>
-#include <vector>
-
+#include <application-notes/widgets/NotesItem.hpp>
#include <module-db/Interface/NotesRecord.hpp>
-
-#include <module-apps/InternalModel.hpp>
-#include "module-apps/application-notes/widgets/NotesItem.hpp"
-#include <module-gui/gui/widgets/ListItemProvider.hpp>
+#include <ListItemProvider.hpp>
+#include <InternalModel.hpp>
+#include <Application.hpp>
namespace app::notes
{
M module-apps/notifications/NotificationsModel.cpp => module-apps/notifications/NotificationsModel.cpp +0 -5
@@ 118,8 118,3 @@ void NotificationsModel::clearAll()
list->reset();
eraseInternalData();
}
-
-void NotificationsModel::setParentWindow(AppWindow *parentWindow) noexcept
-{
- parent = parentWindow;
-}
M module-apps/notifications/NotificationsModel.hpp => module-apps/notifications/NotificationsModel.hpp +0 -2
@@ 22,7 22,6 @@ namespace gui
void requestRecords(uint32_t offset, uint32_t limit) final;
protected:
- AppWindow *parent = nullptr;
[[nodiscard]] virtual auto create(const notifications::NotSeenSMSNotification *notification)
-> NotificationListItem *;
[[nodiscard]] virtual auto create(const notifications::NotSeenCallNotification *notification)
@@ 37,7 36,6 @@ namespace gui
void updateData(app::manager::actions::NotificationsChangedParams *params);
void dismissAll(const InputEvent &event);
void clearAll();
- void setParentWindow(AppWindow *parentWindow) noexcept;
};
} // namespace gui
M => +17 -4
@@ 30,7 30,8 @@ namespace gui
return enterPressed;
}
PhoneLockedWindow::PhoneLockedWindow(app::Application *app, const std::string &name) : AppWindow(app, name)
PhoneLockedWindow::PhoneLockedWindow(app::Application *app, const std::string &name)
: AppWindow(app, name), notificationsModel(std::make_shared<NotificationsModel>())
{
buildInterface();
@@ 54,6 55,14 @@ namespace gui
dayText->setBorderColor(gui::ColorNoColor);
dayText->setFont(style::window::font::biglight);
dayText->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
notificationsList = new ListView(this,
style::notifications::model::x,
style::notifications::model::y,
style::notifications::model::w,
style::notifications::model::h,
notificationsModel,
listview::ScrollBarType::None);
}
top_bar::Configuration PhoneLockedWindow::configureTopBar(top_bar::Configuration appConfiguration)
@@ 70,14 79,18 @@ namespace gui
void PhoneLockedWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
if (auto notificationData = dynamic_cast<app::manager::actions::NotificationsChangedParams *>(data)) {
notificationsModel->updateData(notificationData);
}
else {
app::manager::Controller::requestNotifications(application);
}
bottomBar->setActive(BottomBar::Side::RIGHT, false);
bottomBar->setText(BottomBar::Side::CENTER, utils::translate("app_desktop_unlock"));
bottomBar->setActive(BottomBar::Side::LEFT, false);
application->bus.sendUnicast(std::make_shared<TimersProcessingStopMessage>(), service::name::service_time);
// To be added
// buildNotifications(app);
}
bool PhoneLockedWindow::processLongReleaseEvent(const InputEvent &inputEvent)
M => +6 -2
@@ 6,6 6,8 @@
#include <AppWindow.hpp>
#include <gui/widgets/Label.hpp>
#include <Translator.hpp>
#include <notifications/NotificationsModel.hpp>
#include <ListView.hpp>
namespace app
{
@@ 17,8 19,10 @@ namespace gui
class PhoneLockedWindow : public AppWindow
{
protected:
gui::Label *time = nullptr;
gui::Label *dayText = nullptr;
gui::Label *time = nullptr;
gui::Label *dayText = nullptr;
gui::ListView *notificationsList = nullptr;
std::shared_ptr<gui::NotificationsModel> notificationsModel = nullptr;
/// Locking timer on pressing enter
class LockingTimer