From feec59f5346b7b993271b88d5e5f5495fe4a2895 Mon Sep 17 00:00:00 2001 From: Lukasz Mastalerz Date: Thu, 19 Oct 2023 21:56:00 +0200 Subject: [PATCH] [BH-1696] Notification when connect the device to the charger Adding notifications when charger is connected --- harmony_changelog.md | 4 +- image/system_a/data/lang/Deutsch.json | 2 + image/system_a/data/lang/English.json | 2 + image/system_a/data/lang/Espanol.json | 2 + image/system_a/data/lang/Francais.json | 2 + image/system_a/data/lang/Polski.json | 2 + module-apps/apps-common/popups/Popups.cpp | 6 +- module-apps/apps-common/popups/Popups.hpp | 4 + .../battery/BatteryController.cpp | 34 ++++++- .../battery/BatteryController.hpp | 4 + .../service-evtmgr/BatteryMessages.hpp | 14 +++ products/BellHybrid/CMakeLists.txt | 4 +- products/BellHybrid/alarms/CMakeLists.txt | 2 + ...gingDoneNotificationPopupRequestParams.hpp | 16 +++ ...ChargingNotificationPopupRequestParams.hpp | 16 +++ products/BellHybrid/apps/Application.cpp | 13 +++ .../ApplicationBellAlarm.cpp | 4 +- .../ApplicationBellBedtime.cpp | 6 +- .../ApplicationBellMain.cpp | 4 +- .../MeditationTimer.cpp | 18 +++- .../ApplicationBellOnBoarding.cpp | 2 + .../ApplicationBellPowerNap.cpp | 6 +- .../ApplicationBellRelaxation.cpp | 4 +- .../ApplicationBellSettings.cpp | 4 +- .../BellHybrid/apps/common/CMakeLists.txt | 2 + .../popups/BedtimeNotificationWindow.hpp | 6 +- .../popups/ChargingNotificationWindow.hpp | 41 ++++++++ .../src/popups/BedtimeNotificationWindow.cpp | 4 +- .../src/popups/ChargingNotificationWindow.cpp | 98 +++++++++++++++++++ products/BellHybrid/assets/assets_common.json | 2 +- .../services/appmgr/ApplicationManager.cpp | 29 ++++++ 31 files changed, 333 insertions(+), 24 deletions(-) create mode 100644 products/BellHybrid/alarms/include/popups/ChargingDoneNotificationPopupRequestParams.hpp create mode 100644 products/BellHybrid/alarms/include/popups/ChargingNotificationPopupRequestParams.hpp create mode 100644 products/BellHybrid/apps/common/include/common/popups/ChargingNotificationWindow.hpp create mode 100644 products/BellHybrid/apps/common/src/popups/ChargingNotificationWindow.cpp diff --git a/harmony_changelog.md b/harmony_changelog.md index 09e0645466beaeb396222a0505962325782f8105..357cb3e82e1f16abf3427f0d075699940a532093 100644 --- a/harmony_changelog.md +++ b/harmony_changelog.md @@ -5,14 +5,12 @@ ### Fixed * Fixed frequency lock during user activity - ### Added - +* Added notification when charger is connected ### Changed / Improved * Disabled USB MTP protocol - ## [2.2.1 2023-10-30] ### Fixed diff --git a/image/system_a/data/lang/Deutsch.json b/image/system_a/data/lang/Deutsch.json index 92c57740c78fe1aaa021a4ecab66e330f018e602..b69cbf3867b910e25d9287f4258b55fa9aea9634 100644 --- a/image/system_a/data/lang/Deutsch.json +++ b/image/system_a/data/lang/Deutsch.json @@ -117,6 +117,8 @@ "app_bellmain_relaxation": "Entspannung", "app_bellmain_settings": "Einstellungen", "app_bellmain_usb_status_connected": "Verbunden", + "app_bell_charging_notification": "Wird aufgeladen", + "app_bell_charging_done_notification": "Vollst\u00e4ndig aufgeladen", "app_calculator_decimal_separator": ".", "app_calculator_equals": "GLEICH", "app_calculator_error": "Fehler", diff --git a/image/system_a/data/lang/English.json b/image/system_a/data/lang/English.json index 577b591b386424e91333bc26c366fc267cb2502d..d14669414387f58167d2eb065bef47ba202a36fb 100644 --- a/image/system_a/data/lang/English.json +++ b/image/system_a/data/lang/English.json @@ -152,6 +152,8 @@ "app_bellmain_relaxation": "Relaxation", "app_bellmain_settings": "Settings", "app_bellmain_usb_status_connected": "Connected", + "app_bell_charging_notification": "Charging", + "app_bell_charging_done_notification": "Fully charged", "app_calculator_decimal_separator": ".", "app_calculator_equals": "EQUALS", "app_calculator_error": "Error", diff --git a/image/system_a/data/lang/Espanol.json b/image/system_a/data/lang/Espanol.json index 206acbcda00447cb764718424c6d8cd6e62c08f8..75a9af5b2d56d4a09cf57cfbe863d71e2984c0ed 100644 --- a/image/system_a/data/lang/Espanol.json +++ b/image/system_a/data/lang/Espanol.json @@ -116,6 +116,8 @@ "app_bellmain_relaxation": "Relajaci\u00f3n", "app_bellmain_settings": "Ajustes", "app_bellmain_usb_status_connected": "Conectado", + "app_bell_charging_notification": "Cargando", + "app_bell_charging_done_notification": "Completamente cargado", "app_calculator_decimal_separator": ",", "app_calculator_equals": "IGUAL A", "app_calculator_error": "Error", diff --git a/image/system_a/data/lang/Francais.json b/image/system_a/data/lang/Francais.json index ad3aa82825eb6c4f11ccb59fc7f50cfd683c6820..d85eb3f2af9a81f598f91cd3fb06f3e24af738be 100644 --- a/image/system_a/data/lang/Francais.json +++ b/image/system_a/data/lang/Francais.json @@ -120,6 +120,8 @@ "app_bellmain_relaxation": "Bruits de fond", "app_bellmain_settings": "Param\u00e8tres", "app_bellmain_usb_status_connected": "Connect\u00e9", + "app_bell_charging_notification": "En charge", + "app_bell_charging_done_notification": "Compl\u00e8tement charg\u00e9", "app_calculator_decimal_separator": ",", "app_calculator_equals": "\u00c9QUIVAUT \u00c0", "app_calculator_error": "Erreur", diff --git a/image/system_a/data/lang/Polski.json b/image/system_a/data/lang/Polski.json index e4b527234c064698d880ac8281d88f6a182376aa..91aa598d7f9d1475b4fd4ca8a308104a28fddf7a 100644 --- a/image/system_a/data/lang/Polski.json +++ b/image/system_a/data/lang/Polski.json @@ -118,6 +118,8 @@ "app_bellmain_relaxation": "Relaks", "app_bellmain_settings": "Ustawienia", "app_bellmain_usb_status_connected": "Po\u0142\u0105czony", + "app_bell_charging_notification": "\u0141adowanie", + "app_bell_charging_done_notification": "W pe\u0142ni na\u0142adowany", "app_calculator_decimal_separator": ",", "app_calculator_equals": "WYNIK", "app_calculator_error": "B\u0142\u0105d", diff --git a/module-apps/apps-common/popups/Popups.cpp b/module-apps/apps-common/popups/Popups.cpp index 39bab9b204c3f9075cec2475f549dff716ffb84f..0de4fb2b5b1f7b1efed1671dbda465ee007fcd77 100644 --- a/module-apps/apps-common/popups/Popups.cpp +++ b/module-apps/apps-common/popups/Popups.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "Popups.hpp" @@ -52,6 +52,10 @@ namespace gui::popup return gui::popup::window::reboot_window; case ID::BedtimeNotification: return gui::popup::window::bedtime_notification_window; + case ID::ChargingNotification: + return gui::popup::window::charging_notification_window; + case ID::ChargingDoneNotification: + return gui::popup::window::charging_done_notification_window; case ID::AppTestPopup: return gui::popup::window::test_popup; case ID::Invalid: diff --git a/module-apps/apps-common/popups/Popups.hpp b/module-apps/apps-common/popups/Popups.hpp index c7a0bbd2ded850c7b691936a6b104b0d46a063c2..9451841fee89c3b05c1a96940f2c5d103f8eecae 100644 --- a/module-apps/apps-common/popups/Popups.hpp +++ b/module-apps/apps-common/popups/Popups.hpp @@ -32,6 +32,8 @@ namespace gui PowerOff, Reboot, BedtimeNotification, + ChargingNotification, + ChargingDoneNotification, AppTestPopup, Invalid, }; @@ -61,6 +63,8 @@ namespace gui inline constexpr auto alarm_window = "AlarmPopup"; inline constexpr auto reboot_window = "RebootPopup"; inline constexpr auto bedtime_notification_window = "BedtimeNotificationPopup"; + inline constexpr auto charging_notification_window = "ChargingNotificationPopup"; + inline constexpr auto charging_done_notification_window = "ChargingDoneNotificationPopup"; inline constexpr auto test_popup = "test_popup"; } // namespace window diff --git a/module-services/service-evtmgr/battery/BatteryController.cpp b/module-services/service-evtmgr/battery/BatteryController.cpp index 3349447e798a04bbfd20190b0f7ca51788eee5f0..f8e157e92c9cbd831129e1e7021d54f6fb2639db 100644 --- a/module-services/service-evtmgr/battery/BatteryController.cpp +++ b/module-services/service-evtmgr/battery/BatteryController.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -89,6 +90,16 @@ namespace return NewState::Unknown; } } + + bool isProperLastState(Store::Battery::State state) + { + return (state == Store::Battery::State::Discharging) || (state == Store::Battery::State::PluggedNotCharging); + } + + bool isProperCurrentState(Store::Battery::State state) + { + return (state == Store::Battery::State::Charging) || (state == Store::Battery::State::ChargingDone); + } } // namespace BatteryController::BatteryController(sys::Service *service, xQueueHandle notificationChannel, EventManagerParams params) @@ -176,8 +187,8 @@ void sevm::battery::BatteryController::update() Store::Battery::modify().state = transformChargingState(charger->getChargingStatus()); Store::Battery::modify().temperature = transformTemperatureState(charger->getTemperatureState()); - const auto currentSoc = Store::Battery::get().level; - const auto currentState = Store::Battery::get().state; + const auto currentSoc = Store::Battery::get().level; + const auto currentState = Store::Battery::get().state; const auto currentTemperature = Store::Battery::get().temperature; /// Send BatteryStatusChangeMessage only when battery SOC, charger state or temperature has changed @@ -186,6 +197,16 @@ void sevm::battery::BatteryController::update() service->bus.sendUnicast(std::move(message), service::name::evt_manager); } + if (isFirstUpdateDone) { + sendChargingNotification(lastState, currentState); + } + else { + if (lastState == Store::Battery::State::Discharging) { + sendChargingNotification(lastState, currentState); + } + isFirstUpdateDone = true; + } + batteryState.check(transformChargingState(Store::Battery::get().state), static_cast(Store::Battery::get().level)); @@ -224,3 +245,12 @@ void sevm::battery::BatteryController::checkChargerPresence() service->bus.sendUnicast(std::make_shared(plugEvent), service::name::service_desktop); chargerPresence = newChargerPresence; } + +void sevm::battery::BatteryController::sendChargingNotification(const Store::Battery::State &lastState, + const Store::Battery::State ¤tState) +{ + if (isProperLastState(lastState) && isProperCurrentState(currentState)) { + service->bus.sendUnicast(std::make_shared(transformChargingState(currentState)), + service::name::appmgr); + } +} diff --git a/module-services/service-evtmgr/battery/BatteryController.hpp b/module-services/service-evtmgr/battery/BatteryController.hpp index b241dc6176c0f46deb0e55098fca95bd94d4abac..d81ae04272ebef4f6b2b7a28eba0f2add018a32e 100644 --- a/module-services/service-evtmgr/battery/BatteryController.hpp +++ b/module-services/service-evtmgr/battery/BatteryController.hpp @@ -7,6 +7,7 @@ #include "EventManagerParams.hpp" #include "BatteryBrownoutDetector.hpp" #include "BatteryState.hpp" +#include "EventStore.hpp" #include #include @@ -32,6 +33,8 @@ namespace sevm::battery void updateSoc(); void printCurrentState(); void checkChargerPresence(); + void sendChargingNotification(const Store::Battery::State &lastState, + const Store::Battery::State ¤tState); units::Voltage getVoltage(); sys::Service *service{nullptr}; @@ -39,5 +42,6 @@ namespace sevm::battery BatteryBrownoutDetector brownoutDetector; BatteryState batteryState; ChargerPresence chargerPresence{ChargerPresence::Undefined}; + bool isFirstUpdateDone{false}; }; }; // namespace sevm::battery diff --git a/module-services/service-evtmgr/service-evtmgr/BatteryMessages.hpp b/module-services/service-evtmgr/service-evtmgr/BatteryMessages.hpp index f191cfd13c56a673a05a49f7ac34b60be561a656..133d2cca451ecd85df8fd277422a09dc71c0d49c 100644 --- a/module-services/service-evtmgr/service-evtmgr/BatteryMessages.hpp +++ b/module-services/service-evtmgr/service-evtmgr/BatteryMessages.hpp @@ -42,4 +42,18 @@ namespace sevm Event event = Event::CableUnplugged; }; + + class BatteryChargingMessage : public sys::DataMessage + { + public: + explicit BatteryChargingMessage(BatteryState::ChargingState chargingState) : chargingState{chargingState} {}; + + [[nodiscard]] BatteryState::ChargingState getChargingState() const + { + return chargingState; + } + + private: + BatteryState::ChargingState chargingState{BatteryState::ChargingState::Discharging}; + }; } // namespace sevm diff --git a/products/BellHybrid/CMakeLists.txt b/products/BellHybrid/CMakeLists.txt index 18701473122b25a47d272a33abcc68050d0d9038..0db747951ca97b1c4c390daeeb286aef88920f74 100644 --- a/products/BellHybrid/CMakeLists.txt +++ b/products/BellHybrid/CMakeLists.txt @@ -143,14 +143,14 @@ download_asset_release_json(json-common-target ${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_common.json ${SYSROOT_PATH}/system_a/ MuditaOSPublicAssets - 0.0.17 + 0.0.18 ${MUDITA_CACHE_DIR} ) download_asset_release_json(json-community-target ${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_community.json ${SYSROOT_PATH}/system_a/ MuditaOSPublicAssets - 0.0.17 + 0.0.18 ${MUDITA_CACHE_DIR} ) download_asset_json(json-rt1051-target diff --git a/products/BellHybrid/alarms/CMakeLists.txt b/products/BellHybrid/alarms/CMakeLists.txt index 97f53da8cc35f50fe1f8d7c02a0d76c0fbc92c2d..cf2125556d6763011677598b1c0375438c45db83 100644 --- a/products/BellHybrid/alarms/CMakeLists.txt +++ b/products/BellHybrid/alarms/CMakeLists.txt @@ -19,6 +19,8 @@ target_sources(alarms include/popups/AlarmActivatedPopupRequestParams.hpp include/popups/AlarmDeactivatedPopupRequestParams.hpp include/popups/BedtimeReminderPopupRequestParams.hpp + include/popups/ChargingNotificationPopupRequestParams.hpp + include/popups/ChargingDoneNotificationPopupRequestParams.hpp ) target_include_directories(alarms diff --git a/products/BellHybrid/alarms/include/popups/ChargingDoneNotificationPopupRequestParams.hpp b/products/BellHybrid/alarms/include/popups/ChargingDoneNotificationPopupRequestParams.hpp new file mode 100644 index 0000000000000000000000000000000000000000..87144fc630be0eba68eef01e5430dc95794decaa --- /dev/null +++ b/products/BellHybrid/alarms/include/popups/ChargingDoneNotificationPopupRequestParams.hpp @@ -0,0 +1,16 @@ +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include + +namespace gui +{ + class ChargingDoneNotificationPopupRequestParams : public PopupRequestParams + { + public: + ChargingDoneNotificationPopupRequestParams() : PopupRequestParams{gui::popup::ID::ChargingDoneNotification} + {} + }; +} // namespace gui diff --git a/products/BellHybrid/alarms/include/popups/ChargingNotificationPopupRequestParams.hpp b/products/BellHybrid/alarms/include/popups/ChargingNotificationPopupRequestParams.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9d2bcd734639a4f2586a07b3fed888abd17ff89b --- /dev/null +++ b/products/BellHybrid/alarms/include/popups/ChargingNotificationPopupRequestParams.hpp @@ -0,0 +1,16 @@ +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include + +namespace gui +{ + class ChargingNotificationPopupRequestParams : public PopupRequestParams + { + public: + ChargingNotificationPopupRequestParams() : PopupRequestParams{gui::popup::ID::ChargingNotification} + {} + }; +} // namespace gui diff --git a/products/BellHybrid/apps/Application.cpp b/products/BellHybrid/apps/Application.cpp index 98067ae39322a2b7fa43923b1580eb9620a8d220..be497c1e5cdee1c40eb7e8c85ef2545f752c1279 100644 --- a/products/BellHybrid/apps/Application.cpp +++ b/products/BellHybrid/apps/Application.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace app @@ -101,6 +102,18 @@ namespace app return std::make_unique(app); }); break; + case ID::ChargingNotification: + windowsFactory.attach(window::charging_notification_window, + [](app::ApplicationCommon *app, const std::string &name) { + return std::make_unique(app); + }); + break; + case ID::ChargingDoneNotification: + windowsFactory.attach(window::charging_done_notification_window, + [](app::ApplicationCommon *app, const std::string &name) { + return std::make_unique(app); + }); + break; default: break; } diff --git a/products/BellHybrid/apps/application-bell-alarm/ApplicationBellAlarm.cpp b/products/BellHybrid/apps/application-bell-alarm/ApplicationBellAlarm.cpp index c9114921ec78947d8b9c8e0acb62c6bce26a7284..c454a94a4d97fef5cf586cefef97acd3863f4e31 100644 --- a/products/BellHybrid/apps/application-bell-alarm/ApplicationBellAlarm.cpp +++ b/products/BellHybrid/apps/application-bell-alarm/ApplicationBellAlarm.cpp @@ -61,7 +61,9 @@ namespace app gui::popup::ID::AlarmDeactivated, gui::popup::ID::PowerOff, gui::popup::ID::Reboot, - gui::popup::ID::BedtimeNotification}); + gui::popup::ID::BedtimeNotification, + gui::popup::ID::ChargingNotification, + gui::popup::ID::ChargingDoneNotification}); } sys::MessagePointer ApplicationBellAlarm::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) diff --git a/products/BellHybrid/apps/application-bell-bedtime/ApplicationBellBedtime.cpp b/products/BellHybrid/apps/application-bell-bedtime/ApplicationBellBedtime.cpp index 6d9e12da342f4b96eeaa9215d56388f35585a560..2d26be4bbdbc5865fa82663caaa86a4b0802cea5 100644 --- a/products/BellHybrid/apps/application-bell-bedtime/ApplicationBellBedtime.cpp +++ b/products/BellHybrid/apps/application-bell-bedtime/ApplicationBellBedtime.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "ApplicationBellBedtime.hpp" @@ -48,7 +48,9 @@ namespace app attachPopups({gui::popup::ID::AlarmActivated, gui::popup::ID::AlarmDeactivated, gui::popup::ID::PowerOff, - gui::popup::ID::Reboot}); + gui::popup::ID::Reboot, + gui::popup::ID::ChargingNotification, + gui::popup::ID::ChargingDoneNotification}); } sys::MessagePointer ApplicationBellBedtime::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) diff --git a/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp b/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp index 42bdfd94b0d663fe7a42f4710a7d954fdc3c7a16..26f7f2345f9ef3e889d1056e019b725fcc5925a8 100644 --- a/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp +++ b/products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp @@ -159,7 +159,9 @@ namespace app gui::popup::ID::AlarmDeactivated, gui::popup::ID::PowerOff, gui::popup::ID::Reboot, - gui::popup::ID::BedtimeNotification}); + gui::popup::ID::BedtimeNotification, + gui::popup::ID::ChargingNotification, + gui::popup::ID::ChargingDoneNotification}); } sys::MessagePointer ApplicationBellMain::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) diff --git a/products/BellHybrid/apps/application-bell-meditation-timer/MeditationTimer.cpp b/products/BellHybrid/apps/application-bell-meditation-timer/MeditationTimer.cpp index d215c1b0a6e3ffb4bec1f5b66b2d2e83c63f5a27..6ed32a0cbc9e7f331314ea6a698b678808e543bd 100644 --- a/products/BellHybrid/apps/application-bell-meditation-timer/MeditationTimer.cpp +++ b/products/BellHybrid/apps/application-bell-meditation-timer/MeditationTimer.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "MeditationTimer.hpp" @@ -17,6 +17,7 @@ #include "presenter/SettingsPresenter.hpp" #include "presenter/StatisticsPresenter.hpp" +#include "apps-common/WindowsPopupFilter.hpp" #include #include @@ -32,6 +33,17 @@ namespace app uint32_t stackDepth) : Application(std::move(name), std::move(parent), statusIndicators, startInBackground, stackDepth) { + getPopupFilter().addAppDependentFilter([&](const gui::PopupRequestParams ¶ms) { + const auto popupId = params.getPopupId(); + if (popupId == gui::popup::ID::ChargingNotification || + popupId == gui::popup::ID::ChargingDoneNotification) { + return gui::window::bell_finished::defaultName != getCurrentWindow()->getName() + ? gui::popup::FilterType::Show + : gui::popup::FilterType::Remove; + } + return gui::popup::FilterType::Show; + }); + bus.channels.push_back(sys::BusChannel::ServiceAudioNotifications); } @@ -105,7 +117,9 @@ namespace app gui::popup::ID::AlarmDeactivated, gui::popup::ID::PowerOff, gui::popup::ID::Reboot, - gui::popup::ID::BedtimeNotification}); + gui::popup::ID::BedtimeNotification, + gui::popup::ID::ChargingNotification, + gui::popup::ID::ChargingDoneNotification}); } sys::MessagePointer MeditationTimer::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) diff --git a/products/BellHybrid/apps/application-bell-onboarding/ApplicationBellOnBoarding.cpp b/products/BellHybrid/apps/application-bell-onboarding/ApplicationBellOnBoarding.cpp index de840d6fa3abfb9185e425435ab4b0bbfae8840a..f5154de9bc8f1c9aaaef6d65ce962e996b6ed876 100644 --- a/products/BellHybrid/apps/application-bell-onboarding/ApplicationBellOnBoarding.cpp +++ b/products/BellHybrid/apps/application-bell-onboarding/ApplicationBellOnBoarding.cpp @@ -139,6 +139,8 @@ namespace app [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, name); }); + + attachPopups({gui::popup::ID::ChargingNotification, gui::popup::ID::ChargingDoneNotification}); } void ApplicationBellOnBoarding::destroyUserInterface() diff --git a/products/BellHybrid/apps/application-bell-powernap/ApplicationBellPowerNap.cpp b/products/BellHybrid/apps/application-bell-powernap/ApplicationBellPowerNap.cpp index 158151fb3ab8a8da3ceeffb3d1f49af14b20b2db..92cae3c5bf71504ba13b10d832185f672b790bf8 100644 --- a/products/BellHybrid/apps/application-bell-powernap/ApplicationBellPowerNap.cpp +++ b/products/BellHybrid/apps/application-bell-powernap/ApplicationBellPowerNap.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "ApplicationBellPowerNap.hpp" @@ -73,7 +73,9 @@ namespace app gui::popup::ID::AlarmDeactivated, gui::popup::ID::PowerOff, gui::popup::ID::Reboot, - gui::popup::ID::BedtimeNotification}); + gui::popup::ID::BedtimeNotification, + gui::popup::ID::ChargingNotification, + gui::popup::ID::ChargingDoneNotification}); } sys::MessagePointer ApplicationBellPowerNap::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) diff --git a/products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp b/products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp index 677b6c7a34acb3323686e6d34668818ffd6494c2..1dee2d52853342dc4af68d09ba7b258f27330913 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp @@ -125,7 +125,9 @@ namespace app gui::popup::ID::AlarmDeactivated, gui::popup::ID::PowerOff, gui::popup::ID::Reboot, - gui::popup::ID::BedtimeNotification}); + gui::popup::ID::BedtimeNotification, + gui::popup::ID::ChargingNotification, + gui::popup::ID::ChargingDoneNotification}); } sys::MessagePointer ApplicationBellRelaxation::DataReceivedHandler(sys::DataMessage *msgl, diff --git a/products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp b/products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp index e186ed4522b3ae00af603126282e235750396240..2e5dced71ab3aec932f654353fc4a04f6bf4b71e 100644 --- a/products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp +++ b/products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp @@ -244,7 +244,9 @@ namespace app gui::popup::ID::AlarmDeactivated, gui::popup::ID::PowerOff, gui::popup::ID::Reboot, - gui::popup::ID::BedtimeNotification}); + gui::popup::ID::BedtimeNotification, + gui::popup::ID::ChargingNotification, + gui::popup::ID::ChargingDoneNotification}); } sys::MessagePointer ApplicationBellSettings::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) diff --git a/products/BellHybrid/apps/common/CMakeLists.txt b/products/BellHybrid/apps/common/CMakeLists.txt index 2622e32ccd5624d67b62d3491941d7372c13d546..95a4e7c3de8a93bf9522a402a80414c54e77382c 100644 --- a/products/BellHybrid/apps/common/CMakeLists.txt +++ b/products/BellHybrid/apps/common/CMakeLists.txt @@ -37,6 +37,7 @@ target_sources(application-bell-common src/popups/AlarmDeactivatedWindow.cpp src/popups/BellTurnOffOptionWindow.cpp src/popups/BellRebootWindow.cpp + src/popups/ChargingNotificationWindow.cpp src/popups/presenter/AlarmActivatedPresenter.cpp src/widgets/AlarmIcon.cpp src/widgets/ListItems.cpp @@ -98,6 +99,7 @@ target_sources(application-bell-common include/common/popups/BedtimeNotificationWindow.hpp include/common/popups/BellTurnOffOptionWindow.hpp include/common/popups/BellRebootWindow.hpp + include/common/popups/ChargingNotificationWindow.hpp include/common/widgets/AlarmIcon.hpp include/common/widgets/BellBattery.hpp include/common/widgets/BellConnectionStatus.hpp diff --git a/products/BellHybrid/apps/common/include/common/popups/BedtimeNotificationWindow.hpp b/products/BellHybrid/apps/common/include/common/popups/BedtimeNotificationWindow.hpp index f3dfafb0d3cbf7cac19eff37d2fb3236c0fe9099..47a804d7d86363dcd8e430c12b2a46ad4f6e3488 100644 --- a/products/BellHybrid/apps/common/include/common/popups/BedtimeNotificationWindow.hpp +++ b/products/BellHybrid/apps/common/include/common/popups/BedtimeNotificationWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -18,8 +18,8 @@ namespace gui { private: static constexpr auto bedtimeNotificationIcon = "big_bedtime_W_G"; - static constexpr auto bedtimeNotificationText = "app_bell_bedtime_notification"; - static constexpr auto bedtimeNotificationTimout = std::chrono::seconds{6}; + static constexpr auto bedtimeNotificationText = "app_bell_bedtime_notification"; + static constexpr auto bedtimeNotificationTimeout = std::chrono::seconds{6}; app::ApplicationCommon *app; Icon *icon = nullptr; diff --git a/products/BellHybrid/apps/common/include/common/popups/ChargingNotificationWindow.hpp b/products/BellHybrid/apps/common/include/common/popups/ChargingNotificationWindow.hpp new file mode 100644 index 0000000000000000000000000000000000000000..992ea2e8f88e57200b4568c7328d10278f44b5de --- /dev/null +++ b/products/BellHybrid/apps/common/include/common/popups/ChargingNotificationWindow.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include +#include + +namespace app +{ + class ApplicationCommon; +} +namespace gui +{ + namespace charging_notification + {} // namespace charging_notification + + class Icon; + + class ChargingNotificationWindow : public WindowWithTimer, public app::AsyncCallbackReceiver + { + protected: + app::ApplicationCommon *app; + Icon *icon = nullptr; + + bool onInput(const InputEvent &inputEvent) override; + void returnToPreviousWindow(); + void buildInterface() override; + + public: + explicit ChargingNotificationWindow(app::ApplicationCommon *app); + void onBeforeShow(ShowMode mode, SwitchData *data) override; + }; + + class ChargingDoneNotificationWindow : public ChargingNotificationWindow + { + public: + explicit ChargingDoneNotificationWindow(app::ApplicationCommon *app); + void onBeforeShow(ShowMode mode, SwitchData *data) override; + }; +} /* namespace gui */ diff --git a/products/BellHybrid/apps/common/src/popups/BedtimeNotificationWindow.cpp b/products/BellHybrid/apps/common/src/popups/BedtimeNotificationWindow.cpp index ad964ad3e2cc40969578b7fdaa1baaf8cad1ba2c..aa0fb10cdd1cb658df92ba1115a34fc29b0c3159 100644 --- a/products/BellHybrid/apps/common/src/popups/BedtimeNotificationWindow.cpp +++ b/products/BellHybrid/apps/common/src/popups/BedtimeNotificationWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include