Support screen reader
[platform/core/uifw/inputdelegator.git] / src / w-input-selector.cpp
index 61a55cb..51a15af 100755 (executable)
 #include <string>
 #include <vconf.h>
 #include <vconf-keys.h>
+#include <stdint.h>
+#include <system_info.h>
 
 #include "w-input-selector.h"
 #include "w-input-template.h"
 #include "w-input-keyboard.h"
 #include "w-input-stt-ise.h"
 #include "w-input-emoticon.h"
-#include "w-input-stt-tos.h"
+#include "w-input-smartreply.h"
 
 #include <stt.h>
 
@@ -43,10 +45,45 @@ InputTypeData g_input_type_data;
 static Elm_Object_Item *it_empty;
 static Elm_Object_Item *it_title;
 
+static unsigned int g_smartreply_item_size = 0;                /* Current Smartreply item size */
 static unsigned int g_template_item_size = 0;          /* Current Template item size */
 
 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
 
+tizen_profile_t _get_tizen_profile()
+{
+       static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+       if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+               return profile;
+
+       char *profileName;
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+       switch (*profileName)
+       {
+               case 'm':
+               case 'M':
+                       profile = TIZEN_PROFILE_MOBILE;
+                       break;
+               case 'w':
+               case 'W':
+                       profile = TIZEN_PROFILE_WEARABLE;
+                       break;
+               case 't':
+               case 'T':
+                       profile = TIZEN_PROFILE_TV;
+                       break;
+               case 'i':
+               case 'I':
+                       profile = TIZEN_PROFILE_IVI;
+                       break;
+               default: // common or unknown ==> ALL ARE COMMON.
+                       profile = TIZEN_PROFILE_COMMON;
+       }
+       free(profileName);
+
+       return profile;
+}
+
 void _init_app_data(App_Data* app_data);
 static void _app_language_changed(app_event_info_h event_info, void *user_data);
 
@@ -54,11 +91,14 @@ Evas_Object* _create_genlist(Evas_Object* parent);
 void _create_genlist_items(void* user_data);
 void _create_header_items(void *user_data);
 void _update_genlist_items(void *user_data);
+unsigned int _update_smartreply_items(void *user_data);
 unsigned int _update_template_items(void *user_data);
 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
 static void input_type_deinit(void);
 
+bool __compare_string(const char * src, const char * dst);
+
 void _init_app_data(App_Data* app_data)
 {
        app_data->win_main = NULL;
@@ -98,8 +138,16 @@ void init_customizing_theme(void)
        string stt_edj_path = get_resource_path();
        string app_edj_path = get_resource_path();
 
-       stt_edj_path = stt_edj_path + STT_EDJ_FILE;
-       app_edj_path = app_edj_path + APP_EDJ_FILE;
+       if (_WEARABLE) {
+               stt_edj_path = stt_edj_path + STT_EDJ_FILE_WEARABLE;
+               app_edj_path = app_edj_path + APP_EDJ_FILE_WEARABLE;
+       } else if (_TV) {
+               stt_edj_path = stt_edj_path + STT_EDJ_FILE_TV;
+               app_edj_path = app_edj_path + APP_EDJ_FILE_TV;
+       } else {
+               stt_edj_path = stt_edj_path + STT_EDJ_FILE_MOBILE;
+               app_edj_path = app_edj_path + APP_EDJ_FILE_MOBILE;
+       }
 
        elm_theme_extension_add(NULL, stt_edj_path.c_str());
        elm_theme_extension_add(NULL, app_edj_path.c_str());
@@ -109,7 +157,7 @@ void init_customizing_theme(void)
 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
 {
        reply_to_sender_by_callback_for_back();
-       elm_exit();
+       ui_app_exit();
        return EINA_FALSE;
 }
 
@@ -119,23 +167,16 @@ static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
 
        PRINTFUNC(DLOG_DEBUG, "");
 
-       if(!ad)
+       if (!ad)
                return;
 
-#if 0
-       bool bAgreed = false;
-       stt_get_user_agreement(&bAgreed);
-       if(!bAgreed){
-#endif
-       if(is_tos_N66_agreed() == EINA_FALSE){
-               if(is_sap_connection() == EINA_TRUE){
-                       ise_show_tos_n66_popup(ad);
-               } else {
-                       launch_bt_connection_popup(ad);
-               }
-       } else {
-               ise_show_stt_popup(ad);
-       }
+       ise_show_stt_popup(ad);
+}
+
+static void _input_smartreply_notify_cb(void *user_data)
+{
+       ecore_main_loop_iterate();
+       _update_genlist_items((void *)app_data);
 }
 
 static void _input_template_notify_cb(void *user_data)
@@ -149,7 +190,7 @@ static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info
 
        PRINTFUNC(DLOG_DEBUG, "");
 
-       if(!ad)
+       if (!ad)
                return;
 
        ise_show_emoticon_list(ad);
@@ -167,6 +208,26 @@ static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info
        input_keyboard_launch(ad->win_main, data);
 }
 
+static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
+{
+       Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+
+       if (item) {
+               elm_genlist_item_selected_set(item, EINA_FALSE);
+
+               int index = (intptr_t) elm_object_item_data_get(item);
+
+               int type;
+               char *reply = input_smartreply_get_nth_item(index, &type);
+               if (reply) {
+                       input_smartreply_send_feedback(reply);
+                       reply_to_sender_by_callback(reply, "smartreply", NULL, NULL);
+                       free(reply);
+                       elm_exit();
+               }
+       }
+}
+
 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
 {
        Elm_Object_Item *item = (Elm_Object_Item *) event_info;
@@ -175,24 +236,24 @@ static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info
        if (item) {
                elm_genlist_item_selected_set(item, EINA_FALSE);
 
-               index = (unsigned int) elm_object_item_data_get(item);
+               index = (uintptr_t) elm_object_item_data_get(item);
                const std::vector<TemplateData>  template_list = input_template_get_list();
 
                if (index < (int)template_list.size()) {
-                       reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
-                       elm_exit();
+                       reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template", NULL, NULL);
+                       ui_app_exit();
                }
        }
 }
 
 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
 {
-       if(!strcmp(part, "elm.text")) {
-               unsigned int index = (unsigned int)data;
+       if (!strcmp(part, "elm.text")) {
+               unsigned int index = (uintptr_t)data;
                const std::vector<TemplateData>  template_list = input_template_get_list();
 
-               if(index < template_list.size()) {
-                       if(template_list[index].use_gettext) {
+               if (index < template_list.size()) {
+                       if (template_list[index].use_gettext) {
                                return strdup(gettext(template_list[index].text.c_str()));
                        } else {
                                Eina_Strbuf *buf = NULL;
@@ -200,7 +261,7 @@ static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const cha
                                char *markup = NULL;
 
                                buf = eina_strbuf_new();
-                               if(buf) {
+                               if (buf) {
                                        eina_strbuf_append(buf, template_list[index].text.c_str());
                                        eina_strbuf_replace_all(buf, "\n", "");
                                        eina_strbuf_replace_all(buf, "\r", "");
@@ -232,34 +293,59 @@ static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj,
                Evas_Object* ic = elm_image_add(btn);
                elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
                string path = get_resource_path();
+               if (_WEARABLE)
+                       path = path + "wearable/";
+               else if (_TV)
+                       path = path + "tv/";
+               else
+                       path = path + "mobile/";
+
                if (!strcmp(part, "elm.icon.1")) {
                        string path_ic;
-                       if(!strcmp(first_input_type, "input_voice")) {
+                       if (!strcmp(first_input_type, "input_voice")) {
                                elm_object_style_set(btn, "ime_button_stt");
                                path_ic = path + "images/w_mode_stt_ic.png";
+                               evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        } else if (!strcmp(first_input_type, "input_emoticon")) {
                                elm_object_style_set(btn, "ime_button_emoticon");
                                path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
+                               evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        } else if (!strcmp(first_input_type, "input_keyboard")) {
                                elm_object_style_set(btn, "ime_button_keyboard");
                                path_ic = path + "images/w_mode_keyboard_ic.png";
                                evas_object_propagate_events_set(btn, EINA_FALSE);
+                               evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        }
                        elm_image_file_set(ic, path_ic.c_str(), NULL);
                        elm_object_content_set(btn, ic);
                        evas_object_layer_set(btn, 32000);
                } else if (!strcmp(part, "elm.icon.2")){
                        string path_ic;
-                       if(!strcmp(second_input_type, "input_voice")) {
+                       if (!strcmp(second_input_type, "input_voice")) {
                                elm_object_style_set(btn, "ime_button_stt");
                                path_ic = path + "images/w_mode_stt_ic.png";
+                               evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        } else if (!strcmp(second_input_type, "input_emoticon")) {
                                elm_object_style_set(btn, "ime_button_emoticon");
                                path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
+                               evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        } else if (!strcmp(second_input_type, "input_keyboard")) {
                                elm_object_style_set(btn, "ime_button_keyboard");
                                path_ic = path + "images/w_mode_keyboard_ic.png";
                                evas_object_propagate_events_set(btn, EINA_FALSE);
+                               evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        }
                        elm_image_file_set(ic, path_ic.c_str(), NULL);
                        elm_object_content_set(btn, ic);
@@ -274,23 +360,35 @@ static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj,
                string path = get_resource_path();
                if (!strcmp(part, "elm.icon.1.touch_area")) {
                        evas_object_layer_set(btn, 32000);
-                       if(!strcmp(first_input_type, "input_voice")) {
+                       if (!strcmp(first_input_type, "input_voice")) {
                                evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        } else if (!strcmp(first_input_type, "input_emoticon")) {
                                evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        } else if (!strcmp(first_input_type, "input_keyboard")) {
                                evas_object_propagate_events_set(btn, EINA_FALSE);
                                evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        }
                } else if (!strcmp(part, "elm.icon.2.touch_area")){
                        evas_object_layer_set(btn, 32000);
-                       if(!strcmp(second_input_type, "input_voice")) {
+                       if (!strcmp(second_input_type, "input_voice")) {
                                evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        } else if (!strcmp(second_input_type, "input_emoticon")) {
                                evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        } else if (!strcmp(second_input_type, "input_keyboard")) {
                                evas_object_propagate_events_set(btn, EINA_FALSE);
                                evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
+                               elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
+                               elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                        }
                }
                return btn;
@@ -311,12 +409,22 @@ static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj,
                Evas_Object* ic = elm_image_add(btn);
                elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
                string path = get_resource_path();
+               if (_WEARABLE)
+                       path = path + "wearable/";
+               else if (_TV)
+                       path = path + "tv/";
+               else
+                       path = path + "mobile/";
+
                if (!strcmp(part, "elm.icon.1")) {
                        elm_object_style_set(btn, "ime_button_stt");
                        string path_ic = path + "images/w_mode_stt_ic.png";
                        elm_image_file_set(ic, path_ic.c_str(), NULL);
                        elm_object_content_set(btn, ic);
                        evas_object_layer_set(btn, 32000);
+                       evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
+                       elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
+                       elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
 
                } else if (!strcmp(part, "elm.icon.2")){
                        elm_object_style_set(btn, "ime_button_emoticon");
@@ -324,6 +432,9 @@ static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj,
                        elm_image_file_set(ic, path_ic.c_str(), NULL);
                        elm_object_content_set(btn, ic);
                        evas_object_layer_set(btn, 32000);
+                       evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
+                       elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
+                       elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
 
                } else if (!strcmp(part, "elm.icon.3")){
                        elm_object_style_set(btn, "ime_button_keyboard");
@@ -332,6 +443,9 @@ static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj,
                        elm_object_content_set(btn, ic);
                        evas_object_layer_set(btn, 32000);
                        evas_object_propagate_events_set(btn, EINA_FALSE);
+                       evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
+                       elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
+                       elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                }
 
                return btn;
@@ -344,14 +458,20 @@ static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj,
                if (!strcmp(part, "elm.icon.1.touch_area")) {
                        evas_object_layer_set(btn, 32000);
                        evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
+                       elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
+                       elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
 
                } else if (!strcmp(part, "elm.icon.2.touch_area")){
                        evas_object_layer_set(btn, 32000);
                        evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
+                       elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
+                       elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                } else if (!strcmp(part, "elm.icon.3.touch_area")) {
                        evas_object_layer_set(btn, 32000);
                        evas_object_propagate_events_set(btn, EINA_FALSE);
                        evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
+                       elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
+                       elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
                }
 
                return btn;
@@ -363,6 +483,23 @@ static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj,
        return NULL;
 }
 
+static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
+{
+       if(!strcmp(part, "elm.text")) {
+               int index;
+               char *reply = NULL;
+               index = (intptr_t)data;
+               if (index < 0)
+                       return NULL;
+
+               reply = input_smartreply_get_nth_item(index, NULL);
+               if (reply == NULL)
+                       return NULL;
+
+               return reply;
+       }
+       return NULL;
+}
 
 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
 {
@@ -370,9 +507,42 @@ static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info
        elm_genlist_realized_items_update(obj);
 }
 
+static char * __ise_drawing_text_get(void *data, Evas_Object *obj, const char *part)
+{
+       if(!strcmp(part, "elm.text")) {
+               return(strdup(gettext("WDS_IME_MBODY_DRAWING_M_EMOTICON_ABB")));
+       }
+       return NULL;
+}
+
+static Evas_Object * __ise_drawing_content_get(void *data, Evas_Object *obj, const char *part)
+{
+       if (!strcmp(part, "elm.icon")) {
+               Evas_Object* btn = elm_button_add(obj);
+               evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               Evas_Object* ic = elm_image_add(btn);
+               elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
+               string path = get_resource_path();
+               if (_WEARABLE)
+                       path = path + "wearable/";
+               else if (_TV)
+                       path = path + "tv/";
+               else
+                       path = path + "mobile/";
+               elm_object_style_set(btn, "ime_button_drawing");
+               string path_ic = path + "images/wi_drawing_icon.png";
+               elm_image_file_set(ic, path_ic.c_str(), NULL);
+               elm_object_content_set(btn, ic);
+               evas_object_layer_set(btn, 32000);
+               return btn;
+       }
+       return NULL;
+}
+
 void set_source_caller_app_id(app_control_h app_control)
 {
-       if(!app_control){
+       if (!app_control){
                PRINTFUNC(DLOG_ERROR, "can't get app_control");
                return;
        }
@@ -380,20 +550,20 @@ void set_source_caller_app_id(app_control_h app_control)
        char *caller = NULL;
        app_control_get_caller(app_data->source_app_control, &caller);
 
-       if(caller){
+       if (caller){
                PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
                app_control_add_extra_data(app_control, "caller_appid", caller);
                free(caller);
        }
 }
 
-void reply_to_sender_by_callback(const char *value, const char *type)
+void reply_to_sender_by_callback(const char *value, const char *type, const char *path[], const char *cursor_position)
 {
        PRINTFUNC(DLOG_DEBUG, "");
 
        app_control_h app_control;
 
-       if(app_control_create(&app_control) == 0) {
+       if (app_control_create(&app_control) == 0) {
                int ret;
 
                if (value)
@@ -402,6 +572,13 @@ void reply_to_sender_by_callback(const char *value, const char *type)
                if (type)
                        app_control_add_extra_data(app_control, "reply_type", type);
 
+               if (path != NULL) {
+                       app_control_add_extra_data_array(app_control, APP_CONTROL_DATA_PATH, path, 1);
+               }
+
+               if (cursor_position != NULL)
+                       app_control_add_extra_data(app_control, "cursor_position_get", cursor_position);
+
                set_source_caller_app_id(app_control);
 
                ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
@@ -420,7 +597,7 @@ void reply_to_sender_by_callback_for_back()
 
        app_control_h app_control;
 
-       if(app_control_create(&app_control) == 0) {
+       if (app_control_create(&app_control) == 0) {
                int ret;
 
                app_control_add_extra_data(app_control, "back_to_composer", "yes");
@@ -437,7 +614,7 @@ void reply_to_sender_by_callback_for_back()
 
 char* get_resource_path()
 {
-       if(NULL == app_data->res_path) {
+       if (NULL == app_data->res_path) {
                app_data->res_path = app_get_resource_path();
                PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
        }
@@ -446,7 +623,7 @@ char* get_resource_path()
 
 char* get_shared_resource_path()
 {
-       if(NULL == app_data->shared_res_path) {
+       if (NULL == app_data->shared_res_path) {
                app_data->shared_res_path = app_get_shared_resource_path();
                PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
        }
@@ -454,10 +631,10 @@ char* get_shared_resource_path()
 }
 
 void show_gl_focus(Eina_Bool bVisible){
-       if(app_data->genlist == NULL)
+       if (app_data->genlist == NULL)
                return;
 
-       if(bVisible == EINA_TRUE){
+       if (bVisible == EINA_TRUE){
                elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
                //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
                //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
@@ -481,12 +658,18 @@ void show_popup_toast(const char *text, bool check_img)
 
        if (check_img) {
                string path = get_resource_path();
+               if (_WEARABLE)
+                       path = path + "wearable/";
+               else if (_TV)
+                       path = path + "tv/";
+               else
+                       path = path + "mobile/";
                string path_ic = path + "/images/toast_check_icon.png";
                Evas_Object * img = elm_image_add(popup);
                elm_image_file_set(img, path_ic.c_str(), NULL);
                elm_object_part_content_set(popup, "toast,icon", img);
        }
-       if(text) {
+       if (text) {
                elm_object_part_text_set(popup, "elm.text", text);
        }
 
@@ -500,7 +683,7 @@ void show_popup_toast(const char *text, bool check_img)
 
 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       if(obj){
+       if (obj){
                evas_object_hide(obj);
                evas_object_del(obj);
        }
@@ -508,7 +691,7 @@ static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
 
 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       if(obj)
+       if (obj)
                elm_popup_dismiss(obj);
 }
 
@@ -517,17 +700,17 @@ void _back_to_genlist_for_selector()
 {
        PRINTFUNC(DLOG_DEBUG, "");
 
-       if(!app_data) return;
+       if (!app_data) return;
 
-       if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
-               PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
-               reply_to_sender_by_callback(NULL, NULL);
-               elm_exit();
+       if (_WEARABLE) {
+               Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
+               eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
+       }
+       if (app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON || app_data->app_type == APP_TYPE_KEYBOARD){
+               PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON/KEYBOARD mode, So exit here.");
+               reply_to_sender_by_callback(NULL, NULL, NULL, NULL);
+               ui_app_exit();
        }
-
-       Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
-
-       eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
 }
 
 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
@@ -538,16 +721,16 @@ static void _item_realized(void *data, Evas_Object *obj, void *event_info) //cal
 Evas_Object* _create_genlist(Evas_Object* navi)
 {
        Evas_Object* genlist = elm_genlist_add(navi);
-       if(NULL == genlist)
+       if (NULL == genlist)
                return NULL;
 
        elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
-
-       Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
-       eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
-       evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
-       eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
-
+       if (_WEARABLE) {
+               Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
+               eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
+               evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
+               eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
+       }
        evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
 
@@ -558,12 +741,15 @@ Evas_Object* _create_genlist(Evas_Object* navi)
 
        show_gl_focus(EINA_FALSE);
 
+       const char *item_style = NULL;
+       if (_WEARABLE)
+               item_style = "empty";
        Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
             NULL,
             NULL,
             NULL,
             genlist,
-            "empty");
+            item_style);
 
        elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
        evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
@@ -573,8 +759,8 @@ Evas_Object* _create_genlist(Evas_Object* navi)
 
 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       if(!obj) return;
-       if(!data) return;
+       if (!obj) return;
+       if (!data) return;
 
        Evas_Object *genlist = (Evas_Object *)obj;
        Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
@@ -602,36 +788,27 @@ static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_
        }
 }
 
-static char *
-_main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
-{
-       char buf[1024];
-
-       snprintf(buf, 1023, "%s", "Select method");
-       return strdup(buf);
-}
-
 void _create_genlist_items(void* user_data)
 {
        App_Data* app_data = (App_Data*) user_data;
 
-       if(NULL == app_data->genlist) {
+       if (NULL == app_data->genlist) {
                app_data->genlist = _create_genlist(app_data->naviframe);
-               if(NULL == app_data->genlist)
+               if (NULL == app_data->genlist)
                return;
        }
 
        elm_genlist_clear(app_data->genlist);
 
        Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
-       itc0->item_style = "title";
-       itc0->func.text_get = _main_menu_title_text_get;
+       itc0->item_style = NULL;
+       itc0->func.text_get = NULL;
        itc0->func.content_get = NULL;
        itc0->func.state_get = NULL;
        itc0->func.del = NULL;
 
        Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
-       if(g_input_type_data.input_type_array_len == 2){
+       if (g_input_type_data.input_type_array_len == 2){
                itc1->item_style = "2button_flat";
                itc1->func.text_get = NULL;
                itc1->func.content_get = __ise_gl_2button_content_get;
@@ -718,6 +895,11 @@ void _update_genlist_items(void *user_data)
 
        _create_header_items(user_data);
 
+       if (input_smartreply_is_enabled())
+               g_smartreply_item_size = _update_smartreply_items(user_data);
+       else
+               g_smartreply_item_size = 0;
+
        g_template_item_size = _update_template_items(user_data);
 
        /* Update genlist item position */
@@ -725,11 +907,115 @@ void _update_genlist_items(void *user_data)
        elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
 }
 
+unsigned int _update_smartreply_items(void *user_data)
+{
+       App_Data* app_data;
+
+       Elm_Object_Item *first;
+
+       unsigned int i = 0;
+       unsigned int len = 0;
+       unsigned int item_size = 0;
+
+       app_data = (App_Data *)user_data;
+
+       if (app_data == NULL) {
+               PRINTFUNC(DLOG_ERROR, "Can not get app_data");
+               return item_size;
+       }
+
+       if (app_data->genlist == NULL) {
+               /* smartreply will update when genlist is exist only */
+               PRINTFUNC(DLOG_ERROR, "Can not get getlist");
+               return item_size;
+       }
+
+       /* Move to smartreply */
+       first = elm_genlist_first_item_get(app_data->genlist);
+       elm_genlist_item_next_get(first);
+
+       if (input_smartreply_is_enabled() == false)
+               return item_size;
+
+       /* Append newly added smartreply list */
+       len = input_smartreply_get_reply_num();
+
+       if (len > 0) {
+               const std::vector<TemplateData>  template_list = input_template_get_list();
+
+               Elm_Genlist_Item_Class *itc;
+
+               itc = elm_genlist_item_class_new();
+               itc->item_style = "1text";
+               itc->func.text_get = __ise_smartreply_gl_text_get;
+               itc->func.content_get = NULL;
+               itc->func.state_get = NULL;
+               itc->func.del = NULL;
+
+               for (i = 0; i < len; i++) {
+                       char *reply = (char *)"hello";
+                       unsigned int j;
+                       bool matched;
+
+                       matched = false;
+
+                       int type;
+                       reply = input_smartreply_get_nth_item(i, &type);
+                       if (reply == NULL)
+                               continue;
+                       SECURE_LOGD("SmartReply = [%d]%s", i, reply);
+
+                       for (j = 0; j < template_list.size(); j++) {
+                               const char *template_str;
+
+                               if (template_list[j].use_gettext)
+                                       template_str = gettext(template_list[j].text.c_str());
+                               else
+                                       template_str = template_list[j].text.c_str();
+
+                               if (!__compare_string(reply, template_str)) {
+                                       matched = true;
+                                       break;
+                               }
+                       }
+
+                       if (matched == true)
+                               continue;
+
+                       elm_genlist_item_append(app_data->genlist,
+                                               itc,
+                                               (void *)(uintptr_t)i,
+                                               NULL,
+                                               ELM_GENLIST_ITEM_NONE,
+                                               __ise_smartreply_gl_sel,
+                                               app_data);
+
+                       item_size++;
+                       if (item_size >= 3)
+                               break;
+               }
+               elm_genlist_item_class_free(itc);
+       }
+       return item_size;
+}
+
+static void _drawing_item_clicked_cb(void *data, Evas_Object * obj, void *event_info)
+{
+       PRINTFUNC(DLOG_DEBUG, "%s", __func__);
+       App_Data* ad = (App_Data*) data;
+       if (!ad)
+               return;
+
+       launch_drawing_app(ad);
+}
+
 unsigned int _update_template_items(void *user_data)
 {
        App_Data* app_data;
 
        Elm_Object_Item *first;
+       Elm_Object_Item *menu;
+       Elm_Object_Item *pos;
 
        unsigned int i = 0;
        unsigned int item_size = 0;
@@ -750,7 +1036,20 @@ unsigned int _update_template_items(void *user_data)
        first = elm_genlist_first_item_get(app_data->genlist);
        if (first == NULL)
                return 0;
-       elm_genlist_item_next_get(first);
+       menu = elm_genlist_item_next_get(first);
+
+       pos = menu;
+       /* move to smartreply next if it need */
+       if (input_smartreply_is_enabled()) {
+               unsigned int j = 0;
+
+               for (j = 0; j < g_smartreply_item_size; j++) {
+                       if (pos == NULL)
+                               break;
+
+                       pos = elm_genlist_item_next_get(pos);
+               }
+       }
 
        /* Append New Template list */
        const std::vector<TemplateData> template_list = input_template_get_list();
@@ -767,9 +1066,9 @@ unsigned int _update_template_items(void *user_data)
                itc->func.del = NULL;
 
                for (i = 0; i < template_list.size(); i++) {
-                       elm_genlist_item_append(app_data->genlist,
+                       pos = elm_genlist_item_append(app_data->genlist,
                                        itc,
-                                       (void *)i,
+                                       (void *)(uintptr_t)i,
                                        NULL,
                                        ELM_GENLIST_ITEM_NONE,
                                        __ise_template_gl_sel,
@@ -777,11 +1076,75 @@ unsigned int _update_template_items(void *user_data)
                        item_size++;
                }
                elm_genlist_item_class_free(itc);
+
+               // drawing button (+)
+               if (app_data->mime_type == MIME_TYPE_ALL) {
+                       Elm_Genlist_Item_Class *itc;
+                       itc = elm_genlist_item_class_new();
+
+                       itc->item_style = "1text.1icon";
+                       itc->func.text_get = __ise_drawing_text_get;;
+                       itc->func.content_get = __ise_drawing_content_get;
+                       itc->func.state_get = NULL;
+                       itc->func.del = NULL;
+
+                       elm_genlist_item_append(app_data->genlist,
+                                       itc,
+                                       NULL,
+                                       NULL,
+                                       ELM_GENLIST_ITEM_NONE,
+                                       _drawing_item_clicked_cb,
+                                       app_data);
+
+                       elm_genlist_item_class_free(itc);
+               }
+
+               // dummy item for empty space
+               Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
+               itc0->item_style = "title";
+               itc0->func.text_get = NULL;
+               itc0->func.content_get = NULL;
+               itc0->func.state_get = NULL;
+               itc0->func.del = NULL;
+
+               it_empty = elm_genlist_item_append(app_data->genlist, itc0,
+                               NULL, NULL,
+                               ELM_GENLIST_ITEM_NONE,
+                               NULL, NULL);
+               elm_genlist_item_class_free(itc0);
        }
 
        return item_size;
 }
 
+bool __compare_string(const char * smart_str, const char * template_str)
+{
+       int src_len = 0;
+       int dst_len = 0;
+       bool ret = true;
+
+       if(!smart_str||!template_str)
+               return ret;
+
+       src_len = strlen(smart_str);
+       dst_len = strlen(template_str);
+
+       if(smart_str[src_len-1] == '.')
+               src_len--;
+
+       while(template_str[dst_len-1] == ' ')
+               dst_len--;
+       if(template_str[dst_len-1] == '.')
+               dst_len--;
+
+       dst_len = (dst_len > src_len)? dst_len : src_len;
+
+       if(!strncmp(smart_str, template_str, (size_t)dst_len))
+               ret = false;
+
+       return (ret);
+}
+
 bool _app_create(void* user_data)
 {
        int width = 1000, height = 1000;
@@ -790,7 +1153,7 @@ bool _app_create(void* user_data)
        Evas_Object* conform = NULL;
        Evas_Object* bg = NULL;
        Evas_Object* window = NULL;
-       Eext_Circle_Surface *surface;
+       Eext_Circle_Surface *surface = NULL;
 
        if (!user_data) {
                return false;
@@ -826,9 +1189,10 @@ bool _app_create(void* user_data)
        evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
        conform = elm_conformant_add(window);
-       surface = eext_circle_surface_conformant_add(conform);
-       evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       if (_WEARABLE)
+               surface = eext_circle_surface_conformant_add(conform);
 
+       evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
        elm_win_resize_object_add(window, conform);
        elm_object_content_set(conform, layout);
@@ -860,12 +1224,49 @@ void _app_service(app_control_h service, void* user_data)
        char **input_type_array = NULL;
        int input_type_array_len = -1;
        bool is_extra_data_array = false;
+       char *mime_type = NULL;
 
        app_control_clone(&(app_data->source_app_control), service);
        app_data->reply_type = REPLY_APP_NORMAL;
+       app_data->mime_type = MIME_TYPE_ALL;
+
+       ret = app_control_get_mime(service, &mime_type);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               LOGD("Fail to get mime type : %d", ret);
+       } else {
+               if (mime_type) {
+                       LOGD("mime type = %s", mime_type);
+                       if (!strncmp(mime_type, "image/", strlen("image/"))) {
+                               app_data->mime_type = MIME_TYPE_IMAGE;
+                               app_data->app_type = APP_TYPE_DRAWING;
+                               launch_drawing_app((void *)app_data);
+                               if (mime_type)
+                                       free(mime_type);
+                               goto ACTIVATE;
+                       } else if (!strncmp(mime_type, "audio/", strlen("audio/"))) {
+                               app_data->mime_type = MIME_TYPE_AUDIO;
+                               app_data->app_type = APP_TYPE_STT;
+                               _stt_clicked_cb((void *)app_data, NULL, NULL);
+                               if (mime_type)
+                                       free(mime_type);
+                               goto ACTIVATE;
+                       } else if (!strncmp(mime_type, "text/", strlen("text/"))) {
+                               app_data->mime_type = MIME_TYPE_TEXT;
+                       }
+               }
+       }
+       if (mime_type)
+               free(mime_type);
+
+       if (_TV || _MOBILE) {
+               app_data->app_type = APP_TYPE_KEYBOARD;
+               input_keyboard_init(service);
+               _keyboard_clicked_cb((void *)app_data, NULL, NULL);
+               goto ACTIVATE;
+       }
 
        ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
-       if( is_extra_data_array == true) {
+       if ( is_extra_data_array == true) {
                ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
                g_input_type_data.input_type_array = input_type_array;
                g_input_type_data.input_type_array_len = input_type_array_len;
@@ -896,6 +1297,12 @@ void _app_service(app_control_h service, void* user_data)
 
        input_keyboard_init(service);
 
+       input_smartreply_init(service);
+       input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
+
+       if (input_smartreply_is_enabled())
+               input_smartreply_get_reply_async();
+
        input_template_init(service);
        input_template_set_notify(_input_template_notify_cb,  NULL);
 
@@ -904,7 +1311,7 @@ void _app_service(app_control_h service, void* user_data)
 ACTIVATE :
        elm_win_activate(app_data->win_main);
 
-       if(context)
+       if (context)
                free(context);
 }
 
@@ -918,6 +1325,7 @@ void _app_pause(void* user_data)
 void _app_resume(void* user_data)
 {
        PRINTFUNC(DLOG_DEBUG, "");
+       resume_voice();
 }
 
 void _app_terminate(void* user_data)
@@ -925,17 +1333,18 @@ void _app_terminate(void* user_data)
        App_Data* app_data = NULL;
        app_data = (App_Data*)user_data;
 
-       if(app_data->genlist){
+       if (app_data->genlist){
                evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
        }
 
-       if(app_data->res_path)
+       if (app_data->res_path)
                free(app_data->res_path);
 
-       if(app_data->shared_res_path)
+       if (app_data->shared_res_path)
                free(app_data->shared_res_path);
 
        input_keyboard_deinit();
+       input_smartreply_deinit();
 
        input_template_unset_notify();
        input_template_deinit();
@@ -1000,7 +1409,7 @@ void input_type_deinit(void)
        g_input_type_data.input_type_array_len = 0;
 }
 
-int main(int argc, char* argv[])
+EXPORTED int main(int argc, char* argv[])
 {
        App_Data app_data = {0, };
        ui_app_lifecycle_callback_s event_callback = {0, };