#include "w-input-keyboard.h"
#include "w-input-stt-ise.h"
#include "w-input-emoticon.h"
+#include "w-input-smartreply.h"
#include <stt.h>
static Elm_Object_Item *it_empty;
static Elm_Object_Item *it_title;
+static unsigned int g_smartreply_item_size = 0; /* Current Smartreply item size */
static unsigned int g_template_item_size = 0; /* Current Template item size */
Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
void _create_genlist_items(void* user_data);
void _create_header_items(void *user_data);
void _update_genlist_items(void *user_data);
+unsigned int _update_smartreply_items(void *user_data);
unsigned int _update_template_items(void *user_data);
static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
static void input_type_deinit(void);
+bool __compare_string(const char * src, const char * dst);
+
void _init_app_data(App_Data* app_data)
{
app_data->win_main = NULL;
static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
{
reply_to_sender_by_callback_for_back();
- elm_exit();
+ ui_app_exit();
return EINA_FALSE;
}
ise_show_stt_popup(ad);
}
+static void _input_smartreply_notify_cb(void *user_data)
+{
+ ecore_main_loop_iterate();
+ _update_genlist_items((void *)app_data);
+}
+
static void _input_template_notify_cb(void *user_data)
{
_update_genlist_items((void *)app_data);
input_keyboard_launch(ad->win_main, data);
}
+static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+
+ if (item) {
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+
+ int index = (intptr_t) elm_object_item_data_get(item);
+
+ int type;
+ char *reply = input_smartreply_get_nth_item(index, &type);
+ if (reply) {
+ input_smartreply_send_feedback(reply);
+ reply_to_sender_by_callback(reply, "smartreply", NULL, NULL);
+ free(reply);
+ elm_exit();
+ }
+ }
+}
+
static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
{
Elm_Object_Item *item = (Elm_Object_Item *) event_info;
const std::vector<TemplateData> template_list = input_template_get_list();
if (index < (int)template_list.size()) {
- reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
- elm_exit();
+ reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template", NULL, NULL);
+ ui_app_exit();
}
}
}
return NULL;
}
+static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ if(!strcmp(part, "elm.text")) {
+ int index;
+ char *reply = NULL;
+ index = (intptr_t)data;
+ if (index < 0)
+ return NULL;
+
+ reply = input_smartreply_get_nth_item(index, NULL);
+ if (reply == NULL)
+ return NULL;
+
+ return reply;
+ }
+ return NULL;
+}
static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
{
}
}
-void reply_to_sender_by_callback(const char *value, const char *type)
+void reply_to_sender_by_callback(const char *value, const char *type, const char *path[], const char *cursor_position)
{
PRINTFUNC(DLOG_DEBUG, "");
if (type)
app_control_add_extra_data(app_control, "reply_type", type);
+ if (path != NULL) {
+ app_control_add_extra_data_array(app_control, APP_CONTROL_DATA_PATH, path, 1);
+ }
+
+ if (cursor_position != NULL)
+ app_control_add_extra_data(app_control, "cursor_position_get", cursor_position);
+
set_source_caller_app_id(app_control);
ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
}
if (app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON || app_data->app_type == APP_TYPE_KEYBOARD){
PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON/KEYBOARD mode, So exit here.");
- reply_to_sender_by_callback(NULL, NULL);
- elm_exit();
+ reply_to_sender_by_callback(NULL, NULL, NULL, NULL);
+ ui_app_exit();
}
}
_create_header_items(user_data);
+ if (input_smartreply_is_enabled())
+ g_smartreply_item_size = _update_smartreply_items(user_data);
+ else
+ g_smartreply_item_size = 0;
+
g_template_item_size = _update_template_items(user_data);
/* Update genlist item position */
elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
}
+unsigned int _update_smartreply_items(void *user_data)
+{
+ App_Data* app_data;
+
+ Elm_Object_Item *first;
+
+ unsigned int i = 0;
+ unsigned int len = 0;
+ unsigned int item_size = 0;
+
+ app_data = (App_Data *)user_data;
+
+ if (app_data == NULL) {
+ PRINTFUNC(DLOG_ERROR, "Can not get app_data");
+ return item_size;
+ }
+
+ if (app_data->genlist == NULL) {
+ /* smartreply will update when genlist is exist only */
+ PRINTFUNC(DLOG_ERROR, "Can not get getlist");
+ return item_size;
+ }
+
+ /* Move to smartreply */
+ first = elm_genlist_first_item_get(app_data->genlist);
+ elm_genlist_item_next_get(first);
+
+ if (input_smartreply_is_enabled() == false)
+ return item_size;
+
+ /* Append newly added smartreply list */
+ len = input_smartreply_get_reply_num();
+
+ if (len > 0) {
+ const std::vector<TemplateData> template_list = input_template_get_list();
+
+ Elm_Genlist_Item_Class *itc;
+
+ itc = elm_genlist_item_class_new();
+ itc->item_style = "1text";
+ itc->func.text_get = __ise_smartreply_gl_text_get;
+ itc->func.content_get = NULL;
+ itc->func.state_get = NULL;
+ itc->func.del = NULL;
+
+ for (i = 0; i < len; i++) {
+ char *reply = (char *)"hello";
+ unsigned int j;
+ bool matched;
+
+ matched = false;
+
+ int type;
+ reply = input_smartreply_get_nth_item(i, &type);
+ if (reply == NULL)
+ continue;
+ PRINTFUNC(DLOG_DEBUG, "SmartReply = [%d]%s", i, reply);
+
+ for (j = 0; j < template_list.size(); j++) {
+ const char *template_str;
+
+ if (template_list[j].use_gettext)
+ template_str = gettext(template_list[j].text.c_str());
+ else
+ template_str = template_list[j].text.c_str();
+
+ if (!__compare_string(reply, template_str)) {
+ matched = true;
+ break;
+ }
+ }
+
+ if (matched == true)
+ continue;
+
+ elm_genlist_item_append(app_data->genlist,
+ itc,
+ (void *)(uintptr_t)i,
+ NULL,
+ ELM_GENLIST_ITEM_NONE,
+ __ise_smartreply_gl_sel,
+ app_data);
+
+ item_size++;
+ if (item_size >= 3)
+ break;
+ }
+ elm_genlist_item_class_free(itc);
+ }
+ return item_size;
+}
+
+
unsigned int _update_template_items(void *user_data)
{
App_Data* app_data;
Elm_Object_Item *first;
+ Elm_Object_Item *menu;
+ Elm_Object_Item *pos;
unsigned int i = 0;
unsigned int item_size = 0;
first = elm_genlist_first_item_get(app_data->genlist);
if (first == NULL)
return 0;
- elm_genlist_item_next_get(first);
+ menu = elm_genlist_item_next_get(first);
+
+ pos = menu;
+ /* move to smartreply next if it need */
+ if (input_smartreply_is_enabled()) {
+ unsigned int j = 0;
+
+ for (j = 0; j < g_smartreply_item_size; j++) {
+ if (pos == NULL)
+ break;
+
+ pos = elm_genlist_item_next_get(pos);
+ }
+ }
/* Append New Template list */
const std::vector<TemplateData> template_list = input_template_get_list();
itc->func.del = NULL;
for (i = 0; i < template_list.size(); i++) {
- elm_genlist_item_append(app_data->genlist,
+ pos = elm_genlist_item_append(app_data->genlist,
itc,
(void *)(uintptr_t)i,
NULL,
return item_size;
}
+bool __compare_string(const char * smart_str, const char * template_str)
+{
+ int src_len = 0;
+ int dst_len = 0;
+ bool ret = true;
+
+ if(!smart_str||!template_str)
+ return ret;
+
+ src_len = strlen(smart_str);
+ dst_len = strlen(template_str);
+
+ if(smart_str[src_len-1] == '.')
+ src_len--;
+
+ while(template_str[dst_len-1] == ' ')
+ dst_len--;
+ if(template_str[dst_len-1] == '.')
+ dst_len--;
+
+ dst_len = (dst_len > src_len)? dst_len : src_len;
+
+ if(!strncmp(smart_str, template_str, (size_t)dst_len))
+ ret = false;
+
+ return (ret);
+}
+
bool _app_create(void* user_data)
{
int width = 1000, height = 1000;
Evas_Object* conform = NULL;
Evas_Object* bg = NULL;
Evas_Object* window = NULL;
- Eext_Circle_Surface *surface;
+ Eext_Circle_Surface *surface = NULL;
if (!user_data) {
return false;
char **input_type_array = NULL;
int input_type_array_len = -1;
bool is_extra_data_array = false;
+ char *mime_type = NULL;
app_control_clone(&(app_data->source_app_control), service);
app_data->reply_type = REPLY_APP_NORMAL;
+ app_data->mime_type = MIME_TYPE_ALL;
+
+ ret = app_control_get_mime(service, &mime_type);
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ LOGD("Fail to get mime type : %d", ret);
+ } else {
+ if (mime_type) {
+ LOGD("mime type = %s", mime_type);
+ if (!strncmp(mime_type, "image/", strlen("image/"))) {
+ app_data->mime_type = MIME_TYPE_IMAGE;
+ app_data->app_type = APP_TYPE_DRAWING;
+ launch_drawing_app((void *)app_data);
+ if (mime_type)
+ free(mime_type);
+ goto ACTIVATE;
+ } else if (!strncmp(mime_type, "audio/", strlen("audio/"))) {
+ app_data->mime_type = MIME_TYPE_AUDIO;
+ app_data->app_type = APP_TYPE_STT;
+ _stt_clicked_cb((void *)app_data, NULL, NULL);
+ if (mime_type)
+ free(mime_type);
+ goto ACTIVATE;
+ } else if (!strncmp(mime_type, "text/", strlen("text/"))) {
+ app_data->mime_type = MIME_TYPE_TEXT;
+ }
+ }
+ }
+ if (mime_type)
+ free(mime_type);
if (_TV || _MOBILE) {
app_data->app_type = APP_TYPE_KEYBOARD;
input_keyboard_init(service);
+ input_smartreply_init(service);
+ input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
+
+ if (input_smartreply_is_enabled())
+ input_smartreply_get_reply_async();
+
input_template_init(service);
input_template_set_notify(_input_template_notify_cb, NULL);
void _app_resume(void* user_data)
{
PRINTFUNC(DLOG_DEBUG, "");
+ resume_voice();
}
void _app_terminate(void* user_data)
free(app_data->shared_res_path);
input_keyboard_deinit();
+ input_smartreply_deinit();
input_template_unset_notify();
input_template_deinit();