M products/BellHybrid/apps/application-bell-whats-new/ApplicationWhatsNew.cpp => products/BellHybrid/apps/application-bell-whats-new/ApplicationWhatsNew.cpp +12 -2
@@ 10,6 10,9 @@
#include "WhatsNewFeaturesModel.hpp"
#include <service-appmgr/Controller.hpp>
+#include <common/models/BatteryModel.hpp>
+#include <common/models/LowBatteryInfoModel.hpp>
+#include <common/windows/AppsBatteryStatusWindow.hpp>
#include <common/windows/BellFinishedWindow.hpp>
#include <system/messages/SentinelRegistrationMessage.hpp>
@@ 35,7 38,9 @@ namespace app
return ret;
}
- featuresModel = std::make_unique<whatsnew::models::WhatsNewFeaturesModel>(this, settings.get());
+ featuresModel = std::make_unique<whatsnew::models::WhatsNewFeaturesModel>(this, settings.get());
+ batteryModel = std::make_unique<app::BatteryModel>(this);
+ lowBatteryInfoModel = std::make_unique<app::LowBatteryInfoModel>();
cpuSentinel = std::make_shared<sys::CpuSentinel>(applicationWhatsNewName, this);
auto sentinelRegistrationMsg = std::make_shared<sys::SentinelRegistrationMessage>(cpuSentinel);
@@ 50,7 55,8 @@ namespace app
void ApplicationWhatsNew::createUserInterface()
{
windowsFactory.attach(whatsnew::window::name::main, [this](ApplicationCommon *app, const std::string &name) {
- auto presenter = std::make_unique<whatsnew::WhatsNewMainPresenter>(*featuresModel, settings.get());
+ auto presenter = std::make_unique<whatsnew::WhatsNewMainPresenter>(
+ app, *featuresModel, *batteryModel, *lowBatteryInfoModel, settings.get());
return std::make_unique<whatsnew::WhatsNewMainWindow>(app, std::move(presenter), name);
});
@@ 64,6 70,10 @@ namespace app
return std::make_unique<gui::BellFinishedWindow>(app, name);
});
+ windowsFactory.attach(whatsnew::window::name::lowBattery, [](ApplicationCommon *app, const std::string &name) {
+ return std::make_unique<gui::AppsBatteryStatusWindow>(app, name);
+ });
+
attachPopups({gui::popup::ID::AlarmActivated,
gui::popup::ID::AlarmDeactivated,
gui::popup::ID::PowerOff,
M products/BellHybrid/apps/application-bell-whats-new/data/WhatsNewCommon.hpp => products/BellHybrid/apps/application-bell-whats-new/data/WhatsNewCommon.hpp +1 -0
@@ 11,5 11,6 @@ namespace app::whatsnew
{
inline constexpr auto main = gui::name::window::main_window;
inline constexpr auto features = "WhatsNewFeaturesWindow";
+ inline constexpr auto lowBattery = "WhatsNewLowBatteryWindow";
} // namespace window::name
} // namespace app::whatsnew
M products/BellHybrid/apps/application-bell-whats-new/include/application-bell-whats-new/ApplicationWhatsNew.hpp => products/BellHybrid/apps/application-bell-whats-new/include/application-bell-whats-new/ApplicationWhatsNew.hpp +8 -0
@@ 12,6 12,12 @@ namespace app::whatsnew::models
namespace app
{
+ class AbstractBatteryModel;
+ class AbstractLowBatteryInfoModel;
+} // namespace app
+
+namespace app
+{
inline constexpr auto applicationWhatsNewName = "ApplicationWhatsNew";
inline constexpr auto applicationWhatsNewStackSize = 1024 * 14;
@@ 41,6 47,8 @@ namespace app
private:
std::shared_ptr<sys::CpuSentinel> cpuSentinel;
std::unique_ptr<whatsnew::models::WhatsNewFeaturesModel> featuresModel;
+ std::unique_ptr<AbstractBatteryModel> batteryModel;
+ std::unique_ptr<AbstractLowBatteryInfoModel> lowBatteryInfoModel;
};
template <>
M products/BellHybrid/apps/application-bell-whats-new/presenter/WhatsNewMainPresenter.cpp => products/BellHybrid/apps/application-bell-whats-new/presenter/WhatsNewMainPresenter.cpp +30 -2
@@ 2,14 2,24 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "WhatsNewMainPresenter.hpp"
+#include "WhatsNewCommon.hpp"
+#include <apps-common/ApplicationCommon.hpp>
+#include <common/models/BatteryModel.hpp>
+#include <common/models/LowBatteryInfoModel.hpp>
+#include <common/data/BatteryStatusSwitchData.hpp>
#include <service-db/Settings.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>
#include <product/version.hpp>
namespace app::whatsnew
{
- WhatsNewMainPresenter::WhatsNewMainPresenter(models::WhatsNewFeaturesModel &model, settings::Settings *settings)
- : model{model}, settings{settings}
+ WhatsNewMainPresenter::WhatsNewMainPresenter(app::ApplicationCommon *app,
+ models::WhatsNewFeaturesModel &model,
+ AbstractBatteryModel &batteryModel,
+ AbstractLowBatteryInfoModel &lowBatteryInfoModel,
+ settings::Settings *settings)
+ : app{app}, model{model}, batteryModel{batteryModel}, lowBatteryInfoModel{lowBatteryInfoModel}, settings{
+ settings}
{}
auto WhatsNewMainPresenter::setCurrentOsVersion() -> void
@@ 21,4 31,22 @@ namespace app::whatsnew
{
return model.getFeatures().size();
}
+
+ auto WhatsNewMainPresenter::showFeatures() -> void
+ {
+ auto switchToNextScreen = [this]() { app->switchWindow(window::name::features); };
+
+ const auto batteryState = batteryModel.getLevelState();
+ const units::SOC soc = batteryState.level;
+ const bool isCharging = batteryModel.isBatteryCharging(batteryState.state);
+ if (not lowBatteryInfoModel.isInfoHandled() && not isCharging && soc < constants::lowBatteryInfoThreshold) {
+ auto lowBatterySwitchData =
+ std::make_unique<gui::AppsBatteryStatusSwitchData>(soc, isCharging, switchToNextScreen);
+ app->switchWindow(window::name::lowBattery, std::move(lowBatterySwitchData));
+ lowBatteryInfoModel.handleInfo();
+ }
+ else {
+ switchToNextScreen();
+ }
+ }
} // namespace app::whatsnew
M products/BellHybrid/apps/application-bell-whats-new/presenter/WhatsNewMainPresenter.hpp => products/BellHybrid/apps/application-bell-whats-new/presenter/WhatsNewMainPresenter.hpp +17 -1
@@ 11,6 11,13 @@ namespace settings
class Settings;
}
+namespace app
+{
+ class ApplicationCommon;
+ class AbstractBatteryModel;
+ class AbstractLowBatteryInfoModel;
+} // namespace app
+
namespace app::whatsnew
{
class WhatsNewMainContract
@@ 28,18 35,27 @@ namespace app::whatsnew
virtual ~Presenter() = default;
virtual auto setCurrentOsVersion() -> void = 0;
virtual auto getFeaturesCount() -> bool = 0;
+ virtual auto showFeatures() -> void = 0;
};
};
class WhatsNewMainPresenter : public WhatsNewMainContract::Presenter
{
public:
- WhatsNewMainPresenter(models::WhatsNewFeaturesModel &model, settings::Settings *settings);
+ WhatsNewMainPresenter(app::ApplicationCommon *app,
+ models::WhatsNewFeaturesModel &model,
+ AbstractBatteryModel &batteryModel,
+ AbstractLowBatteryInfoModel &lowBatteryInfoModel,
+ settings::Settings *settings);
auto setCurrentOsVersion() -> void override;
auto getFeaturesCount() -> bool override;
+ auto showFeatures() -> void override;
private:
+ app::ApplicationCommon *app;
models::WhatsNewFeaturesModel &model;
+ AbstractBatteryModel &batteryModel;
+ AbstractLowBatteryInfoModel &lowBatteryInfoModel;
settings::Settings *settings{nullptr};
};
} // namespace app::whatsnew
M products/BellHybrid/apps/application-bell-whats-new/windows/WhatsNewMainWindow.cpp => products/BellHybrid/apps/application-bell-whats-new/windows/WhatsNewMainWindow.cpp +1 -1
@@ 34,7 34,7 @@ namespace app::whatsnew
};
addWinSettings(utils::translate("app_bell_whatsnew_continue"), [this]([[maybe_unused]] Item &item) {
- application->switchWindow(window::name::features);
+ presenter->showFeatures();
return true;
});
addWinSettings(utils::translate("app_bell_whatsnew_skip"), [this]([[maybe_unused]] Item &item) {