fixed ajira defect - TSAM-5954: [SE][Ref.App][Tizen_3.0_Beta_RC15][Mobile][Settings... 21/78321/2 submit/tizen/20160705.063849
authorKyoungyong Lee <bluevox@naver.com>
Tue, 5 Jul 2016 06:17:16 +0000 (15:17 +0900)
committerKyoungyong Lee <bluevox@naver.com>
Tue, 5 Jul 2016 06:24:07 +0000 (15:24 +0900)
Change-Id: I036c9fe853566e19c9bf94b048f50c38aa025cd1

ui/include/privacy_setting.h
ui/include/privacy_view.h
ui/src/privacy_guard_list_view.c
ui/src/privacy_guard_package_list_view.c

index 263ad50999d885a8f42c41ab365f3b52d632a616..2bc91b81d7204b126529911c67dc2c06688b9a9d 100755 (executable)
@@ -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;
index e9683a7d11492e8a5c363ec26ab41419595ac299..9033a2ea1a2fba658d6ff7af969eb4e57a406981 100755 (executable)
@@ -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;
 
index 5c6badb2e1128e73ccee5f26ce3de4275d17e5b7..5ffc9afe774186685765c08050b183de35aa6c24 100755 (executable)
@@ -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);
 }
index 4a432338b5ed8575254754c0ef6848066d376fd7..c77f38a6043a9d4b832de759b7aa82ffd2ed138e 100755 (executable)
 #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);