From 926f6049aa68f096364094880fe597ea2591db71 Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Tue, 27 Dec 2016 14:23:10 +0900 Subject: [PATCH] Unify mobile / wearable codes The next commit will decide whether to use mobile/wearable in runtime. Change-Id: I6f1336e661a0f37ff900906a5aefe7889e6b63b0 Signed-off-by: MyungJoo Ham --- tools/syspopup/src/mobile/default.c | 84 ++++++++++++++++++---- .../syspopup/src/mobile/password-enforce-change.c | 37 ++++++++-- tools/syspopup/src/mobile/toast.c | 13 +++- tools/syspopup/src/wearable/default.c | 78 +++++++++++++------- .../src/wearable/password-enforce-change.c | 39 +++++++--- tools/syspopup/src/wearable/toast.c | 13 +++- 6 files changed, 208 insertions(+), 56 deletions(-) diff --git a/tools/syspopup/src/mobile/default.c b/tools/syspopup/src/mobile/default.c index 4e4f3c7..8d88c46 100644 --- a/tools/syspopup/src/mobile/default.c +++ b/tools/syspopup/src/mobile/default.c @@ -16,11 +16,15 @@ * */ +#define _TIZEN_PROFILE_WEARABLE (0) + #include #include "dpm-syspopup.h" static const char icon_path[] = "/usr/share/icons/default/small/org.tizen.dpm-syspopup.png"; +static const char *delete_icon_file = "/usr/apps/org.tizen.dpm-syspopup/res/images/tw_ic_popup_btn_delete.png"; +static const char *check_icon_file = "/usr/apps/org.tizen.dpm-syspopup/res/images/tw_ic_popup_btn_check.png"; static appdata_s krate_create_appdata[] = { {"mode", "create"} @@ -95,7 +99,7 @@ static void cancel_button_cb(void *data, Evas_Object *obj, void *event_info) static void confirm_button_cb(void *data, Evas_Object *obj, void *event_info) { - Evas_Object *popup = (Evas_Object *)data; + Evas_Object *popup = (Evas_Object *) data; app_control_h app_control = NULL; int ret = 0; @@ -136,12 +140,41 @@ static void popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_ ui_app_exit(); } -static void create_popup_bottom_button(Evas_Object *popup, char *part, char *text, Evas_Smart_Cb callback) +static void create_popup_bottom_button(Evas_Object *popup, const char *part, char *text, Evas_Smart_Cb callback) { Evas_Object *button = NULL; - button = create_button(popup, "popup", __(text), callback, popup); + if (_TIZEN_PROFILE_WEARABLE) + button = create_button(popup, "bottom", __(text), callback, popup); + else + button = create_button(popup, "popup", __(text), callback, popup); elm_object_part_content_set(popup, part, button); + + return; +} + +static void create_popup_left_button(Evas_Object *popup, Evas_Smart_Cb callback) +{ + Evas_Object *button = NULL; + Evas_Object *icon = NULL; + + button = create_button(popup, "popup/circle/left", NULL, callback, popup); + icon = create_image(button, delete_icon_file); + elm_object_part_content_set(button, "elm.swallow.content", icon); + elm_object_part_content_set(popup, "button1", button); + return; +} + +static void create_popup_right_button(Evas_Object *popup, Evas_Smart_Cb callback) +{ + Evas_Object *button = NULL; + Evas_Object *icon = NULL; + + button = create_button(popup, "popup/circle/right", NULL, callback, popup); + icon = create_image(button, check_icon_file); + elm_object_part_content_set(button, "elm.swallow.content", icon); + + elm_object_part_content_set(popup, "button2", button); return; } @@ -176,14 +209,32 @@ static void set_appcontrol(Evas_Object *popup, const char *id, void *user_data) Evas_Object *create_default_popup(Evas_Object *parent, popup_info_s *info, void *user_data) { Evas_Object *popup = NULL; + Evas_Object *layout = NULL; char header[PATH_MAX] = ""; char body[PATH_MAX] = ""; char *lp_text = NULL; + if (_TIZEN_PROFILE_WEARABLE) + popup = create_popup(parent, "circle"); + else + popup = create_popup(parent, "default"); - popup = create_popup(parent, "default"); elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); + if (_TIZEN_PROFILE_WEARABLE) { + layout = elm_layout_add(popup); + elm_object_content_set(popup, layout); + + if (info->left_btn != NULL) { + elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2"); + create_popup_left_button(popup, cancel_button_cb); + create_popup_right_button(popup, confirm_button_cb); + } else { + elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1"); + create_popup_bottom_button(popup, "button1", __(info->right_btn), confirm_button_cb); + } + } + if (info->header != NULL && info->prefix) { lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS"); snprintf(header, PATH_MAX, lp_text, __(info->header)); @@ -199,19 +250,28 @@ Evas_Object *create_default_popup(Evas_Object *parent, popup_info_s *info, void } if (strcmp(header, "")) { - elm_object_part_text_set(popup, "title,text", header); - elm_object_item_part_text_translatable_set(popup, "title,text", EINA_TRUE); + if (_TIZEN_PROFILE_WEARABLE) { + elm_object_part_text_set(layout, "elm.text.title", header); + } else { + elm_object_part_text_set(popup, "title,text", header); + elm_object_item_part_text_translatable_set(popup, "title,text", EINA_TRUE); + } } if (strcmp(body, "")) { - elm_object_text_set(popup, body); + if (_TIZEN_PROFILE_WEARABLE) + elm_object_part_text_set(layout, "elm.text", body); + else + elm_object_text_set(popup, body); } - if (info->left_btn) { - create_popup_bottom_button(popup, "button1", info->left_btn, cancel_button_cb); - create_popup_bottom_button(popup, "button2", info->right_btn, confirm_button_cb); - } else { - create_popup_bottom_button(popup, "button1", info->right_btn, confirm_button_cb); + if (!_TIZEN_PROFILE_WEARABLE) { + if (info->left_btn) { + create_popup_bottom_button(popup, "button1", info->left_btn, cancel_button_cb); + create_popup_bottom_button(popup, "button2", info->right_btn, confirm_button_cb); + } else { + create_popup_bottom_button(popup, "button1", info->right_btn, confirm_button_cb); + } } evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_deleted_cb, info); diff --git a/tools/syspopup/src/mobile/password-enforce-change.c b/tools/syspopup/src/mobile/password-enforce-change.c index 5edce3f..9490385 100644 --- a/tools/syspopup/src/mobile/password-enforce-change.c +++ b/tools/syspopup/src/mobile/password-enforce-change.c @@ -16,6 +16,8 @@ * */ +#define _TIZEN_PROFILE_WEARABLE (0) + #include #include "dpm-syspopup.h" @@ -124,7 +126,11 @@ static void create_popup_bottom_button(Evas_Object *popup, char *part, char *tex { Evas_Object *button = NULL; - button = create_button(popup, "popup", __(text), callback, popup); + if (_TIZEN_PROFILE_WEARABLE) + button = create_button(popup, "bottom", __(text), callback, popup); + else + button = create_button(popup, "popup", __(text), callback, popup); + elm_object_part_content_set(popup, part, button); return; } @@ -132,11 +138,21 @@ static void create_popup_bottom_button(Evas_Object *popup, char *part, char *tex Evas_Object *create_password_enforce_change_popup(Evas_Object *parent, popup_info_s *info, void *user_data) { Evas_Object *popup = NULL; + Evas_Object *layout = NULL; app_control_h app_control = NULL; char header[PATH_MAX] = ""; char body[PATH_MAX] = ""; char *lp_text = NULL; + if (_TIZEN_PROFILE_WEARABLE) { + popup = create_popup(parent, "circle"); + elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); + + layout = elm_layout_add(popup); + elm_object_content_set(popup, layout); + elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1"); + } + if (info->header != NULL && info->prefix) { lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS"); snprintf(header, PATH_MAX, lp_text, __(info->header)); @@ -151,16 +167,25 @@ Evas_Object *create_password_enforce_change_popup(Evas_Object *parent, popup_inf snprintf(body, PATH_MAX, "%s", __(info->body)); } - popup = create_popup(parent, "default"); - elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); + if (!_TIZEN_PROFILE_WEARABLE) { + popup = create_popup(parent, "default"); + elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); + } if (strcmp(header, "")) { - elm_object_part_text_set(popup, "title,text", header); - elm_object_item_part_text_translatable_set(popup, "title,text", EINA_TRUE); + if (_TIZEN_PROFILE_WEARABLE) { + elm_object_part_text_set(layout, "elm.text.title", header); + } else { + elm_object_part_text_set(popup, "title,text", header); + elm_object_item_part_text_translatable_set(popup, "title,text", EINA_TRUE); + } } if (strcmp(body, "")) { - elm_object_text_set(popup, body); + if (_TIZEN_PROFILE_WEARABLE) + elm_object_part_text_set(layout, "elm.text", body); + else + elm_object_text_set(popup, body); } create_popup_bottom_button(popup, "button1", info->right_btn, confirm_button_cb); diff --git a/tools/syspopup/src/mobile/toast.c b/tools/syspopup/src/mobile/toast.c index e01fce9..417a671 100644 --- a/tools/syspopup/src/mobile/toast.c +++ b/tools/syspopup/src/mobile/toast.c @@ -15,6 +15,8 @@ * */ +#define _TIZEN_PROFILE_WEARABLE (0) + #include "dpm-syspopup.h" static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info) @@ -47,11 +49,18 @@ Evas_Object *create_toast_popup(Evas_Object *parent, popup_info_s *info, void *u snprintf(body, PATH_MAX, "%s", __(info->body)); } - popup = create_popup(parent, "toast"); - elm_object_text_set(popup, body); + if (_TIZEN_PROFILE_WEARABLE) { + popup = create_popup(parent, "toast/circle"); + elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER); + elm_object_part_text_set(popup, "elm.text", body); + } else { + popup = create_popup(parent, "toast"); + elm_object_text_set(popup, body); + } elm_popup_timeout_set(popup, 3.0); evas_object_smart_callback_add(popup, "timeout", popup_timeout_cb, NULL); evas_object_smart_callback_add(popup, "block,clicked", block_clicked_cb, NULL); evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_deleted_cb, NULL); + return popup; } diff --git a/tools/syspopup/src/wearable/default.c b/tools/syspopup/src/wearable/default.c index d35ffc1..66a054e 100644 --- a/tools/syspopup/src/wearable/default.c +++ b/tools/syspopup/src/wearable/default.c @@ -16,6 +16,8 @@ * */ +#define _TIZEN_PROFILE_WEARABLE (1) + #include #include "dpm-syspopup.h" @@ -87,15 +89,25 @@ static notification_s notification_list[] = { } }; +static void cancel_button_cb(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Object *popup = (Evas_Object *) data; + evas_object_data_set(popup, "status", "cancel"); + evas_object_del(popup); + return; +} + static void confirm_button_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *popup = (Evas_Object *) data; + app_control_h app_control = NULL; + int ret = 0; /* call application */ - app_control_h app_control = NULL; app_control = (app_control_h)evas_object_data_get(popup, "app-control"); if (app_control) { - if (app_control_send_launch_request(app_control, NULL, NULL) != APP_CONTROL_ERROR_NONE) + ret = app_control_send_launch_request(app_control, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) dlog_print(DLOG_ERROR, LOG_TAG, "failed to send launch request"); } @@ -104,14 +116,6 @@ static void confirm_button_cb(void *data, Evas_Object *obj, void *event_info) return; } -static void cancel_button_cb(void *data, Evas_Object *obj, void *event_info) -{ - Evas_Object *popup = (Evas_Object *) data; - evas_object_data_set(popup, "status", "cancel"); - evas_object_del(popup); - return; -} - static void popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { int ret = 0; @@ -140,7 +144,10 @@ static void create_popup_bottom_button(Evas_Object *popup, const char *part, cha { Evas_Object *button = NULL; - button = create_button(popup, "bottom", __(text), callback, popup); + if (_TIZEN_PROFILE_WEARABLE) + button = create_button(popup, "bottom", __(text), callback, popup); + else + button = create_button(popup, "popup", __(text), callback, popup); elm_object_part_content_set(popup, part, button); return; @@ -207,19 +214,25 @@ Evas_Object *create_default_popup(Evas_Object *parent, popup_info_s *info, void char body[PATH_MAX] = ""; char *lp_text = NULL; - popup = create_popup(parent, "circle"); - elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); + if (_TIZEN_PROFILE_WEARABLE) + popup = create_popup(parent, "circle"); + else + popup = create_popup(parent, "default"); - layout = elm_layout_add(popup); - elm_object_content_set(popup, layout); + elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); - if (info->left_btn != NULL) { - elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2"); - create_popup_left_button(popup, cancel_button_cb); - create_popup_right_button(popup, confirm_button_cb); - } else { - elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1"); - create_popup_bottom_button(popup, "button1", __(info->right_btn), confirm_button_cb); + if (_TIZEN_PROFILE_WEARABLE) { + layout = elm_layout_add(popup); + elm_object_content_set(popup, layout); + + if (info->left_btn != NULL) { + elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2"); + create_popup_left_button(popup, cancel_button_cb); + create_popup_right_button(popup, confirm_button_cb); + } else { + elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1"); + create_popup_bottom_button(popup, "button1", __(info->right_btn), confirm_button_cb); + } } if (info->header != NULL && info->prefix) { @@ -237,11 +250,28 @@ Evas_Object *create_default_popup(Evas_Object *parent, popup_info_s *info, void } if (strcmp(header, "")) { - elm_object_part_text_set(layout, "elm.text.title", header); + if (_TIZEN_PROFILE_WEARABLE) { + elm_object_part_text_set(layout, "elm.text.title", header); + } else { + elm_object_part_text_set(popup, "title,text", header); + elm_object_item_part_text_translatable_set(popup, "title,text", EINA_TRUE); + } } if (strcmp(body, "")) { - elm_object_part_text_set(layout, "elm.text", body); + if (_TIZEN_PROFILE_WEARABLE) + elm_object_part_text_set(layout, "elm.text", body); + else + elm_object_text_set(popup, body); + } + + if (!_TIZEN_PROFILE_WEARABLE) { + if (info->left_btn) { + create_popup_bottom_button(popup, "button1", info->left_btn, cancel_button_cb); + create_popup_bottom_button(popup, "button2", info->right_btn, confirm_button_cb); + } else { + create_popup_bottom_button(popup, "button1", info->right_btn, confirm_button_cb); + } } evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_deleted_cb, info); diff --git a/tools/syspopup/src/wearable/password-enforce-change.c b/tools/syspopup/src/wearable/password-enforce-change.c index 8e49e5b..d80bb31 100644 --- a/tools/syspopup/src/wearable/password-enforce-change.c +++ b/tools/syspopup/src/wearable/password-enforce-change.c @@ -16,6 +16,8 @@ * */ +#define _TIZEN_PROFILE_WEARABLE (1) + #include #include "dpm-syspopup.h" @@ -120,11 +122,15 @@ static void popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_ ui_app_exit(); } -static void create_popup_bottom_button(Evas_Object *popup, const char *part, char *text, Evas_Smart_Cb callback) +static void create_popup_bottom_button(Evas_Object *popup, char *part, char *text, Evas_Smart_Cb callback) { Evas_Object *button = NULL; - button = create_button(popup, "bottom", __(text), callback, popup); + if (_TIZEN_PROFILE_WEARABLE) + button = create_button(popup, "bottom", __(text), callback, popup); + else + button = create_button(popup, "popup", __(text), callback, popup); + elm_object_part_content_set(popup, part, button); return; } @@ -138,12 +144,14 @@ Evas_Object *create_password_enforce_change_popup(Evas_Object *parent, popup_inf char body[PATH_MAX] = ""; char *lp_text = NULL; - popup = create_popup(parent, "circle"); - elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); + if (_TIZEN_PROFILE_WEARABLE) { + popup = create_popup(parent, "circle"); + elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); - layout = elm_layout_add(popup); - elm_object_content_set(popup, layout); - elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1"); + layout = elm_layout_add(popup); + elm_object_content_set(popup, layout); + elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1"); + } if (info->header != NULL && info->prefix) { lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS"); @@ -159,12 +167,25 @@ Evas_Object *create_password_enforce_change_popup(Evas_Object *parent, popup_inf snprintf(body, PATH_MAX, "%s", __(info->body)); } + if (!_TIZEN_PROFILE_WEARABLE) { + popup = create_popup(parent, "default"); + elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); + } + if (strcmp(header, "")) { - elm_object_part_text_set(layout, "elm.text.title", header); + if (_TIZEN_PROFILE_WEARABLE) { + elm_object_part_text_set(layout, "elm.text.title", header); + } else { + elm_object_part_text_set(popup, "title,text", header); + elm_object_item_part_text_translatable_set(popup, "title,text", EINA_TRUE); + } } if (strcmp(body, "")) { - elm_object_part_text_set(layout, "elm.text", body); + if (_TIZEN_PROFILE_WEARABLE) + elm_object_part_text_set(layout, "elm.text", body); + else + elm_object_text_set(popup, body); } create_popup_bottom_button(popup, "button1", info->right_btn, confirm_button_cb); diff --git a/tools/syspopup/src/wearable/toast.c b/tools/syspopup/src/wearable/toast.c index 9c5e4e5..c5d70dd 100644 --- a/tools/syspopup/src/wearable/toast.c +++ b/tools/syspopup/src/wearable/toast.c @@ -15,6 +15,8 @@ * */ +#define _TIZEN_PROFILE_WEARABLE (1) + #include "dpm-syspopup.h" static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info) @@ -47,9 +49,14 @@ Evas_Object *create_toast_popup(Evas_Object *parent, popup_info_s *info, void *u snprintf(body, PATH_MAX, "%s", __(info->body)); } - popup = create_popup(parent, "toast/circle"); - elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER); - elm_object_part_text_set(popup, "elm.text", body); + if (_TIZEN_PROFILE_WEARABLE) { + popup = create_popup(parent, "toast/circle"); + elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER); + elm_object_part_text_set(popup, "elm.text", body); + } else { + popup = create_popup(parent, "toast"); + elm_object_text_set(popup, body); + } elm_popup_timeout_set(popup, 3.0); evas_object_smart_callback_add(popup, "timeout", popup_timeout_cb, NULL); evas_object_smart_callback_add(popup, "block,clicked", block_clicked_cb, NULL); -- 2.7.4