2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <vconf-keys.h>
26 #include <system_info.h>
28 #include "w-input-selector.h"
29 #include "w-input-template.h"
30 #include "w-input-keyboard.h"
31 #include "w-input-stt-ise.h"
32 #include "w-input-emoticon.h"
33 #include "w-input-smartreply.h"
40 App_Data* app_data = NULL;
42 InputKeyboardData g_input_keyboard_data;
43 InputTypeData g_input_type_data;
45 static Elm_Object_Item *it_empty;
46 static Elm_Object_Item *it_title;
48 static unsigned int g_smartreply_item_size = 0; /* Current Smartreply item size */
49 static unsigned int g_template_item_size = 0; /* Current Template item size */
51 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
53 tizen_profile_t _get_tizen_profile()
55 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
56 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
60 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
65 profile = TIZEN_PROFILE_MOBILE;
69 profile = TIZEN_PROFILE_WEARABLE;
73 profile = TIZEN_PROFILE_TV;
77 profile = TIZEN_PROFILE_IVI;
79 default: // common or unknown ==> ALL ARE COMMON.
80 profile = TIZEN_PROFILE_COMMON;
87 void _init_app_data(App_Data* app_data);
88 static void _app_language_changed(app_event_info_h event_info, void *user_data);
90 Evas_Object* _create_genlist(Evas_Object* parent);
91 void _create_genlist_items(void* user_data);
92 void _create_header_items(void *user_data);
93 void _update_genlist_items(void *user_data);
94 unsigned int _update_smartreply_items(void *user_data);
95 unsigned int _update_template_items(void *user_data);
96 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
97 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
98 static void input_type_deinit(void);
100 bool __compare_string(const char * src, const char * dst);
102 void _init_app_data(App_Data* app_data)
104 app_data->win_main = NULL;
105 app_data->layout_main = NULL;
106 app_data->conform = NULL;
107 app_data->naviframe = NULL;
108 app_data->genlist = NULL;
110 app_data->res_path = NULL;
113 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
116 Evas_Object* content;
119 window = elm_layout_add(parent);
121 ret = elm_layout_file_set(window, file, group);
123 evas_object_del(window);
127 content = elm_layout_add(parent);
128 elm_layout_theme_set(content, "layout", "application", "default");
129 elm_object_part_content_set(window, "elm.swallow.content", content);
131 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
136 void init_customizing_theme(void)
138 string stt_edj_path = get_resource_path();
139 string app_edj_path = get_resource_path();
142 stt_edj_path = stt_edj_path + STT_EDJ_FILE_WEARABLE;
143 app_edj_path = app_edj_path + APP_EDJ_FILE_WEARABLE;
145 stt_edj_path = stt_edj_path + STT_EDJ_FILE_TV;
146 app_edj_path = app_edj_path + APP_EDJ_FILE_TV;
148 stt_edj_path = stt_edj_path + STT_EDJ_FILE_MOBILE;
149 app_edj_path = app_edj_path + APP_EDJ_FILE_MOBILE;
152 elm_theme_extension_add(NULL, stt_edj_path.c_str());
153 elm_theme_extension_add(NULL, app_edj_path.c_str());
157 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
159 reply_to_sender_by_callback_for_back();
164 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
166 App_Data* ad = (App_Data*)data;
168 PRINTFUNC(DLOG_DEBUG, "");
173 ise_show_stt_popup(ad);
176 static void _input_smartreply_notify_cb(void *user_data)
178 ecore_main_loop_iterate();
179 _update_genlist_items((void *)app_data);
182 static void _input_template_notify_cb(void *user_data)
184 _update_genlist_items((void *)app_data);
187 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
189 App_Data* ad = (App_Data*)data;
191 PRINTFUNC(DLOG_DEBUG, "");
196 ise_show_emoticon_list(ad);
199 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
201 App_Data* ad = (App_Data *)data;
203 PRINTFUNC(DLOG_DEBUG, "");
208 input_keyboard_launch(ad->win_main, data);
211 static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
213 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
216 elm_genlist_item_selected_set(item, EINA_FALSE);
218 int index = (intptr_t) elm_object_item_data_get(item);
221 char *reply = input_smartreply_get_nth_item(index, &type);
223 input_smartreply_send_feedback(reply);
224 reply_to_sender_by_callback(reply, "smartreply", NULL, NULL);
231 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
233 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
237 elm_genlist_item_selected_set(item, EINA_FALSE);
239 index = (uintptr_t) elm_object_item_data_get(item);
240 const std::vector<TemplateData> template_list = input_template_get_list();
242 if (index < (int)template_list.size()) {
243 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template", NULL, NULL);
249 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
251 if (!strcmp(part, "elm.text")) {
252 unsigned int index = (uintptr_t)data;
253 const std::vector<TemplateData> template_list = input_template_get_list();
255 if (index < template_list.size()) {
256 if (template_list[index].use_gettext) {
257 return strdup(gettext(template_list[index].text.c_str()));
259 Eina_Strbuf *buf = NULL;
260 const char *str = NULL;
263 buf = eina_strbuf_new();
265 eina_strbuf_append(buf, template_list[index].text.c_str());
266 eina_strbuf_replace_all(buf, "\n", "");
267 eina_strbuf_replace_all(buf, "\r", "");
269 str = eina_strbuf_string_get(buf);
272 markup = elm_entry_utf8_to_markup(str);
274 eina_strbuf_free(buf);
283 static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj, const char *part)
285 char *first_input_type = *(g_input_type_data.input_type_array + 0);
286 char *second_input_type = *(g_input_type_data.input_type_array + 1);
288 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2"))) {
289 Evas_Object* btn = elm_button_add(obj);
290 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
291 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
293 Evas_Object* ic = elm_image_add(btn);
294 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
295 string path = get_resource_path();
297 path = path + "wearable/";
301 path = path + "mobile/";
303 if (!strcmp(part, "elm.icon.1")) {
305 if (!strcmp(first_input_type, "input_voice")) {
306 elm_object_style_set(btn, "ime_button_stt");
307 path_ic = path + "images/w_mode_stt_ic.png";
308 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
309 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
310 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
311 } else if (!strcmp(first_input_type, "input_emoticon")) {
312 elm_object_style_set(btn, "ime_button_emoticon");
313 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
314 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
315 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
316 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
317 } else if (!strcmp(first_input_type, "input_keyboard")) {
318 elm_object_style_set(btn, "ime_button_keyboard");
319 path_ic = path + "images/w_mode_keyboard_ic.png";
320 evas_object_propagate_events_set(btn, EINA_FALSE);
321 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
322 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
323 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
325 elm_image_file_set(ic, path_ic.c_str(), NULL);
326 elm_object_content_set(btn, ic);
327 evas_object_layer_set(btn, 32000);
328 } else if (!strcmp(part, "elm.icon.2")){
330 if (!strcmp(second_input_type, "input_voice")) {
331 elm_object_style_set(btn, "ime_button_stt");
332 path_ic = path + "images/w_mode_stt_ic.png";
333 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
334 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
335 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
336 } else if (!strcmp(second_input_type, "input_emoticon")) {
337 elm_object_style_set(btn, "ime_button_emoticon");
338 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
339 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
340 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
341 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
342 } else if (!strcmp(second_input_type, "input_keyboard")) {
343 elm_object_style_set(btn, "ime_button_keyboard");
344 path_ic = path + "images/w_mode_keyboard_ic.png";
345 evas_object_propagate_events_set(btn, EINA_FALSE);
346 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
347 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
348 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
350 elm_image_file_set(ic, path_ic.c_str(), NULL);
351 elm_object_content_set(btn, ic);
352 evas_object_layer_set(btn, 32000);
355 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area"))) {
356 Evas_Object* btn = elm_button_add(obj);
357 elm_object_style_set(btn, "touch_area");
358 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
359 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
360 string path = get_resource_path();
361 if (!strcmp(part, "elm.icon.1.touch_area")) {
362 evas_object_layer_set(btn, 32000);
363 if (!strcmp(first_input_type, "input_voice")) {
364 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
365 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
366 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
367 } else if (!strcmp(first_input_type, "input_emoticon")) {
368 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
369 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
370 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
371 } else if (!strcmp(first_input_type, "input_keyboard")) {
372 evas_object_propagate_events_set(btn, EINA_FALSE);
373 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
374 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
375 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
377 } else if (!strcmp(part, "elm.icon.2.touch_area")){
378 evas_object_layer_set(btn, 32000);
379 if (!strcmp(second_input_type, "input_voice")) {
380 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
381 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
382 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
383 } else if (!strcmp(second_input_type, "input_emoticon")) {
384 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
385 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
386 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
387 } else if (!strcmp(second_input_type, "input_keyboard")) {
388 evas_object_propagate_events_set(btn, EINA_FALSE);
389 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
390 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
391 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
395 } else if (!strcmp(part, "base")) {
396 Evas_Object* btn = elm_button_add(obj);
397 elm_object_style_set(btn, "ime_transparent");
403 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
405 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
406 Evas_Object* btn = elm_button_add(obj);
407 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
408 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
409 Evas_Object* ic = elm_image_add(btn);
410 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
411 string path = get_resource_path();
413 path = path + "wearable/";
417 path = path + "mobile/";
419 if (!strcmp(part, "elm.icon.1")) {
420 elm_object_style_set(btn, "ime_button_stt");
421 string path_ic = path + "images/w_mode_stt_ic.png";
422 elm_image_file_set(ic, path_ic.c_str(), NULL);
423 elm_object_content_set(btn, ic);
424 evas_object_layer_set(btn, 32000);
425 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
426 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
427 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
429 } else if (!strcmp(part, "elm.icon.2")){
430 elm_object_style_set(btn, "ime_button_emoticon");
431 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
432 elm_image_file_set(ic, path_ic.c_str(), NULL);
433 elm_object_content_set(btn, ic);
434 evas_object_layer_set(btn, 32000);
435 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
436 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
437 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
439 } else if (!strcmp(part, "elm.icon.3")){
440 elm_object_style_set(btn, "ime_button_keyboard");
441 string path_ic = path + "images/w_mode_keyboard_ic.png";
442 elm_image_file_set(ic, path_ic.c_str(), NULL);
443 elm_object_content_set(btn, ic);
444 evas_object_layer_set(btn, 32000);
445 evas_object_propagate_events_set(btn, EINA_FALSE);
446 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
447 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
448 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
452 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
453 Evas_Object* btn = elm_button_add(obj);
454 elm_object_style_set(btn, "touch_area");
455 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
456 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
457 string path = get_resource_path();
458 if (!strcmp(part, "elm.icon.1.touch_area")) {
459 evas_object_layer_set(btn, 32000);
460 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
461 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
462 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
464 } else if (!strcmp(part, "elm.icon.2.touch_area")){
465 evas_object_layer_set(btn, 32000);
466 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
467 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
468 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
469 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
470 evas_object_layer_set(btn, 32000);
471 evas_object_propagate_events_set(btn, EINA_FALSE);
472 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
473 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
474 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
478 } else if (!strcmp(part, "base")) {
479 Evas_Object* btn = elm_button_add(obj);
480 elm_object_style_set(btn, "ime_transparent");
486 static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
488 if(!strcmp(part, "elm.text")) {
491 index = (intptr_t)data;
495 reply = input_smartreply_get_nth_item(index, NULL);
504 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
506 //Update genlist items. The Item texts will be translated in the _gl_text_get().
507 elm_genlist_realized_items_update(obj);
510 static char * __ise_drawing_text_get(void *data, Evas_Object *obj, const char *part)
512 if(!strcmp(part, "elm.text")) {
513 return(strdup(gettext("WDS_IME_MBODY_DRAWING_M_EMOTICON_ABB")));
518 static Evas_Object * __ise_drawing_content_get(void *data, Evas_Object *obj, const char *part)
520 if (!strcmp(part, "elm.icon")) {
521 Evas_Object* btn = elm_button_add(obj);
522 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
523 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
524 Evas_Object* ic = elm_image_add(btn);
525 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
526 string path = get_resource_path();
528 path = path + "wearable/";
532 path = path + "mobile/";
533 elm_object_style_set(btn, "ime_button_drawing");
534 string path_ic = path + "images/wi_drawing_icon.png";
535 elm_image_file_set(ic, path_ic.c_str(), NULL);
536 elm_object_content_set(btn, ic);
537 evas_object_layer_set(btn, 32000);
543 void set_source_caller_app_id(app_control_h app_control)
546 PRINTFUNC(DLOG_ERROR, "can't get app_control");
551 app_control_get_caller(app_data->source_app_control, &caller);
554 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
555 app_control_add_extra_data(app_control, "caller_appid", caller);
560 void reply_to_sender_by_callback(const char *value, const char *type, const char *path[], const char *cursor_position)
562 PRINTFUNC(DLOG_DEBUG, "");
564 app_control_h app_control;
566 if (app_control_create(&app_control) == 0) {
570 app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, value);
573 app_control_add_extra_data(app_control, "reply_type", type);
576 app_control_add_extra_data_array(app_control, APP_CONTROL_DATA_PATH, path, 1);
579 if (cursor_position != NULL)
580 app_control_add_extra_data(app_control, "cursor_position_get", cursor_position);
582 set_source_caller_app_id(app_control);
584 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
585 if (ret != APP_CONTROL_ERROR_NONE)
586 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
588 app_control_destroy(app_control);
589 app_control_destroy(app_data->source_app_control);
590 app_data->source_app_control = NULL;
594 void reply_to_sender_by_callback_for_back()
596 PRINTFUNC(DLOG_DEBUG, "");
598 app_control_h app_control;
600 if (app_control_create(&app_control) == 0) {
603 app_control_add_extra_data(app_control, "back_to_composer", "yes");
605 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
606 if (ret != APP_CONTROL_ERROR_NONE)
607 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
609 app_control_destroy(app_control);
610 app_control_destroy(app_data->source_app_control);
611 app_data->source_app_control = NULL;
615 char* get_resource_path()
617 if (NULL == app_data->res_path) {
618 app_data->res_path = app_get_resource_path();
619 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
621 return (app_data->res_path);
624 char* get_shared_resource_path()
626 if (NULL == app_data->shared_res_path) {
627 app_data->shared_res_path = app_get_shared_resource_path();
628 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
630 return (app_data->shared_res_path);
633 void show_gl_focus(Eina_Bool bVisible){
634 if (app_data->genlist == NULL)
637 if (bVisible == EINA_TRUE){
638 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
639 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
640 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
642 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
643 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
644 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
648 void show_popup_toast(const char *text, bool check_img)
650 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
654 popup = elm_popup_add(app_data->win_main);
655 elm_object_style_set(popup, "toast/circle");
656 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
657 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
660 string path = get_resource_path();
662 path = path + "wearable/";
666 path = path + "mobile/";
667 string path_ic = path + "/images/toast_check_icon.png";
668 Evas_Object * img = elm_image_add(popup);
669 elm_image_file_set(img, path_ic.c_str(), NULL);
670 elm_object_part_content_set(popup, "toast,icon", img);
673 elm_object_part_text_set(popup, "elm.text", text);
676 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
677 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
678 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
680 elm_popup_timeout_set(popup, 2.0);
681 evas_object_show(popup);
684 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
687 evas_object_hide(obj);
688 evas_object_del(obj);
692 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
695 elm_popup_dismiss(obj);
699 void _back_to_genlist_for_selector()
701 PRINTFUNC(DLOG_DEBUG, "");
703 if (!app_data) return;
706 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
707 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
709 if (app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON || app_data->app_type == APP_TYPE_KEYBOARD){
710 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON/KEYBOARD mode, So exit here.");
711 reply_to_sender_by_callback(NULL, NULL, NULL, NULL);
716 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
718 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
721 Evas_Object* _create_genlist(Evas_Object* navi)
723 Evas_Object* genlist = elm_genlist_add(navi);
727 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
729 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
730 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
731 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
732 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
734 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
735 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
737 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
738 evas_object_show(genlist);
740 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
742 show_gl_focus(EINA_FALSE);
744 const char *item_style = NULL;
746 item_style = "empty";
747 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
754 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
755 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
760 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
765 Evas_Object *genlist = (Evas_Object *)obj;
766 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
769 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
771 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
773 if (250 > y && y >= 100){
774 if (last_step == 0) return;
776 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
777 show_gl_focus(EINA_TRUE);
778 } else if (100 > y && y >= 50){
779 if (last_step == 1) return;
781 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
782 show_gl_focus(EINA_TRUE);
783 } else if (y < 50 && y >=0){
784 if (last_step == 2) return;
786 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
787 show_gl_focus(EINA_FALSE);
791 void _create_genlist_items(void* user_data)
793 App_Data* app_data = (App_Data*) user_data;
795 if (NULL == app_data->genlist) {
796 app_data->genlist = _create_genlist(app_data->naviframe);
797 if (NULL == app_data->genlist)
801 elm_genlist_clear(app_data->genlist);
803 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
804 itc0->item_style = NULL;
805 itc0->func.text_get = NULL;
806 itc0->func.content_get = NULL;
807 itc0->func.state_get = NULL;
808 itc0->func.del = NULL;
810 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
811 if (g_input_type_data.input_type_array_len == 2){
812 itc1->item_style = "2button_flat";
813 itc1->func.text_get = NULL;
814 itc1->func.content_get = __ise_gl_2button_content_get;
815 itc1->func.state_get = NULL;
816 itc1->func.del = NULL;
818 itc1->item_style = "3button_flat";
819 itc1->func.text_get = NULL;
820 itc1->func.content_get = __ise_gl_3button_content_get;
821 itc1->func.state_get = NULL;
822 itc1->func.del = NULL;
825 // dummy title for empty space
826 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
828 ELM_GENLIST_ITEM_NONE,
831 if (app_data->app_type != APP_TYPE_REPLY) {
833 it_title = elm_genlist_item_append(app_data->genlist, itc1,
835 ELM_GENLIST_ITEM_NONE,
838 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
840 g_template_item_size = _update_template_items(app_data);
842 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
843 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
845 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
847 elm_genlist_item_class_free(itc0);
848 elm_genlist_item_class_free(itc1);
851 void _create_header_items(void *user_data)
853 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
854 itc0->item_style = "title";
855 itc0->func.text_get = NULL;
856 itc0->func.content_get = NULL;
857 itc0->func.state_get = NULL;
858 itc0->func.del = NULL;
860 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
861 if (g_input_type_data.input_type_array_len == 2) {
862 itc1->item_style = "2button_flat";
863 itc1->func.text_get = NULL;
864 itc1->func.content_get = __ise_gl_2button_content_get;
865 itc1->func.state_get = NULL;
866 itc1->func.del = NULL;
868 itc1->item_style = "3button_flat";
869 itc1->func.text_get = NULL;
870 itc1->func.content_get = __ise_gl_3button_content_get;
871 itc1->func.state_get = NULL;
872 itc1->func.del = NULL;
875 // dummy title for empty space
876 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
878 ELM_GENLIST_ITEM_NONE,
882 it_title = elm_genlist_item_append(app_data->genlist, itc1,
884 ELM_GENLIST_ITEM_NONE,
887 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
889 elm_genlist_item_class_free(itc0);
890 elm_genlist_item_class_free(itc1);
893 void _update_genlist_items(void *user_data)
895 elm_genlist_clear(app_data->genlist);
897 _create_header_items(user_data);
899 if (input_smartreply_is_enabled())
900 g_smartreply_item_size = _update_smartreply_items(user_data);
902 g_smartreply_item_size = 0;
904 g_template_item_size = _update_template_items(user_data);
906 /* Update genlist item position */
907 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
908 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
911 unsigned int _update_smartreply_items(void *user_data)
915 Elm_Object_Item *first;
918 unsigned int len = 0;
919 unsigned int item_size = 0;
921 app_data = (App_Data *)user_data;
923 if (app_data == NULL) {
924 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
928 if (app_data->genlist == NULL) {
929 /* smartreply will update when genlist is exist only */
930 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
934 /* Move to smartreply */
935 first = elm_genlist_first_item_get(app_data->genlist);
936 elm_genlist_item_next_get(first);
938 if (input_smartreply_is_enabled() == false)
941 /* Append newly added smartreply list */
942 len = input_smartreply_get_reply_num();
945 const std::vector<TemplateData> template_list = input_template_get_list();
947 Elm_Genlist_Item_Class *itc;
949 itc = elm_genlist_item_class_new();
950 itc->item_style = "1text";
951 itc->func.text_get = __ise_smartreply_gl_text_get;
952 itc->func.content_get = NULL;
953 itc->func.state_get = NULL;
954 itc->func.del = NULL;
956 for (i = 0; i < len; i++) {
957 char *reply = (char *)"hello";
964 reply = input_smartreply_get_nth_item(i, &type);
967 SECURE_LOGD("SmartReply = [%d]%s", i, reply);
969 for (j = 0; j < template_list.size(); j++) {
970 const char *template_str;
972 if (template_list[j].use_gettext)
973 template_str = gettext(template_list[j].text.c_str());
975 template_str = template_list[j].text.c_str();
977 if (!__compare_string(reply, template_str)) {
986 elm_genlist_item_append(app_data->genlist,
988 (void *)(uintptr_t)i,
990 ELM_GENLIST_ITEM_NONE,
991 __ise_smartreply_gl_sel,
998 elm_genlist_item_class_free(itc);
1003 static void _drawing_item_clicked_cb(void *data, Evas_Object * obj, void *event_info)
1005 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
1006 App_Data* ad = (App_Data*) data;
1010 launch_drawing_app(ad);
1013 unsigned int _update_template_items(void *user_data)
1017 Elm_Object_Item *first;
1018 Elm_Object_Item *menu;
1019 Elm_Object_Item *pos;
1022 unsigned int item_size = 0;
1024 app_data = (App_Data *)user_data;
1026 if (app_data == NULL) {
1027 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1031 if (app_data->genlist == NULL) {
1032 /* smartreply will update when genlist is exist only */
1033 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1037 first = elm_genlist_first_item_get(app_data->genlist);
1040 menu = elm_genlist_item_next_get(first);
1043 /* move to smartreply next if it need */
1044 if (input_smartreply_is_enabled()) {
1047 for (j = 0; j < g_smartreply_item_size; j++) {
1051 pos = elm_genlist_item_next_get(pos);
1055 /* Append New Template list */
1056 const std::vector<TemplateData> template_list = input_template_get_list();
1058 if (template_list.size() > 0) {
1059 Elm_Genlist_Item_Class *itc;
1061 itc = elm_genlist_item_class_new();
1063 itc->item_style = "1text";
1064 itc->func.text_get = __ise_template_gl_text_get;
1065 itc->func.content_get = NULL;
1066 itc->func.state_get = NULL;
1067 itc->func.del = NULL;
1069 for (i = 0; i < template_list.size(); i++) {
1070 pos = elm_genlist_item_append(app_data->genlist,
1072 (void *)(uintptr_t)i,
1074 ELM_GENLIST_ITEM_NONE,
1075 __ise_template_gl_sel,
1079 elm_genlist_item_class_free(itc);
1081 // drawing button (+)
1082 if (app_data->mime_type == MIME_TYPE_ALL) {
1083 Elm_Genlist_Item_Class *itc;
1084 itc = elm_genlist_item_class_new();
1086 itc->item_style = "1text.1icon";
1087 itc->func.text_get = __ise_drawing_text_get;;
1088 itc->func.content_get = __ise_drawing_content_get;
1089 itc->func.state_get = NULL;
1090 itc->func.del = NULL;
1092 elm_genlist_item_append(app_data->genlist,
1096 ELM_GENLIST_ITEM_NONE,
1097 _drawing_item_clicked_cb,
1100 elm_genlist_item_class_free(itc);
1103 // dummy item for empty space
1104 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1105 itc0->item_style = "title";
1106 itc0->func.text_get = NULL;
1107 itc0->func.content_get = NULL;
1108 itc0->func.state_get = NULL;
1109 itc0->func.del = NULL;
1111 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1113 ELM_GENLIST_ITEM_NONE,
1115 elm_genlist_item_class_free(itc0);
1121 bool __compare_string(const char * smart_str, const char * template_str)
1127 if(!smart_str||!template_str)
1130 src_len = strlen(smart_str);
1131 dst_len = strlen(template_str);
1133 if(smart_str[src_len-1] == '.')
1136 while(template_str[dst_len-1] == ' ')
1138 if(template_str[dst_len-1] == '.')
1141 dst_len = (dst_len > src_len)? dst_len : src_len;
1143 if(!strncmp(smart_str, template_str, (size_t)dst_len))
1149 bool _app_create(void* user_data)
1151 int width = 1000, height = 1000;
1152 // App_Data* app_data = NULL;
1153 Evas_Object* layout = NULL;
1154 Evas_Object* conform = NULL;
1155 Evas_Object* bg = NULL;
1156 Evas_Object* window = NULL;
1157 Eext_Circle_Surface *surface = NULL;
1163 _app_language_changed(NULL, NULL);
1165 app_data = (App_Data*)user_data;
1167 elm_app_base_scale_set(1.3);
1169 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1171 init_customizing_theme();
1173 elm_win_title_set(window, PACKAGE);
1174 elm_win_borderless_set(window, EINA_TRUE);
1175 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1176 evas_object_resize(window, width, height);
1177 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1179 LOGE("elm_win_add() is failed.");
1183 bg = elm_bg_add(window);
1184 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1185 elm_win_resize_object_add(window, bg);
1186 evas_object_show(bg);
1188 layout = elm_layout_add(window);
1189 elm_layout_theme_set(layout, "layout", "application", "default");
1190 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1192 conform = elm_conformant_add(window);
1194 surface = eext_circle_surface_conformant_add(conform);
1196 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1198 elm_win_resize_object_add(window, conform);
1199 elm_object_content_set(conform, layout);
1201 evas_object_show(layout);
1202 evas_object_show(conform);
1203 evas_object_show(window);
1204 app_data->win_main = window;
1205 app_data->conform = conform;
1206 app_data->layout_main = layout;
1207 app_data->circle_surface = surface;
1208 app_data->app_type = APP_TYPE_SELECT_MODE;
1210 Evas_Object *naviframe = elm_naviframe_add(layout);
1211 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1212 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1213 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1214 evas_object_show(naviframe);
1216 app_data->naviframe = naviframe;
1221 void _app_service(app_control_h service, void* user_data)
1224 char *context = NULL;
1225 char **input_type_array = NULL;
1226 int input_type_array_len = -1;
1227 bool is_extra_data_array = false;
1228 char *mime_type = NULL;
1230 app_control_clone(&(app_data->source_app_control), service);
1231 app_data->reply_type = REPLY_APP_NORMAL;
1232 app_data->mime_type = MIME_TYPE_ALL;
1234 ret = app_control_get_mime(service, &mime_type);
1235 if (ret != APP_CONTROL_ERROR_NONE) {
1236 LOGD("Fail to get mime type : %d", ret);
1239 LOGD("mime type = %s", mime_type);
1240 if (!strncmp(mime_type, "image/", strlen("image/"))) {
1241 app_data->mime_type = MIME_TYPE_IMAGE;
1242 app_data->app_type = APP_TYPE_DRAWING;
1243 launch_drawing_app((void *)app_data);
1247 } else if (!strncmp(mime_type, "audio/", strlen("audio/"))) {
1248 app_data->mime_type = MIME_TYPE_AUDIO;
1249 app_data->app_type = APP_TYPE_STT;
1250 _stt_clicked_cb((void *)app_data, NULL, NULL);
1254 } else if (!strncmp(mime_type, "text/", strlen("text/"))) {
1255 app_data->mime_type = MIME_TYPE_TEXT;
1262 if (_TV || _MOBILE) {
1263 app_data->app_type = APP_TYPE_KEYBOARD;
1264 input_keyboard_init(service);
1265 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1269 ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
1270 if ( is_extra_data_array == true) {
1271 ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
1272 g_input_type_data.input_type_array = input_type_array;
1273 g_input_type_data.input_type_array_len = input_type_array_len;
1275 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1276 if (ret == APP_CONTROL_ERROR_NONE) {
1277 if (!strcmp(context, "input_voice")) {
1278 app_data->app_type = APP_TYPE_STT;
1279 _stt_clicked_cb((void *)app_data, NULL, NULL);
1281 } else if (!strcmp(context, "input_recording")) {
1282 app_data->app_type = APP_TYPE_RECORDING;
1283 _stt_clicked_cb((void *)app_data, NULL, NULL);
1285 } else if (!strcmp(context, "input_emoticon")) {
1286 app_data->app_type = APP_TYPE_EMOTICON;
1287 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1289 } else if (!strcmp(context, "input_keyboard")) {
1290 app_data->app_type = APP_TYPE_KEYBOARD;
1291 input_keyboard_init(service);
1292 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1294 } else if (!strcmp(context, "input_drawing")) {
1295 app_data->app_type = APP_TYPE_DRAWING;
1296 _drawing_item_clicked_cb((void *)app_data, NULL, NULL);
1298 } else if (!strcmp(context, "input_reply")) {
1299 app_data->app_type = APP_TYPE_REPLY;
1304 if (app_data->genlist == NULL)
1305 app_data->genlist = _create_genlist(app_data->naviframe);
1307 input_keyboard_init(service);
1309 input_smartreply_init(service);
1310 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1312 if (input_smartreply_is_enabled())
1313 input_smartreply_get_reply_async();
1315 input_template_init(service);
1316 input_template_set_notify(_input_template_notify_cb, NULL);
1318 _create_genlist_items(app_data);
1321 elm_win_activate(app_data->win_main);
1328 void _app_pause(void* user_data)
1330 PRINTFUNC(DLOG_DEBUG, "");
1334 void _app_resume(void* user_data)
1336 PRINTFUNC(DLOG_DEBUG, "");
1340 void _app_terminate(void* user_data)
1342 App_Data* app_data = NULL;
1343 app_data = (App_Data*)user_data;
1345 if (app_data->genlist){
1346 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1349 if (app_data->res_path)
1350 free(app_data->res_path);
1352 if (app_data->shared_res_path)
1353 free(app_data->shared_res_path);
1355 input_keyboard_deinit();
1356 input_smartreply_deinit();
1358 input_template_unset_notify();
1359 input_template_deinit();
1361 input_type_deinit();
1364 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1366 if (setlocale(LC_ALL, "") == NULL) {
1367 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1368 if (setlocale(LC_ALL, lang_str) == NULL)
1371 if (bindtextdomain(domain, dir) == NULL)
1373 if (textdomain(domain) == NULL)
1380 * @brief Set language and locale.
1384 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1386 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1388 setenv("LANG", lang_str, 1);
1389 setenv("LC_MESSAGES", lang_str, 1);
1391 setenv("LANG", "en_GB.utf8", 1);
1392 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1393 lang_str = strdup("en_GB.UTF-8");
1396 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1399 elm_language_set(lang_str);
1404 void input_type_deinit(void)
1407 char **data_array = NULL;
1409 data_array = g_input_type_data.input_type_array;
1411 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
1412 if (*(data_array + i))
1413 free(*(data_array + i));
1417 g_input_type_data.input_type_array = NULL;
1418 g_input_type_data.input_type_array_len = 0;
1421 EXPORTED int main(int argc, char* argv[])
1423 App_Data app_data = {0, };
1424 ui_app_lifecycle_callback_s event_callback = {0, };
1425 app_event_handler_h handlers[5] = {NULL, };
1427 event_callback.create = _app_create;
1428 event_callback.terminate = _app_terminate;
1429 event_callback.pause = _app_pause;
1430 event_callback.resume = _app_resume;
1431 event_callback.app_control = _app_service;
1433 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1434 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1435 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1436 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1437 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1439 _init_app_data(&app_data);
1441 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1442 if (ret != APP_ERROR_NONE) {
1443 LOGD("ui_app_main() is failed. err = %d", ret);