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 snprintf(str_emoticon_code, sizeof(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)
100 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
104 if (previous_icon == 10 || previous_icon == 11){
105 text = std::string("Page") + " " +std::string(dgettext(PACKAGE, emoticon_info[previous_icon].name));
106 text = text + " " + gettext("WDS_TTS_TBBODY_DOUBLE_TAP_TO_SEND");
108 text = std::string("Page");
110 return strdup(text.c_str());
113 static void _rotary_selector_item_clicked(void *data, Evas_Object *obj, void *event_info)
115 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
116 App_Data* ad = (App_Data*) data;
120 Eext_Object_Item *selected_item = (Eext_Object_Item *)event_info;
121 Eina_List *rotary_selector_list = (Eina_List *)eext_rotary_selector_items_get(obj);
124 Eina_List *l = rotary_selector_list;
125 Eext_Object_Item *item = (Eext_Object_Item *)eina_list_data_get(l);
127 for (i = 0; l != NULL; i++) {
128 if (selected_item == item)
131 l = eina_list_next(l);
132 item = (Eext_Object_Item *)eina_list_data_get(l);
136 const Eina_Unicode unicode_event[2] = { emoticon_info[i].code, 0 };
137 char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
139 input_smartreply_send_feedback(utf_8);
140 if(ad->reply_type == REPLY_APP_CONTROL)
141 reply_to_sender_by_appcontrol(data, (const char*)utf_8, "emoticon");
143 reply_to_sender_by_callback((const char*)utf_8, "emoticon");
145 PRINTFUNC(SECURE_DEBUG, "[%d]%s", i, utf_8);
149 if(ad->reply_type == REPLY_APP_NORMAL)
153 static void _rotary_selector_item_selected(void *data, Evas_Object *obj, void *event_info)
155 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
158 void ise_show_emoticon_popup_rotary(void *data)
160 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
161 App_Data* ad = (App_Data*) data;
165 Eext_Object_Item *first_it;
167 Evas_Object *rotary_selector = eext_rotary_selector_add(ad->naviframe);
168 // uxt_theme_object_replace_color(rotary_selector, "B01153", "AO0117");
169 PRINTFUNC(DLOG_DEBUG, "replace color");
170 for (int i = 0; i < EMOTICON_CNT; ++i)
172 Evas_Object *img = NULL;
173 Eext_Object_Item *item = eext_rotary_selector_item_append(rotary_selector);
175 if (i == 0) first_it = item;
177 img = elm_image_add(rotary_selector);
178 elm_image_file_set(img, get_emoticon_file_name(i), NULL);
179 eext_rotary_selector_item_part_content_set(item, "item,bg_image", EEXT_ROTARY_SELECTOR_ITEM_STATE_NORMAL, img);
181 img = elm_image_add(rotary_selector);
182 elm_image_file_set(img, get_emoticon_file_name(i), NULL);
183 eext_rotary_selector_item_part_content_set(item, "selector,icon", EEXT_ROTARY_SELECTOR_ITEM_STATE_NORMAL, img);
186 evas_object_smart_callback_add(rotary_selector, "item,selected", _rotary_selector_item_selected, rotary_selector);
187 evas_object_smart_callback_add(rotary_selector, "item,clicked", _rotary_selector_item_clicked, (void*)ad);
189 Elm_Object_Item *nf_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, rotary_selector, "empty");
190 elm_naviframe_item_pop_cb_set(nf_item, _custom_back_cb, NULL);
191 eext_rotary_object_event_activated_set(rotary_selector, EINA_TRUE);
193 PRINTFUNC(DLOG_DEBUG, "%s", __func__);