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 <system_info.h>
28 #include "w-input-selector.h"
29 #include "w-input-template.h"
30 #include "w-input-keyboard.h"
31 #include "w-input-stt-ise.h"
32 #include "w-input-emoticon.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 tizen_profile_t _get_tizen_profile()
53 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
54 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
58 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
63 profile = TIZEN_PROFILE_MOBILE;
67 profile = TIZEN_PROFILE_WEARABLE;
71 profile = TIZEN_PROFILE_TV;
75 profile = TIZEN_PROFILE_IVI;
77 default: // common or unknown ==> ALL ARE COMMON.
78 profile = TIZEN_PROFILE_COMMON;
86 void _init_app_data(App_Data* app_data);
87 static void _app_language_changed(app_event_info_h event_info, void *user_data);
89 Evas_Object* _create_genlist(Evas_Object* parent);
90 void _create_genlist_items(void* user_data);
91 void _create_header_items(void *user_data);
92 void _update_genlist_items(void *user_data);
93 unsigned int _update_template_items(void *user_data);
94 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
95 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
96 static void input_type_deinit(void);
98 void _init_app_data(App_Data* app_data)
100 app_data->win_main = NULL;
101 app_data->layout_main = NULL;
102 app_data->conform = NULL;
103 app_data->naviframe = NULL;
104 app_data->genlist = NULL;
106 app_data->res_path = NULL;
109 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
112 Evas_Object* content;
115 window = elm_layout_add(parent);
117 ret = elm_layout_file_set(window, file, group);
119 evas_object_del(window);
123 content = elm_layout_add(parent);
124 elm_layout_theme_set(content, "layout", "application", "default");
125 elm_object_part_content_set(window, "elm.swallow.content", content);
127 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
132 void init_customizing_theme(void)
134 string stt_edj_path = get_resource_path();
135 string app_edj_path = get_resource_path();
138 stt_edj_path = stt_edj_path + STT_EDJ_FILE_WEARABLE;
139 app_edj_path = app_edj_path + APP_EDJ_FILE_WEARABLE;
140 } else if (_MOBILE) {
141 stt_edj_path = stt_edj_path + STT_EDJ_FILE_MOBILE;
142 app_edj_path = app_edj_path + APP_EDJ_FILE_MOBILE;
145 elm_theme_extension_add(NULL, stt_edj_path.c_str());
146 elm_theme_extension_add(NULL, app_edj_path.c_str());
150 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
152 reply_to_sender_by_callback_for_back();
157 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
159 App_Data* ad = (App_Data*)data;
161 PRINTFUNC(DLOG_DEBUG, "");
166 ise_show_stt_popup(ad);
169 static void _input_template_notify_cb(void *user_data)
171 _update_genlist_items((void *)app_data);
174 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
176 App_Data* ad = (App_Data*)data;
178 PRINTFUNC(DLOG_DEBUG, "");
183 ise_show_emoticon_list(ad);
186 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
188 App_Data* ad = (App_Data *)data;
190 PRINTFUNC(DLOG_DEBUG, "");
195 input_keyboard_launch(ad->win_main, data);
198 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
200 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
204 elm_genlist_item_selected_set(item, EINA_FALSE);
206 index = (uintptr_t) elm_object_item_data_get(item);
207 const std::vector<TemplateData> template_list = input_template_get_list();
209 if (index < (int)template_list.size()) {
210 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
216 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
218 if (!strcmp(part, "elm.text")) {
219 unsigned int index = (uintptr_t)data;
220 const std::vector<TemplateData> template_list = input_template_get_list();
222 if (index < template_list.size()) {
223 if (template_list[index].use_gettext) {
224 return strdup(gettext(template_list[index].text.c_str()));
226 Eina_Strbuf *buf = NULL;
227 const char *str = NULL;
230 buf = eina_strbuf_new();
232 eina_strbuf_append(buf, template_list[index].text.c_str());
233 eina_strbuf_replace_all(buf, "\n", "");
234 eina_strbuf_replace_all(buf, "\r", "");
236 str = eina_strbuf_string_get(buf);
239 markup = elm_entry_utf8_to_markup(str);
241 eina_strbuf_free(buf);
250 static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj, const char *part)
252 char *first_input_type = *(g_input_type_data.input_type_array + 0);
253 char *second_input_type = *(g_input_type_data.input_type_array + 1);
255 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2"))) {
256 Evas_Object* btn = elm_button_add(obj);
257 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
258 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
260 Evas_Object* ic = elm_image_add(btn);
261 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
262 string path = get_resource_path();
264 path = path + "wearable/";
266 path = path + "mobile/";
268 if (!strcmp(part, "elm.icon.1")) {
270 if (!strcmp(first_input_type, "input_voice")) {
271 elm_object_style_set(btn, "ime_button_stt");
272 path_ic = path + "images/w_mode_stt_ic.png";
273 } else if (!strcmp(first_input_type, "input_emoticon")) {
274 elm_object_style_set(btn, "ime_button_emoticon");
275 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
276 } else if (!strcmp(first_input_type, "input_keyboard")) {
277 elm_object_style_set(btn, "ime_button_keyboard");
278 path_ic = path + "images/w_mode_keyboard_ic.png";
279 evas_object_propagate_events_set(btn, EINA_FALSE);
281 elm_image_file_set(ic, path_ic.c_str(), NULL);
282 elm_object_content_set(btn, ic);
283 evas_object_layer_set(btn, 32000);
284 } else if (!strcmp(part, "elm.icon.2")){
286 if (!strcmp(second_input_type, "input_voice")) {
287 elm_object_style_set(btn, "ime_button_stt");
288 path_ic = path + "images/w_mode_stt_ic.png";
289 } else if (!strcmp(second_input_type, "input_emoticon")) {
290 elm_object_style_set(btn, "ime_button_emoticon");
291 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
292 } else if (!strcmp(second_input_type, "input_keyboard")) {
293 elm_object_style_set(btn, "ime_button_keyboard");
294 path_ic = path + "images/w_mode_keyboard_ic.png";
295 evas_object_propagate_events_set(btn, EINA_FALSE);
297 elm_image_file_set(ic, path_ic.c_str(), NULL);
298 elm_object_content_set(btn, ic);
299 evas_object_layer_set(btn, 32000);
302 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area"))) {
303 Evas_Object* btn = elm_button_add(obj);
304 elm_object_style_set(btn, "touch_area");
305 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
306 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
307 string path = get_resource_path();
308 if (!strcmp(part, "elm.icon.1.touch_area")) {
309 evas_object_layer_set(btn, 32000);
310 if (!strcmp(first_input_type, "input_voice")) {
311 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
312 } else if (!strcmp(first_input_type, "input_emoticon")) {
313 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
314 } else if (!strcmp(first_input_type, "input_keyboard")) {
315 evas_object_propagate_events_set(btn, EINA_FALSE);
316 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
318 } else if (!strcmp(part, "elm.icon.2.touch_area")){
319 evas_object_layer_set(btn, 32000);
320 if (!strcmp(second_input_type, "input_voice")) {
321 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
322 } else if (!strcmp(second_input_type, "input_emoticon")) {
323 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
324 } else if (!strcmp(second_input_type, "input_keyboard")) {
325 evas_object_propagate_events_set(btn, EINA_FALSE);
326 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
330 } else if (!strcmp(part, "base")) {
331 Evas_Object* btn = elm_button_add(obj);
332 elm_object_style_set(btn, "ime_transparent");
338 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
340 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
341 Evas_Object* btn = elm_button_add(obj);
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 Evas_Object* ic = elm_image_add(btn);
345 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
346 string path = get_resource_path();
348 path = path + "wearable/";
350 path = path + "mobile/";
352 if (!strcmp(part, "elm.icon.1")) {
353 elm_object_style_set(btn, "ime_button_stt");
354 string path_ic = path + "images/w_mode_stt_ic.png";
355 elm_image_file_set(ic, path_ic.c_str(), NULL);
356 elm_object_content_set(btn, ic);
357 evas_object_layer_set(btn, 32000);
359 } else if (!strcmp(part, "elm.icon.2")){
360 elm_object_style_set(btn, "ime_button_emoticon");
361 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
362 elm_image_file_set(ic, path_ic.c_str(), NULL);
363 elm_object_content_set(btn, ic);
364 evas_object_layer_set(btn, 32000);
366 } else if (!strcmp(part, "elm.icon.3")){
367 elm_object_style_set(btn, "ime_button_keyboard");
368 string path_ic = path + "images/w_mode_keyboard_ic.png";
369 elm_image_file_set(ic, path_ic.c_str(), NULL);
370 elm_object_content_set(btn, ic);
371 evas_object_layer_set(btn, 32000);
372 evas_object_propagate_events_set(btn, EINA_FALSE);
376 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
377 Evas_Object* btn = elm_button_add(obj);
378 elm_object_style_set(btn, "touch_area");
379 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
380 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
381 string path = get_resource_path();
382 if (!strcmp(part, "elm.icon.1.touch_area")) {
383 evas_object_layer_set(btn, 32000);
384 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
386 } else if (!strcmp(part, "elm.icon.2.touch_area")){
387 evas_object_layer_set(btn, 32000);
388 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
389 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
390 evas_object_layer_set(btn, 32000);
391 evas_object_propagate_events_set(btn, EINA_FALSE);
392 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
396 } else if (!strcmp(part, "base")) {
397 Evas_Object* btn = elm_button_add(obj);
398 elm_object_style_set(btn, "ime_transparent");
405 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
407 //Update genlist items. The Item texts will be translated in the _gl_text_get().
408 elm_genlist_realized_items_update(obj);
411 void set_source_caller_app_id(app_control_h app_control)
414 PRINTFUNC(DLOG_ERROR, "can't get app_control");
419 app_control_get_caller(app_data->source_app_control, &caller);
422 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
423 app_control_add_extra_data(app_control, "caller_appid", caller);
428 void reply_to_sender_by_callback(const char *value, const char *type)
430 PRINTFUNC(DLOG_DEBUG, "");
432 app_control_h app_control;
434 if (app_control_create(&app_control) == 0) {
438 app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, value);
441 app_control_add_extra_data(app_control, "reply_type", type);
443 set_source_caller_app_id(app_control);
445 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
446 if (ret != APP_CONTROL_ERROR_NONE)
447 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
449 app_control_destroy(app_control);
450 app_control_destroy(app_data->source_app_control);
451 app_data->source_app_control = NULL;
455 void reply_to_sender_by_callback_for_back()
457 PRINTFUNC(DLOG_DEBUG, "");
459 app_control_h app_control;
461 if (app_control_create(&app_control) == 0) {
464 app_control_add_extra_data(app_control, "back_to_composer", "yes");
466 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
467 if (ret != APP_CONTROL_ERROR_NONE)
468 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
470 app_control_destroy(app_control);
471 app_control_destroy(app_data->source_app_control);
472 app_data->source_app_control = NULL;
476 char* get_resource_path()
478 if (NULL == app_data->res_path) {
479 app_data->res_path = app_get_resource_path();
480 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
482 return (app_data->res_path);
485 char* get_shared_resource_path()
487 if (NULL == app_data->shared_res_path) {
488 app_data->shared_res_path = app_get_shared_resource_path();
489 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
491 return (app_data->shared_res_path);
494 void show_gl_focus(Eina_Bool bVisible){
495 if (app_data->genlist == NULL)
498 if (bVisible == EINA_TRUE){
499 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
500 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
501 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
503 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
504 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
505 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
509 void show_popup_toast(const char *text, bool check_img)
511 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
515 popup = elm_popup_add(app_data->win_main);
516 elm_object_style_set(popup, "toast/circle");
517 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
518 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
521 string path = get_resource_path();
523 path = path + "wearable/";
525 path = path + "mobile/";
526 string path_ic = path + "/images/toast_check_icon.png";
527 Evas_Object * img = elm_image_add(popup);
528 elm_image_file_set(img, path_ic.c_str(), NULL);
529 elm_object_part_content_set(popup, "toast,icon", img);
532 elm_object_part_text_set(popup, "elm.text", text);
535 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
536 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
537 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
539 elm_popup_timeout_set(popup, 2.0);
540 evas_object_show(popup);
543 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
546 evas_object_hide(obj);
547 evas_object_del(obj);
551 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
554 elm_popup_dismiss(obj);
558 void _back_to_genlist_for_selector()
560 PRINTFUNC(DLOG_DEBUG, "");
562 if (!app_data) return;
564 if (app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
565 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
566 reply_to_sender_by_callback(NULL, NULL);
570 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
571 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
575 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
577 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
580 Evas_Object* _create_genlist(Evas_Object* navi)
582 Evas_Object* genlist = elm_genlist_add(navi);
586 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
588 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
589 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
590 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
591 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
593 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
594 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
596 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
597 evas_object_show(genlist);
599 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
601 show_gl_focus(EINA_FALSE);
603 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
610 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
611 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
616 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
621 Evas_Object *genlist = (Evas_Object *)obj;
622 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
625 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
627 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
629 if (250 > y && y >= 100){
630 if (last_step == 0) return;
632 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
633 show_gl_focus(EINA_TRUE);
634 } else if (100 > y && y >= 50){
635 if (last_step == 1) return;
637 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
638 show_gl_focus(EINA_TRUE);
639 } else if (y < 50 && y >=0){
640 if (last_step == 2) return;
642 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
643 show_gl_focus(EINA_FALSE);
648 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
652 snprintf(buf, 1023, "%s", "Select method");
656 void _create_genlist_items(void* user_data)
658 App_Data* app_data = (App_Data*) user_data;
660 if (NULL == app_data->genlist) {
661 app_data->genlist = _create_genlist(app_data->naviframe);
662 if (NULL == app_data->genlist)
666 elm_genlist_clear(app_data->genlist);
668 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
669 itc0->item_style = "title";
670 itc0->func.text_get = _main_menu_title_text_get;
671 itc0->func.content_get = NULL;
672 itc0->func.state_get = NULL;
673 itc0->func.del = NULL;
675 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
676 if (g_input_type_data.input_type_array_len == 2){
677 itc1->item_style = "2button_flat";
678 itc1->func.text_get = NULL;
679 itc1->func.content_get = __ise_gl_2button_content_get;
680 itc1->func.state_get = NULL;
681 itc1->func.del = NULL;
683 itc1->item_style = "3button_flat";
684 itc1->func.text_get = NULL;
685 itc1->func.content_get = __ise_gl_3button_content_get;
686 itc1->func.state_get = NULL;
687 itc1->func.del = NULL;
690 // dummy title for empty space
691 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
693 ELM_GENLIST_ITEM_NONE,
697 it_title = elm_genlist_item_append(app_data->genlist, itc1,
699 ELM_GENLIST_ITEM_NONE,
702 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
704 g_template_item_size = _update_template_items(app_data);
706 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
707 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
709 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
711 elm_genlist_item_class_free(itc0);
712 elm_genlist_item_class_free(itc1);
715 void _create_header_items(void *user_data)
717 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
718 itc0->item_style = "title";
719 itc0->func.text_get = NULL;
720 itc0->func.content_get = NULL;
721 itc0->func.state_get = NULL;
722 itc0->func.del = NULL;
724 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
725 if (g_input_type_data.input_type_array_len == 2) {
726 itc1->item_style = "2button_flat";
727 itc1->func.text_get = NULL;
728 itc1->func.content_get = __ise_gl_2button_content_get;
729 itc1->func.state_get = NULL;
730 itc1->func.del = NULL;
732 itc1->item_style = "3button_flat";
733 itc1->func.text_get = NULL;
734 itc1->func.content_get = __ise_gl_3button_content_get;
735 itc1->func.state_get = NULL;
736 itc1->func.del = NULL;
739 // dummy title for empty space
740 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
742 ELM_GENLIST_ITEM_NONE,
746 it_title = elm_genlist_item_append(app_data->genlist, itc1,
748 ELM_GENLIST_ITEM_NONE,
751 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
753 elm_genlist_item_class_free(itc0);
754 elm_genlist_item_class_free(itc1);
757 void _update_genlist_items(void *user_data)
759 elm_genlist_clear(app_data->genlist);
761 _create_header_items(user_data);
763 g_template_item_size = _update_template_items(user_data);
765 /* Update genlist item position */
766 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
767 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
770 unsigned int _update_template_items(void *user_data)
774 Elm_Object_Item *first;
777 unsigned int item_size = 0;
779 app_data = (App_Data *)user_data;
781 if (app_data == NULL) {
782 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
786 if (app_data->genlist == NULL) {
787 /* smartreply will update when genlist is exist only */
788 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
792 first = elm_genlist_first_item_get(app_data->genlist);
795 elm_genlist_item_next_get(first);
797 /* Append New Template list */
798 const std::vector<TemplateData> template_list = input_template_get_list();
800 if (template_list.size() > 0) {
801 Elm_Genlist_Item_Class *itc;
803 itc = elm_genlist_item_class_new();
805 itc->item_style = "1text";
806 itc->func.text_get = __ise_template_gl_text_get;
807 itc->func.content_get = NULL;
808 itc->func.state_get = NULL;
809 itc->func.del = NULL;
811 for (i = 0; i < template_list.size(); i++) {
812 elm_genlist_item_append(app_data->genlist,
814 (void *)(uintptr_t)i,
816 ELM_GENLIST_ITEM_NONE,
817 __ise_template_gl_sel,
821 elm_genlist_item_class_free(itc);
827 bool _app_create(void* user_data)
829 int width = 1000, height = 1000;
830 // App_Data* app_data = NULL;
831 Evas_Object* layout = NULL;
832 Evas_Object* conform = NULL;
833 Evas_Object* bg = NULL;
834 Evas_Object* window = NULL;
836 Eext_Circle_Surface *surface;
842 _app_language_changed(NULL, NULL);
844 app_data = (App_Data*)user_data;
846 elm_app_base_scale_set(1.3);
848 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
850 init_customizing_theme();
852 elm_win_title_set(window, PACKAGE);
853 elm_win_borderless_set(window, EINA_TRUE);
854 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
855 evas_object_resize(window, width, height);
856 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
858 LOGE("elm_win_add() is failed.");
862 bg = elm_bg_add(window);
863 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
864 elm_win_resize_object_add(window, bg);
865 evas_object_show(bg);
867 layout = elm_layout_add(window);
868 elm_layout_theme_set(layout, "layout", "application", "default");
869 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
871 conform = elm_conformant_add(window);
873 surface = eext_circle_surface_conformant_add(conform);
875 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
878 elm_win_resize_object_add(window, conform);
879 elm_object_content_set(conform, layout);
881 evas_object_show(layout);
882 evas_object_show(conform);
883 evas_object_show(window);
884 app_data->win_main = window;
885 app_data->conform = conform;
886 app_data->layout_main = layout;
888 app_data->circle_surface = surface;
890 app_data->app_type = APP_TYPE_SELECT_MODE;
892 Evas_Object *naviframe = elm_naviframe_add(layout);
893 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
894 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
895 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
896 evas_object_show(naviframe);
898 app_data->naviframe = naviframe;
903 void _app_service(app_control_h service, void* user_data)
906 char *context = NULL;
907 char **input_type_array = NULL;
908 int input_type_array_len = -1;
909 bool is_extra_data_array = false;
911 app_control_clone(&(app_data->source_app_control), service);
912 app_data->reply_type = REPLY_APP_NORMAL;
914 ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
915 if ( is_extra_data_array == true) {
916 ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
917 g_input_type_data.input_type_array = input_type_array;
918 g_input_type_data.input_type_array_len = input_type_array_len;
920 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
921 if (ret == APP_CONTROL_ERROR_NONE) {
922 if (!strcmp(context, "input_voice")) {
923 app_data->app_type = APP_TYPE_STT;
924 _stt_clicked_cb((void *)app_data, NULL, NULL);
926 } else if (!strcmp(context, "input_emoticon")) {
927 app_data->app_type = APP_TYPE_EMOTICON;
928 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
930 } else if (!strcmp(context, "input_keyboard")) {
931 app_data->app_type = APP_TYPE_KEYBOARD;
932 input_keyboard_init(service);
933 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
935 } else if (!strcmp(context, "input_reply")) {
936 app_data->app_type = APP_TYPE_REPLY;
941 if (app_data->genlist == NULL)
942 app_data->genlist = _create_genlist(app_data->naviframe);
944 input_keyboard_init(service);
946 input_template_init(service);
947 input_template_set_notify(_input_template_notify_cb, NULL);
949 _create_genlist_items(app_data);
952 elm_win_activate(app_data->win_main);
959 void _app_pause(void* user_data)
961 PRINTFUNC(DLOG_DEBUG, "");
965 void _app_resume(void* user_data)
967 PRINTFUNC(DLOG_DEBUG, "");
970 void _app_terminate(void* user_data)
972 App_Data* app_data = NULL;
973 app_data = (App_Data*)user_data;
975 if (app_data->genlist){
976 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
979 if (app_data->res_path)
980 free(app_data->res_path);
982 if (app_data->shared_res_path)
983 free(app_data->shared_res_path);
985 input_keyboard_deinit();
987 input_template_unset_notify();
988 input_template_deinit();
993 static int init_i18n(const char *domain, const char *dir, char *lang_str)
995 if (setlocale(LC_ALL, "") == NULL) {
996 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
997 if (setlocale(LC_ALL, lang_str) == NULL)
1000 if (bindtextdomain(domain, dir) == NULL)
1002 if (textdomain(domain) == NULL)
1009 * @brief Set language and locale.
1013 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1015 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1017 setenv("LANG", lang_str, 1);
1018 setenv("LC_MESSAGES", lang_str, 1);
1020 setenv("LANG", "en_GB.utf8", 1);
1021 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1022 lang_str = strdup("en_GB.UTF-8");
1025 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1028 elm_language_set(lang_str);
1033 void input_type_deinit(void)
1036 char **data_array = NULL;
1038 data_array = g_input_type_data.input_type_array;
1040 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
1041 if (*(data_array + i))
1042 free(*(data_array + i));
1046 g_input_type_data.input_type_array = NULL;
1047 g_input_type_data.input_type_array_len = 0;
1050 EXPORTED int main(int argc, char* argv[])
1052 App_Data app_data = {0, };
1053 ui_app_lifecycle_callback_s event_callback = {0, };
1054 app_event_handler_h handlers[5] = {NULL, };
1056 event_callback.create = _app_create;
1057 event_callback.terminate = _app_terminate;
1058 event_callback.pause = _app_pause;
1059 event_callback.resume = _app_resume;
1060 event_callback.app_control = _app_service;
1062 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1063 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1064 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1065 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1066 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1068 _init_app_data(&app_data);
1070 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1071 if (ret != APP_ERROR_NONE) {
1072 LOGD("ui_app_main() is failed. err = %d", ret);