[EGD-2594] apps/call: add libphonenumber support

Augment handling phone numbers with libphonenumber:
 - add "as you type" formatting to phone numbers,
 - normalize phone number handling by using libphonenumber's phone
 number representation.

Clean up the code by moving application logic back to the application
and window data back to the window and reordering includes.

Application's stack size has been increased due to formatter stack
utilization level.
This commit is contained in:
Marcin Smoczyński committed 2020-04-08 18:23:45 +02:00
1 parent c34f7ddb53
commit f2eb9bb37a
6 files changed
+151 -87

No files matched your search

@@ -7,30 +7,32 @@
* @details
*/
#include "ApplicationCall.hpp"
#include "Application.hpp"
#include "MessageType.hpp"
#include "data/CallSwitchData.hpp"
#include "log/log.hpp"
#include "time/time_conversion.hpp"
#include "windows/CallMainWindow.hpp"
#include "windows/CallWindow.hpp"
#include "windows/EmergencyCallWindow.hpp"
#include "windows/EnterNumberWindow.hpp"
#include <Application.hpp>
#include <MessageType.hpp>
#include <UiCommonActions.hpp>
#include <log/log.hpp>
#include <service-cellular/ServiceCellular.hpp>
#include <service-cellular/api/CellularServiceAPI.hpp>
#include <service-audio/api/AudioServiceAPI.hpp>
#include <service-appmgr/ApplicationManager.hpp>
#include <time/time_conversion.hpp>
#include <ticks.hpp>
#include "service-cellular/ServiceCellular.hpp"
#include "service-cellular/api/CellularServiceAPI.hpp"
#include "service-audio/api/AudioServiceAPI.hpp"
#include "service-appmgr/ApplicationManager.hpp"
#include <cassert>
namespace app
{
ApplicationCall::ApplicationCall(std::string name, std::string parent, bool startBackgound)
: Application(name, parent, startBackgound, 4096 + 2048),
: Application(name, parent, startBackgound, app::call_stack_size),
timerCall(CreateAppTimer(1000, true, [=]() { timerCallCallback(); }))
{}
@@ -199,7 +201,6 @@ namespace app
void ApplicationCall::createUserInterface()
{
gui::AppWindow *window = nullptr;
window = new gui::CallMainWindow(this);
@@ -215,16 +216,6 @@ namespace app
windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));
}
void ApplicationCall::setDisplayedNumber(std::string num)
{
phoneNumber = num;
}
const std::string &ApplicationCall::getDisplayedNumber()
{
return phoneNumber;
}
void ApplicationCall::runCallTimer()
{
callStartTime = utils::time::Timestamp();
@@ -244,4 +235,17 @@ namespace app
void ApplicationCall::destroyUserInterface()
{}
void ApplicationCall::handleCallEvent(const std::string &number)
{
LOG_INFO("number: [%s]", number.c_str());
auto ret = CellularServiceAPI::DialNumber(this, number.c_str());
LOG_INFO("CALL RESULT: %s", (ret ? "OK" : "FAIL"));
}
void ApplicationCall::handleAddContactEvent(const std::string &number)
{
LOG_INFO("add contact information: %s", number.c_str());
app::contact(this, app::ContactOperation::Add, number);
}
} // namespace app