A art/phone/application_call/emergency_W_G.png => art/phone/application_call/emergency_W_G.png +0 -0
A image/assets/images/emergency_W_G.vpi => image/assets/images/emergency_W_G.vpi +0 -0
M image/assets/lang/English.json => image/assets/lang/English.json +2 -2
@@ 158,8 158,6 @@
"app_notes_no_notes": "<text align='center' color='9'>No notes yet.<p>Press <b>left arrow</b> to add new.</p></text>",
"app_notes_search_no_results": "No notes found.",
- "app_call_emergency_text": "Emergency call",
-
"app_calllog_title_main": "Calls",
"app_calllog_new_note": "New Note",
"app_calllog_save": "SAVE",
@@ 265,6 263,8 @@
"app_call_bluetooth": "BLUETOOTH",
"app_call_no_sim": "No SIM.\n\nTo make a call,\nplease insert a SIM card.",
"app_call_offline": "You're offline.\n\nTo make a call\n switch to the Connected mode.",
+ "app_call_emergency_text": "Emergency call",
+ "app_call_wrong_emergency": "Can't make a call.\n$NUMBER is not an emergency number.",
"app_messages_title_main": "Messages",
"app_messages_new_message": "New Message",
"app_messages_no_messages": "<text align='center' color='9'>No messages yet.<p>Press <b>left arrow</b> to add new.</p></text>",
M module-apps/application-call/ApplicationCall.cpp => module-apps/application-call/ApplicationCall.cpp +26 -6
@@ 181,19 181,37 @@ namespace app
});
}
- bool ApplicationCall::showNotification(std::function<bool()> action)
+ bool ApplicationCall::showNotification(std::function<bool()> action,
+ const std::string &icon,
+ const std::string &text)
{
gui::DialogMetadata meta;
- meta.icon = "info_big_circle_W_G";
- meta.text = utils::localize.get("app_call_no_sim");
- meta.action = action;
- switchWindow(app::window::name_dialogConfirm, std::make_unique<gui::DialogMetadataMessage>(meta));
+ meta.icon = icon;
+ meta.text = text;
+ meta.action = std::move(action);
+ switchWindow(app::window::name_dialogConfirm, std::make_unique<gui::DialogMetadataMessage>(std::move(meta)));
return true;
}
void ApplicationCall::destroyUserInterface()
{}
+ void ApplicationCall::handleEmergencyCallEvent(const std::string &number)
+ {
+ auto ret = CellularServiceAPI::DialNumber(this, utils::PhoneNumber(number));
+ if (ret == false) {
+ auto action = [=]() -> bool {
+ returnToPreviousWindow();
+ return true;
+ };
+ const auto icon = "emergency_W_G";
+ auto text = utils::localize.get("app_call_wrong_emergency");
+ utils::findAndReplaceAll(text, "$NUMBER", number);
+ showNotification(action, icon, text);
+ return;
+ }
+ }
+
void ApplicationCall::handleCallEvent(const std::string &number)
{
if (!Store::GSM::get()->simCardInserted()) {
@@ 202,7 220,9 @@ namespace app
returnToPreviousWindow();
return true;
};
- showNotification(action);
+ const auto icon = "info_big_circle_W_G";
+ const auto text = utils::localize.get("app_call_no_sim");
+ showNotification(action, icon, text);
return;
}
M module-apps/application-call/ApplicationCall.hpp => module-apps/application-call/ApplicationCall.hpp +6 -4
@@ 46,9 46,10 @@ namespace app
class EnterNumberWindowInterface
{
public:
- virtual ~EnterNumberWindowInterface() noexcept = default;
- virtual void handleCallEvent(const std::string &number) = 0;
- virtual void handleAddContactEvent(const std::string &number) = 0;
+ virtual ~EnterNumberWindowInterface() noexcept = default;
+ virtual void handleCallEvent(const std::string &number) = 0;
+ virtual void handleEmergencyCallEvent(const std::string &number) = 0;
+ virtual void handleAddContactEvent(const std::string &number) = 0;
};
class ApplicationCall : public Application, public CallWindowInterface, public EnterNumberWindowInterface
@@ 78,10 79,11 @@ namespace app
void createUserInterface() override;
void destroyUserInterface() override;
+ void handleEmergencyCallEvent(const std::string &number) override;
void handleCallEvent(const std::string &number) override;
void handleAddContactEvent(const std::string &number) override;
- auto showNotification(std::function<bool()> action) -> bool;
+ auto showNotification(std::function<bool()> action, const std::string &icon, const std::string &text) -> bool;
[[nodiscard]] auto getState() const noexcept -> call::State override
{
M module-apps/application-call/windows/EmergencyCallWindow.cpp => module-apps/application-call/windows/EmergencyCallWindow.cpp +13 -6
@@ 29,12 29,19 @@ namespace gui
bool EmergencyCallWindow::onInput(const InputEvent &inputEvent)
{
- if (inputEvent.is(gui::KeyCode::KEY_ENTER)) {
- auto data = std::make_unique<gui::SwitchData>();
- data->ignoreCurrentWindowOnStack = true;
- app::manager::Controller::sendAction(
- application, app::manager::actions::ShowEmergencyContacts, std::move(data));
- return true;
+ if (inputEvent.isShortPress()) {
+ // Call function
+ if (inputEvent.is(KeyCode::KEY_LF)) {
+ interface->handleEmergencyCallEvent(enteredNumber);
+ return true;
+ }
+ else if (inputEvent.is(gui::KeyCode::KEY_ENTER)) {
+ auto data = std::make_unique<gui::SwitchData>();
+ data->ignoreCurrentWindowOnStack = true;
+ app::manager::Controller::sendAction(
+ application, app::manager::actions::ShowEmergencyContacts, std::move(data));
+ return true;
+ }
}
return NumberWindow::onInput(inputEvent);