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");
512 // CscFeatureBool is_security_permission_manager = CSC_FEATURE_BOOL_FALSE;
513 // is_security_permission_manager = csc_feature_get_bool(CSC_FEATURE_DEF_BOOL_SECURITY_PERMISSION_MANAGER);
515 // if(is_security_permission_manager == CSC_FEATURE_BOOL_TRUE){
518 app_control_get_caller(app_data->source_app_control, &caller);
521 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
522 app_control_add_extra_data(app_control, "caller_appid", caller);
528 void reply_to_sender_by_appcontrol(void *data, const char *value, const char *type)
530 PRINTFUNC(DLOG_DEBUG, "");
535 app_control_h app_control;
537 App_Data *appdata = (App_Data *)data;
540 PRINTFUNC(DLOG_ERROR, "Null pointer");
544 ret = app_control_create(&app_control);
545 if (ret != APP_CONTROL_ERROR_NONE) {
546 PRINTFUNC(DLOG_ERROR, "Can not create app_control : %d", ret);
550 app_id = g_input_keyboard_data.app_id;
551 if (app_id == NULL) {
552 PRINTFUNC(DLOG_INFO, "app id is undefined, use defualt");
553 app_id = "com.samsung.message.appcontrol.compose";
556 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose")){
557 app_id = "com.samsung.msg-send";
560 app_control_set_app_id(app_control, app_id);
561 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
563 ret = app_control_set_window(app_control,
564 elm_win_xwindow_get(appdata->win_main));
565 if (ret != APP_CONTROL_ERROR_NONE) {
566 PRINTFUNC(DLOG_ERROR, "Can not app control set window : %d", ret);
567 app_control_destroy(app_control);
571 if (g_input_keyboard_data.data_array && g_input_keyboard_data.data_array_len > 0) {
572 app_control_add_extra_data_array(app_control,
573 "selector_keyboard_data_array",
574 (const char**)(g_input_keyboard_data.data_array),
575 g_input_keyboard_data.data_array_len);
578 app_control_add_extra_data(app_control, "selector_send_data_array", "sending_popup");
581 app_control_add_extra_data(app_control, "selected_context", value);
584 app_control_add_extra_data(app_control, "reply_type", type);
586 set_source_caller_app_id(app_control);
588 ret = app_control_send_launch_request(app_control,
589 _app_control_send_reply_cb,
592 if (ret != APP_CONTROL_ERROR_NONE)
593 PRINTFUNC(DLOG_ERROR, "Can not launch app_control: %d", ret);
595 app_control_destroy(app_control);
600 void reply_to_sender_by_callback(const char *value, const char *type)
602 PRINTFUNC(DLOG_DEBUG, "");
604 app_control_h app_control;
606 if(app_control_create(&app_control) == 0) {
610 app_control_add_extra_data(app_control, "selected_context", value);
613 app_control_add_extra_data(app_control, "reply_type", type);
615 set_source_caller_app_id(app_control);
617 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
618 if (ret != APP_CONTROL_ERROR_NONE)
619 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
621 app_control_destroy(app_control);
622 app_control_destroy(app_data->source_app_control);
623 app_data->source_app_control = NULL;
627 void reply_to_sender_by_callback_for_back()
629 PRINTFUNC(DLOG_DEBUG, "");
631 app_control_h app_control;
633 if(app_control_create(&app_control) == 0) {
636 app_control_add_extra_data(app_control, "back_to_composer", "yes");
638 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
639 if (ret != APP_CONTROL_ERROR_NONE)
640 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
642 app_control_destroy(app_control);
643 app_control_destroy(app_data->source_app_control);
644 app_data->source_app_control = NULL;
648 char* get_resource_path()
650 if(NULL == app_data->res_path) {
651 app_data->res_path = app_get_resource_path();
652 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
654 return (app_data->res_path);
657 char* get_shared_resource_path()
659 if(NULL == app_data->shared_res_path) {
660 app_data->shared_res_path = app_get_shared_resource_path();
661 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
663 return (app_data->shared_res_path);
666 void show_gl_focus(Eina_Bool bVisible){
667 if(app_data->genlist == NULL)
670 if(bVisible == EINA_TRUE){
671 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
672 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
673 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
675 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
676 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
677 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
681 void show_popup_toast(const char *text, bool check_img)
683 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
687 popup = elm_popup_add(app_data->win_main);
688 elm_object_style_set(popup, "toast/circle");
689 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
690 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
693 string path = get_resource_path();
694 string path_ic = path + "/images/toast_check_icon.png";
695 Evas_Object * img = elm_image_add(popup);
696 elm_image_file_set(img, path_ic.c_str(), NULL);
697 elm_object_part_content_set(popup, "toast,icon", img);
700 elm_object_part_text_set(popup, "elm.text", text);
703 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
704 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
705 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
707 elm_popup_timeout_set(popup, 2.0);
708 evas_object_show(popup);
711 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
714 evas_object_hide(obj);
715 evas_object_del(obj);
719 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
722 elm_popup_dismiss(obj);
725 char * _toast_delete_popup_access_info_cb(void *data, Evas_Object *obj)
727 PRINTFUNC(DLOG_ERROR, "%s", __func__);
728 const char * info = elm_object_part_text_get((Evas_Object*)data, "elm.text");
734 void _back_to_genlist_for_selector()
736 PRINTFUNC(DLOG_DEBUG, "");
738 if(!app_data) return;
740 if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
741 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
742 reply_to_sender_by_callback(NULL, NULL);
746 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
748 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
752 char *_it_plus_access_info_cb(void *data, Evas_Object *obj)
754 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
755 std::string text = std::string(gettext("IDS_ACCS_BODY_BUTTON_TTS"));
757 return strdup(text.c_str());
760 char *_access_info_cb(void *data, Evas_Object *obj)
762 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
763 return strdup(gettext("WDS_TTS_TBBODY_DOUBLE_TAP_TO_SEND"));
766 Eina_Bool _access_action_next_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
768 Evas_Object *genlist = (Evas_Object*)data;
769 PRINTFUNC(DLOG_ERROR, "[TNT] _access_action_next_cb called, genlist type:%s", evas_object_type_get(genlist));
770 Elm_Object_Item *it = elm_genlist_first_item_get(genlist);//emptry item?
771 PRINTFUNC(DLOG_ERROR, "[TNT] get first item:%p", it);
772 it = elm_genlist_item_next_get(it);//title item(3 button?)
773 PRINTFUNC(DLOG_ERROR, "[TNT] get Second item:%p, title_item:%p", it, it_title);
774 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
775 force_highlight_to_top = EINA_TRUE;
779 Eina_Bool _access_action_prev_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
781 Evas_Object *genlist = (Evas_Object*)data;
782 PRINTFUNC(DLOG_ERROR, "[TNT] _access_action_prev_cb called, genlist type:%s", evas_object_type_get(genlist));
783 Elm_Object_Item *it = elm_genlist_last_item_get(genlist);//plus button item
784 PRINTFUNC(DLOG_ERROR, "[TNT] get last item:%p", it);
785 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
786 force_highlight_to_bottom = EINA_TRUE;
790 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
792 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
795 Evas_Object* _create_genlist(Evas_Object* navi)
797 Evas_Object* genlist = elm_genlist_add(navi);
801 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
802 elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
804 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
805 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
806 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
807 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
809 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
810 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
812 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
813 evas_object_show(genlist);
815 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
817 show_gl_focus(EINA_FALSE);
819 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
826 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
827 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
832 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
837 Evas_Object *genlist = (Evas_Object *)obj;
838 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
841 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
843 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
845 if (250 > y && y >= 100){
846 if (last_step == 0) return;
848 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
849 show_gl_focus(EINA_TRUE);
850 } else if (100 > y && y >= 50){
851 if (last_step == 1) return;
853 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
854 show_gl_focus(EINA_TRUE);
855 } else if (y < 50 && y >=0){
856 if (last_step == 2) return;
858 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
859 show_gl_focus(EINA_FALSE);
864 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
868 snprintf(buf, 1023, "%s", "Select method");
872 void _create_genlist_items(void* user_data, bool is_type_reply)
874 LOGD("[psw] _create_genlist_items");
876 App_Data* app_data = (App_Data*) user_data;
878 if(NULL == app_data->genlist) {
879 app_data->genlist = _create_genlist(app_data->naviframe);
880 if(NULL == app_data->genlist)
884 elm_genlist_clear(app_data->genlist);
885 g_smartreply_current_number = 0; /* reset previous smartreply size to 0 */
887 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
888 itc0->item_style = "title";
889 itc0->func.text_get = _main_menu_title_text_get;
890 itc0->func.content_get = NULL;
891 itc0->func.state_get = NULL;
892 itc0->func.del = NULL;
894 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
895 itc1->item_style = "3button";
896 itc1->func.text_get = NULL;
897 itc1->func.content_get = __ise_gl_3button_content_get;
898 itc1->func.state_get = NULL;
899 itc1->func.del = NULL;
902 // dummy title for empty space
903 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
905 ELM_GENLIST_ITEM_NONE,
908 if (!is_type_reply) {
910 it_title = elm_genlist_item_append(app_data->genlist, itc1,
912 ELM_GENLIST_ITEM_NONE,
915 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
917 if (input_smartreply_is_enabled() == false) {
918 _update_template_items(app_data);
919 if(g_template_current_number > 0) {
920 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
921 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
922 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
925 // dummy title for bottom
926 Elm_Object_Item *dummy;
928 dummy = elm_genlist_item_append(app_data->genlist, itc0,
930 ELM_GENLIST_ITEM_NONE,
933 elm_genlist_item_select_mode_set(dummy, ELM_OBJECT_SELECT_MODE_NONE);
937 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
938 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
940 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
942 elm_genlist_item_class_free(itc0);
943 elm_genlist_item_class_free(itc1);
946 void _update_genlist_items(void *user_data)
950 if (input_smartreply_is_enabled())
951 len = input_smartreply_get_reply_num();
953 if (g_smartreply_current_number != len)
954 _update_smartreply_items(user_data);
956 _update_template_items(user_data);
958 g_smartreply_current_number = len;
960 if (g_smartreply_current_number > 0 || g_template_current_number > 0) {
961 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
962 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
963 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
967 void _update_smartreply_items(void *user_data)
971 Elm_Object_Item *first;
972 Elm_Object_Item *menu;
973 Elm_Object_Item *pos;
978 app_data = (App_Data *)user_data;
980 if (app_data == NULL) {
981 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
985 if (app_data->genlist == NULL) {
986 /* smartreply will update when genlist is exist only */
987 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
991 if (input_smartreply_is_enabled())
992 len = input_smartreply_get_reply_num();
994 if (g_smartreply_current_number == len)
997 first = elm_genlist_first_item_get(app_data->genlist);
998 menu = elm_genlist_item_next_get(first);
1000 /* Remove current smartreply list */
1001 pos = elm_genlist_item_next_get(menu);
1002 for (i = 0; i < g_smartreply_current_number; i++) {
1003 Elm_Object_Item *next;
1008 next = elm_genlist_item_next_get(pos);
1009 elm_object_item_del(pos);
1013 /* Append newly added smartreply list */
1015 Elm_Genlist_Item_Class *itc;
1017 itc = elm_genlist_item_class_new();
1019 itc->item_style = "1text";
1020 itc->func.text_get = __ise_smartreply_gl_text_get;
1021 itc->func.content_get = NULL;
1022 itc->func.state_get = NULL;
1023 itc->func.del = NULL;
1026 for (i = 0; i < len; i++) {
1027 pos = elm_genlist_item_insert_after(app_data->genlist,
1032 ELM_GENLIST_ITEM_NONE,
1033 __ise_smartreply_gl_sel,
1038 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1040 elm_genlist_item_class_free(itc);
1043 g_smartreply_current_number = len;
1047 void _update_template_items(void *user_data)
1051 Elm_Object_Item *first;
1052 Elm_Object_Item *menu;
1053 Elm_Object_Item *pos;
1054 Elm_Object_Item *template_pos;
1056 unsigned int template_len = 0;
1059 app_data = (App_Data *)user_data;
1061 if (app_data == NULL) {
1062 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1066 if (app_data->genlist == NULL) {
1067 /* smartreply will update when genlist is exist only */
1068 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1072 if (app_data->app_type == APP_TYPE_REPLY) {
1073 menu = elm_genlist_first_item_get(app_data->genlist);
1075 first = elm_genlist_first_item_get(app_data->genlist);
1076 menu = elm_genlist_item_next_get(first);
1080 /* move to smartreply next if it need */
1081 if (input_smartreply_is_enabled()) {
1082 int smartreply_len = 0;
1084 smartreply_len = input_smartreply_get_reply_num();
1085 if (smartreply_len > 0) {
1088 for (j = 0; j < smartreply_len; j++) {
1092 pos = elm_genlist_item_next_get(pos);
1097 /* Remove Current template list */
1098 template_pos = elm_genlist_item_next_get(pos);
1099 for (i = 0 ; i < g_template_current_number; i++) {
1100 Elm_Object_Item *next;
1102 if (template_pos == NULL) {
1103 PRINTFUNC(DLOG_ERROR, "Template mismatched, iter : %d, current num: %d",
1104 i, g_template_current_number);
1108 next = elm_genlist_item_next_get(template_pos);
1109 elm_object_item_del(template_pos);
1110 template_pos = next;
1113 /* Remove Add or dummpy button */
1115 Elm_Object_Item *next;
1117 next = elm_genlist_item_next_get(template_pos);
1118 elm_object_item_del(template_pos);
1119 template_pos = next;
1122 /* Append New Template list */
1123 const std::vector<TemplateData> template_list = input_template_get_list();
1126 if (template_list.size() > 0) {
1127 Elm_Genlist_Item_Class *itc;
1129 itc = elm_genlist_item_class_new();
1131 itc->item_style = "1text";
1132 itc->func.text_get = __ise_template_gl_text_get;
1133 itc->func.content_get = NULL;
1134 itc->func.state_get = NULL;
1135 itc->func.del = NULL;
1137 for (i = 0; i < template_list.size(); i++) {
1138 bool matched = false;
1140 if(!template_list[i].use_gettext) {
1141 int smartreply_len = 0;
1144 smartreply_len = input_smartreply_get_reply_num();
1145 for (j = 0; j < smartreply_len; j++) {
1148 reply = input_smartreply_get_nth_item(j);
1150 if (!strcmp(reply, template_list[i].text.c_str())) {
1160 if (matched == false) {
1161 pos = elm_genlist_item_insert_after(app_data->genlist,
1166 ELM_GENLIST_ITEM_NONE,
1167 __ise_template_gl_sel,
1173 elm_genlist_item_class_free(itc);
1177 // template add button (+)
1178 /* if (!input_template_is_user_template()) {
1179 Elm_Genlist_Item_Class *itc;
1181 itc = elm_genlist_item_class_new();
1183 itc->item_style = "1text.1icon";
1184 itc->func.text_get = __ise_addtemplate_gl_text_get;;
1185 itc->func.content_get = __ise_gl_1button_content_get;
1186 itc->func.state_get = NULL;
1187 itc->func.del = NULL;
1190 pos = elm_genlist_item_insert_after(app_data->genlist,
1195 ELM_GENLIST_ITEM_NONE,
1196 __ise_template_add_gl_sel,
1199 elm_genlist_item_class_free(itc);
1203 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1205 g_template_current_number = template_len;
1209 bool _app_create(void* user_data)
1211 int width = 1000, height = 1000;
1212 // App_Data* app_data = NULL;
1213 Evas_Object* layout = NULL;
1214 Evas_Object* conform = NULL;
1215 Evas_Object* bg = NULL;
1216 Evas_Object* window = NULL;
1217 Eext_Circle_Surface *surface;
1223 _app_language_changed(NULL, NULL);
1225 app_data = (App_Data*)user_data;
1227 elm_app_base_scale_set(1.3);
1229 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1231 init_customizing_theme();
1233 elm_win_title_set(window, PACKAGE);
1234 elm_win_borderless_set(window, EINA_TRUE);
1235 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1236 evas_object_resize(window, width, height);
1237 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1239 LOGE("elm_win_add() is failed.");
1243 bg = elm_bg_add(window);
1244 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1245 elm_win_resize_object_add(window, bg);
1246 evas_object_show(bg);
1248 layout = elm_layout_add(window);
1249 elm_layout_theme_set(layout, "layout", "application", "default");
1250 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1252 conform = elm_conformant_add(window);
1253 surface = eext_circle_surface_conformant_add(conform);
1254 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1257 elm_win_resize_object_add(window, conform);
1258 elm_object_content_set(conform, layout);
1260 evas_object_show(layout);
1261 evas_object_show(conform);
1262 evas_object_show(window);
1263 app_data->win_main = window;
1264 app_data->conform = conform;
1265 app_data->layout_main = layout;
1266 app_data->circle_surface = surface;
1267 app_data->app_type = APP_TYPE_SELECT_MODE;
1269 Evas_Object *naviframe = elm_naviframe_add(layout);
1270 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1271 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1272 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1273 evas_object_show(naviframe);
1275 app_data->naviframe = naviframe;
1280 void _app_service(app_control_h service, void* user_data)
1284 char *context = NULL;
1285 char *app_id = NULL;
1287 app_control_clone(&(app_data->source_app_control), service);
1289 app_data->reply_type = REPLY_APP_NORMAL;
1290 ret = app_control_get_extra_data(service, "selector_keyboard_app_id", &app_id);
1291 if (ret == APP_CONTROL_ERROR_NONE) {
1292 PRINTFUNC(DLOG_DEBUG, "app_id = %s", app_id);
1296 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose") || !strcmp(app_id, "com.samsung.wemail-send")) {
1297 app_data->reply_type = REPLY_APP_CONTROL;
1299 app_data->reply_type = REPLY_APP_NORMAL;
1305 bool is_type_reply = false;
1306 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1307 if (ret == APP_CONTROL_ERROR_NONE) {
1308 if (!strcmp(context, "input_voice")) {
1309 app_data->app_type = APP_TYPE_STT;
1310 _stt_clicked_cb((void *)app_data, NULL, NULL);
1312 } else if (!strcmp(context, "input_emoticon")) {
1313 app_data->app_type = APP_TYPE_EMOTICON;
1314 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1316 } else if (!strcmp(context, "input_keyboard")) {
1317 app_data->app_type = APP_TYPE_KEYBOARD;
1318 input_keyboard_init(service);
1319 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1321 } else if (!strcmp(context, "keyboard_input_from_sms")) {
1322 app_data->app_type = APP_TYPE_KEYBOARD_FROM_SMS;
1323 input_keyboard_init(service);
1324 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1326 } else if (!strcmp(context, "input_reply")) {
1327 app_data->app_type = APP_TYPE_REPLY;
1328 is_type_reply = true;
1332 if (app_data->genlist == NULL)
1333 app_data->genlist = _create_genlist(app_data->naviframe);
1335 input_keyboard_init(service);
1337 // input_smartreply_init(service);
1338 // input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1340 // if (input_smartreply_is_enabled())
1341 // input_smartreply_get_reply_async();
1344 input_template_init(service);
1345 input_template_set_notify(_input_template_notify_cb, NULL);
1347 _create_genlist_items(app_data, is_type_reply);
1350 elm_win_activate(app_data->win_main);
1352 // app_control_request_transient_app(service, elm_win_xwindow_get(app_data->win_main), _app_control_request_transient_app_cb, NULL);
1358 void _app_pause(void* user_data)
1360 PRINTFUNC(DLOG_DEBUG, "");
1364 void _app_resume(void* user_data)
1366 PRINTFUNC(DLOG_DEBUG, "");
1369 void _app_terminate(void* user_data)
1371 App_Data* app_data = NULL;
1372 app_data = (App_Data*)user_data;
1374 if(app_data->genlist){
1375 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1378 if(app_data->res_path)
1379 free(app_data->res_path);
1381 if(app_data->shared_res_path)
1382 free(app_data->shared_res_path);
1384 input_keyboard_deinit();
1385 input_smartreply_deinit();
1387 input_template_unset_notify();
1388 input_template_deinit();
1391 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1393 if (setlocale(LC_ALL, "") == NULL) {
1394 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1395 if (setlocale(LC_ALL, lang_str) == NULL)
1398 if (bindtextdomain(domain, dir) == NULL)
1400 if (textdomain(domain) == NULL)
1407 * @brief Set language and locale.
1411 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1413 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1415 setenv("LANG", lang_str, 1);
1416 setenv("LC_MESSAGES", lang_str, 1);
1418 setenv("LANG", "en_GB.utf8", 1);
1419 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1420 lang_str = strdup("en_GB.UTF-8");
1423 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1426 elm_language_set(lang_str);
1433 int main(int argc, char* argv[])
1435 App_Data app_data = {0, };
1436 ui_app_lifecycle_callback_s event_callback = {0, };
1437 app_event_handler_h handlers[5] = {NULL, };
1439 event_callback.create = _app_create;
1440 event_callback.terminate = _app_terminate;
1441 event_callback.pause = _app_pause;
1442 event_callback.resume = _app_resume;
1443 event_callback.app_control = _app_service;
1445 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1446 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1447 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1448 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1449 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1451 _init_app_data(&app_data);
1453 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1454 if (ret != APP_ERROR_NONE) {
1455 LOGD("ui_app_main() is failed. err = %d", ret);