2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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 "vcui-application.h"
19 #include "vcui-view-keypad.h"
20 #include "vcui-view-common.h"
22 typedef struct _keypad_data_t {
23 Evas_Object *parent_ly;
24 Evas_Object *keypad_ly;
25 Evas_Object *separator_ly;
28 char entry_disp_data[KEYPAD_ENTRY_DISP_DATA_SIZE+1];
29 Eina_Bool bkeypad_show;
32 static keypad_data_t *gkeypad_data;
34 static void __vcui_keypad_create_separator_layout(void *data);
35 static void __vcui_keypad_create_entry(void *data);
37 static Evas_Object *__vcui_keypad_create_contents(void *data, char *grp_name)
40 CALL_UI_DEBUG("ERROR");
43 voice_call_view_data_t *vd = (voice_call_view_data_t *)data;
48 eo = _vcui_load_edj(vd->app_data->win_main, EDJ_NAME, grp_name);
55 static keypad_data_t *__vcui_keypad_memory_alloc()
59 VCUI_RETURN_VALUE_IF_FAIL(gkeypad_data == NULL, gkeypad_data)
62 gkeypad_data = (keypad_data_t *) calloc(1, sizeof(keypad_data_t));
63 if (gkeypad_data == NULL) {
64 CALL_UI_DEBUG("keydata structure not allocated");
67 memset(gkeypad_data, 0x00, sizeof(keypad_data_t));
68 gkeypad_data->bkeypad_show = EINA_FALSE;
73 void _vcui_keypad_create_layout(void *data, Evas_Object *parent_ly)
76 voice_call_view_data_t *vd = (voice_call_view_data_t *)data;
77 keypad_data_t *pkeypad_data = NULL;
79 pkeypad_data = __vcui_keypad_memory_alloc();
80 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
82 if (!pkeypad_data->keypad_ly) {
84 pkeypad_data->keypad_ly = __vcui_keypad_create_contents(vd, GRP_KEYPAD);
85 elm_object_part_content_set(parent_ly, "keypad_region", pkeypad_data->keypad_ly);
87 CALL_UI_DEBUG("keypad_ly :%p", pkeypad_data->keypad_ly);
89 __vcui_keypad_create_separator_layout(vd);
91 __vcui_keypad_create_entry(vd);
94 static void __vcui_keypad_create_separator_layout(void *data)
97 voice_call_view_data_t *vd = (voice_call_view_data_t *)data;
98 keypad_data_t *pkeypad_data = gkeypad_data;
100 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
102 if (!pkeypad_data->separator_ly) {
104 pkeypad_data->separator_ly = __vcui_keypad_create_contents(vd, GRP_KEYPAD_SEP_LAYOUT);
105 elm_object_part_content_set(pkeypad_data->keypad_ly, "separator/bg", pkeypad_data->separator_ly);
109 Eina_Bool _vcui_keypad_get_show_status(void)
111 keypad_data_t *pkeypad_data = gkeypad_data;
113 VCUI_RETURN_FALSE_IF_FAIL(pkeypad_data != NULL)
115 CALL_UI_DEBUG("Get show status(%d)", pkeypad_data->bkeypad_show);
116 return pkeypad_data->bkeypad_show;
119 void _vcui_keypad_set_show_status(Eina_Bool bkeypad_status)
121 keypad_data_t *pkeypad_data = gkeypad_data;
123 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
125 CALL_UI_DEBUG("Set show status(%d)", bkeypad_status);
126 pkeypad_data->bkeypad_show = bkeypad_status;
129 static void __vcui_keypad_on_key_down(void *data, Evas_Object *obj, const char *emission, const char *source)
131 CALL_UI_DEBUG("source(%s)", source);
133 char before_dest[KEYPAD_STR_DEFINE_OPEN_SIZE + KEYPAD_ENTRY_DISP_DATA_SIZE + 1] = { 0, };
134 char *sub_buffer_pointer = NULL;
135 char entry_dest[KEYPAD_ENTRY_SET_DATA_SIZE + 1] = { 0, };
137 voice_call_view_data_t *vd = (voice_call_view_data_t *)data;
138 keypad_data_t *pkeypad_data = gkeypad_data;
140 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
143 CALL_UI_DEBUG("data is null");
147 if (strlen(source) >= KEYPAD_ENTRY_DISP_DATA_SIZE) {
148 CALL_UI_DEBUG("strlen(source) >= DATA_BUF_SIZE(%d)", KEYPAD_ENTRY_DISP_DATA_SIZE);
152 if (strcmp(source, "star") == 0) {
154 } else if (strcmp(source, "sharp") == 0) {
157 keypad_source = (char *)source;
161 dtmf_number[0] = keypad_source[0];
162 dtmf_number[1] = '\0';
163 vcall_engine_send_dtmf_number(dtmf_number);
165 if (strlen(pkeypad_data->entry_disp_data) == KEYPAD_ENTRY_DISP_DATA_SIZE) {
166 sub_buffer_pointer = &pkeypad_data->entry_disp_data[1];
168 snprintf(pkeypad_data->entry_disp_data, sizeof(pkeypad_data->entry_disp_data), "%s", sub_buffer_pointer);
169 CALL_UI_DEBUG("pkeypad_data->entry_disp_data after change [%s]", pkeypad_data->entry_disp_data);
172 pkeypad_data->entry_disp_data[pkeypad_data->data_len] = keypad_source[0];
173 if (pkeypad_data->data_len < (KEYPAD_ENTRY_DISP_DATA_SIZE - 1)) {
174 pkeypad_data->data_len++;
177 snprintf(before_dest, sizeof(before_dest), "<font_size=%d><color=#FFFFFF><shadow_color=#000000><style=outline_shadow>%s", MAX_DIAL_NUMBER_FONT_SIZE, pkeypad_data->entry_disp_data);
179 snprintf(entry_dest, sizeof(entry_dest), "%s</style></shadow_color></color></font_size>", before_dest);
181 CALL_UI_DEBUG("entry_dest [%s]", pkeypad_data->entry_disp_data);
182 elm_entry_entry_set(pkeypad_data->entry, entry_dest);
183 elm_entry_cursor_end_set(pkeypad_data->entry);
186 static Evas_Object *__vcui_keypad_create_single_line_scrolled_entry(void *content)
190 if (content == NULL) {
191 CALL_UI_DEBUG("content is NULL!");
195 en = elm_entry_add(content);
196 elm_entry_scrollable_set(en, EINA_TRUE);
198 elm_entry_select_all(en);
199 elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
201 elm_entry_bounce_set(en, EINA_FALSE, EINA_FALSE);
202 elm_entry_line_wrap_set(en, ELM_WRAP_WORD);
203 elm_entry_input_panel_enabled_set(en, EINA_FALSE);
204 elm_entry_single_line_set(en, EINA_TRUE);
205 elm_entry_cursor_end_set(en);
206 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
207 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
209 evas_object_show(en);
214 static void __vcui_keypad_create_entry(void *data)
217 voice_call_view_data_t *vd = (voice_call_view_data_t *)data;
218 keypad_data_t *pkeypad_data = gkeypad_data;
220 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
222 if (!pkeypad_data->entry) {
224 pkeypad_data->entry = __vcui_keypad_create_single_line_scrolled_entry(pkeypad_data->keypad_ly);
225 memset(pkeypad_data->entry_disp_data, 0x0, sizeof(pkeypad_data->entry_disp_data));
226 pkeypad_data->data_len = 0;
228 edje_object_signal_callback_add(_EDJ(pkeypad_data->keypad_ly), "pad_down", "*", __vcui_keypad_on_key_down, vd);
230 edje_object_part_swallow(_EDJ(pkeypad_data->keypad_ly), "textblock/textarea", pkeypad_data->entry);
234 void _vcui_keypad_delete_layout(Evas_Object *parent_ly)
237 keypad_data_t *pkeypad_data = gkeypad_data;
239 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
241 if (pkeypad_data->separator_ly) {
243 edje_object_part_unswallow(_EDJ(pkeypad_data->keypad_ly), pkeypad_data->separator_ly);
244 evas_object_del(pkeypad_data->separator_ly);
245 pkeypad_data->separator_ly = NULL;
248 if (pkeypad_data->entry) {
250 edje_object_part_unswallow(_EDJ(pkeypad_data->keypad_ly), pkeypad_data->entry);
251 evas_object_del(pkeypad_data->entry);
252 pkeypad_data->entry = NULL;
255 if (pkeypad_data->keypad_ly) {
257 edje_object_part_unswallow(_EDJ(parent_ly), pkeypad_data->keypad_ly);
258 evas_object_del(pkeypad_data->keypad_ly);
259 pkeypad_data->keypad_ly = NULL;
262 pkeypad_data->parent_ly = NULL;
269 void _vcui_keypad_delete_separator_layout(void)
272 keypad_data_t *pkeypad_data = gkeypad_data;
274 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
276 if (pkeypad_data->separator_ly) {
277 edje_object_part_unswallow(_EDJ(pkeypad_data->keypad_ly), pkeypad_data->separator_ly);
278 evas_object_del(pkeypad_data->separator_ly);
279 pkeypad_data->separator_ly = NULL;
283 static void __vcui_keypad_hide_btn_effect_done(void *data, Evas_Object *obj, const char *emission, const char *source)
286 voice_call_view_data_t *vd = (voice_call_view_data_t *) data;
287 vcui_app_call_data_t *ad = vd->app_data;
288 keypad_data_t *pkeypad_data = gkeypad_data;
289 Evas_Object *parent_ly = NULL;
291 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
293 /*Reset the entry area and text*/
294 memset(pkeypad_data->entry_disp_data, '\0', KEYPAD_ENTRY_DISP_DATA_SIZE+1);
295 pkeypad_data->data_len = 0;
296 elm_entry_entry_set(pkeypad_data->entry, "");
297 elm_entry_cursor_end_set(pkeypad_data->entry);
299 parent_ly = pkeypad_data->parent_ly;
300 VCUI_RETURN_IF_FAIL(parent_ly != NULL)
302 /*Hide keypad layout - ON view*/
303 edje_object_signal_emit(_EDJ(parent_ly), "HIDE", "KEYPAD_BTN");
304 /*Show caller info area*/
305 edje_object_signal_emit(_EDJ(parent_ly), "SHOW", "CALL_AREA");
308 if (ad->badd_call_clicked) {
309 _vcui_doc_launch_phoneui_ug(NULL, NULL, vd->layout, NULL, NULL, NULL, &(vd->app_data->ugs_array_data));
310 ad->badd_call_clicked = EINA_FALSE;
311 } else if (ad->bcontact_clicked) {
312 _vcui_doc_launch_contact_list_ug(NULL, NULL, vd->layout, NULL, NULL, NULL, &(vd->app_data->ugs_array_data));
313 ad->bcontact_clicked = EINA_FALSE;
315 ad->beffect_show = EINA_FALSE;
318 void _vcui_keypad_show_hide_effect(void *data, Evas_Object *parent_ly)
321 voice_call_view_data_t *vd = (voice_call_view_data_t *) data;
322 vcui_app_call_data_t *ad = vd->app_data;
323 keypad_data_t *pkeypad_data = gkeypad_data;
325 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
327 ad->beffect_show = EINA_TRUE;
329 edje_object_signal_emit(_EDJ(pkeypad_data->keypad_ly), "HIDE", "KEYPADBTN");
330 pkeypad_data->parent_ly = parent_ly;
331 edje_object_signal_callback_add(_EDJ(pkeypad_data->keypad_ly), "DONE", "HIDEKEYPAD", __vcui_keypad_hide_btn_effect_done, vd);
334 void _vcui_keypad_show_layout(void *data)
337 keypad_data_t *pkeypad_data = gkeypad_data;
339 VCUI_RETURN_IF_FAIL(pkeypad_data != NULL)
341 edje_object_signal_emit(_EDJ(pkeypad_data->keypad_ly), "SHOW", "KEYPADBTN");