diff --git a/module-apps/apps-common/ApplicationCommon.cpp b/module-apps/apps-common/ApplicationCommon.cpp index 3a230bb96..03627ebf2 100644 --- a/module-apps/apps-common/ApplicationCommon.cpp +++ b/module-apps/apps-common/ApplicationCommon.cpp @@ -2,10 +2,10 @@ // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "ApplicationCommon.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 "Service/Message.hpp" #include "Timers/TimerFactory.hpp" // for Timer #include "StatusBar.hpp" @@ -14,10 +14,10 @@ #include "Translator.hpp" // for KeyInputSim... #include // for Battery #include -#include "gui/input/InputEvent.hpp" // for InputEvent -#include // for DEBUG_APPLI... -#include // for LOG_INFO -#include "messages/AppMessage.hpp" // for AppSwitchMe... +#include "gui/input/InputEvent.hpp" // for InputEvent +#include // for DEBUG_APPLI... +#include // for LOG_INFO +#include "messages/AppMessage.hpp" // for AppSwitchMe... #include "messages/AppSwitchWindowPopupMessage.hpp" #include "service-appmgr/Controller.hpp" // for Controller #include "actions/AlarmClockStatusChangeParams.hpp" @@ -896,6 +896,11 @@ namespace app return *popupFilter; } + void ApplicationCommon::clearPendingPopups() + { + windowsPopupQueue->clear(); + } + bool ApplicationCommon::tryShowPopup() { auto request = windowsPopupQueue->popRequest(getPopupFilter()); @@ -1065,9 +1070,4 @@ namespace app getCurrentWindow()->updateBatteryStatus(); getCurrentWindow()->updateSim(); } - - void ApplicationCommon::registerOnPopCallback(std::function callback) - { - windowsStack().registerOnPopCallback(std::move(callback)); - } } /* namespace app */ diff --git a/module-apps/apps-common/ApplicationCommon.hpp b/module-apps/apps-common/ApplicationCommon.hpp index 24e90edaa..64e286bbf 100644 --- a/module-apps/apps-common/ApplicationCommon.hpp +++ b/module-apps/apps-common/ApplicationCommon.hpp @@ -185,7 +185,6 @@ namespace app private: std::unique_ptr popupFilter; std::unique_ptr windowsStackImpl; - WindowsStack &windowsStack() const; std::string default_window; State state = State::DEACTIVATED; @@ -220,6 +219,7 @@ namespace app public: sys::TimerHandle longPressTimer; void clearLongPressTimeout(); + WindowsStack &windowsStack() const; explicit ApplicationCommon(std::string name, std::string parent = "", @@ -275,8 +275,6 @@ namespace app /// Find and pop window from stack by window name void popWindow(const std::string &window); - void registerOnPopCallback(std::function callback); - /// Pops the current window from the windows stack void popCurrentWindow(); @@ -362,13 +360,14 @@ namespace app /// Method used to attach popups windows to application virtual void attachPopups(const std::vector &popupsList) = 0; virtual void actionPopupPush(std::unique_ptr params); + virtual void clearPendingPopups(); virtual bool tryShowPopup(); void abortPopup(gui::popup::ID id); bool userInterfaceDBNotification(sys::Message *msg, const UiNotificationFilter &filter = nullptr); virtual gui::popup::Filter &getPopupFilter() const; - void requestShutdownWindow(std::string windowName); + void requestShutdownWindow(std::string windowName); public: /// push window to the top of windows stack diff --git a/module-apps/apps-common/WindowsPopupQueue.cpp b/module-apps/apps-common/WindowsPopupQueue.cpp index 0f55ff53f..5b1633de8 100644 --- a/module-apps/apps-common/WindowsPopupQueue.cpp +++ b/module-apps/apps-common/WindowsPopupQueue.cpp @@ -6,6 +6,11 @@ namespace app { + void WindowsPopupQueue::clear() + { + requests.clear(); + } + std::optional WindowsPopupQueue::popRequest(const gui::popup::Filter &filter) { for (const auto &val : requests) { diff --git a/module-apps/apps-common/WindowsPopupQueue.hpp b/module-apps/apps-common/WindowsPopupQueue.hpp index 58e090083..cd2791b01 100644 --- a/module-apps/apps-common/WindowsPopupQueue.hpp +++ b/module-apps/apps-common/WindowsPopupQueue.hpp @@ -24,6 +24,9 @@ namespace app class WindowsPopupQueue { public: + /// clears popup queue + void clear(); + /// pops next available popup we require to show /// * in order set by Disposition /// * limited by Filter passed to request diff --git a/module-apps/apps-common/WindowsStack.cpp b/module-apps/apps-common/WindowsStack.cpp index eb1d68aa6..1899d4b77 100644 --- a/module-apps/apps-common/WindowsStack.cpp +++ b/module-apps/apps-common/WindowsStack.cpp @@ -70,9 +70,6 @@ namespace app auto ret = findInStack(window); if (ret != stack.end()) { stack.erase(std::next(ret), stack.end()); - if (onPopCallback) { - onPopCallback(*this); - } return true; } return false; @@ -118,10 +115,7 @@ namespace app { return std::find_if(stack.begin(), stack.end(), [&](auto &el) { return el.name == window; }); } - void WindowsStack::registerOnPopCallback(std::function callback) - { - onPopCallback = std::move(callback); - } + void WindowsStack::dropPendingPopups() { auto it = stack.rbegin(); diff --git a/module-apps/apps-common/WindowsStack.hpp b/module-apps/apps-common/WindowsStack.hpp index 054fb422a..59f301547 100644 --- a/module-apps/apps-common/WindowsStack.hpp +++ b/module-apps/apps-common/WindowsStack.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -40,7 +40,6 @@ namespace app class WindowsStack { - std::function onPopCallback = nullptr; std::map> windows{}; std::vector stack; decltype(stack)::iterator findInStack(const std::string &); @@ -75,7 +74,6 @@ namespace app void clear(); bool rebuildWindows(app::WindowsFactory &windowsFactory, ApplicationCommon *app); - void registerOnPopCallback(std::function callback); }; } // namespace app diff --git a/module-bsp/board/rt1051/bsp/lpm/RT1051LPMCommon.cpp b/module-bsp/board/rt1051/bsp/lpm/RT1051LPMCommon.cpp index 843336d18..6072b31e4 100644 --- a/module-bsp/board/rt1051/bsp/lpm/RT1051LPMCommon.cpp +++ b/module-bsp/board/rt1051/bsp/lpm/RT1051LPMCommon.cpp @@ -23,7 +23,7 @@ namespace bsp RT1051LPMCommon::RT1051LPMCommon() { driverSEMC = drivers::DriverSEMC::Create(drivers::name::ExternalRAM); - CpuFreq = std::make_unique(); + CpuFreq = std::make_unique(); } int32_t RT1051LPMCommon::PowerOff() diff --git a/products/BellHybrid/alarms/include/popups/AlarmActivatedPopupRequestParams.hpp b/products/BellHybrid/alarms/include/popups/AlarmActivatedPopupRequestParams.hpp index c3a2cdab0..872c7709e 100644 --- a/products/BellHybrid/alarms/include/popups/AlarmActivatedPopupRequestParams.hpp +++ b/products/BellHybrid/alarms/include/popups/AlarmActivatedPopupRequestParams.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -11,6 +11,8 @@ namespace gui { public: AlarmActivatedPopupRequestParams() : PopupRequestParams{gui::popup::ID::AlarmActivated} - {} + { + // ignoreCurrentWindowOnStack = true; + } }; } // namespace gui diff --git a/products/BellHybrid/alarms/include/popups/AlarmDeactivatedPopupRequestParams.hpp b/products/BellHybrid/alarms/include/popups/AlarmDeactivatedPopupRequestParams.hpp index e1603543a..e1049b503 100644 --- a/products/BellHybrid/alarms/include/popups/AlarmDeactivatedPopupRequestParams.hpp +++ b/products/BellHybrid/alarms/include/popups/AlarmDeactivatedPopupRequestParams.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -11,6 +11,8 @@ namespace gui { public: AlarmDeactivatedPopupRequestParams() : PopupRequestParams{gui::popup::ID::AlarmDeactivated} - {} + { + // ignoreCurrentWindowOnStack = true; + } }; } // namespace gui diff --git a/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp b/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp index 19294f8b8..235b2459b 100644 --- a/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp +++ b/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp @@ -39,7 +39,10 @@ namespace app std::uint32_t stackDepth) : Application(name, parent, statusIndicators, startInBackground, stackDepth) { - registerOnPopCallback([](WindowsStack &windowsStack) { windowsStack.dropPendingPopups(); }); + getPopupFilter().addAppDependentFilter([&](const gui::PopupRequestParams &) { + return gui::name::window::main_window != getCurrentWindow()->getName(); + }); + bus.channels.push_back(sys::BusChannel::ServiceDBNotifications); addActionReceiver(manager::actions::ShowAlarm, [this](auto &&data) { @@ -166,6 +169,7 @@ namespace app else if (newWindowName == gui::window::name::bell_main_menu || newWindowName == gui::window::name::bell_main_menu_dialog) { startIdleTimer(); + clearPendingPopups(); } } return ApplicationCommon::handleSwitchWindow(msgl); diff --git a/products/BellHybrid/apps/common/src/popups/AlarmActivatedWindow.cpp b/products/BellHybrid/apps/common/src/popups/AlarmActivatedWindow.cpp index 785c8afce..abc6e60c9 100644 --- a/products/BellHybrid/apps/common/src/popups/AlarmActivatedWindow.cpp +++ b/products/BellHybrid/apps/common/src/popups/AlarmActivatedWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include @@ -14,6 +14,7 @@ #include #include #include +#include namespace { @@ -65,6 +66,16 @@ namespace gui application, app::manager::actions::AbortPopup, std::make_unique(gui::popup::ID::AlarmDeactivated)); + + if (application->windowsStack().pop(gui::window::name::bellAlarmSet)) { + app::manager::Controller::sendAction( + application, + app::manager::actions::Launch, + std::make_unique(app::applicationBellName)); + } + else { + application->returnToPreviousWindow(); + } } bool AlarmActivatedWindow::onInput(const InputEvent &inputEvent) diff --git a/products/BellHybrid/apps/common/src/popups/AlarmDeactivatedWindow.cpp b/products/BellHybrid/apps/common/src/popups/AlarmDeactivatedWindow.cpp index 93022ff27..ecbe7d04d 100644 --- a/products/BellHybrid/apps/common/src/popups/AlarmDeactivatedWindow.cpp +++ b/products/BellHybrid/apps/common/src/popups/AlarmDeactivatedWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include @@ -15,6 +15,7 @@ #include #include #include +#include namespace gui { @@ -67,5 +68,14 @@ namespace gui app::manager::Controller::sendAction(application, app::manager::actions::AbortPopup, std::make_unique(gui::popup::ID::AlarmActivated)); + if (application->windowsStack().pop(gui::window::name::bellAlarmSet)) { + app::manager::Controller::sendAction( + application, + app::manager::actions::Launch, + std::make_unique(app::applicationBellName)); + } + else { + application->returnToPreviousWindow(); + } } } /* namespace gui */