Files
MuditaOS/module-gui/gui/widgets/TopBar/SIM.cpp
T
Michał Kamoń eec4370cdc [EGD-5703] Fix SimCard topBar icon on Desktop
In initial design a `TobBar`'s SimCard icon with number is supposed
to display on the home screen only if there are two cards inserted.
Because of the hardware limitations (there is no way of telling if
there is a single or two cards inserted) the established consensus is
that home screen should not display SimCard widget unless it's
indication error state.

Although in the task description there is only home screen mentioned,
the behaviour was established for all `ApplicationDesktop`'s windows.
2021-04-27 08:14:17 +02:00

77 lines
2.1 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "SIM.hpp"
namespace gui::top_bar
{
using namespace Store;
constexpr auto sim1 = "sim1"; // sim 1 indicator
constexpr auto sim2 = "sim2"; // sim 2 indicator
constexpr auto simunknown = "simunknown"; // sim - unknown sim state indicator (i.e. no initialization was done)
constexpr auto simfailed = "simfail"; // sim - notification for sim failure
SIM::SIM(Item *parent, uint32_t x, uint32_t y) : StatusBarWidgetBase(parent, x, y, 0, 0)
{
set(simunknown);
}
void SIM::update(const Store::GSM::SIM &state)
{
if (state == current) {
return;
}
current = state;
switch (current) {
case GSM::SIM::SIM1:
set(sim1);
break;
case GSM::SIM::SIM2:
set(sim2);
break;
case GSM::SIM::SIM_FAIL:
set(simfailed);
break;
case GSM::SIM::NONE:
[[fallthrough]];
case GSM::SIM::SIM_UNKNOWN:
set(simunknown);
break;
}
}
void SIM::show()
{
bool isVisible = !(mode == SIMConfiguration::DisplayMode::OnlyInactiveState &&
(current == GSM::SIM::SIM1 || current == GSM::SIM::SIM2));
StatusBarWidgetBase<Image>::setVisible(isVisible);
}
void SIM::acceptStatusBarVisitor(StatusBarVisitor &visitor)
{
visitor.visit(*this);
}
SIMConfiguration::SIMConfiguration(DisplayMode mode) : mode{mode}
{}
void SIMConfiguration::visit(gui::top_bar::SIM &widget) const
{
widget.mode = getMode();
}
SIMConfiguration::DisplayMode SIMConfiguration::getMode() const noexcept
{
return mode;
}
SIMDevelopersMode::SIMDevelopersMode(Item *parent, uint32_t x, uint32_t y) : SIM(parent, x, y)
{}
void SIMDevelopersMode::show()
{
StatusBarWidgetBase<Image>::setVisible(true);
}
}; // namespace gui::top_bar