X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fw-input-emoticon.cpp;h=8ffd747d06d31c88e04c1b7643ad883f6b369142;hb=588163ca8386f6b7b595939b770af4e12db75e61;hp=e3b9b9d85344408e44e9585c2f875f8234634cf6;hpb=74353db9442ec97b8f1d092c0462df42e1c9c950;p=platform%2Fcore%2Fuifw%2Finputdelegator.git diff --git a/src/w-input-emoticon.cpp b/src/w-input-emoticon.cpp index e3b9b9d..8ffd747 100755 --- a/src/w-input-emoticon.cpp +++ b/src/w-input-emoticon.cpp @@ -14,10 +14,12 @@ * limitations under the License. */ +#include #include #include #include #include +#include #include #include @@ -41,12 +43,13 @@ vector recent_emoji_list; typedef struct { int code; - char* name; + const char* name; }Emoticon; static Elm_Object_Item *it_emoticon_empty = NULL; static Elm_Object_Item *it_emoticon_recent_group = NULL; static Elm_Object_Item *it_emoticon_emoji_group = NULL; +static Elm_Object_Item* it_drawing = NULL; static Elm_Object_Item *it_last = NULL; static Elm_Genlist_Item_Class *itc_emoticon = NULL; @@ -70,6 +73,7 @@ typedef struct emoticon_content } emoticon_content_s; static emoticon_content_s emoticon_contents_pool[EMOTICON_CNT] = { 0, }; +static emoticon_content_s emoticon_drawing_pool = { 0, }; static emoticon_content_s emoticon_recents_pool[RECENT_CNT] = { 0, }; @@ -257,13 +261,6 @@ Emoticon emoticon_info[EMOTICON_CNT] = { }; -static Eina_Bool _custom_back_cb(void *data, Elm_Object_Item *it) -{ - _back_to_genlist_for_selector(); - return EINA_TRUE; -} - - //---------------------------------------------------------------------------------------// static Eina_Bool _custom_back_cb2(void *data, Elm_Object_Item *it) @@ -283,6 +280,11 @@ static Eina_Bool _custom_back_cb2(void *data, Elm_Object_Item *it) lazy_loading_timer_for_contents = NULL; } + if (emoticon_drawing_pool.used == 0){ + evas_object_del(emoticon_drawing_pool.content); + } + emoticon_drawing_pool.content = NULL; + //Recent EMOTICONS : the recent emoiton need to be updated whenever emoticon view is generated, so deleted here. for (i=0;i< RECENT_CNT;i++) { @@ -313,12 +315,12 @@ void get_recent_emoticons(vector &emoticon_list) PRINTFUNC(DLOG_DEBUG, "str = %s", str); if (str != NULL) { - char *tok; - tok = strtok(str, ","); + char *tok, *ptr; + tok = strtok_r(str, ",", &ptr); while (tok != NULL) { PRINTFUNC(DLOG_DEBUG, "tok = %s", tok); emoticon_list.push_back(strtol(tok, (char **)NULL, 10)); - tok = strtok(NULL, ","); + tok = strtok_r(NULL, ",", &ptr); } } @@ -330,7 +332,7 @@ void get_recent_emoticons(vector &emoticon_list) void set_recent_emoticons(vector &emoticon_list, int val) { - int i; + unsigned int i; int ret = PREFERENCE_ERROR_NONE; if (emoticon_list.size() > 0) { @@ -368,9 +370,46 @@ void set_recent_emoticons(vector &emoticon_list, int val) } } +static void _drawing_app_control_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) +{ + char* path = NULL; + app_control_get_extra_data(reply, APP_CONTROL_DATA_PATH, &path); + + if (path){ + PRINTFUNC(DLOG_DEBUG, "path=%s", path); + char *pathes[] = {path, }; + reply_to_sender_by_callback(NULL, "image", (const char **)pathes, NULL); + free(path); + } + ui_app_exit(); +} + +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; + + Elm_Object_Item *item = (Elm_Object_Item *) event_info; + if (item) + elm_genlist_item_selected_set(item, EINA_FALSE); + + /* launch */ + app_control_h request = NULL; + app_control_create(&request); + app_control_set_app_id(request, "org.tizen.sketch"); + + int ret = app_control_send_launch_request(request, _drawing_app_control_reply_cb, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + PRINTFUNC(DLOG_DEBUG, "error code = 0x%x", ret); + } + app_control_destroy(request); +} + static void _emoticon_item_clicked_cb(void *data, Evas_Object * obj, void *event_info) { - int index = (int)data; + int index = (uintptr_t)data; PRINTFUNC(DLOG_DEBUG, "index = %d", index); @@ -378,16 +417,16 @@ static void _emoticon_item_clicked_cb(void *data, Evas_Object * obj, void *event set_recent_emoticons(recent_emoji_list, index); int length; - const Eina_Unicode unicode_event[2] = { emoticon_info[index].code, 0 }; + const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); - reply_to_sender_by_callback((const char*)utf_8, "emoticon"); + reply_to_sender_by_callback((const char*)utf_8, "emoticon", NULL, NULL); PRINTFUNC(SECURE_DEBUG, "[%d]%s", index, utf_8); if (utf_8) free(utf_8); - elm_exit(); + ui_app_exit(); } Evas_Object* get_emoticon_button(Evas_Object* parent, int index){ @@ -400,7 +439,7 @@ Evas_Object* get_emoticon_button(Evas_Object* parent, int index){ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); int length; - const Eina_Unicode unicode_event[2] = { emoticon_info[index].code, 0 }; + const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); elm_object_part_text_set(btn, "elm.text", utf_8); @@ -409,7 +448,7 @@ Evas_Object* get_emoticon_button(Evas_Object* parent, int index){ evas_object_layer_set(btn, 32000); - evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void *)index); + evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void *)(uintptr_t)index); return btn; } @@ -424,17 +463,17 @@ Evas_Object* get_recent_emoticon_button(Evas_Object* parent, int index){ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); int length; - const Eina_Unicode unicode_event[2] = { emoticon_info[recent_emoji_list.at(index)].code, 0 }; + const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[recent_emoji_list.at(index)].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); elm_object_part_text_set(btn, "elm.text", utf_8); - evas_object_data_set(btn, "index", (void*) recent_emoji_list.at(index)); + evas_object_data_set(btn, "index", (void*)(uintptr_t) recent_emoji_list.at(index)); if (utf_8) free(utf_8); evas_object_layer_set(btn, 32000); - evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void*) recent_emoji_list.at(index)); + evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void*)(uintptr_t) recent_emoji_list.at(index)); return btn; } @@ -447,7 +486,6 @@ static void _emoticon_gl_lang_changed(void *data, Evas_Object *obj, void *event_ static char * __emoticon_gl_text_get(void *data, Evas_Object *obj, const char *part) { //PRINTFUNC(DLOG_DEBUG,"part = %s", part); - const char* str = (const char*) data; if (!str) return NULL; @@ -465,9 +503,9 @@ static void _emoticon_gl_content_unswallowed_cb(void *data, Evas_Object *obj, vo const Elm_Genlist_Item_Class *itc = elm_genlist_item_item_class_get(it); -// PRINTFUNC(DLOG_DEBUG,"%s - stype[%s]", __func__, itc->item_style); + //PRINTFUNC(DLOG_DEBUG,"%s - stype[%s]", __func__, itc->item_style); if (!strcmp(itc->item_style, "3button_flat")) { - int index = (int)elm_object_item_data_get(it); + int index = (uintptr_t)elm_object_item_data_get(it); //PRINTFUNC(DLOG_DEBUG,"it = %p", it); PRINTFUNC(DLOG_DEBUG, "index = %d %d %d", index, index+1, index+2); @@ -481,7 +519,7 @@ static void _emoticon_gl_content_unswallowed_cb(void *data, Evas_Object *obj, vo emoticon_contents_pool[index+2].used = 0; } } else if (!strcmp(itc->item_style, "3button_flat_recent")) { - int index = (int)elm_object_item_data_get(it); + unsigned int index = (uintptr_t)elm_object_item_data_get(it); //PRINTFUNC(DLOG_DEBUG,"index = %d",index); if (index < recent_emoji_list.size()) { @@ -493,16 +531,55 @@ static void _emoticon_gl_content_unswallowed_cb(void *data, Evas_Object *obj, vo if (index + 2 < recent_emoji_list.size()) { emoticon_recents_pool[index+2].used = 0; } + } else if (it_drawing == it) { + //PRINTFUNC(DLOG_DEBUG,"it_drawing = %p", it_drawing); + emoticon_drawing_pool.used = 0; } } +static Evas_Object * __emoticon_gl_1_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"; + PRINTFUNC(DLOG_DEBUG, "path_ic = %s", path_ic.c_str()); + elm_image_file_set(ic, path_ic.c_str(), NULL); + elm_object_content_set(btn, ic); + evas_object_layer_set(btn, 32000); + + emoticon_drawing_pool.index = 0; + emoticon_drawing_pool.content = btn; + emoticon_drawing_pool.used = 0; + return btn; + } else if (!strcmp(part, "base")){ + Evas_Object* btn = elm_button_add(obj); + elm_object_style_set(btn, "ime/transparent"); + return btn; + } + return NULL; +} + static Evas_Object * __emoticon_gl_recent_content_get(void *data, Evas_Object *obj, const char *part) { if (is_content_reuse_on) { - int index = (int)data; + unsigned int index = (uintptr_t)data; int new_index = 0; - //PRINTFUNC(DLOG_DEBUG,"%s %d", part, index); + //PRINTFUNC(DLOG_DEBUG,"%s %d", part, index); if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) { if (!strcmp(part, "elm.icon.1")) { if (index >= recent_emoji_list.size()) return NULL; @@ -525,10 +602,10 @@ static Evas_Object * __emoticon_gl_recent_content_get(void *data, Evas_Object *o return btn; } } else { - int index = (int)data; + unsigned int index = (uintptr_t)data; int new_index = 0; - // PRINTFUNC(DLOG_DEBUG,"%s %d", part, index); + //PRINTFUNC(DLOG_DEBUG,"%s %d", part, index); if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) { if (!strcmp(part, "elm.icon.1")) { if (index >= recent_emoji_list.size()) return NULL; @@ -553,9 +630,8 @@ static Evas_Object * __emoticon_gl_recent_content_get(void *data, Evas_Object *o static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object *obj, const char *part) { //PRINTFUNC(DLOG_DEBUG,"%s", __func__); - if (is_content_reuse_on) { - int index = (int)data; + int index = (uintptr_t)data; int new_index = 0; if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) { @@ -579,10 +655,10 @@ static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object elm_object_part_text_set(btn, "elm.text", strdup(utf_8)); #else int length; - const Eina_Unicode unicode_event[2] = { emoticon_info[new_index].code, 0 }; + const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[new_index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); elm_object_part_text_set(btn, "elm.text", utf_8); - evas_object_data_set(btn, "index", (void*)new_index); + evas_object_data_set(btn, "index", (void*)(uintptr_t)new_index); if (utf_8) free(utf_8); @@ -595,7 +671,7 @@ static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object return btn; } } else { - int index = (int)data; + int index = (uintptr_t)data; int new_index = 0; if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) { @@ -619,7 +695,6 @@ static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object return NULL; } - void _create_reusable_recents(Evas_Object *parent) { if (!parent) { @@ -627,7 +702,7 @@ void _create_reusable_recents(Evas_Object *parent) return; } - int i; + unsigned int i; for (i = 0; i < recent_emoji_list.size(); i++ ) { emoticon_recents_pool[i].index = i; emoticon_recents_pool[i].content = get_recent_emoticon_button(parent, i); @@ -729,7 +804,7 @@ static Eina_Bool _lazy_loader_cb_for_items(void *data) int i; for (i = loading_done_for_item; i < loading_top; i++ ) { if (i%3 == 0) - elm_genlist_item_append(gl, itc_emoticon, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i); + elm_genlist_item_append(gl, itc_emoticon, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i); } loading_done_for_item = loading_top; @@ -746,7 +821,7 @@ void _create_reusable_contents(Evas_Object *gl){ for (i = 0; i < INITAL_ITEM_UNIT; i++ ) { if (i%3 == 0) - elm_genlist_item_append(gl, itc_emoticon, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i); + elm_genlist_item_append(gl, itc_emoticon, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i); } lazy_loading_timer_for_items = ecore_timer_add(0.1, _lazy_loader_cb_for_items, (void *)gl); @@ -763,16 +838,20 @@ Evas_Object* _create_emoticon_genlist(void* data) if (NULL == genlist) return NULL; - Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface); - eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); - 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, ad->circle_surface); + eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + 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); evas_object_show(genlist); - Elm_Object_Item *nf_emoticon_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, genlist, "empty"); + const char *item_style = NULL; + if (_WEARABLE) + item_style = "empty"; + Elm_Object_Item *nf_emoticon_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, genlist, item_style); elm_naviframe_item_pop_cb_set(nf_emoticon_item, _custom_back_cb2, ad); @@ -792,7 +871,7 @@ void _update_emoticon_items(void *data) if (!gl) return; - int i; + unsigned int i; Elm_Object_Item *it = NULL; Elm_Object_Item *first_it = NULL; @@ -803,8 +882,17 @@ void _update_emoticon_items(void *data) itc_dummy->func.state_get = NULL; itc_dummy->func.del = NULL; - Elm_Genlist_Item_Class *itc_group = elm_genlist_item_class_new(); + Elm_Genlist_Item_Class *itc_1text_1icon = NULL; + if (app_data->mime_type == MIME_TYPE_ALL) { + itc_1text_1icon = elm_genlist_item_class_new(); + itc_1text_1icon->item_style = "drawing"; + itc_1text_1icon->func.text_get = __emoticon_gl_text_get; + itc_1text_1icon->func.content_get = __emoticon_gl_1_content_get; + itc_1text_1icon->func.state_get = NULL; + itc_1text_1icon->func.del = NULL; + } + Elm_Genlist_Item_Class *itc_group = elm_genlist_item_class_new(); itc_group->item_style = "groupindex"; itc_group->func.text_get = __emoticon_gl_text_get; itc_group->func.content_get = NULL; @@ -812,9 +900,6 @@ void _update_emoticon_items(void *data) itc_group->func.del = NULL; Elm_Genlist_Item_Class *itc_recent = elm_genlist_item_class_new(); - if (is_content_reuse_on) { -// itc_recent->content_reusable = EINA_TRUE; - } itc_recent->item_style = "3button_flat_recent"; itc_recent->func.text_get = NULL; itc_recent->func.content_get = __emoticon_gl_recent_content_get; @@ -822,9 +907,6 @@ void _update_emoticon_items(void *data) itc_recent->func.del = NULL; itc_emoticon = elm_genlist_item_class_new(); - if (is_content_reuse_on) { -// itc_emoticon->content_reusable = EINA_TRUE; - } itc_emoticon->item_style = "3button_flat"; itc_emoticon->func.text_get = NULL; itc_emoticon->func.content_get = __emoticon_gl_emoticon_content_get; @@ -834,13 +916,19 @@ void _update_emoticon_items(void *data) // dummy title for empty space it_emoticon_empty = elm_genlist_item_append(gl, itc_dummy, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + // Drawing + if (app_data->mime_type == MIME_TYPE_ALL) { + it_drawing = elm_genlist_item_append(gl, itc_1text_1icon, (void*)"WDS_IME_MBODY_DRAWING_M_EMOTICON_ABB", NULL, ELM_GENLIST_ITEM_NONE, _drawing_item_clicked_cb, (void *)app_data); + first_it = it_drawing; + } + if (recent_emoji_list.size() > 0) { if (is_content_reuse_on) { _create_reusable_recents(gl); } // Group Recents - it_emoticon_recent_group = elm_genlist_item_append(gl, itc_group, (void*)"IDS_IME_HEADER_RECENT_M_RECETLY_SENT_EMOJIS_ABB", NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)2); + it_emoticon_recent_group = elm_genlist_item_append(gl, itc_group, (void*)"WDS_IME_HEADER_RECENT_M_RECETLY_SENT_EMOJIS_ABB", NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)2); elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); if (first_it == NULL) first_it = it_emoticon_recent_group; @@ -849,12 +937,12 @@ void _update_emoticon_items(void *data) for (i=0;i < recent_emoji_list.size();i=i+3) { - it = elm_genlist_item_append(gl, itc_recent, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i); + it = elm_genlist_item_append(gl, itc_recent, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i); } } // Group Emoticons - it_emoticon_emoji_group = elm_genlist_item_append(gl, itc_group, (void*)"IDS_IME_HEADER_EMOJIS_ABB", NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)2); + it_emoticon_emoji_group = elm_genlist_item_append(gl, itc_group, (void*)"WDS_IME_HEADER_EMOJIS_ABB", NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)2); elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); if (first_it == NULL) first_it = it_emoticon_emoji_group; @@ -864,7 +952,7 @@ void _update_emoticon_items(void *data) } else { // Emoticons for (i=0;i< EMOTICON_CNT;i=i+3) { - it = elm_genlist_item_append(gl, itc_emoticon, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i); + it = elm_genlist_item_append(gl, itc_emoticon, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i); it_last = it; } elm_genlist_item_class_free(itc_emoticon); @@ -878,6 +966,7 @@ void _update_emoticon_items(void *data) elm_genlist_item_class_free(itc_recent); elm_genlist_item_class_free(itc_group); + elm_genlist_item_class_free(itc_1text_1icon); elm_genlist_item_class_free(itc_dummy); } @@ -890,6 +979,7 @@ void ise_show_emoticon_list(void *data) it_emoticon_empty = NULL; it_emoticon_recent_group = NULL; it_emoticon_emoji_group = NULL; + it_drawing = NULL; it_last = NULL; get_recent_emoticons(recent_emoji_list); @@ -903,3 +993,12 @@ void ise_show_emoticon_list(void *data) } _update_emoticon_items(emoticon_list); } + +void launch_drawing_app(void *data) +{ + App_Data* ad = (App_Data*) data; + if (!ad) + return; + + _drawing_item_clicked_cb(ad, NULL, NULL); +}