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>
26 #include "w-input-selector.h"
27 #include "w-input-template.h"
28 #include "w-input-keyboard.h"
29 #include "w-input-stt-ise.h"
30 #include "w-input-emoticon.h"
31 #include "w-input-stt-tos.h"
38 App_Data* app_data = NULL;
40 InputKeyboardData g_input_keyboard_data;
41 InputTypeData g_input_type_data;
43 static Elm_Object_Item *it_empty;
44 static Elm_Object_Item *it_title;
46 static unsigned int g_template_item_size = 0; /* Current Template item size */
48 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
50 void _init_app_data(App_Data* app_data);
51 static void _app_language_changed(app_event_info_h event_info, void *user_data);
53 Evas_Object* _create_genlist(Evas_Object* parent);
54 void _create_genlist_items(void* user_data);
55 void _create_header_items(void *user_data);
56 void _update_genlist_items(void *user_data);
57 unsigned int _update_template_items(void *user_data);
58 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
59 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
60 static void input_type_deinit(void);
62 void _init_app_data(App_Data* app_data)
64 app_data->win_main = NULL;
65 app_data->layout_main = NULL;
66 app_data->conform = NULL;
67 app_data->naviframe = NULL;
68 app_data->genlist = NULL;
70 app_data->res_path = NULL;
73 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
79 window = elm_layout_add(parent);
81 ret = elm_layout_file_set(window, file, group);
83 evas_object_del(window);
87 content = elm_layout_add(parent);
88 elm_layout_theme_set(content, "layout", "application", "default");
89 elm_object_part_content_set(window, "elm.swallow.content", content);
91 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
96 void init_customizing_theme(void)
98 string stt_edj_path = get_resource_path();
99 string app_edj_path = get_resource_path();
101 stt_edj_path = stt_edj_path + STT_EDJ_FILE;
102 app_edj_path = app_edj_path + APP_EDJ_FILE;
104 elm_theme_extension_add(NULL, stt_edj_path.c_str());
105 elm_theme_extension_add(NULL, app_edj_path.c_str());
109 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
111 reply_to_sender_by_callback_for_back();
116 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
118 App_Data* ad = (App_Data*)data;
120 PRINTFUNC(DLOG_DEBUG, "");
126 bool bAgreed = false;
127 stt_get_user_agreement(&bAgreed);
130 if(is_tos_N66_agreed() == EINA_FALSE){
131 if(is_sap_connection() == EINA_TRUE){
132 ise_show_tos_n66_popup(ad);
134 launch_bt_connection_popup(ad);
137 ise_show_stt_popup(ad);
141 static void _input_template_notify_cb(void *user_data)
143 _update_genlist_items((void *)app_data);
146 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
148 App_Data* ad = (App_Data*)data;
150 PRINTFUNC(DLOG_DEBUG, "");
155 ise_show_emoticon_list(ad);
158 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
160 App_Data* ad = (App_Data *)data;
162 PRINTFUNC(DLOG_DEBUG, "");
167 input_keyboard_launch(ad->win_main, data);
170 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
172 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
176 elm_genlist_item_selected_set(item, EINA_FALSE);
178 index = (unsigned int) elm_object_item_data_get(item);
179 const std::vector<TemplateData> template_list = input_template_get_list();
181 if (index < (int)template_list.size()) {
182 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
188 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
190 if(!strcmp(part, "elm.text")) {
191 unsigned int index = (unsigned int)data;
192 const std::vector<TemplateData> template_list = input_template_get_list();
194 if(index < template_list.size()) {
195 if(template_list[index].use_gettext) {
196 return strdup(gettext(template_list[index].text.c_str()));
198 Eina_Strbuf *buf = NULL;
199 const char *str = NULL;
202 buf = eina_strbuf_new();
204 eina_strbuf_append(buf, template_list[index].text.c_str());
205 eina_strbuf_replace_all(buf, "\n", "");
206 eina_strbuf_replace_all(buf, "\r", "");
208 str = eina_strbuf_string_get(buf);
211 markup = elm_entry_utf8_to_markup(str);
213 eina_strbuf_free(buf);
222 static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj, const char *part)
224 char *first_input_type = *(g_input_type_data.input_type_array + 0);
225 char *second_input_type = *(g_input_type_data.input_type_array + 1);
227 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2"))) {
228 Evas_Object* btn = elm_button_add(obj);
229 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
230 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
232 Evas_Object* ic = elm_image_add(btn);
233 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
234 string path = get_resource_path();
235 if (!strcmp(part, "elm.icon.1")) {
237 if(!strcmp(first_input_type, "input_voice")) {
238 elm_object_style_set(btn, "ime_button_stt");
239 path_ic = path + "images/w_mode_stt_ic.png";
240 } else if (!strcmp(first_input_type, "input_emoticon")) {
241 elm_object_style_set(btn, "ime_button_emoticon");
242 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
243 } else if (!strcmp(first_input_type, "input_keyboard")) {
244 elm_object_style_set(btn, "ime_button_keyboard");
245 path_ic = path + "images/w_mode_keyboard_ic.png";
246 evas_object_propagate_events_set(btn, EINA_FALSE);
248 elm_image_file_set(ic, path_ic.c_str(), NULL);
249 elm_object_content_set(btn, ic);
250 evas_object_layer_set(btn, 32000);
251 } else if (!strcmp(part, "elm.icon.2")){
253 if(!strcmp(second_input_type, "input_voice")) {
254 elm_object_style_set(btn, "ime_button_stt");
255 path_ic = path + "images/w_mode_stt_ic.png";
256 } else if (!strcmp(second_input_type, "input_emoticon")) {
257 elm_object_style_set(btn, "ime_button_emoticon");
258 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
259 } else if (!strcmp(second_input_type, "input_keyboard")) {
260 elm_object_style_set(btn, "ime_button_keyboard");
261 path_ic = path + "images/w_mode_keyboard_ic.png";
262 evas_object_propagate_events_set(btn, EINA_FALSE);
264 elm_image_file_set(ic, path_ic.c_str(), NULL);
265 elm_object_content_set(btn, ic);
266 evas_object_layer_set(btn, 32000);
269 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area"))) {
270 Evas_Object* btn = elm_button_add(obj);
271 elm_object_style_set(btn, "touch_area");
272 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
273 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
274 string path = get_resource_path();
275 if (!strcmp(part, "elm.icon.1.touch_area")) {
276 evas_object_layer_set(btn, 32000);
277 if(!strcmp(first_input_type, "input_voice")) {
278 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
279 } else if (!strcmp(first_input_type, "input_emoticon")) {
280 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
281 } else if (!strcmp(first_input_type, "input_keyboard")) {
282 evas_object_propagate_events_set(btn, EINA_FALSE);
283 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
285 } else if (!strcmp(part, "elm.icon.2.touch_area")){
286 evas_object_layer_set(btn, 32000);
287 if(!strcmp(second_input_type, "input_voice")) {
288 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
289 } else if (!strcmp(second_input_type, "input_emoticon")) {
290 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
291 } else if (!strcmp(second_input_type, "input_keyboard")) {
292 evas_object_propagate_events_set(btn, EINA_FALSE);
293 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
297 } else if (!strcmp(part, "base")) {
298 Evas_Object* btn = elm_button_add(obj);
299 elm_object_style_set(btn, "ime_transparent");
305 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
307 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
308 Evas_Object* btn = elm_button_add(obj);
309 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
310 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
311 Evas_Object* ic = elm_image_add(btn);
312 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
313 string path = get_resource_path();
314 if (!strcmp(part, "elm.icon.1")) {
315 elm_object_style_set(btn, "ime_button_stt");
316 string path_ic = path + "images/w_mode_stt_ic.png";
317 elm_image_file_set(ic, path_ic.c_str(), NULL);
318 elm_object_content_set(btn, ic);
319 evas_object_layer_set(btn, 32000);
321 } else if (!strcmp(part, "elm.icon.2")){
322 elm_object_style_set(btn, "ime_button_emoticon");
323 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
324 elm_image_file_set(ic, path_ic.c_str(), NULL);
325 elm_object_content_set(btn, ic);
326 evas_object_layer_set(btn, 32000);
328 } else if (!strcmp(part, "elm.icon.3")){
329 elm_object_style_set(btn, "ime_button_keyboard");
330 string path_ic = path + "images/w_mode_keyboard_ic.png";
331 elm_image_file_set(ic, path_ic.c_str(), NULL);
332 elm_object_content_set(btn, ic);
333 evas_object_layer_set(btn, 32000);
334 evas_object_propagate_events_set(btn, EINA_FALSE);
338 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
339 Evas_Object* btn = elm_button_add(obj);
340 elm_object_style_set(btn, "touch_area");
341 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
342 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
343 string path = get_resource_path();
344 if (!strcmp(part, "elm.icon.1.touch_area")) {
345 evas_object_layer_set(btn, 32000);
346 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
348 } else if (!strcmp(part, "elm.icon.2.touch_area")){
349 evas_object_layer_set(btn, 32000);
350 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
351 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
352 evas_object_layer_set(btn, 32000);
353 evas_object_propagate_events_set(btn, EINA_FALSE);
354 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
358 } else if (!strcmp(part, "base")) {
359 Evas_Object* btn = elm_button_add(obj);
360 elm_object_style_set(btn, "ime_transparent");
367 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
369 //Update genlist items. The Item texts will be translated in the _gl_text_get().
370 elm_genlist_realized_items_update(obj);
373 void set_source_caller_app_id(app_control_h app_control)
376 PRINTFUNC(DLOG_ERROR, "can't get app_control");
381 app_control_get_caller(app_data->source_app_control, &caller);
384 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
385 app_control_add_extra_data(app_control, "caller_appid", caller);
390 void reply_to_sender_by_callback(const char *value, const char *type)
392 PRINTFUNC(DLOG_DEBUG, "");
394 app_control_h app_control;
396 if(app_control_create(&app_control) == 0) {
400 app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, value);
403 app_control_add_extra_data(app_control, "reply_type", type);
405 set_source_caller_app_id(app_control);
407 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
408 if (ret != APP_CONTROL_ERROR_NONE)
409 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
411 app_control_destroy(app_control);
412 app_control_destroy(app_data->source_app_control);
413 app_data->source_app_control = NULL;
417 void reply_to_sender_by_callback_for_back()
419 PRINTFUNC(DLOG_DEBUG, "");
421 app_control_h app_control;
423 if(app_control_create(&app_control) == 0) {
426 app_control_add_extra_data(app_control, "back_to_composer", "yes");
428 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
429 if (ret != APP_CONTROL_ERROR_NONE)
430 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
432 app_control_destroy(app_control);
433 app_control_destroy(app_data->source_app_control);
434 app_data->source_app_control = NULL;
438 char* get_resource_path()
440 if(NULL == app_data->res_path) {
441 app_data->res_path = app_get_resource_path();
442 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
444 return (app_data->res_path);
447 char* get_shared_resource_path()
449 if(NULL == app_data->shared_res_path) {
450 app_data->shared_res_path = app_get_shared_resource_path();
451 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
453 return (app_data->shared_res_path);
456 void show_gl_focus(Eina_Bool bVisible){
457 if(app_data->genlist == NULL)
460 if(bVisible == EINA_TRUE){
461 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
462 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
463 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
465 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
466 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
467 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
471 void show_popup_toast(const char *text, bool check_img)
473 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
477 popup = elm_popup_add(app_data->win_main);
478 elm_object_style_set(popup, "toast/circle");
479 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
480 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
483 string path = get_resource_path();
484 string path_ic = path + "/images/toast_check_icon.png";
485 Evas_Object * img = elm_image_add(popup);
486 elm_image_file_set(img, path_ic.c_str(), NULL);
487 elm_object_part_content_set(popup, "toast,icon", img);
490 elm_object_part_text_set(popup, "elm.text", text);
493 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
494 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
495 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
497 elm_popup_timeout_set(popup, 2.0);
498 evas_object_show(popup);
501 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
504 evas_object_hide(obj);
505 evas_object_del(obj);
509 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
512 elm_popup_dismiss(obj);
516 void _back_to_genlist_for_selector()
518 PRINTFUNC(DLOG_DEBUG, "");
520 if(!app_data) return;
522 if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
523 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
524 reply_to_sender_by_callback(NULL, NULL);
528 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
530 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
533 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
535 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
538 Evas_Object* _create_genlist(Evas_Object* navi)
540 Evas_Object* genlist = elm_genlist_add(navi);
544 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
546 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
547 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
548 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
549 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
551 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
552 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
554 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
555 evas_object_show(genlist);
557 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
559 show_gl_focus(EINA_FALSE);
561 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
568 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
569 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
574 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
579 Evas_Object *genlist = (Evas_Object *)obj;
580 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
583 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
585 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
587 if (250 > y && y >= 100){
588 if (last_step == 0) return;
590 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
591 show_gl_focus(EINA_TRUE);
592 } else if (100 > y && y >= 50){
593 if (last_step == 1) return;
595 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
596 show_gl_focus(EINA_TRUE);
597 } else if (y < 50 && y >=0){
598 if (last_step == 2) return;
600 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
601 show_gl_focus(EINA_FALSE);
606 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
610 snprintf(buf, 1023, "%s", "Select method");
614 void _create_genlist_items(void* user_data)
616 App_Data* app_data = (App_Data*) user_data;
618 if(NULL == app_data->genlist) {
619 app_data->genlist = _create_genlist(app_data->naviframe);
620 if(NULL == app_data->genlist)
624 elm_genlist_clear(app_data->genlist);
626 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
627 itc0->item_style = "title";
628 itc0->func.text_get = _main_menu_title_text_get;
629 itc0->func.content_get = NULL;
630 itc0->func.state_get = NULL;
631 itc0->func.del = NULL;
633 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
634 if(g_input_type_data.input_type_array_len == 2){
635 itc1->item_style = "2button_flat";
636 itc1->func.text_get = NULL;
637 itc1->func.content_get = __ise_gl_2button_content_get;
638 itc1->func.state_get = NULL;
639 itc1->func.del = NULL;
641 itc1->item_style = "3button_flat";
642 itc1->func.text_get = NULL;
643 itc1->func.content_get = __ise_gl_3button_content_get;
644 itc1->func.state_get = NULL;
645 itc1->func.del = NULL;
648 // dummy title for empty space
649 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
651 ELM_GENLIST_ITEM_NONE,
655 it_title = elm_genlist_item_append(app_data->genlist, itc1,
657 ELM_GENLIST_ITEM_NONE,
660 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
662 g_template_item_size = _update_template_items(app_data);
664 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
665 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
667 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
669 elm_genlist_item_class_free(itc0);
670 elm_genlist_item_class_free(itc1);
673 void _create_header_items(void *user_data)
675 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
676 itc0->item_style = "title";
677 itc0->func.text_get = NULL;
678 itc0->func.content_get = NULL;
679 itc0->func.state_get = NULL;
680 itc0->func.del = NULL;
682 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
683 if (g_input_type_data.input_type_array_len == 2) {
684 itc1->item_style = "2button_flat";
685 itc1->func.text_get = NULL;
686 itc1->func.content_get = __ise_gl_2button_content_get;
687 itc1->func.state_get = NULL;
688 itc1->func.del = NULL;
690 itc1->item_style = "3button_flat";
691 itc1->func.text_get = NULL;
692 itc1->func.content_get = __ise_gl_3button_content_get;
693 itc1->func.state_get = NULL;
694 itc1->func.del = NULL;
697 // dummy title for empty space
698 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
700 ELM_GENLIST_ITEM_NONE,
704 it_title = elm_genlist_item_append(app_data->genlist, itc1,
706 ELM_GENLIST_ITEM_NONE,
709 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
711 elm_genlist_item_class_free(itc0);
712 elm_genlist_item_class_free(itc1);
715 void _update_genlist_items(void *user_data)
717 elm_genlist_clear(app_data->genlist);
719 _create_header_items(user_data);
721 g_template_item_size = _update_template_items(user_data);
723 /* Update genlist item position */
724 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
725 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
728 unsigned int _update_template_items(void *user_data)
732 Elm_Object_Item *first;
735 unsigned int item_size = 0;
737 app_data = (App_Data *)user_data;
739 if (app_data == NULL) {
740 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
744 if (app_data->genlist == NULL) {
745 /* smartreply will update when genlist is exist only */
746 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
750 first = elm_genlist_first_item_get(app_data->genlist);
753 elm_genlist_item_next_get(first);
755 /* Append New Template list */
756 const std::vector<TemplateData> template_list = input_template_get_list();
758 if (template_list.size() > 0) {
759 Elm_Genlist_Item_Class *itc;
761 itc = elm_genlist_item_class_new();
763 itc->item_style = "1text";
764 itc->func.text_get = __ise_template_gl_text_get;
765 itc->func.content_get = NULL;
766 itc->func.state_get = NULL;
767 itc->func.del = NULL;
769 for (i = 0; i < template_list.size(); i++) {
770 elm_genlist_item_append(app_data->genlist,
774 ELM_GENLIST_ITEM_NONE,
775 __ise_template_gl_sel,
779 elm_genlist_item_class_free(itc);
785 bool _app_create(void* user_data)
787 int width = 1000, height = 1000;
788 // App_Data* app_data = NULL;
789 Evas_Object* layout = NULL;
790 Evas_Object* conform = NULL;
791 Evas_Object* bg = NULL;
792 Evas_Object* window = NULL;
793 Eext_Circle_Surface *surface;
799 _app_language_changed(NULL, NULL);
801 app_data = (App_Data*)user_data;
803 elm_app_base_scale_set(1.3);
805 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
807 init_customizing_theme();
809 elm_win_title_set(window, PACKAGE);
810 elm_win_borderless_set(window, EINA_TRUE);
811 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
812 evas_object_resize(window, width, height);
813 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
815 LOGE("elm_win_add() is failed.");
819 bg = elm_bg_add(window);
820 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
821 elm_win_resize_object_add(window, bg);
822 evas_object_show(bg);
824 layout = elm_layout_add(window);
825 elm_layout_theme_set(layout, "layout", "application", "default");
826 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
828 conform = elm_conformant_add(window);
829 surface = eext_circle_surface_conformant_add(conform);
830 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
833 elm_win_resize_object_add(window, conform);
834 elm_object_content_set(conform, layout);
836 evas_object_show(layout);
837 evas_object_show(conform);
838 evas_object_show(window);
839 app_data->win_main = window;
840 app_data->conform = conform;
841 app_data->layout_main = layout;
842 app_data->circle_surface = surface;
843 app_data->app_type = APP_TYPE_SELECT_MODE;
845 Evas_Object *naviframe = elm_naviframe_add(layout);
846 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
847 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
848 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
849 evas_object_show(naviframe);
851 app_data->naviframe = naviframe;
856 void _app_service(app_control_h service, void* user_data)
859 char *context = NULL;
860 char **input_type_array = NULL;
861 int input_type_array_len = -1;
862 bool is_extra_data_array = false;
864 app_control_clone(&(app_data->source_app_control), service);
865 app_data->reply_type = REPLY_APP_NORMAL;
867 ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
868 if( is_extra_data_array == true) {
869 ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
870 g_input_type_data.input_type_array = input_type_array;
871 g_input_type_data.input_type_array_len = input_type_array_len;
873 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
874 if (ret == APP_CONTROL_ERROR_NONE) {
875 if (!strcmp(context, "input_voice")) {
876 app_data->app_type = APP_TYPE_STT;
877 _stt_clicked_cb((void *)app_data, NULL, NULL);
879 } else if (!strcmp(context, "input_emoticon")) {
880 app_data->app_type = APP_TYPE_EMOTICON;
881 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
883 } else if (!strcmp(context, "input_keyboard")) {
884 app_data->app_type = APP_TYPE_KEYBOARD;
885 input_keyboard_init(service);
886 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
888 } else if (!strcmp(context, "input_reply")) {
889 app_data->app_type = APP_TYPE_REPLY;
894 if (app_data->genlist == NULL)
895 app_data->genlist = _create_genlist(app_data->naviframe);
897 input_keyboard_init(service);
899 input_template_init(service);
900 input_template_set_notify(_input_template_notify_cb, NULL);
902 _create_genlist_items(app_data);
905 elm_win_activate(app_data->win_main);
912 void _app_pause(void* user_data)
914 PRINTFUNC(DLOG_DEBUG, "");
918 void _app_resume(void* user_data)
920 PRINTFUNC(DLOG_DEBUG, "");
923 void _app_terminate(void* user_data)
925 App_Data* app_data = NULL;
926 app_data = (App_Data*)user_data;
928 if(app_data->genlist){
929 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
932 if(app_data->res_path)
933 free(app_data->res_path);
935 if(app_data->shared_res_path)
936 free(app_data->shared_res_path);
938 input_keyboard_deinit();
940 input_template_unset_notify();
941 input_template_deinit();
946 static int init_i18n(const char *domain, const char *dir, char *lang_str)
948 if (setlocale(LC_ALL, "") == NULL) {
949 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
950 if (setlocale(LC_ALL, lang_str) == NULL)
953 if (bindtextdomain(domain, dir) == NULL)
955 if (textdomain(domain) == NULL)
962 * @brief Set language and locale.
966 static void _app_language_changed(app_event_info_h event_info, void *user_data)
968 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
970 setenv("LANG", lang_str, 1);
971 setenv("LC_MESSAGES", lang_str, 1);
973 setenv("LANG", "en_GB.utf8", 1);
974 setenv("LC_MESSAGES", "en_GB.utf8", 1);
975 lang_str = strdup("en_GB.UTF-8");
978 init_i18n(PACKAGE, LOCALEDIR, lang_str);
981 elm_language_set(lang_str);
986 void input_type_deinit(void)
989 char **data_array = NULL;
991 data_array = g_input_type_data.input_type_array;
993 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
994 if (*(data_array + i))
995 free(*(data_array + i));
999 g_input_type_data.input_type_array = NULL;
1000 g_input_type_data.input_type_array_len = 0;
1003 int main(int argc, char* argv[])
1005 App_Data app_data = {0, };
1006 ui_app_lifecycle_callback_s event_callback = {0, };
1007 app_event_handler_h handlers[5] = {NULL, };
1009 event_callback.create = _app_create;
1010 event_callback.terminate = _app_terminate;
1011 event_callback.pause = _app_pause;
1012 event_callback.resume = _app_resume;
1013 event_callback.app_control = _app_service;
1015 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1016 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1017 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1018 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1019 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1021 _init_app_data(&app_data);
1023 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1024 if (ret != APP_ERROR_NONE) {
1025 LOGD("ui_app_main() is failed. err = %d", ret);