diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 01:37:52 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 01:37:52 +0900 |
commit | 568c09651ccbdc576bc7662af3d9328728370262 (patch) | |
tree | 6edbe93ecee55afe6b0cb401f600d11f2212180c /lib/speed | |
parent | b9b4104f70d3f35414260d964f4c7c0221d21446 (diff) | |
download | phone-contacts-568c09651ccbdc576bc7662af3d9328728370262.tar.gz phone-contacts-568c09651ccbdc576bc7662af3d9328728370262.tar.bz2 phone-contacts-568c09651ccbdc576bc7662af3d9328728370262.zip |
Tizen 2.1 base
Diffstat (limited to 'lib/speed')
-rwxr-xr-x | lib/speed/CMakeLists.txt | 16 | ||||
-rwxr-xr-x | lib/speed/include/phone-speed.h | 25 | ||||
-rwxr-xr-x | lib/speed/ph-speeddial-main.c | 203 | ||||
-rwxr-xr-x | lib/speed/ph-speeddial-view.c | 588 | ||||
-rwxr-xr-x | lib/speed/ph-speeddial-view.h | 43 | ||||
-rw-r--r-- | lib/speed/speeddial-efl.xml | 29 |
6 files changed, 904 insertions, 0 deletions
diff --git a/lib/speed/CMakeLists.txt b/lib/speed/CMakeLists.txt new file mode 100755 index 0000000..a0979cf --- /dev/null +++ b/lib/speed/CMakeLists.txt @@ -0,0 +1,16 @@ +LINK_DIRECTORIES(${CMAKE_BINARY_DIR}) + +SET(TARGET ${SPEEDDIAL}) + +FILE(GLOB SRCS *.c) + +ADD_LIBRARY(${TARGET} SHARED ${SRCS}) +SET_TARGET_PROPERTIES(${TARGET} PROPERTIES VERSION ${VERSION}) +SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS}) +TARGET_LINK_LIBRARIES(${TARGET} ${COMMON_LIB} ${ug_pkgs_LDFLAGS}) + +ADD_DEPENDENCIES(${TARGET} speeddial_theme_build) + +INSTALL(TARGETS ${TARGET} DESTINATION ${UGLIBDIR}) + +INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/speed/speeddial-efl.xml DESTINATION "/usr/share/packages") diff --git a/lib/speed/include/phone-speed.h b/lib/speed/include/phone-speed.h new file mode 100755 index 0000000..337f00e --- /dev/null +++ b/lib/speed/include/phone-speed.h @@ -0,0 +1,25 @@ +/* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.0 (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. +*/ + + +#ifndef __PHONE_SPEED_H__ +#define __PHONE_SPEED_H__ + +#include "phone-common.h" + +Evas_Object *phone_create_speeddial_view(void *ug, Evas_Object *win, Evas_Object *navi); + +#endif //__PHONE_SPEED_H__ diff --git a/lib/speed/ph-speeddial-main.c b/lib/speed/ph-speeddial-main.c new file mode 100755 index 0000000..24d590c --- /dev/null +++ b/lib/speed/ph-speeddial-main.c @@ -0,0 +1,203 @@ +/* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.0 (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 <ui-gadget-module.h> +#include <bundle.h> + +#include "phone.h" +#include "phone-common.h" +#include "ph-speeddial-view.h" + +// for removing build warning //////////////////////////////////// +int service_export_as_bundle(service_h service, bundle **data); +//////////////////////////////////////////////////////// + +static bool speed_create_ug_view(ph_speeddial_data * speed_d, Evas_Object *base) +{ + p_retvm_if(NULL == speed_d, false, "Parameter is null"); + + if (NULL == speed_d->navi) { + speed_d->navi = elm_naviframe_add(base); + p_retvm_if(NULL == speed_d->navi, false, "elm_naviframe_add is failed"); + elm_object_part_content_set(base, "elm.swallow.content", speed_d->navi); + evas_object_show(speed_d->navi); + } + + speed_d->layout = ph_speed_create_content(speed_d->navi, speed_d); + p_retvm_if(NULL == speed_d->layout, false, "Fail to ph_speed_create_content"); + + return true; +} + +static void *speed_on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) +{ + PH_FN_CALL; + contacts_error_e err = CONTACTS_ERROR_NONE; + Evas_Object *bg; + Evas_Object *base; + Evas_Object *parent; + ph_speeddial_data *speed_d; + + if (!ug || !priv) + return NULL; + + bindtextdomain(PACKAGE, LOCALEDIR); + + parent = ug_get_parent_layout(ug); + if (!parent) + return NULL; + + speed_d = priv; + speed_d->ug = ug; + speed_d->win = ug_get_window(); + speed_d->is_ug = true; + + err = contacts_connect2(); + p_retvm_if(CONTACTS_ERROR_NONE != err, NULL, "contacts_connect2() Failed(%d)", err); + + if (mode==UG_MODE_FULLVIEW) + base = phone_create_base_layout(parent, true); + else + base = phone_create_base_layout(parent, false); + + bg = phone_create_bg(base); + if (NULL == bg) { + PH_DBG("phone_create_bg() return NULL"); + evas_object_del(base); + err = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err); + return NULL; + } + + if (!speed_create_ug_view(speed_d, base)) { + evas_object_del(base); + err = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err); + } + return base; +} + +static void speed_on_start(ui_gadget_h ug, service_h service, void *priv) +{ +} + +static void speed_on_pause(ui_gadget_h ug, service_h service, void *priv) +{ +} + +static void speed_on_resume(ui_gadget_h ug, service_h service, void *priv) +{ +} + +static void speed_on_destroy(ui_gadget_h ug, service_h service, void *priv) +{ + PH_FN_CALL; + contacts_error_e err = CONTACTS_ERROR_NONE; + if (!ug) + return; + + evas_object_del(ug_get_layout(ug)); + err = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err); +} + +static void speed_on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv) +{ +} + +static void speed_on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv) +{ + switch (event) { + case UG_EVENT_ROTATE_PORTRAIT: + case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN: + case UG_EVENT_ROTATE_LANDSCAPE: + case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN: + break; + case UG_EVENT_LANG_CHANGE: + break; + default: + break; + } +} + +static void speed_on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h data, void *priv) +{ + PH_FN_CALL; + if (!ug) + return; + + switch (event) { + case UG_KEY_EVENT_END: + ug_destroy_me(ug); + break; + default: + break; + } +} + +API int UG_MODULE_INIT(struct ug_module_ops *ops) +{ + ph_speeddial_data *speed_d; + + if (!ops) + return -1; + + speed_d = calloc(1, sizeof(ph_speeddial_data)); + if (!speed_d) + return -1; + + ops->create = speed_on_create; + ops->start = speed_on_start; + ops->pause = speed_on_pause; + ops->resume = speed_on_resume; + ops->destroy = speed_on_destroy; + ops->message = speed_on_message; + ops->event = speed_on_event; + ops->key_event = speed_on_key_event; + ops->priv = speed_d; + ops->opt = UG_OPT_INDICATOR_ENABLE; + + return 0; +} + +API void UG_MODULE_EXIT(struct ug_module_ops *ops) +{ + PH_FN_END; + if (!ops) + return; + + ops->priv = NULL; +} + +API Evas_Object *phone_create_speeddial_view(void *ug, Evas_Object *win, Evas_Object *navi) +{ + ph_speeddial_data * speed_d = calloc(1, sizeof(ph_speeddial_data)); + p_retvm_if(NULL == speed_d, NULL, "Faile to calloc ph_speeddial_data"); + + speed_d->ug = ug; + speed_d->is_ug = false; + speed_d->win = win; + speed_d->navi = navi; + speed_d->layout = ph_speed_create_content(navi, speed_d); + if (NULL == speed_d->layout) { + free(speed_d); + return NULL; + } + + return speed_d->layout; +} + diff --git a/lib/speed/ph-speeddial-view.c b/lib/speed/ph-speeddial-view.c new file mode 100755 index 0000000..15bbc59 --- /dev/null +++ b/lib/speed/ph-speeddial-view.c @@ -0,0 +1,588 @@ +/* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.0 (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 <Ecore_X.h> +#include <ui-gadget-module.h> + +#include "phone.h" +#include "phone-common.h" +#include "ph-speeddial-view.h" + +#define KEY_SPEED_DATA "speed_d" +#define SPEED_VOICE_MAIL_NUM 1 + +static Elm_Gengrid_Item_Class grid_itc, grid_itc_empty; + +enum{ + PH_SPEED_MODE_DEFAULT, + PH_SPEED_MODE_EDIT, +}; + +static void speed_edit_mode_start(ph_speeddial_data * speed_d); +static void speed_edit_mode_end(ph_speeddial_data * speed_d); + +static int speed_set_speeddial(int spdial_num, int number_id) +{ + contacts_record_h spd_record = NULL; + int ret_id = 0; + contacts_error_e err = CONTACTS_ERROR_NONE; + + contacts_record_create( _contacts_speeddial._uri, &spd_record ); + + err = contacts_record_set_int(spd_record, _contacts_speeddial.speeddial_number, spdial_num); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_set_int() Failed(%d)", err); + + err = contacts_record_set_int(spd_record, _contacts_speeddial.number_id, number_id); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_set_int() Failed(%d)", err); + + err = contacts_db_insert_record(spd_record, &ret_id); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_insert_record() Failed(%d)", err); + + contacts_record_destroy(spd_record, true); + return err; +} + +static int speed_unset_speeddial(int spdial_num) +{ + return contacts_db_delete_record( _contacts_speeddial._uri, spdial_num); +} + +static void speed_update_button_status(ph_speeddial_data *speed_d) +{ + p_retm_if(NULL == speed_d, "Parameter is null"); + p_retm_if(NULL == speed_d->ctrl_item, "Navi button is null"); + + if ((false == speed_d->is_edit_mode && 0 == speed_d->speeddial_list_count) + || (true == speed_d->is_edit_mode && 0 == speed_d->checked_cnt)) + elm_object_disabled_set(speed_d->ctrl_item, EINA_TRUE); + else + elm_object_disabled_set(speed_d->ctrl_item, EINA_FALSE); +} + +static void speed_load_list(ph_speeddial_data *speed_d) +{ + p_retm_if(NULL == speed_d, "Parameter is null"); + + phone_free_speeddial_data(speed_d->speeddial_list); + speed_d->speeddial_list_count = 0; + speed_d->speeddial_list = phone_load_speeddial_data(&(speed_d->speeddial_list_count)); +} + +static void speed_popup_response_cb(void *data, Evas_Object *obj, void *event_info) +{ + PH_FN_CALL; + ph_speeddial_data *speed_d = data; + evas_object_del(speed_d->popup); + speed_d->popup = NULL; +} + +static void speed_add_start_cb(void *data, void *data2) +{ + PH_FN_CALL; + ph_speeddial_data *speed_d = data; + int *number_id = data2; + int ret; + + p_retm_if(NULL == speed_d, "speed data is null"); + p_retm_if(*number_id <= 0, "returned number_id is less than 0"); + p_retm_if(20 < speed_d->cur_dial_num, "current dial num is higher than 20"); + + ret = speed_set_speeddial(speed_d->cur_dial_num, *number_id); + if (ret < 0) + phone_show_popup(speed_d->navi, S_(PH_SYS_POP_ALREDY_EXISTS), 2.0); +} + +static void speed_destroy_child_ug(void *data) +{ + ph_speeddial_data *speed_d = data; + speed_d->child_ug = NULL; +} + +static void speed_grid_empty_selected(void *data, Evas_Object *obj, void *event_info) +{ + ph_speeddial_data * speed_d = evas_object_data_get(obj, KEY_SPEED_DATA); + int index = (int)data; + p_retm_if(true == speed_d->is_edit_mode, "It is in Edit mode"); + elm_gengrid_item_selected_set(event_info, EINA_FALSE); + + speed_d->cur_dial_num = index; + speed_d->child_ug = phone_launch_contact_list_ug(speed_d->ug, CT_UG_REQUEST_SELECT_NUMBER, + speed_add_start_cb, speed_destroy_child_ug, speed_d); +} + +static void speed_change_start_cb(void *data, void *data2) +{ + PH_FN_CALL; + ph_speeddial_data *speed_d = data; + int *number_id = data2; + contacts_error_e err = CONTACTS_ERROR_NONE; + p_retm_if(NULL == speed_d, "speed data is null"); + p_retm_if(*number_id <= 0, "returned number_id is less than 0"); + p_retm_if(20 < speed_d->cur_dial_num, "current dial num is higher than 20"); + speed_unset_speeddial(speed_d->cur_dial_num); + err = speed_set_speeddial(speed_d->cur_dial_num, *number_id); + if (CONTACTS_ERROR_NONE != err) { + phone_show_popup(speed_d->navi, S_(PH_SYS_POP_ALREDY_EXISTS), 1.5); + } +} + +static void speed_grid_change_contact(void *data, Evas_Object *obj, void *event_info) +{ + PH_FN_CALL; + ph_speeddial_data *speed_d = data; + p_retm_if(NULL== speed_d, "Speeddial data is null"); + + speed_popup_response_cb(speed_d, NULL, NULL); + speed_d->child_ug = phone_launch_contact_list_ug(speed_d->ug, CT_UG_REQUEST_SELECT_NUMBER, + speed_change_start_cb, speed_destroy_child_ug, speed_d); +} + +static void speed_grid_remove_speeddial(void *data, Evas_Object *obj, void *event_info) +{ + PH_FN_CALL; + contacts_error_e err = CONTACTS_ERROR_NONE; + ph_speeddial_data *speed_d = data; + speed_popup_response_cb(speed_d, NULL, NULL); + err = speed_unset_speeddial(speed_d->cur_dial_num); + if (CONTACTS_ERROR_NONE != err) + phone_show_tickernoti(S_(PH_SYS_POP_FAILED)); + else + phone_show_tickernoti(S_(PH_SYS_POP_REMOVED)); +} + +static void speed_grid_item_sel(void *data, Evas_Object *obj, void *event_info) +{ + ph_speeddial_info *s_info = data; + ph_speeddial_data *speed_d = evas_object_data_get(obj, KEY_SPEED_DATA); + Evas_Object *popup; + Evas_Object *list; + Evas_Object *btn; + + p_retm_if(true == speed_d->is_edit_mode, "It is in Edit mode"); + elm_gengrid_item_selected_set(event_info, EINA_FALSE); + + p_retm_if(NULL == s_info, "speeddial info is null"); + if (SPEED_VOICE_MAIL_NUM == s_info->dial_number) + return; + + speed_d->cur_dial_num = s_info->dial_number; + popup = elm_popup_add(speed_d->win); + elm_object_style_set(popup, "min_liststyle"); + elm_object_part_text_set(popup, "title,text", S_(PH_SYS_SK_EDIT)); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + list = elm_list_add(popup); + elm_list_item_append(list, T_(PH_GET_TEXT_BASE_OP, PHTEXT_CHANGE_CONTACT), + NULL, NULL, speed_grid_change_contact, speed_d); + elm_list_item_append(list, S_(PH_SYS_BODY_REMOVE), + NULL, NULL, speed_grid_remove_speeddial, speed_d); + elm_list_mode_set(list, ELM_LIST_EXPAND); + elm_object_content_set(popup, list); + + btn = elm_button_add(popup); + elm_object_text_set(btn, S_(PH_SYS_POP_CLOSE)); + elm_object_part_content_set(popup, "button1", btn); + elm_object_style_set(btn, "popup_button/default"); + evas_object_smart_callback_add(btn, "clicked", speed_popup_response_cb, speed_d); + + speed_d->popup = popup; + evas_object_show(popup); +} + +static void speed_fill_gengrid(ph_speeddial_data *speed_d) +{ + int i; + p_retm_if(NULL == speed_d, "Parameter is null"); + + for(i = 1 ; i < 10; i++) { + Eina_List *l=NULL; + bool is_find = false; + ph_speeddial_info *cd = NULL; + + EINA_LIST_FOREACH(speed_d->speeddial_list, l, cd) { + if (!cd) continue; + if (cd->dial_number == i) { + is_find = true; + break; + } + } + if (is_find) + elm_gengrid_item_append(speed_d->gengrid, &grid_itc, cd, speed_grid_item_sel, cd); + else + elm_gengrid_item_append(speed_d->gengrid, &grid_itc_empty, (void*)i, speed_grid_empty_selected, (void*)i); + } + evas_object_show(speed_d->gengrid); +} + +static void speed_data_list_changed_cb(const char* view_uri, void* data) +{ + PH_FN_CALL; + ph_speeddial_data *speed_d = data; + p_retm_if(NULL == speed_d, "Parameter is null"); + if (speed_d->gengrid) { + speed_d->checked_cnt = 0; + speed_load_list(speed_d); + elm_gengrid_clear(speed_d->gengrid); + speed_fill_gengrid(speed_d); + speed_update_button_status(speed_d); + } + PH_FN_END; +} + +static char *speed_grid_empty_label_get(void *data, Evas_Object *obj, const char *part ) +{ + if (0 == strcmp(part, "elm.text.number")) { + int index = (int)data; + char buf[PATH_MAX]={0}; + snprintf(buf, sizeof(buf), "%d", index); + return strdup(buf); + } + return NULL; +} + +static char *speed_grid_label_get(void *data, Evas_Object *obj, const char *part ) +{ + char buf[PATH_MAX]={0}; + ph_speeddial_info * s_info = data; + + p_retvm_if(NULL == s_info, NULL, "speeddial info is null"); + + if (0 == strcmp(part, "elm.text.number")) { + if (SPEED_VOICE_MAIL_NUM == s_info->dial_number) + return NULL; + snprintf(buf, sizeof(buf), "%d", s_info->dial_number); + return strdup(buf); + } + else if (0 == strcmp(part, "elm.text")) { + if (s_info->display && *s_info->display) + snprintf(buf, sizeof(buf), "%s", s_info->display); + else if (s_info->ph_number && *s_info->ph_number) + snprintf(buf, sizeof(buf), "%s", s_info->ph_number); + else + return NULL; + return strdup(buf); + } + return NULL; +} + +static void speed_del_btn_cb(void *data, Evas_Object *obj, void *event_info) +{ + ph_speeddial_data *speed_d = data; + ph_speeddial_info *s_info = NULL; + Eina_List *l; + bool deleted = false; + + EINA_LIST_FOREACH(speed_d->speeddial_list, l, s_info) { + if (!s_info) continue; + if (EINA_TRUE == s_info->is_checked) { + PH_DBG("%d", s_info->dial_number); + speed_unset_speeddial(s_info->dial_number); + deleted = true; + } + } + + if (deleted){ + phone_hide_notify(speed_d->layout); + phone_show_tickernoti(S_(PH_SYS_POP_REMOVED)); + } + + speed_edit_mode_end(speed_d); +} + +static void speed_edit_set_selection_info(void *data) +{ + ph_speeddial_data *speed_d = data; + p_retm_if(NULL == speed_d, "Selection info is null"); + + if (0 == speed_d->checked_cnt) + phone_hide_notify(speed_d->layout); + else { + char info_text[PH_TEXT_SHORT_LEN]={0}; + snprintf(info_text, sizeof(info_text), "%s (%d)", S_(PH_SYS_POP_SELECTED), + speed_d->checked_cnt); + phone_show_notify(speed_d->layout, info_text); + } +} + +static void speed_edit_check_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + ph_speeddial_data *speed_d = data; + if (elm_check_state_get(obj)) + speed_d->checked_cnt++; + else + speed_d->checked_cnt--; + speed_edit_set_selection_info(speed_d); + speed_update_button_status(speed_d); +} + +static Evas_Object *speed_grid_content_get(void *data, Evas_Object *obj, const char *part ) +{ + ph_speeddial_info *s_info = data; + p_retvm_if(NULL == s_info, NULL, "parameter is null"); + ph_speeddial_data *speed_d = evas_object_data_get(obj, KEY_SPEED_DATA); + + if ((0 == strcmp(part, "elm.thumbnail")) || (0 == strcmp(part, "elm.swallow.icon"))) { + Evas_Object *ic; + if (s_info->img_path) + ic = phone_create_icon_with_img(obj, s_info->img_path); + else + ic = phone_create_icon_with_img(obj, IMG_DEFAULT); + if (SPEED_VOICE_MAIL_NUM == s_info->dial_number) + elm_icon_resizable_set(ic, EINA_FALSE, EINA_FALSE); + return ic; + } + else if (0 == strcmp(part, "elm.swallow.check.icon") && speed_d->is_edit_mode) { + Evas_Object *btn; + if (SPEED_VOICE_MAIL_NUM == s_info->dial_number) + return NULL; + btn = elm_check_add(obj); + elm_object_style_set(btn, "grid"); + elm_check_state_pointer_set(btn, &(s_info->is_checked)); + evas_object_smart_callback_add(btn, "changed", speed_edit_check_changed_cb, speed_d); + evas_object_propagate_events_set(btn, EINA_FALSE); + return btn; + } + return NULL; +} + +static void speed_edit_back_btn_cb(void *data, Evas_Object *obj, void *event_info) +{ + Elm_Object_Item *item; + ph_speeddial_data *speed_d = data; + ph_speeddial_info *s_info; + Eina_List *l; + + EINA_LIST_FOREACH(speed_d->speeddial_list, l, s_info) { + if (!s_info) continue; + s_info->is_checked = EINA_FALSE; + } + speed_d->checked_cnt = 0; + phone_hide_notify(speed_d->layout); + speed_edit_mode_end(speed_d); + + item = elm_gengrid_first_item_get(speed_d->gengrid); + while (item) { + elm_gengrid_item_update(item); + item = elm_gengrid_item_next_get(item); + } +} + +static void speed_edit_btn_cb(void *data, Evas_Object *obj, void *event_info) +{ + ph_speeddial_data *speed_d = data; + speed_edit_mode_start(speed_d); +} + +static void speed_navi_set(int mode, ph_speeddial_data *speed_d) +{ + Elm_Object_Item *navi_it; + Evas_Object *back_btn, *toolbar_btn; + + p_retm_if(NULL == speed_d, "parameter(controlbar) is NULL"); + + navi_it = elm_naviframe_top_item_get(speed_d->navi); + p_retm_if(NULL == navi_it, "navi item is NULL"); + + if (speed_d->navi) { + phone_navi_item_clear(speed_d->navi_item); + } + + back_btn = elm_button_add(speed_d->navi); + elm_object_item_part_content_set(speed_d->navi_item, "prev_btn", back_btn); + + switch (mode) { + case PH_SPEED_MODE_DEFAULT: + toolbar_btn = phone_create_toolbar_btn(speed_d->navi, S_(PH_SYS_SK_DELETE), speed_edit_btn_cb, speed_d); + elm_object_item_part_content_set(speed_d->navi_item, "toolbar_button1", toolbar_btn); + elm_object_style_set(back_btn, "naviframe/back_btn/default"); + if (speed_d->is_ug) + evas_object_smart_callback_add(back_btn, "clicked", phone_ug_destroy_me_cb, speed_d->ug); + else + evas_object_smart_callback_add(back_btn, "clicked", phone_view_back_btn_cb, speed_d->navi); + + break; + case PH_SPEED_MODE_EDIT: + toolbar_btn = phone_create_toolbar_btn(speed_d->navi, S_(PH_SYS_SK_DELETE), speed_del_btn_cb, speed_d); + elm_object_item_part_content_set(speed_d->navi_item, "toolbar_button1", toolbar_btn); + elm_object_style_set(back_btn, "naviframe/back_btn/default"); + evas_object_smart_callback_add(back_btn, "clicked", speed_edit_back_btn_cb, speed_d); + break; + default: + return; + } + if(toolbar_btn) + speed_d->ctrl_item = toolbar_btn; + speed_update_button_status(speed_d); +} + +static void speed_edit_mode_start(ph_speeddial_data *speed_d) +{ + Elm_Object_Item *item; + + speed_d->is_edit_mode = true; + + item = elm_gengrid_first_item_get(speed_d->gengrid); + while (item) { + elm_gengrid_item_update(item); + item = elm_gengrid_item_next_get(item); + } + elm_object_item_part_text_set(speed_d->navi_item, "elm.text.title", T_(PH_GET_TEXT_BASE_OP, PHTEXT_SELECT_SPEED_DIAL_CONTACTS)); + speed_navi_set(PH_SPEED_MODE_EDIT, speed_d); +} + +static void speed_edit_mode_end(ph_speeddial_data *speed_d) +{ + Evas_Object *back_btn; + + speed_d->is_edit_mode = false; + back_btn = elm_button_add(speed_d->layout); + if (speed_d->is_ug) + evas_object_smart_callback_add(back_btn, "clicked", phone_ug_destroy_me_cb, speed_d->ug); + else + evas_object_smart_callback_add(back_btn, "clicked", phone_view_back_btn_cb, speed_d->navi); + + elm_object_item_part_content_set(speed_d->navi_item, "prev_btn", back_btn); + elm_object_style_set(back_btn, "naviframe/back_btn/default"); + + elm_object_item_part_text_set(speed_d->navi_item, "elm.text.title", T_(PH_GET_TEXT_BASIC, PHTEXT_SPEEDDIAL)); + speed_navi_set(PH_SPEED_MODE_DEFAULT, speed_d); +} + +static Evas_Object* speed_create_gengrid(ph_speeddial_data *speed_d, Evas_Object *parent) +{ + Evas_Object *gengrid; + int wx = 0; + int hy = 0; + + p_retvm_if(NULL == speed_d, NULL, "Parameter is null"); + + gengrid = elm_gengrid_add(parent); + p_retvm_if(NULL == gengrid, NULL, "elm_gengrid_add is failed"); + elm_object_theme_set(gengrid, speed_d->th); + + ecore_x_window_size_get(ecore_x_window_root_get(ecore_x_window_focus_get()), &wx, &hy); + elm_gengrid_item_size_set(gengrid, wx/3, 273); + elm_gengrid_align_set(gengrid, 0.5, 0.0); + elm_gengrid_horizontal_set(gengrid, EINA_FALSE); + elm_gengrid_bounce_set(gengrid, EINA_FALSE, EINA_TRUE); + elm_gengrid_multi_select_set(gengrid, EINA_TRUE); + + evas_object_size_hint_weight_set(gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + grid_itc_empty.item_style = "gridtext_speeddial"; + grid_itc_empty.func.text_get = speed_grid_empty_label_get; + grid_itc_empty.func.content_get = NULL; + grid_itc_empty.func.state_get = NULL; + grid_itc_empty.func.del = NULL; + + grid_itc.item_style = "gridtext_speeddial"; + grid_itc.func.text_get = speed_grid_label_get; + grid_itc.func.content_get = speed_grid_content_get; + grid_itc.func.state_get = NULL; + grid_itc.func.del = NULL; + + evas_object_data_set(gengrid, KEY_SPEED_DATA, speed_d); + + return gengrid; +} + +static void speed_view_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + PH_FN_CALL; + ph_speeddial_data *speed_d = data; + contacts_error_e err = CONTACTS_ERROR_NONE; + + p_retm_if(NULL == speed_d, "speed data is null"); + + err = contacts_db_remove_changed_cb(_contacts_person._uri, speed_data_list_changed_cb, speed_d); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); + err = contacts_db_remove_changed_cb(_contacts_speeddial._uri, speed_data_list_changed_cb, speed_d); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); + + if (speed_d->speeddial_list) + phone_free_speeddial_data(speed_d->speeddial_list); + + if (speed_d->th) { + elm_theme_extension_del(speed_d->th, SPEEDDIAL_THEME_EDJ); + elm_theme_free(speed_d->th); + } + + if (speed_d->popup) + evas_object_del(speed_d->popup); + + if (!speed_d->ug && speed_d->child_ug) + ug_destroy(speed_d->child_ug); + + free(speed_d); + PH_FN_END; +} + +static int speed_create_layout(ph_speeddial_data *speed_d) +{ + Evas_Object *layout; + Evas_Object *base; + Evas_Object *gengrid; + + base = elm_layout_add(speed_d->navi); + p_retvm_if(NULL == base, 0, "elm_layout_add() return NULL"); + elm_layout_file_set(base, SELECTION_INFO_EDJ, "selectioninfo_layout"); + + layout = phone_create_base_layout(base, false); + p_retvm_if(NULL == layout, 0, "fail : phone_create_base_layout"); + elm_object_part_content_set(base, "contents", layout); + speed_d->layout = base; + + gengrid = speed_create_gengrid(speed_d, layout); + p_retvm_if(NULL == gengrid, 0, "fail : _create_check_gengrid"); + speed_d->gengrid = gengrid; + elm_object_part_content_set(layout, "elm.swallow.content", gengrid); + + speed_load_list(speed_d); + speed_fill_gengrid(speed_d); + + evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, + speed_view_delete_cb, speed_d); + return 1; +} + +Evas_Object *ph_speed_create_content(Evas_Object *parent, ph_speeddial_data *speed_d) +{ + Elm_Theme *th; + int ret; + contacts_error_e err = CONTACTS_ERROR_NONE; + + th = elm_theme_new(); + elm_theme_ref_set(th, NULL); + elm_theme_extension_add(th, SPEEDDIAL_THEME_EDJ); + speed_d->th = th; + + ret = speed_create_layout(speed_d); + p_retvm_if(0 == ret, NULL, "speed_create_layout is failed"); + + speed_d->navi_item = elm_naviframe_item_push(speed_d->navi, T_(PH_GET_TEXT_BASIC, PHTEXT_SPEEDDIAL), NULL, + NULL, speed_d->layout, NULL); + + + speed_navi_set(PH_SPEED_MODE_DEFAULT, speed_d); + + err = contacts_db_add_changed_cb(_contacts_person._uri, speed_data_list_changed_cb, speed_d); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); + err = contacts_db_add_changed_cb(_contacts_speeddial._uri, speed_data_list_changed_cb, speed_d); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); + + return speed_d->layout; +} diff --git a/lib/speed/ph-speeddial-view.h b/lib/speed/ph-speeddial-view.h new file mode 100755 index 0000000..6b1535b --- /dev/null +++ b/lib/speed/ph-speeddial-view.h @@ -0,0 +1,43 @@ +/* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.0 (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. +*/ + + +#ifndef __SPEEDDIAL_VIEW_H__ +#define __SPEEDDIAL_VIEW_H__ + +typedef struct +{ + Evas_Object *win; + Evas_Object *navi; + Evas_Object *layout; + Evas_Object *gengrid; + Evas_Object *popup; + Elm_Object_Item *navi_item; + Evas_Object *ctrl_item; + Eina_List *speeddial_list; + int cur_dial_num; + int checked_cnt; + int speeddial_list_count; + Elm_Theme *th; + void *ug; + void *child_ug; + bool is_ug; + bool is_edit_mode; +}ph_speeddial_data; + +Evas_Object *ph_speed_create_content(Evas_Object *parent, ph_speeddial_data *speed_d); + +#endif /* __SPEEDDIAL_VIEW_H__ */ diff --git a/lib/speed/speeddial-efl.xml b/lib/speed/speeddial-efl.xml new file mode 100644 index 0000000..b807660 --- /dev/null +++ b/lib/speed/speeddial-efl.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns="http://tizen.org/ns/packages" package="speeddial-efl" version="0.1.0-0" install-location="internal-only"> + <label>speeddial</label> + <author email="ensung.park@samsung.com" href="www.samsung.com">ensung park</author> + <description>speeddial-efl Application</description> + <ui-application appid="speeddial-efl" exec="/usr/ug/bin/speeddial-efl" nodisplay="true" multiple="true" type="capp" taskmanage="false"> + <icon>org.tizen.contacts.png</icon> + <label>speeddial</label> + <label xml:lang="en-us">speeddial</label> + <label xml:lang="nl-nl">speeddial</label> + <label xml:lang="de-de">speeddial</label> + <label xml:lang="en-gb">speeddial</label> + <label xml:lang="zh-hk">speeddial</label> + <label xml:lang="zh-cn">speeddial</label> + <label xml:lang="ru-ru">speeddial</label> + <label xml:lang="zh-tw">speeddial</label> + <label xml:lang="ja-jp">speeddial</label> + <label xml:lang="es-es">speeddial</label> + <label xml:lang="el-gr">speeddial</label> + <label xml:lang="it-it">speeddial</label> + <label xml:lang="tr-tr">speeddial</label> + <label xml:lang="pt-pt">speeddial</label> + <label xml:lang="fr-fr">speeddial</label> + <label xml:lang="ko-kr">speeddial</label> + <application-service> + <operation name="http://tizen.org/ns/packages"/> + </application-service> + </ui-application> +</manifest> |