From 7f8fd25e9edee0f05df77490fca59dd15c953585 Mon Sep 17 00:00:00 2001 From: Mateusz Grzegorzek Date: Mon, 30 Aug 2021 15:28:40 +0200 Subject: [PATCH] [BH-831] Show popup on Alarm activation - part I Handle Deep press up when not on Home Screen. --- module-apps/apps-common/Application.cpp | 3 +++ module-apps/apps-common/Application.hpp | 2 +- module-apps/apps-common/popups/Popups.cpp | 2 ++ module-apps/apps-common/popups/Popups.hpp | 2 ++ module-sys/Service/Common.hpp | 3 +++ products/BellHybrid/CMakeLists.txt | 5 ++-- products/BellHybrid/alarms/CMakeLists.txt | 4 +++ .../popups/AlarmPopupRequestParams.hpp | 16 ++++++++++++ .../ApplicationBellMain.cpp | 17 ++++++++++++ .../apps/application-bell-main/CMakeLists.txt | 2 +- .../ApplicationBellMain.hpp | 4 +++ .../presenters/KeyMap.hpp | 26 ------------------- .../presenters/StateController.cpp | 3 ++- products/BellHybrid/keymap/CMakeLists.txt | 11 ++++++++ .../keymap/include/keymap/KeyMap.hpp | 23 ++++++++++++++++ .../services/appmgr/ApplicationManager.cpp | 18 +++++++++++++ .../BellHybrid/services/appmgr/CMakeLists.txt | 2 ++ .../include/appmgr/ApplicationManager.hpp | 7 ++--- .../BellHybrid/services/evtmgr/CMakeLists.txt | 3 +++ .../services/evtmgr/EventManager.cpp | 19 ++++++++++++++ .../evtmgr/include/evtmgr/EventManager.hpp | 3 +++ .../include/evtmgr/messages/AlarmMessage.hpp | 22 ++++++++++++++++ 22 files changed, 161 insertions(+), 36 deletions(-) create mode 100644 products/BellHybrid/alarms/include/popups/AlarmPopupRequestParams.hpp delete mode 100644 products/BellHybrid/apps/application-bell-main/presenters/KeyMap.hpp create mode 100644 products/BellHybrid/keymap/CMakeLists.txt create mode 100644 products/BellHybrid/keymap/include/keymap/KeyMap.hpp create mode 100644 products/BellHybrid/services/evtmgr/include/evtmgr/messages/AlarmMessage.hpp diff --git a/module-apps/apps-common/Application.cpp b/module-apps/apps-common/Application.cpp index 0f1f3a1fd207e00ddf3a46f1e29a926cb9ec3059..ab8e54c47c1bdefc9b2432949dd801603238b8ba 100644 --- a/module-apps/apps-common/Application.cpp +++ b/module-apps/apps-common/Application.cpp @@ -814,6 +814,9 @@ namespace app return std::make_unique(app, window::sim_not_ready_window); }); break; + case ID::AlarmActivated: + LOG_DEBUG("TODO"); + break; } } } diff --git a/module-apps/apps-common/Application.hpp b/module-apps/apps-common/Application.hpp index 5c7366dad959c8ee656cde6fd72ded13e2ee41e4..b13e8021e6b747f09eeee9be27efb7212b69abee 100644 --- a/module-apps/apps-common/Application.hpp +++ b/module-apps/apps-common/Application.hpp @@ -348,7 +348,7 @@ namespace app /// Method used to attach popups windows to application void attachPopups(const std::vector &popupsList); - void showPopup(gui::popup::ID id, const gui::PopupRequestParams *params); + virtual void showPopup(gui::popup::ID id, const gui::PopupRequestParams *params); void abortPopup(gui::popup::ID id); public: diff --git a/module-apps/apps-common/popups/Popups.cpp b/module-apps/apps-common/popups/Popups.cpp index 5c6ae756888f17f9b783aad1caa6b25e5eaa4b57..97b28223852017943344b5aef5771d8d8eafe1dc 100644 --- a/module-apps/apps-common/popups/Popups.cpp +++ b/module-apps/apps-common/popups/Popups.cpp @@ -32,6 +32,8 @@ namespace gui::popup return gui::popup::window::sim_info_window; case ID::SimNotReady: return gui::popup::window::sim_not_ready_window; + case ID::AlarmActivated: + return gui::popup::window::alarm_activated_window; } return {}; diff --git a/module-apps/apps-common/popups/Popups.hpp b/module-apps/apps-common/popups/Popups.hpp index 60e183cb39bae7e3d0b6e3d2ade0207199d36833..37a291cf46fc1917866ca3521192c474c4d353c8 100644 --- a/module-apps/apps-common/popups/Popups.hpp +++ b/module-apps/apps-common/popups/Popups.hpp @@ -23,6 +23,7 @@ namespace gui SimLock, SimInfo, SimNotReady, + AlarmActivated }; namespace window @@ -41,6 +42,7 @@ namespace gui inline constexpr auto sim_unlock_window = "SimUnlockPopup"; inline constexpr auto sim_info_window = "SimInfoPopup"; inline constexpr auto sim_not_ready_window = "SimNotReadyPopup"; + inline constexpr auto alarm_activated_window = "AlarmActivatedPopup"; } // namespace window std::string resolveWindowName(ID id); diff --git a/module-sys/Service/Common.hpp b/module-sys/Service/Common.hpp index 7f96ef755886447730ea40d9dc3d290fae04be54..1303de5da14bb322f30d7feff28d6fec0db274fc 100644 --- a/module-sys/Service/Common.hpp +++ b/module-sys/Service/Common.hpp @@ -24,6 +24,7 @@ namespace sys ServiceEvtmgrNotifications, PhoneModeChanges, PhoneLockChanges, + AlarmChanges, }; enum class ServicePriority @@ -121,6 +122,8 @@ inline const char *c_str(sys::BusChannel channel) return "PhoneModeChanges"; case sys::BusChannel::PhoneLockChanges: return "PhoneLockChanges"; + case sys::BusChannel::AlarmChanges: + return "AlarmChanges"; } return ""; } diff --git a/products/BellHybrid/CMakeLists.txt b/products/BellHybrid/CMakeLists.txt index 8f5934cbc2baf5a8008b12bf4a1071b61ab2a69e..83b89d98bad020c1aee8c9e16ad9076fa232b387 100644 --- a/products/BellHybrid/CMakeLists.txt +++ b/products/BellHybrid/CMakeLists.txt @@ -86,7 +86,8 @@ add_version_json(BellHybrid) add_standalone_image(BellHybrid) add_update_package(BellHybrid) -add_subdirectory(services) add_subdirectory(alarms) -add_subdirectory(sys) add_subdirectory(apps) +add_subdirectory(keymap) +add_subdirectory(services) +add_subdirectory(sys) diff --git a/products/BellHybrid/alarms/CMakeLists.txt b/products/BellHybrid/alarms/CMakeLists.txt index 929dcd33a2272264b4ef494f102831c38edae8fa..2fd12c25adb228ca2ad0530fdc570f8844c12d11 100644 --- a/products/BellHybrid/alarms/CMakeLists.txt +++ b/products/BellHybrid/alarms/CMakeLists.txt @@ -4,6 +4,10 @@ target_sources(alarms PRIVATE BellAlarmHandler.cpp AlarmHandlerActions.cpp + include/AlarmHandlerActions.hpp + include/BellAlarmHandler.hpp + PUBLIC + include/popups/AlarmPopupRequestParams.hpp ) target_include_directories(alarms diff --git a/products/BellHybrid/alarms/include/popups/AlarmPopupRequestParams.hpp b/products/BellHybrid/alarms/include/popups/AlarmPopupRequestParams.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6aa0fc2fb8ef15287ab68868495bf66fa6dbb76e --- /dev/null +++ b/products/BellHybrid/alarms/include/popups/AlarmPopupRequestParams.hpp @@ -0,0 +1,16 @@ +// 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 + +namespace gui +{ + class AlarmPopupRequestParams : public PopupRequestParams + { + public: + AlarmPopupRequestParams() : PopupRequestParams{gui::popup::ID::AlarmActivated} + {} + }; +} // namespace gui diff --git a/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp b/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp index 91f97af9d8266a88ac30a3bbdd303d0447b975f6..8b2dd719d0da0d9dad9176bd2724173ba427cdee 100644 --- a/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp +++ b/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp @@ -62,4 +62,21 @@ namespace app } return std::make_shared(); } + + void ApplicationBellMain::showPopup(gui::popup::ID id, const gui::PopupRequestParams *params) + { + if (id == gui::popup::ID::AlarmActivated) { + if (not isHomeScreenFocused()) { + switchWindow(gui::popup::resolveWindowName(id)); + } + } + else { + Application::showPopup(id, params); + } + } + + auto ApplicationBellMain::isHomeScreenFocused() -> bool + { + return GetName() == app::applicationBellName && getCurrentWindow()->getName() == gui::name::window::main_window; + } } // namespace app diff --git a/products/BellHybrid/apps/application-bell-main/CMakeLists.txt b/products/BellHybrid/apps/application-bell-main/CMakeLists.txt index 21269dab675c218999bf25b4247a9075da0cbfd1..669bedce7f739d0a4f019d349f70ef0d6f540d55 100644 --- a/products/BellHybrid/apps/application-bell-main/CMakeLists.txt +++ b/products/BellHybrid/apps/application-bell-main/CMakeLists.txt @@ -21,7 +21,6 @@ target_sources(application-bell-main models/TimeModel.hpp presenters/HomeScreenPresenter.hpp - presenters/KeyMap.hpp presenters/StateController.hpp PUBLIC @@ -42,6 +41,7 @@ target_link_libraries(application-bell-main apps-common bellgui i18n + keymap module-gui service-gui time diff --git a/products/BellHybrid/apps/application-bell-main/include/application-bell-main/ApplicationBellMain.hpp b/products/BellHybrid/apps/application-bell-main/include/application-bell-main/ApplicationBellMain.hpp index f7988ed66e859bdab055f6141ee8b85aee82bc18..0316857cd25516ed179432da3cc8ed606d2c46a9 100644 --- a/products/BellHybrid/apps/application-bell-main/include/application-bell-main/ApplicationBellMain.hpp +++ b/products/BellHybrid/apps/application-bell-main/include/application-bell-main/ApplicationBellMain.hpp @@ -36,6 +36,10 @@ namespace app { return sys::ReturnCodes::Success; } + + private: + void showPopup(gui::popup::ID id, const gui::PopupRequestParams *params) override; + auto isHomeScreenFocused() -> bool; }; template <> struct ManifestTraits diff --git a/products/BellHybrid/apps/application-bell-main/presenters/KeyMap.hpp b/products/BellHybrid/apps/application-bell-main/presenters/KeyMap.hpp deleted file mode 100644 index 2a40a3ae76c411734286780c1700a6e43b017016..0000000000000000000000000000000000000000 --- a/products/BellHybrid/apps/application-bell-main/presenters/KeyMap.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// 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 - -namespace app::home_screen -{ - /// Key mapping structure to ease translation between PureOS key definitions and nomenclature used throughout the - /// GUI design - enum class KeyMap - { - Back = static_cast(gui::KeyCode::KEY_RF), - LightPress = static_cast(gui::KeyCode::KEY_ENTER), - RotateLeft = static_cast(gui::KeyCode::KEY_DOWN), - RotateRight = static_cast(gui::KeyCode::KEY_UP), - DeepPressUp = static_cast(gui::KeyCode::KEY_LEFT), - DeepPressDown = static_cast(gui::KeyCode::KEY_RIGHT), - }; - - inline static KeyMap mapKey(gui::KeyCode key) - { - return KeyMap{key}; - } -} // namespace app::home_screen diff --git a/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp b/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp index 23642314313c061c3294e28981fe23250779b192..0ce1be7cd543516db51444eec59051cd69455c7e 100644 --- a/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp +++ b/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp @@ -3,10 +3,11 @@ #include "StateController.hpp" #include "HomeScreenPresenter.hpp" -#include "KeyMap.hpp" #include "models/AlarmModel.hpp" #include "models/TimeModel.hpp" +#include + #include #include