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"
36 #ifdef SUPPORT_LOG_MANAGER
37 #include <samsung_log_manager.h>
38 #include <samsung_log_manager_uri.h>
46 App_Data* app_data = NULL;
47 #ifdef SUPPORT_LOG_MANAGER
48 static samsung_log_manager_h g_log_manager = NULL;
51 InputKeyboardData g_input_keyboard_data;
53 static Elm_Object_Item *it_empty;
54 static Elm_Object_Item *it_title;
55 static Elm_Object_Item *it_plus;
56 static int g_smartreply_current_number = 0; /* currently loaded smartreply number */
57 static unsigned int g_template_current_number = 0; /* currnetly loaded template number */
59 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
61 static Eina_Bool force_highlight_to_top = EINA_FALSE;
62 static Eina_Bool force_highlight_to_bottom = EINA_FALSE;
63 static Eina_Bool is_genlist_highlighed = EINA_FALSE;
65 void _init_app_data(App_Data* app_data);
66 static void _app_language_changed(app_event_info_h event_info, void *user_data);
67 static int _app_control_request_transient_app_cb(void *data);
68 #ifdef SUPPORT_LOG_MANAGER
69 static void log_manager_init(void);
70 static void log_manager_exit(void);
71 static void log_manager_set(const char *feature, const char *extra, const char *value);
74 static char *_genlist_text_set_theme_color(const char *str, const char *code);
76 Evas_Object* _create_genlist(Evas_Object* parent);
77 void _create_genlist_items(void* user_data, bool is_type_reply);
78 void _update_genlist_items(void *user_data);
79 void _update_smartreply_items(void *user_data);
80 void _update_template_items(void *user_data);
81 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
82 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
83 char * _toast_delete_popup_access_info_cb(void *data, Evas_Object *obj);
87 void _init_app_data(App_Data* app_data)
89 app_data->win_main = NULL;
90 app_data->layout_main = NULL;
91 app_data->conform = NULL;
92 app_data->naviframe = NULL;
93 app_data->genlist = NULL;
95 app_data->res_path = NULL;
100 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
103 Evas_Object* content;
106 window = elm_layout_add(parent);
108 ret = elm_layout_file_set(window, file, group);
110 evas_object_del(window);
114 content = elm_layout_add(parent);
115 elm_layout_theme_set(content, "layout", "application", "default");
116 elm_object_part_content_set(window, "elm.swallow.content", content);
118 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
124 void init_customizing_theme(void)
126 string stt_edj_path = get_resource_path();
127 string app_edj_path = get_resource_path();
129 stt_edj_path = stt_edj_path + STT_EDJ_FILE;
130 app_edj_path = app_edj_path + APP_EDJ_FILE;
132 elm_theme_extension_add(NULL, stt_edj_path.c_str());
133 elm_theme_extension_add(NULL, app_edj_path.c_str());
137 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
139 reply_to_sender_by_callback_for_back();
144 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
146 App_Data* ad = (App_Data*)data;
148 PRINTFUNC(DLOG_DEBUG, "");
154 bool bAgreed = false;
155 stt_get_user_agreement(&bAgreed);
158 if(is_tos_N66_agreed() == EINA_FALSE){
159 if(is_sap_connection() == EINA_TRUE){
160 ise_show_tos_n66_popup(ad);
162 launch_bt_connection_popup(ad);
165 ise_show_stt_popup(ad);
169 #ifdef SUPPORT_LOG_MANAGER
170 log_manager_set("IM01", "STT", NULL);
174 static void _input_smartreply_notify_cb(void *user_data)
176 ecore_main_loop_iterate();
177 _update_genlist_items((void *)app_data);
180 static void _input_template_notify_cb(void *user_data)
182 _update_genlist_items((void *)app_data);
186 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
188 App_Data* ad = (App_Data*)data;
190 PRINTFUNC(DLOG_DEBUG, "");
195 // ise_show_emoticon_popup(ad);
196 ise_show_emoticon_popup_rotary(ad);
198 #ifdef SUPPORT_LOG_MANAGER
199 log_manager_set("IM01", "Emoticon", NULL);
203 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
205 App_Data* ad = (App_Data *)data;
207 PRINTFUNC(DLOG_DEBUG, "");
212 #ifdef SUPPORT_LOG_MANAGER
213 log_manager_set("IM01", "Keypad", NULL);
216 if (app_data->app_type == APP_TYPE_KEYBOARD_FROM_SMS)
217 input_keyboard_launch(ad->win_main);
219 input_keyboard_launch_with_ui(ad->win_main, data);
222 static void __bt_connection_result_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
227 PRINTFUNC(DLOG_ERROR, "service_h is NULL");
231 app_control_get_extra_data(reply, "__BT_CONNECTION__", &val);
233 if ( strcmp(val, "Connected") == 0 ) {
234 PRINTFUNC(DLOG_ERROR, "BT Connected");
236 PRINTFUNC(DLOG_ERROR, "BT Not Connected");
244 static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
246 App_Data* app_data = (App_Data*) data;
247 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
250 elm_genlist_item_selected_set(item, EINA_FALSE);
252 int index = (unsigned int) elm_object_item_data_get(item);
254 #ifdef SUPPORT_LOG_MANAGER
255 log_manager_set("IM01", "Preset", NULL);
256 log_manager_set("IM02", "Smart Reply", NULL);
258 char *reply = input_smartreply_get_nth_item(index);
260 input_smartreply_send_feedback(reply);
261 if(app_data->reply_type == REPLY_APP_CONTROL){
262 reply_to_sender_by_appcontrol((void*)app_data, reply, "smartreply");
265 reply_to_sender_by_callback(reply, "smartreply");
273 static void __ise_template_add_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;
279 elm_genlist_item_selected_set(item, EINA_FALSE);
281 if(is_sap_connection() == EINA_TRUE){
283 show_popup_toast(gettext("WDS_IME_TPOP_ADD_TEMPLATE_ON_YOUR_PHONE_ABB"), true);
285 // send message to Host
286 app_control_h appctrl;
287 app_control_create(&appctrl);
288 app_control_set_app_id(appctrl, "com.samsung.w-manager-service");
289 app_control_add_extra_data(appctrl, "type", "gm_setting");
290 app_control_add_extra_data(appctrl, "data/setting_menu", "texttemplate_setting");
291 app_control_send_launch_request(appctrl, NULL, NULL);
292 app_control_destroy(appctrl);
294 app_control_h app_control;
295 app_control_create(&app_control);
296 app_control_set_app_id(app_control, "com.samsung.bt-connection-popup");
297 app_control_add_extra_data(app_control, "msg", "perform");
298 app_control_send_launch_request(app_control, __bt_connection_result_cb, NULL);
299 app_control_destroy(app_control);
304 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
306 App_Data* app_data = (App_Data*) data;
307 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
311 elm_genlist_item_selected_set(item, EINA_FALSE);
313 index = (unsigned int) elm_object_item_data_get(item);
314 const std::vector<TemplateData> template_list = input_template_get_list();
316 //@ToDo : should call reply function when any template string is selected and confirmed.
317 // Here reply string will be template_list[index].text.c_str();
318 if( index < template_list.size()) {
319 #ifdef SUPPORT_LOG_MANAGER
320 log_manager_set("IM01", "Preset", NULL);
321 log_manager_set("IM02", "Preset except smart reply", NULL);
323 if(app_data->reply_type == REPLY_APP_CONTROL){
324 reply_to_sender_by_appcontrol((void*)app_data, gettext(template_list[index].text.c_str()), "template");
326 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
333 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
335 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
336 Evas_Object* btn = elm_button_add(obj);
337 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
338 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
339 Evas_Object* ic = elm_image_add(btn);
340 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
341 string path = get_resource_path();
342 if (!strcmp(part, "elm.icon.1")) {
343 elm_object_style_set(btn, "anchor");
344 string path_ic = path + "images/w_mode_stt_ic.png";
345 elm_image_file_set(ic, path_ic.c_str(), NULL);
346 elm_object_content_set(btn, ic);
347 evas_object_layer_set(btn, 32000);
349 } else if (!strcmp(part, "elm.icon.2")){
350 elm_object_style_set(btn, "anchor");
351 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
352 elm_image_file_set(ic, path_ic.c_str(), NULL);
353 elm_object_content_set(btn, ic);
354 evas_object_layer_set(btn, 32000);
356 } else if (!strcmp(part, "elm.icon.3")){
357 elm_object_style_set(btn, "anchor");
358 string path_ic = path + "images/w_mode_keyboard_ic.png";
359 elm_image_file_set(ic, path_ic.c_str(), NULL);
360 elm_object_content_set(btn, ic);
361 evas_object_layer_set(btn, 32000);
362 evas_object_propagate_events_set(btn, EINA_FALSE);
366 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
367 Evas_Object* btn = elm_button_add(obj);
368 elm_object_style_set(btn, "touch_area");
369 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
370 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
371 string path = get_resource_path();
372 if (!strcmp(part, "elm.icon.1.touch_area")) {
373 evas_object_layer_set(btn, 32000);
374 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
376 } else if (!strcmp(part, "elm.icon.2.touch_area")){
377 evas_object_layer_set(btn, 32000);
378 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
379 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
380 evas_object_layer_set(btn, 32000);
381 evas_object_propagate_events_set(btn, EINA_FALSE);
382 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
386 } else if (!strcmp(part, "base")) {
387 Evas_Object* btn = elm_button_add(obj);
388 elm_object_style_set(btn, "ime_transparent");
394 static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
396 if(!strcmp(part, "elm.text")) {
404 reply = input_smartreply_get_nth_item(index);
408 /* Set hightlight color on first 3 smartreply items */
410 char *colored = _genlist_text_set_theme_color(reply, "AT0113");
412 if (colored == NULL) {
425 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
427 if(!strcmp(part, "elm.text")) {
428 unsigned int index = (unsigned int)data;
429 const std::vector<TemplateData> template_list = input_template_get_list();
431 if(index < template_list.size()) {
432 if(template_list[index].use_gettext) {
433 return strdup(gettext(template_list[index].text.c_str()));
435 Eina_Strbuf *buf = NULL;
436 const char *str = NULL;
439 buf = eina_strbuf_new();
441 eina_strbuf_append(buf, template_list[index].text.c_str());
442 eina_strbuf_replace_all(buf, "\n", "");
443 eina_strbuf_replace_all(buf, "\r", "");
445 str = eina_strbuf_string_get(buf);
448 markup = elm_entry_utf8_to_markup(str);
450 eina_strbuf_free(buf);
460 static char * __ise_addtemplate_gl_text_get(void *data, Evas_Object *obj, const char *part)
462 if(!strcmp(part, "elm.text")) {
463 return(strdup(gettext("WDS_IME_MBODY_ADD_TEMPLATE_ABB")));
468 static Evas_Object * __ise_gl_1button_content_get(void *data, Evas_Object *obj, const char *part)
470 if (!strcmp(part, "elm.icon")) {
471 Evas_Object* btn = elm_button_add(obj);
472 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
473 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
474 Evas_Object* ic = elm_image_add(btn);
475 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
476 string path = get_resource_path();
477 elm_object_style_set(btn, "ime_button_template");
478 string path_ic = path + "/images/w_list_add_ic.png";
479 elm_image_file_set(ic, path_ic.c_str(), NULL);
480 elm_object_content_set(btn, ic);
481 evas_object_layer_set(btn, 32000);
488 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
490 //Update genlist items. The Item texts will be translated in the _gl_text_get().
491 elm_genlist_realized_items_update(obj);
494 static int _app_control_request_transient_app_cb(void *data)
500 static char *_genlist_text_set_theme_color(const char *str, const char *code)
503 Eina_Strbuf *buf = NULL;
504 char *colored = NULL;
509 buf = eina_strbuf_new();
511 PRINTFUNC(DLOG_ERROR, "Can not get create strbuf");
515 // ea_theme_color_get(code,
517 // NULL, NULL, NULL, NULL,
518 // NULL, NULL, NULL, NULL);
520 eina_strbuf_append_printf(buf, "<color=#%02x%02x%02x%02x>%s</color>",
523 colored = eina_strbuf_string_steal(buf);
525 eina_strbuf_free(buf);
531 static void _app_control_send_reply_cb(app_control_h request, app_control_h reply,
532 app_control_result_e result, void *user_data)
534 PRINTFUNC(DLOG_DEBUG, "");
535 reply_to_sender_by_callback(NULL, NULL);
539 void set_source_caller_app_id(app_control_h app_control)
542 PRINTFUNC(DLOG_ERROR, "can't get app_control");
546 // CscFeatureBool is_security_permission_manager = CSC_FEATURE_BOOL_FALSE;
547 // is_security_permission_manager = csc_feature_get_bool(CSC_FEATURE_DEF_BOOL_SECURITY_PERMISSION_MANAGER);
549 // if(is_security_permission_manager == CSC_FEATURE_BOOL_TRUE){
552 app_control_get_caller(app_data->source_app_control, &caller);
555 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
556 app_control_add_extra_data(app_control, "caller_appid", caller);
562 void reply_to_sender_by_appcontrol(void *data, const char *value, const char *type)
564 PRINTFUNC(DLOG_DEBUG, "");
569 app_control_h app_control;
571 App_Data *appdata = (App_Data *)data;
574 PRINTFUNC(DLOG_ERROR, "Null pointer");
578 ret = app_control_create(&app_control);
579 if (ret != APP_CONTROL_ERROR_NONE) {
580 PRINTFUNC(DLOG_ERROR, "Can not create app_control : %d", ret);
584 app_id = g_input_keyboard_data.app_id;
585 if (app_id == NULL) {
586 PRINTFUNC(DLOG_INFO, "app id is undefined, use defualt");
587 app_id = "com.samsung.message.appcontrol.compose";
590 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose")){
591 app_id = "com.samsung.msg-send";
594 app_control_set_app_id(app_control, app_id);
595 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
597 ret = app_control_set_window(app_control,
598 elm_win_xwindow_get(appdata->win_main));
599 if (ret != APP_CONTROL_ERROR_NONE) {
600 PRINTFUNC(DLOG_ERROR, "Can not app control set window : %d", ret);
601 app_control_destroy(app_control);
605 if (g_input_keyboard_data.data_array && g_input_keyboard_data.data_array_len > 0) {
606 app_control_add_extra_data_array(app_control,
607 "selector_keyboard_data_array",
608 (const char**)(g_input_keyboard_data.data_array),
609 g_input_keyboard_data.data_array_len);
612 app_control_add_extra_data(app_control, "selector_send_data_array", "sending_popup");
615 app_control_add_extra_data(app_control, "selected_context", value);
618 app_control_add_extra_data(app_control, "reply_type", type);
620 set_source_caller_app_id(app_control);
622 ret = app_control_send_launch_request(app_control,
623 _app_control_send_reply_cb,
626 if (ret != APP_CONTROL_ERROR_NONE)
627 PRINTFUNC(DLOG_ERROR, "Can not launch app_control: %d", ret);
629 app_control_destroy(app_control);
634 void reply_to_sender_by_callback(const char *value, const char *type)
636 PRINTFUNC(DLOG_DEBUG, "");
638 app_control_h app_control;
640 if(app_control_create(&app_control) == 0) {
644 app_control_add_extra_data(app_control, "selected_context", value);
647 app_control_add_extra_data(app_control, "reply_type", type);
649 set_source_caller_app_id(app_control);
651 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
652 if (ret != APP_CONTROL_ERROR_NONE)
653 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
655 app_control_destroy(app_control);
656 app_control_destroy(app_data->source_app_control);
657 app_data->source_app_control = NULL;
661 void reply_to_sender_by_callback_for_back()
663 PRINTFUNC(DLOG_DEBUG, "");
665 app_control_h app_control;
667 if(app_control_create(&app_control) == 0) {
670 app_control_add_extra_data(app_control, "back_to_composer", "yes");
672 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
673 if (ret != APP_CONTROL_ERROR_NONE)
674 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
676 app_control_destroy(app_control);
677 app_control_destroy(app_data->source_app_control);
678 app_data->source_app_control = NULL;
682 char* get_resource_path()
684 if(NULL == app_data->res_path) {
685 app_data->res_path = app_get_resource_path();
686 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
688 return (app_data->res_path);
691 char* get_shared_resource_path()
693 if(NULL == app_data->shared_res_path) {
694 app_data->shared_res_path = app_get_shared_resource_path();
695 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
697 return (app_data->shared_res_path);
700 void show_gl_focus(Eina_Bool bVisible){
701 if(app_data->genlist == NULL)
704 if(bVisible == EINA_TRUE){
705 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
706 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
707 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
709 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
710 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
711 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
715 void show_popup_toast(const char *text, bool check_img)
717 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
721 popup = elm_popup_add(app_data->win_main);
722 elm_object_style_set(popup, "toast/circle");
723 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
724 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
727 string path = get_resource_path();
728 string path_ic = path + "/images/toast_check_icon.png";
729 Evas_Object * img = elm_image_add(popup);
730 elm_image_file_set(img, path_ic.c_str(), NULL);
731 elm_object_part_content_set(popup, "toast,icon", img);
734 elm_object_part_text_set(popup, "elm.text", text);
737 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
738 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
739 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
741 elm_popup_timeout_set(popup, 2.0);
742 evas_object_show(popup);
745 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
748 evas_object_hide(obj);
749 evas_object_del(obj);
753 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
756 elm_popup_dismiss(obj);
759 char * _toast_delete_popup_access_info_cb(void *data, Evas_Object *obj)
761 PRINTFUNC(DLOG_ERROR, "%s", __func__);
762 const char * info = elm_object_part_text_get((Evas_Object*)data, "elm.text");
768 void _back_to_genlist_for_selector()
770 PRINTFUNC(DLOG_DEBUG, "");
772 if(!app_data) return;
774 if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
775 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
776 reply_to_sender_by_callback(NULL, NULL);
780 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
782 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
786 char *_it_plus_access_info_cb(void *data, Evas_Object *obj)
788 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
789 std::string text = std::string(gettext("IDS_ACCS_BODY_BUTTON_TTS"));
791 return strdup(text.c_str());
794 char *_access_info_cb(void *data, Evas_Object *obj)
796 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
797 return strdup(gettext("WDS_TTS_TBBODY_DOUBLE_TAP_TO_SEND"));
800 Eina_Bool _access_action_next_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
802 Evas_Object *genlist = (Evas_Object*)data;
803 PRINTFUNC(DLOG_ERROR, "[TNT] _access_action_next_cb called, genlist type:%s", evas_object_type_get(genlist));
804 Elm_Object_Item *it = elm_genlist_first_item_get(genlist);//emptry item?
805 PRINTFUNC(DLOG_ERROR, "[TNT] get first item:%p", it);
806 it = elm_genlist_item_next_get(it);//title item(3 button?)
807 PRINTFUNC(DLOG_ERROR, "[TNT] get Second item:%p, title_item:%p", it, it_title);
808 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
809 force_highlight_to_top = EINA_TRUE;
813 Eina_Bool _access_action_prev_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
815 Evas_Object *genlist = (Evas_Object*)data;
816 PRINTFUNC(DLOG_ERROR, "[TNT] _access_action_prev_cb called, genlist type:%s", evas_object_type_get(genlist));
817 Elm_Object_Item *it = elm_genlist_last_item_get(genlist);//plus button item
818 PRINTFUNC(DLOG_ERROR, "[TNT] get last item:%p", it);
819 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
820 force_highlight_to_bottom = EINA_TRUE;
824 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
826 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
829 Evas_Object* _create_genlist(Evas_Object* navi)
831 Evas_Object* genlist = elm_genlist_add(navi);
835 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
836 elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
838 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
839 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
840 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
841 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
843 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
844 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
846 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
847 evas_object_show(genlist);
849 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
851 show_gl_focus(EINA_FALSE);
853 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
860 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
861 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
866 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
871 Evas_Object *genlist = (Evas_Object *)obj;
872 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
875 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
877 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
879 if (250 > y && y >= 100){
880 if (last_step == 0) return;
882 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
883 show_gl_focus(EINA_TRUE);
884 } else if (100 > y && y >= 50){
885 if (last_step == 1) return;
887 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
888 show_gl_focus(EINA_TRUE);
889 } else if (y < 50 && y >=0){
890 if (last_step == 2) return;
892 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
893 show_gl_focus(EINA_FALSE);
898 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
902 snprintf(buf, 1023, "%s", "Select method");
906 void _create_genlist_items(void* user_data, bool is_type_reply)
908 LOGD("[psw] _create_genlist_items");
910 App_Data* app_data = (App_Data*) user_data;
912 if(NULL == app_data->genlist) {
913 app_data->genlist = _create_genlist(app_data->naviframe);
914 if(NULL == app_data->genlist)
918 elm_genlist_clear(app_data->genlist);
919 g_smartreply_current_number = 0; /* reset previous smartreply size to 0 */
921 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
922 itc0->item_style = "title";
923 itc0->func.text_get = _main_menu_title_text_get;
924 itc0->func.content_get = NULL;
925 itc0->func.state_get = NULL;
926 itc0->func.del = NULL;
928 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
929 itc1->item_style = "3button";
930 itc1->func.text_get = NULL;
931 itc1->func.content_get = __ise_gl_3button_content_get;
932 itc1->func.state_get = NULL;
933 itc1->func.del = NULL;
936 // dummy title for empty space
937 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
939 ELM_GENLIST_ITEM_NONE,
942 if (!is_type_reply) {
944 it_title = elm_genlist_item_append(app_data->genlist, itc1,
946 ELM_GENLIST_ITEM_NONE,
949 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
951 if (input_smartreply_is_enabled() == false) {
952 _update_template_items(app_data);
953 if(g_template_current_number > 0) {
954 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
955 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
956 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
959 // dummy title for bottom
960 Elm_Object_Item *dummy;
962 dummy = elm_genlist_item_append(app_data->genlist, itc0,
964 ELM_GENLIST_ITEM_NONE,
967 elm_genlist_item_select_mode_set(dummy, ELM_OBJECT_SELECT_MODE_NONE);
971 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
972 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
974 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
976 elm_genlist_item_class_free(itc0);
977 elm_genlist_item_class_free(itc1);
980 void _update_genlist_items(void *user_data)
984 if (input_smartreply_is_enabled())
985 len = input_smartreply_get_reply_num();
987 if (g_smartreply_current_number != len)
988 _update_smartreply_items(user_data);
990 _update_template_items(user_data);
992 g_smartreply_current_number = len;
994 if (g_smartreply_current_number > 0 || g_template_current_number > 0) {
995 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
996 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
997 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
1001 void _update_smartreply_items(void *user_data)
1005 Elm_Object_Item *first;
1006 Elm_Object_Item *menu;
1007 Elm_Object_Item *pos;
1012 app_data = (App_Data *)user_data;
1014 if (app_data == NULL) {
1015 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1019 if (app_data->genlist == NULL) {
1020 /* smartreply will update when genlist is exist only */
1021 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1025 if (input_smartreply_is_enabled())
1026 len = input_smartreply_get_reply_num();
1028 if (g_smartreply_current_number == len)
1031 first = elm_genlist_first_item_get(app_data->genlist);
1032 menu = elm_genlist_item_next_get(first);
1034 /* Remove current smartreply list */
1035 pos = elm_genlist_item_next_get(menu);
1036 for (i = 0; i < g_smartreply_current_number; i++) {
1037 Elm_Object_Item *next;
1042 next = elm_genlist_item_next_get(pos);
1043 elm_object_item_del(pos);
1047 /* Append newly added smartreply list */
1049 Elm_Genlist_Item_Class *itc;
1051 itc = elm_genlist_item_class_new();
1053 itc->item_style = "1text";
1054 itc->func.text_get = __ise_smartreply_gl_text_get;
1055 itc->func.content_get = NULL;
1056 itc->func.state_get = NULL;
1057 itc->func.del = NULL;
1060 for (i = 0; i < len; i++) {
1061 pos = elm_genlist_item_insert_after(app_data->genlist,
1066 ELM_GENLIST_ITEM_NONE,
1067 __ise_smartreply_gl_sel,
1072 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1074 elm_genlist_item_class_free(itc);
1077 g_smartreply_current_number = len;
1081 void _update_template_items(void *user_data)
1085 Elm_Object_Item *first;
1086 Elm_Object_Item *menu;
1087 Elm_Object_Item *pos;
1088 Elm_Object_Item *template_pos;
1090 unsigned int template_len = 0;
1093 app_data = (App_Data *)user_data;
1095 if (app_data == NULL) {
1096 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1100 if (app_data->genlist == NULL) {
1101 /* smartreply will update when genlist is exist only */
1102 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1106 if (app_data->app_type == APP_TYPE_REPLY) {
1107 menu = elm_genlist_first_item_get(app_data->genlist);
1109 first = elm_genlist_first_item_get(app_data->genlist);
1110 menu = elm_genlist_item_next_get(first);
1114 /* move to smartreply next if it need */
1115 if (input_smartreply_is_enabled()) {
1116 int smartreply_len = 0;
1118 smartreply_len = input_smartreply_get_reply_num();
1119 if (smartreply_len > 0) {
1122 for (j = 0; j < smartreply_len; j++) {
1126 pos = elm_genlist_item_next_get(pos);
1131 /* Remove Current template list */
1132 template_pos = elm_genlist_item_next_get(pos);
1133 for (i = 0 ; i < g_template_current_number; i++) {
1134 Elm_Object_Item *next;
1136 if (template_pos == NULL) {
1137 PRINTFUNC(DLOG_ERROR, "Template mismatched, iter : %d, current num: %d",
1138 i, g_template_current_number);
1142 next = elm_genlist_item_next_get(template_pos);
1143 elm_object_item_del(template_pos);
1144 template_pos = next;
1147 /* Remove Add or dummpy button */
1149 Elm_Object_Item *next;
1151 next = elm_genlist_item_next_get(template_pos);
1152 elm_object_item_del(template_pos);
1153 template_pos = next;
1156 /* Append New Template list */
1157 const std::vector<TemplateData> template_list = input_template_get_list();
1160 if (template_list.size() > 0) {
1161 Elm_Genlist_Item_Class *itc;
1163 itc = elm_genlist_item_class_new();
1165 itc->item_style = "1text";
1166 itc->func.text_get = __ise_template_gl_text_get;
1167 itc->func.content_get = NULL;
1168 itc->func.state_get = NULL;
1169 itc->func.del = NULL;
1171 for (i = 0; i < template_list.size(); i++) {
1172 bool matched = false;
1174 if(!template_list[i].use_gettext) {
1175 int smartreply_len = 0;
1178 smartreply_len = input_smartreply_get_reply_num();
1179 for (j = 0; j < smartreply_len; j++) {
1182 reply = input_smartreply_get_nth_item(j);
1184 if (!strcmp(reply, template_list[i].text.c_str())) {
1194 if (matched == false) {
1195 pos = elm_genlist_item_insert_after(app_data->genlist,
1200 ELM_GENLIST_ITEM_NONE,
1201 __ise_template_gl_sel,
1207 elm_genlist_item_class_free(itc);
1211 // template add button (+)
1212 /* if (!input_template_is_user_template()) {
1213 Elm_Genlist_Item_Class *itc;
1215 itc = elm_genlist_item_class_new();
1217 itc->item_style = "1text.1icon";
1218 itc->func.text_get = __ise_addtemplate_gl_text_get;;
1219 itc->func.content_get = __ise_gl_1button_content_get;
1220 itc->func.state_get = NULL;
1221 itc->func.del = NULL;
1224 pos = elm_genlist_item_insert_after(app_data->genlist,
1229 ELM_GENLIST_ITEM_NONE,
1230 __ise_template_add_gl_sel,
1233 elm_genlist_item_class_free(itc);
1237 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1239 g_template_current_number = template_len;
1243 bool _app_create(void* user_data)
1245 int width = 1000, height = 1000;
1246 // App_Data* app_data = NULL;
1247 Evas_Object* layout = NULL;
1248 Evas_Object* conform = NULL;
1249 Evas_Object* bg = NULL;
1250 Evas_Object* window = NULL;
1251 Eext_Circle_Surface *surface;
1257 _app_language_changed(NULL, NULL);
1258 #ifdef SUPPORT_LOG_MANAGER
1262 app_data = (App_Data*)user_data;
1264 elm_app_base_scale_set(1.3);
1266 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1268 init_customizing_theme();
1270 elm_win_title_set(window, PACKAGE);
1271 elm_win_borderless_set(window, EINA_TRUE);
1272 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1273 evas_object_resize(window, width, height);
1274 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1276 LOGE("elm_win_add() is failed.");
1280 bg = elm_bg_add(window);
1281 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1282 elm_win_resize_object_add(window, bg);
1283 evas_object_show(bg);
1285 layout = elm_layout_add(window);
1286 elm_layout_theme_set(layout, "layout", "application", "default");
1287 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1289 conform = elm_conformant_add(window);
1290 surface = eext_circle_surface_conformant_add(conform);
1291 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1294 elm_win_resize_object_add(window, conform);
1295 elm_object_content_set(conform, layout);
1297 evas_object_show(layout);
1298 evas_object_show(conform);
1299 evas_object_show(window);
1300 app_data->win_main = window;
1301 app_data->conform = conform;
1302 app_data->layout_main = layout;
1303 app_data->circle_surface = surface;
1304 app_data->app_type = APP_TYPE_SELECT_MODE;
1306 Evas_Object *naviframe = elm_naviframe_add(layout);
1307 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1308 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1309 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1310 evas_object_show(naviframe);
1312 app_data->naviframe = naviframe;
1317 void _app_service(app_control_h service, void* user_data)
1321 char *context = NULL;
1322 char *app_id = NULL;
1324 app_control_clone(&(app_data->source_app_control), service);
1326 app_data->reply_type = REPLY_APP_NORMAL;
1327 ret = app_control_get_extra_data(service, "selector_keyboard_app_id", &app_id);
1328 if (ret == APP_CONTROL_ERROR_NONE) {
1329 PRINTFUNC(DLOG_DEBUG, "app_id = %s", app_id);
1333 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose") || !strcmp(app_id, "com.samsung.wemail-send")) {
1334 app_data->reply_type = REPLY_APP_CONTROL;
1336 app_data->reply_type = REPLY_APP_NORMAL;
1342 bool is_type_reply = false;
1343 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1344 if (ret == APP_CONTROL_ERROR_NONE) {
1345 if (!strcmp(context, "input_voice")) {
1346 app_data->app_type = APP_TYPE_STT;
1347 _stt_clicked_cb((void *)app_data, NULL, NULL);
1349 } else if (!strcmp(context, "input_emoticon")) {
1350 app_data->app_type = APP_TYPE_EMOTICON;
1351 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1353 } else if (!strcmp(context, "input_keyboard")) {
1354 app_data->app_type = APP_TYPE_KEYBOARD;
1355 input_keyboard_init(service);
1356 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1358 } else if (!strcmp(context, "keyboard_input_from_sms")) {
1359 app_data->app_type = APP_TYPE_KEYBOARD_FROM_SMS;
1360 input_keyboard_init(service);
1361 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1363 } else if (!strcmp(context, "input_reply")) {
1364 app_data->app_type = APP_TYPE_REPLY;
1365 is_type_reply = true;
1369 if (app_data->genlist == NULL)
1370 app_data->genlist = _create_genlist(app_data->naviframe);
1372 input_keyboard_init(service);
1374 // input_smartreply_init(service);
1375 // input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1377 // if (input_smartreply_is_enabled())
1378 // input_smartreply_get_reply_async();
1381 input_template_init(service);
1382 input_template_set_notify(_input_template_notify_cb, NULL);
1384 _create_genlist_items(app_data, is_type_reply);
1387 elm_win_activate(app_data->win_main);
1389 // app_control_request_transient_app(service, elm_win_xwindow_get(app_data->win_main), _app_control_request_transient_app_cb, NULL);
1395 void _app_pause(void* user_data)
1397 PRINTFUNC(DLOG_DEBUG, "");
1401 void _app_resume(void* user_data)
1403 PRINTFUNC(DLOG_DEBUG, "");
1406 void _app_terminate(void* user_data)
1408 App_Data* app_data = NULL;
1409 app_data = (App_Data*)user_data;
1411 if(app_data->genlist){
1412 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1415 if(app_data->res_path)
1416 free(app_data->res_path);
1418 if(app_data->shared_res_path)
1419 free(app_data->shared_res_path);
1421 input_keyboard_deinit();
1422 input_smartreply_deinit();
1424 input_template_unset_notify();
1425 input_template_deinit();
1427 #ifdef SUPPORT_LOG_MANAGER
1432 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1434 if (setlocale(LC_ALL, "") == NULL) {
1435 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1436 if (setlocale(LC_ALL, lang_str) == NULL)
1439 if (bindtextdomain(domain, dir) == NULL)
1441 if (textdomain(domain) == NULL)
1448 * @brief Set language and locale.
1452 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1454 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1456 setenv("LANG", lang_str, 1);
1457 setenv("LC_MESSAGES", lang_str, 1);
1459 setenv("LANG", "en_GB.utf8", 1);
1460 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1461 lang_str = strdup("en_GB.UTF-8");
1464 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1467 elm_language_set(lang_str);
1474 int main(int argc, char* argv[])
1476 App_Data app_data = {0, };
1477 ui_app_lifecycle_callback_s event_callback = {0, };
1478 app_event_handler_h handlers[5] = {NULL, };
1480 event_callback.create = _app_create;
1481 event_callback.terminate = _app_terminate;
1482 event_callback.pause = _app_pause;
1483 event_callback.resume = _app_resume;
1484 event_callback.app_control = _app_service;
1486 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1487 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1488 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1489 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1490 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1492 _init_app_data(&app_data);
1494 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1495 if (ret != APP_ERROR_NONE) {
1496 LOGD("ui_app_main() is failed. err = %d", ret);
1502 #ifdef SUPPORT_LOG_MANAGER
1503 static void log_manager_init(void)
1508 samsung_log_manager_create(&g_log_manager);
1511 static void log_manager_exit(void)
1513 samsung_log_manager_destroy(g_log_manager);
1514 g_log_manager = NULL;
1517 static void log_manager_set(const char *feature, const char *extra, const char *value)
1519 const char *uri = USE_APP_FEATURE_SURVEY_URI;
1521 unsigned int request_id;
1524 if (g_log_manager == NULL) {
1525 PRINTFUNC(DLOG_ERROR, "log manager doesn't initialized");
1529 if (feature == NULL) {
1530 PRINTFUNC(DLOG_ERROR, "feature is empty");
1534 log_data = bundle_create();
1536 bundle_add(log_data, "app_id", PACKAGE);
1537 bundle_add(log_data, "feature", feature);
1540 bundle_add(log_data, "extra", extra);
1542 bundle_add(log_data, "value", value);
1544 samsung_log_manager_insert(g_log_manager, uri, log_data, NULL, NULL, &request_id);
1546 bundle_free(log_data);