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.
24 #include <vconf-keys.h>
27 #include "w-input-selector.h"
28 #include "w-input-template.h"
29 #include "w-input-keyboard.h"
30 #include "w-input-stt-ise.h"
31 #include "w-input-emoticon.h"
32 #include "w-input-stt-tos.h"
39 App_Data* app_data = NULL;
41 InputKeyboardData g_input_keyboard_data;
42 InputTypeData g_input_type_data;
44 static Elm_Object_Item *it_empty;
45 static Elm_Object_Item *it_title;
47 static unsigned int g_template_item_size = 0; /* Current Template item size */
49 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
51 void _init_app_data(App_Data* app_data);
52 static void _app_language_changed(app_event_info_h event_info, void *user_data);
54 Evas_Object* _create_genlist(Evas_Object* parent);
55 void _create_genlist_items(void* user_data);
56 void _create_header_items(void *user_data);
57 void _update_genlist_items(void *user_data);
58 unsigned int _update_template_items(void *user_data);
59 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
60 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
61 static void input_type_deinit(void);
63 void _init_app_data(App_Data* app_data)
65 app_data->win_main = NULL;
66 app_data->layout_main = NULL;
67 app_data->conform = NULL;
68 app_data->naviframe = NULL;
69 app_data->genlist = NULL;
71 app_data->res_path = NULL;
74 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
80 window = elm_layout_add(parent);
82 ret = elm_layout_file_set(window, file, group);
84 evas_object_del(window);
88 content = elm_layout_add(parent);
89 elm_layout_theme_set(content, "layout", "application", "default");
90 elm_object_part_content_set(window, "elm.swallow.content", content);
92 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
97 void init_customizing_theme(void)
99 string stt_edj_path = get_resource_path();
100 string app_edj_path = get_resource_path();
102 stt_edj_path = stt_edj_path + STT_EDJ_FILE;
103 app_edj_path = app_edj_path + APP_EDJ_FILE;
105 elm_theme_extension_add(NULL, stt_edj_path.c_str());
106 elm_theme_extension_add(NULL, app_edj_path.c_str());
110 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
112 reply_to_sender_by_callback_for_back();
117 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
119 App_Data* ad = (App_Data*)data;
121 PRINTFUNC(DLOG_DEBUG, "");
127 bool bAgreed = false;
128 stt_get_user_agreement(&bAgreed);
131 if(is_tos_N66_agreed() == EINA_FALSE){
132 if(is_sap_connection() == EINA_TRUE){
133 ise_show_tos_n66_popup(ad);
135 launch_bt_connection_popup(ad);
138 ise_show_stt_popup(ad);
142 static void _input_template_notify_cb(void *user_data)
144 _update_genlist_items((void *)app_data);
147 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
149 App_Data* ad = (App_Data*)data;
151 PRINTFUNC(DLOG_DEBUG, "");
156 ise_show_emoticon_list(ad);
159 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
161 App_Data* ad = (App_Data *)data;
163 PRINTFUNC(DLOG_DEBUG, "");
168 input_keyboard_launch(ad->win_main, data);
171 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
173 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
177 elm_genlist_item_selected_set(item, EINA_FALSE);
179 index = (uintptr_t) elm_object_item_data_get(item);
180 const std::vector<TemplateData> template_list = input_template_get_list();
182 if (index < (int)template_list.size()) {
183 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
189 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
191 if(!strcmp(part, "elm.text")) {
192 unsigned int index = (uintptr_t)data;
193 const std::vector<TemplateData> template_list = input_template_get_list();
195 if(index < template_list.size()) {
196 if(template_list[index].use_gettext) {
197 return strdup(gettext(template_list[index].text.c_str()));
199 Eina_Strbuf *buf = NULL;
200 const char *str = NULL;
203 buf = eina_strbuf_new();
205 eina_strbuf_append(buf, template_list[index].text.c_str());
206 eina_strbuf_replace_all(buf, "\n", "");
207 eina_strbuf_replace_all(buf, "\r", "");
209 str = eina_strbuf_string_get(buf);
212 markup = elm_entry_utf8_to_markup(str);
214 eina_strbuf_free(buf);
223 static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj, const char *part)
225 char *first_input_type = *(g_input_type_data.input_type_array + 0);
226 char *second_input_type = *(g_input_type_data.input_type_array + 1);
228 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2"))) {
229 Evas_Object* btn = elm_button_add(obj);
230 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
231 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
233 Evas_Object* ic = elm_image_add(btn);
234 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
235 string path = get_resource_path();
236 if (!strcmp(part, "elm.icon.1")) {
238 if(!strcmp(first_input_type, "input_voice")) {
239 elm_object_style_set(btn, "ime_button_stt");
240 path_ic = path + "images/w_mode_stt_ic.png";
241 } else if (!strcmp(first_input_type, "input_emoticon")) {
242 elm_object_style_set(btn, "ime_button_emoticon");
243 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
244 } else if (!strcmp(first_input_type, "input_keyboard")) {
245 elm_object_style_set(btn, "ime_button_keyboard");
246 path_ic = path + "images/w_mode_keyboard_ic.png";
247 evas_object_propagate_events_set(btn, EINA_FALSE);
249 elm_image_file_set(ic, path_ic.c_str(), NULL);
250 elm_object_content_set(btn, ic);
251 evas_object_layer_set(btn, 32000);
252 } else if (!strcmp(part, "elm.icon.2")){
254 if(!strcmp(second_input_type, "input_voice")) {
255 elm_object_style_set(btn, "ime_button_stt");
256 path_ic = path + "images/w_mode_stt_ic.png";
257 } else if (!strcmp(second_input_type, "input_emoticon")) {
258 elm_object_style_set(btn, "ime_button_emoticon");
259 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
260 } else if (!strcmp(second_input_type, "input_keyboard")) {
261 elm_object_style_set(btn, "ime_button_keyboard");
262 path_ic = path + "images/w_mode_keyboard_ic.png";
263 evas_object_propagate_events_set(btn, EINA_FALSE);
265 elm_image_file_set(ic, path_ic.c_str(), NULL);
266 elm_object_content_set(btn, ic);
267 evas_object_layer_set(btn, 32000);
270 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area"))) {
271 Evas_Object* btn = elm_button_add(obj);
272 elm_object_style_set(btn, "touch_area");
273 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
274 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
275 string path = get_resource_path();
276 if (!strcmp(part, "elm.icon.1.touch_area")) {
277 evas_object_layer_set(btn, 32000);
278 if(!strcmp(first_input_type, "input_voice")) {
279 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
280 } else if (!strcmp(first_input_type, "input_emoticon")) {
281 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
282 } else if (!strcmp(first_input_type, "input_keyboard")) {
283 evas_object_propagate_events_set(btn, EINA_FALSE);
284 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
286 } else if (!strcmp(part, "elm.icon.2.touch_area")){
287 evas_object_layer_set(btn, 32000);
288 if(!strcmp(second_input_type, "input_voice")) {
289 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
290 } else if (!strcmp(second_input_type, "input_emoticon")) {
291 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
292 } else if (!strcmp(second_input_type, "input_keyboard")) {
293 evas_object_propagate_events_set(btn, EINA_FALSE);
294 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
298 } else if (!strcmp(part, "base")) {
299 Evas_Object* btn = elm_button_add(obj);
300 elm_object_style_set(btn, "ime_transparent");
306 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
308 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
309 Evas_Object* btn = elm_button_add(obj);
310 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
311 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
312 Evas_Object* ic = elm_image_add(btn);
313 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
314 string path = get_resource_path();
315 if (!strcmp(part, "elm.icon.1")) {
316 elm_object_style_set(btn, "ime_button_stt");
317 string path_ic = path + "images/w_mode_stt_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.2")){
323 elm_object_style_set(btn, "ime_button_emoticon");
324 string path_ic = path + "images/Delta_w_mode_emoticon_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);
329 } else if (!strcmp(part, "elm.icon.3")){
330 elm_object_style_set(btn, "ime_button_keyboard");
331 string path_ic = path + "images/w_mode_keyboard_ic.png";
332 elm_image_file_set(ic, path_ic.c_str(), NULL);
333 elm_object_content_set(btn, ic);
334 evas_object_layer_set(btn, 32000);
335 evas_object_propagate_events_set(btn, EINA_FALSE);
339 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
340 Evas_Object* btn = elm_button_add(obj);
341 elm_object_style_set(btn, "touch_area");
342 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
343 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
344 string path = get_resource_path();
345 if (!strcmp(part, "elm.icon.1.touch_area")) {
346 evas_object_layer_set(btn, 32000);
347 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
349 } else if (!strcmp(part, "elm.icon.2.touch_area")){
350 evas_object_layer_set(btn, 32000);
351 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
352 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
353 evas_object_layer_set(btn, 32000);
354 evas_object_propagate_events_set(btn, EINA_FALSE);
355 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
359 } else if (!strcmp(part, "base")) {
360 Evas_Object* btn = elm_button_add(obj);
361 elm_object_style_set(btn, "ime_transparent");
368 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
370 //Update genlist items. The Item texts will be translated in the _gl_text_get().
371 elm_genlist_realized_items_update(obj);
374 void set_source_caller_app_id(app_control_h app_control)
377 PRINTFUNC(DLOG_ERROR, "can't get app_control");
382 app_control_get_caller(app_data->source_app_control, &caller);
385 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
386 app_control_add_extra_data(app_control, "caller_appid", caller);
391 void reply_to_sender_by_callback(const char *value, const char *type)
393 PRINTFUNC(DLOG_DEBUG, "");
395 app_control_h app_control;
397 if(app_control_create(&app_control) == 0) {
401 app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, value);
404 app_control_add_extra_data(app_control, "reply_type", type);
406 set_source_caller_app_id(app_control);
408 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
409 if (ret != APP_CONTROL_ERROR_NONE)
410 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
412 app_control_destroy(app_control);
413 app_control_destroy(app_data->source_app_control);
414 app_data->source_app_control = NULL;
418 void reply_to_sender_by_callback_for_back()
420 PRINTFUNC(DLOG_DEBUG, "");
422 app_control_h app_control;
424 if(app_control_create(&app_control) == 0) {
427 app_control_add_extra_data(app_control, "back_to_composer", "yes");
429 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
430 if (ret != APP_CONTROL_ERROR_NONE)
431 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
433 app_control_destroy(app_control);
434 app_control_destroy(app_data->source_app_control);
435 app_data->source_app_control = NULL;
439 char* get_resource_path()
441 if(NULL == app_data->res_path) {
442 app_data->res_path = app_get_resource_path();
443 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
445 return (app_data->res_path);
448 char* get_shared_resource_path()
450 if(NULL == app_data->shared_res_path) {
451 app_data->shared_res_path = app_get_shared_resource_path();
452 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
454 return (app_data->shared_res_path);
457 void show_gl_focus(Eina_Bool bVisible){
458 if(app_data->genlist == NULL)
461 if(bVisible == EINA_TRUE){
462 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
463 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
464 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
466 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
467 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
468 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
472 void show_popup_toast(const char *text, bool check_img)
474 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
478 popup = elm_popup_add(app_data->win_main);
479 elm_object_style_set(popup, "toast/circle");
480 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
481 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
484 string path = get_resource_path();
485 string path_ic = path + "/images/toast_check_icon.png";
486 Evas_Object * img = elm_image_add(popup);
487 elm_image_file_set(img, path_ic.c_str(), NULL);
488 elm_object_part_content_set(popup, "toast,icon", img);
491 elm_object_part_text_set(popup, "elm.text", text);
494 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
495 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
496 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
498 elm_popup_timeout_set(popup, 2.0);
499 evas_object_show(popup);
502 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
505 evas_object_hide(obj);
506 evas_object_del(obj);
510 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
513 elm_popup_dismiss(obj);
517 void _back_to_genlist_for_selector()
519 PRINTFUNC(DLOG_DEBUG, "");
521 if(!app_data) return;
523 if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
524 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
525 reply_to_sender_by_callback(NULL, NULL);
529 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
531 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
534 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
536 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
539 Evas_Object* _create_genlist(Evas_Object* navi)
541 Evas_Object* genlist = elm_genlist_add(navi);
545 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
547 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
548 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
549 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
550 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
552 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
553 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
555 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
556 evas_object_show(genlist);
558 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
560 show_gl_focus(EINA_FALSE);
562 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
569 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
570 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
575 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
580 Evas_Object *genlist = (Evas_Object *)obj;
581 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
584 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
586 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
588 if (250 > y && y >= 100){
589 if (last_step == 0) return;
591 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
592 show_gl_focus(EINA_TRUE);
593 } else if (100 > y && y >= 50){
594 if (last_step == 1) return;
596 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
597 show_gl_focus(EINA_TRUE);
598 } else if (y < 50 && y >=0){
599 if (last_step == 2) return;
601 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
602 show_gl_focus(EINA_FALSE);
607 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
611 snprintf(buf, 1023, "%s", "Select method");
615 void _create_genlist_items(void* user_data)
617 App_Data* app_data = (App_Data*) user_data;
619 if(NULL == app_data->genlist) {
620 app_data->genlist = _create_genlist(app_data->naviframe);
621 if(NULL == app_data->genlist)
625 elm_genlist_clear(app_data->genlist);
627 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
628 itc0->item_style = "title";
629 itc0->func.text_get = _main_menu_title_text_get;
630 itc0->func.content_get = NULL;
631 itc0->func.state_get = NULL;
632 itc0->func.del = NULL;
634 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
635 if(g_input_type_data.input_type_array_len == 2){
636 itc1->item_style = "2button_flat";
637 itc1->func.text_get = NULL;
638 itc1->func.content_get = __ise_gl_2button_content_get;
639 itc1->func.state_get = NULL;
640 itc1->func.del = NULL;
642 itc1->item_style = "3button_flat";
643 itc1->func.text_get = NULL;
644 itc1->func.content_get = __ise_gl_3button_content_get;
645 itc1->func.state_get = NULL;
646 itc1->func.del = NULL;
649 // dummy title for empty space
650 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
652 ELM_GENLIST_ITEM_NONE,
656 it_title = elm_genlist_item_append(app_data->genlist, itc1,
658 ELM_GENLIST_ITEM_NONE,
661 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
663 g_template_item_size = _update_template_items(app_data);
665 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
666 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
668 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
670 elm_genlist_item_class_free(itc0);
671 elm_genlist_item_class_free(itc1);
674 void _create_header_items(void *user_data)
676 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
677 itc0->item_style = "title";
678 itc0->func.text_get = NULL;
679 itc0->func.content_get = NULL;
680 itc0->func.state_get = NULL;
681 itc0->func.del = NULL;
683 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
684 if (g_input_type_data.input_type_array_len == 2) {
685 itc1->item_style = "2button_flat";
686 itc1->func.text_get = NULL;
687 itc1->func.content_get = __ise_gl_2button_content_get;
688 itc1->func.state_get = NULL;
689 itc1->func.del = NULL;
691 itc1->item_style = "3button_flat";
692 itc1->func.text_get = NULL;
693 itc1->func.content_get = __ise_gl_3button_content_get;
694 itc1->func.state_get = NULL;
695 itc1->func.del = NULL;
698 // dummy title for empty space
699 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
701 ELM_GENLIST_ITEM_NONE,
705 it_title = elm_genlist_item_append(app_data->genlist, itc1,
707 ELM_GENLIST_ITEM_NONE,
710 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
712 elm_genlist_item_class_free(itc0);
713 elm_genlist_item_class_free(itc1);
716 void _update_genlist_items(void *user_data)
718 elm_genlist_clear(app_data->genlist);
720 _create_header_items(user_data);
722 g_template_item_size = _update_template_items(user_data);
724 /* Update genlist item position */
725 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
726 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
729 unsigned int _update_template_items(void *user_data)
733 Elm_Object_Item *first;
736 unsigned int item_size = 0;
738 app_data = (App_Data *)user_data;
740 if (app_data == NULL) {
741 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
745 if (app_data->genlist == NULL) {
746 /* smartreply will update when genlist is exist only */
747 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
751 first = elm_genlist_first_item_get(app_data->genlist);
754 elm_genlist_item_next_get(first);
756 /* Append New Template list */
757 const std::vector<TemplateData> template_list = input_template_get_list();
759 if (template_list.size() > 0) {
760 Elm_Genlist_Item_Class *itc;
762 itc = elm_genlist_item_class_new();
764 itc->item_style = "1text";
765 itc->func.text_get = __ise_template_gl_text_get;
766 itc->func.content_get = NULL;
767 itc->func.state_get = NULL;
768 itc->func.del = NULL;
770 for (i = 0; i < template_list.size(); i++) {
771 elm_genlist_item_append(app_data->genlist,
773 (void *)(uintptr_t)i,
775 ELM_GENLIST_ITEM_NONE,
776 __ise_template_gl_sel,
780 elm_genlist_item_class_free(itc);
786 bool _app_create(void* user_data)
788 int width = 1000, height = 1000;
789 // App_Data* app_data = NULL;
790 Evas_Object* layout = NULL;
791 Evas_Object* conform = NULL;
792 Evas_Object* bg = NULL;
793 Evas_Object* window = NULL;
794 Eext_Circle_Surface *surface;
800 _app_language_changed(NULL, NULL);
802 app_data = (App_Data*)user_data;
804 elm_app_base_scale_set(1.3);
806 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
808 init_customizing_theme();
810 elm_win_title_set(window, PACKAGE);
811 elm_win_borderless_set(window, EINA_TRUE);
812 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
813 evas_object_resize(window, width, height);
814 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
816 LOGE("elm_win_add() is failed.");
820 bg = elm_bg_add(window);
821 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
822 elm_win_resize_object_add(window, bg);
823 evas_object_show(bg);
825 layout = elm_layout_add(window);
826 elm_layout_theme_set(layout, "layout", "application", "default");
827 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
829 conform = elm_conformant_add(window);
830 surface = eext_circle_surface_conformant_add(conform);
831 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
834 elm_win_resize_object_add(window, conform);
835 elm_object_content_set(conform, layout);
837 evas_object_show(layout);
838 evas_object_show(conform);
839 evas_object_show(window);
840 app_data->win_main = window;
841 app_data->conform = conform;
842 app_data->layout_main = layout;
843 app_data->circle_surface = surface;
844 app_data->app_type = APP_TYPE_SELECT_MODE;
846 Evas_Object *naviframe = elm_naviframe_add(layout);
847 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
848 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
849 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
850 evas_object_show(naviframe);
852 app_data->naviframe = naviframe;
857 void _app_service(app_control_h service, void* user_data)
860 char *context = NULL;
861 char **input_type_array = NULL;
862 int input_type_array_len = -1;
863 bool is_extra_data_array = false;
865 app_control_clone(&(app_data->source_app_control), service);
866 app_data->reply_type = REPLY_APP_NORMAL;
868 ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
869 if( is_extra_data_array == true) {
870 ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
871 g_input_type_data.input_type_array = input_type_array;
872 g_input_type_data.input_type_array_len = input_type_array_len;
874 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
875 if (ret == APP_CONTROL_ERROR_NONE) {
876 if (!strcmp(context, "input_voice")) {
877 app_data->app_type = APP_TYPE_STT;
878 _stt_clicked_cb((void *)app_data, NULL, NULL);
880 } else if (!strcmp(context, "input_emoticon")) {
881 app_data->app_type = APP_TYPE_EMOTICON;
882 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
884 } else if (!strcmp(context, "input_keyboard")) {
885 app_data->app_type = APP_TYPE_KEYBOARD;
886 input_keyboard_init(service);
887 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
889 } else if (!strcmp(context, "input_reply")) {
890 app_data->app_type = APP_TYPE_REPLY;
895 if (app_data->genlist == NULL)
896 app_data->genlist = _create_genlist(app_data->naviframe);
898 input_keyboard_init(service);
900 input_template_init(service);
901 input_template_set_notify(_input_template_notify_cb, NULL);
903 _create_genlist_items(app_data);
906 elm_win_activate(app_data->win_main);
913 void _app_pause(void* user_data)
915 PRINTFUNC(DLOG_DEBUG, "");
919 void _app_resume(void* user_data)
921 PRINTFUNC(DLOG_DEBUG, "");
924 void _app_terminate(void* user_data)
926 App_Data* app_data = NULL;
927 app_data = (App_Data*)user_data;
929 if(app_data->genlist){
930 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
933 if(app_data->res_path)
934 free(app_data->res_path);
936 if(app_data->shared_res_path)
937 free(app_data->shared_res_path);
939 input_keyboard_deinit();
941 input_template_unset_notify();
942 input_template_deinit();
947 static int init_i18n(const char *domain, const char *dir, char *lang_str)
949 if (setlocale(LC_ALL, "") == NULL) {
950 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
951 if (setlocale(LC_ALL, lang_str) == NULL)
954 if (bindtextdomain(domain, dir) == NULL)
956 if (textdomain(domain) == NULL)
963 * @brief Set language and locale.
967 static void _app_language_changed(app_event_info_h event_info, void *user_data)
969 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
971 setenv("LANG", lang_str, 1);
972 setenv("LC_MESSAGES", lang_str, 1);
974 setenv("LANG", "en_GB.utf8", 1);
975 setenv("LC_MESSAGES", "en_GB.utf8", 1);
976 lang_str = strdup("en_GB.UTF-8");
979 init_i18n(PACKAGE, LOCALEDIR, lang_str);
982 elm_language_set(lang_str);
987 void input_type_deinit(void)
990 char **data_array = NULL;
992 data_array = g_input_type_data.input_type_array;
994 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
995 if (*(data_array + i))
996 free(*(data_array + i));
1000 g_input_type_data.input_type_array = NULL;
1001 g_input_type_data.input_type_array_len = 0;
1004 EXPORTED int main(int argc, char* argv[])
1006 App_Data app_data = {0, };
1007 ui_app_lifecycle_callback_s event_callback = {0, };
1008 app_event_handler_h handlers[5] = {NULL, };
1010 event_callback.create = _app_create;
1011 event_callback.terminate = _app_terminate;
1012 event_callback.pause = _app_pause;
1013 event_callback.resume = _app_resume;
1014 event_callback.app_control = _app_service;
1016 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1017 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1018 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1019 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1020 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1022 _init_app_data(&app_data);
1024 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1025 if (ret != APP_ERROR_NONE) {
1026 LOGD("ui_app_main() is failed. err = %d", ret);