M changelog.md => changelog.md +4 -0
@@ 1,6 1,10 @@
# MuditaOS changelog
## Current release
+### Fixed
+* `[settings]` Fix lack of sim at startup
+* `[settings]` Fix Network All Operators display condition
+* `[settings]` Fix Network window items indentation
### Added
M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +29 -1
@@ 35,6 35,11 @@
namespace app
{
+ namespace settings
+ {
+ constexpr inline auto operators_on = "operators_on";
+ }
+
ApplicationSettingsNew::ApplicationSettingsNew(std::string name,
std::string parent,
StartInBackground startInBackground)
@@ 44,6 49,13 @@ namespace app
Store::GSM::get()->sim == selectedSim) {
selectedSimNumber = CellularServiceAPI::GetOwnNumber(this);
}
+ settings->registerValueChange(settings::operators_on,
+ [this](const std::string &value) { operatorOnChanged(value); });
+ }
+
+ ApplicationSettingsNew::~ApplicationSettingsNew()
+ {
+ settings->unregisterValueChange(settings::operators_on);
}
// Invoked upon receiving data message
@@ 143,7 155,8 @@ namespace app
return std::make_unique<gui::NightshiftWindow>(app);
});
windowsFactory.attach(gui::window::name::network, [](Application *app, const std::string &name) {
- return std::make_unique<gui::NetworkWindow>(app, dynamic_cast<SimParams *>(app));
+ return std::make_unique<gui::NetworkWindow>(
+ app, static_cast<ApplicationSettingsNew *>(app), static_cast<ApplicationSettingsNew *>(app));
});
windowsFactory.attach(gui::window::name::messages, [](Application *app, const std::string &name) {
return std::make_unique<gui::MessagesWindow>(app);
@@ 186,4 199,19 @@ namespace app
return selectedSim;
}
+ void ApplicationSettingsNew::operatorOnChanged(const std::string &value)
+ {
+ if (!value.empty()) {
+ operatorsOn = utils::getNumericValue<bool>(value);
+ }
+ }
+ bool ApplicationSettingsNew::getOperatorsOn() const noexcept
+ {
+ return operatorsOn;
+ }
+ void ApplicationSettingsNew::setOperatorsOn(bool value)
+ {
+ operatorsOn = value;
+ settings->setValue(settings::operators_on, std::to_string(value));
+ }
} /* namespace app */
M module-apps/application-settings-new/ApplicationSettings.hpp => module-apps/application-settings-new/ApplicationSettings.hpp +18 -3
@@ 58,14 58,24 @@ namespace app
virtual Store::GSM::SIM getSim() = 0;
virtual std::string getNumber() = 0;
};
- } // namespace settingsInterface
+ class OperatorsSettings
+ {
+ public:
+ virtual ~OperatorsSettings() = default;
+ virtual void setOperatorsOn(bool value) = 0;
+ [[nodiscard]] virtual bool getOperatorsOn() const noexcept = 0;
+ };
+ }; // namespace settingsInterface
- class ApplicationSettingsNew : public app::Application, public settingsInterface::SimParams
+ class ApplicationSettingsNew : public app::Application,
+ public settingsInterface::SimParams,
+ public settingsInterface::OperatorsSettings
{
public:
ApplicationSettingsNew(std::string name = name_settings_new,
std::string parent = {},
StartInBackground startInBackground = {false});
+ ~ApplicationSettingsNew() override;
auto DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) -> sys::MessagePointer override;
auto InitHandler() -> sys::ReturnCodes override;
@@ 79,11 89,16 @@ namespace app
void setSim(Store::GSM::SIM sim) override;
Store::GSM::SIM getSim() override;
std::string getNumber() override;
- bsp::Board board = bsp::Board::none;
+
+ void operatorOnChanged(const std::string &value);
+ void setOperatorsOn(bool value) override;
+ bool getOperatorsOn() const noexcept override;
private:
Store::GSM::SIM selectedSim = Store::GSM::get()->selected;
std::string selectedSimNumber = {};
+ bsp::Board board = bsp::Board::none;
+ bool operatorsOn = false;
};
template <> struct ManifestTraits<ApplicationSettingsNew>
M module-apps/application-settings-new/windows/NetworkWindow.cpp => module-apps/application-settings-new/windows/NetworkWindow.cpp +16 -9
@@ 10,10 10,11 @@
namespace gui
{
- NetworkWindow::NetworkWindow(app::Application *app, app::settingsInterface::SimParams *simParams)
- : OptionWindow(app, gui::window::name::network), simParams(simParams)
+ NetworkWindow::NetworkWindow(app::Application *app,
+ app::settingsInterface::SimParams *simParams,
+ app::settingsInterface::OperatorsSettings *operatorsSettings)
+ : OptionWindow(app, gui::window::name::network), simParams(simParams), operatorsSettings(operatorsSettings)
{
- operatorsOn = false;
}
void NetworkWindow::onBeforeShow(ShowMode m, SwitchData *d)
{
@@ 39,6 40,7 @@ namespace gui
phoneNumber = {};
break;
}
+ auto operatorsOn = operatorsSettings->getOperatorsOn();
optList.emplace_back(std::make_unique<gui::OptionSettings>(
utils::translateI18("app_settings_network_active_card") + ":" + simStr + " / " + phoneNumber,
[=](gui::Item &item) {
@@ 63,17 65,18 @@ namespace gui
return true;
},
this));
+
optList.emplace_back(std::make_unique<gui::OptionSettings>(
utils::translateI18("app_settings_network_operator_auto_select"),
[=](gui::Item &item) {
- operatorsOn = !operatorsOn;
+ operatorsSettings->setOperatorsOn(!operatorsOn);
rebuild();
return true;
},
nullptr,
nullptr,
operatorsOn ? RightItem::On : RightItem::Off));
- if (operatorsOn) {
+ if (!operatorsOn) {
optList.emplace_back(std::make_unique<gui::OptionSettings>(
utils::translateI18("app_settings_network_all_operators"),
[=](gui::Item &item) {
@@ 82,13 85,17 @@ namespace gui
},
nullptr,
nullptr,
- RightItem::ArrowWhite));
+ RightItem::ArrowWhite,
+ true));
}
- optList.emplace_back(gui::Option{
- utils::translateI18("app_settings_network_import_contacts_from_sim_card"), [=](gui::Item &item) {
+ optList.emplace_back(std::make_unique<gui::OptionSettings>(
+ utils::translateI18("app_settings_network_import_contacts_from_sim_card"),
+ [=](gui::Item &item) {
this->application->switchWindow(gui::window::name::import_contacts, nullptr);
return true;
- }});
+ },
+ nullptr,
+ nullptr));
bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::select));
M module-apps/application-settings-new/windows/NetworkWindow.hpp => module-apps/application-settings-new/windows/NetworkWindow.hpp +8 -5
@@ 9,7 9,8 @@
namespace app::settingsInterface
{
class SimParams;
-}
+ class OperatorsSettings;
+}; // namespace app::settingsInterface
namespace gui
{
@@ 22,13 23,15 @@ namespace gui
class NetworkWindow : public OptionWindow
{
private:
- bool operatorsOn;
- app::settingsInterface::SimParams *simParams;
auto netOptList() -> std::list<gui::Option>;
- void rebuild() override;
+ app::settingsInterface::SimParams *simParams;
+ void rebuild();
+ app::settingsInterface::OperatorsSettings *operatorsSettings;
public:
- NetworkWindow(app::Application *app, app::settingsInterface::SimParams *simParams);
+ NetworkWindow(app::Application *app,
+ app::settingsInterface::SimParams *simParams,
+ app::settingsInterface::OperatorsSettings *operatorsSettings);
void onBeforeShow(ShowMode m, SwitchData *d) override;
};
} // namespace gui
M module-apps/windows/OptionSetting.cpp => module-apps/windows/OptionSetting.cpp +5 -1
@@ 14,7 14,8 @@ namespace gui
optionBodyHBox->focusChangedCallback = focusCb;
style::window::decorate(optionBodyHBox);
- auto optionNameLabel = new Label(optionBodyHBox, 0, 0, 0, 0, text);
+ auto optionNameLabel =
+ new Label(optionBodyHBox, indent ? style::window::default_left_margin : 0, 0, 0, 0, text);
optionNameLabel->setEdges(RectangleEdge::None);
optionNameLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
optionNameLabel->setFont(style::window::font::big);
@@ 51,6 52,9 @@ namespace gui
auto image = new gui::Image(optionBodyHBox, 0, 0, 0, 0, imageName);
optionRightItemWidth = image->getWidth();
}
+ if (indent) {
+ optionRightItemWidth += style::window::default_left_margin;
+ }
optionNameLabel->setMinimumSize(style::window::default_body_width - optionRightItemWidth,
style::window::label::big_h);
M module-apps/windows/OptionSetting.hpp => module-apps/windows/OptionSetting.hpp +5 -2
@@ 27,14 27,17 @@ namespace gui
std::function<bool(Item &)> focusCb = nullptr;
AppWindow *app = nullptr;
RightItem rightItem = RightItem::Disabled;
+ bool indent = false;
public:
OptionSettings(const UTF8 text,
std::function<bool(Item &)> cb,
std::function<bool(Item &)> cbFocus,
AppWindow *app,
- RightItem rightItem = RightItem::Disabled)
- : text(text), activatedCallback(std::move(cb)), focusCb(std::move(cbFocus)), app(app), rightItem(rightItem)
+ RightItem rightItem = RightItem::Disabled,
+ bool indent = false)
+ : text(text), activatedCallback(std::move(cb)), focusCb(std::move(cbFocus)), app(app), rightItem(rightItem),
+ indent(indent)
{}
[[nodiscard]] auto build() const -> Item * override;
};