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,
832 it_title = elm_genlist_item_append(app_data->genlist, itc1,
834 ELM_GENLIST_ITEM_NONE,
837 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
839 g_template_item_size = _update_template_items(app_data);
841 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
842 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
844 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
846 elm_genlist_item_class_free(itc0);
847 elm_genlist_item_class_free(itc1);
850 void _create_header_items(void *user_data)
852 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
853 itc0->item_style = "title";
854 itc0->func.text_get = NULL;
855 itc0->func.content_get = NULL;
856 itc0->func.state_get = NULL;
857 itc0->func.del = NULL;
859 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
860 if (g_input_type_data.input_type_array_len == 2) {
861 itc1->item_style = "2button_flat";
862 itc1->func.text_get = NULL;
863 itc1->func.content_get = __ise_gl_2button_content_get;
864 itc1->func.state_get = NULL;
865 itc1->func.del = NULL;
867 itc1->item_style = "3button_flat";
868 itc1->func.text_get = NULL;
869 itc1->func.content_get = __ise_gl_3button_content_get;
870 itc1->func.state_get = NULL;
871 itc1->func.del = NULL;
874 // dummy title for empty space
875 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
877 ELM_GENLIST_ITEM_NONE,
881 it_title = elm_genlist_item_append(app_data->genlist, itc1,
883 ELM_GENLIST_ITEM_NONE,
886 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
888 elm_genlist_item_class_free(itc0);
889 elm_genlist_item_class_free(itc1);
892 void _update_genlist_items(void *user_data)
894 elm_genlist_clear(app_data->genlist);
896 _create_header_items(user_data);
898 if (input_smartreply_is_enabled())
899 g_smartreply_item_size = _update_smartreply_items(user_data);
901 g_smartreply_item_size = 0;
903 g_template_item_size = _update_template_items(user_data);
905 /* Update genlist item position */
906 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
907 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
910 unsigned int _update_smartreply_items(void *user_data)
914 Elm_Object_Item *first;
917 unsigned int len = 0;
918 unsigned int item_size = 0;
920 app_data = (App_Data *)user_data;
922 if (app_data == NULL) {
923 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
927 if (app_data->genlist == NULL) {
928 /* smartreply will update when genlist is exist only */
929 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
933 /* Move to smartreply */
934 first = elm_genlist_first_item_get(app_data->genlist);
935 elm_genlist_item_next_get(first);
937 if (input_smartreply_is_enabled() == false)
940 /* Append newly added smartreply list */
941 len = input_smartreply_get_reply_num();
944 const std::vector<TemplateData> template_list = input_template_get_list();
946 Elm_Genlist_Item_Class *itc;
948 itc = elm_genlist_item_class_new();
949 itc->item_style = "1text";
950 itc->func.text_get = __ise_smartreply_gl_text_get;
951 itc->func.content_get = NULL;
952 itc->func.state_get = NULL;
953 itc->func.del = NULL;
955 for (i = 0; i < len; i++) {
956 char *reply = (char *)"hello";
963 reply = input_smartreply_get_nth_item(i, &type);
966 SECURE_LOGD("SmartReply = [%d]%s", i, reply);
968 for (j = 0; j < template_list.size(); j++) {
969 const char *template_str;
971 if (template_list[j].use_gettext)
972 template_str = gettext(template_list[j].text.c_str());
974 template_str = template_list[j].text.c_str();
976 if (!__compare_string(reply, template_str)) {
985 elm_genlist_item_append(app_data->genlist,
987 (void *)(uintptr_t)i,
989 ELM_GENLIST_ITEM_NONE,
990 __ise_smartreply_gl_sel,
997 elm_genlist_item_class_free(itc);
1002 static void _drawing_item_clicked_cb(void *data, Evas_Object * obj, void *event_info)
1004 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
1005 App_Data* ad = (App_Data*) data;
1009 launch_drawing_app(ad);
1012 unsigned int _update_template_items(void *user_data)
1016 Elm_Object_Item *first;
1017 Elm_Object_Item *menu;
1018 Elm_Object_Item *pos;
1021 unsigned int item_size = 0;
1023 app_data = (App_Data *)user_data;
1025 if (app_data == NULL) {
1026 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1030 if (app_data->genlist == NULL) {
1031 /* smartreply will update when genlist is exist only */
1032 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1036 first = elm_genlist_first_item_get(app_data->genlist);
1039 menu = elm_genlist_item_next_get(first);
1042 /* move to smartreply next if it need */
1043 if (input_smartreply_is_enabled()) {
1046 for (j = 0; j < g_smartreply_item_size; j++) {
1050 pos = elm_genlist_item_next_get(pos);
1054 /* Append New Template list */
1055 const std::vector<TemplateData> template_list = input_template_get_list();
1057 if (template_list.size() > 0) {
1058 Elm_Genlist_Item_Class *itc;
1060 itc = elm_genlist_item_class_new();
1062 itc->item_style = "1text";
1063 itc->func.text_get = __ise_template_gl_text_get;
1064 itc->func.content_get = NULL;
1065 itc->func.state_get = NULL;
1066 itc->func.del = NULL;
1068 for (i = 0; i < template_list.size(); i++) {
1069 pos = elm_genlist_item_append(app_data->genlist,
1071 (void *)(uintptr_t)i,
1073 ELM_GENLIST_ITEM_NONE,
1074 __ise_template_gl_sel,
1078 elm_genlist_item_class_free(itc);
1080 // drawing button (+)
1081 if (app_data->mime_type == MIME_TYPE_ALL) {
1082 Elm_Genlist_Item_Class *itc;
1083 itc = elm_genlist_item_class_new();
1085 itc->item_style = "1text.1icon";
1086 itc->func.text_get = __ise_drawing_text_get;;
1087 itc->func.content_get = __ise_drawing_content_get;
1088 itc->func.state_get = NULL;
1089 itc->func.del = NULL;
1091 elm_genlist_item_append(app_data->genlist,
1095 ELM_GENLIST_ITEM_NONE,
1096 _drawing_item_clicked_cb,
1099 elm_genlist_item_class_free(itc);
1102 // dummy item for empty space
1103 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1104 itc0->item_style = "title";
1105 itc0->func.text_get = NULL;
1106 itc0->func.content_get = NULL;
1107 itc0->func.state_get = NULL;
1108 itc0->func.del = NULL;
1110 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1112 ELM_GENLIST_ITEM_NONE,
1114 elm_genlist_item_class_free(itc0);
1120 bool __compare_string(const char * smart_str, const char * template_str)
1126 if(!smart_str||!template_str)
1129 src_len = strlen(smart_str);
1130 dst_len = strlen(template_str);
1132 if(smart_str[src_len-1] == '.')
1135 while(template_str[dst_len-1] == ' ')
1137 if(template_str[dst_len-1] == '.')
1140 dst_len = (dst_len > src_len)? dst_len : src_len;
1142 if(!strncmp(smart_str, template_str, (size_t)dst_len))
1148 bool _app_create(void* user_data)
1150 int width = 1000, height = 1000;
1151 // App_Data* app_data = NULL;
1152 Evas_Object* layout = NULL;
1153 Evas_Object* conform = NULL;
1154 Evas_Object* bg = NULL;
1155 Evas_Object* window = NULL;
1156 Eext_Circle_Surface *surface = NULL;
1162 _app_language_changed(NULL, NULL);
1164 app_data = (App_Data*)user_data;
1166 elm_app_base_scale_set(1.3);
1168 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1170 init_customizing_theme();
1172 elm_win_title_set(window, PACKAGE);
1173 elm_win_borderless_set(window, EINA_TRUE);
1174 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1175 evas_object_resize(window, width, height);
1176 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1178 LOGE("elm_win_add() is failed.");
1182 bg = elm_bg_add(window);
1183 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1184 elm_win_resize_object_add(window, bg);
1185 evas_object_show(bg);
1187 layout = elm_layout_add(window);
1188 elm_layout_theme_set(layout, "layout", "application", "default");
1189 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1191 conform = elm_conformant_add(window);
1193 surface = eext_circle_surface_conformant_add(conform);
1195 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1197 elm_win_resize_object_add(window, conform);
1198 elm_object_content_set(conform, layout);
1200 evas_object_show(layout);
1201 evas_object_show(conform);
1202 evas_object_show(window);
1203 app_data->win_main = window;
1204 app_data->conform = conform;
1205 app_data->layout_main = layout;
1206 app_data->circle_surface = surface;
1207 app_data->app_type = APP_TYPE_SELECT_MODE;
1209 Evas_Object *naviframe = elm_naviframe_add(layout);
1210 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1211 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1212 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1213 evas_object_show(naviframe);
1215 app_data->naviframe = naviframe;
1220 void _app_service(app_control_h service, void* user_data)
1223 char *context = NULL;
1224 char **input_type_array = NULL;
1225 int input_type_array_len = -1;
1226 bool is_extra_data_array = false;
1227 char *mime_type = NULL;
1229 app_control_clone(&(app_data->source_app_control), service);
1230 app_data->reply_type = REPLY_APP_NORMAL;
1231 app_data->mime_type = MIME_TYPE_ALL;
1233 ret = app_control_get_mime(service, &mime_type);
1234 if (ret != APP_CONTROL_ERROR_NONE) {
1235 LOGD("Fail to get mime type : %d", ret);
1238 LOGD("mime type = %s", mime_type);
1239 if (!strncmp(mime_type, "image/", strlen("image/"))) {
1240 app_data->mime_type = MIME_TYPE_IMAGE;
1241 app_data->app_type = APP_TYPE_DRAWING;
1242 launch_drawing_app((void *)app_data);
1246 } else if (!strncmp(mime_type, "audio/", strlen("audio/"))) {
1247 app_data->mime_type = MIME_TYPE_AUDIO;
1248 app_data->app_type = APP_TYPE_STT;
1249 _stt_clicked_cb((void *)app_data, NULL, NULL);
1253 } else if (!strncmp(mime_type, "text/", strlen("text/"))) {
1254 app_data->mime_type = MIME_TYPE_TEXT;
1261 if (_TV || _MOBILE) {
1262 app_data->app_type = APP_TYPE_KEYBOARD;
1263 input_keyboard_init(service);
1264 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1268 ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
1269 if ( is_extra_data_array == true) {
1270 ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
1271 g_input_type_data.input_type_array = input_type_array;
1272 g_input_type_data.input_type_array_len = input_type_array_len;
1274 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1275 if (ret == APP_CONTROL_ERROR_NONE) {
1276 if (!strcmp(context, "input_voice")) {
1277 app_data->app_type = APP_TYPE_STT;
1278 _stt_clicked_cb((void *)app_data, NULL, NULL);
1280 } else if (!strcmp(context, "input_emoticon")) {
1281 app_data->app_type = APP_TYPE_EMOTICON;
1282 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1284 } else if (!strcmp(context, "input_keyboard")) {
1285 app_data->app_type = APP_TYPE_KEYBOARD;
1286 input_keyboard_init(service);
1287 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1289 } else if (!strcmp(context, "input_reply")) {
1290 app_data->app_type = APP_TYPE_REPLY;
1295 if (app_data->genlist == NULL)
1296 app_data->genlist = _create_genlist(app_data->naviframe);
1298 input_keyboard_init(service);
1300 input_smartreply_init(service);
1301 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1303 if (input_smartreply_is_enabled())
1304 input_smartreply_get_reply_async();
1306 input_template_init(service);
1307 input_template_set_notify(_input_template_notify_cb, NULL);
1309 _create_genlist_items(app_data);
1312 elm_win_activate(app_data->win_main);
1319 void _app_pause(void* user_data)
1321 PRINTFUNC(DLOG_DEBUG, "");
1325 void _app_resume(void* user_data)
1327 PRINTFUNC(DLOG_DEBUG, "");
1331 void _app_terminate(void* user_data)
1333 App_Data* app_data = NULL;
1334 app_data = (App_Data*)user_data;
1336 if (app_data->genlist){
1337 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1340 if (app_data->res_path)
1341 free(app_data->res_path);
1343 if (app_data->shared_res_path)
1344 free(app_data->shared_res_path);
1346 input_keyboard_deinit();
1347 input_smartreply_deinit();
1349 input_template_unset_notify();
1350 input_template_deinit();
1352 input_type_deinit();
1355 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1357 if (setlocale(LC_ALL, "") == NULL) {
1358 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1359 if (setlocale(LC_ALL, lang_str) == NULL)
1362 if (bindtextdomain(domain, dir) == NULL)
1364 if (textdomain(domain) == NULL)
1371 * @brief Set language and locale.
1375 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1377 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1379 setenv("LANG", lang_str, 1);
1380 setenv("LC_MESSAGES", lang_str, 1);
1382 setenv("LANG", "en_GB.utf8", 1);
1383 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1384 lang_str = strdup("en_GB.UTF-8");
1387 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1390 elm_language_set(lang_str);
1395 void input_type_deinit(void)
1398 char **data_array = NULL;
1400 data_array = g_input_type_data.input_type_array;
1402 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
1403 if (*(data_array + i))
1404 free(*(data_array + i));
1408 g_input_type_data.input_type_array = NULL;
1409 g_input_type_data.input_type_array_len = 0;
1412 EXPORTED int main(int argc, char* argv[])
1414 App_Data app_data = {0, };
1415 ui_app_lifecycle_callback_s event_callback = {0, };
1416 app_event_handler_h handlers[5] = {NULL, };
1418 event_callback.create = _app_create;
1419 event_callback.terminate = _app_terminate;
1420 event_callback.pause = _app_pause;
1421 event_callback.resume = _app_resume;
1422 event_callback.app_control = _app_service;
1424 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1425 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1426 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1427 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1428 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1430 _init_app_data(&app_data);
1432 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1433 if (ret != APP_ERROR_NONE) {
1434 LOGD("ui_app_main() is failed. err = %d", ret);