diff options
author | yunju06lee <yunju06.lee@samsung.com> | 2013-04-08 16:27:53 +0900 |
---|---|---|
committer | yunju06lee <yunju06.lee@samsung.com> | 2013-04-08 16:27:53 +0900 |
commit | 57a2c3a16d83ce182a0bbd4e5fcde98209b4be9f (patch) | |
tree | abbe3c65ec0f90f28ed19cb29c4e52a2b87240f2 | |
parent | 79b566ea3eb810aba86317f61360e2c6ec809b8a (diff) | |
download | phone-contacts-57a2c3a16d83ce182a0bbd4e5fcde98209b4be9f.tar.gz phone-contacts-57a2c3a16d83ce182a0bbd4e5fcde98209b4be9f.tar.bz2 phone-contacts-57a2c3a16d83ce182a0bbd4e5fcde98209b4be9f.zip |
apply new rotate rule
Change-Id: I293b40da9770a95c65e92678ab43fe43e65f10ae
-rwxr-xr-x | contacts-viewer/contacts-viewer.c | 88 | ||||
-rwxr-xr-x | contacts/contacts.c | 58 | ||||
-rwxr-xr-x | lib/common/ct-list-view-common.c | 29 | ||||
-rwxr-xr-x | lib/common/include/phone-common.h | 2 | ||||
-rwxr-xr-x | lib/ct-front/ct-front-view.c | 21 | ||||
-rwxr-xr-x | lib/ct-front/include/ct-front.h | 3 |
6 files changed, 95 insertions, 106 deletions
diff --git a/contacts-viewer/contacts-viewer.c b/contacts-viewer/contacts-viewer.c index 2cebc25..02eda8c 100755 --- a/contacts-viewer/contacts-viewer.c +++ b/contacts-viewer/contacts-viewer.c @@ -40,6 +40,7 @@ typedef struct { Evas_Object *icon; Evas_Object *prev_btn; #endif + int current_rotate; } ct_viewer_data; static void cv_win_del(void *data, Evas_Object *obj, void *event) @@ -103,6 +104,43 @@ static void __win_profile_changed_cb(void *data, Evas_Object *obj, void *event_i } } #endif // _PHONE_CONTACTS_DESKTOP_MODE_ + +static void __viewer_rotate_cb(void *data, Evas_Object *obj, void *event) +{ + ct_viewer_data *cviewer_d = data; + int changed_rotate = elm_win_rotation_get(obj); + +#ifndef _PHONE_CONTACTS_DESKTOP_MODE_ + const char *config = elm_config_profile_get(); + if (!strcmp(config, "desktop")) + return; +#endif + p_retm_if(cviewer_d == NULL || cviewer_d->win == NULL, "Paramter is NULL"); + + if (changed_rotate != cviewer_d->current_rotate) { + ERR("rotate changed %d", changed_rotate); + cviewer_d->current_rotate = changed_rotate; + switch (cviewer_d->current_rotate) { + case 0: + ug_send_event(UG_EVENT_ROTATE_PORTRAIT); + break; + case 180: + ug_send_event(UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN); + break; + case 270: + ug_send_event(UG_EVENT_ROTATE_LANDSCAPE); + break; + case 90: + ug_send_event(UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN); + break; + default: + break; + } + } +} + + + static bool viewer_create(void *data) { int rotate; @@ -123,8 +161,13 @@ static bool viewer_create(void *data) bindtextdomain(PACKAGE, LOCALEDIR); evas_object_show(win); - rotate = app_get_device_orientation(); - elm_win_rotation_with_resize_set(cviewer_d->win, rotate); + if (elm_win_wm_rotation_supported_get(win)) { + int rotation[4] = {0, 90, 180, 270}; + elm_win_wm_rotation_available_rotations_set(win, (const int *)(&rotation), 4); + cviewer_d->current_rotate = elm_win_rotation_get(win); + ERR("rotate current %d", cviewer_d->current_rotate); + evas_object_smart_callback_add(win, "wm,rotation,changed", __viewer_rotate_cb, cviewer_d); + } UG_INIT_EFL(cviewer_d->win, UG_OPT_INDICATOR_PORTRAIT_ONLY); @@ -488,46 +531,6 @@ static void viewer_service(service_h service, void *data) return; } -static void viewer_device_orientation(app_device_orientation_e orientation, void *data) -{ - PH_FN_CALL; - int rotate; - ct_viewer_data *cviewer_d = data; -#ifdef _PHONE_CONTACTS_DESKTOP_MODE_ - const char *config = elm_config_profile_get(); - if(!strcmp(config, "desktop")) - return; -#endif - p_retm_if(cviewer_d == NULL || cviewer_d->win == NULL, "Paramter is NULL"); - - switch (orientation) { - case APP_DEVICE_ORIENTATION_0: - rotate = 0; - ug_send_event(UG_EVENT_ROTATE_PORTRAIT); - break; - case APP_DEVICE_ORIENTATION_180: - rotate = 180; - ug_send_event(UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN); - break; - case APP_DEVICE_ORIENTATION_270: - rotate = 270; - ug_send_event(UG_EVENT_ROTATE_LANDSCAPE); - break; - case APP_DEVICE_ORIENTATION_90: - rotate = 90; - ug_send_event(UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN); - break; - default: - rotate = -1; - break; - } - - if (0 <= rotate) - elm_win_rotation_with_resize_set(cviewer_d->win, rotate); - - return; -} - API int main(int argc, char *argv[]) { ct_viewer_data ad = {0}; @@ -544,7 +547,6 @@ API int main(int argc, char *argv[]) event_callback.service = viewer_service; event_callback.low_memory = NULL; event_callback.low_battery = NULL; - event_callback.device_orientation = viewer_device_orientation; event_callback.language_changed = NULL; event_callback.region_format_changed = NULL; diff --git a/contacts/contacts.c b/contacts/contacts.c index 87c3679..fdaa9d3 100755 --- a/contacts/contacts.c +++ b/contacts/contacts.c @@ -37,6 +37,7 @@ struct contact_data Evas_Object *icon; Evas_Object *prev_btn; #endif + int current_rotate; }; static void ctapp_win_del(void *data, Evas_Object *obj, void *event) @@ -85,23 +86,6 @@ static void ctapp_language_changed(void *data) return; } -static void device_orientation(app_device_orientation_e orientation, void *data) -{ - PH_FN_CALL; - struct contact_data *ad = data; - ct_front_data *cfront_d = ad->cfront_d; -#ifdef _PHONE_CONTACTS_DESKTOP_MODE_ - const char *config = elm_config_profile_get(); - if(!strcmp(config, "desktop")) - return; -#endif - p_retm_if(cfront_d == NULL || cfront_d->win == NULL, "Paramter is NULL"); - p_ret_if(!cfront_d->auto_rorate_screen); - cfront_d->rotate = orientation; - ctui_front_view_rotate(cfront_d, orientation); - return; -} - static int ctapp_open(void *data) { PH_FN_CALL; @@ -151,24 +135,25 @@ static void __win_profile_changed_cb(void *data, Evas_Object *obj, void *event_i } #endif //_PHONE_CONTACTS_DESKTOP_MODE_ -static void __ctapp_auto_rotate_screen_bool_changed(keynode_t *key, void *data) +static void __ctapp_rotate_cb(void *data, Evas_Object *obj, void *event) { - PH_FN_CALL; struct contact_data *ad = data; + int changed_rotate = elm_win_rotation_get(obj); + if (changed_rotate != ad->current_rotate) { + ERR("rotate changed %d", changed_rotate); + ad->current_rotate = changed_rotate; - ct_front_data *cfront_d = ad->cfront_d; - p_retm_if(cfront_d == NULL || cfront_d->win == NULL, "Paramter is NULL"); - - vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &cfront_d->auto_rorate_screen); - if (cfront_d->rotate != APP_DEVICE_ORIENTATION_0) { - if (cfront_d->auto_rorate_screen) - ctui_front_view_rotate(cfront_d, cfront_d->rotate); - else - ctui_front_view_rotate(cfront_d, APP_DEVICE_ORIENTATION_0); +#ifdef _PHONE_CONTACTS_DESKTOP_MODE_ + const char *config = elm_config_profile_get(); + if (!strcmp(config, "desktop")) + return; +#endif + + ctui_front_view_rotate(ad->cfront_d, ad->current_rotate); } - return; } + static bool ctapp_create(void *data) { PH_FN_CALL; @@ -203,12 +188,14 @@ static bool ctapp_create(void *data) UG_INIT_EFL(ad->win, UG_OPT_INDICATOR_ENABLE); ad->cfront_d = ctui_front_view_create(ad->win); - vconf_notify_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, __ctapp_auto_rotate_screen_bool_changed, ad); - vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &(ad->cfront_d->auto_rorate_screen)); + if (elm_win_wm_rotation_supported_get(win)) { + int rotation[4] = {0, 90, 180, 270}; + elm_win_wm_rotation_available_rotations_set(win, (const int *)(&rotation), 4); + ad->current_rotate = elm_win_rotation_get(win); + ERR("rotate current %d", ad->current_rotate); + evas_object_smart_callback_add(win, "wm,rotation,changed", __ctapp_rotate_cb, ad); + } - ad->cfront_d->rotate = app_get_device_orientation(); - if (ad->cfront_d->auto_rorate_screen) - elm_win_rotation_with_resize_set(ad->cfront_d->win, ad->cfront_d->rotate); appcore_set_open_cb(ctapp_open, data); return true; } @@ -219,8 +206,6 @@ static void ctapp_terminate(void *data) contacts_error_e err = CONTACTS_ERROR_NONE; struct contact_data *ad = data; - vconf_ignore_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, __ctapp_auto_rotate_screen_bool_changed); - if (NULL != ad->win) evas_object_del(ad->win); //ug_destroy_all(); @@ -311,7 +296,6 @@ API int main(int argc, char *argv[]) event_callback.service = ctapp_service; event_callback.low_memory = NULL; event_callback.low_battery = NULL; - event_callback.device_orientation = device_orientation; event_callback.language_changed = ctapp_language_changed; event_callback.region_format_changed = ctapp_region_changed; diff --git a/lib/common/ct-list-view-common.c b/lib/common/ct-list-view-common.c index b4649c0..481cba5 100755 --- a/lib/common/ct-list-view-common.c +++ b/lib/common/ct-list-view-common.c @@ -1683,19 +1683,22 @@ static Evas_Object* list_create_contact_list(Evas_Object *parent, ct_list_data * return layout; } -static void list_resize_contact_view(void *data, Evas *e, Evas_Object *obj, void *event_info) +static void list_resize_contact_view(void *data, Evas_Object *obj, void *event_info) { - int rotate; Evas_Object *scroller; Evas_Object *box; ct_list_data *clist_d = data; + int changed_rotate = elm_win_rotation_get(clist_d->win); if (clist_d->list || clist_d->search_str) return; - rotate = (int)evas_object_data_get(clist_d->navi, "phone_rotate"); + if(clist_d->current_rotate != changed_rotate) + clist_d->current_rotate = changed_rotate; + else + return; - if (90 == rotate || 270 == rotate) { + if (0 == changed_rotate || 180 == changed_rotate) { scroller = elm_object_part_content_get(clist_d->content_layout, "elm.swallow.content"); p_retm_if(NULL == scroller, "elm_object_part_content_get() return NULL"); box = elm_object_content_get(scroller); @@ -1703,13 +1706,13 @@ static void list_resize_contact_view(void *data, Evas *e, Evas_Object *obj, void elm_box_unpack(box, clist_d->nocontent); p_retm_if(NULL == clist_d->nocontent, "elm_box_unpack() return NULL"); evas_object_size_hint_weight_set(clist_d->nocontent, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(clist_d->nocontent, EVAS_HINT_FILL, 0.0); + evas_object_size_hint_align_set(clist_d->nocontent, EVAS_HINT_FILL, 0.2); elm_box_pack_end(box, clist_d->nocontent); elm_object_content_set(scroller, box); evas_object_size_hint_min_set(box, 720, 650); elm_object_part_content_set(clist_d->content_layout, "elm.swallow.content", scroller); } - else if (0 == rotate || 180 == rotate) { + else { scroller = elm_object_part_content_get(clist_d->content_layout, "elm.swallow.content"); p_retm_if(NULL == scroller, "elm_object_part_content_get() return NULL"); box = elm_object_content_get(scroller); @@ -1717,12 +1720,13 @@ static void list_resize_contact_view(void *data, Evas *e, Evas_Object *obj, void elm_box_unpack(box, clist_d->nocontent); p_retm_if(NULL == clist_d->nocontent, "elm_box_unpack() return NULL"); evas_object_size_hint_weight_set(clist_d->nocontent, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(clist_d->nocontent, EVAS_HINT_FILL, 0.2); + evas_object_size_hint_align_set(clist_d->nocontent, EVAS_HINT_FILL, 0.0); elm_box_pack_end(box, clist_d->nocontent); elm_object_content_set(scroller, box); evas_object_size_hint_min_set(box, 720, 650); elm_object_part_content_set(clist_d->content_layout, "elm.swallow.content", scroller); } + } @@ -1747,6 +1751,7 @@ static void list_fill_contact_view(Evas_Object *parent, ct_list_data *clist_d) else ctui_list_refresh_genlist(clist_d); } + evas_object_smart_callback_del(clist_d->win, "wm,rotation,changed", list_resize_contact_view); } else { char buf[PH_TEXT_MAX_LEN] ={0,}; @@ -1779,7 +1784,8 @@ static void list_fill_contact_view(Evas_Object *parent, ct_list_data *clist_d) evas_object_size_hint_min_set(box, 720, 650); evas_object_show(base); clist_d->nocontent = base; - evas_object_event_callback_add(clist_d->nocontent, EVAS_CALLBACK_RESIZE, list_resize_contact_view, clist_d); + clist_d->current_rotate = elm_win_rotation_get(clist_d->win); + evas_object_smart_callback_add(clist_d->win, "wm,rotation,changed", list_resize_contact_view, clist_d); elm_object_part_content_set(parent, "elm.swallow.content", scroller); clist_d->genlist = NULL; @@ -1976,7 +1982,8 @@ static Eina_Bool list_genlist_update(void *data) evas_object_size_hint_min_set(box, 720, 650); evas_object_show(base); clist_d->nocontent = base; - evas_object_event_callback_add(clist_d->nocontent, EVAS_CALLBACK_RESIZE, list_resize_contact_view, clist_d); + clist_d->current_rotate = elm_win_rotation_get(clist_d->win); + evas_object_smart_callback_add(clist_d->win, "wm,rotation,changed", list_resize_contact_view, clist_d); elm_object_part_content_set(clist_d->content_layout, "elm.swallow.content", scroller); clist_d->genlist = NULL; @@ -2006,6 +2013,8 @@ static Eina_Bool list_genlist_update(void *data) elm_object_item_del(clist_d->count_item); } + evas_object_smart_callback_del(clist_d->win, "wm,rotation,changed", list_resize_contact_view); + evas_object_show(clist_d->fast_index); elm_object_disabled_set(clist_d->fast_index, EINA_FALSE); @@ -2230,7 +2239,7 @@ static void list_view_delete_cb(void *data, Evas *e, Evas_Object *obj, void *eve clist_d->genlist = NULL; } - evas_object_event_callback_del(clist_d->nocontent, EVAS_CALLBACK_RESIZE, list_resize_contact_view); + evas_object_smart_callback_del(clist_d->win, "wm,rotation,changed", list_resize_contact_view); if (CT_GET_LIST_PERSON_OF_GROUP_ID == clist_d->list_op) { err = contacts_db_remove_changed_cb(_contacts_contact._uri, ctui_list_lazy_update, clist_d); diff --git a/lib/common/include/phone-common.h b/lib/common/include/phone-common.h index cc70200..7747a1f 100755 --- a/lib/common/include/phone-common.h +++ b/lib/common/include/phone-common.h @@ -436,6 +436,8 @@ typedef struct { ct_contact_add_cb contact_add_cb; void *select_result_cb_data; + int current_rotate; + }ct_list_data; typedef struct { diff --git a/lib/ct-front/ct-front-view.c b/lib/ct-front/ct-front-view.c index 1201d30..1b4cb14 100755 --- a/lib/ct-front/ct-front-view.c +++ b/lib/ct-front/ct-front-view.c @@ -371,36 +371,29 @@ static void cfront_view_win_activate(void *data, Evas *e, void *even_info) evas_event_callback_del(e, EVAS_CALLBACK_RENDER_FLUSH_POST, cfront_view_win_activate); } -API int ctui_front_view_rotate(ct_front_data *cfront_d, app_device_orientation_e orientation) +API int ctui_front_view_rotate(ct_front_data *cfront_d, int rotate) { - int rotate; int ret = 0; - switch (orientation) { - case APP_DEVICE_ORIENTATION_0: - rotate = 0; + switch (rotate) { + case 0: ug_send_event(UG_EVENT_ROTATE_PORTRAIT); break; - case APP_DEVICE_ORIENTATION_180: - rotate = 180; + case 180: ug_send_event(UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN); break; - case APP_DEVICE_ORIENTATION_270: - rotate = 270; + case 270: ug_send_event(UG_EVENT_ROTATE_LANDSCAPE); break; - case APP_DEVICE_ORIENTATION_90: - rotate = 90; + case 90: ug_send_event(UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN); break; default: - rotate = -1; break; } evas_object_data_set(cfront_d->navi, "phone_rotate", (void *)rotate); - if (0 <= rotate) - elm_win_rotation_with_resize_set(cfront_d->win, rotate); + return ret; } diff --git a/lib/ct-front/include/ct-front.h b/lib/ct-front/include/ct-front.h index 785b62f..479aacd 100755 --- a/lib/ct-front/include/ct-front.h +++ b/lib/ct-front/include/ct-front.h @@ -53,7 +53,6 @@ typedef struct int cnt_max; int select_tab; int auto_rorate_screen; - app_device_orientation_e rotate; Ecore_Idler *idler; Ecore_Timer *timer; }ct_front_data; @@ -65,7 +64,7 @@ void ctui_front_view_reset(ct_front_data *cfront_d, int tab_index, int op, servi void ctui_front_view_language_changed(ct_front_data *cfront_d); void ctui_front_view_resume(ct_front_data *cfront_d); void ctui_front_view_pause(ct_front_data *cfront_d); -int ctui_front_view_rotate(ct_front_data *cfront_d, app_device_orientation_e orientation); +int ctui_front_view_rotate(ct_front_data *cfront_d, int rotate); #endif /* __CT_FRONT_H__ */ |