M changelog.md => changelog.md +0 -1
@@ 15,7 15,6 @@
### Fixed
-* `[desktop][gui]` Fixed SIM passcodes to accepts variable length
* `[desktop][messages]` Fixed notifications display and navigation
* `[cellular]` Fixed 32 bit UCS2 codes handling.
* `[call]` Fixed incorrect start of call duration timer
M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +1 -0
@@ 41,6 41,7 @@ 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
{
- 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;
+ 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;
} // namespace style::window::pin_lock
M module-apps/application-desktop/widgets/PinLock.cpp => module-apps/application-desktop/widgets/PinLock.cpp +22 -22
@@ 16,34 16,40 @@ namespace gui
}
}
- void PinLock::putNextChar(unsigned int c)
+ void PinLock::putNextChar(unsigned int c) noexcept
{
- if (state == State::EnterPin && maxPinSize > pinValue.size()) {
- pinValue.push_back(c);
+ if (state == State::EnterPin && charCount < pinValue.size()) {
+ pinValue[charCount++] = c;
}
}
- void PinLock::verifyPin()
+ void PinLock::verifyPin() noexcept
{
- handler->handle(pinValue);
- clearAttempt();
+ if (charCount == pinValue.size()) {
+ handler->handle(pinValue);
+ clearAttempt();
+ }
}
- void PinLock::popChar()
+ void PinLock::popChar() noexcept
{
- if (state == State::EnterPin && pinValue.size() > 0) {
- pinValue.pop_back();
+ if (state == State::EnterPin && charCount > 0) {
+ charCount--;
+ pinValue[charCount] = 0;
}
}
void PinLock::clearAttempt() noexcept
{
- pinValue.clear();
+ for (auto &c : pinValue) {
+ c = 0;
+ }
+ charCount = 0;
}
bool PinLock::unlock() noexcept
{
- if (state == State::VerifiedPin || maxPinSize == 0) {
+ if (state == State::VerifiedPin || pinValue.size() == 0) {
state = State::Unlocked;
return true;
}
@@ 72,17 78,11 @@ namespace gui
}
}
- void PinLock::reset(LockType _type,
- State _state,
- unsigned int _remainingAttempts,
- unsigned int _maxPinSize,
- unsigned int _minPinSize) noexcept
+ void PinLock::reset(LockType newType, State newState, unsigned int attempts, unsigned int size) noexcept
{
- type = _type;
- state = _state;
- remainingAttempts = _remainingAttempts;
- pinValue = std::vector<unsigned int>();
- maxPinSize = _maxPinSize;
- minPinSize = _minPinSize;
+ type = newType;
+ state = newState;
+ remainingAttempts = attempts;
+ pinValue = std::vector<unsigned int>(size, 0);
}
} // namespace gui
M module-apps/application-desktop/widgets/PinLock.hpp => module-apps/application-desktop/widgets/PinLock.hpp +10 -18
@@ 37,14 37,14 @@ namespace gui
{
return state;
}
- [[nodiscard]] unsigned int getMaxPinSize() const noexcept
+ [[nodiscard]] unsigned int getPinSize() const noexcept
{
- return maxPinSize;
+ return pinValue.size();
}
/// returns current position of a PIN character to be inserted
[[nodiscard]] unsigned int getCharCount() const noexcept
{
- return pinValue.size();
+ return charCount;
}
[[nodiscard]] unsigned int getRemainingAttempts() const noexcept
{
@@ 52,16 52,12 @@ namespace gui
}
[[nodiscard]] bool canPut() const noexcept
{
- return getCharCount() != getMaxPinSize();
- }
- [[nodiscard]] bool canVerify() const noexcept
- {
- return getCharCount() >= minPinSize;
+ return getCharCount() != getPinSize();
}
- void putNextChar(unsigned int c);
- void verifyPin();
+ void putNextChar(unsigned int c) noexcept;
+ void verifyPin() noexcept;
/// removes a last character passed to Lock via putNextChar. The last character can not be popped
- void popChar();
+ void popChar() noexcept;
/// 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
@@ 87,15 83,11 @@ namespace gui
unsigned int remainingAttempts = 0;
/// code of the entered character on specified position
std::vector<unsigned int> pinValue;
- unsigned int maxPinSize = 0;
- unsigned int minPinSize = 0;
+ /// flag defines number of entered pin characters
+ unsigned int charCount = 0;
std::map<InfoName, std::string> additionalLockInfo;
- void reset(LockType _type,
- State _state,
- unsigned int _remainingAttempts,
- unsigned int _maxPinSize,
- unsigned int _minPinSize) noexcept;
+ void reset(LockType, State, unsigned int remainingAttempts, unsigned int pinSize) noexcept;
friend class gui::PinLockHandler;
};
M module-apps/application-desktop/widgets/PinLockHandler.cpp => module-apps/application-desktop/widgets/PinLockHandler.cpp +12 -16
@@ 8,10 8,8 @@
namespace gui
{
- constexpr unsigned int defaultScreenPinSize = 4;
- constexpr unsigned int defaultScreenAttempts = 4;
- constexpr unsigned int maxSimPasscodesSize = 10;
- constexpr unsigned int minSimPasscodesSize = 4;
+ constexpr unsigned int default_screen_pin_size = 4;
+ constexpr unsigned int default_screen_attempts = 4;
PinLockHandler::PinLockHandler(app::ApplicationDesktop *app, SettingsRecord &settings)
: app(app), appSettings(settings), lock(this)
@@ 22,15 20,13 @@ 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();
- auto currentWindow = app->getWindow(app::window::name::desktop_pin_lock);
- if (currentWindow != nullptr && currentWindow->getName() == gui::name::window::main_window) {
- currentWindow->rebuild();
- }
+ app->getWindow(app::window::name::desktop_pin_lock)->rebuild();
app->switchWindow(gui::name::window::main_window);
return true;
}
@@ 95,9 91,7 @@ namespace gui
reloadScreenLock();
}
else {
- lock.pinValue = std::vector<unsigned int>();
- lock.maxPinSize = maxSimPasscodesSize;
- lock.minPinSize = minSimPasscodesSize;
+ lock.pinValue = std::vector<unsigned int>(msg->getPinSize(), 0);
lock.remainingAttempts = msg->getAttemptsLeft();
}
}
@@ 109,7 103,7 @@ namespace gui
uint32_t hash = hashEngine(pin);
lock.remainingAttempts--;
if (hash == appSettings.lockPassHash) {
- lock.remainingAttempts = defaultScreenAttempts;
+ lock.remainingAttempts = default_screen_attempts;
lock.state = gui::PinLock::State::VerifiedPin;
}
else if (lock.remainingAttempts > 0) {
@@ 132,10 126,12 @@ namespace gui
void PinLockHandler::reloadScreenLock()
{
- 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);
+ 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;
}
} // namespace gui
M module-apps/application-desktop/windows/PinLockBaseWindow.cpp => module-apps/application-desktop/windows/PinLockBaseWindow.cpp +16 -16
@@ 47,31 47,26 @@ namespace gui
infoText->setVisible(true);
infoText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
}
- void PinLockBaseWindow::buildPinLabels(std::function<Rect *()> itemBuilder,
- unsigned int pinSize,
- unsigned int offsetX,
- unsigned int offsetY,
- unsigned int boxWidth)
+ void PinLockBaseWindow::buildPinLabels(gui::Label *labelsBox, unsigned int pinSize, unsigned int singleLabelWidth)
{
- 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;
+ if (pinSize * singleLabelWidth > labelsBox->getWidth()) {
+ singleLabelWidth = labelsBox->getWidth() / pinSize;
}
+ const uint32_t pinLabelSpacing = (labelsBox->getWidth() - pinSize * singleLabelWidth) / (pinSize - 1);
+ uint32_t pinLabelX = 0;
for (uint32_t i = 0; i < pinSize; i++) {
- auto label = itemBuilder();
+ gui::Label *label = new gui::Label(labelsBox, pinLabelX, 0, singleLabelWidth, lock_style::label_size);
label->setFilled(false);
label->setBorderColor(gui::ColorFullBlack);
label->setPenWidth(2);
- label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
+ label->setFont(style::window::font::largelight);
+ label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
label->setVisible(true);
- label->activeItem = false;
- pinLabelsBox->addWidget(label);
+ this->pinLabels.push_back(label);
+ pinLabelX += singleLabelWidth + pinLabelSpacing;
}
}
-
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);
@@ 93,5 88,10 @@ 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 +4 -7
@@ 5,7 5,6 @@
#include "AppWindow.hpp"
#include "Text.hpp"
-#include "BoxLayout.hpp"
namespace gui
{
@@ 21,21 20,19 @@ namespace gui
{}
void build();
void buildInfoText(unsigned int textHight);
- void buildPinLabels(std::function<Rect *()> itemBuilder,
- unsigned int pinSize,
- unsigned int offsetX,
- unsigned int offsetY,
- unsigned int boxWidth);
+ void buildPinLabels(gui::Label *labelBox, unsigned int pinSize, unsigned int singleLabelWidth);
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(unsigned int charNum) = 0;
- virtual void putChar(unsigned int charNum) = 0;
+ virtual void popChar(uint32_t charNum) = 0;
+ virtual void putChar(uint32_t 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,6 18,7 @@
namespace gui
{
+
PinLockWindow::PinLockWindow(app::Application *app, const std::string &window_name, PinLock &lock)
: PinLockBaseWindow(app, window_name, lock), this_window_name(window_name)
{
@@ 38,7 39,7 @@ namespace gui
AppWindow::buildInterface();
PinLockBaseWindow::build();
buildPinLockBox();
- LockBox->buildLockBox(lock.getMaxPinSize());
+ LockBox->buildLockBox(lock.getPinSize());
}
void PinLockWindow::destroyInterface()
@@ 53,7 54,8 @@ namespace gui
lockImage = nullptr;
infoImage = nullptr;
infoText = nullptr;
- pinLabelsBox = nullptr;
+ pinLabel = nullptr;
+ pinLabels.clear();
}
void PinLockWindow::setVisibleState(const PinLock::State state)
@@ 92,14 94,15 @@ namespace gui
return AppWindow::onInput(inputEvent);
}
// accept only LF, enter, RF, #, and numeric values;
- if (inputEvent.is(KeyCode::KEY_LF) && bottomBar->isActive(BottomBar::Side::LEFT)) {
+ if (inputEvent.keyCode == 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.is(KeyCode::KEY_RF) && bottomBar->isActive(BottomBar::Side::RIGHT)) {
+ else if (inputEvent.keyCode == KeyCode::KEY_RF && bottomBar->isActive(BottomBar::Side::RIGHT)) {
if (state == PinLock::State::EnterPin) {
lock.clearAttempt();
+ clearPinLabels();
}
else if (state == PinLock::State::InvalidPin) {
LockBox->setVisibleStateInvalidPin();
@@ 108,13 111,10 @@ namespace gui
application->switchWindow(gui::name::window::main_window);
return true;
}
- else if (inputEvent.is(KeyCode::KEY_PND)) {
+ else if (inputEvent.keyCode == 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.canPut() && lock.getLockType() == PinLock::LockType::Screen) {
+ if (lock.getLockType() == PinLock::LockType::Screen) {
lock.verifyPin();
}
- else if (lock.canVerify()) {
+ else if (!lock.canPut()) {
bottomBar->setActive(BottomBar::Side::CENTER, true);
}
return true;
}
}
- else if (inputEvent.is(KeyCode::KEY_ENTER) && bottomBar->isActive(BottomBar::Side::CENTER)) {
+ else if (inputEvent.keyCode == 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 +21 -26
@@ 15,44 15,37 @@ namespace lock_style = style::window::pin_lock;
namespace gui
{
- void PukLockBox::popChar(unsigned int charNum)
+ void PukLockBox::popChar(uint32_t charNum)
{
- rebuildPinLabels(charNum);
+ LockWindow->pinLabels[charNum]->clear();
}
- void PukLockBox::putChar(unsigned int charNum)
+ void PukLockBox::putChar(uint32_t charNum)
{
- rebuildPinLabels(++charNum);
+ LockWindow->pinLabels[charNum]->setText("*");
}
void PukLockBox::buildLockBox(unsigned int pinSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
LockWindow->buildInfoText(lock_style::info_text_h_puk);
- buildPinLabels(0);
+ buildPinLabels(pinSize);
}
void PukLockBox::buildPinLabels(unsigned int pinSize)
{
- auto itemBuilder = []() -> Rect * {
- auto label = new gui::Image("dot_12px_hard_alpha_W_G");
- return label;
- };
-
- 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);
- }
+ // 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);
- void PukLockBox::rebuildPinLabels(unsigned int pinSize)
- {
- LockWindow->pinLabelsBox->erase();
- buildPinLabels(pinSize);
+ LockWindow->buildPinLabels(LockWindow->pinLabel, pinSize, lock_style::label_size);
+ for (auto label : LockWindow->pinLabels) {
+ label->setEdges(RectangleEdge::None);
+ }
}
-
void PukLockBox::setVisibleStateEnterPin()
{
- LockWindow->pinLabelsBox->setVisible(true);
+ LockWindow->clearPinLabels();
+ LockWindow->pinLabel->setVisible(true);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_blocked"));
@@ 65,12 58,14 @@ namespace gui
}
void PukLockBox::setVisibleStateVerifiedPin()
{
- LockWindow->pinLabelsBox->setVisible(false);
+ LockWindow->clearPinLabels();
+ LockWindow->pinLabel->setVisible(false);
LockWindow->infoText->setVisible(false);
}
void PukLockBox::setVisibleStateInvalidPin()
{
- LockWindow->pinLabelsBox->setVisible(false);
+ LockWindow->clearPinLabels();
+ LockWindow->pinLabel->setVisible(false);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_wrong_puk"));
@@ 99,7 94,7 @@ namespace gui
}
void PukLockBox::setVisibleStateBlocked()
{
- LockWindow->pinLabelsBox->setVisible(false);
+ LockWindow->pinLabel->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,6 4,7 @@
#pragma once
#include "PinLockBox.hpp"
+#include "Label.hpp"
namespace gui
{
@@ 20,8 21,8 @@ namespace gui
private:
PinLockBaseWindow *LockWindow;
- void popChar(unsigned int charNum) override final;
- void putChar(unsigned int charNum) override final;
+ void popChar(uint32_t charNum) override final;
+ void putChar(uint32_t charNum) override final;
void setVisibleStateEnterPin() override final;
void setVisibleStateVerifiedPin() override final;
@@ 30,6 31,5 @@ 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 +19 -58
@@ 14,33 14,13 @@ namespace lock_style = style::window::pin_lock;
namespace gui
{
-
- 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)
+ void ScreenLockBox::popChar(uint32_t charNum)
{
- if (isImageVisible) {
- image = new gui::Image("dot_12px_hard_alpha_W_G");
- image->setVisible(true);
- image->activeItem = false;
- addWidget(image);
- }
- else {
- image->erase();
- }
+ LockWindow->pinLabels[charNum]->clear();
}
-
- void ScreenLockBox::popChar(unsigned int charNum)
+ void ScreenLockBox::putChar(uint32_t charNum)
{
- if (charNum < pinLabels.size()) {
- pinLabels[charNum]->setVisibleState(false);
- }
- }
- void ScreenLockBox::putChar(unsigned int charNum)
- {
- if (charNum < pinLabels.size()) {
- pinLabels[charNum]->setVisibleState(true);
- }
+ LockWindow->pinLabels[charNum]->setText("*");
}
void ScreenLockBox::buildLockBox(unsigned int pinSize)
{
@@ 50,32 30,20 @@ namespace gui
}
void ScreenLockBox::buildPinLabels(unsigned int pinSize)
{
- 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);
+ // 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);
- 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->pinLabelsBox->setVisible(true);
+ LockWindow->pinLabel->setVisible(true);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get("app_desktop_screen_enter_passcode"));
@@ 86,14 54,14 @@ namespace gui
}
void ScreenLockBox::setVisibleStateVerifiedPin()
{
- clearPinLabels();
- LockWindow->pinLabelsBox->setVisible(false);
+ LockWindow->clearPinLabels();
+ LockWindow->pinLabel->setVisible(false);
LockWindow->titleLabel->setVisible(false);
}
void ScreenLockBox::setVisibleStateInvalidPin()
{
- clearPinLabels();
- LockWindow->pinLabelsBox->setVisible(false);
+ LockWindow->clearPinLabels();
+ LockWindow->pinLabel->setVisible(false);
LockWindow->titleLabel->setVisible(true);
LockWindow->titleLabel->setText(utils::localize.get("app_desktop_screen_wrong_pin"));
@@ 109,7 77,7 @@ namespace gui
}
void ScreenLockBox::setVisibleStateBlocked()
{
- LockWindow->pinLabelsBox->setVisible(false);
+ LockWindow->pinLabel->setVisible(false);
LockWindow->titleLabel->setVisible(false);
LockWindow->infoText->clear();
@@ 119,11 87,4 @@ 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 +3 -13
@@ 4,8 4,7 @@
#pragma once
#include "PinLockBox.hpp"
-#include "BoxLayout.hpp"
-#include "Image.hpp"
+#include "Label.hpp"
namespace gui
{
@@ 21,17 20,9 @@ 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(unsigned int charNum) override final;
- void putChar(unsigned int charNum) override final;
+ void popChar(uint32_t charNum) override final;
+ void putChar(uint32_t charNum) override final;
void setVisibleStateEnterPin() override final;
void setVisibleStateVerifiedPin() override final;
@@ 40,6 31,5 @@ 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 +20 -26
@@ 15,45 15,37 @@ namespace lock_style = style::window::pin_lock;
namespace gui
{
- void SimLockBox::popChar(unsigned int charNum)
+ void SimLockBox::popChar(uint32_t charNum)
{
- rebuildPinLabels(charNum);
+ LockWindow->pinLabels[charNum]->clear();
}
- void SimLockBox::putChar(unsigned int charNum)
+ void SimLockBox::putChar(uint32_t charNum)
{
- rebuildPinLabels(++charNum);
+ LockWindow->pinLabels[charNum]->setText("*");
}
void SimLockBox::buildLockBox(unsigned int pinSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
LockWindow->buildInfoText(lock_style::info_text_h_sim);
- buildPinLabels(0);
+ buildPinLabels(pinSize);
}
void SimLockBox::buildPinLabels(unsigned int pinSize)
{
- auto itemBuilder = []() -> Rect * {
- auto label = new gui::Image("dot_12px_hard_alpha_W_G");
- return label;
- };
-
- 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);
- }
+ // 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);
- void SimLockBox::rebuildPinLabels(unsigned int pinSize)
- {
- LockWindow->pinLabelsBox->erase();
- buildPinLabels(pinSize);
+ LockWindow->buildPinLabels(LockWindow->pinLabel, pinSize, lock_style::label_size);
+ for (auto label : LockWindow->pinLabels) {
+ label->setEdges(RectangleEdge::None);
+ }
}
-
void SimLockBox::setVisibleStateEnterPin()
{
- LockWindow->pinLabelsBox->setVisible(true);
+ LockWindow->pinLabel->setVisible(true);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_to_unlock"));
@@ 74,13 66,15 @@ namespace gui
}
void SimLockBox::setVisibleStateVerifiedPin()
{
+ LockWindow->clearPinLabels();
LockWindow->infoText->clear();
LockWindow->infoText->setVisible(false);
- LockWindow->pinLabelsBox->setVisible(false);
+ LockWindow->pinLabel->setVisible(false);
}
void SimLockBox::setVisibleStateInvalidPin()
{
- LockWindow->pinLabelsBox->setVisible(false);
+ LockWindow->clearPinLabels();
+ LockWindow->pinLabel->setVisible(false);
LockWindow->infoText->clear();
LockWindow->infoText->addText(utils::localize.get(utils::localize.get("app_desktop_sim_wrong_pin")));
@@ 102,7 96,7 @@ namespace gui
}
void SimLockBox::setVisibleStateBlocked()
{
- LockWindow->pinLabelsBox->setVisible(false);
+ LockWindow->pinLabel->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,6 4,7 @@
#pragma once
#include "PinLockBox.hpp"
+#include "Label.hpp"
namespace gui
{
@@ 20,8 21,8 @@ namespace gui
private:
PinLockBaseWindow *LockWindow;
- void popChar(unsigned int charNum) override final;
- void putChar(unsigned int charNum) override final;
+ void popChar(uint32_t charNum) override final;
+ void putChar(uint32_t charNum) override final;
void setVisibleStateEnterPin() override final;
void setVisibleStateVerifiedPin() override final;
@@ 30,6 31,5 @@ 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 +8 -1
@@ 215,8 215,9 @@ 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), attemptsLeft(attemptsLeft)
+ : CellularSimMessage(sim), state(state), number(number), pinSize(pinSize), attemptsLeft(attemptsLeft)
{}
SimState getSimState() const noexcept
@@ 227,6 228,10 @@ class CellularSimResponseMessage : public CellularSimMessage
{
return number;
}
+ unsigned int getPinSize() const noexcept
+ {
+ return pinSize;
+ }
unsigned int getAttemptsLeft() const noexcept
{
return attemptsLeft;
@@ 235,9 240,11 @@ 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;
};