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.
23 #include <efl_assist.h>
25 #include <vconf-keys.h>
27 //#include "ui_extension.h"
28 #include "w-input-selector.h"
29 #include "w-input-template.h"
30 #include "w-input-smartreply.h"
31 #include "w-input-keyboard.h"
32 #include "w-input-stt-ise.h"
33 #include "w-input-emoticon.h"
34 #include "w-input-stt-tos.h"
41 App_Data* app_data = NULL;
43 InputKeyboardData g_input_keyboard_data;
45 static Elm_Object_Item *it_empty;
46 static Elm_Object_Item *it_title;
47 static Elm_Object_Item *it_plus;
48 static int g_smartreply_current_number = 0; /* currently loaded smartreply number */
49 static unsigned int g_template_current_number = 0; /* currnetly loaded template number */
51 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
53 static Eina_Bool force_highlight_to_top = EINA_FALSE;
54 static Eina_Bool force_highlight_to_bottom = EINA_FALSE;
55 static Eina_Bool is_genlist_highlighed = EINA_FALSE;
57 void _init_app_data(App_Data* app_data);
58 static void _app_language_changed(app_event_info_h event_info, void *user_data);
59 static int _app_control_request_transient_app_cb(void *data);
61 static char *_genlist_text_set_theme_color(const char *str, const char *code);
63 Evas_Object* _create_genlist(Evas_Object* parent);
64 void _create_genlist_items(void* user_data, bool is_type_reply);
65 void _update_genlist_items(void *user_data);
66 void _update_smartreply_items(void *user_data);
67 void _update_template_items(void *user_data);
68 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
69 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
73 void _init_app_data(App_Data* app_data)
75 app_data->win_main = NULL;
76 app_data->layout_main = NULL;
77 app_data->conform = NULL;
78 app_data->naviframe = NULL;
79 app_data->genlist = NULL;
81 app_data->res_path = NULL;
86 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
92 window = elm_layout_add(parent);
94 ret = elm_layout_file_set(window, file, group);
96 evas_object_del(window);
100 content = elm_layout_add(parent);
101 elm_layout_theme_set(content, "layout", "application", "default");
102 elm_object_part_content_set(window, "elm.swallow.content", content);
104 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
110 void init_customizing_theme(void)
112 string stt_edj_path = get_resource_path();
113 string app_edj_path = get_resource_path();
115 stt_edj_path = stt_edj_path + STT_EDJ_FILE;
116 app_edj_path = app_edj_path + APP_EDJ_FILE;
118 elm_theme_extension_add(NULL, stt_edj_path.c_str());
119 elm_theme_extension_add(NULL, app_edj_path.c_str());
123 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
125 reply_to_sender_by_callback_for_back();
130 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
132 App_Data* ad = (App_Data*)data;
134 PRINTFUNC(DLOG_DEBUG, "");
140 bool bAgreed = false;
141 stt_get_user_agreement(&bAgreed);
144 if(is_tos_N66_agreed() == EINA_FALSE){
145 if(is_sap_connection() == EINA_TRUE){
146 ise_show_tos_n66_popup(ad);
148 launch_bt_connection_popup(ad);
151 ise_show_stt_popup(ad);
155 static void _input_smartreply_notify_cb(void *user_data)
157 ecore_main_loop_iterate();
158 _update_genlist_items((void *)app_data);
161 static void _input_template_notify_cb(void *user_data)
163 _update_genlist_items((void *)app_data);
167 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
169 App_Data* ad = (App_Data*)data;
171 PRINTFUNC(DLOG_DEBUG, "");
176 // ise_show_emoticon_popup(ad);
177 ise_show_emoticon_popup_rotary(ad);
180 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
182 App_Data* ad = (App_Data *)data;
184 PRINTFUNC(DLOG_DEBUG, "");
189 input_keyboard_launch(ad->win_main, data);
192 static void __bt_connection_result_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
197 PRINTFUNC(DLOG_ERROR, "service_h is NULL");
201 app_control_get_extra_data(reply, "__BT_CONNECTION__", &val);
203 if ( strcmp(val, "Connected") == 0 ) {
204 PRINTFUNC(DLOG_ERROR, "BT Connected");
206 PRINTFUNC(DLOG_ERROR, "BT Not Connected");
213 static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
215 App_Data* app_data = (App_Data*) data;
216 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
219 elm_genlist_item_selected_set(item, EINA_FALSE);
221 int index = (unsigned int) elm_object_item_data_get(item);
223 char *reply = input_smartreply_get_nth_item(index);
225 input_smartreply_send_feedback(reply);
226 reply_to_sender_by_callback(reply, "smartreply");
233 static void __ise_template_add_gl_sel(void *data, Evas_Object *obj, void *event_info)
235 App_Data* app_data = (App_Data*) data;
236 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
239 elm_genlist_item_selected_set(item, EINA_FALSE);
241 if(is_sap_connection() == EINA_TRUE){
243 show_popup_toast(gettext("WDS_IME_TPOP_ADD_TEMPLATE_ON_YOUR_PHONE_ABB"), true);
245 // send message to Host
246 app_control_h appctrl;
247 app_control_create(&appctrl);
248 app_control_set_app_id(appctrl, "com.samsung.w-manager-service");
249 app_control_add_extra_data(appctrl, "type", "gm_setting");
250 app_control_add_extra_data(appctrl, "data/setting_menu", "texttemplate_setting");
251 app_control_send_launch_request(appctrl, NULL, NULL);
252 app_control_destroy(appctrl);
254 app_control_h app_control;
255 app_control_create(&app_control);
256 app_control_set_app_id(app_control, "com.samsung.bt-connection-popup");
257 app_control_add_extra_data(app_control, "msg", "perform");
258 app_control_send_launch_request(app_control, __bt_connection_result_cb, NULL);
259 app_control_destroy(app_control);
264 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
266 App_Data* app_data = (App_Data*) data;
267 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
271 elm_genlist_item_selected_set(item, EINA_FALSE);
273 index = (unsigned int) elm_object_item_data_get(item);
274 const std::vector<TemplateData> template_list = input_template_get_list();
276 //@ToDo : should call reply function when any template string is selected and confirmed.
277 // Here reply string will be template_list[index].text.c_str();
278 if( index < template_list.size()) {
279 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
285 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
287 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
288 Evas_Object* btn = elm_button_add(obj);
289 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
290 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
291 Evas_Object* ic = elm_image_add(btn);
292 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
293 string path = get_resource_path();
294 if (!strcmp(part, "elm.icon.1")) {
295 elm_object_style_set(btn, "anchor");
296 string path_ic = path + "images/w_mode_stt_ic.png";
297 elm_image_file_set(ic, path_ic.c_str(), NULL);
298 elm_object_content_set(btn, ic);
299 evas_object_layer_set(btn, 32000);
301 } else if (!strcmp(part, "elm.icon.2")){
302 elm_object_style_set(btn, "anchor");
303 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
304 elm_image_file_set(ic, path_ic.c_str(), NULL);
305 elm_object_content_set(btn, ic);
306 evas_object_layer_set(btn, 32000);
308 } else if (!strcmp(part, "elm.icon.3")){
309 elm_object_style_set(btn, "anchor");
310 string path_ic = path + "images/w_mode_keyboard_ic.png";
311 elm_image_file_set(ic, path_ic.c_str(), NULL);
312 elm_object_content_set(btn, ic);
313 evas_object_layer_set(btn, 32000);
314 evas_object_propagate_events_set(btn, EINA_FALSE);
318 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
319 Evas_Object* btn = elm_button_add(obj);
320 elm_object_style_set(btn, "touch_area");
321 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
322 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
323 string path = get_resource_path();
324 if (!strcmp(part, "elm.icon.1.touch_area")) {
325 evas_object_layer_set(btn, 32000);
326 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
328 } else if (!strcmp(part, "elm.icon.2.touch_area")){
329 evas_object_layer_set(btn, 32000);
330 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
331 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
332 evas_object_layer_set(btn, 32000);
333 evas_object_propagate_events_set(btn, EINA_FALSE);
334 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
338 } else if (!strcmp(part, "base")) {
339 Evas_Object* btn = elm_button_add(obj);
340 elm_object_style_set(btn, "ime_transparent");
346 static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
348 if(!strcmp(part, "elm.text")) {
356 reply = input_smartreply_get_nth_item(index);
360 /* Set hightlight color on first 3 smartreply items */
362 char *colored = _genlist_text_set_theme_color(reply, "AT0113");
364 if (colored == NULL) {
377 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
379 if(!strcmp(part, "elm.text")) {
380 unsigned int index = (unsigned int)data;
381 const std::vector<TemplateData> template_list = input_template_get_list();
383 if(index < template_list.size()) {
384 if(template_list[index].use_gettext) {
385 return strdup(gettext(template_list[index].text.c_str()));
387 Eina_Strbuf *buf = NULL;
388 const char *str = NULL;
391 buf = eina_strbuf_new();
393 eina_strbuf_append(buf, template_list[index].text.c_str());
394 eina_strbuf_replace_all(buf, "\n", "");
395 eina_strbuf_replace_all(buf, "\r", "");
397 str = eina_strbuf_string_get(buf);
400 markup = elm_entry_utf8_to_markup(str);
402 eina_strbuf_free(buf);
412 static char * __ise_addtemplate_gl_text_get(void *data, Evas_Object *obj, const char *part)
414 if(!strcmp(part, "elm.text")) {
415 return(strdup(gettext("WDS_IME_MBODY_ADD_TEMPLATE_ABB")));
420 static Evas_Object * __ise_gl_1button_content_get(void *data, Evas_Object *obj, const char *part)
422 if (!strcmp(part, "elm.icon")) {
423 Evas_Object* btn = elm_button_add(obj);
424 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
425 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
426 Evas_Object* ic = elm_image_add(btn);
427 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
428 string path = get_resource_path();
429 elm_object_style_set(btn, "ime_button_template");
430 string path_ic = path + "/images/w_list_add_ic.png";
431 elm_image_file_set(ic, path_ic.c_str(), NULL);
432 elm_object_content_set(btn, ic);
433 evas_object_layer_set(btn, 32000);
440 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
442 //Update genlist items. The Item texts will be translated in the _gl_text_get().
443 elm_genlist_realized_items_update(obj);
446 static int _app_control_request_transient_app_cb(void *data)
452 static char *_genlist_text_set_theme_color(const char *str, const char *code)
455 Eina_Strbuf *buf = NULL;
456 char *colored = NULL;
461 buf = eina_strbuf_new();
463 PRINTFUNC(DLOG_ERROR, "Can not get create strbuf");
467 // ea_theme_color_get(code,
469 // NULL, NULL, NULL, NULL,
470 // NULL, NULL, NULL, NULL);
472 eina_strbuf_append_printf(buf, "<color=#%02x%02x%02x%02x>%s</color>",
475 colored = eina_strbuf_string_steal(buf);
477 eina_strbuf_free(buf);
483 static void _app_control_send_reply_cb(app_control_h request, app_control_h reply,
484 app_control_result_e result, void *user_data)
486 PRINTFUNC(DLOG_DEBUG, "");
487 reply_to_sender_by_callback(NULL, NULL);
491 void set_source_caller_app_id(app_control_h app_control)
494 PRINTFUNC(DLOG_ERROR, "can't get app_control");
499 app_control_get_caller(app_data->source_app_control, &caller);
502 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
503 app_control_add_extra_data(app_control, "caller_appid", caller);
508 void reply_to_sender_by_callback(const char *value, const char *type)
510 PRINTFUNC(DLOG_DEBUG, "");
512 app_control_h app_control;
514 if(app_control_create(&app_control) == 0) {
518 app_control_add_extra_data(app_control, "selected_context", value);
521 app_control_add_extra_data(app_control, "reply_type", type);
523 set_source_caller_app_id(app_control);
525 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
526 if (ret != APP_CONTROL_ERROR_NONE)
527 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
529 app_control_destroy(app_control);
530 app_control_destroy(app_data->source_app_control);
531 app_data->source_app_control = NULL;
535 void reply_to_sender_by_callback_for_back()
537 PRINTFUNC(DLOG_DEBUG, "");
539 app_control_h app_control;
541 if(app_control_create(&app_control) == 0) {
544 app_control_add_extra_data(app_control, "back_to_composer", "yes");
546 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
547 if (ret != APP_CONTROL_ERROR_NONE)
548 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
550 app_control_destroy(app_control);
551 app_control_destroy(app_data->source_app_control);
552 app_data->source_app_control = NULL;
556 char* get_resource_path()
558 if(NULL == app_data->res_path) {
559 app_data->res_path = app_get_resource_path();
560 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
562 return (app_data->res_path);
565 char* get_shared_resource_path()
567 if(NULL == app_data->shared_res_path) {
568 app_data->shared_res_path = app_get_shared_resource_path();
569 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
571 return (app_data->shared_res_path);
574 void show_gl_focus(Eina_Bool bVisible){
575 if(app_data->genlist == NULL)
578 if(bVisible == EINA_TRUE){
579 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
580 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
581 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
583 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
584 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
585 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
589 void show_popup_toast(const char *text, bool check_img)
591 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
595 popup = elm_popup_add(app_data->win_main);
596 elm_object_style_set(popup, "toast/circle");
597 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
598 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
601 string path = get_resource_path();
602 string path_ic = path + "/images/toast_check_icon.png";
603 Evas_Object * img = elm_image_add(popup);
604 elm_image_file_set(img, path_ic.c_str(), NULL);
605 elm_object_part_content_set(popup, "toast,icon", img);
608 elm_object_part_text_set(popup, "elm.text", text);
611 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
612 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
613 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
615 elm_popup_timeout_set(popup, 2.0);
616 evas_object_show(popup);
619 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
622 evas_object_hide(obj);
623 evas_object_del(obj);
627 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
630 elm_popup_dismiss(obj);
634 void _back_to_genlist_for_selector()
636 PRINTFUNC(DLOG_DEBUG, "");
638 if(!app_data) return;
640 if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
641 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
642 reply_to_sender_by_callback(NULL, NULL);
646 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
648 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
651 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
653 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
656 Evas_Object* _create_genlist(Evas_Object* navi)
658 Evas_Object* genlist = elm_genlist_add(navi);
662 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
663 elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
665 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
666 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
667 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
668 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
670 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
671 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
673 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
674 evas_object_show(genlist);
676 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
678 show_gl_focus(EINA_FALSE);
680 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
687 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
688 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
693 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
698 Evas_Object *genlist = (Evas_Object *)obj;
699 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
702 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
704 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
706 if (250 > y && y >= 100){
707 if (last_step == 0) return;
709 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
710 show_gl_focus(EINA_TRUE);
711 } else if (100 > y && y >= 50){
712 if (last_step == 1) return;
714 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
715 show_gl_focus(EINA_TRUE);
716 } else if (y < 50 && y >=0){
717 if (last_step == 2) return;
719 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
720 show_gl_focus(EINA_FALSE);
725 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
729 snprintf(buf, 1023, "%s", "Select method");
733 void _create_genlist_items(void* user_data, bool is_type_reply)
735 LOGD("[psw] _create_genlist_items");
737 App_Data* app_data = (App_Data*) user_data;
739 if(NULL == app_data->genlist) {
740 app_data->genlist = _create_genlist(app_data->naviframe);
741 if(NULL == app_data->genlist)
745 elm_genlist_clear(app_data->genlist);
746 g_smartreply_current_number = 0; /* reset previous smartreply size to 0 */
748 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
749 itc0->item_style = "title";
750 itc0->func.text_get = _main_menu_title_text_get;
751 itc0->func.content_get = NULL;
752 itc0->func.state_get = NULL;
753 itc0->func.del = NULL;
755 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
756 itc1->item_style = "3button";
757 itc1->func.text_get = NULL;
758 itc1->func.content_get = __ise_gl_3button_content_get;
759 itc1->func.state_get = NULL;
760 itc1->func.del = NULL;
763 // dummy title for empty space
764 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
766 ELM_GENLIST_ITEM_NONE,
769 if (!is_type_reply) {
771 it_title = elm_genlist_item_append(app_data->genlist, itc1,
773 ELM_GENLIST_ITEM_NONE,
776 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
778 if (input_smartreply_is_enabled() == false) {
779 _update_template_items(app_data);
780 if(g_template_current_number > 0) {
781 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
782 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
783 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
786 // dummy title for bottom
787 Elm_Object_Item *dummy;
789 dummy = elm_genlist_item_append(app_data->genlist, itc0,
791 ELM_GENLIST_ITEM_NONE,
794 elm_genlist_item_select_mode_set(dummy, ELM_OBJECT_SELECT_MODE_NONE);
798 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
799 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
801 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
803 elm_genlist_item_class_free(itc0);
804 elm_genlist_item_class_free(itc1);
807 void _update_genlist_items(void *user_data)
811 if (input_smartreply_is_enabled())
812 len = input_smartreply_get_reply_num();
814 if (g_smartreply_current_number != len)
815 _update_smartreply_items(user_data);
817 _update_template_items(user_data);
819 g_smartreply_current_number = len;
821 if (g_smartreply_current_number > 0 || g_template_current_number > 0) {
822 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
823 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
824 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
828 void _update_smartreply_items(void *user_data)
832 Elm_Object_Item *first;
833 Elm_Object_Item *menu;
834 Elm_Object_Item *pos;
839 app_data = (App_Data *)user_data;
841 if (app_data == NULL) {
842 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
846 if (app_data->genlist == NULL) {
847 /* smartreply will update when genlist is exist only */
848 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
852 if (input_smartreply_is_enabled())
853 len = input_smartreply_get_reply_num();
855 if (g_smartreply_current_number == len)
858 first = elm_genlist_first_item_get(app_data->genlist);
859 menu = elm_genlist_item_next_get(first);
861 /* Remove current smartreply list */
862 pos = elm_genlist_item_next_get(menu);
863 for (i = 0; i < g_smartreply_current_number; i++) {
864 Elm_Object_Item *next;
869 next = elm_genlist_item_next_get(pos);
870 elm_object_item_del(pos);
874 /* Append newly added smartreply list */
876 Elm_Genlist_Item_Class *itc;
878 itc = elm_genlist_item_class_new();
880 itc->item_style = "1text";
881 itc->func.text_get = __ise_smartreply_gl_text_get;
882 itc->func.content_get = NULL;
883 itc->func.state_get = NULL;
884 itc->func.del = NULL;
887 for (i = 0; i < len; i++) {
888 pos = elm_genlist_item_insert_after(app_data->genlist,
893 ELM_GENLIST_ITEM_NONE,
894 __ise_smartreply_gl_sel,
899 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
901 elm_genlist_item_class_free(itc);
904 g_smartreply_current_number = len;
908 void _update_template_items(void *user_data)
912 Elm_Object_Item *first;
913 Elm_Object_Item *menu;
914 Elm_Object_Item *pos;
915 Elm_Object_Item *template_pos;
917 unsigned int template_len = 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 if (app_data->app_type == APP_TYPE_REPLY) {
934 menu = elm_genlist_first_item_get(app_data->genlist);
936 first = elm_genlist_first_item_get(app_data->genlist);
937 menu = elm_genlist_item_next_get(first);
941 /* move to smartreply next if it need */
942 if (input_smartreply_is_enabled()) {
943 int smartreply_len = 0;
945 smartreply_len = input_smartreply_get_reply_num();
946 if (smartreply_len > 0) {
949 for (j = 0; j < smartreply_len; j++) {
953 pos = elm_genlist_item_next_get(pos);
958 /* Remove Current template list */
959 template_pos = elm_genlist_item_next_get(pos);
960 for (i = 0 ; i < g_template_current_number; i++) {
961 Elm_Object_Item *next;
963 if (template_pos == NULL) {
964 PRINTFUNC(DLOG_ERROR, "Template mismatched, iter : %d, current num: %d",
965 i, g_template_current_number);
969 next = elm_genlist_item_next_get(template_pos);
970 elm_object_item_del(template_pos);
974 /* Remove Add or dummpy button */
976 Elm_Object_Item *next;
978 next = elm_genlist_item_next_get(template_pos);
979 elm_object_item_del(template_pos);
983 /* Append New Template list */
984 const std::vector<TemplateData> template_list = input_template_get_list();
987 if (template_list.size() > 0) {
988 Elm_Genlist_Item_Class *itc;
990 itc = elm_genlist_item_class_new();
992 itc->item_style = "1text";
993 itc->func.text_get = __ise_template_gl_text_get;
994 itc->func.content_get = NULL;
995 itc->func.state_get = NULL;
996 itc->func.del = NULL;
998 for (i = 0; i < template_list.size(); i++) {
999 bool matched = false;
1001 if(!template_list[i].use_gettext) {
1002 int smartreply_len = 0;
1005 smartreply_len = input_smartreply_get_reply_num();
1006 for (j = 0; j < smartreply_len; j++) {
1009 reply = input_smartreply_get_nth_item(j);
1011 if (!strcmp(reply, template_list[i].text.c_str())) {
1021 if (matched == false) {
1022 pos = elm_genlist_item_insert_after(app_data->genlist,
1027 ELM_GENLIST_ITEM_NONE,
1028 __ise_template_gl_sel,
1034 elm_genlist_item_class_free(itc);
1038 // template add button (+)
1039 /* if (!input_template_is_user_template()) {
1040 Elm_Genlist_Item_Class *itc;
1042 itc = elm_genlist_item_class_new();
1044 itc->item_style = "1text.1icon";
1045 itc->func.text_get = __ise_addtemplate_gl_text_get;;
1046 itc->func.content_get = __ise_gl_1button_content_get;
1047 itc->func.state_get = NULL;
1048 itc->func.del = NULL;
1051 pos = elm_genlist_item_insert_after(app_data->genlist,
1056 ELM_GENLIST_ITEM_NONE,
1057 __ise_template_add_gl_sel,
1060 elm_genlist_item_class_free(itc);
1064 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1066 g_template_current_number = template_len;
1070 bool _app_create(void* user_data)
1072 int width = 1000, height = 1000;
1073 // App_Data* app_data = NULL;
1074 Evas_Object* layout = NULL;
1075 Evas_Object* conform = NULL;
1076 Evas_Object* bg = NULL;
1077 Evas_Object* window = NULL;
1078 Eext_Circle_Surface *surface;
1084 _app_language_changed(NULL, NULL);
1086 app_data = (App_Data*)user_data;
1088 elm_app_base_scale_set(1.3);
1090 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1092 init_customizing_theme();
1094 elm_win_title_set(window, PACKAGE);
1095 elm_win_borderless_set(window, EINA_TRUE);
1096 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1097 evas_object_resize(window, width, height);
1098 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1100 LOGE("elm_win_add() is failed.");
1104 bg = elm_bg_add(window);
1105 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1106 elm_win_resize_object_add(window, bg);
1107 evas_object_show(bg);
1109 layout = elm_layout_add(window);
1110 elm_layout_theme_set(layout, "layout", "application", "default");
1111 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1113 conform = elm_conformant_add(window);
1114 surface = eext_circle_surface_conformant_add(conform);
1115 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1118 elm_win_resize_object_add(window, conform);
1119 elm_object_content_set(conform, layout);
1121 evas_object_show(layout);
1122 evas_object_show(conform);
1123 evas_object_show(window);
1124 app_data->win_main = window;
1125 app_data->conform = conform;
1126 app_data->layout_main = layout;
1127 app_data->circle_surface = surface;
1128 app_data->app_type = APP_TYPE_SELECT_MODE;
1130 Evas_Object *naviframe = elm_naviframe_add(layout);
1131 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1132 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1133 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1134 evas_object_show(naviframe);
1136 app_data->naviframe = naviframe;
1141 void _app_service(app_control_h service, void* user_data)
1145 char *context = NULL;
1147 app_control_clone(&(app_data->source_app_control), service);
1148 app_data->reply_type = REPLY_APP_NORMAL;
1150 bool is_type_reply = false;
1151 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1152 if (ret == APP_CONTROL_ERROR_NONE) {
1153 if (!strcmp(context, "input_voice")) {
1154 app_data->app_type = APP_TYPE_STT;
1155 _stt_clicked_cb((void *)app_data, NULL, NULL);
1157 } else if (!strcmp(context, "input_emoticon")) {
1158 app_data->app_type = APP_TYPE_EMOTICON;
1159 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1161 } else if (!strcmp(context, "input_keyboard")) {
1162 app_data->app_type = APP_TYPE_KEYBOARD;
1163 input_keyboard_init(service);
1164 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1166 } else if (!strcmp(context, "input_reply")) {
1167 app_data->app_type = APP_TYPE_REPLY;
1168 is_type_reply = true;
1172 if (app_data->genlist == NULL)
1173 app_data->genlist = _create_genlist(app_data->naviframe);
1175 input_keyboard_init(service);
1177 // input_smartreply_init(service);
1178 // input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1180 // if (input_smartreply_is_enabled())
1181 // input_smartreply_get_reply_async();
1184 input_template_init(service);
1185 input_template_set_notify(_input_template_notify_cb, NULL);
1187 _create_genlist_items(app_data, is_type_reply);
1190 elm_win_activate(app_data->win_main);
1192 // app_control_request_transient_app(service, elm_win_xwindow_get(app_data->win_main), _app_control_request_transient_app_cb, NULL);
1198 void _app_pause(void* user_data)
1200 PRINTFUNC(DLOG_DEBUG, "");
1204 void _app_resume(void* user_data)
1206 PRINTFUNC(DLOG_DEBUG, "");
1209 void _app_terminate(void* user_data)
1211 App_Data* app_data = NULL;
1212 app_data = (App_Data*)user_data;
1214 if(app_data->genlist){
1215 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1218 if(app_data->res_path)
1219 free(app_data->res_path);
1221 if(app_data->shared_res_path)
1222 free(app_data->shared_res_path);
1224 input_keyboard_deinit();
1225 input_smartreply_deinit();
1227 input_template_unset_notify();
1228 input_template_deinit();
1231 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1233 if (setlocale(LC_ALL, "") == NULL) {
1234 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1235 if (setlocale(LC_ALL, lang_str) == NULL)
1238 if (bindtextdomain(domain, dir) == NULL)
1240 if (textdomain(domain) == NULL)
1247 * @brief Set language and locale.
1251 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1253 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1255 setenv("LANG", lang_str, 1);
1256 setenv("LC_MESSAGES", lang_str, 1);
1258 setenv("LANG", "en_GB.utf8", 1);
1259 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1260 lang_str = strdup("en_GB.UTF-8");
1263 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1266 elm_language_set(lang_str);
1273 int main(int argc, char* argv[])
1275 App_Data app_data = {0, };
1276 ui_app_lifecycle_callback_s event_callback = {0, };
1277 app_event_handler_h handlers[5] = {NULL, };
1279 event_callback.create = _app_create;
1280 event_callback.terminate = _app_terminate;
1281 event_callback.pause = _app_pause;
1282 event_callback.resume = _app_resume;
1283 event_callback.app_control = _app_service;
1285 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1286 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1287 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1288 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1289 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1291 _init_app_data(&app_data);
1293 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1294 if (ret != APP_ERROR_NONE) {
1295 LOGD("ui_app_main() is failed. err = %d", ret);