Update App notifications view 94/84094/1
authorDmytro Dragan <dm.dragan@samsung.com>
Tue, 16 Aug 2016 14:44:18 +0000 (17:44 +0300)
committerDmytro Dragan <dm.dragan@samsung.com>
Tue, 16 Aug 2016 14:44:18 +0000 (17:44 +0300)
Change-Id: I2980e21b8eaeeabd8a2a21bbb09ae1a7323e582e
Signed-off-by: Dmytro Dragan <dm.dragan@samsung.com>
inc/app-details.h
inc/common-efl.h
inc/notification-setting-info.h
src/app-details.c
src/common-efl.c
src/main.c
src/notification-setting-info.c

index e441ff5..306aa0f 100644 (file)
  */
 void app_details_create_view(ug_data *data, item_info_s *app_info);
 
-
+/**
+ * @brief Creates genlist with notifications apps
+ *
+ * @param[in] ugd   pointer to main control struct
+ *
+ * @return filled genlist object
+ */
+Evas_Object *create_app_notification_gl(ug_data *ugd);
 
 #endif /* __APP_DETAILS_H__ */
index 1c98a4a..410a71d 100755 (executable)
@@ -155,14 +155,6 @@ void append_gl_item_list(Evas_Object *genlist, Eina_List* list, int style);
 void append_gl_start_option(Evas_Object *genlist, char *style, char *ugName);
 
 /**
- * @brief Creates an item with checkbox and "Allow All" text for "App Notifications" view and
- * adds it to specified genlist.
- * @param[in] genlist a genlist new item should be added to.
- * @return created genlist item.
- */
-Elm_Widget_Item *append_gl_allow_all(Evas_Object *genlist);
-
-/**
  * @brief Aimed to append item with complex content to specified genlist (like weekday selector
  * in "Set schedule")
  * @param[in] genlist a genlist new item should be appended to.
index 26ebc83..4e19004 100755 (executable)
@@ -26,7 +26,8 @@
 typedef struct _setting_info_t {
     Eina_List *not_excepted_list;
     Eina_List *excepted_list;
-    Eina_List *all_apps_list;
+    Eina_List *apps_noti_allowed_list;
+    Eina_List *apps_noti_blocked_list;
     Eina_List *first_allowed_list;
     Eina_List *first_excepted_list;
     Eina_List *show_all_content_list;
@@ -50,9 +51,8 @@ bool get_allow_to_nofity(char *pkg_name);
 bool set_allow_to_nofity(char *pkg_name, bool state);
 bool set_excepted_apps(char *pkg_name, bool state);
 
-bool get_allow_all();
-void set_allow_all(bool state);
-Eina_List *get_all_apps_list();
+Eina_List *get_apps_noti_allowed_list();
+Eina_List *get_apps_noti_blocked_list();
 Eina_List *get_first_allowed_apps_list();
 Eina_List *get_first_excepted_apps_list();
 Eina_List *get_excepted_apps_list();
@@ -64,6 +64,7 @@ Eina_List *get_not_excepted_apps_list();
 Eina_List *get_lower_noti_list();
 
 void create_app_notification_list();
+void update_app_notification_list_on_item(item_info_s *item_info);
 void create_do_not_disturb_application_list();
 /**
  *@brief Create list that should be shown in lower part of screen in lock screen content menu.
@@ -73,7 +74,8 @@ void create_notification_on_ls_list();
  *@brief Remove list that should be shown in lower part of screen in lock screen content menu.
  */
 void remove_lower_noti_list();
-void remove_all_apps_list();
+void remove_apps_noti_allowed_list();
+void remove_apps_noti_blocked_list();
 void remove_excepted_apps_list();
 void remove_arranged_list();
 
index f6ecac3..09ebcf2 100644 (file)
@@ -28,6 +28,7 @@ typedef enum
 } App_Details_Items;
 
 item_info_s *g_app_info = NULL;
+Evas_Object *g_app_notification_genlist = NULL;
 
 static void close_app_details_cb(void *data, Evas_Object *obj, void *event_info)
 {
@@ -233,6 +234,21 @@ static void app_details_gl_append(Evas_Object *genlist, char *style, App_Details
     elm_genlist_item_class_free(itc);
 }
 
+static void fill_app_noti_gl(Evas_Object *genlist)
+{
+    append_gl_item_list(genlist, get_apps_noti_allowed_list(), ITEM_STYLE_TYPE_ONE);
+    append_gl_start_option(genlist, "group_index", "blocked-noti");
+    append_gl_item_list(genlist, get_apps_noti_blocked_list(), ITEM_STYLE_TYPE_ONE);
+}
+
+static Eina_Bool app_details_pop_cb(void *data, Elm_Object_Item * it)
+{
+    update_app_notification_list_on_item(g_app_info);
+    elm_genlist_clear(g_app_notification_genlist);
+    fill_app_noti_gl(g_app_notification_genlist);
+    return EINA_TRUE;
+}
+
 void app_details_create_view(ug_data *data, item_info_s *app_info)
 {
     ret_if(!data || !app_info);
@@ -257,5 +273,26 @@ void app_details_create_view(ug_data *data, item_info_s *app_info)
     /* ] */
     app_details_gl_append(genlist, "type1", APP_DETAILS_NOTI_ON_LOCK);
 
-    elm_naviframe_item_push(data->naviframe, g_app_info->name, back_btn, NULL, genlist, NULL);
+    Elm_Object_Item *navi_item = elm_naviframe_item_push(data->naviframe, g_app_info->name, back_btn, NULL, genlist, NULL);
+    elm_naviframe_item_pop_cb_set(navi_item, app_details_pop_cb, NULL);
+}
+
+Evas_Object *create_app_notification_gl(ug_data *ugd)
+{
+    Evas_Object *parent = ugd->naviframe;
+    Evas_Object *genlist;
+
+    genlist = elm_genlist_add(parent);
+    elm_genlist_mode_set(genlist, ELM_LIST_SCROLL);
+    elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+    evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    elm_genlist_block_count_set(genlist, 8);
+
+    /* Add Smart Callback */
+    evas_object_smart_callback_add(genlist, "contracted", gl_contracted_cb, NULL);
+
+    fill_app_noti_gl(genlist);
+    g_app_notification_genlist = genlist;
+    return genlist;
 }
index ee968ba..e14af7a 100755 (executable)
@@ -203,30 +203,6 @@ static void _do_not_disturb_check_changed_cb(void *data, Evas_Object *obj, void
     NOTISET_DBG("do_not_disturb check value = %s", state==false ? "FALSE":"TRUE");
 }
 
-static void _app_notif_allow_all_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
-{
-    NOTISET_TRACE_BEGIN;
-
-       Eina_Bool state = elm_check_state_get(obj);
-       NOTISET_DBG("allow_all check value = %s", state==false ? "FALSE":"TRUE");
-       set_allow_all(state);
-       elm_genlist_realized_items_update((Evas_Object*)data);
-}
-
-static void _allow_to_nofity_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
-{
-    NOTISET_TRACE_BEGIN;
-       item_info_s *data_list = data;
-       ret_if(!data_list);
-
-       Eina_Bool state = elm_check_state_get(obj);
-       set_allow_to_nofity(data_list->appid, state);
-       data_list->allow_to_notify = state;
-       /* Update allow all item*/
-       elm_genlist_item_update(elm_genlist_first_item_get(g_ug_data->list_main));
-       NOTISET_DBG("appid = %s state = %d", data_list->appid, state);
-}
-
 static Evas_Object* gl_content_get_cb(void *data, Evas_Object *obj, const char *part)
 {
     retv_if(!data, NULL);
@@ -248,10 +224,7 @@ static Evas_Object* gl_content_get_cb(void *data, Evas_Object *obj, const char *
     {
         if(data_list->item_style == ITEM_STYLE_TYPE_ONE)
         {
-            content = create_on_off_check(obj);
-            elm_check_state_set(content, data_list->allow_to_notify);
-            evas_object_smart_callback_add(content, "changed", _allow_to_nofity_check_changed_cb, data_list);
-            return content;
+            return NULL;
         }
         else if(data_list->item_style == ITEM_STYLE_DEFAULT)
         {
@@ -402,15 +375,7 @@ static char *_gl_option_text_get_cb(void *data, Evas_Object *obj, const char *pa
        char buf[MAX_TEXT_SIZE] = {0,};
 
     retv_if(!data, NULL);
-    if(!strcmp(data, "app-notifications"))
-    {
-        if(!strcmp("elm.text.multiline", part))
-        {
-            snprintf(buf, sizeof(buf), "<font_size=30>%s</font_size>", APP_STRING("IDS_QP_BODY_SELECT_THE_APPS_YOU_WANT_TO_RECEIVE_NOTIFICATIONS_FROM_BELOW"));
-            return strdup(buf);
-        }
-    }
-    else if(!strcmp(data, "do-not-disturb"))
+    if(!strcmp(data, "do-not-disturb"))
     {
         if(!strcmp("elm.text.multiline", part))
         {
@@ -498,6 +463,11 @@ static char *_gl_option_text_get_cb(void *data, Evas_Object *obj, const char *pa
         else if(!strcmp("elm.text.sub.end", part))
             return strdup("Date");
     }
+    else if(!strcmp(data, "blocked-noti"))
+    {
+        if(!strcmp("elm.text", part))
+            return strdup("Blocked notification");
+    }
 
        return NULL;
 }
@@ -541,56 +511,11 @@ static Evas_Object* _gl_option_content_get_cb(void *data, Evas_Object *obj, cons
     return NULL;
 }
 
-static Evas_Object* _gl_app_notif_allow_all_content_get_cb(void *data, Evas_Object *obj, const char *part)
-{
-       if (!strcmp(part, "elm.swallow.end") ) {
-               Evas_Object *check = NULL;
-               check = create_on_off_check(obj);
-               elm_check_state_set(check, get_allow_all());
-               evas_object_smart_callback_add(check, "changed", _app_notif_allow_all_check_changed_cb, obj);
-               return check;
-       }
-       return NULL;
-}
-
-static char *_gl_app_notif_allow_all_text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
-       if (!strcmp(part, "elm.text")) {
-               return strdup(APP_STRING("IDS_ST_MBODY_ALLOW_ALL"));
-       }
-
-       return NULL;
-}
-
-Elm_Widget_Item *append_gl_allow_all(Evas_Object *genlist)
-{
-    NOTISET_TRACE_BEGIN;
-
-       Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
-       if (!itc)
-               return NULL;
-
-       itc->item_style = "type1";
-       itc->func.text_get = _gl_app_notif_allow_all_text_get_cb;
-       itc->func.content_get = _gl_app_notif_allow_all_content_get_cb;
-       itc->func.del = gl_del_cb;
-
-       Elm_Widget_Item *item = elm_genlist_item_append(genlist,                                        /* genlist object */
-                                                       itc,                                            /* item class */
-                                                       NULL,                                           /* data */
-                                                       NULL,                                           /* parent item */
-                                                       ELM_GENLIST_ITEM_NONE,          /* item type */
-                                                       gl_selected_cb,                         /* select smart callback */
-                                                       NULL);                                          /* smart callback user data */
-
-       elm_genlist_item_class_free(itc);
-       return item;
-}
-
 void append_gl_start_option(Evas_Object *genlist, char *style, char *ugName)
 {
     NOTISET_TRACE_BEGIN;
 
+    Elm_Object_Item *gen_item = NULL;
     Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
     ret_if(!itc);
 
@@ -599,7 +524,7 @@ void append_gl_start_option(Evas_Object *genlist, char *style, char *ugName)
     itc->func.content_get = _gl_option_content_get_cb;
     itc->func.del = gl_del_cb;
 
-    elm_genlist_item_append(genlist,                    /* genlist object */
+    gen_item = elm_genlist_item_append(genlist,                    /* genlist object */
                             itc,                        /* item class */
                             ugName,                     /* item class user data */
                             NULL,                       /* parent item */
@@ -607,6 +532,8 @@ void append_gl_start_option(Evas_Object *genlist, char *style, char *ugName)
                             gl_selected_cb,             /* select smart callback */
                             ugName);                    /* smart callback user data */
 
+    if(style && !strcmp(style, "group_index"))
+        elm_genlist_item_select_mode_set(gen_item, ELM_OBJECT_SELECT_MODE_NONE);
     elm_genlist_item_class_free(itc);
 }
 
index 56fd142..b371eb7 100755 (executable)
@@ -23,6 +23,7 @@
 #include "pkgmgr-setting-info.h"
 #include "excepted-apps-efl.h"
 #include "common-efl.h"
+#include "app-details.h"
 
 /* TODO: change when app control operation will be add */
 #define NOTIFICATIONS_ON_LOCK_SCREEN_OP "http://tizen.org/appcontrol/operation/setting/notification_on_lock_screen"
@@ -133,28 +134,6 @@ Evas_Object* _create_lockscreen_content(ug_data *ugd)
     return bg;
 }
 
-Evas_Object* _create_app_notification_gl(ug_data *ugd)
-{
-       Evas_Object *parent = ugd->naviframe;
-       Evas_Object *genlist;
-
-       genlist = elm_genlist_add(parent);
-       elm_genlist_mode_set(genlist, ELM_LIST_SCROLL);
-       elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
-       evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
-       elm_genlist_block_count_set(genlist, 8);
-
-       /* Add Smart Callback */
-       evas_object_smart_callback_add(genlist, "contracted", gl_contracted_cb, NULL);
-
-       append_gl_allow_all(genlist);
-       append_gl_start_option(genlist, "multiline", "app-notifications");
-       append_gl_item_list(genlist, get_all_apps_list(), ITEM_STYLE_TYPE_ONE);
-
-       return genlist;
-}
-
 static void _create_do_not_disturb_view(void *data)
 {
     NOTISET_TRACE_BEGIN;
@@ -215,7 +194,7 @@ static void _create_notif_view(void *data)
        create_app_notification_list();
 
        /* Create genlist */
-       ugd->list_main = _create_app_notification_gl(ugd);
+       ugd->list_main = create_app_notification_gl(ugd);
 
        /* back Button */
        Evas_Object *back_btn = elm_button_add(ugd->naviframe);
@@ -277,7 +256,8 @@ static void on_destroy(void *priv)
 {
     NOTISET_TRACE_BEGIN;
        ug_data *ugd = priv;
-       remove_all_apps_list();
+       remove_apps_noti_allowed_list();
+       remove_apps_noti_blocked_list();
        free(ugd);
 }
 
index 115bf1f..8696f0f 100755 (executable)
@@ -42,7 +42,8 @@ void create_app_notification_list()
     notification_setting_h temp = NULL;
     item_info_s *item_info = NULL;
 
-    remove_all_apps_list();
+    remove_apps_noti_allowed_list();
+    remove_apps_noti_blocked_list();
     setting_info = calloc(1, sizeof(setting_info_s));
 
     notification_setting_get_setting_array(&setting_array, &count);
@@ -72,7 +73,10 @@ void create_app_notification_list()
                                 && strcmp(package_name, CALENDAR_PACKAGE)
                                 && strcmp(package_name, CLOCK_PACKAGE))
             {
-                setting_info->all_apps_list = eina_list_append(setting_info->all_apps_list, item_info);
+                if(item_info->allow_to_notify)
+                    setting_info->apps_noti_allowed_list = eina_list_append(setting_info->apps_noti_allowed_list, item_info);
+                else
+                    setting_info->apps_noti_blocked_list = eina_list_append(setting_info->apps_noti_blocked_list, item_info);
             } else {
                 FREEIF(package_name);
                 FREEIF(item_info->name);
@@ -82,10 +86,23 @@ void create_app_notification_list()
         }
     }
 
-    setting_info->all_apps_list = eina_list_sort(setting_info->all_apps_list, eina_list_count(setting_info->all_apps_list), apps_sort_cb);
+    setting_info->apps_noti_allowed_list = eina_list_sort(setting_info->apps_noti_allowed_list, eina_list_count(setting_info->apps_noti_allowed_list), apps_sort_cb);
+    setting_info->apps_noti_blocked_list = eina_list_sort(setting_info->apps_noti_blocked_list, eina_list_count(setting_info->apps_noti_blocked_list), apps_sort_cb);
     notification_setting_free_notification(setting_array);
 }
 
+void update_app_notification_list_on_item(item_info_s *item_info)
+{
+    ret_if(!item_info);
+
+    setting_info->apps_noti_allowed_list = eina_list_remove(setting_info->apps_noti_allowed_list, item_info);
+    setting_info->apps_noti_blocked_list = eina_list_remove(setting_info->apps_noti_blocked_list, item_info);
+    if(get_allow_to_nofity(item_info->appid))
+        setting_info->apps_noti_allowed_list = eina_list_sorted_insert(setting_info->apps_noti_allowed_list, apps_sort_cb, item_info);
+    else
+        setting_info->apps_noti_blocked_list = eina_list_sorted_insert(setting_info->apps_noti_blocked_list, apps_sort_cb, item_info);
+}
+
 void create_do_not_disturb_application_list()
 {
     NOTISET_TRACE_BEGIN;
@@ -208,64 +225,28 @@ Eina_List *get_excepted_apps_list()
     return setting_info->excepted_list;
 }
 
-Eina_List *get_all_apps_list()
+Eina_List *get_apps_noti_allowed_list()
 {
     NOTISET_TRACE_BEGIN;
-    return setting_info->all_apps_list;
+    return setting_info->apps_noti_allowed_list;
 }
 
-Eina_List *get_first_allowed_apps_list()
+Eina_List *get_apps_noti_blocked_list()
 {
     NOTISET_TRACE_BEGIN;
-    return setting_info->first_allowed_list;
+    return setting_info->apps_noti_blocked_list;
 }
 
-Eina_List *get_first_excepted_apps_list()
+Eina_List *get_first_allowed_apps_list()
 {
     NOTISET_TRACE_BEGIN;
-    return setting_info->first_excepted_list;
-}
-
-bool get_allow_all()
-{
-    item_info_s *item = NULL;
-    Eina_List *list = get_all_apps_list();
-
-    int count = eina_list_count(list);
-    NOTISET_DBG("count %d", count);
-
-    if (count == 0)
-        return false;
-
-    while (list) {
-        item = (item_info_s*)eina_list_data_get(list);
-        if(item && !item->allow_to_notify)
-            return false;
-        list = eina_list_next(list);
-    }
-
-    return true;
+    return setting_info->first_allowed_list;
 }
 
-void set_allow_all(bool state)
+Eina_List *get_first_excepted_apps_list()
 {
     NOTISET_TRACE_BEGIN;
-
-    item_info_s *item = NULL;
-    Eina_List *list = get_all_apps_list();
-
-    int count = eina_list_count(list);
-    NOTISET_DBG("count %d", count);
-
-    while (list) {
-        item = (item_info_s*)eina_list_data_get(list);
-        if(item) {
-            bool res = set_allow_to_nofity(item->appid, state);
-            if (res)
-                item->allow_to_notify = state;
-        }
-        list = eina_list_next(list);
-    }
+    return setting_info->first_excepted_list;
 }
 
 Eina_List *get_not_excepted_apps_list()
@@ -437,10 +418,17 @@ void remove_lower_noti_list()
         _remove_apps_list(setting_info->lower_noti_list);
 }
 
-void remove_all_apps_list() {
+void remove_apps_noti_allowed_list() {
+    NOTISET_TRACE_BEGIN;
+    if(setting_info) {
+        _remove_apps_list(setting_info->apps_noti_allowed_list);
+    }
+}
+
+void remove_apps_noti_blocked_list() {
     NOTISET_TRACE_BEGIN;
     if(setting_info) {
-        _remove_apps_list(setting_info->all_apps_list);
+        _remove_apps_list(setting_info->apps_noti_blocked_list);
     }
 }
 void remove_excepted_apps_list()