Files
MuditaOS/module-gui/gui/widgets/InputMode.cpp
Alek-Mudita 8585ea8cf4 Call app - contact recognition (#169)
* [EGD-2569] added # and * as numeric inputs

* [EGD-2569] added '+' input sign

* [EGD-2569] created defines with window names for call app

* [EGD-2547] contact recognition during call

* [EGD-2547] moved UiCommon

* [fix][EGD-2547] fix for setting empty UTF string to text gui field

* [EGD-2547] adding new contact from call enter window

* [EGD-2547] minor clean up and added param validation

* [EGD-2547] easier method to add contact

* [EGD-2569] added new keyboard profile (numeric with special signs)
Desktop is passing it properly to Call app.

* [EGD-2569] added transaltor to enternumberwindow

* [EGD-2569] reverted unnecessary changes

[EGD-2569] revert

[EGD-2569] revert of not needed changes

* [EGD-2569] fix in phone.kprof

* [EGD-2547] unified API to call and send sms

* [EGD-2547]  changed default to true

* [EGD-2547] minor clean up.

* [EGD-2569] revert changes in PinLockWindow.cpp

* [EGD-2569][fix] eneter as null char

* [EGD-2547] PR fixes

[EGD-2547] code review fixes / refactored UiCommon

[EGD-2547] more code review fixes

[EGD-2547] rem not needed cast

* [EGD-2547] PR fixes

* [EGD-2547] splitting of UiCommon

* [EGD-2547] typo fix

* [EGD-2547] revereted one line conversion from char to string.
2020-02-28 09:37:25 +01:00

88 lines
2.0 KiB
C++

#include <InputMode.hpp>
#include <i18/i18.hpp>
#include <map>
/// input mode strings - as these are stored in json (in files...)
const std::map<InputMode::Mode, std::string> input_mode = {
{InputMode::digit, "common_kbd_numeric"},
{InputMode::ABC, "common_kbd_upper"},
{InputMode::abc, "common_kbd_lower"},
{InputMode::phone, "common_kbd_phone"},
};
static std::string getInputName(InputMode::Mode m)
{
switch (m)
{
case InputMode::digit:
return "123";
case InputMode::ABC:
return "ABC";
case InputMode::abc:
return "abc";
case InputMode::phone:
return "phone";
default:
return "";
}
}
InputMode::InputMode(std::list<InputMode::Mode> mode_list, std::function<void(const UTF8 &text)> show_type_cb, std::function<void()> show_special_char_selector,
const UTF8 &prev_text)
: input_mode_list(mode_list), show_type_cb(show_type_cb), show_special_char_selector(show_special_char_selector)
{
// failsafe
if (input_mode_list.size() == 0)
{
input_mode_list.push_back(Mode::digit);
}
}
InputMode::Mode InputMode::modeNow()
{
return *std::next(input_mode_list.begin(), input_mode_list_pos);
}
/// sets next selected mode using Application pointer
void InputMode::next()
{
++input_mode_list_pos;
if (input_mode_list_pos == input_mode_list.size())
{
input_mode_list_pos = 0;
}
LOG_INFO("%d", input_mode_list_pos);
show_input_type();
}
const std::string &InputMode::get()
{
return utils::localize.get(input_mode.at(modeNow()));
}
void InputMode::show_input_type()
{
LOG_INFO("Mode: %d", modeNow());
if (show_type_cb)
{
show_type_cb(getInputName(modeNow()));
}
}
void InputMode::show_restore()
{
if (show_type_cb)
{
show_type_cb(restore_text);
}
}
void InputMode::select_special_char()
{
LOG_INFO("Special character selector");
if (show_special_char_selector)
{
show_special_char_selector();
}
}