Files
MuditaOS/module-apps/application-special-input/ApplicationSpecialInput.cpp
Przemyslaw Brudny cbd74648d0 [EGD-6494] Application Manager on action switch fix
Application Manager switch on Action no longer causes to
newly opened application main window switch but it
calls declared action handler.
2021-04-13 10:59:29 +02:00

66 lines
2.0 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ApplicationSpecialInput.hpp"
#include "messages/AppMessage.hpp"
#include "windows/SpecialInputMainWindow.hpp"
using namespace app;
namespace
{
constexpr auto SpecialInputAppStackDepth = 2048U;
} // namespace
ApplicationSpecialInput::ApplicationSpecialInput(std::string name,
std::string parent,
sys::phone_modes::PhoneMode mode,
StartInBackground startInBackground)
: Application(name, parent, mode, startInBackground, SpecialInputAppStackDepth)
{
addActionReceiver(manager::actions::ShowSpecialInput, [this](auto &&data) {
switchWindow(app::char_select, std::move(data));
return actionHandled();
});
windowsFactory.attach(app::char_select, [](Application *app, const std::string &name) {
return std::make_unique<gui::SpecialInputMainWindow>(app);
});
setActiveWindow(app::char_select);
}
sys::MessagePointer ApplicationSpecialInput::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp)
{
auto retMsg = Application::DataReceivedHandler(msgl);
if (dynamic_cast<sys::ResponseMessage *>(retMsg.get())->retCode == sys::ReturnCodes::Success) {
return retMsg;
}
return std::make_shared<sys::ResponseMessage>(sys::ReturnCodes::Unresolved);
}
sys::ReturnCodes ApplicationSpecialInput::InitHandler()
{
auto ret = Application::InitHandler();
if (ret != sys::ReturnCodes::Success) {
LOG_ERROR("Can't initialize ApplicationSpecialInput");
}
createUserInterface();
return ret;
}
void ApplicationSpecialInput::createUserInterface()
{
windowsFactory.build(this, app::char_select);
}
void ApplicationSpecialInput::destroyUserInterface()
{}
sys::ReturnCodes ApplicationSpecialInput::DeinitHandler()
{
return sys::ReturnCodes::Success;
}