M changelog.md => changelog.md +2 -0
@@ 7,6 7,8 @@
### Changed
+* `[desktop]` Windows refactor
+
### Fixed
### Other
M image/assets/lang/English.json => image/assets/lang/English.json +1 -1
@@ 150,7 150,7 @@
"app_desktop_unlock": "UNLOCK",
"app_desktop_lock": "LOCK",
"app_desktop_menu": "MENU",
- "app_desktop_emergency": "EMERG.",
+ "app_desktop_emergency": "SOS",
"app_desktop_screen_enter_passcode": "Enter passcode",
"app_desktop_screen_wrong_pin": "Wrong passcode",
"app_desktop_screen_allowed_attempts": "Allowed unlock attempts",
M module-apps/application-desktop/data/AppDesktopStyle.hpp => module-apps/application-desktop/data/AppDesktopStyle.hpp +56 -15
@@ 3,21 3,62 @@
#pragma once
-#include <inttypes.h>
-
namespace style::window::pin_lock
{
- constexpr inline auto image_x = 177;
- constexpr inline auto image_y = 132;
- constexpr inline auto title_label_y = 60;
- constexpr inline auto title_label_h = 40;
- constexpr inline auto label_size = 60;
- constexpr inline auto label_margins = 10;
- constexpr inline auto pin_label_x = 85;
- constexpr inline auto pin_label_y = 450;
- constexpr inline auto pin_label_y_screen = 400;
- constexpr inline auto info_text_y = 294;
- constexpr inline auto info_text_h_screen = 60;
- constexpr inline auto info_text_h_sim = 150;
- constexpr inline auto info_text_h_puk = 180;
+ namespace image
+ {
+ constexpr inline auto x = 177;
+ constexpr inline auto y = 132;
+ } // namespace image
+
+ namespace pin_label
+ {
+ constexpr inline auto x = 85;
+ constexpr inline auto y = 400;
+ constexpr inline auto w = style::window_width - 2 * x;
+
+ constexpr inline auto size = 60;
+ constexpr inline auto margin = 10;
+ } // namespace pin_label
+
+ namespace title
+ {
+ constexpr inline auto x = 0;
+ constexpr inline auto y = 60;
+ constexpr inline auto w = style::window_width;
+ constexpr inline auto h = 50;
+ } // namespace title
+
+ namespace ice
+ {
+ constexpr inline auto x = style::window::default_left_margin;
+ constexpr inline auto y = title::y;
+ constexpr inline auto w = 60;
+ constexpr inline auto h = title::h;
+
+ constexpr inline auto margin = 3;
+
+ namespace text
+ {
+ constexpr inline auto w = 40;
+ }
+
+ } // namespace ice
+
+ namespace primary_text
+ {
+ constexpr inline auto x = style::window::default_left_margin;
+ constexpr inline auto y = 294;
+ constexpr inline auto w = style::window_width - 2 * x;
+ constexpr inline auto h = 60;
+ } // namespace primary_text
+
+ namespace secondary_text
+ {
+ constexpr inline auto x = style::window::default_left_margin;
+ constexpr inline auto y = primary_text::y + primary_text::h + 30;
+ constexpr inline auto w = style::window_width - 2 * x;
+ constexpr inline auto h = 90;
+ } // namespace secondary_text
+
} // namespace style::window::pin_lock
M module-apps/application-desktop/widgets/PinLockHandler.cpp => module-apps/application-desktop/widgets/PinLockHandler.cpp +2 -1
@@ 73,6 73,7 @@ namespace gui
void PinLockHandler::handlePasscodeRequest(PinLock::LockType type, app::manager::actions::ActionParamsPtr &&data)
{
LOG_DEBUG("Handling on of PasscodeRequest actions");
+ promptSimLockWindow = true;
handlePasscodeParams(type, PinLock::LockState::PasscodeRequired, std::move(data));
if (!getStrongestLock().isType(PinLock::LockType::Screen)) {
unlock();
@@ 129,9 130,9 @@ namespace gui
{
auto lock = std::make_unique<gui::PinLock>(getStrongestLock());
if (lock->isState(PinLock::LockState::PasscodeInvalidRetryRequired)) {
+ getStrongestLock().consumeState();
lock->onActivatedCallback = [this, onLockActivatedCallback](PinLock::LockType,
const std::vector<unsigned int> &) {
- getStrongestLock().consumeState();
switchToPinLockWindow(onLockActivatedCallback);
};
}
M module-apps/application-desktop/widgets/PinLockHandler.hpp => module-apps/application-desktop/widgets/PinLockHandler.hpp +4 -0
@@ 59,6 59,10 @@ namespace gui
{
return !screenLock.isState(PinLock::LockState::Unlocked);
}
+ [[nodiscard]] auto isScreenBlocked() const noexcept -> bool
+ {
+ return screenLock.isState(PinLock::LockState::Blocked);
+ }
void lockScreen();
void unlockScreen();
};
M module-apps/application-desktop/windows/DesktopMainWindow.cpp => module-apps/application-desktop/windows/DesktopMainWindow.cpp +7 -1
@@ 91,8 91,10 @@ namespace gui
auto app = getAppDesktop();
if (app->lockHandler.isScreenLocked()) {
bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get("app_desktop_unlock"));
- bottomBar->setActive(BottomBar::Side::LEFT, false);
bottomBar->setActive(BottomBar::Side::RIGHT, false);
+ bottomBar->setText(BottomBar::Side::LEFT,
+ utils::localize.get("app_desktop_emergency"),
+ app->lockHandler.isScreenBlocked());
topBar->setActive(TopBar::Elements::LOCK, true);
inputCallback = nullptr;
setFocusItem(nullptr);
@@ 194,6 196,10 @@ namespace gui
getAppDesktop()->lockHandler.unlockScreen();
return true;
}
+ else if (inputEvent.is(KeyCode::KEY_LF) && bottomBar->isActive(BottomBar::Side::LEFT)) {
+ app::manager::Controller::sendAction(application, app::manager::actions::ShowEmergencyContacts);
+ return true;
+ }
else if (enter_cache.storeEnter(inputEvent)) {
return true;
}
M module-apps/application-desktop/windows/LockedInfoWindow.cpp => module-apps/application-desktop/windows/LockedInfoWindow.cpp +8 -9
@@ 63,23 63,22 @@ void LockedInfoWindow::rebuild()
void LockedInfoWindow::buildInterface()
{
+ namespace lock_style = style::window::pin_lock;
AppWindow::buildInterface();
bottomBar->setText(BottomBar::Side::LEFT, utils::localize.get("app_desktop_emergency"));
bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get("common_back"));
- lockImage =
- new gui::Image(this, style::window::pin_lock::image_x, style::window::pin_lock::image_y, 0, 0, "pin_lock");
-
- infoText = new Text(this,
- 0,
- style::window::pin_lock::info_text_y,
- style::window_width,
- style::window::pin_lock::info_text_h_screen);
+ lockImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, "pin_lock");
+ infoText = new Text(this,
+ lock_style::primary_text::x,
+ lock_style::primary_text::y,
+ lock_style::primary_text::w,
+ lock_style::primary_text::h);
TextFormat format(FontManager::getInstance().getFont(style::window::font::medium));
text::RichTextParser rtParser;
- auto parsedText = rtParser.parse(utils::localize.get("app_desktop_no_pin_lock"), &format);
+ auto parsedText = rtParser.parse(utils::localize.get("app_desktop_press_to_unlock"), &format);
infoText->setText(std::move(parsedText));
infoText->setAlignment(Alignment::Horizontal::Center);
M module-apps/application-desktop/windows/PinLockBaseWindow.cpp => module-apps/application-desktop/windows/PinLockBaseWindow.cpp +111 -21
@@ 6,6 6,8 @@
#include "application-desktop/widgets/PinLock.hpp"
#include <module-utils/i18n/i18n.hpp>
+#include "FontManager.hpp"
+
namespace lock_style = style::window::pin_lock;
namespace gui
{
@@ 14,7 16,8 @@ namespace gui
{
buildBottomBar();
buildTopBar();
- buildTitleLabel();
+ buildTitleBar();
+ buildInfoTexts();
}
void PinLockBaseWindow::buildBottomBar()
{
@@ 29,23 32,47 @@ namespace gui
topBar->setActive(TopBar::Elements::BATTERY, true);
topBar->setActive(TopBar::Elements::LOCK, true);
}
- void PinLockBaseWindow::buildTitleLabel()
+ void PinLockBaseWindow::buildTitleBar()
{
- titleLabel = new gui::Label(this, 0, lock_style::title_label_y, style::window_width, lock_style::title_label_h);
- titleLabel->setFilled(false);
- titleLabel->setVisible(false);
- titleLabel->setBorderColor(gui::ColorFullBlack);
- titleLabel->setFont(style::header::font::title);
- titleLabel->setText(utils::localize.get("app_desktop_pin_info1"));
- titleLabel->setEdges(RectangleEdge::None);
- titleLabel->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
+ using namespace style::window::pin_lock;
+
+ iceBox = new gui::HBox(this, ice::x, ice::y, ice::w, ice::h);
+ iceBox->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center));
+ iceBox->setEdges(RectangleEdge::None);
+ iceBox->setVisible(false);
+
+ auto arrow = new gui::Image("left_label_arrow");
+ arrow->activeItem = false;
+ arrow->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center));
+ arrow->setMargins(Margins(0, 0, ice::margin, 0));
+ iceBox->addWidget(arrow);
+
+ auto iceText = new gui::Text(nullptr, 0, 0, ice::text::w, ice::h);
+ iceText->activeItem = false;
+ iceText->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center));
+ iceText->setFont(style::window::font::verysmall);
+ iceText->setText(utils::localize.get("app_desktop_emergency"));
+ iceBox->addWidget(iceText);
+
+ title = new gui::Text(this, title::x, title::y, title::w, title::h);
+ title->setFilled(false);
+ title->setBorderColor(gui::ColorFullBlack);
+ title->setFont(style::header::font::title);
+ title->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
+ title->setVisible(false);
+ title->setPenWidth(2);
}
- void PinLockBaseWindow::buildInfoText(unsigned int h)
+ void PinLockBaseWindow::buildInfoTexts()
{
- infoText = new Text(this, 0, lock_style::info_text_y, style::window_width, h);
- infoText->setFont(style::window::font::medium);
- infoText->setVisible(true);
- infoText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
+ using namespace style::window::pin_lock;
+
+ primaryText = new Text(this, primary_text::x, primary_text::y, primary_text::w, primary_text::h);
+ primaryText->setFont(style::window::font::medium);
+ primaryText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
+
+ secondaryText = new Text(this, secondary_text::x, secondary_text::y, secondary_text::w, secondary_text::h);
+ secondaryText->setFont(style::window::font::medium);
+ secondaryText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
}
void PinLockBaseWindow::buildPinLabels(std::function<Rect *()> itemBuilder,
unsigned int pinSize,
@@ 53,7 80,7 @@ namespace gui
unsigned int offsetY,
unsigned int boxWidth)
{
- pinLabelsBox = new gui::HBox(this, offsetX, offsetY, boxWidth, lock_style::label_size);
+ pinLabelsBox = new gui::HBox(this, offsetX, offsetY, boxWidth, lock_style::pin_label::size);
pinLabelsBox->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
if (pinSize == 0) {
@@ 73,9 100,8 @@ namespace gui
}
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);
- infoImage = new gui::Image(this, lock_style::image_x, lock_style::image_y, 0, 0, infoImg);
- infoImage->setVisible(false);
+ lockImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, lockImg);
+ infoImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, infoImg);
}
void PinLockBaseWindow::setBottomBarWidgetsActive(bool left, bool center, bool right)
{
@@ 88,8 114,72 @@ namespace gui
lockImage->setVisible(lockImg);
infoImage->setVisible(infoImg);
}
- void PinLockBaseWindow::setBottomBarWidgetText(BottomBar::Side side, const UTF8 &txt)
+
+ void PinLockBaseWindow::setTitleBar(bool isVisible, bool isIceActive)
+ {
+ iceBox->setVisible(isIceActive);
+ title->setVisible(isVisible);
+ if (isVisible) {
+ title->setEdges(RectangleEdge::Bottom);
+ }
+ else {
+ title->clear();
+ title->setEdges(RectangleEdge::None);
+ }
+ }
+
+ void PinLockBaseWindow::setText(const std::string &value,
+ TextType type,
+ bool isReach,
+ text::RichTextParser::TokenMap tokens)
+ {
+ auto text = getText(type);
+ text->setVisible(true);
+ if (isReach) {
+ TextFormat format(FontManager::getInstance().getFont(style::window::font::medium));
+ text::RichTextParser rtParser;
+ auto parsedText = rtParser.parse(utils::localize.get(value), &format, std::move(tokens));
+ text->setText(std::move(parsedText));
+ }
+ else {
+ text->setText(utils::localize.get(value));
+ }
+ }
+
+ auto PinLockBaseWindow::getText(TextType type) noexcept -> gui::Text *
+ {
+ if (type == TextType::Title) {
+ return title;
+ }
+ else if (type == TextType::Primary) {
+ return primaryText;
+ }
+ return secondaryText;
+ }
+
+ void PinLockBaseWindow::restore() noexcept
+ {
+ primaryText->setVisible(false);
+ secondaryText->setVisible(false);
+ lockImage->setVisible(false);
+ infoImage->setVisible(false);
+ pinLabelsBox->setVisible(false);
+ }
+
+ auto PinLockBaseWindow::getToken(Token token) const -> std::string
{
- bottomBar->setText(side, txt, false);
+ if (token == Token::Sim) {
+ return "$SIM";
+ }
+ else if (token == Token::Attempts) {
+ return "$ATTEMPTS";
+ }
+ else if (token == Token::Mins) {
+ return "$MINUTES";
+ }
+ else if (token == Token::CmeCode) {
+ return "$CMECODE";
+ }
+ return std::string{};
}
} // namespace gui
M module-apps/application-desktop/windows/PinLockBaseWindow.hpp => module-apps/application-desktop/windows/PinLockBaseWindow.hpp +31 -5
@@ 6,6 6,8 @@
#include "AppWindow.hpp"
#include "Text.hpp"
+#include "RichTextParser.hpp"
+
namespace gui
{
class PinLock;
@@ 16,10 18,25 @@ namespace gui
class PinLockBaseWindow : public AppWindow
{
public:
+ enum class TextType
+ {
+ Title,
+ Primary,
+ Secondary
+ };
+
+ enum class Token
+ {
+ Sim,
+ Attempts,
+ Mins,
+ CmeCode
+ };
+
PinLockBaseWindow(app::Application *app, std::string name) : AppWindow(app, name)
{}
void build();
- void buildInfoText(unsigned int textHight);
+ void buildInfoTexts();
void buildPinLabels(std::function<Rect *()> itemBuilder,
unsigned int pinSize,
unsigned int offsetX,
@@ 28,10 45,18 @@ namespace gui
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 setTitleBar(bool isVisible, bool isIceActive);
+ void setText(const std::string &value,
+ TextType type,
+ bool isReach = false,
+ text::RichTextParser::TokenMap tokens = text::RichTextParser::TokenMap{});
+ void restore() noexcept;
+ [[nodiscard]] auto getToken(Token token) const -> std::string;
- gui::Label *titleLabel = nullptr;
- gui::Text *infoText = nullptr;
+ gui::HBox *iceBox = nullptr;
+ gui::Text *title = nullptr;
+ gui::Text *primaryText = nullptr;
+ gui::Text *secondaryText = nullptr;
gui::Image *lockImage = nullptr;
gui::Image *infoImage = nullptr;
gui::HBox *pinLabelsBox = nullptr;
@@ 41,6 66,7 @@ namespace gui
private:
void buildBottomBar();
void buildTopBar();
- void buildTitleLabel();
+ void buildTitleBar();
+ [[nodiscard]] auto getText(TextType type) noexcept -> gui::Text *;
};
} // namespace gui
M module-apps/application-desktop/windows/PinLockBox.hpp => module-apps/application-desktop/windows/PinLockBox.hpp +0 -1
@@ 29,7 29,6 @@ namespace gui
virtual void clear() = 0;
virtual void setVisibleStateEnterPin(EnterPasscodeType type) = 0;
- virtual void setVisibleStateVerifiedPin() = 0;
virtual void setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value) = 0;
virtual void setVisibleStateBlocked() = 0;
M module-apps/application-desktop/windows/PinLockWindow.cpp => module-apps/application-desktop/windows/PinLockWindow.cpp +14 -7
@@ 47,15 47,18 @@ namespace gui
void PinLockWindow::invalidate() noexcept
{
- titleLabel = nullptr;
+ iceBox = nullptr;
+ title = nullptr;
lockImage = nullptr;
infoImage = nullptr;
- infoText = nullptr;
+ primaryText = nullptr;
+ secondaryText = nullptr;
pinLabelsBox = nullptr;
}
void PinLockWindow::setVisibleState()
{
+ restore();
if (lock->isState(PinLock::LockState::PasscodeRequired)) {
LockBox->setVisibleStateEnterPin(PinLockBox::EnterPasscodeType::ProvidePasscode);
}
@@ 83,11 86,8 @@ namespace gui
void PinLockWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
- if (mode == ShowMode::GUI_SHOW_INIT) {
- rebuild();
- }
if (auto lockData = dynamic_cast<LockPhoneData *>(data)) {
- assert(lockData);
+ rebuild();
lockTimeoutApplication = lockData->getPreviousApplication();
lock = lockData->getLock();
assert(lock);
@@ 111,7 111,11 @@ 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.is(KeyCode::KEY_LEFT) && iceBox->visible) {
+ app::manager::Controller::sendAction(application, app::manager::actions::ShowEmergencyContacts);
+ return true;
+ }
+ else if (inputEvent.is(KeyCode::KEY_LF) && bottomBar->isActive(BottomBar::Side::LEFT)) {
app::manager::Controller::sendAction(application, app::manager::actions::ShowEmergencyContacts);
return true;
}
@@ 143,6 147,7 @@ namespace gui
}
else if (inputEvent.is(KeyCode::KEY_ENTER) && bottomBar->isActive(BottomBar::Side::CENTER)) {
lock->activate();
+ bottomBar->setActive(BottomBar::Side::CENTER, false);
return true;
}
// check if any of the lower inheritance onInput methods catch the event
@@ 157,6 162,8 @@ namespace gui
}
else if (lockType == PinLock::LockType::SimPuk) {
LockBox = std::make_unique<PukLockBox>(this);
+ setTitleBar(true, true);
+ setText("app_desktop_header_sim_setup", TextType::Title, true, {{getToken(Token::Sim), "SIM1"}});
}
else if (lockType == PinLock::LockType::SimPin) {
LockBox = std::make_unique<SimLockBox>(this);
M module-apps/application-desktop/windows/PukLockBox.cpp => module-apps/application-desktop/windows/PukLockBox.cpp +24 -56
@@ 6,13 6,11 @@
#include "PinLockBaseWindow.hpp"
#include "application-desktop/widgets/PinLock.hpp"
#include "application-desktop/data/AppDesktopStyle.hpp"
-#include "gui/widgets/Label.hpp"
#include "gui/widgets/Image.hpp"
#include <module-utils/i18n/i18n.hpp>
#include <Style.hpp>
-namespace lock_style = style::window::pin_lock;
-
+namespace label_style = style::window::pin_lock::pin_label;
namespace gui
{
void PukLockBox::popChar(unsigned int charNum)
@@ 26,7 24,6 @@ namespace gui
void PukLockBox::buildLockBox(unsigned int pinSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
- LockWindow->buildInfoText(lock_style::info_text_h_puk);
buildPinLabels(0);
}
void PukLockBox::buildPinLabels(unsigned int pinSize)
@@ 36,11 33,7 @@ namespace gui
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->buildPinLabels(itemBuilder, pinSize, label_style::x, label_style::y, label_style::w);
LockWindow->pinLabelsBox->setEdges(RectangleEdge::Bottom);
}
@@ 53,80 46,55 @@ namespace gui
void PukLockBox::setVisibleStateEnterPin(EnterPasscodeType type)
{
LockWindow->pinLabelsBox->setVisible(true);
- LockWindow->infoText->clear();
-
switch (type) {
- case PinLockBox::EnterPasscodeType::ProvidePasscode:
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_blocked"));
- LockWindow->infoText->addText("\n");
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_type_puk"));
+ case PinLockBox::EnterPasscodeType::ProvidePasscode: {
+ LockWindow->setText("app_desktop_sim_setup_enter_puk", PinLockBaseWindow::TextType::Primary, true);
break;
- case PinLockBox::EnterPasscodeType::ProvideNewPasscode:
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_enter_pin"));
+ }
+ case PinLockBox::EnterPasscodeType::ProvideNewPasscode: {
+ LockWindow->setText("app_desktop_sim_enter_new_pin", PinLockBaseWindow::TextType::Primary);
break;
+ }
case PinLockBox::EnterPasscodeType::ConfirmNewPasscode:
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_confirm_pin"));
+ LockWindow->setText("app_desktop_sim_confirm_new_pin", PinLockBaseWindow::TextType::Primary);
+ break;
}
- LockWindow->infoText->setVisible(true);
LockWindow->setImagesVisible(true, false);
LockWindow->setBottomBarWidgetsActive(false, false, true);
}
- void PukLockBox::setVisibleStateVerifiedPin()
- {
- LockWindow->pinLabelsBox->setVisible(false);
- LockWindow->infoText->setVisible(false);
- }
void PukLockBox::setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value)
{
- LockWindow->pinLabelsBox->setVisible(false);
- LockWindow->infoText->clear();
-
switch (type) {
case PinLockBox::PasscodeErrorType::InvalidPasscode:
-
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_wrong_puk"));
- LockWindow->infoText->addText("\n");
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_you_have"));
- LockWindow->infoText->addText(" ");
- LockWindow->infoText->addText(std::to_string(value));
- LockWindow->infoText->addText(" ");
-
if (value > 1) {
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_attempt_left_plural"));
+ LockWindow->setText("app_desktop_sim_setup_wrong_puk",
+ PinLockBaseWindow::TextType::Primary,
+ true,
+ {{LockWindow->getToken(PinLockBaseWindow::Token::Attempts), value}});
}
else {
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_attempt_left_singular"));
- LockWindow->infoText->addText("\n\n");
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_warning1"));
- LockWindow->infoText->addText("\n");
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_warning2"));
- LockWindow->infoText->addText("\n");
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_warning3"));
+ LockWindow->setText(
+ "app_desktop_sim_setup_wrong_puk_last_attempt", PinLockBaseWindow::TextType::Primary, true);
+ LockWindow->setText("app_desktop_sim_setup_wrong_puk_last_attempt_warning",
+ PinLockBaseWindow::TextType::Secondary,
+ true);
}
break;
- case PinLockBox::PasscodeErrorType::NewPasscodeConfirmFailed:
- LockWindow->infoText->setText(utils::localize.get("app_desktop_sim_wrong_pin"));
+ case PinLockBox::PasscodeErrorType::NewPasscodeConfirmFailed: {
+ LockWindow->setText("app_desktop_sim_wrong_pin", PinLockBaseWindow::TextType::Primary);
break;
+ }
case PinLockBox::PasscodeErrorType::UnhandledError:
LOG_ERROR("No use case for UnhandledError in PukLockBox");
break;
}
-
- LockWindow->infoText->setVisible(true);
LockWindow->setImagesVisible(false, true);
- LockWindow->setBottomBarWidgetsActive(true, true, false);
+ LockWindow->setBottomBarWidgetsActive(false, true, false);
}
void PukLockBox::setVisibleStateBlocked()
{
- LockWindow->pinLabelsBox->setVisible(false);
-
- LockWindow->infoText->clear();
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_blocked_info1"));
- LockWindow->infoText->addText("\n");
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_blocked_info2"));
- LockWindow->infoText->setVisible(true);
-
+ LockWindow->setText("app_desktop_sim_puk_blocked", PinLockBaseWindow::TextType::Primary, true);
LockWindow->setImagesVisible(false, true);
LockWindow->setBottomBarWidgetsActive(true, false, false);
}
M module-apps/application-desktop/windows/PukLockBox.hpp => module-apps/application-desktop/windows/PukLockBox.hpp +1 -2
@@ 22,10 22,9 @@ namespace gui
PinLockBaseWindow *LockWindow;
void popChar(unsigned int charNum) final;
void putChar(unsigned int charNum) final;
- virtual void clear() final;
+ void clear() final;
void setVisibleStateEnterPin(EnterPasscodeType type) final;
- void setVisibleStateVerifiedPin() final;
void setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value) final;
void setVisibleStateBlocked() final;
M module-apps/application-desktop/windows/ScreenLockBox.cpp => module-apps/application-desktop/windows/ScreenLockBox.cpp +28 -40
@@ 10,11 10,13 @@
#include "gui/widgets/Image.hpp"
#include <module-utils/i18n/i18n.hpp>
-namespace lock_style = style::window::pin_lock;
+namespace label_style = style::window::pin_lock::pin_label;
namespace gui
{
+ constexpr auto timeToUnlock = 10;
+
ScreenLockBox::PinLabel::PinLabel(Item *parent, uint32_t w, uint32_t h) : HBox(parent, 0, 0, w, h)
{}
void ScreenLockBox::PinLabel::setVisibleState(bool isImageVisible)
@@ 46,7 48,6 @@ namespace gui
void ScreenLockBox::buildLockBox(unsigned int pinSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
- LockWindow->buildInfoText(lock_style::info_text_h_screen);
ScreenLockBox::buildPinLabels(pinSize);
}
void ScreenLockBox::buildPinLabels(unsigned int pinSize)
@@ 58,80 59,67 @@ namespace gui
return;
}
- unsigned int singleLabelWidth = lock_style::label_size;
- unsigned int maxNoMarginsLabelsWidth = pinLabelWidth - pinSize * 2 * lock_style::label_margins;
+ unsigned int singleLabelWidth = label_style::size;
+ unsigned int maxNoMarginsLabelsWidth = pinLabelWidth - pinSize * 2 * label_style::margin;
if (pinSize * singleLabelWidth > maxNoMarginsLabelsWidth) {
singleLabelWidth = maxNoMarginsLabelsWidth / pinSize;
}
auto itemBuilder = [this, singleLabelWidth]() {
- auto label = new PinLabel(nullptr, singleLabelWidth, lock_style::label_size);
+ auto label = new PinLabel(nullptr, singleLabelWidth, label_style::size);
label->setEdges(RectangleEdge::Bottom);
- label->setMargins(Margins(lock_style::label_margins, 0, lock_style::label_margins, 0));
+ label->setMargins(Margins(label_style::margin, 0, label_style::margin, 0));
pinLabels.push_back(label);
return label;
};
LockWindow->buildPinLabels(
- itemBuilder, pinSize, style::window::default_left_margin, lock_style::pin_label_y_screen, pinLabelWidth);
+ itemBuilder, pinSize, style::window::default_left_margin, label_style::y, pinLabelWidth);
LockWindow->pinLabelsBox->setEdges(RectangleEdge::None);
}
void ScreenLockBox::setVisibleStateEnterPin(EnterPasscodeType type)
{
LockWindow->pinLabelsBox->setVisible(true);
-
- LockWindow->infoText->clear();
- LockWindow->infoText->addText(utils::localize.get("app_desktop_screen_enter_passcode"));
- LockWindow->infoText->setVisible(true);
-
+ LockWindow->setText("app_desktop_screen_enter_passcode_to_unlock", PinLockBaseWindow::TextType::Primary, true);
LockWindow->setImagesVisible(true, false);
LockWindow->setBottomBarWidgetsActive(true, false, true);
}
- void ScreenLockBox::setVisibleStateVerifiedPin()
- {
- clear();
- LockWindow->pinLabelsBox->setVisible(false);
- LockWindow->titleLabel->setVisible(false);
- }
+
void ScreenLockBox::setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value)
{
- clear();
- LockWindow->pinLabelsBox->setVisible(false);
- LockWindow->infoText->clear();
- LockWindow->titleLabel->setVisible(true);
switch (type) {
case PinLockBox::PasscodeErrorType::InvalidPasscode:
- LockWindow->titleLabel->setText(utils::localize.get("app_desktop_screen_wrong_pin"));
-
- LockWindow->infoText->addText(utils::localize.get(utils::localize.get("app_desktop_sim_you_have")));
- LockWindow->infoText->addText(" ");
- LockWindow->infoText->addText(std::to_string(value));
- LockWindow->infoText->addText(" ");
- LockWindow->infoText->addText(
- utils::localize.get(utils::localize.get("app_desktop_sim_attempt_left_plural")));
+ LockWindow->setTitleBar(false, false);
+ if (value == 1) {
+ LockWindow->setText(
+ "app_desktop_screen_wrong_passcode_last_attempt", PinLockBaseWindow::TextType::Primary, true);
+ LockWindow->setText("app_desktop_screen_wrong_passcode_last_attempt_warning",
+ PinLockBaseWindow::TextType::Secondary,
+ true,
+ {{LockWindow->getToken(PinLockBaseWindow::Token::Mins), timeToUnlock}});
+ }
+ else {
+ LockWindow->setText("app_desktop_screen_wrong_passcode",
+ PinLockBaseWindow::TextType::Primary,
+ true,
+ {{LockWindow->getToken(PinLockBaseWindow::Token::Attempts), value}});
+ }
break;
+
case PinLockBox::PasscodeErrorType::NewPasscodeConfirmFailed:
- LockWindow->titleLabel->setText(utils::localize.get("app_desktop_screen_wrong_passcode"));
+ LockWindow->setText("app_desktop_screen_setup_wrong_passcode", PinLockBaseWindow::TextType::Primary, true);
break;
case PinLockBox::PasscodeErrorType::UnhandledError:
LOG_ERROR("No use case for UnhandledError");
break;
}
-
- LockWindow->infoText->setVisible(true);
LockWindow->setImagesVisible(false, true);
LockWindow->setBottomBarWidgetsActive(false, true, true);
}
void ScreenLockBox::setVisibleStateBlocked()
{
- LockWindow->pinLabelsBox->setVisible(false);
- LockWindow->titleLabel->setVisible(false);
-
- LockWindow->infoText->clear();
- LockWindow->infoText->addText(utils::localize.get(utils::localize.get("app_desktop_screen_blocked_info")));
- LockWindow->infoText->setVisible(true);
-
+ LockWindow->setText("app_desktop_screen_blocked", PinLockBaseWindow::TextType::Primary);
LockWindow->setImagesVisible(false, true);
LockWindow->setBottomBarWidgetsActive(false, true, false);
}
M module-apps/application-desktop/windows/ScreenLockBox.hpp => module-apps/application-desktop/windows/ScreenLockBox.hpp +1 -2
@@ 32,10 32,9 @@ namespace gui
PinLockBaseWindow *LockWindow;
void popChar(unsigned int charNum) final;
void putChar(unsigned int charNum) final;
- virtual void clear() final;
+ void clear() final;
void setVisibleStateEnterPin(EnterPasscodeType type) final;
- void setVisibleStateVerifiedPin() final;
void setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value) final;
void setVisibleStateBlocked() final;
M module-apps/application-desktop/windows/SimLockBox.cpp => module-apps/application-desktop/windows/SimLockBox.cpp +23 -56
@@ 6,14 6,9 @@
#include "PinLockBaseWindow.hpp"
#include "application-desktop/widgets/PinLock.hpp"
#include "application-desktop/data/AppDesktopStyle.hpp"
-#include "gui/widgets/Label.hpp"
-#include "RichTextParser.hpp"
-#include "FontManager.hpp"
-
-#include <module-utils/i18n/i18n.hpp>
#include <Style.hpp>
-namespace lock_style = style::window::pin_lock;
+namespace label_style = style::window::pin_lock::pin_label;
namespace gui
{
@@ 30,7 25,6 @@ namespace gui
void SimLockBox::buildLockBox(unsigned int pinSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
- LockWindow->buildInfoText(lock_style::info_text_h_sim);
buildPinLabels(0);
}
void SimLockBox::buildPinLabels(unsigned int pinSize)
@@ 40,11 34,7 @@ namespace gui
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->buildPinLabels(itemBuilder, pinSize, label_style::x, label_style::y, label_style::w);
LockWindow->pinLabelsBox->setEdges(RectangleEdge::Bottom);
}
@@ 57,79 47,56 @@ namespace gui
void SimLockBox::setVisibleStateEnterPin(EnterPasscodeType type)
{
LockWindow->pinLabelsBox->setVisible(true);
- LockWindow->infoText->clear();
-
switch (type) {
- case PinLockBox::EnterPasscodeType::ProvidePasscode:
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_to_unlock"));
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_card"));
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_type_pin"));
+ case PinLockBox::EnterPasscodeType::ProvidePasscode: {
+ LockWindow->setText("app_desktop_sim_enter_pin_unlock", PinLockBaseWindow::TextType::Primary, true);
break;
+ }
case PinLockBox::EnterPasscodeType::ProvideNewPasscode:
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_enter_pin"));
+ LockWindow->setText("app_desktop_sim_enter_new_pin", PinLockBaseWindow::TextType::Primary);
break;
case PinLockBox::EnterPasscodeType::ConfirmNewPasscode:
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_confirm_pin"));
+ LockWindow->setText("app_desktop_sim_confirm_new_pin", PinLockBaseWindow::TextType::Primary);
break;
}
- LockWindow->infoText->setVisible(true);
LockWindow->setImagesVisible(true, false);
LockWindow->setBottomBarWidgetsActive(false, false, true);
}
- void SimLockBox::setVisibleStateVerifiedPin()
- {
- LockWindow->infoText->clear();
- LockWindow->infoText->setVisible(false);
- LockWindow->pinLabelsBox->setVisible(false);
- }
void SimLockBox::setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value)
{
- LockWindow->pinLabelsBox->setVisible(false);
-
- LockWindow->infoText->clear();
-
switch (type) {
case PinLockBox::PasscodeErrorType::InvalidPasscode:
- LockWindow->infoText->addText(utils::localize.get(utils::localize.get("app_desktop_sim_wrong_pin")));
- LockWindow->infoText->addText("\n");
- LockWindow->infoText->addText(utils::localize.get(utils::localize.get("app_desktop_sim_you_have")));
- LockWindow->infoText->addText(" ");
- LockWindow->infoText->addText(std::to_string(value));
- LockWindow->infoText->addText(" ");
- if (value > 1) {
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_attempt_left_plural"));
+ if (value == 1) {
+ LockWindow->setText(
+ "app_desktop_sim_setup_wrong_pin_last_attempt", PinLockBaseWindow::TextType::Primary, true);
}
else {
- LockWindow->infoText->addText(utils::localize.get("app_desktop_sim_attempt_left_singular"));
+ LockWindow->setText("app_desktop_sim_setup_wrong_pin",
+ PinLockBaseWindow::TextType::Primary,
+ true,
+ {{LockWindow->getToken(PinLockBaseWindow::Token::Attempts), value}});
}
- LockWindow->infoText->setVisible(true);
-
- LockWindow->setImagesVisible(false, true);
- LockWindow->setBottomBarWidgetsActive(true, true, true);
break;
case PinLockBox::PasscodeErrorType::NewPasscodeConfirmFailed:
- LockWindow->infoText->setText(utils::localize.get("app_desktop_sim_wrong_pin"));
+ LockWindow->setText("app_desktop_sim_wrong_pin", PinLockBaseWindow::TextType::Primary);
break;
case PinLockBox::PasscodeErrorType::UnhandledError: {
- TextFormat format(FontManager::getInstance().getFont(style::window::font::medium));
- text::RichTextParser rtParser;
- auto parsedText = rtParser.parse(utils::localize.get("app_desktop_sim_cme_error"), &format);
- LockWindow->infoText->setText(std::move(parsedText));
- LockWindow->infoText->addText(std::to_string(value));
+ LockWindow->setText("app_desktop_sim_cme_error",
+ PinLockBaseWindow::TextType::Primary,
+ true,
+ {{LockWindow->getToken(PinLockBaseWindow::Token::CmeCode), value}});
break;
}
}
+ LockWindow->setImagesVisible(false, true);
+ LockWindow->setBottomBarWidgetsActive(false, true, true);
}
void SimLockBox::setVisibleStateBlocked()
{
- LockWindow->pinLabelsBox->setVisible(false);
- LockWindow->infoText->clear();
- LockWindow->infoText->addText(utils::localize.get(utils::localize.get("app_desktop_puk_lock1")));
- LockWindow->infoText->setVisible(true);
-
+ LockWindow->setText("app_desktop_sim_puk_blocked", PinLockBaseWindow::TextType::Primary);
LockWindow->setImagesVisible(false, true);
- LockWindow->setBottomBarWidgetsActive(true, true, true);
+ LockWindow->setBottomBarWidgetsActive(false, true, true);
}
void SimLockBox::clear()
M module-apps/application-desktop/windows/SimLockBox.hpp => module-apps/application-desktop/windows/SimLockBox.hpp +1 -2
@@ 22,10 22,9 @@ namespace gui
PinLockBaseWindow *LockWindow;
void popChar(unsigned int charNum) final;
void putChar(unsigned int charNum) final;
- virtual void clear() final;
+ void clear() final;
void setVisibleStateEnterPin(EnterPasscodeType type) final;
- void setVisibleStateVerifiedPin() final;
void setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value) final;
void setVisibleStateBlocked() final;