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.
18 #include <Elementary.h>
20 #include <efl_assist.h>
23 #include "w-input-selector.h"
24 #include "w-input-smartreply.h"
26 #define EMOTICON_CNT 27
28 static int previous_icon = -1;
37 Emoticon emoticon_info[EMOTICON_CNT] = {
38 {0x1f44c, "IDS_IME_BODY_OK_HAND_SIGN_M_EMOTICON_NAME_TTS"},
39 {0x1f44d, "IDS_IME_BODY_THUMBS_UP_SIGN_M_EMOTICON_NAME"},
40 {0x1f44e, "IDS_IME_BODY_THUMBS_DOWN_SIGN_M_EMOTICON_NAME"},
41 {0x1f604, "IDS_IME_BODY_SMILING_FACE_WITH_OPEN_MOUTH_AND_SMILING_EYES_M_EMOTICON_NAME"},
42 {0x1f606, "IDS_IME_BODY_SMILING_FACE_WITH_OPEN_MOUTH_AND_TIGHTLY_CLOSED_EYES_M_EMOTICON_NAME"},
43 {0x1f60a, "IDS_IME_BODY_SMILING_FACE_WITH_SMILING_EYES_M_EMOTICON_NAME"},
44 {0x1f60d, "IDS_IME_BODY_SMILING_FACE_WITH_HEART_SHAPED_EYES_M_EMOTICON_NAME"},
45 {0x1f61a, "IDS_IME_BODY_KISSING_FACE_WITH_CLOSED_EYES_M_EMOTICON_NAME"},
46 {0x1f61c, "IDS_IME_BODY_FACE_WITH_STUCK_OUT_TONGUE_AND_WINKING_EYE_M_EMOTICON_NAME"},
47 {0x1f620, "IDS_IME_BODY_ANGRY_FACE_M_EMOTICON_NAME"},
48 {0x1f621, "IDS_IME_BODY_POUTING_FACE_M_EMOTICON_NAME"},
49 {0x1f622, "IDS_IME_BODY_CRYING_FACE_M_EMOTICON_NAME"},
50 {0x1f624, "IDS_IME_BODY_FACE_WITH_LOOK_OF_TRIUMPH_M_EMOTICON_NAME"},
51 {0x1f625, "IDS_IME_BODY_DISAPPOINTED_BUT_RELIEVED_FACE_M_EMOTICON_NAME"},
52 {0x1f62a, "IDS_IME_BODY_SLEEPY_FACE_M_EMOTICON_NAME"},
53 {0x1f62b, "IDS_IME_BODY_TIRED_FACE_M_EMOTICON_NAME"},
54 {0x1f631, "IDS_IME_BODY_FACE_SCREAMING_IN_FEAR_M_EMOTICON_NAME"},
55 {0x1f632, "IDS_IME_BODY_ASTONISHED_FACE_M_EMOTICON_NAME"},
56 {0x1f637, "IDS_IME_BODY_FACE_WITH_MEDICAL_MASK_M_EMOTICON_NAME"},
57 {0x1f495, "IDS_IME_BODY_TWO_HEARTS_M_EMOTICON_NAME"},
58 {0x1f43d, "IDS_IME_BODY_PIG_NOSE_M_EMOTICON_NAME"},
59 {0x1f415, "IDS_IME_BODY_DOG_M_EMOTICON_NAME"},
60 {0x1f408, "IDS_IME_BODY_CAT_M_EMOTICON_NAME"},
61 {0x1f414, "IDS_IME_BODY_CHICKEN_M_EMOTICON_NAME"},
62 {0x1f433, "IDS_IME_BODY_SPOUTING_WHALE_M_EMOTICON_NAME"},
63 {0x1f43c, "IDS_IME_BODY_PANDA_FACE_M_EMOTICON_NAME"},
64 {0x1f42f, "IDS_IME_BODY_TIGER_FACE_M_EMOTICON_NAME"},
67 const char * get_emoticon_file_name(int index)
69 static string path = get_resource_path() + string("images/u00000.png");
71 int ipos = path.size()-9;
72 char str_emoticon_code[10] = {0};
73 sprintf(str_emoticon_code, "%x", emoticon_info[index].code);
75 path.insert(ipos, str_emoticon_code);
79 static Eina_Bool _custom_back_cb(void *data, Elm_Object_Item *it)
81 _back_to_genlist_for_selector();
86 _rotary_selector_rotary_cb(void *data, Evas_Object *obj, Eext_Rotary_Event_Info *info)
88 PRINTFUNC(DLOG_DEBUG,"%s", __func__);
90 if (info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE){
91 evas_object_smart_callback_call(obj, "item,selected", (void*)data);
92 eext_rotary_object_event_callback_del(obj, _rotary_selector_rotary_cb);
95 return ECORE_CALLBACK_PASS_ON;
98 static char *_access_info_prepend_cb(void *data, Evas_Object *obj)
101 PRINTFUNC(DLOG_DEBUG,"%s", __func__);
105 if(previous_icon == 10 || previous_icon == 11){
106 text = std::string("Page") + " " +std::string(dgettext(PACKAGE, emoticon_info[previous_icon].name));
107 text = text + " " + gettext("WDS_TTS_TBBODY_DOUBLE_TAP_TO_SEND");
109 text = std::string("Page");
111 return strdup(text.c_str());
114 static void _rotary_selector_item_clicked(void *data, Evas_Object *obj, void *event_info)
116 PRINTFUNC(DLOG_DEBUG,"%s", __func__);
117 App_Data* ad = (App_Data*) data;
121 Eext_Object_Item *selected_item = (Eext_Object_Item *)event_info;
122 Eina_List *rotary_selector_list = (Eina_List *)eext_rotary_selector_items_get(obj);
125 Eina_List *l = rotary_selector_list;
126 Eext_Object_Item *item = (Eext_Object_Item *)eina_list_data_get(l);
128 for (i=0; l!=NULL; i++) {
129 if (selected_item == item)
132 l = eina_list_next(l);
133 item = (Eext_Object_Item *)eina_list_data_get(l);
137 const Eina_Unicode unicode_event[2] = { emoticon_info[i].code, 0 };
138 char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
140 input_smartreply_send_feedback(utf_8);
141 if(ad->reply_type == REPLY_APP_CONTROL)
142 reply_to_sender_by_appcontrol(data, (const char*)utf_8, "emoticon");
144 reply_to_sender_by_callback((const char*)utf_8, "emoticon");
146 PRINTFUNC(SECURE_DEBUG,"[%d]%s", i, utf_8);
150 if(ad->reply_type == REPLY_APP_NORMAL)
154 static void _rotary_selector_item_selected(void *data, Evas_Object *obj, void *event_info)
156 PRINTFUNC(DLOG_DEBUG,"%s", __func__);
157 if (elm_config_access_get())
159 Eext_Object_Item *selected_item = (Eext_Object_Item *)event_info;
160 Eina_List *rotary_selector_list = (Eina_List *)eext_rotary_selector_items_get(obj);
163 Eina_List *l = rotary_selector_list;
164 Eext_Object_Item *item = (Eext_Object_Item *)eina_list_data_get(l);
166 for (i=0; l!=NULL; i++) {
167 if (selected_item == item)
170 l = eina_list_next(l);
171 item = (Eext_Object_Item *)eina_list_data_get(l);
177 Evas_Object *content = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(obj), "content");
178 if (!content) return;
180 Evas_Object *content_access = elm_access_object_get(content);
185 std::string text = std::string(dgettext(PACKAGE, emoticon_info[i].name));
186 PRINTFUNC(DLOG_DEBUG,"[%d]%s",i,text.c_str());
187 text = text + " " + gettext("WDS_TTS_TBBODY_DOUBLE_TAP_TO_SEND");
188 elm_access_say(text.c_str());
193 void ise_show_emoticon_popup_rotary(void *data)
195 PRINTFUNC(DLOG_DEBUG,"%s", __func__);
196 App_Data* ad = (App_Data*) data;
201 Eext_Object_Item *first_it;
203 Evas_Object *rotary_selector = eext_rotary_selector_add(ad->naviframe);
204 // uxt_theme_object_replace_color(rotary_selector, "B01153", "AO0117");
205 PRINTFUNC(DLOG_DEBUG,"replace color");
206 for (int i = 0; i < EMOTICON_CNT; ++i)
208 Evas_Object *img = NULL;
209 Eext_Object_Item *item = eext_rotary_selector_item_append(rotary_selector);
211 if(i==0) first_it=item;
213 img = elm_image_add(rotary_selector);
214 elm_image_file_set(img, get_emoticon_file_name(i), NULL);
215 eext_rotary_selector_item_part_content_set(item, "item,bg_image", EEXT_ROTARY_SELECTOR_ITEM_STATE_NORMAL, img);
217 img = elm_image_add(rotary_selector);
218 elm_image_file_set(img, get_emoticon_file_name(i), NULL);
219 eext_rotary_selector_item_part_content_set(item, "selector,icon", EEXT_ROTARY_SELECTOR_ITEM_STATE_NORMAL, img);
222 evas_object_smart_callback_add(rotary_selector, "item,selected", _rotary_selector_item_selected, rotary_selector);
223 evas_object_smart_callback_add(rotary_selector, "item,clicked", _rotary_selector_item_clicked, (void*)ad);
225 Elm_Object_Item *nf_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, rotary_selector, "empty");
226 elm_naviframe_item_pop_cb_set(nf_item, _custom_back_cb, NULL);
227 eext_rotary_object_event_activated_set(rotary_selector, EINA_TRUE);
229 if (elm_config_access_get()){
230 Evas_Object *selector_access = elm_access_object_get(rotary_selector);
231 elm_access_highlight_set(selector_access);
232 eext_rotary_object_event_callback_add(rotary_selector, _rotary_selector_rotary_cb, first_it);
234 // ea_screen_reader_access_info_append_cb_set(selector_access, ELM_ACCESS_CONTEXT_INFO, _access_info_prepend_cb, NULL);
238 PRINTFUNC(DLOG_DEBUG,"%s", __func__);