M image/assets/lang/English.json => image/assets/lang/English.json +1 -1
@@ 248,7 248,7 @@
"app_desktop_screen_wrong_passcode_last_attempt_warning": "<text>If the passcode is wrong this time,<br></br>you'll have to wait <token>$MINUTES</token> minutes<br></br>before trying again.</text>",
"app_desktop_screen_wrong_passcode": "<text>Wrong passcode.<br></br>You have <token>$ATTEMPTS</token> attempts left.</text>",
"app_desktop_screen_blocked_info": "Sorry, phone blocked",
- "app_desktop_press_to_unlock": "<text>Press <b>Unlock</b> and then <b>#</b></text>",
+ "app_desktop_press_to_unlock": "<text font='gt_pressura' size='27'>Press <b>Unlock</b> and then <b>#</b></text>",
"app_desktop_unread_messages": "<text>Unread <b>messages</b></text>",
"app_desktop_missed_calls": "<text>Missed <b>calls</b></text>",
"app_desktop_menu_phone": "CALLS",
M image/assets/lang/Svenska.json => image/assets/lang/Svenska.json +1 -1
@@ 234,7 234,7 @@
"app_desktop_screen_wrong_passcode_last_attempt_warning": "<text>Om lösenordet är fel den här gången,<br></br>måste du vänta <token>$MINUTES</token> minuter<br></br>innan nästa försök.</text>",
"app_desktop_screen_wrong_passcode": "<text>Fel lösenord.<br></br>Du har <token>$ATTEMPTS</token> försök kvar.</text>",
"app_desktop_screen_blocked_info": "Tyvärr, telefonen blockerad.",
- "app_desktop_press_to_unlock": "<text>Tryck <b>Lås upp</b> följt av <b>#</b></text>",
+ "app_desktop_press_to_unlock": "<text font='gt_pressura' size='27'>Tryck <b>Lås upp</b> följt av <b>#</b></text>",
"app_desktop_unread_messages": "<text>Olästa <b>meddelanden</b></text>",
"app_desktop_missed_calls": "<text>Missade <b>samtal</b></text>",
"app_desktop_menu_phone": "SAMTAL",
M module-apps/Application.cpp => module-apps/Application.cpp +1 -1
@@ 42,7 42,7 @@
#include <module-utils/time/DateAndTimeSettings.hpp>
#include <service-audio/AudioServiceAPI.hpp> // for GetOutputVolume
-#include <TetheringPhoneModePopup.hpp>
+#include <popups/TetheringPhoneModePopup.hpp>
#include "popups/data/PopupData.hpp"
namespace gui
M module-apps/Application.hpp => module-apps/Application.hpp +1 -2
@@ 28,10 28,9 @@
#include <utility> // for move, pair
#include <vector> // for vector
#include "TopBarManager.hpp"
-#include "popups/Popups.hpp"
#include "WindowsFactory.hpp"
#include "WindowsStack.hpp"
-#include "Popups.hpp"
+#include "popups/Popups.hpp"
namespace app
{
M module-apps/CMakeLists.txt => module-apps/CMakeLists.txt +3 -8
@@ 30,13 30,6 @@ set( SOURCES
"windows/NoEvents.cpp"
"widgets/ButtonOnOff.cpp"
"widgets/InputBox.cpp"
- "popups/Popups.cpp"
- "popups/VolumeWindow.cpp"
- "popups/WindowWithTimer.cpp"
- "popups/HomeModesWindow.cpp"
- "popups/TetheringNotificationPopup.cpp"
- "popups/TetheringConfirmationPopup.cpp"
- "popups/TetheringPhoneModePopup.cpp"
"windows/BrightnessWindow.cpp"
"widgets/BrightnessBox.cpp"
"widgets/ModesBox.cpp"
@@ 120,6 113,9 @@ include_directories( ../module-os )
include_directories( ../module-bsp )
include_directories( ../module-db )
+add_subdirectory(popups)
+add_subdirectory(locks)
+
target_link_libraries(${PROJECT_NAME}
PRIVATE
service-appmgr
@@ 156,7 152,6 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/messages
${CMAKE_CURRENT_SOURCE_DIR}/windows
- ${CMAKE_CURRENT_SOURCE_DIR}/popups
${CMAKE_CURRENT_SOURCE_DIR}/options
${CMAKE_CURRENT_SOURCE_DIR}/options/type
${CMAKE_BINARY_DIR}
M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +5 -4
@@ 6,7 6,7 @@
#include "MessageType.hpp"
#include "windows/DesktopMainWindow.hpp"
#include "windows/MenuWindow.hpp"
-#include "windows/PinLockWindow.hpp"
+#include "locks/windows/PinLockWindow.hpp"
#include "windows/PowerOffWindow.hpp"
#include "windows/DeadBatteryWindow.hpp"
#include "windows/LogoWindow.hpp"
@@ 25,7 25,8 @@
#include <messages/DialogMetadataMessage.hpp>
#include "AppWindow.hpp"
-#include "data/LockPhoneData.hpp"
+#include "locks/data/LockData.hpp"
+#include "data/DesktopData.hpp"
#include "models/ActiveNotificationsModel.hpp"
#include <service-db/DBServiceAPI.hpp>
@@ 86,7 87,7 @@ namespace app
bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
addActionReceiver(app::manager::actions::RequestPin, [this](auto &&data) {
- lockHandler.handlePasscodeRequest(gui::PinLock::LockType::SimPin, std::move(data));
+ lockHandler.handlePasscodeRequest(locks::Lock::LockType::SimPin, std::move(data));
return actionHandled();
});
@@ 96,7 97,7 @@ namespace app
});
addActionReceiver(app::manager::actions::RequestPuk, [this](auto &&data) {
- lockHandler.handlePasscodeRequest(gui::PinLock::LockType::SimPuk, std::move(data));
+ lockHandler.handlePasscodeRequest(locks::Lock::LockType::SimPuk, std::move(data));
return actionHandled();
});
M module-apps/application-desktop/ApplicationDesktop.hpp => module-apps/application-desktop/ApplicationDesktop.hpp +1 -1
@@ 4,7 4,7 @@
#pragma once
#include "windows/Names.hpp"
-#include "widgets/PinLockHandler.hpp"
+#include "locks/handlers/PinLockHandler.hpp"
#include <Application.hpp>
#include <Service/Message.hpp>
M module-apps/application-desktop/CMakeLists.txt => module-apps/application-desktop/CMakeLists.txt +2 -22
@@ 15,15 15,8 @@ target_sources( ${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/ApplicationDesktop.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/widgets/PinLock.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/widgets/PinLockHandler.cpp"
"${CMAKE_CURRENT_LIST_DIR}/widgets/DesktopInputWidget.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/DesktopMainWindow.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockBaseWindow.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/ScreenLockBox.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/SimLockBox.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/PukLockBox.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/MenuWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/PowerOffWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/DeadBatteryWindow.cpp"
@@ 37,27 30,16 @@ target_sources( ${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/windows/MmiPullWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/MmiPushWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/MmiInternalMsgWindow.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/ScreenLockBaseBox.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/LockWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/UpdateProgress.cpp"
"${CMAKE_CURRENT_LIST_DIR}/presenter/PowerOffPresenter.cpp"
"${CMAKE_CURRENT_LIST_DIR}/models/ActiveNotificationsModel.cpp"
PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/ApplicationDesktop.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/data/LockPhoneData.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/data/Style.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/data/DesktopData.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/data/DesktopStyle.hpp"
"${CMAKE_CURRENT_LIST_DIR}/data/Mmi.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/widgets/PinHash.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/widgets/PinLock.hpp"
"${CMAKE_CURRENT_LIST_DIR}/widgets/DesktopInputWidget.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/widgets/PinLockHandler.hpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/DesktopMainWindow.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockBaseWindow.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockBox.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/ScreenLockBox.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/SimLockBox.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/PukLockBox.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/MenuWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/PowerOffWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/LockedInfoWindow.hpp"
@@ 69,8 51,6 @@ target_sources( ${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/windows/MmiPullWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/MmiPushWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/MmiInternalMsgWindow.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/ScreenLockBaseBox.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/LockWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/models/ActiveNotificationsModel.hpp"
)
R module-apps/application-desktop/data/LockPhoneData.hpp => module-apps/application-desktop/data/DesktopData.hpp +6 -39
@@ 1,55 1,24 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#ifndef MODULE_APPS_APPLICATION_DESKTOP_DATA_LOCKPHONEDATA_HPP_
-#define MODULE_APPS_APPLICATION_DESKTOP_DATA_LOCKPHONEDATA_HPP_
+#pragma once
#include "gui/SwitchData.hpp"
#include <service-desktop/DesktopMessages.hpp>
#include <service-desktop/ServiceDesktop.hpp>
#include <filesystem>
-
-#include "application-desktop/widgets/PinLock.hpp"
+#include <utility>
namespace gui
{
- // class template that stores information that was sent along with switch message
- class LockPhoneData : public gui::SwitchData
- {
- std::string previousApplication;
- std::unique_ptr<PinLock> lock;
-
- public:
- LockPhoneData(std::unique_ptr<PinLock> &&lock) : SwitchData(), lock(std::move(lock))
- {
- description = "LockPhoneData";
- }
-
- virtual ~LockPhoneData(){};
-
- void setPrevApplication(const std::string &prevApp)
- {
- previousApplication = prevApp;
- };
- [[nodiscard]] const std::string &getPreviousApplication()
- {
- return previousApplication;
- };
-
- [[nodiscard]] std::unique_ptr<PinLock> getLock()
- {
- return std::make_unique<PinLock>(*lock.get());
- }
- };
-
class UpdateSwitchData : public gui::SwitchData
{
public:
- UpdateSwitchData(sdesktop::UpdateOsMessage *messageToCopyFrom) : updateOsMessage(*messageToCopyFrom)
+ explicit UpdateSwitchData(sdesktop::UpdateOsMessage *messageToCopyFrom) : updateOsMessage(*messageToCopyFrom)
{}
- const sdesktop::UpdateOsMessage &getUpdateOsMessage()
+ [[nodiscard]] const sdesktop::UpdateOsMessage &getUpdateOsMessage() const noexcept
{
return updateOsMessage;
}
@@ 70,10 39,8 @@ namespace gui
void setData(std::string version)
{
- osVersion = version;
+ osVersion = std::move(version);
}
};
} // namespace gui
-
-#endif /* MODULE_APPS_APPLICATION_DESKTOP_DATA_LOCKPHONEDATA_HPP_ */
R module-apps/application-desktop/data/Style.hpp => module-apps/application-desktop/data/DesktopStyle.hpp +2 -0
@@ 3,6 3,8 @@
#pragma once
+#include "Style.hpp"
+
namespace style::desktop
{
namespace timeLabel
M module-apps/application-desktop/windows/DesktopMainWindow.cpp => module-apps/application-desktop/windows/DesktopMainWindow.cpp +3 -2
@@ 8,8 8,9 @@
#include "DesktopMainWindow.hpp"
#include "GuiTimer.hpp"
#include "application-desktop/ApplicationDesktop.hpp"
-#include "application-desktop/data/LockPhoneData.hpp"
-#include "application-desktop/data/Style.hpp"
+#include "locks/data/LockData.hpp"
+#include "application-desktop/data/DesktopStyle.hpp"
+#include "application-desktop/data/DesktopData.hpp"
#include "application-messages/ApplicationMessages.hpp"
#include "gui/widgets/Image.hpp"
#include <service-appmgr/Controller.hpp>
M module-apps/application-desktop/windows/LockedInfoWindow.cpp => module-apps/application-desktop/windows/LockedInfoWindow.cpp +2 -1
@@ 9,7 9,8 @@
#include "RichTextParser.hpp"
#include "FontManager.hpp"
-#include "application-desktop/data/AppDesktopStyle.hpp"
+#include "application-desktop/data/DesktopStyle.hpp"
+#include "locks/data/LockStyle.hpp"
#include "Names.hpp"
#include <application-phonebook/ApplicationPhonebook.hpp>
M module-apps/application-desktop/windows/PostUpdateWindow.cpp => module-apps/application-desktop/windows/PostUpdateWindow.cpp +3 -2
@@ 12,8 12,9 @@
#include <module-gui/gui/widgets/TopBar.hpp>
#include <module-gui/gui/core/FontManager.hpp>
-#include <module-apps/application-desktop/data/AppDesktopStyle.hpp>
-#include <module-apps/application-desktop/data/LockPhoneData.hpp>
+#include <module-apps/application-desktop/data/DesktopStyle.hpp>
+#include <module-apps/application-desktop/data/DesktopData.hpp>
+#include <locks/data/LockStyle.hpp>
#include <module-apps/application-desktop/windows/Names.hpp>
#include <application-phonebook/ApplicationPhonebook.hpp>
M module-apps/application-desktop/windows/Update.cpp => module-apps/application-desktop/windows/Update.cpp +1 -1
@@ 4,7 4,7 @@
#include "log/log.hpp"
#include "gui/widgets/BottomBar.hpp"
#include "gui/widgets/TopBar.hpp"
-#include "../data/LockPhoneData.hpp"
+#include "application-desktop/data/DesktopData.hpp"
#include <source/version.hpp>
// module-utils
M module-apps/application-desktop/windows/UpdateProgress.cpp => module-apps/application-desktop/windows/UpdateProgress.cpp +2 -2
@@ 4,14 4,14 @@
#include <log/log.hpp>
#include <gui/widgets/BottomBar.hpp>
#include <gui/widgets/TopBar.hpp>
-#include <application-desktop/data/LockPhoneData.hpp>
#include <source/version.hpp>
// module-utils
#include <i18n/i18n.hpp>
#include <application-desktop/ApplicationDesktop.hpp>
-#include <application-desktop/data/Style.hpp>
+#include <application-desktop/data/DesktopStyle.hpp>
+#include <application-desktop/data/DesktopData.hpp>
// services
#include <service-appmgr/model/ApplicationManager.hpp>
M module-apps/application-onboarding/windows/ConfigurePasscodeWindow.cpp => module-apps/application-onboarding/windows/ConfigurePasscodeWindow.cpp +7 -7
@@ 2,10 2,10 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ConfigurePasscodeWindow.hpp"
+#include "locks/data/LockStyle.hpp"
#include <application-onboarding/ApplicationOnBoarding.hpp>
#include <application-onboarding/data/OnBoardingSwitchData.hpp>
-#include <application-desktop/data/AppDesktopStyle.hpp>
#include <application-settings-new/ApplicationSettings.hpp>
#include <application-settings-new/windows/ChangePasscodeWindow.hpp>
@@ 20,7 20,7 @@ namespace gui
{
ConfigurePasscodeWindow::ConfigurePasscodeWindow(app::Application *app) : ChangePasscodeWindow(app)
{
- lockState = PinLock::LockState::NewPasscodeRequired;
+ lockState = Lock::LockState::NewInputRequired;
textForEnterNewPassword = "app_onboarding_set_password";
testForConfirmPassword = "app_onboarding_confirm_password";
@@ 54,10 54,10 @@ namespace gui
void ConfigurePasscodeWindow::processPasscode()
{
switch (lockState) {
- case PinLock::LockState::NewPasscodeConfirmRequired:
- case PinLock::LockState::NewPasscodeInvalid: {
+ case Lock::LockState::NewInputConfirmRequired:
+ case Lock::LockState::NewInputInvalid: {
lockState = lockHandler.newPasscodeConfirmed();
- if (lockState == PinLock::LockState::Unlocked) {
+ if (lockState == Lock::LockState::Unlocked) {
auto app = static_cast<app::ApplicationOnBoarding *>(application);
app->setLockPassHash(lockHandler.getNewPasscodeHash());
}
@@ 71,7 71,7 @@ namespace gui
void ConfigurePasscodeWindow::setVisibleState()
{
switch (lockState) {
- case PinLock::LockState::NewPasscodeInvalid: {
+ case Lock::LockState::NewInputInvalid: {
auto metaData = std::make_unique<gui::DialogMetadataMessage>(
gui::DialogMetadata{utils::translate("app_onboarding_passcode_configuration"),
@@ 91,7 91,7 @@ namespace gui
break;
}
- case PinLock::LockState::Unlocked: {
+ case Lock::LockState::Unlocked: {
application->setLockScreenPasscodeOn(true);
application->switchWindow(gui::window::name::onBoarding_date_and_time,
gui::ShowMode::GUI_SHOW_INIT,
M module-apps/application-onboarding/windows/ConfigurePasscodeWindow.hpp => module-apps/application-onboarding/windows/ConfigurePasscodeWindow.hpp +2 -2
@@ 3,8 3,8 @@
#pragma once
-#include <application-desktop/windows/LockWindow.hpp>
-#include <application-desktop/windows/ScreenLockBaseBox.hpp>
+#include <locks/widgets/PhoneLockBaseBox.hpp>
+#include <locks/windows/LockWindow.hpp>
#include <application-settings-new/windows/ChangePasscodeWindow.hpp>
#include <application-settings-new/data/ChangePasscodeData.hpp>
#include <application-settings-new/widgets/ChangePasscodeLockHandler.hpp>
M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +1 -1
@@ 77,7 77,7 @@
#include <module-services/service-evtmgr/service-evtmgr/EVMessages.hpp>
#include <module-services/service-appmgr/service-appmgr/messages/Message.hpp>
#include <module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp>
-#include <module-apps/application-desktop/windows/PinLockWindow.hpp>
+#include <locks/windows/PinLockWindow.hpp>
#include <module-apps/application-desktop/windows/Names.hpp>
#include <module-apps/messages/DialogMetadataMessage.hpp>
#include <module-apps/windows/Dialog.hpp>
M module-apps/application-settings-new/widgets/ChangePasscodeLockHandler.cpp => module-apps/application-settings-new/widgets/ChangePasscodeLockHandler.cpp +19 -19
@@ 2,53 2,53 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ChangePasscodeLockHandler.hpp"
-#include "application-desktop/widgets/PinHash.hpp"
+#include "locks/widgets/LockHash.hpp"
namespace gui
{
ChangePasscodeLockHandler::ChangePasscodeLockHandler()
- : lock(Store::GSM::SIM::NONE, PinLock::LockState::PasscodeRequired, PinLock::LockType::Screen)
+ : lock(Store::GSM::SIM::NONE, Lock::LockState::InputRequired, Lock::LockType::Screen)
{}
- PinLock::LockState ChangePasscodeLockHandler::checkPasscode(unsigned int currentLockPassHash)
+ Lock::LockState ChangePasscodeLockHandler::checkPasscode(unsigned int currentLockPassHash)
{
- return activateLock([this, currentLockPassHash](PinLock::LockType, const std::vector<unsigned int> &pin) {
- const auto hash = GetPinHash(pin);
+ return activateLock([this, currentLockPassHash](Lock::LockType, const std::vector<unsigned int> &pin) {
+ const auto hash = getHash(pin);
if (hash == currentLockPassHash) {
- lock.lockState = PinLock::LockState::NewPasscodeRequired;
+ lock.lockState = Lock::LockState::NewInputRequired;
}
else {
- lock.lockState = PinLock::LockState::PasscodeInvalidRetryRequired;
+ lock.lockState = Lock::LockState::InputInvalidRetryRequired;
}
});
}
- PinLock::LockState ChangePasscodeLockHandler::newPasscodeConfirmed()
+ Lock::LockState ChangePasscodeLockHandler::newPasscodeConfirmed()
{
- return activateLock([this](PinLock::LockType, const std::vector<unsigned int> &pin) {
- const auto newPasscodeConfirmedHash = GetPinHash(pin);
+ return activateLock([this](Lock::LockType, const std::vector<unsigned int> &pin) {
+ const auto newPasscodeConfirmedHash = getHash(pin);
if (newPasscodeHash == newPasscodeConfirmedHash) {
- lock.lockState = PinLock::LockState::Unlocked;
+ lock.lockState = Lock::LockState::Unlocked;
}
else {
- lock.lockState = PinLock::LockState::NewPasscodeInvalid;
+ lock.lockState = Lock::LockState::NewInputInvalid;
}
});
}
- PinLock::LockState ChangePasscodeLockHandler::newPasscodeProvided()
+ Lock::LockState ChangePasscodeLockHandler::newPasscodeProvided()
{
- return activateLock([this](PinLock::LockType, const std::vector<unsigned int> &pin) {
- if (pin.size() < lock.getMaxPinSize()) {
- lock.lockState = PinLock::LockState::NewPasscodeInvalidRetryRequired;
+ return activateLock([this](Lock::LockType, const std::vector<unsigned int> &pin) {
+ if (pin.size() < lock.getMaxInputSize()) {
+ lock.lockState = Lock::LockState::NewInputInvalidRetryRequired;
return;
}
- newPasscodeHash = GetPinHash(pin);
- lock.lockState = PinLock::LockState::NewPasscodeConfirmRequired;
+ newPasscodeHash = getHash(pin);
+ lock.lockState = Lock::LockState::NewInputConfirmRequired;
});
}
- PinLock::LockState ChangePasscodeLockHandler::activateLock(OnActivatedCallback onActivatedCallback)
+ Lock::LockState ChangePasscodeLockHandler::activateLock(OnActivatedCallback onActivatedCallback)
{
lock.onActivatedCallback = onActivatedCallback;
lock.activate();
M module-apps/application-settings-new/widgets/ChangePasscodeLockHandler.hpp => module-apps/application-settings-new/widgets/ChangePasscodeLockHandler.hpp +10 -8
@@ 3,17 3,19 @@
#pragma once
-#include "application-desktop/widgets/PinLock.hpp"
+#include "locks/widgets/Lock.hpp"
namespace gui
{
+ using namespace locks;
+
class ChangePasscodeLockHandler
{
public:
ChangePasscodeLockHandler();
- auto checkPasscode(unsigned int currentLockPassHash) -> PinLock::LockState;
- [[nodiscard]] auto getLock() -> PinLock &
+ auto checkPasscode(unsigned int currentLockPassHash) -> Lock::LockState;
+ [[nodiscard]] auto getLock() -> Lock &
{
return lock;
}
@@ 21,14 23,14 @@ namespace gui
{
return newPasscodeHash;
}
- auto newPasscodeConfirmed() -> PinLock::LockState;
- auto newPasscodeProvided() -> PinLock::LockState;
+ auto newPasscodeConfirmed() -> Lock::LockState;
+ auto newPasscodeProvided() -> Lock::LockState;
private:
- using OnActivatedCallback = std::function<void(PinLock::LockType type, const std::vector<unsigned int> &)>;
- auto activateLock(OnActivatedCallback onActivatedCallback) -> PinLock::LockState;
+ using OnActivatedCallback = std::function<void(Lock::LockType type, const std::vector<unsigned int> &)>;
+ auto activateLock(OnActivatedCallback onActivatedCallback) -> Lock::LockState;
- PinLock lock;
+ Lock lock;
unsigned int newPasscodeHash;
};
} // namespace gui
M module-apps/application-settings-new/windows/ChangePasscodeWindow.cpp => module-apps/application-settings-new/windows/ChangePasscodeWindow.cpp +20 -20
@@ 1,8 1,8 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "application-desktop/data/AppDesktopStyle.hpp"
#include "application-settings-new/ApplicationSettings.hpp"
+#include "locks/data/LockStyle.hpp"
#include "ChangePasscodeWindow.hpp"
#include "DialogMetadata.hpp"
#include "DialogMetadataMessage.hpp"
@@ 22,7 22,7 @@ namespace gui
auto ChangePasscodeWindow::onInput(const InputEvent &inputEvent) -> bool
{
auto &lock = lockHandler.getLock();
- if (lock.isState(PinLock::LockState::Unlocked) && inputEvent.isShortPress()) {
+ if (lock.isState(Lock::LockState::Unlocked) && inputEvent.isShortPress()) {
application->returnToPreviousWindow();
}
if (!inputEvent.isShortPress()) {
@@ 65,8 65,8 @@ namespace gui
AppWindow::buildInterface();
LockWindow::build();
- lockBox = std::make_unique<ScreenLockBaseBox>(this);
- lockBox->buildLockBox(lockHandler.getLock().getMaxPinSize());
+ lockBox = std::make_unique<PhoneLockBaseBox>(this);
+ lockBox->buildLockBox(lockHandler.getLock().getMaxInputSize());
lockImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, "pin_lock");
@@ 90,7 90,7 @@ namespace gui
auto changePasscodeData = static_cast<ChangePasscodeData *>(data);
changePasscodeAction = changePasscodeData->changePasscodeAction;
if (ChangePasscodeAction::OnlyProvideNewPasscode == changePasscodeAction) {
- lockState = PinLock::LockState::NewPasscodeRequired;
+ lockState = Lock::LockState::NewInputRequired;
}
}
setVisibleState();
@@ 99,12 99,12 @@ namespace gui
void ChangePasscodeWindow::processPasscode()
{
switch (lockState) {
- case PinLock::LockState::PasscodeRequired:
- case PinLock::LockState::PasscodeInvalidRetryRequired: {
+ case Lock::LockState::InputRequired:
+ case Lock::LockState::InputInvalidRetryRequired: {
auto app = static_cast<app::ApplicationSettingsNew *>(application);
lockState = lockHandler.checkPasscode(app->getLockPassHash());
if (ChangePasscodeAction::OnlyCheckCurrentPasscode == changePasscodeAction &&
- lockState == PinLock::LockState::NewPasscodeRequired) {
+ lockState == Lock::LockState::NewInputRequired) {
application->setLockScreenPasscodeOn(false);
auto metaData = std::make_unique<gui::DialogMetadataMessage>(
@@ 122,15 122,15 @@ namespace gui
}
break;
}
- case PinLock::LockState::NewPasscodeRequired:
- case PinLock::LockState::NewPasscodeInvalidRetryRequired: {
+ case Lock::LockState::NewInputRequired:
+ case Lock::LockState::NewInputInvalidRetryRequired: {
lockState = lockHandler.newPasscodeProvided();
break;
}
- case PinLock::LockState::NewPasscodeConfirmRequired:
- case PinLock::LockState::NewPasscodeInvalid: {
+ case Lock::LockState::NewInputConfirmRequired:
+ case Lock::LockState::NewInputInvalid: {
lockState = lockHandler.newPasscodeConfirmed();
- if (lockState == PinLock::LockState::Unlocked) {
+ if (lockState == Lock::LockState::Unlocked) {
auto app = static_cast<app::ApplicationSettingsNew *>(application);
app->setLockPassHash(lockHandler.getNewPasscodeHash());
}
@@ 145,28 145,28 @@ namespace gui
{
lockBox->clear();
switch (lockState) {
- case PinLock::LockState::PasscodeRequired: {
+ case Lock::LockState::InputRequired: {
setText("app_settings_security_type_current_passcode", LockWindow::TextType::Primary);
secondaryText->setVisible(false);
break;
}
- case PinLock::LockState::NewPasscodeRequired: {
+ case Lock::LockState::NewInputRequired: {
setText("app_settings_security_enter_new_passcode", LockWindow::TextType::Primary);
secondaryText->setVisible(false);
break;
}
- case PinLock::LockState::NewPasscodeConfirmRequired: {
+ case Lock::LockState::NewInputConfirmRequired: {
setText("app_settings_security_confirm_new_passcode", LockWindow::TextType::Primary);
secondaryText->setVisible(false);
break;
}
- case PinLock::LockState::PasscodeInvalidRetryRequired:
- case PinLock::LockState::NewPasscodeInvalidRetryRequired:
- case PinLock::LockState::NewPasscodeInvalid: {
+ case Lock::LockState::InputInvalidRetryRequired:
+ case Lock::LockState::NewInputInvalidRetryRequired:
+ case Lock::LockState::NewInputInvalid: {
setText("app_settings_security_wrong_passcode", LockWindow::TextType::Secondary);
break;
}
- case PinLock::LockState::Unlocked: {
+ case Lock::LockState::Unlocked: {
application->setLockScreenPasscodeOn(true);
auto metaData = std::make_unique<gui::DialogMetadataMessage>(
M module-apps/application-settings-new/windows/ChangePasscodeWindow.hpp => module-apps/application-settings-new/windows/ChangePasscodeWindow.hpp +4 -4
@@ 3,8 3,8 @@
#pragma once
-#include "application-desktop/windows/LockWindow.hpp"
-#include "application-desktop/windows/ScreenLockBaseBox.hpp"
+#include "locks/windows/LockWindow.hpp"
+#include "locks/widgets/PhoneLockBaseBox.hpp"
#include "application-settings-new/data/ChangePasscodeData.hpp"
#include "application-settings-new/widgets/ChangePasscodeLockHandler.hpp"
@@ 28,9 28,9 @@ namespace gui
virtual void setVisibleState();
ChangePasscodeAction changePasscodeAction;
- std::unique_ptr<ScreenLockBaseBox> lockBox = nullptr;
+ std::unique_ptr<PhoneLockBaseBox> lockBox = nullptr;
gui::Image *lockImage = nullptr;
- PinLock::LockState lockState{PinLock::LockState::PasscodeRequired};
+ Lock::LockState lockState{Lock::LockState::InputRequired};
ChangePasscodeLockHandler lockHandler;
std::string textForEnterCurrentPassword = "app_settings_security_type_current_passcode";
M module-apps/application-settings-new/windows/SecurityMainWindow.cpp => module-apps/application-settings-new/windows/SecurityMainWindow.cpp +6 -5
@@ 1,10 1,11 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+#include <locks/widgets/Lock.hpp>
+#include <locks/data/LockData.hpp>
#include "application-settings-new/ApplicationSettings.hpp"
#include "application-settings-new/data/ChangePasscodeData.hpp"
#include "module-apps/application-desktop/windows/Names.hpp"
-#include "module-apps/application-desktop/data/LockPhoneData.hpp"
#include "OptionSetting.hpp"
#include "SecurityMainWindow.hpp"
@@ 45,15 46,15 @@ namespace gui
optionList.emplace_back(std::make_unique<option::OptionSettings>(
utils::translate("app_settings_security_usb_passcode"),
[=](Item &item) {
- auto lock = std::make_unique<gui::PinLock>(
- Store::GSM::SIM::NONE, PinLock::LockState::PasscodeRequired, PinLock::LockType::Screen);
- lock->onActivatedCallback = [this](PinLock::LockType type, const std::vector<unsigned int> &data) {
+ auto lock = std::make_unique<locks::Lock>(
+ Store::GSM::SIM::NONE, locks::Lock::LockState::InputRequired, locks::Lock::LockType::Screen);
+ lock->onActivatedCallback = [this](locks::Lock::LockType type, const std::vector<unsigned int> &data) {
securitySettings->setUSBSecurity(!securitySettings->isUSBSecured());
application->returnToPreviousWindow();
};
application->switchWindow(app::window::name::desktop_pin_lock,
gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<gui::LockPhoneData>(std::move(lock)));
+ std::make_unique<locks::LockData>(*lock));
return true;
},
[=](Item &item) {
A module-apps/locks/CMakeLists.txt => module-apps/locks/CMakeLists.txt +41 -0
@@ 0,0 1,41 @@
+
+include_directories( ${CMAKE_PROJECT_NAME}
+
+ PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}"
+)
+
+include_directories( ${PROJECT_NAME}
+
+ PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}"
+)
+
+target_sources( ${PROJECT_NAME}
+
+ PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/handlers/PinLockHandler.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/windows/LockWindow.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockBaseWindow.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockWindow.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/Lock.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/PukLockBox.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/PhoneLockBaseBox.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/PhoneLockBox.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/SimLockBox.cpp"
+
+ PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/data/LockData.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/data/LockStyle.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/handlers/PinLockHandler.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/windows/LockWindow.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockBaseWindow.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/windows/PinLockWindow.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/LockHash.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/Lock.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/LockBox.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/PukLockBox.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/PhoneLockBaseBox.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/PhoneLockBox.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/SimLockBox.hpp"
+)
A module-apps/locks/data/LockData.hpp => module-apps/locks/data/LockData.hpp +30 -0
@@ 0,0 1,30 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <memory>
+#include "gui/SwitchData.hpp"
+#include "locks/widgets/Lock.hpp"
+
+namespace locks
+{
+
+ // class template that stores information that was sent along with switch message
+ class LockData : public gui::SwitchData
+ {
+ Lock lock;
+
+ public:
+ explicit LockData(Lock lock) : SwitchData(), lock(std::move(lock))
+ {
+ description = "LockPhoneData";
+ }
+
+ [[nodiscard]] const Lock &getLock() const noexcept
+ {
+ return lock;
+ }
+ };
+
+} // namespace lock
R module-apps/application-desktop/data/AppDesktopStyle.hpp => module-apps/locks/data/LockStyle.hpp +0 -0
R module-apps/application-desktop/widgets/PinLockHandler.cpp => module-apps/locks/handlers/PinLockHandler.cpp +97 -103
@@ 1,10 1,10 @@
//// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
//// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+#include "locks/data/LockData.hpp"
#include "PinLockHandler.hpp"
-#include "PinHash.hpp"
+#include "locks/widgets/LockHash.hpp"
#include "application-desktop/ApplicationDesktop.hpp"
-#include "application-desktop/data/LockPhoneData.hpp"
#include "application-desktop/windows/Names.hpp"
#include <module-utils/common_data/EventStore.hpp>
#include <service-appmgr/service-appmgr/data/SimActionsParams.hpp>
@@ 25,56 25,55 @@ namespace gui
PinLockHandler::PinLockHandler(app::ApplicationDesktop *app)
: app(app),
- screenLock(
- Store::GSM::SIM::NONE, PinLock::LockState::PasscodeRequired, PinLock::LockType::Screen, default_attempts),
- simLock(Store::GSM::SIM::NONE, PinLock::LockState::Unlocked, PinLock::LockType::SimPin, default_attempts)
+ screenLock(Store::GSM::SIM::NONE, Lock::LockState::InputRequired, Lock::LockType::Screen, default_attempts),
+ simLock(Store::GSM::SIM::NONE, Lock::LockState::Unlocked, Lock::LockType::SimPin, default_attempts)
{
- simLock.setPinSizeBounds(sim_min_passcode_size, sim_max_passcode_size);
- screenLock.setPinSizeBounds(default_screen_pin_size, default_screen_pin_size);
+ simLock.setInputSizeBounds(sim_min_passcode_size, sim_max_passcode_size);
+ screenLock.setInputSizeBounds(default_screen_pin_size, default_screen_pin_size);
screenLock.setAutoActivate(true);
}
void PinLockHandler::handleScreenPin(const std::vector<unsigned int> &pin)
{
- const uint32_t hash = GetPinHash(pin);
- screenLock.value--;
+ const uint32_t hash = getHash(pin);
+ screenLock.attemptsLeft--;
if (hash == app->getLockPassHash()) {
- screenLock.lockState = gui::PinLock::LockState::Unlocked;
- screenLock.value = default_attempts;
+ screenLock.lockState = gui::Lock::LockState::Unlocked;
+ screenLock.attemptsLeft = default_attempts;
}
- else if (screenLock.value > 0) {
- screenLock.lockState = gui::PinLock::LockState::PasscodeInvalidRetryRequired;
+ else if (screenLock.attemptsLeft > 0) {
+ screenLock.lockState = gui::Lock::LockState::InputInvalidRetryRequired;
}
else {
- screenLock.lockState = gui::PinLock::LockState::Blocked;
+ screenLock.lockState = gui::Lock::LockState::Blocked;
}
unlock();
}
- void PinLockHandler::handlePasscodeParams(PinLock::LockType type,
- PinLock::LockState state,
+ void PinLockHandler::handlePasscodeParams(Lock::LockType type,
+ Lock::LockState state,
app::manager::actions::ActionParamsPtr &&data)
{
auto passcodeData = static_cast<app::manager::actions::PasscodeParams *>(data.get());
if (simLock.isSim(passcodeData->getSim()) && simLock.isType(type) && simLock.isState(state) &&
- simLock.getValue() > passcodeData->getAttempts()) {
- simLock.lockState = PinLock::LockState::PasscodeInvalidRetryRequired;
+ simLock.getAttemptsLeft() > passcodeData->getAttempts()) {
+ simLock.lockState = Lock::LockState::InputInvalidRetryRequired;
}
else {
simLock.lockState = state;
simLock.sim = passcodeData->getSim();
simLock.lockType = type;
}
- simLock.passcodeName = passcodeData->getPasscodeName();
- simLock.value = passcodeData->getAttempts();
+ simLock.lockName = passcodeData->getPasscodeName();
+ simLock.attemptsLeft = passcodeData->getAttempts();
}
- void PinLockHandler::handlePasscodeRequest(PinLock::LockType type, app::manager::actions::ActionParamsPtr &&data)
+ void PinLockHandler::handlePasscodeRequest(Lock::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)) {
+ handlePasscodeParams(type, Lock::LockState::InputRequired, std::move(data));
+ if (!getStrongestLock().isType(Lock::LockType::Screen)) {
unlock();
}
}
@@ 82,8 81,8 @@ namespace gui
void PinLockHandler::handleScreenPasscodeRequest(app::manager::actions::ActionParamsPtr &&data) const
{
auto params = static_cast<app::manager::actions::ScreenPasscodeParams *>(data.get());
- auto lock = std::make_unique<gui::PinLock>(
- Store::GSM::SIM::NONE, PinLock::LockState::PasscodeRequired, PinLock::LockType::Screen);
+ auto lock =
+ std::make_unique<gui::Lock>(Store::GSM::SIM::NONE, Lock::LockState::InputRequired, Lock::LockType::Screen);
if (params->isCancel()) {
if (app->getCurrentWindow()->getName() == app::window::name::desktop_pin_lock) {
@@ 92,23 91,22 @@ namespace gui
return;
}
- lock->onActivatedCallback = [this](PinLock::LockType type, const std::vector<unsigned int> &data) {
+ lock->onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
app->bus.sendUnicast(std::make_shared<sdesktop::passcode::ScreenPasscodeUnlocked>(),
service::name::service_desktop);
app->switchWindow(app::window::name::desktop_main_window);
};
- app->switchWindow(app::window::name::desktop_pin_lock,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<gui::LockPhoneData>(std::move(lock)));
+ app->switchWindow(
+ app::window::name::desktop_pin_lock, gui::ShowMode::GUI_SHOW_INIT, std::make_unique<gui::LockData>(*lock));
}
void PinLockHandler::handlePinChangeRequest(app::manager::actions::ActionParamsPtr &&data)
{
LOG_DEBUG("Handling RequestPinChange action");
- handlePasscodeParams(PinLock::LockType::SimPin, PinLock::LockState::PasscodeRequired, std::move(data));
+ handlePasscodeParams(Lock::LockType::SimPin, Lock::LockState::InputRequired, std::move(data));
promptSimLockWindow = true;
- auto onActivatedCallback = [this](PinLock::LockType type, const std::vector<unsigned int> &data) {
+ auto onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
handlePasscodeChange(data);
};
switchToPinLockWindow(onActivatedCallback);
@@ 118,9 116,9 @@ namespace gui
CellularSimCardLockDataMessage::SimCardLock simCardLock)
{
LOG_DEBUG("Handling PinEnableRequest action, simCardLock = %d", static_cast<int>(simCardLock));
- handlePasscodeParams(PinLock::LockType::SimPin, PinLock::LockState::PasscodeRequired, std::move(data));
+ handlePasscodeParams(Lock::LockType::SimPin, Lock::LockState::InputRequired, std::move(data));
promptSimLockWindow = true;
- auto onActivatedCallback = [this, simCardLock](PinLock::LockType type, const std::vector<unsigned int> &data) {
+ auto onActivatedCallback = [this, simCardLock](Lock::LockType type, const std::vector<unsigned int> &data) {
app->bus.sendUnicast(
std::make_shared<CellularSimCardLockDataMessage>(Store::GSM::get()->selected, simCardLock, data),
serviceCellular);
@@ 132,66 130,65 @@ namespace gui
{
LOG_DEBUG("Handling PinEnableRequestFailed action, simCardLock = %d, simLock.value = %u",
static_cast<int>(simCardLock),
- simLock.value);
+ simLock.attemptsLeft);
using namespace app::manager::actions;
- if (simLock.value > 0) {
- --simLock.value;
+ if (simLock.attemptsLeft > 0) {
+ --simLock.attemptsLeft;
}
else {
LOG_ERROR("Number of attempts left is equal to zero before decrementation!");
}
- if (simLock.value > 0) {
- simLock.lockState = PinLock::LockState::PasscodeInvalidRetryRequired;
- auto onActivatedCallback = [this, simCardLock](PinLock::LockType type,
- const std::vector<unsigned int> &data) {
+ if (simLock.attemptsLeft > 0) {
+ simLock.lockState = Lock::LockState::InputInvalidRetryRequired;
+ auto onActivatedCallback = [this, simCardLock](Lock::LockType type, const std::vector<unsigned int> &data) {
auto params = std::make_unique<PasscodeParams>(
- Store::GSM::get()->selected, simLock.value, PasscodeParams::pinName);
+ Store::GSM::get()->selected, simLock.attemptsLeft, PasscodeParams::pinName);
handlePinEnableRequest(std::move(params), simCardLock);
};
- switchToPinLockWindow(PinLock::LockState::PasscodeInvalidRetryRequired, onActivatedCallback);
+ switchToPinLockWindow(Lock::LockState::InputInvalidRetryRequired, onActivatedCallback);
}
else {
auto params = std::make_unique<PasscodeParams>(
Store::GSM::get()->selected, PasscodeParams::numOfAttemptsForEnteringPUK, PasscodeParams::pukName);
- handlePasscodeRequest(gui::PinLock::LockType::SimPuk, std::move(params));
+ handlePasscodeRequest(gui::Lock::LockType::SimPuk, std::move(params));
}
}
void PinLockHandler::handlePinChangeRequestFailed()
{
- LOG_DEBUG("Handling PinChangeRequestFailed action, simLock.value = %u", simLock.value);
+ LOG_DEBUG("Handling PinChangeRequestFailed action, simLock.value = %u", simLock.attemptsLeft);
using namespace app::manager::actions;
- if (simLock.value > 0) {
- --simLock.value;
+ if (simLock.attemptsLeft > 0) {
+ --simLock.attemptsLeft;
}
else {
LOG_ERROR("Number of attempts left is equal to zero before decrementation!");
}
- if (simLock.value > 0) {
- simLock.lockState = PinLock::LockState::PasscodeInvalidRetryRequired;
- auto onActivatedCallback = [this](PinLock::LockType type, const std::vector<unsigned int> &data) {
+ if (simLock.attemptsLeft > 0) {
+ simLock.lockState = Lock::LockState::InputInvalidRetryRequired;
+ auto onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
auto params = std::make_unique<PasscodeParams>(
- Store::GSM::get()->selected, simLock.value, PasscodeParams::pinName);
+ Store::GSM::get()->selected, simLock.attemptsLeft, PasscodeParams::pinName);
handlePinChangeRequest(std::move(params));
};
- switchToPinLockWindow(PinLock::LockState::PasscodeInvalidRetryRequired, onActivatedCallback);
+ switchToPinLockWindow(Lock::LockState::InputInvalidRetryRequired, onActivatedCallback);
}
else {
auto params = std::make_unique<PasscodeParams>(
Store::GSM::get()->selected, PasscodeParams::numOfAttemptsForEnteringPUK, PasscodeParams::pukName);
- handlePasscodeRequest(gui::PinLock::LockType::SimPuk, std::move(params));
+ handlePasscodeRequest(gui::Lock::LockType::SimPuk, std::move(params));
}
}
void PinLockHandler::handleSimBlocked(app::manager::actions::ActionParamsPtr &&data)
{
LOG_DEBUG("Handling BlockSim action");
- auto params = static_cast<app::manager::actions::SimStateParams *>(data.get());
- promptSimLockWindow = true;
- simLock.sim = params->getSim();
- simLock.lockState = gui::PinLock::LockState::Blocked;
- simLock.lockType = gui::PinLock::LockType::SimPin;
- simLock.value = blocked_sim_attempts;
+ auto params = static_cast<app::manager::actions::SimStateParams *>(data.get());
+ promptSimLockWindow = true;
+ simLock.sim = params->getSim();
+ simLock.lockState = gui::Lock::LockState::Blocked;
+ simLock.lockType = gui::Lock::LockType::SimPin;
+ simLock.attemptsLeft = blocked_sim_attempts;
unlock();
}
@@ 199,8 196,8 @@ namespace gui
{
LOG_DEBUG("Handling UnlockSim action");
promptSimLockWindow = false;
- if (!simLock.isState(PinLock::LockState::Unlocked)) {
- simLock.lockState = PinLock::LockState::Unlocked;
+ if (!simLock.isState(Lock::LockState::Unlocked)) {
+ simLock.lockState = Lock::LockState::Unlocked;
unlock();
}
}
@@ 209,34 206,33 @@ namespace gui
{
LOG_DEBUG("Handling DisplayCMEError action");
auto params = static_cast<app::manager::actions::UnhandledCMEParams *>(data.get());
- auto lock = std::make_unique<gui::PinLock>(
- params->getSim(), PinLock::LockState::ErrorOccurred, PinLock::LockType::SimPin, params->getCMECode());
- lock->onActivatedCallback = [this](PinLock::LockType type, const std::vector<unsigned int> &data) {
+ auto lock = std::make_unique<gui::Lock>(
+ params->getSim(), Lock::LockState::ErrorOccurred, Lock::LockType::SimPin, params->getCMECode());
+ lock->onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
app->switchWindow(app::window::name::desktop_main_window);
};
- app->switchWindow(app::window::name::desktop_pin_lock,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<gui::LockPhoneData>(std::move(lock)));
+ app->switchWindow(
+ app::window::name::desktop_pin_lock, gui::ShowMode::GUI_SHOW_INIT, std::make_unique<gui::LockData>(*lock));
}
void PinLockHandler::switchToPinLockWindow(
- std::function<void(PinLock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback)
+ std::function<void(Lock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback)
{
- auto lock = std::make_unique<gui::PinLock>(getStrongestLock());
- if (lock->isState(PinLock::LockState::PasscodeInvalidRetryRequired)) {
+ auto lock = std::make_unique<gui::Lock>(getStrongestLock());
+ if (lock->isState(Lock::LockState::InputInvalidRetryRequired)) {
getStrongestLock().consumeState();
- lock->onActivatedCallback = [this, onLockActivatedCallback](PinLock::LockType,
+ lock->onActivatedCallback = [this, onLockActivatedCallback](Lock::LockType,
const std::vector<unsigned int> &) {
switchToPinLockWindow(onLockActivatedCallback);
};
}
- else if (lock->isState(gui::PinLock::LockState::Blocked)) {
- lock->onActivatedCallback = [this](PinLock::LockType type, const std::vector<unsigned int> &data) {
+ else if (lock->isState(gui::Lock::LockState::Blocked)) {
+ lock->onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
setSimLockHandled();
app->switchWindow(app::window::name::desktop_main_window);
};
}
- else if (lock->isState(gui::PinLock::LockState::Unlocked)) {
+ else if (lock->isState(gui::Lock::LockState::Unlocked)) {
setSimLockHandled();
app->switchWindow(app::window::name::desktop_main_window);
return;
@@ 244,49 240,47 @@ namespace gui
else {
lock->onActivatedCallback = onLockActivatedCallback;
}
- app->switchWindow(app::window::name::desktop_pin_lock,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<gui::LockPhoneData>(std::move(lock)));
+ app->switchWindow(
+ app::window::name::desktop_pin_lock, gui::ShowMode::GUI_SHOW_INIT, std::make_unique<gui::LockData>(*lock));
}
void PinLockHandler::switchToPinLockWindow(
- PinLock::LockState state,
- std::function<void(PinLock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback)
+ Lock::LockState state,
+ std::function<void(Lock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback)
{
- auto lock = std::make_unique<gui::PinLock>(getStrongestLock());
+ auto lock = std::make_unique<gui::Lock>(getStrongestLock());
lock->lockState = state;
lock->onActivatedCallback = onLockActivatedCallback;
- app->switchWindow(app::window::name::desktop_pin_lock,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<gui::LockPhoneData>(std::move(lock)));
+ app->switchWindow(
+ app::window::name::desktop_pin_lock, gui::ShowMode::GUI_SHOW_INIT, std::make_unique<gui::LockData>(*lock));
}
- void PinLockHandler::handlePasscode(PinLock::LockType type, const std::vector<unsigned int> passcode)
+ void PinLockHandler::handlePasscode(Lock::LockType type, const std::vector<unsigned int> passcode)
{
- if (type == PinLock::LockType::SimPin) {
+ if (type == Lock::LockType::SimPin) {
setSimLockHandled();
app->bus.sendUnicast(std::make_shared<CellularSimPinDataMessage>(simLock.sim, passcode), serviceCellular);
}
- else if (type == PinLock::LockType::SimPuk) {
+ else if (type == Lock::LockType::SimPuk) {
handlePasscodeChange(passcode);
}
- else if (type == PinLock::LockType::Screen) {
+ else if (type == Lock::LockType::Screen) {
handleScreenPin(passcode);
}
}
void PinLockHandler::handlePasscodeChange(const std::vector<unsigned int> passcode)
{
- auto onActivatedCallback = [this, passcode](PinLock::LockType, const std::vector<unsigned int> &pin) {
+ auto onActivatedCallback = [this, passcode](Lock::LockType, const std::vector<unsigned int> &pin) {
handleNewPasscodeUnconfirmed(passcode, pin);
};
- switchToPinLockWindow(PinLock::LockState::NewPasscodeRequired, onActivatedCallback);
+ switchToPinLockWindow(Lock::LockState::NewInputRequired, onActivatedCallback);
}
void PinLockHandler::handleNewPasscodeUnconfirmed(const std::vector<unsigned int> &passcode,
const std::vector<unsigned int> &pin)
{
- auto onActivatedCallback = [this, passcode, pin](PinLock::LockType type,
+ auto onActivatedCallback = [this, passcode, pin](Lock::LockType type,
const std::vector<unsigned int> &pinConfirmed) {
if (pin == pinConfirmed) {
handleNewPasscodeConfirmed(type, passcode, pin);
@@ 295,18 289,18 @@ namespace gui
handleNewPasscodeInvalid(passcode);
}
};
- switchToPinLockWindow(PinLock::LockState::NewPasscodeConfirmRequired, onActivatedCallback);
+ switchToPinLockWindow(Lock::LockState::NewInputConfirmRequired, onActivatedCallback);
}
- void PinLockHandler::handleNewPasscodeConfirmed(PinLock::LockType type,
+ void PinLockHandler::handleNewPasscodeConfirmed(Lock::LockType type,
const std::vector<unsigned int> &passcode,
const std::vector<unsigned int> &pin)
{
- if (type == PinLock::LockType::SimPin) {
+ if (type == Lock::LockType::SimPin) {
app->bus.sendUnicast(std::make_shared<CellularSimNewPinDataMessage>(simLock.sim, passcode, pin),
serviceCellular);
}
- else if (type == PinLock::LockType::SimPuk) {
+ else if (type == Lock::LockType::SimPuk) {
app->bus.sendUnicast(std::make_shared<CellularSimPukDataMessage>(simLock.sim, passcode, pin),
serviceCellular);
}
@@ 314,25 308,25 @@ namespace gui
void PinLockHandler::handleNewPasscodeInvalid(const std::vector<unsigned int> &passcode)
{
- auto onActivatedCallback = [this, passcode](PinLock::LockType type, const std::vector<unsigned int> &pin) {
+ auto onActivatedCallback = [this, passcode](Lock::LockType type, const std::vector<unsigned int> &pin) {
handlePasscodeChange(passcode);
};
- switchToPinLockWindow(PinLock::LockState::NewPasscodeInvalid, onActivatedCallback);
+ switchToPinLockWindow(Lock::LockState::NewInputInvalid, onActivatedCallback);
}
void PinLockHandler::unlock()
{
- auto onActivatedCallback = [this](PinLock::LockType type, const std::vector<unsigned int> &data) {
+ auto onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
handlePasscode(type, data);
};
switchToPinLockWindow(onActivatedCallback);
}
- auto PinLockHandler::getStrongestLock() noexcept -> gui::PinLock &
+ auto PinLockHandler::getStrongestLock() noexcept -> gui::Lock &
{
- if (!screenLock.isState(PinLock::LockState::Unlocked)) {
+ if (!screenLock.isState(Lock::LockState::Unlocked)) {
return screenLock;
}
- else if (promptSimLockWindow && !simLock.isState(PinLock::LockState::Unlocked)) {
+ else if (promptSimLockWindow && !simLock.isState(Lock::LockState::Unlocked)) {
return simLock;
}
return screenLock;
@@ 340,20 334,20 @@ namespace gui
void PinLockHandler::lockScreen()
{
- screenLock.lockState = PinLock::LockState::PasscodeRequired;
+ screenLock.lockState = Lock::LockState::InputRequired;
}
void PinLockHandler::unlockScreen()
{
- if (getStrongestLock().isType(PinLock::LockType::Screen) && !app->isLockScreenPasscodeOn()) {
- screenLock.lockState = gui::PinLock::LockState::Unlocked;
+ if (getStrongestLock().isType(Lock::LockType::Screen) && !app->isLockScreenPasscodeOn()) {
+ screenLock.lockState = gui::Lock::LockState::Unlocked;
}
unlock();
}
void PinLockHandler::setSimLockHandled() noexcept
{
- if (!getStrongestLock().isType(PinLock::LockType::Screen)) {
+ if (!getStrongestLock().isType(Lock::LockType::Screen)) {
promptSimLockWindow = false;
}
}
R module-apps/application-desktop/widgets/PinLockHandler.hpp => module-apps/locks/handlers/PinLockHandler.hpp +16 -14
@@ 3,7 3,7 @@
#pragma once
-#include "PinLock.hpp"
+#include "locks/widgets/Lock.hpp"
#include <module-services/service-appmgr/service-appmgr/messages/ActionRequest.hpp>
#include <module-services/service-appmgr/service-appmgr/Actions.hpp>
@@ 16,39 16,41 @@ namespace app
namespace gui
{
+ using namespace locks;
+
class PinLockHandler
{
app::ApplicationDesktop *app = nullptr;
- gui::PinLock screenLock;
- gui::PinLock simLock;
+ Lock screenLock;
+ Lock simLock;
bool promptSimLockWindow = true;
void handleScreenPin(const std::vector<unsigned int> &pin);
- void handlePasscode(PinLock::LockType type, const std::vector<unsigned int> passcode);
+ void handlePasscode(Lock::LockType type, const std::vector<unsigned int> passcode);
void handlePasscodeChange(const std::vector<unsigned int> passcode);
void handleNewPasscodeUnconfirmed(const std::vector<unsigned int> &passcode,
const std::vector<unsigned int> &pin);
- void handleNewPasscodeConfirmed(PinLock::LockType type,
+ void handleNewPasscodeConfirmed(Lock::LockType type,
const std::vector<unsigned int> &passcode,
const std::vector<unsigned int> &pin);
void handleNewPasscodeInvalid(const std::vector<unsigned int> &passcode);
- void handlePasscodeParams(PinLock::LockType type,
- PinLock::LockState state,
+ void handlePasscodeParams(Lock::LockType type,
+ Lock::LockState state,
app::manager::actions::ActionParamsPtr &&data);
void switchToPinLockWindow(
- std::function<void(PinLock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback);
+ std::function<void(Lock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback);
void switchToPinLockWindow(
- PinLock::LockState type,
- std::function<void(PinLock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback);
+ Lock::LockState type,
+ std::function<void(Lock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback);
- auto getStrongestLock() noexcept -> gui::PinLock &;
+ auto getStrongestLock() noexcept -> gui::Lock &;
void unlock();
void setSimLockHandled() noexcept;
public:
PinLockHandler(app::ApplicationDesktop *app);
- void handlePasscodeRequest(PinLock::LockType type, app::manager::actions::ActionParamsPtr &&data);
+ void handlePasscodeRequest(Lock::LockType type, app::manager::actions::ActionParamsPtr &&data);
void handlePinChangeRequest(app::manager::actions::ActionParamsPtr &&data);
void handlePinEnableRequest(app::manager::actions::ActionParamsPtr &&data,
CellularSimCardLockDataMessage::SimCardLock simCardLock);
@@ 61,11 63,11 @@ namespace gui
[[nodiscard]] auto isScreenLocked() const noexcept -> bool
{
- return !screenLock.isState(PinLock::LockState::Unlocked);
+ return !screenLock.isState(Lock::LockState::Unlocked);
}
[[nodiscard]] auto isScreenBlocked() const noexcept -> bool
{
- return screenLock.isState(PinLock::LockState::Blocked);
+ return screenLock.isState(Lock::LockState::Blocked);
}
void lockScreen();
void unlockScreen();
R module-apps/application-desktop/widgets/PinLock.cpp => module-apps/locks/widgets/Lock.cpp +20 -28
@@ 1,58 1,50 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "PinLock.hpp"
+#include "Lock.hpp"
#include <module-utils/log/log.hpp>
-namespace gui
+namespace locks
{
- void PinLock::consumeState() noexcept
+ void Lock::consumeState() noexcept
{
- if (lockState == LockState::PasscodeInvalidRetryRequired) {
- lockState = LockState::PasscodeRequired;
+ if (lockState == LockState::InputInvalidRetryRequired) {
+ lockState = LockState::InputRequired;
}
- else if (lockState == LockState::NewPasscodeInvalid) {
- lockState = LockState::NewPasscodeRequired;
+ else if (lockState == LockState::NewInputInvalid) {
+ lockState = LockState::NewInputRequired;
}
}
- void PinLock::setNewPasscodeInvalidState() noexcept
+ void Lock::putNextChar(unsigned int c)
{
- if (lockState == LockState::NewPasscodeRequired) {
- lockState = LockState::NewPasscodeInvalid;
- }
- }
-
- void PinLock::putNextChar(unsigned int c)
- {
- if (maxPinSize > pinValue.size()) {
- pinValue.push_back(c);
+ if (maxInputSize > inputValue.size()) {
+ inputValue.push_back(c);
}
if (canVerify() && autoActivate && onActivatedCallback != nullptr) {
- onActivatedCallback(lockType, pinValue);
+ onActivatedCallback(lockType, inputValue);
}
}
- void PinLock::popChar()
+ void Lock::popChar()
{
- if (pinValue.size() > 0) {
- pinValue.pop_back();
+ if (inputValue.size() > 0) {
+ inputValue.pop_back();
}
}
- void PinLock::clearAttempt() noexcept
+ void Lock::clearAttempt() noexcept
{
- pinValue.clear();
+ inputValue.clear();
}
- void PinLock::activate()
+ void Lock::activate()
{
- auto pinCopy = std::move(pinValue);
- clearAttempt();
if (!onActivatedCallback) {
LOG_ERROR("Passcode verification callback null");
return;
}
- onActivatedCallback(lockType, pinCopy);
+ onActivatedCallback(lockType, inputValue);
+ clearAttempt();
}
-} // namespace gui
+} // namespace lock
R module-apps/application-desktop/widgets/PinLock.hpp => module-apps/locks/widgets/Lock.hpp +48 -43
@@ 12,8 12,12 @@
namespace gui
{
class PinLockHandler;
+ class ChangePasscodeLockHandler;
+} // namespace gui
- class PinLock
+namespace locks
+{
+ class Lock
{
public:
enum class LockType
@@ 22,18 26,17 @@ namespace gui
SimPuk,
Screen
};
+
enum class LockState
{
Unlocked,
- PasscodeRequired,
- PasscodeInvalidRetryRequired,
+ InputRequired,
+ InputInvalidRetryRequired,
Blocked,
- NewPasscodeRequired,
- NewPasscodeInvalidRetryRequired,
- NewPasscodeConfirmRequired,
- NewPasscodeInvalid,
- PinLockDisableRequired,
- PinLockEnableRequired,
+ NewInputRequired,
+ NewInputInvalidRetryRequired,
+ NewInputConfirmRequired,
+ NewInputInvalid,
ErrorOccurred
};
@@ 45,30 48,30 @@ namespace gui
{
return lockType;
}
- [[nodiscard]] unsigned int getMaxPinSize() const noexcept
+ [[nodiscard]] unsigned int getMaxInputSize() const noexcept
{
- return maxPinSize;
+ return maxInputSize;
}
- /// returns current position of a PIN character to be inserted
+ /// returns current position of a Input character to be inserted
[[nodiscard]] unsigned int getCharCount() const noexcept
{
- return pinValue.size();
+ return inputValue.size();
}
[[nodiscard]] bool canPut() const noexcept
{
- return getCharCount() < getMaxPinSize();
+ return getCharCount() < getMaxInputSize();
}
[[nodiscard]] bool canVerify() const noexcept
{
- return getCharCount() >= minPinSize;
+ return getCharCount() >= minInputSize;
}
- [[nodiscard]] std::vector<unsigned int> getPin() const
+ [[nodiscard]] std::vector<unsigned int> getInput() const
{
- return pinValue;
+ return inputValue;
}
- [[nodiscard]] unsigned int getValue() const noexcept
+ [[nodiscard]] unsigned int getAttemptsLeft() const noexcept
{
- return value;
+ return attemptsLeft;
}
[[nodiscard]] bool isSim(Store::GSM::SIM _sim) const noexcept
{
@@ 82,9 85,9 @@ namespace gui
{
return lockType == type;
}
- [[nodiscard]] const std::string &getPasscodeName() const noexcept
+ [[nodiscard]] const std::string &getLockName() const noexcept
{
- return passcodeName;
+ return lockName;
}
[[nodiscard]] Store::GSM::SIM getSim() const noexcept
{
@@ 98,44 101,46 @@ namespace gui
void clearAttempt() noexcept;
/// consumes LockState::PasscodeInvalidRetryRequired state and LockState::NewPasscodeInvalid)
void consumeState() noexcept;
- void setNewPasscodeInvalidState() noexcept;
/// calls
void activate();
- PinLock(Store::GSM::SIM sim, LockState state, LockType type, unsigned int value = unlimitedNumOfAttempts)
- : sim{sim}, lockState{state}, lockType{type}, value{value}
+ Lock(Store::GSM::SIM sim, LockState state, LockType type, unsigned int attemptsLeft = unlimitedNumOfAttempts)
+ : sim{sim}, lockState{state}, lockType{type}, attemptsLeft{attemptsLeft}
+ {}
+
+ Lock(LockState state, unsigned int attemptsLeft = unlimitedNumOfAttempts)
+ : lockState{state}, attemptsLeft{attemptsLeft}
{}
- PinLock(const PinLock &other) = default;
std::function<void(LockType type, const std::vector<unsigned int> &)> onActivatedCallback = nullptr;
private:
- std::string passcodeName;
- Store::GSM::SIM sim = Store::GSM::SIM::NONE;
- LockState lockState = LockState::Unlocked;
- LockType lockType = LockType::Screen;
- unsigned int value = 0;
-
- std::vector<unsigned int> pinValue;
- unsigned int maxPinSize = defaultPasscodeSize;
- unsigned int minPinSize = defaultPasscodeSize;
- bool autoActivate = false;
-
- static constexpr unsigned int defaultPasscodeSize = 4;
+ std::string lockName;
+ Store::GSM::SIM sim = Store::GSM::SIM::NONE;
+ LockState lockState = LockState::Unlocked;
+ LockType lockType = LockType::Screen;
+ unsigned int attemptsLeft = 0;
+
+ std::vector<unsigned int> inputValue;
+ unsigned int maxInputSize = defaultInputSize;
+ unsigned int minInputSize = defaultInputSize;
+ bool autoActivate = false;
+
+ static constexpr unsigned int defaultInputSize = 4;
static constexpr unsigned int unlimitedNumOfAttempts = std::numeric_limits<unsigned int>::max();
void setAutoActivate(bool _autoActivate)
{
autoActivate = _autoActivate;
}
- void setPinSizeBounds(unsigned int _minPinSize, unsigned int _maxPinSize)
+ void setInputSizeBounds(unsigned int _minInputSize, unsigned int _maxInputSize)
{
- minPinSize = _minPinSize;
- maxPinSize = _maxPinSize;
+ minInputSize = _minInputSize;
+ maxInputSize = _maxInputSize;
}
- friend class PinLockHandler;
- friend class ChangePasscodeLockHandler;
+ friend class gui::PinLockHandler;
+ friend class gui::ChangePasscodeLockHandler;
};
-} // namespace gui
+} // namespace lock
R module-apps/application-desktop/windows/PinLockBox.hpp => module-apps/locks/widgets/LockBox.hpp +14 -14
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 7,20 7,20 @@
namespace gui
{
- class PinLockBox
+ class LockBox
{
public:
- enum class EnterPasscodeType
+ enum class InputActionType
{
- ProvidePasscode,
- ProvideNewPasscode,
- ConfirmNewPasscode
+ ProvideInput,
+ ProvideNewInput,
+ ConfirmNewInput
};
- enum class PasscodeErrorType
+ enum class InputErrorType
{
- InvalidPasscode,
- NewPasscodeConfirmFailed,
+ InvalidInput,
+ NewInputConfirmFailed,
UnhandledError
};
@@ 28,11 28,11 @@ namespace gui
virtual void putChar(unsigned int charNum) = 0;
virtual void clear() = 0;
- virtual void setVisibleStateEnterPin(EnterPasscodeType type) = 0;
- virtual void setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value) = 0;
- virtual void setVisibleStateBlocked() = 0;
+ virtual void setVisibleStateInputRequired(InputActionType type) = 0;
+ virtual void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) = 0;
+ virtual void setVisibleStateBlocked() = 0;
- virtual void buildLockBox(unsigned int pinSize) = 0;
- virtual ~PinLockBox() = default;
+ virtual void buildLockBox(unsigned int inputSize) = 0;
+ virtual ~LockBox() = default;
};
} // namespace gui
R module-apps/application-desktop/widgets/PinHash.hpp => module-apps/locks/widgets/LockHash.hpp +5 -5
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 10,18 10,18 @@
template <> struct std::hash<std::vector<unsigned int>>
{
const static unsigned int digit_multiplier = 10;
- uint32_t operator()(std::vector<unsigned int> const &pin) const noexcept
+ uint32_t operator()(std::vector<unsigned int> const &input) const noexcept
{
uint32_t value = 0;
- for (auto i : pin) {
+ for (auto i : input) {
value = digit_multiplier * value + i;
}
return value;
}
};
-static inline uint32_t GetPinHash(const std::vector<unsigned int> &pin)
+static inline uint32_t getHash(const std::vector<unsigned int> &input)
{
static std::hash<std::vector<unsigned int>> hashEngine;
- return hashEngine(pin);
+ return hashEngine(input);
}
R module-apps/application-desktop/windows/ScreenLockBaseBox.cpp => module-apps/locks/widgets/PhoneLockBaseBox.cpp +19 -19
@@ 1,45 1,45 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "application-desktop/data/AppDesktopStyle.hpp"
-#include "application-desktop/widgets/PinLock.hpp"
-#include "PinLockBaseWindow.hpp"
-#include "ScreenLockBaseBox.hpp"
+#include "locks/data/LockStyle.hpp"
+#include "locks/windows/PinLockBaseWindow.hpp"
+#include "Lock.hpp"
+#include "PhoneLockBaseBox.hpp"
namespace label_style = style::window::pin_lock::pin_label;
namespace gui
{
- void ScreenLockBaseBox::buildLockBox(unsigned int pinSize)
+ void PhoneLockBaseBox::buildLockBox(unsigned int pinSize)
{
buildPinLabels(pinSize);
}
- void ScreenLockBaseBox::clear()
+ void PhoneLockBaseBox::clear()
{
- for (unsigned i = 0; i < pinLabels.size(); i++) {
+ for (unsigned i = 0; i < inputLabels.size(); i++) {
popChar(i);
}
}
- void ScreenLockBaseBox::popChar(unsigned int charNum)
+ void PhoneLockBaseBox::popChar(unsigned int charNum)
{
- if (charNum < pinLabels.size()) {
- pinLabels[charNum]->setVisibleState(false);
+ if (charNum < inputLabels.size()) {
+ inputLabels[charNum]->setVisibleState(false);
}
}
- void ScreenLockBaseBox::putChar(unsigned int charNum)
+ void PhoneLockBaseBox::putChar(unsigned int charNum)
{
- if (charNum < pinLabels.size()) {
- pinLabels[charNum]->setVisibleState(true);
+ if (charNum < inputLabels.size()) {
+ inputLabels[charNum]->setVisibleState(true);
}
}
- void ScreenLockBaseBox::buildPinLabels(unsigned int pinSize)
+ void PhoneLockBaseBox::buildPinLabels(unsigned int pinSize)
{
constexpr auto pinLabelWidth = style::window::default_body_width;
- pinLabels.clear();
+ inputLabels.clear();
if (pinSize == 0) {
return;
@@ 53,10 53,10 @@ namespace gui
}
auto itemBuilder = [this, singleLabelWidth]() {
- auto label = new PinLabel(nullptr, singleLabelWidth, label_style::size);
+ auto label = new InputLabel(nullptr, singleLabelWidth, label_style::size);
label->setEdges(RectangleEdge::Bottom);
label->setMargins(Margins(label_style::margin, 0, label_style::margin, 0));
- pinLabels.push_back(label);
+ inputLabels.push_back(label);
return label;
};
@@ 65,10 65,10 @@ namespace gui
lockWindow->pinLabelsBox->setEdges(RectangleEdge::None);
}
- ScreenLockBaseBox::PinLabel::PinLabel(Item *parent, uint32_t w, uint32_t h) : HBox(parent, 0, 0, w, h)
+ PhoneLockBaseBox::InputLabel::InputLabel(Item *parent, uint32_t w, uint32_t h) : HBox(parent, 0, 0, w, h)
{}
- void ScreenLockBaseBox::PinLabel::setVisibleState(bool isImageVisible)
+ void PhoneLockBaseBox::InputLabel::setVisibleState(bool isImageVisible)
{
if (isImageVisible && image == nullptr) {
image = new gui::Image("dot_12px_hard_alpha_W_G");
R module-apps/application-desktop/windows/ScreenLockBaseBox.hpp => module-apps/locks/widgets/PhoneLockBaseBox.hpp +10 -10
@@ 4,15 4,15 @@
#pragma once
#include "Image.hpp"
-#include "PinLockBox.hpp"
-#include "LockWindow.hpp"
+#include "LockBox.hpp"
+#include "locks/windows/LockWindow.hpp"
namespace gui
{
- class ScreenLockBaseBox : public PinLockBox
+ class PhoneLockBaseBox : public LockBox
{
public:
- ScreenLockBaseBox(LockWindow *lockBaseWindow) : lockWindow(lockBaseWindow)
+ explicit PhoneLockBaseBox(LockWindow *lockBaseWindow) : lockWindow(lockBaseWindow)
{}
void buildLockBox(unsigned int pinSize) override;
@@ 22,22 22,22 @@ namespace gui
private:
void buildPinLabels(unsigned int pinSize);
- void setVisibleStateBlocked()
+ void setVisibleStateBlocked() override
{}
- void setVisibleStateEnterPin(EnterPasscodeType type)
+ void setVisibleStateInputRequired(InputActionType type) override
{}
- void setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value)
+ void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) override
{}
- struct PinLabel : public HBox
+ struct InputLabel : public HBox
{
- PinLabel(Item *parent, uint32_t w, uint32_t h);
+ InputLabel(Item *parent, uint32_t w, uint32_t h);
void setVisibleState(bool isImageVisible);
gui::Image *image = nullptr;
};
LockWindow *lockWindow;
- std::vector<PinLabel *> pinLabels;
+ std::vector<InputLabel *> inputLabels;
};
} // namespace gui
R module-apps/application-desktop/windows/ScreenLockBox.cpp => module-apps/locks/widgets/PhoneLockBox.cpp +10 -10
@@ 1,27 1,27 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "application-desktop/widgets/PinLock.hpp"
-#include "ScreenLockBox.hpp"
+#include "Lock.hpp"
+#include "PhoneLockBox.hpp"
namespace gui
{
constexpr auto timeToUnlock = 10;
- void ScreenLockBox::buildLockBox(unsigned int pinSize)
+ void PhoneLockBox::buildLockBox(unsigned int pinSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
- ScreenLockBaseBox::buildLockBox(pinSize);
+ PhoneLockBaseBox::buildLockBox(pinSize);
}
- void ScreenLockBox::setVisibleStateBlocked()
+ void PhoneLockBox::setVisibleStateBlocked()
{
LockWindow->setText("app_desktop_screen_blocked_info", LockWindow::TextType::Primary);
LockWindow->setImagesVisible(false, true);
LockWindow->setBottomBarWidgetsActive(false, true, false);
}
- void ScreenLockBox::setVisibleStateEnterPin(EnterPasscodeType type)
+ void PhoneLockBox::setVisibleStateInputRequired(InputActionType type)
{
LockWindow->pinLabelsBox->setVisible(true);
LockWindow->setText("app_desktop_screen_enter_passcode_to_unlock", LockWindow::TextType::Primary, true);
@@ 29,10 29,10 @@ namespace gui
LockWindow->setBottomBarWidgetsActive(false, false, true);
}
- void ScreenLockBox::setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value)
+ void PhoneLockBox::setVisibleStateInputInvalid(InputErrorType type, unsigned int value)
{
switch (type) {
- case PinLockBox::PasscodeErrorType::InvalidPasscode:
+ case LockBox::InputErrorType::InvalidInput:
LockWindow->setTitleBar(false, false);
if (value == 1) {
LockWindow->setText(
@@ 50,10 50,10 @@ namespace gui
}
break;
- case PinLockBox::PasscodeErrorType::NewPasscodeConfirmFailed:
+ case LockBox::InputErrorType::NewInputConfirmFailed:
LOG_ERROR("No use case for NewPasscodeConfirmFailed");
break;
- case PinLockBox::PasscodeErrorType::UnhandledError:
+ case LockBox::InputErrorType::UnhandledError:
LOG_ERROR("No use case for UnhandledError");
break;
}
R module-apps/application-desktop/windows/ScreenLockBox.hpp => module-apps/locks/widgets/PhoneLockBox.hpp +8 -7
@@ 1,24 1,25 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
-#include "PinLockBaseWindow.hpp"
-#include "ScreenLockBaseBox.hpp"
+#include "locks/windows/PinLockBaseWindow.hpp"
+#include "PhoneLockBaseBox.hpp"
namespace gui
{
- class ScreenLockBox : public ScreenLockBaseBox
+ class PhoneLockBox : public PhoneLockBaseBox
{
public:
- ScreenLockBox(PinLockBaseWindow *LockBaseWindow) : ScreenLockBaseBox(LockBaseWindow), LockWindow(LockBaseWindow)
+ explicit PhoneLockBox(PinLockBaseWindow *LockBaseWindow)
+ : PhoneLockBaseBox(LockBaseWindow), LockWindow(LockBaseWindow)
{}
private:
void buildLockBox(unsigned int pinSize) final;
void setVisibleStateBlocked() final;
- void setVisibleStateEnterPin(EnterPasscodeType type) final;
- void setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value) final;
+ void setVisibleStateInputRequired(InputActionType type) final;
+ void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) final;
PinLockBaseWindow *LockWindow;
};
R module-apps/application-desktop/windows/PukLockBox.cpp => module-apps/locks/widgets/PukLockBox.cpp +21 -21
@@ 1,11 1,11 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "PukLockBox.hpp"
-#include "PinLockBaseWindow.hpp"
-#include "application-desktop/widgets/PinLock.hpp"
-#include "application-desktop/data/AppDesktopStyle.hpp"
+#include "locks/data/LockStyle.hpp"
+#include "locks/windows/PinLockBaseWindow.hpp"
+#include "Lock.hpp"
#include "gui/widgets/Image.hpp"
#include <i18n/i18n.hpp>
#include <Style.hpp>
@@ 15,47 15,47 @@ namespace gui
{
void PukLockBox::popChar(unsigned int charNum)
{
- rebuildPinLabels(charNum);
+ rebuildInputLabels(charNum);
}
void PukLockBox::putChar(unsigned int charNum)
{
- rebuildPinLabels(++charNum);
+ rebuildInputLabels(++charNum);
}
- void PukLockBox::buildLockBox(unsigned int pinSize)
+ void PukLockBox::buildLockBox(unsigned int inputSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
- buildPinLabels(0);
+ buildInputLabels(0);
}
- void PukLockBox::buildPinLabels(unsigned int pinSize)
+ void PukLockBox::buildInputLabels(unsigned int inputSize)
{
auto itemBuilder = []() {
auto label = new gui::Image("dot_12px_hard_alpha_W_G");
return label;
};
- LockWindow->buildPinLabels(itemBuilder, pinSize, label_style::x, label_style::y, label_style::w);
+ LockWindow->buildPinLabels(itemBuilder, inputSize, label_style::x, label_style::y, label_style::w);
LockWindow->pinLabelsBox->setEdges(RectangleEdge::Bottom);
}
- void PukLockBox::rebuildPinLabels(unsigned int pinSize)
+ void PukLockBox::rebuildInputLabels(unsigned int inputSize)
{
LockWindow->pinLabelsBox->erase();
- buildPinLabels(pinSize);
+ buildInputLabels(inputSize);
}
- void PukLockBox::setVisibleStateEnterPin(EnterPasscodeType type)
+ void PukLockBox::setVisibleStateInputRequired(InputActionType type)
{
LockWindow->pinLabelsBox->setVisible(true);
switch (type) {
- case PinLockBox::EnterPasscodeType::ProvidePasscode: {
+ case LockBox::InputActionType::ProvideInput: {
LockWindow->setText("app_desktop_sim_setup_enter_puk", PinLockBaseWindow::TextType::Primary, true);
break;
}
- case PinLockBox::EnterPasscodeType::ProvideNewPasscode: {
+ case LockBox::InputActionType::ProvideNewInput: {
LockWindow->setText("app_desktop_sim_enter_new_pin", PinLockBaseWindow::TextType::Primary);
break;
}
- case PinLockBox::EnterPasscodeType::ConfirmNewPasscode:
+ case LockBox::InputActionType::ConfirmNewInput:
LockWindow->setText("app_desktop_sim_confirm_new_pin", PinLockBaseWindow::TextType::Primary);
break;
}
@@ 63,10 63,10 @@ namespace gui
LockWindow->setImagesVisible(true, false);
LockWindow->setBottomBarWidgetsActive(false, false, true);
}
- void PukLockBox::setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value)
+ void PukLockBox::setVisibleStateInputInvalid(InputErrorType type, unsigned int value)
{
switch (type) {
- case PinLockBox::PasscodeErrorType::InvalidPasscode:
+ case LockBox::InputErrorType::InvalidInput:
if (value > 1) {
LockWindow->setText(
"app_desktop_sim_setup_wrong_puk",
@@ 82,11 82,11 @@ namespace gui
true);
}
break;
- case PinLockBox::PasscodeErrorType::NewPasscodeConfirmFailed: {
+ case LockBox::InputErrorType::NewInputConfirmFailed: {
LockWindow->setText("app_desktop_sim_wrong_pin_confirmation", PinLockBaseWindow::TextType::Primary);
break;
}
- case PinLockBox::PasscodeErrorType::UnhandledError:
+ case LockBox::InputErrorType::UnhandledError:
LOG_ERROR("No use case for UnhandledError in PukLockBox");
break;
}
@@ 102,6 102,6 @@ namespace gui
void PukLockBox::clear()
{
- rebuildPinLabels(0);
+ rebuildInputLabels(0);
}
} // namespace gui
R module-apps/application-desktop/windows/PukLockBox.hpp => module-apps/locks/widgets/PukLockBox.hpp +7 -7
@@ 3,7 3,7 @@
#pragma once
-#include "PinLockBox.hpp"
+#include "LockBox.hpp"
namespace gui
{
@@ 12,7 12,7 @@ namespace gui
namespace gui
{
- class PukLockBox : public PinLockBox
+ class PukLockBox : public LockBox
{
public:
explicit PukLockBox(PinLockBaseWindow *LockBaseWindow) : LockWindow(LockBaseWindow)
@@ 24,12 24,12 @@ namespace gui
void putChar(unsigned int charNum) final;
void clear() final;
- void setVisibleStateEnterPin(EnterPasscodeType type) final;
- void setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value) final;
+ void setVisibleStateInputRequired(InputActionType type) final;
+ void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) final;
void setVisibleStateBlocked() final;
- void buildLockBox(unsigned int pinSize) final;
- void buildPinLabels(unsigned int pinSize);
- void rebuildPinLabels(unsigned int pinSize);
+ void buildLockBox(unsigned int inputSize) final;
+ void buildInputLabels(unsigned int inputSize);
+ void rebuildInputLabels(unsigned int inputSize);
};
} // namespace gui
R module-apps/application-desktop/windows/SimLockBox.cpp => module-apps/locks/widgets/SimLockBox.cpp +21 -21
@@ 3,9 3,9 @@
#include "SimLockBox.hpp"
-#include "PinLockBaseWindow.hpp"
-#include "application-desktop/widgets/PinLock.hpp"
-#include "application-desktop/data/AppDesktopStyle.hpp"
+#include "locks/data/LockStyle.hpp"
+#include "locks/windows/PinLockBaseWindow.hpp"
+#include "Lock.hpp"
#include <Style.hpp>
#include <Image.hpp>
@@ 16,51 16,51 @@ namespace gui
void SimLockBox::popChar(unsigned int charNum)
{
- rebuildPinLabels(charNum);
+ rebuildInputLabels(charNum);
}
void SimLockBox::putChar(unsigned int charNum)
{
- rebuildPinLabels(++charNum);
+ rebuildInputLabels(++charNum);
}
- void SimLockBox::buildLockBox(unsigned int pinSize)
+ void SimLockBox::buildLockBox(unsigned int inputSize)
{
LockWindow->buildImages("pin_lock", "pin_lock_info");
- buildPinLabels(0);
+ buildInputLabels(0);
}
- void SimLockBox::buildPinLabels(unsigned int pinSize)
+ void SimLockBox::buildInputLabels(unsigned int inputSize)
{
auto itemBuilder = []() {
auto label = new gui::Image("dot_12px_hard_alpha_W_G");
return label;
};
- LockWindow->buildPinLabels(itemBuilder, pinSize, label_style::x, label_style::y, label_style::w);
+ LockWindow->buildPinLabels(itemBuilder, inputSize, label_style::x, label_style::y, label_style::w);
LockWindow->pinLabelsBox->setEdges(RectangleEdge::Bottom);
}
- void SimLockBox::rebuildPinLabels(unsigned int pinSize)
+ void SimLockBox::rebuildInputLabels(unsigned int inputSize)
{
LockWindow->pinLabelsBox->erase();
- buildPinLabels(pinSize);
+ buildInputLabels(inputSize);
}
- void SimLockBox::setVisibleStateEnterPin(EnterPasscodeType type)
+ void SimLockBox::setVisibleStateInputRequired(InputActionType type)
{
LockWindow->pinLabelsBox->setVisible(true);
switch (type) {
- case PinLockBox::EnterPasscodeType::ProvidePasscode: {
+ case LockBox::InputActionType::ProvideInput: {
LockWindow->setText(
"app_desktop_sim_enter_pin_unlock",
PinLockBaseWindow::TextType::Primary,
true,
- {{LockWindow->getToken(PinLockBaseWindow::Token::PinType), LockWindow->lock->getPasscodeName()}});
+ {{LockWindow->getToken(PinLockBaseWindow::Token::PinType), LockWindow->lock->getLockName()}});
break;
}
- case PinLockBox::EnterPasscodeType::ProvideNewPasscode:
+ case LockBox::InputActionType::ProvideNewInput:
LockWindow->setText("app_desktop_sim_enter_new_pin", PinLockBaseWindow::TextType::Primary);
break;
- case PinLockBox::EnterPasscodeType::ConfirmNewPasscode:
+ case LockBox::InputActionType::ConfirmNewInput:
LockWindow->setText("app_desktop_sim_confirm_new_pin", PinLockBaseWindow::TextType::Primary);
break;
}
@@ 68,10 68,10 @@ namespace gui
LockWindow->setImagesVisible(true, false);
LockWindow->setBottomBarWidgetsActive(false, false, true);
}
- void SimLockBox::setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value)
+ void SimLockBox::setVisibleStateInputInvalid(InputErrorType type, unsigned int value)
{
switch (type) {
- case PinLockBox::PasscodeErrorType::InvalidPasscode:
+ case LockBox::InputErrorType::InvalidInput:
if (value == 1) {
LockWindow->setText(
"app_desktop_sim_setup_wrong_pin_last_attempt", PinLockBaseWindow::TextType::Primary, true);
@@ 84,10 84,10 @@ namespace gui
{{LockWindow->getToken(PinLockBaseWindow::Token::Attempts), static_cast<int>(value)}});
}
break;
- case PinLockBox::PasscodeErrorType::NewPasscodeConfirmFailed:
+ case LockBox::InputErrorType::NewInputConfirmFailed:
LockWindow->setText("app_desktop_sim_wrong_pin_confirmation", PinLockBaseWindow::TextType::Primary);
break;
- case PinLockBox::PasscodeErrorType::UnhandledError: {
+ case LockBox::InputErrorType::UnhandledError: {
LockWindow->setText("app_desktop_sim_cme_error",
PinLockBaseWindow::TextType::Primary,
true,
@@ 107,6 107,6 @@ namespace gui
void SimLockBox::clear()
{
- rebuildPinLabels(0);
+ rebuildInputLabels(0);
}
} // namespace gui
R module-apps/application-desktop/windows/SimLockBox.hpp => module-apps/locks/widgets/SimLockBox.hpp +8 -8
@@ 1,9 1,9 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
-#include "PinLockBox.hpp"
+#include "LockBox.hpp"
namespace gui
{
@@ 12,7 12,7 @@ namespace gui
namespace gui
{
- class SimLockBox : public PinLockBox
+ class SimLockBox : public LockBox
{
public:
SimLockBox(PinLockBaseWindow *LockBaseWindow) : LockWindow(LockBaseWindow)
@@ 24,12 24,12 @@ namespace gui
void putChar(unsigned int charNum) final;
void clear() final;
- void setVisibleStateEnterPin(EnterPasscodeType type) final;
- void setVisibleStateInvalidPin(PasscodeErrorType type, unsigned int value) final;
+ void setVisibleStateInputRequired(InputActionType type) final;
+ void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) final;
void setVisibleStateBlocked() final;
- void buildLockBox(unsigned int pinSize) final;
- void buildPinLabels(unsigned int pinSize);
- void rebuildPinLabels(unsigned int pinSize);
+ void buildLockBox(unsigned int inputSize) final;
+ void buildInputLabels(unsigned int inputSize);
+ void rebuildInputLabels(unsigned int inputSize);
};
} // namespace gui
R module-apps/application-desktop/windows/LockWindow.cpp => module-apps/locks/windows/LockWindow.cpp +2 -2
@@ 1,8 1,8 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "application-desktop/data/AppDesktopStyle.hpp"
-#include "application-desktop/widgets/PinLock.hpp"
+#include "locks/data/LockStyle.hpp"
+#include "locks/widgets/Lock.hpp"
#include "FontManager.hpp"
#include <i18n/i18n.hpp>
#include "LockWindow.hpp"
R module-apps/application-desktop/windows/LockWindow.hpp => module-apps/locks/windows/LockWindow.hpp +7 -7
@@ 7,9 7,9 @@
#include "RichTextParser.hpp"
#include "Text.hpp"
-namespace gui
+namespace locks
{
- class PinLock;
+ class Lock;
}
namespace gui
@@ 50,11 50,11 @@ namespace gui
text::RichTextParser::TokenMap tokens = text::RichTextParser::TokenMap{});
void setTitleBar(bool isVisible);
- std::unique_ptr<PinLock> lock = nullptr;
- gui::HBox *pinLabelsBox = nullptr;
- gui::Text *primaryText = nullptr;
- gui::Text *secondaryText = nullptr;
- gui::Text *title = nullptr;
+ std::unique_ptr<locks::Lock> lock = nullptr;
+ gui::HBox *pinLabelsBox = nullptr;
+ gui::Text *primaryText = nullptr;
+ gui::Text *secondaryText = nullptr;
+ gui::Text *title = nullptr;
protected:
virtual void buildBottomBar();
R module-apps/application-desktop/windows/PinLockBaseWindow.cpp => module-apps/locks/windows/PinLockBaseWindow.cpp +2 -2
@@ 1,8 1,8 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "application-desktop/data/AppDesktopStyle.hpp"
-#include "application-desktop/widgets/PinLock.hpp"
+#include "locks/data/LockStyle.hpp"
+#include "locks/widgets/Lock.hpp"
#include <i18n/i18n.hpp>
#include "PinLockBaseWindow.hpp"
#include <Image.hpp>
R module-apps/application-desktop/windows/PinLockBaseWindow.hpp => module-apps/locks/windows/PinLockBaseWindow.hpp +0 -0
R module-apps/application-desktop/windows/PinLockWindow.cpp => module-apps/locks/windows/PinLockWindow.cpp +39 -41
@@ 10,10 10,10 @@
#include "PinLockWindow.hpp"
#include "application-desktop/ApplicationDesktop.hpp"
-#include "application-desktop/data/LockPhoneData.hpp"
-#include "ScreenLockBox.hpp"
-#include "SimLockBox.hpp"
-#include "PukLockBox.hpp"
+#include "locks/data/LockData.hpp"
+#include "locks/widgets/PhoneLockBox.hpp"
+#include "locks/widgets/SimLockBox.hpp"
+#include "locks/widgets/PukLockBox.hpp"
#include <application-phonebook/ApplicationPhonebook.hpp>
namespace gui
@@ 47,47 47,45 @@ namespace gui
void PinLockWindow::setVisibleState()
{
restore();
- if (lock->isState(PinLock::LockState::PasscodeRequired)) {
- LockBox->setVisibleStateEnterPin(PinLockBox::EnterPasscodeType::ProvidePasscode);
+ if (lock->isState(Lock::LockState::InputRequired)) {
+ lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideInput);
}
- else if (lock->isState(PinLock::LockState::PasscodeInvalidRetryRequired)) {
- LockBox->setVisibleStateInvalidPin(PinLockBox::PasscodeErrorType::InvalidPasscode, lock->getValue());
+ else if (lock->isState(Lock::LockState::InputInvalidRetryRequired)) {
+ lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::InvalidInput, lock->getAttemptsLeft());
}
- else if (lock->isState(PinLock::LockState::Blocked)) {
- LockBox->setVisibleStateBlocked();
+ else if (lock->isState(Lock::LockState::Blocked)) {
+ lockBox->setVisibleStateBlocked();
}
- else if (lock->isState(PinLock::LockState::NewPasscodeRequired)) {
- LockBox->setVisibleStateEnterPin(PinLockBox::EnterPasscodeType::ProvideNewPasscode);
+ else if (lock->isState(Lock::LockState::NewInputRequired)) {
+ lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideNewInput);
}
- else if (lock->isState(PinLock::LockState::NewPasscodeConfirmRequired)) {
- LockBox->setVisibleStateEnterPin(PinLockBox::EnterPasscodeType::ConfirmNewPasscode);
+ else if (lock->isState(Lock::LockState::NewInputConfirmRequired)) {
+ lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ConfirmNewInput);
}
- else if (lock->isState(PinLock::LockState::NewPasscodeInvalid)) {
- LockBox->setVisibleStateInvalidPin(PinLockBox::PasscodeErrorType::NewPasscodeConfirmFailed,
- lock->getValue());
+ else if (lock->isState(Lock::LockState::NewInputInvalid)) {
+ lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::NewInputConfirmFailed,
+ lock->getAttemptsLeft());
}
- else if (lock->isState(PinLock::LockState::ErrorOccurred)) {
- LockBox->setVisibleStateInvalidPin(PinLockBox::PasscodeErrorType::UnhandledError, lock->getValue());
+ else if (lock->isState(Lock::LockState::ErrorOccurred)) {
+ lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::UnhandledError, lock->getAttemptsLeft());
}
application->refreshWindow(RefreshModes::GUI_REFRESH_FAST);
}
void PinLockWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
- if (auto lockData = dynamic_cast<LockPhoneData *>(data)) {
+ if (auto lockData = dynamic_cast<LockData *>(data)) {
rebuild();
- lockTimeoutApplication = lockData->getPreviousApplication();
- lock = lockData->getLock();
- assert(lock);
+ lock = std::make_unique<locks::Lock>(lockData->getLock());
buildPinLockBox();
- LockBox->buildLockBox(lock->getMaxPinSize());
+ lockBox->buildLockBox(lock->getMaxInputSize());
- if (lock->isState(PinLock::LockState::PasscodeRequired)) {
- currentPasscodeType = PinLockBox::EnterPasscodeType::ProvidePasscode;
+ if (lock->isState(Lock::LockState::InputRequired)) {
+ currentPasscodeType = LockBox::InputActionType::ProvideInput;
}
- else if (lock->isState(PinLock::LockState::NewPasscodeRequired)) {
- currentPasscodeType = PinLockBox::EnterPasscodeType::ProvideNewPasscode;
+ else if (lock->isState(Lock::LockState::NewInputRequired)) {
+ currentPasscodeType = LockBox::InputActionType::ProvideNewInput;
}
setVisibleState();
}
@@ 107,7 105,7 @@ namespace gui
if (usesNumericKeys()) {
lock->clearAttempt();
}
- else if (lock->isState(PinLock::LockState::PasscodeInvalidRetryRequired)) {
+ else if (lock->isState(Lock::LockState::InputInvalidRetryRequired)) {
lock->consumeState();
}
application->switchWindow(gui::name::window::main_window);
@@ 116,14 114,14 @@ namespace gui
else if (inputEvent.is(KeyCode::KEY_PND)) {
if (usesNumericKeys()) {
lock->popChar();
- LockBox->popChar(lock->getCharCount());
+ lockBox->popChar(lock->getCharCount());
bottomBar->setActive(BottomBar::Side::CENTER, lock->canVerify());
return true;
}
}
else if (0 <= gui::toNumeric(inputEvent.keyCode) && gui::toNumeric(inputEvent.keyCode) <= 9) {
if (usesNumericKeys() && lock->canPut()) {
- LockBox->putChar(lock->getCharCount());
+ lockBox->putChar(lock->getCharCount());
lock->putNextChar(gui::toNumeric(inputEvent.keyCode));
bottomBar->setActive(BottomBar::Side::CENTER, lock->canVerify());
return true;
@@ 141,32 139,32 @@ namespace gui
void PinLockWindow::buildPinLockBox()
{
auto lockType = lock->getLockType();
- if (lockType == PinLock::LockType::Screen) {
- LockBox = std::make_unique<ScreenLockBox>(this);
+ if (lockType == Lock::LockType::Screen) {
+ lockBox = std::make_unique<PhoneLockBox>(this);
}
- else if (lockType == PinLock::LockType::SimPuk) {
- LockBox = std::make_unique<PukLockBox>(this);
+ else if (lockType == Lock::LockType::SimPuk) {
+ lockBox = std::make_unique<PukLockBox>(this);
setTitleBar(true, true);
setText("app_desktop_header_sim_setup",
TextType::Title,
true,
{{getToken(Token::Sim), utils::enumToString(lock->getSim())}});
}
- else if (lockType == PinLock::LockType::SimPin) {
- LockBox = std::make_unique<SimLockBox>(this);
+ else if (lockType == Lock::LockType::SimPin) {
+ lockBox = std::make_unique<SimLockBox>(this);
setTitleBar(true, false);
setText("app_desktop_header_sim_setup",
TextType::Title,
true,
{{getToken(Token::Sim), utils::enumToString(lock->getSim())}});
}
- assert(LockBox != nullptr);
+ assert(lockBox != nullptr);
}
auto PinLockWindow::usesNumericKeys() const noexcept -> bool
{
- return lock && (lock->isState(PinLock::LockState::PasscodeRequired) ||
- lock->isState(PinLock::LockState::NewPasscodeRequired) ||
- lock->isState(PinLock::LockState::NewPasscodeConfirmRequired));
+ return lock &&
+ (lock->isState(Lock::LockState::InputRequired) || lock->isState(Lock::LockState::NewInputRequired) ||
+ lock->isState(Lock::LockState::NewInputConfirmRequired));
}
} /* namespace gui */
R module-apps/application-desktop/windows/PinLockWindow.hpp => module-apps/locks/windows/PinLockWindow.hpp +6 -5
@@ 7,17 7,18 @@
#include "gui/widgets/Label.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/BottomBar.hpp"
-#include "application-desktop/widgets/PinLock.hpp"
-#include "PinLockBox.hpp"
+#include "locks/widgets/Lock.hpp"
+#include "locks/widgets/LockBox.hpp"
#include "PinLockBaseWindow.hpp"
+
namespace gui
{
class PinLockWindow : public PinLockBaseWindow
{
const std::string this_window_name;
- std::string lockTimeoutApplication = "";
- std::unique_ptr<PinLockBox> LockBox = nullptr;
- PinLockBox::EnterPasscodeType currentPasscodeType = PinLockBox::EnterPasscodeType::ProvidePasscode;
+ std::string lockTimeoutApplication = "";
+ std::unique_ptr<LockBox> lockBox = nullptr;
+ LockBox::InputActionType currentPasscodeType = LockBox::InputActionType::ProvideInput;
// method hides or show widgets and sets bars according to provided state
void setVisibleState();
A => +34 -0
@@ 0,0 1,34 @@
include_directories( ${CMAKE_PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}"
)
include_directories( ${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}"
)
target_sources( ${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/Popups.cpp"
"${CMAKE_CURRENT_LIST_DIR}/VolumeWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/WindowWithTimer.cpp"
"${CMAKE_CURRENT_LIST_DIR}/HomeModesWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/TetheringConfirmationPopup.cpp"
"${CMAKE_CURRENT_LIST_DIR}/TetheringNotificationPopup.cpp"
"${CMAKE_CURRENT_LIST_DIR}/TetheringPhoneModePopup.cpp"
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/Popups.hpp"
"${CMAKE_CURRENT_LIST_DIR}/VolumeWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/WindowWithTimer.hpp"
"${CMAKE_CURRENT_LIST_DIR}/HomeModesWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/TetheringConfirmationPopup.hpp"
"${CMAKE_CURRENT_LIST_DIR}/TetheringNotificationPopup.hpp"
"${CMAKE_CURRENT_LIST_DIR}/TetheringPhoneModePopup.hpp"
"${CMAKE_CURRENT_LIST_DIR}/data/PopupData.hpp"
)
M module-gui/gui/SwitchData.hpp => module-gui/gui/SwitchData.hpp +4 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 22,9 22,10 @@ namespace gui
public:
SwitchData() = default;
- SwitchData(const std::string &description) : description{description} {};
+ explicit SwitchData(std::string description) : description{std::move(description)} {};
+
virtual ~SwitchData() = default;
- virtual const std::string &getDescription() const
+ [[nodiscard]] virtual const std::string &getDescription() const
{
return description;
};