diff --git a/module-apps/application-antenna/ApplicationAntenna.cpp b/module-apps/application-antenna/ApplicationAntenna.cpp index 000c314d9..79d39d5dd 100644 --- a/module-apps/application-antenna/ApplicationAntenna.cpp +++ b/module-apps/application-antenna/ApplicationAntenna.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/module-apps/application-antenna/include/application-antenna/ApplicationAntenna.hpp b/module-apps/application-antenna/include/application-antenna/ApplicationAntenna.hpp index 70a5ad45e..3e2f199ee 100644 --- a/module-apps/application-antenna/include/application-antenna/ApplicationAntenna.hpp +++ b/module-apps/application-antenna/include/application-antenna/ApplicationAntenna.hpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include namespace app diff --git a/module-apps/application-call/ApplicationCall.cpp b/module-apps/application-call/ApplicationCall.cpp index f943afe2e..f99d0be3a 100644 --- a/module-apps/application-call/ApplicationCall.cpp +++ b/module-apps/application-call/ApplicationCall.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/module-apps/application-call/include/application-call/ApplicationCall.hpp b/module-apps/application-call/include/application-call/ApplicationCall.hpp index 7908f525e..46bbbf40e 100644 --- a/module-apps/application-call/include/application-call/ApplicationCall.hpp +++ b/module-apps/application-call/include/application-call/ApplicationCall.hpp @@ -6,7 +6,7 @@ #include "Application.hpp" #include "CallState.hpp" -#include +#include #include #include #include diff --git a/module-apps/application-clock/ApplicationClock.cpp b/module-apps/application-clock/ApplicationClock.cpp new file mode 100644 index 000000000..fcd979b12 --- /dev/null +++ b/module-apps/application-clock/ApplicationClock.cpp @@ -0,0 +1,97 @@ +// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +// module-gui +#include "AppWindow.hpp" +#include "gui/widgets/Window.hpp" + +// module-utils +#include +#include +#include +#include +// MessageType +#include "MessageType.hpp" +// this module +#include "windows/ClockMainWindow.hpp" +#include "ApplicationClock.hpp" + +namespace app +{ + ApplicationClock::ApplicationClock(std::string name, + std::string parent, + sys::phone_modes::PhoneMode phoneMode, + sys::bluetooth::BluetoothMode bluetoothMode, + StartInBackground startInBackground, + uint32_t stackDepth, + sys::ServicePriority priority) + : Application(name, parent, phoneMode, bluetoothMode, startInBackground, stackDepth, priority) + { + timerClock = sys::TimerFactory::createPeriodicTimer( + this, "Clock", std::chrono::milliseconds{1000}, [&](sys::Timer &) { timerClockCallback(); }); + timerClock.start(); + } + + void ApplicationClock::timerClockCallback() + { + auto win = reinterpret_cast(windowsStack.get(gui::name::window::main_window)); + win->incrementSecond(); + win->updateLabels(); + render(gui::RefreshModes::GUI_REFRESH_FAST); + } + + // Invoked upon receiving data message + sys::MessagePointer ApplicationClock::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) + { + + auto retMsg = Application::DataReceivedHandler(msgl); + // if message was handled by application's template there is no need to process further. + if (reinterpret_cast(retMsg.get())->retCode == sys::ReturnCodes::Success) { + return retMsg; + } + + // this variable defines whether message was processed. + bool handled = false; + // if keyboard message received + + if (handled) + return std::make_shared(); + else + return std::make_shared(sys::ReturnCodes::Unresolved); + } + + // Invoked during initialization + sys::ReturnCodes ApplicationClock::InitHandler() + { + + auto ret = Application::InitHandler(); + if (ret != sys::ReturnCodes::Success) + return ret; + + createUserInterface(); + + setActiveWindow("MainWindow"); + + return ret; + } + + sys::ReturnCodes ApplicationClock::DeinitHandler() + { + timerClock.stop(); + return Application::DeinitHandler(); + } + + void ApplicationClock::createUserInterface() + { + windowsFactory.attach(gui::name::window::main_window, [](ApplicationCommon *app, const std::string &name) { + return std::make_unique(app, name); + }); + + attachPopups( + {gui::popup::ID::Volume, gui::popup::ID::Tethering, gui::popup::ID::PhoneModes, gui::popup::ID::PhoneLock}); + } + + void ApplicationClock::destroyUserInterface() + {} + +} /* namespace app */ diff --git a/module-apps/application-clock/ApplicationClock.hpp b/module-apps/application-clock/ApplicationClock.hpp new file mode 100644 index 000000000..09724eed7 --- /dev/null +++ b/module-apps/application-clock/ApplicationClock.hpp @@ -0,0 +1,51 @@ +// 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 "Application.hpp" +#include "Service/Message.hpp" +#include "gui/widgets/Label.hpp" +#include "gui/widgets/Image.hpp" +#include "gui/widgets/ProgressBar.hpp" +#include "Timers/TimerHandle.hpp" + +namespace app +{ + const inline std::string name_clock = "ApplicationClock"; + + class ApplicationClock : public Application + { + sys::TimerHandle timerClock; + void timerClockCallback(); + + public: + explicit ApplicationClock(std::string name = name_clock, + std::string parent = {}, + sys::phone_modes::PhoneMode phoneMode = sys::phone_modes::PhoneMode::Connected, + sys::bluetooth::BluetoothMode bluetoothMode = sys::bluetooth::BluetoothMode::Disabled, + StartInBackground startInBackground = {false}, + uint32_t stackDepth = 4096, + sys::ServicePriority priority = sys::ServicePriority::Idle); + + sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override; + sys::ReturnCodes InitHandler() override; + sys::ReturnCodes DeinitHandler() override; + + sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final + { + return sys::ReturnCodes::Success; + } + + void createUserInterface() override; + void destroyUserInterface() override; + }; + + template <> struct ManifestTraits + { + static auto GetManifest() -> manager::ApplicationManifest + { + return { + {manager::actions::Launch, manager::actions::PhoneModeChanged, manager::actions::BluetoothModeChanged}}; + } + }; +} /* namespace app */ diff --git a/module-apps/apps-common/ApplicationCommon.cpp b/module-apps/apps-common/ApplicationCommon.cpp index 43cd416c3..eee735640 100644 --- a/module-apps/apps-common/ApplicationCommon.cpp +++ b/module-apps/apps-common/ApplicationCommon.cpp @@ -2,11 +2,11 @@ // 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 "module-sys/Timers/TimerFactory.hpp" // for Timer +#include "Common.hpp" // for RefreshModes +#include "GuiTimer.hpp" // for GuiTimer +#include "Item.hpp" // for Item +#include "MessageType.hpp" // for MessageType +#include "Timers/TimerFactory.hpp" // for Timer #include "StatusBar.hpp" #include "status-bar/Time.hpp" #include "Translator.hpp" // for KeyInputSim... diff --git a/module-apps/apps-common/CallbackStorage.hpp b/module-apps/apps-common/CallbackStorage.hpp index f43311b93..6cc724078 100644 --- a/module-apps/apps-common/CallbackStorage.hpp +++ b/module-apps/apps-common/CallbackStorage.hpp @@ -5,7 +5,7 @@ #include "AsyncTask.hpp" -#include "module-sys/Service/Message.hpp" +#include "Service/Message.hpp" #include #include diff --git a/module-apps/apps-common/GuiTimer.cpp b/module-apps/apps-common/GuiTimer.cpp index 46374a2ab..1378e279d 100644 --- a/module-apps/apps-common/GuiTimer.cpp +++ b/module-apps/apps-common/GuiTimer.cpp @@ -6,8 +6,8 @@ #include // for Application -#include "module-sys/Timers/SystemTimer.hpp" // for Timer, Timer::Type, Timer::Ty... -#include "module-sys/Timers/TimerFactory.hpp" +#include "Timers/SystemTimer.hpp" // for Timer, Timer::Type, Timer::Ty... +#include "Timers/TimerFactory.hpp" #include diff --git a/module-apps/apps-common/GuiTimer.hpp b/module-apps/apps-common/GuiTimer.hpp index d1b28433d..9667ca61b 100644 --- a/module-apps/apps-common/GuiTimer.hpp +++ b/module-apps/apps-common/GuiTimer.hpp @@ -3,8 +3,8 @@ #pragma once -#include "module-sys/Timers/Timer.hpp" // for Timer -#include "module-sys/Timers/TimerHandle.hpp" // for TimerHandle +#include "Timers/Timer.hpp" // for Timer +#include "Timers/TimerHandle.hpp" // for TimerHandle #include #include // for string diff --git a/module-apps/apps-common/locks/handlers/PhoneLockHandler.cpp b/module-apps/apps-common/locks/handlers/PhoneLockHandler.cpp index b1f8aa3f9..5c340bc77 100644 --- a/module-apps/apps-common/locks/handlers/PhoneLockHandler.cpp +++ b/module-apps/apps-common/locks/handlers/PhoneLockHandler.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include