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);
70 char * _toast_delete_popup_access_info_cb(void *data, Evas_Object *obj);
74 void _init_app_data(App_Data* app_data)
76 app_data->win_main = NULL;
77 app_data->layout_main = NULL;
78 app_data->conform = NULL;
79 app_data->naviframe = NULL;
80 app_data->genlist = NULL;
82 app_data->res_path = NULL;
87 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
93 window = elm_layout_add(parent);
95 ret = elm_layout_file_set(window, file, group);
97 evas_object_del(window);
101 content = elm_layout_add(parent);
102 elm_layout_theme_set(content, "layout", "application", "default");
103 elm_object_part_content_set(window, "elm.swallow.content", content);
105 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
111 void init_customizing_theme(void)
113 string stt_edj_path = get_resource_path();
114 string app_edj_path = get_resource_path();
116 stt_edj_path = stt_edj_path + STT_EDJ_FILE;
117 app_edj_path = app_edj_path + APP_EDJ_FILE;
119 elm_theme_extension_add(NULL, stt_edj_path.c_str());
120 elm_theme_extension_add(NULL, app_edj_path.c_str());
124 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
126 reply_to_sender_by_callback_for_back();
131 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
133 App_Data* ad = (App_Data*)data;
135 PRINTFUNC(DLOG_DEBUG, "");
141 bool bAgreed = false;
142 stt_get_user_agreement(&bAgreed);
145 if(is_tos_N66_agreed() == EINA_FALSE){
146 if(is_sap_connection() == EINA_TRUE){
147 ise_show_tos_n66_popup(ad);
149 launch_bt_connection_popup(ad);
152 ise_show_stt_popup(ad);
156 static void _input_smartreply_notify_cb(void *user_data)
158 ecore_main_loop_iterate();
159 _update_genlist_items((void *)app_data);
162 static void _input_template_notify_cb(void *user_data)
164 _update_genlist_items((void *)app_data);
168 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
170 App_Data* ad = (App_Data*)data;
172 PRINTFUNC(DLOG_DEBUG, "");
177 // ise_show_emoticon_popup(ad);
178 ise_show_emoticon_popup_rotary(ad);
181 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
183 App_Data* ad = (App_Data *)data;
185 PRINTFUNC(DLOG_DEBUG, "");
190 if (app_data->app_type == APP_TYPE_KEYBOARD_FROM_SMS)
191 input_keyboard_launch(ad->win_main);
193 input_keyboard_launch_with_ui(ad->win_main, data);
196 static void __bt_connection_result_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
201 PRINTFUNC(DLOG_ERROR, "service_h is NULL");
205 app_control_get_extra_data(reply, "__BT_CONNECTION__", &val);
207 if ( strcmp(val, "Connected") == 0 ) {
208 PRINTFUNC(DLOG_ERROR, "BT Connected");
210 PRINTFUNC(DLOG_ERROR, "BT Not Connected");
218 static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
220 App_Data* app_data = (App_Data*) data;
221 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
224 elm_genlist_item_selected_set(item, EINA_FALSE);
226 int index = (unsigned int) elm_object_item_data_get(item);
228 char *reply = input_smartreply_get_nth_item(index);
230 input_smartreply_send_feedback(reply);
231 if(app_data->reply_type == REPLY_APP_CONTROL){
232 reply_to_sender_by_appcontrol((void*)app_data, reply, "smartreply");
235 reply_to_sender_by_callback(reply, "smartreply");
243 static void __ise_template_add_gl_sel(void *data, Evas_Object *obj, void *event_info)
245 App_Data* app_data = (App_Data*) data;
246 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
249 elm_genlist_item_selected_set(item, EINA_FALSE);
251 if(is_sap_connection() == EINA_TRUE){
253 show_popup_toast(gettext("WDS_IME_TPOP_ADD_TEMPLATE_ON_YOUR_PHONE_ABB"), true);
255 // send message to Host
256 app_control_h appctrl;
257 app_control_create(&appctrl);
258 app_control_set_app_id(appctrl, "com.samsung.w-manager-service");
259 app_control_add_extra_data(appctrl, "type", "gm_setting");
260 app_control_add_extra_data(appctrl, "data/setting_menu", "texttemplate_setting");
261 app_control_send_launch_request(appctrl, NULL, NULL);
262 app_control_destroy(appctrl);
264 app_control_h app_control;
265 app_control_create(&app_control);
266 app_control_set_app_id(app_control, "com.samsung.bt-connection-popup");
267 app_control_add_extra_data(app_control, "msg", "perform");
268 app_control_send_launch_request(app_control, __bt_connection_result_cb, NULL);
269 app_control_destroy(app_control);
274 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
276 App_Data* app_data = (App_Data*) data;
277 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
281 elm_genlist_item_selected_set(item, EINA_FALSE);
283 index = (unsigned int) elm_object_item_data_get(item);
284 const std::vector<TemplateData> template_list = input_template_get_list();
286 //@ToDo : should call reply function when any template string is selected and confirmed.
287 // Here reply string will be template_list[index].text.c_str();
288 if( index < template_list.size()) {
289 if(app_data->reply_type == REPLY_APP_CONTROL){
290 reply_to_sender_by_appcontrol((void*)app_data, gettext(template_list[index].text.c_str()), "template");
292 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
299 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
301 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
302 Evas_Object* btn = elm_button_add(obj);
303 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
304 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
305 Evas_Object* ic = elm_image_add(btn);
306 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
307 string path = get_resource_path();
308 if (!strcmp(part, "elm.icon.1")) {
309 elm_object_style_set(btn, "anchor");
310 string path_ic = path + "images/w_mode_stt_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);
315 } else if (!strcmp(part, "elm.icon.2")){
316 elm_object_style_set(btn, "anchor");
317 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
318 elm_image_file_set(ic, path_ic.c_str(), NULL);
319 elm_object_content_set(btn, ic);
320 evas_object_layer_set(btn, 32000);
322 } else if (!strcmp(part, "elm.icon.3")){
323 elm_object_style_set(btn, "anchor");
324 string path_ic = path + "images/w_mode_keyboard_ic.png";
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 evas_object_propagate_events_set(btn, EINA_FALSE);
332 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
333 Evas_Object* btn = elm_button_add(obj);
334 elm_object_style_set(btn, "touch_area");
335 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
336 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
337 string path = get_resource_path();
338 if (!strcmp(part, "elm.icon.1.touch_area")) {
339 evas_object_layer_set(btn, 32000);
340 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
342 } else if (!strcmp(part, "elm.icon.2.touch_area")){
343 evas_object_layer_set(btn, 32000);
344 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
345 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
346 evas_object_layer_set(btn, 32000);
347 evas_object_propagate_events_set(btn, EINA_FALSE);
348 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
352 } else if (!strcmp(part, "base")) {
353 Evas_Object* btn = elm_button_add(obj);
354 elm_object_style_set(btn, "ime_transparent");
360 static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
362 if(!strcmp(part, "elm.text")) {
370 reply = input_smartreply_get_nth_item(index);
374 /* Set hightlight color on first 3 smartreply items */
376 char *colored = _genlist_text_set_theme_color(reply, "AT0113");
378 if (colored == NULL) {
391 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
393 if(!strcmp(part, "elm.text")) {
394 unsigned int index = (unsigned int)data;
395 const std::vector<TemplateData> template_list = input_template_get_list();
397 if(index < template_list.size()) {
398 if(template_list[index].use_gettext) {
399 return strdup(gettext(template_list[index].text.c_str()));
401 Eina_Strbuf *buf = NULL;
402 const char *str = NULL;
405 buf = eina_strbuf_new();
407 eina_strbuf_append(buf, template_list[index].text.c_str());
408 eina_strbuf_replace_all(buf, "\n", "");
409 eina_strbuf_replace_all(buf, "\r", "");
411 str = eina_strbuf_string_get(buf);
414 markup = elm_entry_utf8_to_markup(str);
416 eina_strbuf_free(buf);
426 static char * __ise_addtemplate_gl_text_get(void *data, Evas_Object *obj, const char *part)
428 if(!strcmp(part, "elm.text")) {
429 return(strdup(gettext("WDS_IME_MBODY_ADD_TEMPLATE_ABB")));
434 static Evas_Object * __ise_gl_1button_content_get(void *data, Evas_Object *obj, const char *part)
436 if (!strcmp(part, "elm.icon")) {
437 Evas_Object* btn = elm_button_add(obj);
438 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
439 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
440 Evas_Object* ic = elm_image_add(btn);
441 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
442 string path = get_resource_path();
443 elm_object_style_set(btn, "ime_button_template");
444 string path_ic = path + "/images/w_list_add_ic.png";
445 elm_image_file_set(ic, path_ic.c_str(), NULL);
446 elm_object_content_set(btn, ic);
447 evas_object_layer_set(btn, 32000);
454 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
456 //Update genlist items. The Item texts will be translated in the _gl_text_get().
457 elm_genlist_realized_items_update(obj);
460 static int _app_control_request_transient_app_cb(void *data)
466 static char *_genlist_text_set_theme_color(const char *str, const char *code)
469 Eina_Strbuf *buf = NULL;
470 char *colored = NULL;
475 buf = eina_strbuf_new();
477 PRINTFUNC(DLOG_ERROR, "Can not get create strbuf");
481 // ea_theme_color_get(code,
483 // NULL, NULL, NULL, NULL,
484 // NULL, NULL, NULL, NULL);
486 eina_strbuf_append_printf(buf, "<color=#%02x%02x%02x%02x>%s</color>",
489 colored = eina_strbuf_string_steal(buf);
491 eina_strbuf_free(buf);
497 static void _app_control_send_reply_cb(app_control_h request, app_control_h reply,
498 app_control_result_e result, void *user_data)
500 PRINTFUNC(DLOG_DEBUG, "");
501 reply_to_sender_by_callback(NULL, NULL);
505 void set_source_caller_app_id(app_control_h app_control)
508 PRINTFUNC(DLOG_ERROR, "can't get app_control");
513 app_control_get_caller(app_data->source_app_control, &caller);
516 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
517 app_control_add_extra_data(app_control, "caller_appid", caller);
522 void reply_to_sender_by_appcontrol(void *data, const char *value, const char *type)
524 PRINTFUNC(DLOG_DEBUG, "");
529 app_control_h app_control;
531 App_Data *appdata = (App_Data *)data;
534 PRINTFUNC(DLOG_ERROR, "Null pointer");
538 ret = app_control_create(&app_control);
539 if (ret != APP_CONTROL_ERROR_NONE) {
540 PRINTFUNC(DLOG_ERROR, "Can not create app_control : %d", ret);
544 app_id = g_input_keyboard_data.app_id;
545 if (app_id == NULL) {
546 PRINTFUNC(DLOG_INFO, "app id is undefined, use defualt");
547 app_id = "com.samsung.message.appcontrol.compose";
550 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose")){
551 app_id = "com.samsung.msg-send";
554 app_control_set_app_id(app_control, app_id);
555 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
557 ret = app_control_set_window(app_control,
558 elm_win_xwindow_get(appdata->win_main));
559 if (ret != APP_CONTROL_ERROR_NONE) {
560 PRINTFUNC(DLOG_ERROR, "Can not app control set window : %d", ret);
561 app_control_destroy(app_control);
565 if (g_input_keyboard_data.data_array && g_input_keyboard_data.data_array_len > 0) {
566 app_control_add_extra_data_array(app_control,
567 "selector_keyboard_data_array",
568 (const char**)(g_input_keyboard_data.data_array),
569 g_input_keyboard_data.data_array_len);
572 app_control_add_extra_data(app_control, "selector_send_data_array", "sending_popup");
575 app_control_add_extra_data(app_control, "selected_context", value);
578 app_control_add_extra_data(app_control, "reply_type", type);
580 set_source_caller_app_id(app_control);
582 ret = app_control_send_launch_request(app_control,
583 _app_control_send_reply_cb,
586 if (ret != APP_CONTROL_ERROR_NONE)
587 PRINTFUNC(DLOG_ERROR, "Can not launch app_control: %d", ret);
589 app_control_destroy(app_control);
594 void reply_to_sender_by_callback(const char *value, const char *type)
596 PRINTFUNC(DLOG_DEBUG, "");
598 app_control_h app_control;
600 if(app_control_create(&app_control) == 0) {
604 app_control_add_extra_data(app_control, "selected_context", value);
607 app_control_add_extra_data(app_control, "reply_type", type);
609 set_source_caller_app_id(app_control);
611 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
612 if (ret != APP_CONTROL_ERROR_NONE)
613 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
615 app_control_destroy(app_control);
616 app_control_destroy(app_data->source_app_control);
617 app_data->source_app_control = NULL;
621 void reply_to_sender_by_callback_for_back()
623 PRINTFUNC(DLOG_DEBUG, "");
625 app_control_h app_control;
627 if(app_control_create(&app_control) == 0) {
630 app_control_add_extra_data(app_control, "back_to_composer", "yes");
632 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
633 if (ret != APP_CONTROL_ERROR_NONE)
634 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
636 app_control_destroy(app_control);
637 app_control_destroy(app_data->source_app_control);
638 app_data->source_app_control = NULL;
642 char* get_resource_path()
644 if(NULL == app_data->res_path) {
645 app_data->res_path = app_get_resource_path();
646 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
648 return (app_data->res_path);
651 char* get_shared_resource_path()
653 if(NULL == app_data->shared_res_path) {
654 app_data->shared_res_path = app_get_shared_resource_path();
655 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
657 return (app_data->shared_res_path);
660 void show_gl_focus(Eina_Bool bVisible){
661 if(app_data->genlist == NULL)
664 if(bVisible == EINA_TRUE){
665 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
666 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
667 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
669 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
670 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
671 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
675 void show_popup_toast(const char *text, bool check_img)
677 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
681 popup = elm_popup_add(app_data->win_main);
682 elm_object_style_set(popup, "toast/circle");
683 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
684 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
687 string path = get_resource_path();
688 string path_ic = path + "/images/toast_check_icon.png";
689 Evas_Object * img = elm_image_add(popup);
690 elm_image_file_set(img, path_ic.c_str(), NULL);
691 elm_object_part_content_set(popup, "toast,icon", img);
694 elm_object_part_text_set(popup, "elm.text", text);
697 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
698 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
699 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
701 elm_popup_timeout_set(popup, 2.0);
702 evas_object_show(popup);
705 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
708 evas_object_hide(obj);
709 evas_object_del(obj);
713 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
716 elm_popup_dismiss(obj);
719 char * _toast_delete_popup_access_info_cb(void *data, Evas_Object *obj)
721 PRINTFUNC(DLOG_ERROR, "%s", __func__);
722 const char * info = elm_object_part_text_get((Evas_Object*)data, "elm.text");
728 void _back_to_genlist_for_selector()
730 PRINTFUNC(DLOG_DEBUG, "");
732 if(!app_data) return;
734 if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
735 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
736 reply_to_sender_by_callback(NULL, NULL);
740 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
742 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
746 char *_it_plus_access_info_cb(void *data, Evas_Object *obj)
748 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
749 std::string text = std::string(gettext("IDS_ACCS_BODY_BUTTON_TTS"));
751 return strdup(text.c_str());
754 char *_access_info_cb(void *data, Evas_Object *obj)
756 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
757 return strdup(gettext("WDS_TTS_TBBODY_DOUBLE_TAP_TO_SEND"));
760 Eina_Bool _access_action_next_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
762 Evas_Object *genlist = (Evas_Object*)data;
763 PRINTFUNC(DLOG_ERROR, "[TNT] _access_action_next_cb called, genlist type:%s", evas_object_type_get(genlist));
764 Elm_Object_Item *it = elm_genlist_first_item_get(genlist);//emptry item?
765 PRINTFUNC(DLOG_ERROR, "[TNT] get first item:%p", it);
766 it = elm_genlist_item_next_get(it);//title item(3 button?)
767 PRINTFUNC(DLOG_ERROR, "[TNT] get Second item:%p, title_item:%p", it, it_title);
768 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
769 force_highlight_to_top = EINA_TRUE;
773 Eina_Bool _access_action_prev_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
775 Evas_Object *genlist = (Evas_Object*)data;
776 PRINTFUNC(DLOG_ERROR, "[TNT] _access_action_prev_cb called, genlist type:%s", evas_object_type_get(genlist));
777 Elm_Object_Item *it = elm_genlist_last_item_get(genlist);//plus button item
778 PRINTFUNC(DLOG_ERROR, "[TNT] get last item:%p", it);
779 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
780 force_highlight_to_bottom = EINA_TRUE;
784 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
786 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
789 Evas_Object* _create_genlist(Evas_Object* navi)
791 Evas_Object* genlist = elm_genlist_add(navi);
795 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
796 elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
798 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
799 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
800 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
801 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
803 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
804 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
806 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
807 evas_object_show(genlist);
809 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
811 show_gl_focus(EINA_FALSE);
813 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
820 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
821 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
826 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
831 Evas_Object *genlist = (Evas_Object *)obj;
832 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
835 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
837 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
839 if (250 > y && y >= 100){
840 if (last_step == 0) return;
842 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
843 show_gl_focus(EINA_TRUE);
844 } else if (100 > y && y >= 50){
845 if (last_step == 1) return;
847 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
848 show_gl_focus(EINA_TRUE);
849 } else if (y < 50 && y >=0){
850 if (last_step == 2) return;
852 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
853 show_gl_focus(EINA_FALSE);
858 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
862 snprintf(buf, 1023, "%s", "Select method");
866 void _create_genlist_items(void* user_data, bool is_type_reply)
868 LOGD("[psw] _create_genlist_items");
870 App_Data* app_data = (App_Data*) user_data;
872 if(NULL == app_data->genlist) {
873 app_data->genlist = _create_genlist(app_data->naviframe);
874 if(NULL == app_data->genlist)
878 elm_genlist_clear(app_data->genlist);
879 g_smartreply_current_number = 0; /* reset previous smartreply size to 0 */
881 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
882 itc0->item_style = "title";
883 itc0->func.text_get = _main_menu_title_text_get;
884 itc0->func.content_get = NULL;
885 itc0->func.state_get = NULL;
886 itc0->func.del = NULL;
888 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
889 itc1->item_style = "3button";
890 itc1->func.text_get = NULL;
891 itc1->func.content_get = __ise_gl_3button_content_get;
892 itc1->func.state_get = NULL;
893 itc1->func.del = NULL;
896 // dummy title for empty space
897 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
899 ELM_GENLIST_ITEM_NONE,
902 if (!is_type_reply) {
904 it_title = elm_genlist_item_append(app_data->genlist, itc1,
906 ELM_GENLIST_ITEM_NONE,
909 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
911 if (input_smartreply_is_enabled() == false) {
912 _update_template_items(app_data);
913 if(g_template_current_number > 0) {
914 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
915 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
916 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
919 // dummy title for bottom
920 Elm_Object_Item *dummy;
922 dummy = elm_genlist_item_append(app_data->genlist, itc0,
924 ELM_GENLIST_ITEM_NONE,
927 elm_genlist_item_select_mode_set(dummy, ELM_OBJECT_SELECT_MODE_NONE);
931 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
932 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
934 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
936 elm_genlist_item_class_free(itc0);
937 elm_genlist_item_class_free(itc1);
940 void _update_genlist_items(void *user_data)
944 if (input_smartreply_is_enabled())
945 len = input_smartreply_get_reply_num();
947 if (g_smartreply_current_number != len)
948 _update_smartreply_items(user_data);
950 _update_template_items(user_data);
952 g_smartreply_current_number = len;
954 if (g_smartreply_current_number > 0 || g_template_current_number > 0) {
955 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
956 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
957 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
961 void _update_smartreply_items(void *user_data)
965 Elm_Object_Item *first;
966 Elm_Object_Item *menu;
967 Elm_Object_Item *pos;
972 app_data = (App_Data *)user_data;
974 if (app_data == NULL) {
975 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
979 if (app_data->genlist == NULL) {
980 /* smartreply will update when genlist is exist only */
981 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
985 if (input_smartreply_is_enabled())
986 len = input_smartreply_get_reply_num();
988 if (g_smartreply_current_number == len)
991 first = elm_genlist_first_item_get(app_data->genlist);
992 menu = elm_genlist_item_next_get(first);
994 /* Remove current smartreply list */
995 pos = elm_genlist_item_next_get(menu);
996 for (i = 0; i < g_smartreply_current_number; i++) {
997 Elm_Object_Item *next;
1002 next = elm_genlist_item_next_get(pos);
1003 elm_object_item_del(pos);
1007 /* Append newly added smartreply list */
1009 Elm_Genlist_Item_Class *itc;
1011 itc = elm_genlist_item_class_new();
1013 itc->item_style = "1text";
1014 itc->func.text_get = __ise_smartreply_gl_text_get;
1015 itc->func.content_get = NULL;
1016 itc->func.state_get = NULL;
1017 itc->func.del = NULL;
1020 for (i = 0; i < len; i++) {
1021 pos = elm_genlist_item_insert_after(app_data->genlist,
1026 ELM_GENLIST_ITEM_NONE,
1027 __ise_smartreply_gl_sel,
1032 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1034 elm_genlist_item_class_free(itc);
1037 g_smartreply_current_number = len;
1041 void _update_template_items(void *user_data)
1045 Elm_Object_Item *first;
1046 Elm_Object_Item *menu;
1047 Elm_Object_Item *pos;
1048 Elm_Object_Item *template_pos;
1050 unsigned int template_len = 0;
1053 app_data = (App_Data *)user_data;
1055 if (app_data == NULL) {
1056 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1060 if (app_data->genlist == NULL) {
1061 /* smartreply will update when genlist is exist only */
1062 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1066 if (app_data->app_type == APP_TYPE_REPLY) {
1067 menu = elm_genlist_first_item_get(app_data->genlist);
1069 first = elm_genlist_first_item_get(app_data->genlist);
1070 menu = elm_genlist_item_next_get(first);
1074 /* move to smartreply next if it need */
1075 if (input_smartreply_is_enabled()) {
1076 int smartreply_len = 0;
1078 smartreply_len = input_smartreply_get_reply_num();
1079 if (smartreply_len > 0) {
1082 for (j = 0; j < smartreply_len; j++) {
1086 pos = elm_genlist_item_next_get(pos);
1091 /* Remove Current template list */
1092 template_pos = elm_genlist_item_next_get(pos);
1093 for (i = 0 ; i < g_template_current_number; i++) {
1094 Elm_Object_Item *next;
1096 if (template_pos == NULL) {
1097 PRINTFUNC(DLOG_ERROR, "Template mismatched, iter : %d, current num: %d",
1098 i, g_template_current_number);
1102 next = elm_genlist_item_next_get(template_pos);
1103 elm_object_item_del(template_pos);
1104 template_pos = next;
1107 /* Remove Add or dummpy button */
1109 Elm_Object_Item *next;
1111 next = elm_genlist_item_next_get(template_pos);
1112 elm_object_item_del(template_pos);
1113 template_pos = next;
1116 /* Append New Template list */
1117 const std::vector<TemplateData> template_list = input_template_get_list();
1120 if (template_list.size() > 0) {
1121 Elm_Genlist_Item_Class *itc;
1123 itc = elm_genlist_item_class_new();
1125 itc->item_style = "1text";
1126 itc->func.text_get = __ise_template_gl_text_get;
1127 itc->func.content_get = NULL;
1128 itc->func.state_get = NULL;
1129 itc->func.del = NULL;
1131 for (i = 0; i < template_list.size(); i++) {
1132 bool matched = false;
1134 if(!template_list[i].use_gettext) {
1135 int smartreply_len = 0;
1138 smartreply_len = input_smartreply_get_reply_num();
1139 for (j = 0; j < smartreply_len; j++) {
1142 reply = input_smartreply_get_nth_item(j);
1144 if (!strcmp(reply, template_list[i].text.c_str())) {
1154 if (matched == false) {
1155 pos = elm_genlist_item_insert_after(app_data->genlist,
1160 ELM_GENLIST_ITEM_NONE,
1161 __ise_template_gl_sel,
1167 elm_genlist_item_class_free(itc);
1171 // template add button (+)
1172 /* if (!input_template_is_user_template()) {
1173 Elm_Genlist_Item_Class *itc;
1175 itc = elm_genlist_item_class_new();
1177 itc->item_style = "1text.1icon";
1178 itc->func.text_get = __ise_addtemplate_gl_text_get;;
1179 itc->func.content_get = __ise_gl_1button_content_get;
1180 itc->func.state_get = NULL;
1181 itc->func.del = NULL;
1184 pos = elm_genlist_item_insert_after(app_data->genlist,
1189 ELM_GENLIST_ITEM_NONE,
1190 __ise_template_add_gl_sel,
1193 elm_genlist_item_class_free(itc);
1197 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1199 g_template_current_number = template_len;
1203 bool _app_create(void* user_data)
1205 int width = 1000, height = 1000;
1206 // App_Data* app_data = NULL;
1207 Evas_Object* layout = NULL;
1208 Evas_Object* conform = NULL;
1209 Evas_Object* bg = NULL;
1210 Evas_Object* window = NULL;
1211 Eext_Circle_Surface *surface;
1217 _app_language_changed(NULL, NULL);
1219 app_data = (App_Data*)user_data;
1221 elm_app_base_scale_set(1.3);
1223 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1225 init_customizing_theme();
1227 elm_win_title_set(window, PACKAGE);
1228 elm_win_borderless_set(window, EINA_TRUE);
1229 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1230 evas_object_resize(window, width, height);
1231 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1233 LOGE("elm_win_add() is failed.");
1237 bg = elm_bg_add(window);
1238 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1239 elm_win_resize_object_add(window, bg);
1240 evas_object_show(bg);
1242 layout = elm_layout_add(window);
1243 elm_layout_theme_set(layout, "layout", "application", "default");
1244 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1246 conform = elm_conformant_add(window);
1247 surface = eext_circle_surface_conformant_add(conform);
1248 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1251 elm_win_resize_object_add(window, conform);
1252 elm_object_content_set(conform, layout);
1254 evas_object_show(layout);
1255 evas_object_show(conform);
1256 evas_object_show(window);
1257 app_data->win_main = window;
1258 app_data->conform = conform;
1259 app_data->layout_main = layout;
1260 app_data->circle_surface = surface;
1261 app_data->app_type = APP_TYPE_SELECT_MODE;
1263 Evas_Object *naviframe = elm_naviframe_add(layout);
1264 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1265 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1266 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1267 evas_object_show(naviframe);
1269 app_data->naviframe = naviframe;
1274 void _app_service(app_control_h service, void* user_data)
1278 char *context = NULL;
1279 char *app_id = NULL;
1281 app_control_clone(&(app_data->source_app_control), service);
1283 app_data->reply_type = REPLY_APP_NORMAL;
1284 ret = app_control_get_extra_data(service, "selector_keyboard_app_id", &app_id);
1285 if (ret == APP_CONTROL_ERROR_NONE) {
1286 PRINTFUNC(DLOG_DEBUG, "app_id = %s", app_id);
1290 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose") || !strcmp(app_id, "com.samsung.wemail-send")) {
1291 app_data->reply_type = REPLY_APP_CONTROL;
1293 app_data->reply_type = REPLY_APP_NORMAL;
1299 bool is_type_reply = false;
1300 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1301 if (ret == APP_CONTROL_ERROR_NONE) {
1302 if (!strcmp(context, "input_voice")) {
1303 app_data->app_type = APP_TYPE_STT;
1304 _stt_clicked_cb((void *)app_data, NULL, NULL);
1306 } else if (!strcmp(context, "input_emoticon")) {
1307 app_data->app_type = APP_TYPE_EMOTICON;
1308 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1310 } else if (!strcmp(context, "input_keyboard")) {
1311 app_data->app_type = APP_TYPE_KEYBOARD;
1312 input_keyboard_init(service);
1313 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1315 } else if (!strcmp(context, "keyboard_input_from_sms")) {
1316 app_data->app_type = APP_TYPE_KEYBOARD_FROM_SMS;
1317 input_keyboard_init(service);
1318 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1320 } else if (!strcmp(context, "input_reply")) {
1321 app_data->app_type = APP_TYPE_REPLY;
1322 is_type_reply = true;
1326 if (app_data->genlist == NULL)
1327 app_data->genlist = _create_genlist(app_data->naviframe);
1329 input_keyboard_init(service);
1331 // input_smartreply_init(service);
1332 // input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1334 // if (input_smartreply_is_enabled())
1335 // input_smartreply_get_reply_async();
1338 input_template_init(service);
1339 input_template_set_notify(_input_template_notify_cb, NULL);
1341 _create_genlist_items(app_data, is_type_reply);
1344 elm_win_activate(app_data->win_main);
1346 // app_control_request_transient_app(service, elm_win_xwindow_get(app_data->win_main), _app_control_request_transient_app_cb, NULL);
1352 void _app_pause(void* user_data)
1354 PRINTFUNC(DLOG_DEBUG, "");
1358 void _app_resume(void* user_data)
1360 PRINTFUNC(DLOG_DEBUG, "");
1363 void _app_terminate(void* user_data)
1365 App_Data* app_data = NULL;
1366 app_data = (App_Data*)user_data;
1368 if(app_data->genlist){
1369 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1372 if(app_data->res_path)
1373 free(app_data->res_path);
1375 if(app_data->shared_res_path)
1376 free(app_data->shared_res_path);
1378 input_keyboard_deinit();
1379 input_smartreply_deinit();
1381 input_template_unset_notify();
1382 input_template_deinit();
1385 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1387 if (setlocale(LC_ALL, "") == NULL) {
1388 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1389 if (setlocale(LC_ALL, lang_str) == NULL)
1392 if (bindtextdomain(domain, dir) == NULL)
1394 if (textdomain(domain) == NULL)
1401 * @brief Set language and locale.
1405 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1407 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1409 setenv("LANG", lang_str, 1);
1410 setenv("LC_MESSAGES", lang_str, 1);
1412 setenv("LANG", "en_GB.utf8", 1);
1413 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1414 lang_str = strdup("en_GB.UTF-8");
1417 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1420 elm_language_set(lang_str);
1427 int main(int argc, char* argv[])
1429 App_Data app_data = {0, };
1430 ui_app_lifecycle_callback_s event_callback = {0, };
1431 app_event_handler_h handlers[5] = {NULL, };
1433 event_callback.create = _app_create;
1434 event_callback.terminate = _app_terminate;
1435 event_callback.pause = _app_pause;
1436 event_callback.resume = _app_resume;
1437 event_callback.app_control = _app_service;
1439 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1440 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1441 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1442 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1443 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1445 _init_app_data(&app_data);
1447 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1448 if (ret != APP_ERROR_NONE) {
1449 LOGD("ui_app_main() is failed. err = %d", ret);