/* * Copyright 2012 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://floralicense.org/license/ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include "phone.h" #include "ph-front.h" #include "phone-log.h" #include "phone-dialer.h" #include "ph-front-view.h" #include "ct-list.h" #include "ct-favor.h" static void front_view_reset_current_sub_view(ph_phoneui_data *phoneui_d) { PH_FN_CALL; p_ret_if(phoneui_d->select_tab <= PH_VIEW_NONE || PH_VIEW_MAX <= phoneui_d->select_tab); if (phoneui_d->sub_view[phoneui_d->select_tab]) { switch (phoneui_d->select_tab) { case PH_VIEW_DIALER: phone_dialer_view_reset(phoneui_d->sub_view[PH_VIEW_DIALER]); phone_dialer_set_background(phoneui_d->sub_view[PH_VIEW_DIALER], true); break; case PH_VIEW_CONTACT : ctui_list_view_reset(evas_object_data_get(phoneui_d->navi, "clist_d")); ctui_list_set_background(phoneui_d->navi, true); break; case PH_VIEW_LOG : phone_log_view_reset(phoneui_d->navi); phone_log_set_background(phoneui_d->navi, true); break; case PH_VIEW_FAVORITE : phone_favor_view_reset(phoneui_d->sub_view[PH_VIEW_FAVORITE]); phone_favor_set_background(phoneui_d->sub_view[PH_VIEW_FAVORITE], true); break; } } } static void front_view_load_sub_view(ph_phoneui_data *phoneui_d, int tab_index) { PH_FN_CALL; ph_view_info *view_info; view_info = calloc(1, sizeof(ph_view_info)); phone_set_view_info(view_info, phoneui_d->win, phoneui_d->navi, phoneui_d->ug, phoneui_d->ug_request, phoneui_d->cnt_max, phoneui_d->ug_data); switch (tab_index) { case PH_VIEW_DIALER: phoneui_d->sub_view[tab_index] = phone_create_dialer_view(view_info); break; case PH_VIEW_CONTACT: phoneui_d->sub_view[tab_index] = ctui_create_phone_list_view(view_info); break; case PH_VIEW_LOG: phoneui_d->sub_view[tab_index] = phone_create_log_view(view_info); break; case PH_VIEW_FAVORITE: phoneui_d->sub_view[tab_index] = phone_favor_create_view(view_info); break; default: ERR("INVALID tab_index : %d", tab_index); break; }; free(view_info); return; } API void phone_front_view_show_sub_view(ph_phoneui_data *phoneui_d) { PH_FN_CALL; Evas_Object *view; ph_view_info *view_info; front_view_reset_current_sub_view(phoneui_d); phone_hide_notify(phoneui_d->navi); view_info = calloc(1, sizeof(ph_view_info)); phone_set_view_info(view_info, phoneui_d->win, phoneui_d->navi, phoneui_d->ug, phoneui_d->ug_request, phoneui_d->cnt_max, phoneui_d->ug_data); if (NULL == phoneui_d->sub_view[PH_VIEW_CONTACT]) phoneui_d->sub_view[PH_VIEW_CONTACT] = ctui_create_phone_list_view(view_info); ctui_list_set_background(phoneui_d->navi, false); ctui_list_navi_set(CT_LIST_MODE_DEFAULT, evas_object_data_get(phoneui_d->navi, "clist_d")); phoneui_d->select_tab = PH_VIEW_CONTACT; view = elm_object_part_content_unset(phoneui_d->layout, "elm.swallow.content"); if (view) evas_object_hide(view); elm_object_part_content_set(phoneui_d->layout, "elm.swallow.content", phoneui_d->sub_view[PH_VIEW_CONTACT]); evas_object_show(phoneui_d->sub_view[PH_VIEW_CONTACT]); free(view_info); } static void front_view_show_sub_view(ph_phoneui_data *phoneui_d, int tab_index) { PH_FN_CALL; Evas_Object *view; ph_view_info *view_info; p_retm_if(tab_index <= PH_VIEW_NONE || PH_VIEW_MAX <= tab_index, "tab index is invalid"); p_retm_if(phoneui_d->select_tab == tab_index, "The tab is already shown"); front_view_reset_current_sub_view(phoneui_d); phone_hide_notify(phoneui_d->navi); view_info = calloc(1, sizeof(ph_view_info)); phone_set_view_info(view_info, phoneui_d->win, phoneui_d->navi, phoneui_d->ug, phoneui_d->ug_request, phoneui_d->cnt_max, phoneui_d->ug_data); switch (tab_index) { case PH_VIEW_DIALER: if (NULL == phoneui_d->sub_view[tab_index]) phoneui_d->sub_view[tab_index] = phone_create_dialer_view(view_info); phone_dialer_set_background(phoneui_d->sub_view[PH_VIEW_DIALER], false); phone_dialer_set_navi(phoneui_d->sub_view[PH_VIEW_DIALER]); phone_dialer_check_focus(phoneui_d->sub_view[PH_VIEW_DIALER]); if(!phoneui_d->ug) phone_front_view_show_call_app(phoneui_d); evas_object_data_set(phoneui_d->sub_view[tab_index], "phoneui_d", phoneui_d); break; case PH_VIEW_CONTACT: if (NULL == phoneui_d->sub_view[tab_index]) phoneui_d->sub_view[tab_index] = ctui_create_phone_list_view(view_info); ctui_list_set_background(phoneui_d->navi, false); if (PH_UG_REQUEST_CHECK == phoneui_d->ug_request || PH_UG_REQUEST_CHECK_FOR_NUMBER == phoneui_d->ug_request || PH_UG_REQUEST_CHECK_FOR_EMAIL == phoneui_d->ug_request || PH_UG_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL == phoneui_d->ug_request) { ctui_list_edit_mode_start(evas_object_data_get(phoneui_d->navi, "clist_d")); } else ctui_list_navi_set(CT_LIST_MODE_DEFAULT, evas_object_data_get(phoneui_d->navi, "clist_d")); break; case PH_VIEW_LOG: if (NULL == phoneui_d->sub_view[tab_index]) phoneui_d->sub_view[tab_index] = phone_create_log_view(view_info); phone_log_set_background(phoneui_d->navi, false); if (!phoneui_d->ug) phone_log_missed_info_update(phoneui_d->navi); if (PH_UG_REQUEST_CHECK == phoneui_d->ug_request || PH_UG_REQUEST_CHECK_FOR_NUMBER == phoneui_d->ug_request || PH_UG_REQUEST_CHECK_FOR_EMAIL == phoneui_d->ug_request || PH_UG_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL == phoneui_d->ug_request) phone_log_check_mode_start(evas_object_data_get(phoneui_d->navi, "log_data")); else phone_log_set_navi(phoneui_d->navi); break; case PH_VIEW_FAVORITE: if (NULL == phoneui_d->sub_view[tab_index]) phoneui_d->sub_view[tab_index] = phone_favor_create_view(view_info); phone_favor_set_background(phoneui_d->sub_view[PH_VIEW_FAVORITE], false); if (phoneui_d->ug && (PH_UG_REQUEST_CHECK == phoneui_d->ug_request || PH_UG_REQUEST_CHECK_FOR_NUMBER == phoneui_d->ug_request || PH_UG_REQUEST_CHECK_FOR_EMAIL == phoneui_d->ug_request || PH_UG_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL == phoneui_d->ug_request)) { phone_favor_edit_mode_start(evas_object_data_get(phoneui_d->sub_view[tab_index], "favor_d")); } else phone_favor_set_navi(phoneui_d->sub_view[tab_index], PH_FAVOR_MODE_DEFAULT); break; default: free(view_info); ERR("INVALID tab_index: %d", tab_index); return; } phoneui_d->select_tab = tab_index; view = elm_object_part_content_unset(phoneui_d->layout, "elm.swallow.content"); if (view) evas_object_hide(view); elm_object_part_content_set(phoneui_d->layout, "elm.swallow.content", phoneui_d->sub_view[tab_index]); evas_object_show(phoneui_d->sub_view[tab_index]); free(view_info); } static Eina_Bool front_view_load_all_sub_view(void *data) { PH_FN_CALL; ph_phoneui_data *phoneui_d = data; int i; for (i=PH_VIEW_DIALER;iview_visible[i] && NULL == phoneui_d->sub_view[i]) { front_view_load_sub_view(phoneui_d, i); return ECORE_CALLBACK_RENEW; } } phoneui_d->idler = NULL; return ECORE_CALLBACK_CANCEL; } API Eina_Bool phone_front_view_load_timer(void *data) { ph_phoneui_data *phoneui_d = data; phoneui_d->idler = ecore_idler_add(front_view_load_all_sub_view, phoneui_d); phoneui_d->timer = NULL; return ECORE_CALLBACK_CANCEL; } static void pfront_view_change_cb(void *data, Evas_Object *obj, void *event_info) { PH_FN_CALL; int i; Elm_Object_Item *selected_it; ph_phoneui_data *phoneui_d = data; selected_it = elm_toolbar_selected_item_get(obj); for (i=PH_VIEW_DIALER;iitem[i]) if (selected_it == phoneui_d->item[i]) break; } PH_DBG("cur sel : %d, sel index : %d", phoneui_d->select_tab, i); front_view_show_sub_view(phoneui_d, i); #ifdef _PHONE_CONTACTS_DESKTOP_MODE_ if(phoneui_d->is_desktop_mode) { Elm_Object_Item *navi_item = elm_naviframe_bottom_item_get(phoneui_d->navi); elm_object_item_part_content_set(navi_item, "prev_btn", NULL); } #endif } static void pfront_view_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { PH_FN_CALL; ph_phoneui_data *phoneui_d = data; int i; p_retm_if(NULL == phoneui_d, "phoneui_d is null"); for (i=0;isub_view[i]) evas_object_del(phoneui_d->sub_view[i]); } if (phoneui_d->idler) ecore_idler_del(phoneui_d->idler); if (phoneui_d->timer) ecore_timer_del(phoneui_d->timer); if(!phoneui_d->ug) { PH_DBG("no ug"); free(phoneui_d); } else { PH_DBG("view destroy called earlier than ug destroy"); phoneui_d->ug = NULL; } PH_FN_END; } Evas_Object* ph_front_create_toolbar(ph_phoneui_data *phoneui_d) { Evas_Object *base; Evas_Object *layout; Evas_Object *naviframe; Evas_Object *toolbar; Elm_Object_Item *navi_it; Evas_Object *conform; conform = elm_conformant_add(phoneui_d->win); p_retvm_if(NULL == conform, NULL, "elm_conformant_add() Failed"); evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); base = elm_layout_add(conform); p_retvm_if(NULL == base, NULL, "elm_layout_add() Failed"); evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_layout_theme_set(base, "layout", "application", "default"); elm_win_resize_object_add(phoneui_d->win, conform); elm_object_content_set(conform, base); evas_object_show(base); evas_object_show(conform); naviframe = elm_naviframe_add(base); elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE); elm_object_part_content_set(base, "elm.swallow.content", naviframe); phoneui_d->navi = naviframe; layout = elm_layout_add(naviframe); p_retvm_if(NULL == layout, NULL, "elm_layout_add() Failed"); elm_layout_theme_set(layout, "layout", "tabbar", "default"); phoneui_d->layout = layout; toolbar = elm_toolbar_add(naviframe); p_retvm_if(NULL == toolbar, NULL, "elm_toolbar_add() Failed"); elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); elm_object_style_set(toolbar, "tabbar"); elm_object_part_content_set(layout, "elm.swallow.tabbar", toolbar); phoneui_d->tabbar = toolbar; elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND); if (phoneui_d->view_visible[PH_VIEW_DIALER]) phoneui_d->item[PH_VIEW_DIALER] = elm_toolbar_item_append(toolbar, PH_IMG_ICON_DIALER, T_(PH_GET_TEXT_BASIC, PHTEXT_KEYPAD), pfront_view_change_cb, phoneui_d); if (phoneui_d->view_visible[PH_VIEW_CONTACT]) phoneui_d->item[PH_VIEW_CONTACT] = elm_toolbar_item_append(toolbar, PH_IMG_ICON_CONTACTS, S_(PH_SYS_BODY_CONTACTS), pfront_view_change_cb, phoneui_d); if (phoneui_d->view_visible[PH_VIEW_LOG]) phoneui_d->item[PH_VIEW_LOG] = elm_toolbar_item_append(toolbar, PH_IMG_ICON_LOGS, T_(PH_GET_TEXT_BASIC, PHTEXT_LOGS), pfront_view_change_cb, phoneui_d); if (phoneui_d->view_visible[PH_VIEW_FAVORITE]) phoneui_d->item[PH_VIEW_FAVORITE] = elm_toolbar_item_append(toolbar, PH_IMG_ICON_FAVORITE, T_(PH_GET_TEXT_BASIC, PHTEXT_FAVORITES), pfront_view_change_cb, phoneui_d); navi_it = elm_naviframe_item_push(naviframe, NULL, NULL, NULL, layout, NULL); elm_naviframe_item_title_visible_set(navi_it, EINA_FALSE); evas_object_event_callback_add(base, EVAS_CALLBACK_DEL, pfront_view_delete_cb, phoneui_d); return base; } API ph_phoneui_data* phone_front_view_create(Evas_Object *win) { PH_FN_CALL; Evas_Object *bg; Evas_Object *layout; ph_phoneui_data *phoneui_d = calloc(1, sizeof(ph_phoneui_data)); phoneui_d->win = win; phoneui_d->select_tab = PH_VIEW_NONE; phoneui_d->view_visible[PH_VIEW_DIALER] = true; phoneui_d->view_visible[PH_VIEW_CONTACT] = true; phoneui_d->view_visible[PH_VIEW_LOG] = true; phoneui_d->view_visible[PH_VIEW_FAVORITE] = true; layout = ph_front_create_toolbar(phoneui_d); if (NULL == layout) { PH_DBG("layout_main is null"); free(phoneui_d); return NULL; } bg = phone_create_bg(layout); if (NULL == bg) { PH_DBG("phone_create_bg() return NULL"); free(phoneui_d); return NULL; } return phoneui_d; } API void phone_front_view_region_changed(ph_phoneui_data *phoneui_d) { if (phoneui_d && phoneui_d->sub_view[PH_VIEW_LOG]) phone_log_views_update(phoneui_d->navi); } API void phone_front_view_pause(ph_phoneui_data *phoneui_d) { if (phoneui_d && phoneui_d->sub_view[PH_VIEW_LOG]) phone_log_set_background(phoneui_d->navi, true); if (phoneui_d && phoneui_d->sub_view[PH_VIEW_CONTACT]) ctui_list_view_pause(phoneui_d->navi); if (phoneui_d && phoneui_d->sub_view[PH_VIEW_DIALER]) phone_dialer_set_background(phoneui_d->sub_view[PH_VIEW_DIALER], true); if (phoneui_d && phoneui_d->sub_view[PH_VIEW_FAVORITE]) phone_favor_set_background(phoneui_d->sub_view[PH_VIEW_FAVORITE], true); } API void phone_front_view_resume(ph_phoneui_data *phoneui_d) { if (phoneui_d && phoneui_d->sub_view[PH_VIEW_LOG]) { if (PH_VIEW_LOG == phoneui_d->select_tab) { phone_log_set_background(phoneui_d->navi, false); phone_log_view_resume(phoneui_d->navi); } } if (phoneui_d && phoneui_d->sub_view[PH_VIEW_CONTACT]) ctui_list_view_resume(phoneui_d->navi); if (phoneui_d && phoneui_d->sub_view[PH_VIEW_DIALER]) { if (PH_VIEW_DIALER == phoneui_d->select_tab) { phone_dialer_set_background(phoneui_d->sub_view[PH_VIEW_DIALER], false); phone_dialer_view_resume(phoneui_d->sub_view[PH_VIEW_DIALER]); } } if (phoneui_d && phoneui_d->sub_view[PH_VIEW_FAVORITE] && PH_VIEW_FAVORITE == phoneui_d->select_tab) phone_favor_set_background(phoneui_d->sub_view[PH_VIEW_FAVORITE], false); } static void front_view_win_activate(void *data, Evas *e, void *even_info) { elm_win_activate(data); evas_event_callback_del(e, EVAS_CALLBACK_RENDER_FLUSH_POST, front_view_win_activate); } API void phone_front_view_language_changed(ph_phoneui_data *phoneui_d) { p_retm_if(NULL == phoneui_d, "parameter(phoneui_d) is NULL"); // 1. Update toolbar if (phoneui_d->item[PH_VIEW_LOG]) elm_object_item_text_set(phoneui_d->item[PH_VIEW_LOG], T_(PH_GET_TEXT_BASIC, PHTEXT_LOGS)); if (phoneui_d->item[PH_VIEW_CONTACT]) elm_object_item_text_set(phoneui_d->item[PH_VIEW_CONTACT], S_(PH_SYS_BODY_CONTACTS)); if (phoneui_d->item[PH_VIEW_DIALER]) elm_object_item_text_set(phoneui_d->item[PH_VIEW_DIALER], T_(PH_GET_TEXT_BASIC, PHTEXT_KEYPAD)); if (phoneui_d->item[PH_VIEW_FAVORITE]) elm_object_item_text_set(phoneui_d->item[PH_VIEW_FAVORITE], T_(PH_GET_TEXT_BASIC, PHTEXT_FAVORITES)); // 2. update view if (phoneui_d->sub_view[PH_VIEW_LOG]) phone_log_view_language_changed(phoneui_d->navi); if (phoneui_d->sub_view[PH_VIEW_CONTACT]) ctui_list_view_language_changed(phoneui_d->navi); if (phoneui_d->sub_view[PH_VIEW_DIALER]) phone_dialer_view_language_changed(phoneui_d->sub_view[PH_VIEW_DIALER]); if (phoneui_d->sub_view[PH_VIEW_FAVORITE]) phone_favor_view_language_changed(phoneui_d->sub_view[PH_VIEW_FAVORITE]); } API void phone_front_view_reset(ph_phoneui_data *phoneui_d, int select_index, int op, service_h service) { PH_FN_CALL; int call_launched = FALSE; ph_view_info *view_info; Evas_Object *view; int ret; elm_toolbar_select_mode_set(phoneui_d->tabbar, ELM_OBJECT_SELECT_MODE_NONE); front_view_reset_current_sub_view(phoneui_d); if (phoneui_d->sub_view[PH_VIEW_CONTACT]) ctui_list_view_resume(phoneui_d->navi); view = elm_object_part_content_unset(phoneui_d->layout, "elm.swallow.content"); if (view) evas_object_hide(view); elm_toolbar_select_mode_set(phoneui_d->tabbar, ELM_OBJECT_SELECT_MODE_ALWAYS); view_info = calloc(1, sizeof(ph_view_info)); phone_set_view_info(view_info, phoneui_d->win, phoneui_d->navi, phoneui_d->ug, phoneui_d->ug_request, phoneui_d->cnt_max, phoneui_d->ug_data); switch (select_index) { case PH_VIEW_DIALER: if (NULL == phoneui_d->sub_view[select_index]) phoneui_d->sub_view[select_index] = phone_create_dialer_view(view_info); if (PH_FRONT_DIALER_WITH_NUM == op) { char *num = NULL; ret = service_get_uri(service, &num); p_warn_if(SERVICE_ERROR_NONE != ret, "service_get_uri is failed(%d)", ret); phone_dialer_view_set_num(phoneui_d->sub_view[PH_VIEW_DIALER], num+4); free(num); } else if(PH_FRONT_DIALER_WITH_SEND_KEY == op) { phone_dialer_view_send_key(phoneui_d->sub_view[PH_VIEW_DIALER]); } else { phone_dialer_view_resume(phoneui_d->sub_view[PH_VIEW_DIALER]); } phone_dialer_set_navi(phoneui_d->sub_view[PH_VIEW_DIALER]); phone_dialer_check_focus(phoneui_d->sub_view[PH_VIEW_DIALER]); phone_dialer_set_background(phoneui_d->sub_view[PH_VIEW_DIALER], false); if(!phoneui_d->ug) call_launched = phone_front_view_show_call_app(phoneui_d); break; case PH_VIEW_CONTACT: if (NULL == phoneui_d->sub_view[select_index]) { phoneui_d->sub_view[PH_VIEW_CONTACT] = ctui_create_phone_list_view(view_info); } ctui_list_navi_set(CT_LIST_MODE_DEFAULT, evas_object_data_get(phoneui_d->navi, "clist_d")); break; case PH_VIEW_LOG: if (NULL == phoneui_d->sub_view[select_index]) phoneui_d->sub_view[select_index] = phone_create_log_view(view_info); if (!phoneui_d->ug) phone_log_missed_info_update(phoneui_d->navi); if (PH_FRONT_LOG_MISSED == op) phone_viewby_type_set(phoneui_d->navi, VIEWBY_MISSED_CALL); phone_log_set_navi(phoneui_d->navi); break; case PH_VIEW_FAVORITE: if (NULL == phoneui_d->sub_view[select_index]) phoneui_d->sub_view[select_index] = phone_favor_create_view(view_info); phone_favor_set_navi(phoneui_d->sub_view[select_index], PH_FAVOR_MODE_DEFAULT); phone_favor_set_background(phoneui_d->sub_view[PH_VIEW_FAVORITE], false); break; default: break; } phoneui_d->select_tab = select_index; if (PH_VIEW_NONE < select_index && select_index < PH_VIEW_MAX) { elm_object_part_content_set(phoneui_d->layout, "elm.swallow.content", phoneui_d->sub_view[select_index]); evas_object_show(phoneui_d->sub_view[select_index]); elm_toolbar_item_selected_set(phoneui_d->item[select_index], EINA_TRUE); } if (phoneui_d->win && FALSE == call_launched && PH_VIEW_NONE != select_index) { if (EINA_FALSE == evas_object_visible_get(phoneui_d->win)) evas_object_show(phoneui_d->win); evas_event_callback_add(evas_object_evas_get(phoneui_d->navi), EVAS_CALLBACK_RENDER_FLUSH_POST, front_view_win_activate, phoneui_d->win); elm_win_activate(phoneui_d->win); } else elm_win_lower(phoneui_d->win); phoneui_d->timer = ecore_timer_add(3.0, phone_front_view_load_timer, phoneui_d); free(view_info); PH_FN_END; } static bool front_view_call_app_check(service_h service, const char *pkg_name, void *data) { int *call_app_launched = data; // premise : Only one Call app can be running at a time if (1 == aul_app_is_running(pkg_name)) { aul_open_app(pkg_name); *call_app_launched = TRUE; return true; } return true; } API int phone_front_view_show_call_app(ph_phoneui_data *phoneui_d) { PH_FN_CALL; service_h service; int call_app_launched = FALSE; service_create(&service); service_set_operation(service, SERVICE_OPERATION_CALL); service_set_uri(service, "tel:"); service_foreach_app_matched(service, front_view_call_app_check, (void *)&call_app_launched); if (call_app_launched) return 1; if (1 == aul_app_is_running(VIDEOCALL_PKG)) { aul_open_app(VIDEOCALL_PKG); return 1; } return 0; }