M products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp => products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp +8 -10
@@ 13,20 13,16 @@
#include <apps-common/messages/AppMessage.hpp>
#include <common/BellPowerOffPresenter.hpp>
#include <common/layouts/HomeScreenLayouts.hpp>
-#include <common/models/AlarmModel.hpp>
#include <common/models/TimeModel.hpp>
#include <common/models/LayoutModel.hpp>
#include <common/windows/BellWelcomeWindow.hpp>
#include <common/windows/BellFactoryReset.hpp>
#include <service-db/DBNotificationMessage.hpp>
#include <windows/Dialog.hpp>
-#include <service-appmgr/Controller.hpp>
#include <appmgr/messages/ChangeHomescreenLayoutMessage.hpp>
#include <appmgr/messages/ChangeHomescreenLayoutParams.hpp>
#include <system/messages/SystemManagerMessage.hpp>
-#include <common/popups/BedtimeNotificationWindow.hpp>
#include <apps-common/WindowsPopupFilter.hpp>
-#include <common/windows/BellTurnOffWindow.hpp>
#include <WindowsStack.hpp>
#include <popups/Popups.hpp>
@@ 80,11 76,11 @@ namespace app
return ret;
}
- auto timeModel = std::make_unique<app::TimeModel>();
- auto batteryModel = std::make_unique<app::home_screen::BatteryModel>(this);
- auto temperatureModel = std::make_unique<app::home_screen::TemperatureModel>(this);
- homeScreenPresenter = std::make_shared<app::home_screen::HomeScreenPresenter>(
- this, std::move(alarmModel), std::move(batteryModel), std::move(temperatureModel), std::move(timeModel));
+ timeModel = std::make_unique<app::TimeModel>();
+ batteryModel = std::make_unique<app::home_screen::BatteryModel>(this);
+ temperatureModel = std::make_unique<app::home_screen::TemperatureModel>(this);
+ homeScreenPresenter = std::make_shared<app::home_screen::HomeScreenPresenter>(
+ this, *alarmModel, *batteryModel, *temperatureModel, *timeModel);
createUserInterface();
@@ 161,7 157,7 @@ namespace app
sys::MessagePointer ApplicationBellMain::handleSwitchWindow(sys::Message *msgl)
{
auto msg = static_cast<AppSwitchWindowMessage *>(msgl);
- if (msg) {
+ if (msg != nullptr) {
const auto newWindowName = msg->getWindowName();
if (newWindowName == gui::name::window::main_window) {
stopIdleTimer();
@@ 186,4 182,6 @@ namespace app
homeScreenPresenter->setLayout(layoutGenerator);
return true;
}
+
+ ApplicationBellMain::~ApplicationBellMain() = default;
} // namespace app
M products/BellHybrid/apps/application-bell-main/include/application-bell-main/ApplicationBellMain.hpp => products/BellHybrid/apps/application-bell-main/include/application-bell-main/ApplicationBellMain.hpp +5 -1
@@ 27,6 27,7 @@ namespace app
StatusIndicators statusIndicators = StatusIndicators{},
StartInBackground startInBackground = {false},
std::uint32_t stackDepth = 1024 * 15);
+ ~ApplicationBellMain();
sys::ReturnCodes InitHandler() override;
@@ 46,7 47,10 @@ namespace app
sys::MessagePointer handleSwitchWindow(sys::Message *msgl) override;
bool setHomeScreenLayout(std::string layoutName);
- std::shared_ptr<app::home_screen::HomeScreenPresenter> homeScreenPresenter{};
+ std::unique_ptr<home_screen::AbstractBatteryModel> batteryModel;
+ std::unique_ptr<home_screen::AbstractTemperatureModel> temperatureModel;
+ std::unique_ptr<AbstractTimeModel> timeModel;
+ std::shared_ptr<app::home_screen::HomeScreenPresenter> homeScreenPresenter;
};
template <> struct ManifestTraits<ApplicationBellMain>
M products/BellHybrid/apps/application-bell-main/include/application-bell-main/presenters/HomeScreenPresenter.hpp => products/BellHybrid/apps/application-bell-main/include/application-bell-main/presenters/HomeScreenPresenter.hpp +9 -9
@@ 104,10 104,10 @@ namespace app::home_screen
{
public:
HomeScreenPresenter(ApplicationCommon *app,
- std::unique_ptr<AbstractAlarmModel> alarmModel,
- std::unique_ptr<AbstractBatteryModel> batteryModel,
- std::unique_ptr<AbstractTemperatureModel> temperatureModel,
- std::unique_ptr<AbstractTimeModel> timeModel);
+ AbstractAlarmModel &alarmModel,
+ AbstractBatteryModel &batteryModel,
+ AbstractTemperatureModel &temperatureModel,
+ AbstractTimeModel &timeModel);
virtual ~HomeScreenPresenter();
HomeScreenPresenter() = delete;
HomeScreenPresenter &operator=(const HomeScreenPresenter &oth) = delete;
@@ 146,11 146,11 @@ namespace app::home_screen
private:
ApplicationCommon *app;
sys::TimerHandle timer;
- std::unique_ptr<AbstractAlarmModel> alarmModel;
- std::unique_ptr<AbstractBatteryModel> batteryModel;
- std::unique_ptr<AbstractTemperatureModel> temperatureModel;
- std::unique_ptr<AbstractTimeModel> timeModel;
- std::shared_ptr<AbstractController> stateController;
+ AbstractAlarmModel &alarmModel;
+ AbstractBatteryModel &batteryModel;
+ AbstractTemperatureModel &temperatureModel;
+ AbstractTimeModel &timeModel;
+ std::unique_ptr<AbstractController> stateController;
std::unique_ptr<ProgressTimerWithSnoozeTimer> snoozeTimer;
std::unique_ptr<std::mt19937> rngEngine;
M products/BellHybrid/apps/application-bell-main/presenters/HomeScreenPresenter.cpp => products/BellHybrid/apps/application-bell-main/presenters/HomeScreenPresenter.cpp +18 -19
@@ 70,18 70,17 @@ namespace
namespace app::home_screen
{
HomeScreenPresenter::HomeScreenPresenter(ApplicationCommon *app,
- std::unique_ptr<AbstractAlarmModel> alarmModel,
- std::unique_ptr<AbstractBatteryModel> batteryModel,
- std::unique_ptr<AbstractTemperatureModel> temperatureModel,
- std::unique_ptr<AbstractTimeModel> timeModel)
- : app{app}, alarmModel{std::move(alarmModel)}, batteryModel{std::move(batteryModel)},
- temperatureModel{std::move(temperatureModel)}, timeModel{std::move(timeModel)},
- rngEngine{std::make_unique<std::mt19937>(std::random_device{}())}
+ AbstractAlarmModel &alarmModel,
+ AbstractBatteryModel &batteryModel,
+ AbstractTemperatureModel &temperatureModel,
+ AbstractTimeModel &timeModel)
+ : app{app}, alarmModel{alarmModel}, batteryModel{batteryModel}, temperatureModel{temperatureModel},
+ timeModel{timeModel}, rngEngine{std::make_unique<std::mt19937>(std::random_device{}())}
{}
void HomeScreenPresenter::handleUpdateTimeEvent()
{
- getView()->setTime(timeModel->getCurrentTime());
+ getView()->setTime(timeModel.getCurrentTime());
stateController->handleTimeUpdateEvent();
handleCyclicDeepRefresh();
}
@@ 122,16 121,16 @@ namespace app::home_screen
void HomeScreenPresenter::onBeforeShow()
{
stateController->resetStateMachine();
- getView()->setTimeFormat(timeModel->getTimeFormat());
- getView()->setTime(timeModel->getCurrentTime());
- getView()->setAlarmTimeFormat(timeModel->getTimeFormat());
- getView()->setSnoozeFormat(timeModel->getTimeFormat());
- getView()->setTemperature(temperatureModel->getTemperature());
+ getView()->setTimeFormat(timeModel.getTimeFormat());
+ getView()->setTime(timeModel.getCurrentTime());
+ getView()->setAlarmTimeFormat(timeModel.getTimeFormat());
+ getView()->setSnoozeFormat(timeModel.getTimeFormat());
+ getView()->setTemperature(temperatureModel.getTemperature());
}
void HomeScreenPresenter::createData()
{
- stateController = std::make_unique<StateController>(
- *getView(), *this, *batteryModel, *temperatureModel, *alarmModel, *timeModel);
+ stateController =
+ std::make_unique<StateController>(*getView(), *this, batteryModel, temperatureModel, alarmModel, timeModel);
}
void HomeScreenPresenter::refreshWindow()
@@ 141,12 140,12 @@ namespace app::home_screen
void HomeScreenPresenter::onDatabaseMessage(db::NotificationMessage *msg)
{
if (msg->interface == db::Interface::Name::AlarmEvents && msg->type == db::Query::Type::Update) {
- alarmModel->update();
+ alarmModel.update();
}
}
void HomeScreenPresenter::handleAlarmModelReady()
{
- getView()->setAlarmTime(alarmModel->getAlarmTime());
+ getView()->setAlarmTime(alarmModel.getAlarmTime());
stateController->handleAlarmModelReady();
}
@@ 173,12 172,12 @@ namespace app::home_screen
std::uint32_t HomeScreenPresenter::getBatteryLvl() const
{
- return batteryModel->getLevelState().level;
+ return batteryModel.getLevelState().level;
}
bool HomeScreenPresenter::isBatteryCharging() const
{
- return batteryModel->getLevelState().state == Store::Battery::State::Charging;
+ return batteryModel.getLevelState().state == Store::Battery::State::Charging;
}
bool HomeScreenPresenter::isAlarmActivatedByLatch() const