M changelog.md => changelog.md +1 -0
@@ 12,6 12,7 @@
### Fixed
+* `[desktop][gui]` Fixed SIM passcodes to accepts variable length
* `[desktop][messages]` Fixed notifications display and navigation
* `[cellular]` Fixed 32 bit UCS2 codes handling.
M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +0 -1
@@ 41,7 41,6 @@ namespace app
// Invoked upon receiving data message
sys::Message_t ApplicationDesktop::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 (dynamic_cast<sys::ResponseMessage *>(retMsg.get())->retCode == sys::ReturnCodes::Success) {
M module-apps/application-desktop/data/AppDesktopStyle.hpp => module-apps/application-desktop/data/AppDesktopStyle.hpp +13 -13
@@ 7,17 7,17 @@
namespace style::window::pin_lock
{
- const inline uint32_t image_x = 177;
- const inline uint32_t image_y = 132;
- const inline uint32_t title_label_y = 60;
- const inline uint32_t title_label_h = 40;
- const inline uint32_t label_size = 30;
- const inline uint32_t label_size_screen = 60;
- const inline uint32_t pin_label_x = 85;
- const inline uint32_t pin_label_x_screen = 100;
- const inline uint32_t pin_label_y = 450;
- const inline uint32_t info_text_y = 294;
- const inline uint32_t info_text_h_screen = 60;
- const inline uint32_t info_text_h_sim = 150;
- const inline uint32_t info_text_h_puk = 180;
+ constexpr auto image_x = 177;
+ constexpr auto image_y = 132;
+ constexpr auto title_label_y = 60;
+ constexpr auto title_label_h = 40;
+ constexpr auto label_size = 60;
+ constexpr auto label_margins = 10;
+ constexpr auto pin_label_x = 85;
+ constexpr auto pin_label_y = 450;
+ constexpr auto pin_label_y_screen = 400;
+ constexpr auto info_text_y = 294;
+ constexpr auto info_text_h_screen = 60;
+ constexpr auto info_text_h_sim = 150;
+ constexpr auto info_text_h_puk = 180;
} // namespace style::window::pin_lock
M module-apps/application-desktop/widgets/PinLock.cpp => module-apps/application-desktop/widgets/PinLock.cpp +22 -22
@@ 16,40 16,34 @@ namespace gui
}
}
- void PinLock::putNextChar(unsigned int c) noexcept
+ void PinLock::putNextChar(unsigned int c)
{
- if (state == State::EnterPin && charCount < pinValue.size()) {
- pinValue[charCount++] = c;
+ if (state == State::EnterPin && maxPinSize > pinValue.size()) {
+ pinValue.push_back(c);
}
}
- void PinLock::verifyPin() noexcept
+ void PinLock::verifyPin()
{
- if (charCount == pinValue.size()) {
- handler->handle(pinValue);
- clearAttempt();
- }
+ handler->handle(pinValue);
+ clearAttempt();
}
- void PinLock::popChar() noexcept
+ void PinLock::popChar()
{
- if (state == State::EnterPin && charCount > 0) {
- charCount--;
- pinValue[charCount] = 0;
+ if (state == State::EnterPin && pinValue.size() > 0) {
+ pinValue.pop_back();
}
}
void PinLock::clearAttempt() noexcept
{
- for (auto &c : pinValue) {
- c = 0;
- }
- charCount = 0;
+ pinValue.clear();
}
bool PinLock::unlock() noexcept
{
- if (state == State::VerifiedPin || pinValue.size() == 0) {
+ if (state == State::VerifiedPin || maxPinSize == 0) {
state = State::Unlocked;
return true;
}
@@ 78,11 72,17 @@ namespace gui
}
}
- void PinLock::reset(LockType newType, State newState, unsigned int attempts, unsigned int size) noexcept
+ void PinLock::reset(LockType _type,
+ State _state,
+ unsigned int _remainingAttempts,
+ unsigned int _maxPinSize,
+ unsigned int _minPinSize) noexcept
{
- type = newType;
- state = newState;
- remainingAttempts = attempts;
- pinValue = std::vector<unsigned int>(size, 0);
+ type = _type;
+ state = _state;
+ remainingAttempts = _remainingAttempts;
+ pinValue = std::vector<unsigned int>();
+ maxPinSize = _maxPinSize;
+ minPinSize = _minPinSize;
}
} // namespace gui
M module-apps/application-desktop/widgets/PinLock.hpp => module-apps/application-desktop/widgets/PinLock.hpp +18 -10
@@ 37,14 37,14 @@ namespace gui
{
return state;
}
- [[nodiscard]] unsigned int getPinSize() const noexcept
+ [[nodiscard]] unsigned int getMaxPinSize() const noexcept
{
- return pinValue.size();
+ return maxPinSize;
}
/// returns current position of a PIN character to be inserted
[[nodiscard]] unsigned int getCharCount() const noexcept
{
- return charCount;
+ return pinValue.size();
}
[[nodiscard]] unsigned int getRemainingAttempts() const noexcept
{
@@ 52,12 52,16 @@ namespace gui
}
[[nodiscard]] bool canPut() const noexcept
{
- return getCharCount() != getPinSize();
+ return getCharCount() != getMaxPinSize();
+ }
+ [[nodiscard]] bool canVerify() const noexcept
+ {
+ return getCharCount() >= minPinSize;
}
- void putNextChar(unsigned int c) noexcept;
- void verifyPin() noexcept;
+ void putNextChar(unsigned int c);
+ void verifyPin();
/// removes a last character passed to Lock via putNextChar. The last character can not be popped
- void popChar() noexcept;
+ void popChar();
/// clear all characters passed to the Lock
void clearAttempt() noexcept;
/// if Lock is in the State::InvalidPin state, changes it's state to the State::EnterPin
@@ 83,11 87,15 @@ namespace gui
unsigned int remainingAttempts = 0;
/// code of the entered character on specified position
std::vector<unsigned int> pinValue;
- /// flag defines number of entered pin characters
- unsigned int charCount = 0;
+ unsigned int maxPinSize = 0;
+ unsigned int minPinSize = 0;
std::map<InfoName, std::string> additionalLockInfo;
- void reset(LockType, State, unsigned int remainingAttempts, unsigned int pinSize) noexcept;
+ void reset(LockType _type,
+ State _state,
+ unsigned int _remainingAttempts,
+ unsigned int _maxPinSize,
+ unsigned int _minPinSize) noexcept;
friend class gui::PinLockHandler;
};
M module-apps/application-desktop/widgets/PinLockHandler.cpp => module-apps/application-desktop/widgets/PinLockHandler.cpp +16 -12
@@ 8,8 8,10 @@
namespace gui
{
- constexpr unsigned int default_screen_pin_size = 4;
- constexpr unsigned int default_screen_attempts = 4;
+ constexpr unsigned int defaultScreenPinSize = 4;
+ constexpr unsigned int defaultScreenAttempts = 4;
+ constexpr unsigned int maxSimPasscodesSize = 10;
+ constexpr unsigned int minSimPasscodesSize = 4;
PinLockHandler::PinLockHandler(app::ApplicationDesktop *app, SettingsRecord &settings)
: app(app), appSettings(settings), lock(this)
@@ 20,13 22,15 @@ namespace gui
auto PinLockHandler::handle(CellularSimResponseMessage *msg) -> bool
{
assert(msg);
-
parseSimCard(msg);
parseSimState(msg);
parseAttemptsAndPinSize(msg);
lock.additionalLockInfo[gui::PinLock::InfoName::PhoneNum] = msg->getPhoneNumber().getFormatted();
- app->getWindow(app::window::name::desktop_pin_lock)->rebuild();
+ auto currentWindow = app->getWindow(app::window::name::desktop_pin_lock);
+ if (currentWindow != nullptr && currentWindow->getName() == gui::name::window::main_window) {
+ currentWindow->rebuild();
+ }
app->switchWindow(gui::name::window::main_window);
return true;
}
@@ 91,7 95,9 @@ namespace gui
reloadScreenLock();
}
else {
- lock.pinValue = std::vector<unsigned int>(msg->getPinSize(), 0);
+ lock.pinValue = std::vector<unsigned int>();
+ lock.maxPinSize = maxSimPasscodesSize;
+ lock.minPinSize = minSimPasscodesSize;
lock.remainingAttempts = msg->getAttemptsLeft();
}
}
@@ 103,7 109,7 @@ namespace gui
uint32_t hash = hashEngine(pin);
lock.remainingAttempts--;
if (hash == appSettings.lockPassHash) {
- lock.remainingAttempts = default_screen_attempts;
+ lock.remainingAttempts = defaultScreenAttempts;
lock.state = gui::PinLock::State::VerifiedPin;
}
else if (lock.remainingAttempts > 0) {
@@ 126,12 132,10 @@ namespace gui
void PinLockHandler::reloadScreenLock()
{
- lock.type = gui::PinLock::LockType::Screen;
- lock.state = gui::PinLock::State::EnterPin;
-
- unsigned int pinSize = appSettings.lockPassHash == 0 ? 0 : default_screen_pin_size;
- lock.pinValue = std::vector<unsigned int>(pinSize, 0);
- lock.remainingAttempts = default_screen_attempts;
+ auto type = gui::PinLock::LockType::Screen;
+ auto state = gui::PinLock::State::EnterPin;
+ unsigned int pinSize = appSettings.lockPassHash == 0 ? 0 : defaultScreenPinSize;
+ lock.reset(type, state, defaultScreenAttempts, pinSize, pinSize);
}
} // namespace gui
M module-apps/application-desktop/windows/PinLockBaseWindow.cpp => module-apps/application-desktop/windows/PinLockBaseWindow.cpp +16 -16
@@ 47,26 47,31 @@ namespace gui
infoText->setVisible(true);
infoText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
}
- void PinLockBaseWindow::buildPinLabels(gui::Label *labelsBox, unsigned int pinSize, unsigned int singleLabelWidth)
+ void PinLockBaseWindow::buildPinLabels(std::function<Rect *()> itemBuilder,
+ unsigned int pinSize,
+ unsigned int offsetX,
+ unsigned int offsetY,
+ unsigned int boxWidth)
{
- if (pinSize * singleLabelWidth > labelsBox->getWidth()) {
- singleLabelWidth = labelsBox->getWidth() / pinSize;
+ pinLabelsBox = new gui::HBox(this, offsetX, offsetY, boxWidth, lock_style::label_size);
+ pinLabelsBox->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
+
+ if (pinSize == 0) {
+ return;
}
- const uint32_t pinLabelSpacing = (labelsBox->getWidth() - pinSize * singleLabelWidth) / (pinSize - 1);
- uint32_t pinLabelX = 0;
for (uint32_t i = 0; i < pinSize; i++) {
- gui::Label *label = new gui::Label(labelsBox, pinLabelX, 0, singleLabelWidth, lock_style::label_size);
+ auto label = itemBuilder();
label->setFilled(false);
label->setBorderColor(gui::ColorFullBlack);
label->setPenWidth(2);
- label->setFont(style::window::font::largelight);
- label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
+ label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
label->setVisible(true);
- this->pinLabels.push_back(label);
- pinLabelX += singleLabelWidth + pinLabelSpacing;
+ label->activeItem = false;
+ pinLabelsBox->addWidget(label);
}
}
+
void PinLockBaseWindow::buildImages(const std::string &lockImg, const std::string &infoImg)
{
lockImage = new gui::Image(this, lock_style::image_x, lock_style::image_y, 0, 0, lockImg);
@@ 88,10 93,5 @@ namespace gui
{
bottomBar->setText(side, txt, false);
}
- void PinLockBaseWindow::clearPinLabels()
- {
- for (auto label : pinLabels) {
- label->clear();
- }
- }
+
} // namespace gui
M module-apps/application-desktop/windows/PinLockBaseWindow.hpp => module-apps/application-desktop/windows/PinLockBaseWindow.hpp +7 -4
@@ 5,6 5,7 @@
#include "AppWindow.hpp"
#include "Text.hpp"
+#include "BoxLayout.hpp"
namespace gui
{
@@ 20,19 21,21 @@ namespace gui
{}
void build();
void buildInfoText(unsigned int textHight);
- void buildPinLabels(gui::Label *labelBox, unsigned int pinSize, unsigned int singleLabelWidth);
+ void buildPinLabels(std::function<Rect *()> itemBuilder,
+ unsigned int pinSize,
+ unsigned int offsetX,
+ unsigned int offsetY,
+ unsigned int boxWidth);
void buildImages(const std::string &lockImg, const std::string &infoImg);
void setBottomBarWidgetsActive(bool left, bool center, bool right);
void setImagesVisible(bool lockImg, bool infoImg);
void setBottomBarWidgetText(BottomBar::Side side, const UTF8 &txt);
- void clearPinLabels();
gui::Label *titleLabel = nullptr;
gui::Text *infoText = nullptr;
- gui::Label *pinLabel = nullptr;
- std::vector<gui::Label *> pinLabels;
gui::Image *lockImage = nullptr;
gui::Image *infoImage = nullptr;
+ gui::HBox *pinLabelsBox = nullptr;
PinLock &lock;
M module-apps/application-desktop/windows/PinLockBox.hpp => module-apps/application-desktop/windows/PinLockBox.hpp +2 -2
@@ 10,8 10,8 @@ namespace gui
class PinLockBox
{
public:
- virtual void popChar(uint32_t charNum) = 0;
- virtual void putChar(uint32_t charNum) = 0;
+ virtual void popChar(unsigned int charNum) = 0;
+ virtual void putChar(unsigned int charNum) = 0;
virtual void setVisibleStateEnterPin() = 0;
virtual void setVisibleStateVerifiedPin() = 0;
M module-apps/application-desktop/windows/PinLockWindow.cpp => module-apps/application-desktop/windows/PinLockWindow.cpp +11 -11
@@ 18,7 18,6 @@
namespace gui
{
-
PinLockWindow::PinLockWindow(app::Application *app, const std::string &window_name, PinLock &lock)
: PinLockBaseWindow(app, window_name, lock), this_window_name(window_name)
{
@@ 39,7 38,7 @@ namespace gui
AppWindow::buildInterface();
PinLockBaseWindow::build();
buildPinLockBox();
- LockBox->buildLockBox(lock.getPinSize());
+ LockBox->buildLockBox(lock.getMaxPinSize());
}
void PinLockWindow::destroyInterface()
@@ 54,8 53,7 @@ namespace gui
lockImage = nullptr;
infoImage = nullptr;
infoText = nullptr;
- pinLabel = nullptr;
- pinLabels.clear();
+ pinLabelsBox = nullptr;
}
void PinLockWindow::setVisibleState(const PinLock::State state)
@@ 94,15 92,14 @@ namespace gui
return AppWindow::onInput(inputEvent);
}
// accept only LF, enter, RF, #, and numeric values;
- if (inputEvent.keyCode == KeyCode::KEY_LF && bottomBar->isActive(BottomBar::Side::LEFT)) {
+ if (inputEvent.is(KeyCode::KEY_LF) && bottomBar->isActive(BottomBar::Side::LEFT)) {
app::manager::Controller::switchApplication(
application, app::name_phonebook, gui::window::name::ice_contacts, nullptr);
return true;
}
- else if (inputEvent.keyCode == KeyCode::KEY_RF && bottomBar->isActive(BottomBar::Side::RIGHT)) {
+ else if (inputEvent.is(KeyCode::KEY_RF) && bottomBar->isActive(BottomBar::Side::RIGHT)) {
if (state == PinLock::State::EnterPin) {
lock.clearAttempt();
- clearPinLabels();
}
else if (state == PinLock::State::InvalidPin) {
LockBox->setVisibleStateInvalidPin();
@@ 111,10 108,13 @@ namespace gui
application->switchWindow(gui::name::window::main_window);
return true;
}
- else if (inputEvent.keyCode == KeyCode::KEY_PND) {
+ else if (inputEvent.is(KeyCode::KEY_PND)) {
if (state == PinLock::State::EnterPin) {
lock.popChar();
LockBox->popChar(lock.getCharCount());
+ if (!lock.canVerify()) {
+ bottomBar->setActive(BottomBar::Side::CENTER, false);
+ }
return true;
}
}
@@ 122,16 122,16 @@ namespace gui
if (state == PinLock::State::EnterPin && lock.canPut()) {
LockBox->putChar(lock.getCharCount());
lock.putNextChar(gui::toNumeric(inputEvent.keyCode));
- if (lock.getLockType() == PinLock::LockType::Screen) {
+ if (!lock.canPut() && lock.getLockType() == PinLock::LockType::Screen) {
lock.verifyPin();
}
- else if (!lock.canPut()) {
+ else if (lock.canVerify()) {
bottomBar->setActive(BottomBar::Side::CENTER, true);
}
return true;
}
}
- else if (inputEvent.keyCode == KeyCode::KEY_ENTER && bottomBar->isActive(BottomBar::Side::CENTER)) {
+ else if (inputEvent.is(KeyCode::KEY_ENTER) && bottomBar->isActive(BottomBar::Side::CENTER)) {
if (state == PinLock::State::InvalidPin) {
lock.consumeInvalidPinState();
application->switchWindow(this_window_name);
M module-apps/application-desktop/windows/PukLockBox.cpp => module-apps/application-desktop/windows/PukLockBox.cpp +26 -21
@@ 15,37 15,44 @@ namespace lock_style = style::window::pin_lock;
namespace gui
{
- void PukLockBox::popChar(uint32_t charNum)
+ void PukLockBox::popChar(unsigned int charNum)
{
- LockWindow->pinLabels[charNum]->clear();
+ rebuildPinLabels(charNum);
}
- void PukLockBox::putChar(uint32_t charNum)
+ void PukLockBox::putChar(unsigned int charNum)
{
- LockWindow->pinLabels[charNum]->setText("*");
+ rebuildPinLabels(++charNum);
}
void PukLockBox::buildLockBox(unsigned int pinSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
LockWindow->buildInfoText(lock_style::info_text_h_puk);
- buildPinLabels(pinSize);
+ buildPinLabels(0);
}
void PukLockBox::buildPinLabels(unsigned int pinSize)
{
- // labels with stars for displaying entered digits
- const uint32_t pinLabelWidth = style::window_width - 2 * lock_style::pin_label_x;
- LockWindow->pinLabel = new gui::Label(
- LockWindow, lock_style::pin_label_x, lock_style::pin_label_y, pinLabelWidth, lock_style::label_size);
- LockWindow->pinLabel->setEdges(RectangleEdge::Bottom);
+ auto itemBuilder = []() -> Rect * {
+ auto label = new gui::Image("dot_12px_hard_alpha_W_G");
+ return label;
+ };
- LockWindow->buildPinLabels(LockWindow->pinLabel, pinSize, lock_style::label_size);
- for (auto label : LockWindow->pinLabels) {
- label->setEdges(RectangleEdge::None);
- }
+ LockWindow->buildPinLabels(itemBuilder,
+ pinSize,
+ lock_style::pin_label_x,
+ lock_style::pin_label_y,
+ style::window_width - 2 * lock_style::pin_label_x);
+ LockWindow->pinLabelsBox->setEdges(RectangleEdge::Bottom);
}
+
+ void PukLockBox::rebuildPinLabels(unsigned int pinSize)
+ {
+ LockWindow->pinLabelsBox->erase();
+ buildPinLabels(pinSize);
+ }
+
void PukLockBox::setVisibleStateEnterPin()
{
- LockWindow->clearPinLabels();
- LockWindow->pinLabel->setVisible(true);
+ LockWindow->pinLabelsBox->setVisible(true);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_blocked"));
@@ 58,14 65,12 @@ namespace gui
}
void PukLockBox::setVisibleStateVerifiedPin()
{
- LockWindow->clearPinLabels();
- LockWindow->pinLabel->setVisible(false);
+ LockWindow->pinLabelsBox->setVisible(false);
LockWindow->infoText->setVisible(false);
}
void PukLockBox::setVisibleStateInvalidPin()
{
- LockWindow->clearPinLabels();
- LockWindow->pinLabel->setVisible(false);
+ LockWindow->pinLabelsBox->setVisible(false);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_wrong_puk"));
@@ 94,7 99,7 @@ namespace gui
}
void PukLockBox::setVisibleStateBlocked()
{
- LockWindow->pinLabel->setVisible(false);
+ LockWindow->pinLabelsBox->setVisible(false);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_blocked_info1"));
M module-apps/application-desktop/windows/PukLockBox.hpp => module-apps/application-desktop/windows/PukLockBox.hpp +3 -3
@@ 4,7 4,6 @@
#pragma once
#include "PinLockBox.hpp"
-#include "Label.hpp"
namespace gui
{
@@ 21,8 20,8 @@ namespace gui
private:
PinLockBaseWindow *LockWindow;
- void popChar(uint32_t charNum) override final;
- void putChar(uint32_t charNum) override final;
+ void popChar(unsigned int charNum) override final;
+ void putChar(unsigned int charNum) override final;
void setVisibleStateEnterPin() override final;
void setVisibleStateVerifiedPin() override final;
@@ 31,5 30,6 @@ namespace gui
void buildLockBox(unsigned int pinSize) override final;
void buildPinLabels(unsigned int pinSize);
+ void rebuildPinLabels(unsigned int pinSize);
};
} // namespace gui
M module-apps/application-desktop/windows/ScreenLockBox.cpp => module-apps/application-desktop/windows/ScreenLockBox.cpp +58 -19
@@ 14,13 14,33 @@ namespace lock_style = style::window::pin_lock;
namespace gui
{
- void ScreenLockBox::popChar(uint32_t charNum)
+
+ ScreenLockBox::PinLabel::PinLabel(Item *parent, const uint32_t &w, const uint32_t &h) : HBox(parent, 0, 0, w, h)
+ {}
+ void ScreenLockBox::PinLabel::setVisibleState(bool isImageVisible)
{
- LockWindow->pinLabels[charNum]->clear();
+ if (isImageVisible) {
+ image = new gui::Image("dot_12px_hard_alpha_W_G");
+ image->setVisible(true);
+ image->activeItem = false;
+ addWidget(image);
+ }
+ else {
+ image->erase();
+ }
}
- void ScreenLockBox::putChar(uint32_t charNum)
+
+ void ScreenLockBox::popChar(unsigned int charNum)
{
- LockWindow->pinLabels[charNum]->setText("*");
+ if (charNum < pinLabels.size()) {
+ pinLabels[charNum]->setVisibleState(false);
+ }
+ }
+ void ScreenLockBox::putChar(unsigned int charNum)
+ {
+ if (charNum < pinLabels.size()) {
+ pinLabels[charNum]->setVisibleState(true);
+ }
}
void ScreenLockBox::buildLockBox(unsigned int pinSize)
{
@@ 30,20 50,32 @@ namespace gui
}
void ScreenLockBox::buildPinLabels(unsigned int pinSize)
{
- // labels with stars for displaying entered digits
- const uint32_t pinLabelWidth = style::window_width - 2 * lock_style::pin_label_x_screen;
- LockWindow->pinLabel = new gui::Label(
- LockWindow, lock_style::pin_label_x_screen, lock_style::pin_label_y, pinLabelWidth, lock_style::label_size);
- LockWindow->pinLabel->setEdges(RectangleEdge::None);
-
- LockWindow->buildPinLabels(LockWindow->pinLabel, pinSize, lock_style::label_size_screen);
- for (auto label : LockWindow->pinLabels) {
- label->setEdges(RectangleEdge::Bottom);
+ unsigned int singleLabelWidth = lock_style::label_size;
+ constexpr auto pinLabelWidth = style::window::default_body_width;
+ pinLabels.clear();
+
+ if (pinSize == 0) {
+ return;
+ }
+ if (pinSize * singleLabelWidth > pinLabelWidth - pinSize * 2 * lock_style::label_margins) {
+ singleLabelWidth = pinLabelWidth / pinSize - 2 * lock_style::label_margins;
}
+
+ auto itemBuilder = [this, singleLabelWidth]() -> Rect * {
+ auto label = new PinLabel(nullptr, singleLabelWidth, lock_style::label_size);
+ label->setEdges(RectangleEdge::Bottom);
+ label->setMargins(Margins(lock_style::label_margins, 0, lock_style::label_margins, 0));
+ pinLabels.push_back(label);
+ return label;
+ };
+
+ LockWindow->buildPinLabels(
+ itemBuilder, pinSize, style::window::default_left_margin, lock_style::pin_label_y_screen, pinLabelWidth);
+ LockWindow->pinLabelsBox->setEdges(RectangleEdge::None);
}
void ScreenLockBox::setVisibleStateEnterPin()
{
- LockWindow->pinLabel->setVisible(true);
+ LockWindow->pinLabelsBox->setVisible(true);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get("app_desktop_screen_enter_passcode"));
@@ 54,14 86,14 @@ namespace gui
}
void ScreenLockBox::setVisibleStateVerifiedPin()
{
- LockWindow->clearPinLabels();
- LockWindow->pinLabel->setVisible(false);
+ clearPinLabels();
+ LockWindow->pinLabelsBox->setVisible(false);
LockWindow->titleLabel->setVisible(false);
}
void ScreenLockBox::setVisibleStateInvalidPin()
{
- LockWindow->clearPinLabels();
- LockWindow->pinLabel->setVisible(false);
+ clearPinLabels();
+ LockWindow->pinLabelsBox->setVisible(false);
LockWindow->titleLabel->setVisible(true);
LockWindow->titleLabel->setText(utils::localize.get("app_desktop_screen_wrong_pin"));
@@ 77,7 109,7 @@ namespace gui
}
void ScreenLockBox::setVisibleStateBlocked()
{
- LockWindow->pinLabel->setVisible(false);
+ LockWindow->pinLabelsBox->setVisible(false);
LockWindow->titleLabel->setVisible(false);
LockWindow->infoText->clear();
@@ 87,4 119,11 @@ namespace gui
LockWindow->setImagesVisible(false, true);
LockWindow->setBottomBarWidgetsActive(false, true, false);
}
+
+ void ScreenLockBox::clearPinLabels()
+ {
+ for (unsigned i = 0; i < pinLabels.size(); i++) {
+ popChar(i);
+ }
+ }
} // namespace gui
M module-apps/application-desktop/windows/ScreenLockBox.hpp => module-apps/application-desktop/windows/ScreenLockBox.hpp +13 -3
@@ 4,7 4,8 @@
#pragma once
#include "PinLockBox.hpp"
-#include "Label.hpp"
+#include "BoxLayout.hpp"
+#include "Image.hpp"
namespace gui
{
@@ 20,9 21,17 @@ namespace gui
{}
private:
+ struct PinLabel : public HBox
+ {
+ gui::Image *image;
+ PinLabel(Item *parent, const uint32_t &w, const uint32_t &h);
+ void setVisibleState(bool isImageVisible);
+ };
+
+ std::vector<PinLabel *> pinLabels;
PinLockBaseWindow *LockWindow;
- void popChar(uint32_t charNum) override final;
- void putChar(uint32_t charNum) override final;
+ void popChar(unsigned int charNum) override final;
+ void putChar(unsigned int charNum) override final;
void setVisibleStateEnterPin() override final;
void setVisibleStateVerifiedPin() override final;
@@ 31,5 40,6 @@ namespace gui
void buildLockBox(unsigned int pinSize) override final;
void buildPinLabels(unsigned int pinSize);
+ void clearPinLabels();
};
} // namespace gui
M module-apps/application-desktop/windows/SimLockBox.cpp => module-apps/application-desktop/windows/SimLockBox.cpp +26 -20
@@ 15,37 15,45 @@ namespace lock_style = style::window::pin_lock;
namespace gui
{
- void SimLockBox::popChar(uint32_t charNum)
+ void SimLockBox::popChar(unsigned int charNum)
{
- LockWindow->pinLabels[charNum]->clear();
+ rebuildPinLabels(charNum);
}
- void SimLockBox::putChar(uint32_t charNum)
+ void SimLockBox::putChar(unsigned int charNum)
{
- LockWindow->pinLabels[charNum]->setText("*");
+ rebuildPinLabels(++charNum);
}
void SimLockBox::buildLockBox(unsigned int pinSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
LockWindow->buildInfoText(lock_style::info_text_h_sim);
- buildPinLabels(pinSize);
+ buildPinLabels(0);
}
void SimLockBox::buildPinLabels(unsigned int pinSize)
{
- // labels with stars for displaying entered digits
- const uint32_t pinLabelWidth = style::window_width - 2 * lock_style::pin_label_x;
- LockWindow->pinLabel = new gui::Label(
- LockWindow, lock_style::pin_label_x, lock_style::pin_label_y, pinLabelWidth, lock_style::label_size);
- LockWindow->pinLabel->setEdges(RectangleEdge::Bottom);
+ auto itemBuilder = []() -> Rect * {
+ auto label = new gui::Image("dot_12px_hard_alpha_W_G");
+ return label;
+ };
- LockWindow->buildPinLabels(LockWindow->pinLabel, pinSize, lock_style::label_size);
- for (auto label : LockWindow->pinLabels) {
- label->setEdges(RectangleEdge::None);
- }
+ LockWindow->buildPinLabels(itemBuilder,
+ pinSize,
+ lock_style::pin_label_x,
+ lock_style::pin_label_y,
+ style::window_width - 2 * lock_style::pin_label_x);
+ LockWindow->pinLabelsBox->setEdges(RectangleEdge::Bottom);
}
+
+ void SimLockBox::rebuildPinLabels(unsigned int pinSize)
+ {
+ LockWindow->pinLabelsBox->erase();
+ buildPinLabels(pinSize);
+ }
+
void SimLockBox::setVisibleStateEnterPin()
{
- LockWindow->pinLabel->setVisible(true);
+ LockWindow->pinLabelsBox->setVisible(true);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_to_unlock"));
@@ 66,15 74,13 @@ namespace gui
}
void SimLockBox::setVisibleStateVerifiedPin()
{
- LockWindow->clearPinLabels();
LockWindow->infoText->clear();
LockWindow->infoText->setVisible(false);
- LockWindow->pinLabel->setVisible(false);
+ LockWindow->pinLabelsBox->setVisible(false);
}
void SimLockBox::setVisibleStateInvalidPin()
{
- LockWindow->clearPinLabels();
- LockWindow->pinLabel->setVisible(false);
+ LockWindow->pinLabelsBox->setVisible(false);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get(utils::localize.get("app_desktop_sim_wrong_pin")));
@@ 96,7 102,7 @@ namespace gui
}
void SimLockBox::setVisibleStateBlocked()
{
- LockWindow->pinLabel->setVisible(false);
+ LockWindow->pinLabelsBox->setVisible(false);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get(utils::localize.get("app_desktop_puk_lock1")));
LockWindow->infoText->setVisible(true);
M module-apps/application-desktop/windows/SimLockBox.hpp => module-apps/application-desktop/windows/SimLockBox.hpp +3 -3
@@ 4,7 4,6 @@
#pragma once
#include "PinLockBox.hpp"
-#include "Label.hpp"
namespace gui
{
@@ 21,8 20,8 @@ namespace gui
private:
PinLockBaseWindow *LockWindow;
- void popChar(uint32_t charNum) override final;
- void putChar(uint32_t charNum) override final;
+ void popChar(unsigned int charNum) override final;
+ void putChar(unsigned int charNum) override final;
void setVisibleStateEnterPin() override final;
void setVisibleStateVerifiedPin() override final;
@@ 31,5 30,6 @@ namespace gui
void buildLockBox(unsigned int pinSize) override final;
void buildPinLabels(unsigned int pinSize);
+ void rebuildPinLabels(unsigned int pinSize);
};
} // namespace gui
M module-services/service-cellular/messages/CellularMessage.hpp => module-services/service-cellular/messages/CellularMessage.hpp +1 -8
@@ 192,9 192,8 @@ class CellularSimResponseMessage : public CellularSimMessage
CellularSimResponseMessage(SimCard sim,
SimState state,
const utils::PhoneNumber::View &number,
- unsigned int pinSize,
unsigned int attemptsLeft = defaultAttemptsLeft)
- : CellularSimMessage(sim), state(state), number(number), pinSize(pinSize), attemptsLeft(attemptsLeft)
+ : CellularSimMessage(sim), state(state), number(number), attemptsLeft(attemptsLeft)
{}
SimState getSimState() const noexcept
@@ 205,10 204,6 @@ class CellularSimResponseMessage : public CellularSimMessage
{
return number;
}
- unsigned int getPinSize() const noexcept
- {
- return pinSize;
- }
unsigned int getAttemptsLeft() const noexcept
{
return attemptsLeft;
@@ 217,11 212,9 @@ class CellularSimResponseMessage : public CellularSimMessage
private:
SimState state = defaultSimState;
utils::PhoneNumber::View number;
- unsigned int pinSize = defaultPinSize;
/// ignored if state is not one of { PINInvalidRetryPossible, PUKInvalidRetryPossible }
unsigned int attemptsLeft = defaultAttemptsLeft;
- static const unsigned int defaultPinSize = 4;
static const unsigned int defaultAttemptsLeft = 4;
static const SimState defaultSimState = SimState::SIMUnlocked;
};