diff options
author | Kyoungyong Lee <bluevox@naver.com> | 2016-07-05 15:17:16 +0900 |
---|---|---|
committer | Kyoungyong Lee <bluevox@naver.com> | 2016-07-05 15:24:07 +0900 |
commit | 044d5ef8a7efd190e9dcfacc02fe070427d1b68b (patch) | |
tree | 38e5242e4879e9228d02fb9826e13700b82fb418 | |
parent | 9877cec4224461db4779a8a463083485fb0111a5 (diff) | |
download | privacy-setting-044d5ef8a7efd190e9dcfacc02fe070427d1b68b.tar.gz privacy-setting-044d5ef8a7efd190e9dcfacc02fe070427d1b68b.tar.bz2 privacy-setting-044d5ef8a7efd190e9dcfacc02fe070427d1b68b.zip |
fixed ajira defect - TSAM-5954: [SE][Ref.App][Tizen_3.0_Beta_RC15][Mobile][Settings][Menutree] Screen is blue and has not any contentsubmit/tizen/20160705.063849
Change-Id: I036c9fe853566e19c9bf94b048f50c38aa025cd1
-rwxr-xr-x | ui/include/privacy_setting.h | 2 | ||||
-rwxr-xr-x | ui/include/privacy_view.h | 4 | ||||
-rwxr-xr-x | ui/src/privacy_guard_list_view.c | 2 | ||||
-rwxr-xr-x | ui/src/privacy_guard_package_list_view.c | 183 |
4 files changed, 123 insertions, 68 deletions
diff --git a/ui/include/privacy_setting.h b/ui/include/privacy_setting.h index 263ad50..2bc91b8 100755 --- a/ui/include/privacy_setting.h +++ b/ui/include/privacy_setting.h @@ -30,7 +30,7 @@ #include <app.h> #define PRIVACY_MENU_SETTING "Privacy Setting" -#define PRIVACY_MENU_GUARD_SETTING "Privacy Guard Setting" +#define PRIVACY_MENU_GUARD_SETTING "Privacy Usage" struct app_data_s { Evas_Object *parent_layout; diff --git a/ui/include/privacy_view.h b/ui/include/privacy_view.h index e9683a7..9033a2e 100755 --- a/ui/include/privacy_view.h +++ b/ui/include/privacy_view.h @@ -56,10 +56,12 @@ typedef struct { typedef struct { int index; - char *title; + char *label; + char *description; uid_t user_id; char *pkg_id; char *privacy_id; + char *icon; bool status; } pg_item_data_s; diff --git a/ui/src/privacy_guard_list_view.c b/ui/src/privacy_guard_list_view.c index 5c6badb..5ffc9af 100755 --- a/ui/src/privacy_guard_list_view.c +++ b/ui/src/privacy_guard_list_view.c @@ -82,7 +82,7 @@ void create_privacy_guard_list_view(struct app_data_s *ad) evas_object_show(genlist); /* Change "Privacy Setting" to proper DID : use dgettext() */ - Elm_Object_Item *nf_it = elm_naviframe_item_push(ad->nf, "Privacy Guard Setting", common_back_btn_add(ad), NULL, genlist, NULL); + Elm_Object_Item *nf_it = elm_naviframe_item_push(ad->nf, PRIVACY_MENU_GUARD_SETTING, common_back_btn_add(ad), NULL, genlist, NULL); elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE); } diff --git a/ui/src/privacy_guard_package_list_view.c b/ui/src/privacy_guard_package_list_view.c index 4a43233..c77f38a 100755 --- a/ui/src/privacy_guard_package_list_view.c +++ b/ui/src/privacy_guard_package_list_view.c @@ -23,11 +23,14 @@ #include <efl_extension.h> #include <glib.h> #include <pkgmgr-info.h> +#include <tzplatform_config.h> #include <privacy_guard_client.h> #include "common_utils.h" #include "privacy_setting.h" #include "privacy_view.h" +#define DEFAULT_ICON_PATH _TZ_SYS_RO_APP"/org.tizen.privacy-setting/res/icon/default.png" + static GList* pg_data_list; static void _gl_del_cb(void *data, Evas_Object *obj) @@ -47,8 +50,16 @@ static void _privacy_package_selected_cb(void *data, Evas_Object *obj, void *eve } static char* _gl_text_get_cb(void *data, Evas_Object *obj, const char *part) { - item_data_s *id = data; - lreturn_if(!strcmp(part, "elm.text"), , strdup(id->title), "privacy-package item = %s", id->title); + pg_item_data_s *id = data; + + if (!strcmp(part, "elm.text")) { + return strdup(id->label); + } else if (!strcmp(part, "elm.text.sub")) { + return strdup(id->description); + } else { + return NULL; + } + return "FAIL"; } @@ -61,29 +72,39 @@ static void _privacy_package_check_changed_cb(void *data, Evas_Object *obj, void int res = privacy_guard_client_update_monitor_policy(id->user_id, id->pkg_id, id->privacy_id, !id->status); log_if(res != PRIV_GUARD_ERROR_SUCCESS, 1, "privacy_guard_client_update_monitor_policy() is failed. [%d]", res); id->status = !id->status; + LOGD("changed policy: [%d]", id->status); } static Evas_Object* _gl_content_get_cb(void *data, Evas_Object *obj, const char *part) { - Evas_Object *check; pg_item_data_s *id = (pg_item_data_s*)data; - Eina_Bool status = id->status; - if (strcmp(part, "elm.swallow.end")) - return NULL; + if (!strcmp("elm.swallow.icon", part)) { + Evas_Object *icon; + icon = elm_image_add(obj); + elm_image_file_set(icon, id->icon, NULL); + evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(70), ELM_SCALE_SIZE(70)); - check = elm_check_add(obj); + return icon; + } - elm_object_style_set(check, "on&off"); - elm_check_state_set(check, status); - evas_object_repeat_events_set(check, EINA_FALSE); - evas_object_propagate_events_set(check, EINA_FALSE); - evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_smart_callback_add(check, "changed", _privacy_package_check_changed_cb, data); - evas_object_show(check); + if (!strcmp(part, "elm.swallow.end")) { + Evas_Object *check; + Eina_Bool status = id->status; + check = elm_check_add(obj); + elm_object_style_set(check, "on&off"); + elm_check_state_set(check, status); + evas_object_repeat_events_set(check, EINA_FALSE); + evas_object_propagate_events_set(check, EINA_FALSE); + evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_smart_callback_add(check, "changed", _privacy_package_check_changed_cb, data); + evas_object_show(check); + + return check; + } - return check; + return NULL; } static bool _privacy_package_info_cb(const char *package_id, const int count, const int monitor_policy, void *user_data) @@ -95,11 +116,6 @@ static bool _privacy_package_info_cb(const char *package_id, const int count, co pg_data_list = g_list_append(pg_data_list, data); - GList *l; - for (l = pg_data_list; l != NULL; l = l->next) { - pg_data_s *item = (pg_data_s*)l->data; - } - return true; } @@ -114,10 +130,6 @@ void create_privacy_guard_package_list_view(struct app_data_s* ad) /* Set itc */ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new(); - itc->item_style = "default"; - itc->func.content_get = _gl_content_get_cb; - itc->func.text_get = _gl_text_get_cb; - itc->func.del = _gl_del_cb; /* Get privacy guard data (pkg, count, policy) list by a privacy */ if (pg_data_list!= NULL) { @@ -132,57 +144,98 @@ void create_privacy_guard_package_list_view(struct app_data_s* ad) int res = privacy_guard_client_foreach_package_info_by_privacy_id(user_id, ad->privacy, _privacy_package_info_cb, NULL); log_if(res != PRIV_GUARD_ERROR_SUCCESS, 1, "privacy_guard_client_foreach_package_info_by_privacy_id() is failed. [%d]", res); - /* Append privacy related package as genlist item */ - GList* l; - int i = 0; - Elm_Object_Item *it = NULL; - for (l = pg_data_list; l != NULL; l = l->next) { - pg_data_s* data = (pg_data_s*)l->data; + // no content in the genlist + if (!pg_data_list) { + itc->item_style = "default"; + itc->func.text_get = _gl_text_get_cb; + itc->func.del = _gl_del_cb; + + Elm_Object_Item *it = NULL; pg_item_data_s *item = calloc(sizeof(pg_item_data_s), 1); - char temp[256] = {'\0',}; - char *label = NULL; - pkgmgrinfo_pkginfo_h handle; - - // index - item->index = i++; - - // package ID - item->pkg_id = strdup(data->pkg_id); - - // package label - res = pkgmgrinfo_pkginfo_get_pkginfo(item->pkg_id, &handle); - if (res != PMINFO_R_OK) { - LOGE("Failed to operate pkgmgrinfo_pkginfo_get_pkginfo [%d]", res); - LOGE("So replace the label to package ID"); - label = item->pkg_id; - } else { - res = pkgmgrinfo_pkginfo_get_label(handle, &label); + item->index = 0; + item->label = strdup("<font color=#A9A9A9FF>No Package</font>"); + + // append to the genlist + it = elm_genlist_item_append(genlist, itc, item, NULL, ELM_GENLIST_ITEM_NONE, _privacy_package_selected_cb, item); + log_if(it == NULL, 1, "Error in elm_genlist_item_append"); + } else { + itc->item_style = "type1"; + itc->func.content_get = _gl_content_get_cb; + itc->func.text_get = _gl_text_get_cb; + itc->func.del = _gl_del_cb; + + /* Append privacy related package as genlist item */ + GList* l; + int i = 0; + Elm_Object_Item *it = NULL; + for (l = pg_data_list; l != NULL; l = l->next) { + pg_item_data_s *item = calloc(sizeof(pg_item_data_s), 1); + pg_data_s* data = (pg_data_s*)l->data; + char temp[256] = {'\0',}; + char *label = NULL; + char* icon = NULL; + pkgmgrinfo_pkginfo_h handle; + + // index + item->index = i++; + + // package ID + item->pkg_id = strdup(data->pkg_id); + + // package label + res = pkgmgrinfo_pkginfo_get_pkginfo(item->pkg_id, &handle); if (res != PMINFO_R_OK) { - LOGE("Failed to operate pkgmgrinfo_pkginfo_get_label [%d]", res); + LOGE("Failed to operate pkgmgrinfo_pkginfo_get_pkginfo [%d]", res); LOGE("So replace the label to package ID"); label = item->pkg_id; - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + } else { + res = pkgmgrinfo_pkginfo_get_label(handle, &label); + if (res != PMINFO_R_OK) { + LOGE("Failed to operate pkgmgrinfo_pkginfo_get_label [%d]", res); + LOGE("So replace the label to package ID"); + label = item->pkg_id; + } } - } - // title.. "label (count)" ==> privacyapp (0) - snprintf(temp, sizeof(temp), "%s (%d)", label, data->count); - item->title = strdup(temp); + // title.. (package label) + snprintf(temp, sizeof(temp), "%s", label); + item->label = strdup(temp); - // user ID - item->user_id = user_id; + // description + snprintf(temp, sizeof(temp), "<font color=#3DB9CCFF>%d</font> time(s)", data->count); + item->description = strdup(temp); - // privacy ID - item->privacy_id = strdup(ad->privacy); + // user ID + item->user_id = user_id; - // status - item->status = ((data->monitor_policy == 1) ? EINA_TRUE : EINA_FALSE); + // privacy ID + item->privacy_id = strdup(ad->privacy); - // append to the genlist - it = elm_genlist_item_append(genlist, itc, item, NULL, ELM_GENLIST_ITEM_NONE, _privacy_package_selected_cb, item); - log_if(it == NULL, 1, "Error in elm_genlist_item_append"); + // icon + res = pkgmgrinfo_pkginfo_get_icon(handle, &icon); + if (res != PMINFO_R_OK) { + LOGE("Failed to operate pkgmgrinfo_pkginfo_get_icon [%d]", res); + LOGE("So replace the icon to the default icon"); + item->icon = strdup(DEFAULT_ICON_PATH); + } else { + if (EINA_TRUE == ecore_file_exists(icon)) { + item->icon = strdup(icon); + } + else { + LOGD("The icon [%s] is not exist. So replace the icon to the default icon.", icon); + item->icon = strdup(DEFAULT_ICON_PATH); + } + } - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + // status + item->status = ((data->monitor_policy == 1) ? EINA_TRUE : EINA_FALSE); + + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + + // append to the genlist + it = elm_genlist_item_append(genlist, itc, item, NULL, ELM_GENLIST_ITEM_NONE, _privacy_package_selected_cb, item); + log_if(it == NULL, 1, "Error in elm_genlist_item_append"); + } } elm_genlist_item_class_free(itc); |