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 if (app_data->app_type == APP_TYPE_KEYBOARD_FROM_SMS)
190 input_keyboard_launch(ad->win_main);
192 input_keyboard_launch_with_ui(ad->win_main, data);
195 static void __bt_connection_result_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
200 PRINTFUNC(DLOG_ERROR, "service_h is NULL");
204 app_control_get_extra_data(reply, "__BT_CONNECTION__", &val);
206 if ( strcmp(val, "Connected") == 0 ) {
207 PRINTFUNC(DLOG_ERROR, "BT Connected");
209 PRINTFUNC(DLOG_ERROR, "BT Not Connected");
217 static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
219 App_Data* app_data = (App_Data*) data;
220 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
223 elm_genlist_item_selected_set(item, EINA_FALSE);
225 int index = (unsigned int) elm_object_item_data_get(item);
227 char *reply = input_smartreply_get_nth_item(index);
229 input_smartreply_send_feedback(reply);
230 if(app_data->reply_type == REPLY_APP_CONTROL){
231 reply_to_sender_by_appcontrol((void*)app_data, reply, "smartreply");
234 reply_to_sender_by_callback(reply, "smartreply");
242 static void __ise_template_add_gl_sel(void *data, Evas_Object *obj, void *event_info)
244 App_Data* app_data = (App_Data*) data;
245 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
248 elm_genlist_item_selected_set(item, EINA_FALSE);
250 if(is_sap_connection() == EINA_TRUE){
252 show_popup_toast(gettext("WDS_IME_TPOP_ADD_TEMPLATE_ON_YOUR_PHONE_ABB"), true);
254 // send message to Host
255 app_control_h appctrl;
256 app_control_create(&appctrl);
257 app_control_set_app_id(appctrl, "com.samsung.w-manager-service");
258 app_control_add_extra_data(appctrl, "type", "gm_setting");
259 app_control_add_extra_data(appctrl, "data/setting_menu", "texttemplate_setting");
260 app_control_send_launch_request(appctrl, NULL, NULL);
261 app_control_destroy(appctrl);
263 app_control_h app_control;
264 app_control_create(&app_control);
265 app_control_set_app_id(app_control, "com.samsung.bt-connection-popup");
266 app_control_add_extra_data(app_control, "msg", "perform");
267 app_control_send_launch_request(app_control, __bt_connection_result_cb, NULL);
268 app_control_destroy(app_control);
273 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
275 App_Data* app_data = (App_Data*) data;
276 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
280 elm_genlist_item_selected_set(item, EINA_FALSE);
282 index = (unsigned int) elm_object_item_data_get(item);
283 const std::vector<TemplateData> template_list = input_template_get_list();
285 //@ToDo : should call reply function when any template string is selected and confirmed.
286 // Here reply string will be template_list[index].text.c_str();
287 if( index < template_list.size()) {
288 if(app_data->reply_type == REPLY_APP_CONTROL){
289 reply_to_sender_by_appcontrol((void*)app_data, gettext(template_list[index].text.c_str()), "template");
291 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
298 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
300 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
301 Evas_Object* btn = elm_button_add(obj);
302 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
303 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
304 Evas_Object* ic = elm_image_add(btn);
305 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
306 string path = get_resource_path();
307 if (!strcmp(part, "elm.icon.1")) {
308 elm_object_style_set(btn, "anchor");
309 string path_ic = path + "images/w_mode_stt_ic.png";
310 elm_image_file_set(ic, path_ic.c_str(), NULL);
311 elm_object_content_set(btn, ic);
312 evas_object_layer_set(btn, 32000);
314 } else if (!strcmp(part, "elm.icon.2")){
315 elm_object_style_set(btn, "anchor");
316 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
317 elm_image_file_set(ic, path_ic.c_str(), NULL);
318 elm_object_content_set(btn, ic);
319 evas_object_layer_set(btn, 32000);
321 } else if (!strcmp(part, "elm.icon.3")){
322 elm_object_style_set(btn, "anchor");
323 string path_ic = path + "images/w_mode_keyboard_ic.png";
324 elm_image_file_set(ic, path_ic.c_str(), NULL);
325 elm_object_content_set(btn, ic);
326 evas_object_layer_set(btn, 32000);
327 evas_object_propagate_events_set(btn, EINA_FALSE);
331 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
332 Evas_Object* btn = elm_button_add(obj);
333 elm_object_style_set(btn, "touch_area");
334 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
335 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
336 string path = get_resource_path();
337 if (!strcmp(part, "elm.icon.1.touch_area")) {
338 evas_object_layer_set(btn, 32000);
339 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
341 } else if (!strcmp(part, "elm.icon.2.touch_area")){
342 evas_object_layer_set(btn, 32000);
343 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
344 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
345 evas_object_layer_set(btn, 32000);
346 evas_object_propagate_events_set(btn, EINA_FALSE);
347 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
351 } else if (!strcmp(part, "base")) {
352 Evas_Object* btn = elm_button_add(obj);
353 elm_object_style_set(btn, "ime_transparent");
359 static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
361 if(!strcmp(part, "elm.text")) {
369 reply = input_smartreply_get_nth_item(index);
373 /* Set hightlight color on first 3 smartreply items */
375 char *colored = _genlist_text_set_theme_color(reply, "AT0113");
377 if (colored == NULL) {
390 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
392 if(!strcmp(part, "elm.text")) {
393 unsigned int index = (unsigned int)data;
394 const std::vector<TemplateData> template_list = input_template_get_list();
396 if(index < template_list.size()) {
397 if(template_list[index].use_gettext) {
398 return strdup(gettext(template_list[index].text.c_str()));
400 Eina_Strbuf *buf = NULL;
401 const char *str = NULL;
404 buf = eina_strbuf_new();
406 eina_strbuf_append(buf, template_list[index].text.c_str());
407 eina_strbuf_replace_all(buf, "\n", "");
408 eina_strbuf_replace_all(buf, "\r", "");
410 str = eina_strbuf_string_get(buf);
413 markup = elm_entry_utf8_to_markup(str);
415 eina_strbuf_free(buf);
425 static char * __ise_addtemplate_gl_text_get(void *data, Evas_Object *obj, const char *part)
427 if(!strcmp(part, "elm.text")) {
428 return(strdup(gettext("WDS_IME_MBODY_ADD_TEMPLATE_ABB")));
433 static Evas_Object * __ise_gl_1button_content_get(void *data, Evas_Object *obj, const char *part)
435 if (!strcmp(part, "elm.icon")) {
436 Evas_Object* btn = elm_button_add(obj);
437 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
438 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
439 Evas_Object* ic = elm_image_add(btn);
440 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
441 string path = get_resource_path();
442 elm_object_style_set(btn, "ime_button_template");
443 string path_ic = path + "/images/w_list_add_ic.png";
444 elm_image_file_set(ic, path_ic.c_str(), NULL);
445 elm_object_content_set(btn, ic);
446 evas_object_layer_set(btn, 32000);
453 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
455 //Update genlist items. The Item texts will be translated in the _gl_text_get().
456 elm_genlist_realized_items_update(obj);
459 static int _app_control_request_transient_app_cb(void *data)
465 static char *_genlist_text_set_theme_color(const char *str, const char *code)
468 Eina_Strbuf *buf = NULL;
469 char *colored = NULL;
474 buf = eina_strbuf_new();
476 PRINTFUNC(DLOG_ERROR, "Can not get create strbuf");
480 // ea_theme_color_get(code,
482 // NULL, NULL, NULL, NULL,
483 // NULL, NULL, NULL, NULL);
485 eina_strbuf_append_printf(buf, "<color=#%02x%02x%02x%02x>%s</color>",
488 colored = eina_strbuf_string_steal(buf);
490 eina_strbuf_free(buf);
496 static void _app_control_send_reply_cb(app_control_h request, app_control_h reply,
497 app_control_result_e result, void *user_data)
499 PRINTFUNC(DLOG_DEBUG, "");
500 reply_to_sender_by_callback(NULL, NULL);
504 void set_source_caller_app_id(app_control_h app_control)
507 PRINTFUNC(DLOG_ERROR, "can't get app_control");
512 app_control_get_caller(app_data->source_app_control, &caller);
515 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
516 app_control_add_extra_data(app_control, "caller_appid", caller);
521 void reply_to_sender_by_appcontrol(void *data, const char *value, const char *type)
523 PRINTFUNC(DLOG_DEBUG, "");
528 app_control_h app_control;
530 App_Data *appdata = (App_Data *)data;
533 PRINTFUNC(DLOG_ERROR, "Null pointer");
537 ret = app_control_create(&app_control);
538 if (ret != APP_CONTROL_ERROR_NONE) {
539 PRINTFUNC(DLOG_ERROR, "Can not create app_control : %d", ret);
543 app_id = g_input_keyboard_data.app_id;
544 if (app_id == NULL) {
545 PRINTFUNC(DLOG_INFO, "app id is undefined, use defualt");
546 app_id = "com.samsung.message.appcontrol.compose";
549 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose")){
550 app_id = "com.samsung.msg-send";
553 app_control_set_app_id(app_control, app_id);
554 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
556 ret = app_control_set_window(app_control,
557 elm_win_xwindow_get(appdata->win_main));
558 if (ret != APP_CONTROL_ERROR_NONE) {
559 PRINTFUNC(DLOG_ERROR, "Can not app control set window : %d", ret);
560 app_control_destroy(app_control);
564 if (g_input_keyboard_data.data_array && g_input_keyboard_data.data_array_len > 0) {
565 app_control_add_extra_data_array(app_control,
566 "selector_keyboard_data_array",
567 (const char**)(g_input_keyboard_data.data_array),
568 g_input_keyboard_data.data_array_len);
571 app_control_add_extra_data(app_control, "selector_send_data_array", "sending_popup");
574 app_control_add_extra_data(app_control, "selected_context", value);
577 app_control_add_extra_data(app_control, "reply_type", type);
579 set_source_caller_app_id(app_control);
581 ret = app_control_send_launch_request(app_control,
582 _app_control_send_reply_cb,
585 if (ret != APP_CONTROL_ERROR_NONE)
586 PRINTFUNC(DLOG_ERROR, "Can not launch app_control: %d", ret);
588 app_control_destroy(app_control);
593 void reply_to_sender_by_callback(const char *value, const char *type)
595 PRINTFUNC(DLOG_DEBUG, "");
597 app_control_h app_control;
599 if(app_control_create(&app_control) == 0) {
603 app_control_add_extra_data(app_control, "selected_context", value);
606 app_control_add_extra_data(app_control, "reply_type", type);
608 set_source_caller_app_id(app_control);
610 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
611 if (ret != APP_CONTROL_ERROR_NONE)
612 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
614 app_control_destroy(app_control);
615 app_control_destroy(app_data->source_app_control);
616 app_data->source_app_control = NULL;
620 void reply_to_sender_by_callback_for_back()
622 PRINTFUNC(DLOG_DEBUG, "");
624 app_control_h app_control;
626 if(app_control_create(&app_control) == 0) {
629 app_control_add_extra_data(app_control, "back_to_composer", "yes");
631 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
632 if (ret != APP_CONTROL_ERROR_NONE)
633 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
635 app_control_destroy(app_control);
636 app_control_destroy(app_data->source_app_control);
637 app_data->source_app_control = NULL;
641 char* get_resource_path()
643 if(NULL == app_data->res_path) {
644 app_data->res_path = app_get_resource_path();
645 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
647 return (app_data->res_path);
650 char* get_shared_resource_path()
652 if(NULL == app_data->shared_res_path) {
653 app_data->shared_res_path = app_get_shared_resource_path();
654 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
656 return (app_data->shared_res_path);
659 void show_gl_focus(Eina_Bool bVisible){
660 if(app_data->genlist == NULL)
663 if(bVisible == EINA_TRUE){
664 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
665 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
666 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
668 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
669 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
670 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
674 void show_popup_toast(const char *text, bool check_img)
676 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
680 popup = elm_popup_add(app_data->win_main);
681 elm_object_style_set(popup, "toast/circle");
682 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
683 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
686 string path = get_resource_path();
687 string path_ic = path + "/images/toast_check_icon.png";
688 Evas_Object * img = elm_image_add(popup);
689 elm_image_file_set(img, path_ic.c_str(), NULL);
690 elm_object_part_content_set(popup, "toast,icon", img);
693 elm_object_part_text_set(popup, "elm.text", text);
696 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
697 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
698 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
700 elm_popup_timeout_set(popup, 2.0);
701 evas_object_show(popup);
704 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
707 evas_object_hide(obj);
708 evas_object_del(obj);
712 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
715 elm_popup_dismiss(obj);
719 void _back_to_genlist_for_selector()
721 PRINTFUNC(DLOG_DEBUG, "");
723 if(!app_data) return;
725 if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
726 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
727 reply_to_sender_by_callback(NULL, NULL);
731 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
733 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
736 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
738 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
741 Evas_Object* _create_genlist(Evas_Object* navi)
743 Evas_Object* genlist = elm_genlist_add(navi);
747 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
748 elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
750 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
751 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
752 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
753 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
755 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
756 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
758 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
759 evas_object_show(genlist);
761 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
763 show_gl_focus(EINA_FALSE);
765 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
772 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
773 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
778 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
783 Evas_Object *genlist = (Evas_Object *)obj;
784 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
787 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
789 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
791 if (250 > y && y >= 100){
792 if (last_step == 0) return;
794 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
795 show_gl_focus(EINA_TRUE);
796 } else if (100 > y && y >= 50){
797 if (last_step == 1) return;
799 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
800 show_gl_focus(EINA_TRUE);
801 } else if (y < 50 && y >=0){
802 if (last_step == 2) return;
804 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
805 show_gl_focus(EINA_FALSE);
810 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
814 snprintf(buf, 1023, "%s", "Select method");
818 void _create_genlist_items(void* user_data, bool is_type_reply)
820 LOGD("[psw] _create_genlist_items");
822 App_Data* app_data = (App_Data*) user_data;
824 if(NULL == app_data->genlist) {
825 app_data->genlist = _create_genlist(app_data->naviframe);
826 if(NULL == app_data->genlist)
830 elm_genlist_clear(app_data->genlist);
831 g_smartreply_current_number = 0; /* reset previous smartreply size to 0 */
833 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
834 itc0->item_style = "title";
835 itc0->func.text_get = _main_menu_title_text_get;
836 itc0->func.content_get = NULL;
837 itc0->func.state_get = NULL;
838 itc0->func.del = NULL;
840 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
841 itc1->item_style = "3button";
842 itc1->func.text_get = NULL;
843 itc1->func.content_get = __ise_gl_3button_content_get;
844 itc1->func.state_get = NULL;
845 itc1->func.del = NULL;
848 // dummy title for empty space
849 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
851 ELM_GENLIST_ITEM_NONE,
854 if (!is_type_reply) {
856 it_title = elm_genlist_item_append(app_data->genlist, itc1,
858 ELM_GENLIST_ITEM_NONE,
861 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
863 if (input_smartreply_is_enabled() == false) {
864 _update_template_items(app_data);
865 if(g_template_current_number > 0) {
866 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
867 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
868 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
871 // dummy title for bottom
872 Elm_Object_Item *dummy;
874 dummy = elm_genlist_item_append(app_data->genlist, itc0,
876 ELM_GENLIST_ITEM_NONE,
879 elm_genlist_item_select_mode_set(dummy, ELM_OBJECT_SELECT_MODE_NONE);
883 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
884 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
886 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
888 elm_genlist_item_class_free(itc0);
889 elm_genlist_item_class_free(itc1);
892 void _update_genlist_items(void *user_data)
896 if (input_smartreply_is_enabled())
897 len = input_smartreply_get_reply_num();
899 if (g_smartreply_current_number != len)
900 _update_smartreply_items(user_data);
902 _update_template_items(user_data);
904 g_smartreply_current_number = len;
906 if (g_smartreply_current_number > 0 || g_template_current_number > 0) {
907 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
908 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
909 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
913 void _update_smartreply_items(void *user_data)
917 Elm_Object_Item *first;
918 Elm_Object_Item *menu;
919 Elm_Object_Item *pos;
924 app_data = (App_Data *)user_data;
926 if (app_data == NULL) {
927 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
931 if (app_data->genlist == NULL) {
932 /* smartreply will update when genlist is exist only */
933 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
937 if (input_smartreply_is_enabled())
938 len = input_smartreply_get_reply_num();
940 if (g_smartreply_current_number == len)
943 first = elm_genlist_first_item_get(app_data->genlist);
944 menu = elm_genlist_item_next_get(first);
946 /* Remove current smartreply list */
947 pos = elm_genlist_item_next_get(menu);
948 for (i = 0; i < g_smartreply_current_number; i++) {
949 Elm_Object_Item *next;
954 next = elm_genlist_item_next_get(pos);
955 elm_object_item_del(pos);
959 /* Append newly added smartreply list */
961 Elm_Genlist_Item_Class *itc;
963 itc = elm_genlist_item_class_new();
965 itc->item_style = "1text";
966 itc->func.text_get = __ise_smartreply_gl_text_get;
967 itc->func.content_get = NULL;
968 itc->func.state_get = NULL;
969 itc->func.del = NULL;
972 for (i = 0; i < len; i++) {
973 pos = elm_genlist_item_insert_after(app_data->genlist,
978 ELM_GENLIST_ITEM_NONE,
979 __ise_smartreply_gl_sel,
984 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
986 elm_genlist_item_class_free(itc);
989 g_smartreply_current_number = len;
993 void _update_template_items(void *user_data)
997 Elm_Object_Item *first;
998 Elm_Object_Item *menu;
999 Elm_Object_Item *pos;
1000 Elm_Object_Item *template_pos;
1002 unsigned int template_len = 0;
1005 app_data = (App_Data *)user_data;
1007 if (app_data == NULL) {
1008 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1012 if (app_data->genlist == NULL) {
1013 /* smartreply will update when genlist is exist only */
1014 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1018 if (app_data->app_type == APP_TYPE_REPLY) {
1019 menu = elm_genlist_first_item_get(app_data->genlist);
1021 first = elm_genlist_first_item_get(app_data->genlist);
1022 menu = elm_genlist_item_next_get(first);
1026 /* move to smartreply next if it need */
1027 if (input_smartreply_is_enabled()) {
1028 int smartreply_len = 0;
1030 smartreply_len = input_smartreply_get_reply_num();
1031 if (smartreply_len > 0) {
1034 for (j = 0; j < smartreply_len; j++) {
1038 pos = elm_genlist_item_next_get(pos);
1043 /* Remove Current template list */
1044 template_pos = elm_genlist_item_next_get(pos);
1045 for (i = 0 ; i < g_template_current_number; i++) {
1046 Elm_Object_Item *next;
1048 if (template_pos == NULL) {
1049 PRINTFUNC(DLOG_ERROR, "Template mismatched, iter : %d, current num: %d",
1050 i, g_template_current_number);
1054 next = elm_genlist_item_next_get(template_pos);
1055 elm_object_item_del(template_pos);
1056 template_pos = next;
1059 /* Remove Add or dummpy button */
1061 Elm_Object_Item *next;
1063 next = elm_genlist_item_next_get(template_pos);
1064 elm_object_item_del(template_pos);
1065 template_pos = next;
1068 /* Append New Template list */
1069 const std::vector<TemplateData> template_list = input_template_get_list();
1072 if (template_list.size() > 0) {
1073 Elm_Genlist_Item_Class *itc;
1075 itc = elm_genlist_item_class_new();
1077 itc->item_style = "1text";
1078 itc->func.text_get = __ise_template_gl_text_get;
1079 itc->func.content_get = NULL;
1080 itc->func.state_get = NULL;
1081 itc->func.del = NULL;
1083 for (i = 0; i < template_list.size(); i++) {
1084 bool matched = false;
1086 if(!template_list[i].use_gettext) {
1087 int smartreply_len = 0;
1090 smartreply_len = input_smartreply_get_reply_num();
1091 for (j = 0; j < smartreply_len; j++) {
1094 reply = input_smartreply_get_nth_item(j);
1096 if (!strcmp(reply, template_list[i].text.c_str())) {
1106 if (matched == false) {
1107 pos = elm_genlist_item_insert_after(app_data->genlist,
1112 ELM_GENLIST_ITEM_NONE,
1113 __ise_template_gl_sel,
1119 elm_genlist_item_class_free(itc);
1123 // template add button (+)
1124 /* if (!input_template_is_user_template()) {
1125 Elm_Genlist_Item_Class *itc;
1127 itc = elm_genlist_item_class_new();
1129 itc->item_style = "1text.1icon";
1130 itc->func.text_get = __ise_addtemplate_gl_text_get;;
1131 itc->func.content_get = __ise_gl_1button_content_get;
1132 itc->func.state_get = NULL;
1133 itc->func.del = NULL;
1136 pos = elm_genlist_item_insert_after(app_data->genlist,
1141 ELM_GENLIST_ITEM_NONE,
1142 __ise_template_add_gl_sel,
1145 elm_genlist_item_class_free(itc);
1149 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1151 g_template_current_number = template_len;
1155 bool _app_create(void* user_data)
1157 int width = 1000, height = 1000;
1158 // App_Data* app_data = NULL;
1159 Evas_Object* layout = NULL;
1160 Evas_Object* conform = NULL;
1161 Evas_Object* bg = NULL;
1162 Evas_Object* window = NULL;
1163 Eext_Circle_Surface *surface;
1169 _app_language_changed(NULL, NULL);
1171 app_data = (App_Data*)user_data;
1173 elm_app_base_scale_set(1.3);
1175 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1177 init_customizing_theme();
1179 elm_win_title_set(window, PACKAGE);
1180 elm_win_borderless_set(window, EINA_TRUE);
1181 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1182 evas_object_resize(window, width, height);
1183 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1185 LOGE("elm_win_add() is failed.");
1189 bg = elm_bg_add(window);
1190 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1191 elm_win_resize_object_add(window, bg);
1192 evas_object_show(bg);
1194 layout = elm_layout_add(window);
1195 elm_layout_theme_set(layout, "layout", "application", "default");
1196 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1198 conform = elm_conformant_add(window);
1199 surface = eext_circle_surface_conformant_add(conform);
1200 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1203 elm_win_resize_object_add(window, conform);
1204 elm_object_content_set(conform, layout);
1206 evas_object_show(layout);
1207 evas_object_show(conform);
1208 evas_object_show(window);
1209 app_data->win_main = window;
1210 app_data->conform = conform;
1211 app_data->layout_main = layout;
1212 app_data->circle_surface = surface;
1213 app_data->app_type = APP_TYPE_SELECT_MODE;
1215 Evas_Object *naviframe = elm_naviframe_add(layout);
1216 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1217 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1218 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1219 evas_object_show(naviframe);
1221 app_data->naviframe = naviframe;
1226 void _app_service(app_control_h service, void* user_data)
1230 char *context = NULL;
1231 char *app_id = NULL;
1233 app_control_clone(&(app_data->source_app_control), service);
1235 app_data->reply_type = REPLY_APP_NORMAL;
1236 ret = app_control_get_extra_data(service, "selector_keyboard_app_id", &app_id);
1237 if (ret == APP_CONTROL_ERROR_NONE) {
1238 PRINTFUNC(DLOG_DEBUG, "app_id = %s", app_id);
1242 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose") || !strcmp(app_id, "com.samsung.wemail-send")) {
1243 app_data->reply_type = REPLY_APP_CONTROL;
1245 app_data->reply_type = REPLY_APP_NORMAL;
1251 bool is_type_reply = false;
1252 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1253 if (ret == APP_CONTROL_ERROR_NONE) {
1254 if (!strcmp(context, "input_voice")) {
1255 app_data->app_type = APP_TYPE_STT;
1256 _stt_clicked_cb((void *)app_data, NULL, NULL);
1258 } else if (!strcmp(context, "input_emoticon")) {
1259 app_data->app_type = APP_TYPE_EMOTICON;
1260 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1262 } else if (!strcmp(context, "input_keyboard")) {
1263 app_data->app_type = APP_TYPE_KEYBOARD;
1264 input_keyboard_init(service);
1265 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1267 } else if (!strcmp(context, "keyboard_input_from_sms")) {
1268 app_data->app_type = APP_TYPE_KEYBOARD_FROM_SMS;
1269 input_keyboard_init(service);
1270 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1272 } else if (!strcmp(context, "input_reply")) {
1273 app_data->app_type = APP_TYPE_REPLY;
1274 is_type_reply = true;
1278 if (app_data->genlist == NULL)
1279 app_data->genlist = _create_genlist(app_data->naviframe);
1281 input_keyboard_init(service);
1283 // input_smartreply_init(service);
1284 // input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1286 // if (input_smartreply_is_enabled())
1287 // input_smartreply_get_reply_async();
1290 input_template_init(service);
1291 input_template_set_notify(_input_template_notify_cb, NULL);
1293 _create_genlist_items(app_data, is_type_reply);
1296 elm_win_activate(app_data->win_main);
1298 // app_control_request_transient_app(service, elm_win_xwindow_get(app_data->win_main), _app_control_request_transient_app_cb, NULL);
1304 void _app_pause(void* user_data)
1306 PRINTFUNC(DLOG_DEBUG, "");
1310 void _app_resume(void* user_data)
1312 PRINTFUNC(DLOG_DEBUG, "");
1315 void _app_terminate(void* user_data)
1317 App_Data* app_data = NULL;
1318 app_data = (App_Data*)user_data;
1320 if(app_data->genlist){
1321 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1324 if(app_data->res_path)
1325 free(app_data->res_path);
1327 if(app_data->shared_res_path)
1328 free(app_data->shared_res_path);
1330 input_keyboard_deinit();
1331 input_smartreply_deinit();
1333 input_template_unset_notify();
1334 input_template_deinit();
1337 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1339 if (setlocale(LC_ALL, "") == NULL) {
1340 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1341 if (setlocale(LC_ALL, lang_str) == NULL)
1344 if (bindtextdomain(domain, dir) == NULL)
1346 if (textdomain(domain) == NULL)
1353 * @brief Set language and locale.
1357 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1359 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1361 setenv("LANG", lang_str, 1);
1362 setenv("LC_MESSAGES", lang_str, 1);
1364 setenv("LANG", "en_GB.utf8", 1);
1365 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1366 lang_str = strdup("en_GB.UTF-8");
1369 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1372 elm_language_set(lang_str);
1379 int main(int argc, char* argv[])
1381 App_Data app_data = {0, };
1382 ui_app_lifecycle_callback_s event_callback = {0, };
1383 app_event_handler_h handlers[5] = {NULL, };
1385 event_callback.create = _app_create;
1386 event_callback.terminate = _app_terminate;
1387 event_callback.pause = _app_pause;
1388 event_callback.resume = _app_resume;
1389 event_callback.app_control = _app_service;
1391 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1392 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1393 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1394 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1395 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1397 _init_app_data(&app_data);
1399 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1400 if (ret != APP_ERROR_NONE) {
1401 LOGD("ui_app_main() is failed. err = %d", ret);