Implement "App notification detail" view 27/83927/3
authorDmytro Dragan <dm.dragan@samsung.com>
Mon, 15 Aug 2016 15:52:33 +0000 (18:52 +0300)
committerDmytro Dragan <dm.dragan@samsung.com>
Tue, 16 Aug 2016 08:39:45 +0000 (11:39 +0300)
Change-Id: Ib3083a1112255325be55491d1b8a46c6a34bef76
Signed-off-by: Dmytro Dragan <dm.dragan@samsung.com>
inc/app-details.h [new file with mode: 0644]
inc/common-efl.h
inc/notification-setting-info.h
project_def.prop
src/CMakeLists.txt
src/app-details.c [new file with mode: 0644]
src/common-efl.c
src/notification-setting-info.c

diff --git a/inc/app-details.h b/inc/app-details.h
new file mode 100644 (file)
index 0000000..e441ff5
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2009 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __APP_DETAILS_H__
+#define __APP_DETAILS_H__
+
+#include "common-efl.h"
+
+/**
+ * @brief Creates app notification details view
+ *
+ * @param[in] data  ug_data pointer to main control struct
+ * @param[in] app_info  item_info_s pointer to struct with selected app data
+ */
+void app_details_create_view(ug_data *data, item_info_s *app_info);
+
+
+
+#endif /* __APP_DETAILS_H__ */
index d2449ce969e458ee56038434ea2af4a61da434bd..1c98a4add43a7b14e6c4b320280dbc749007015c 100755 (executable)
@@ -100,6 +100,13 @@ Evas_Object *create_naviframe(Evas_Object *parent);
  */
 Evas_Object *create_icon(Evas_Object *parent, char *icon_path);
 
+/**
+ * @brief Creates on&off check without callbacks.
+ * @param[in] parent parent object.
+ * @return created check.
+ */
+Evas_Object *create_on_off_check(Evas_Object *parent);
+
 /**
  * @brief Creates a layout based on specified parent object and applies specified style to it.
  * @param[in] parent parent object.
index 2161190631ec50a01add4acbfb30b1eb4d379381..26ebc83851f27367bb99cc0176102d1cb1ba1b0a 100755 (executable)
@@ -46,6 +46,7 @@ bool get_do_not_disturb();
  */
 void set_do_not_disturb(bool state);
 
+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);
 
index d5c73db62d74eed042e859ba8cece4d30e2478c7..68754bacf4cc3954ac036a9acbe0eff651dfad9f 100644 (file)
@@ -9,13 +9,13 @@ type = app
 profile = mobile-3.0
 
 # C/CPP Sources
-USER_SRCS = src/common-efl.c src/do-not-disturb-efl.c src/notification-setting-info.c src/excepted-apps-efl.c src/main.c src/allowed-calls.c src/pkgmgr-setting-info.c src/lock_screen_content.c src/set-schedule-info.c 
+USER_SRCS = src/lock_screen_content.c src/excepted-apps-efl.c src/app-details.c src/pkgmgr-setting-info.c src/allowed-calls.c src/set-schedule-info.c src/notification-setting-info.c src/main.c src/do-not-disturb-efl.c src/common-efl.c 
 
 # EDC Sources
 USER_EDCS =  
 
 # PO Sources
-USER_POS = res/po/fr.po res/po/it_IT.po res/po/et.po res/po/sr.po res/po/hy.po res/po/ca.po res/po/is.po res/po/hi.po res/po/az.po res/po/en_US.po res/po/hr.po res/po/ka.po res/po/zh_HK.po res/po/pl.po res/po/el_GR.po res/po/ko_KR.po res/po/lt.po res/po/sl.po res/po/uz.po res/po/sv.po res/po/fi.po res/po/eu.po res/po/fr_CA.po res/po/bg.po res/po/ja_JP.po res/po/en_PH.po res/po/nl.po res/po/gl.po res/po/uk.po res/po/de.po res/po/tr_TR.po res/po/zh_TW.po res/po/en.po res/po/lv.po res/po/nb.po res/po/pt_PT.po res/po/ru_RU.po res/po/da.po res/po/ro.po res/po/es_ES.po res/po/mk.po res/po/ga.po res/po/sk.po res/po/kk.po res/po/cs.po res/po/pt_BR.po res/po/hu.po res/po/zh_CN.po res/po/ar.po res/po/es_US.po 
+USER_POS = res/po/is.po res/po/ja_JP.po res/po/bg.po res/po/gl.po res/po/pt_PT.po res/po/pl.po res/po/es_US.po res/po/mk.po res/po/ar.po res/po/fi.po res/po/uk.po res/po/lt.po res/po/ko_KR.po res/po/en.po res/po/et.po res/po/hr.po res/po/en_US.po res/po/ru_RU.po res/po/el_GR.po res/po/it_IT.po res/po/nl.po res/po/hu.po res/po/zh_TW.po res/po/kk.po res/po/eu.po res/po/ca.po res/po/cs.po res/po/fr_CA.po res/po/az.po res/po/fr.po res/po/ro.po res/po/sv.po res/po/ga.po res/po/ka.po res/po/sl.po res/po/pt_BR.po res/po/uz.po res/po/zh_HK.po res/po/hi.po res/po/tr_TR.po res/po/en_PH.po res/po/sk.po res/po/lv.po res/po/sr.po res/po/es_ES.po res/po/zh_CN.po res/po/hy.po res/po/nb.po res/po/da.po res/po/de.po 
 
 # User Defines
 USER_DEFS = 
@@ -52,7 +52,7 @@ USER_EDCS_FONT_DIRS = ${OUTPUT_DIR} edje/fonts
 # EDC Flags
 USER_EXT_EDC_KEYS = EDC0 
 
-USER_EXT_EDC0_EDCS = res/edje/repeat_weekly_item.edc res/edje/setting_notification.edc res/edje/reject_calls_popup.edc res/edje/time_button_layout.edc 
+USER_EXT_EDC0_EDCS = res/edje/setting_notification.edc res/edje/time_button_layout.edc res/edje/repeat_weekly_item.edc res/edje/reject_calls_popup.edc 
 USER_EXT_EDC0_EDCS_IMAGE_DIRS = ${OUTPUT_DIR} edje/images 
 USER_EXT_EDC0_EDCS_SOUND_DIRS = ${OUTPUT_DIR} edje/sounds 
 USER_EXT_EDC0_EDCS_FONT_DIRS = ${OUTPUT_DIR} edje/fonts 
index 072d55b2b5d5818ad0677a0ef09564f251dc46c3..d8dc883eea0cdaa5c075056c073444cb33a65564 100644 (file)
@@ -6,16 +6,8 @@ SET(LIBDIR "${PREFIX}/lib")
 
 SET(VERSION 0.1.0)
 
-SET(SRCS
-    allowed-calls.c
-       common-efl.c
-       do-not-disturb-efl.c
-       excepted-apps-efl.c
-       lock_screen_content.c
-       main.c
-       notification-setting-info.c
-    pkgmgr-setting-info.c
-    set-schedule-info.c
+file(GLOB SRCS
+    "*.c"
 )
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc/)
diff --git a/src/app-details.c b/src/app-details.c
new file mode 100644 (file)
index 0000000..f6ecac3
--- /dev/null
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 2009 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "app-details.h"
+
+typedef enum
+{
+    APP_DETAILS_ALLOW_NOTI = 1,
+    APP_DETAILS_GROUP_INDEX,
+    APP_DETAILS_POPUP_NOTI,
+    APP_DETAILS_APP_BADGE,
+    APP_DETAILS_NOTI_ON_LOCK,
+    APP_DETAILS_MAX
+} App_Details_Items;
+
+item_info_s *g_app_info = NULL;
+
+static void close_app_details_cb(void *data, Evas_Object *obj, void *event_info)
+{
+    NOTISET_TRACE_BEGIN;
+    ret_if(!data);
+    elm_naviframe_item_pop(data);
+}
+
+static Eina_Bool allow_noti_status_get()
+{
+    return get_allow_to_nofity(g_app_info->appid);
+}
+
+static void allow_noti_status_set(Eina_Bool value)
+{
+    set_allow_to_nofity(g_app_info->appid, value);
+}
+
+static void allow_noti_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+    Eina_Bool state = elm_check_state_get(obj);
+    allow_noti_status_set(state);
+}
+
+static Eina_Bool popup_noti_status_get()
+{
+    /*TODO: implement when API appears */
+    return EINA_TRUE;
+}
+
+static void popup_noti_status_set(Eina_Bool value)
+{
+    /*TODO: implement when API appears */
+}
+
+static void popup_noti_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+    Eina_Bool state = elm_check_state_get(obj);
+    popup_noti_status_set(state);
+}
+
+static Eina_Bool app_badge_status_get()
+{
+    /*TODO: implement when API appears */
+    return EINA_TRUE;
+}
+
+static void app_badge_status_set(Eina_Bool value)
+{
+    /*TODO: implement when API appears */
+}
+
+static void app_badge_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+    Eina_Bool state = elm_check_state_get(obj);
+    app_badge_status_set(state);
+}
+
+static const char *noti_on_lock_screen_status_get()
+{
+    /*TODO: implement when API appears */
+    return "IDS_QP_OPT_SHOW_ALL_CONTENT_ABB";
+}
+
+static char *app_details_gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+    retv_if(!data, NULL);
+    App_Details_Items item = (App_Details_Items)data;
+
+    switch (item) {
+        case APP_DETAILS_ALLOW_NOTI:
+            if(!strcmp(part, "elm.text"))
+            {
+                return strdup(APP_STRING("IDS_ST_MBODY_ALLOW_NOTIFICATIONS"));
+            }
+            break;
+        /*TODO: get IDS for strings below*/
+        case APP_DETAILS_GROUP_INDEX:
+            if(!strcmp(part, "elm.text"))
+            {
+                return strdup("Details");
+            }
+            break;
+        case APP_DETAILS_POPUP_NOTI:
+            if(!strcmp(part, "elm.text"))
+            {
+                return strdup("Pop-up notification");
+            }
+            else if(!strcmp(part, "elm.text.multiline"))
+            {
+                return strdup("Show pop-up notification on the top of the screen.");
+            }
+            break;
+        case APP_DETAILS_APP_BADGE:
+            if(!strcmp(part, "elm.text"))
+            {
+                return strdup("App badge");
+            }
+            else if(!strcmp(part, "elm.text.sub"))
+            {
+                return strdup("Show badge on the app icon");
+            }
+            break;
+        case APP_DETAILS_NOTI_ON_LOCK:
+            if(!strcmp(part, "elm.text"))
+            {
+                return strdup("Notification on lock screen");
+            }
+            else if(!strcmp(part, "elm.text.sub"))
+            {
+                return strdup(APP_STRING(noti_on_lock_screen_status_get()));
+            }
+            break;
+        default:
+            NOTISET_ERR("Wrong App_Details_Items value used");
+            break;
+    }
+    return NULL;
+}
+
+static Evas_Object *app_details_gl_content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+    Evas_Object *check = NULL;
+    retv_if(!data, NULL);
+    App_Details_Items item = (App_Details_Items)data;
+
+    switch (item) {
+        case APP_DETAILS_ALLOW_NOTI:
+            if(!strcmp(part, "elm.swallow.end"))
+            {
+                check = create_on_off_check(obj);
+                elm_check_state_set(check, allow_noti_status_get());
+                evas_object_smart_callback_add(check, "changed", allow_noti_check_changed_cb, NULL);
+                return check;
+            }
+            else if(!strcmp(part, "elm.swallow.icon"))
+            {
+                return create_icon(obj, g_app_info->icon);
+            }
+            break;
+        case APP_DETAILS_POPUP_NOTI:
+            if(!strcmp(part, "elm.swallow.end"))
+            {
+                check = create_on_off_check(obj);
+                elm_check_state_set(check, popup_noti_status_get());
+                evas_object_smart_callback_add(check, "changed", popup_noti_check_changed_cb, NULL);
+                return check;
+            }
+            break;
+        case APP_DETAILS_APP_BADGE:
+            if(!strcmp(part, "elm.swallow.end"))
+            {
+                check = create_on_off_check(obj);
+                elm_check_state_set(check, app_badge_status_get());
+                evas_object_smart_callback_add(check, "changed", app_badge_check_changed_cb, NULL);
+                return check;
+            }
+            break;
+        default:
+            NOTISET_ERR("Wrong App_Details_Items value used");
+            break;
+    }
+    return NULL;
+}
+
+static void app_details_gl_del_cb(void *data, Evas_Object *obj EINA_UNUSED)
+{
+}
+
+static void app_details_gl_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+    Elm_Object_Item *it = (Elm_Object_Item*)event_info;
+    elm_genlist_item_selected_set(it, EINA_FALSE);
+
+    Evas_Object *check = elm_object_item_part_content_get(it, "elm.swallow.end");
+    if (check) {
+        elm_check_state_set(check, !elm_check_state_get(check));
+        evas_object_smart_callback_call(check, "changed", NULL);
+    }
+}
+
+static void app_details_gl_append(Evas_Object *genlist, char *style, App_Details_Items item_name)
+{
+    NOTISET_TRACE_BEGIN;
+    Elm_Object_Item *gen_item = NULL;
+    Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+    ret_if(!itc);
+
+    itc->item_style = style;
+    itc->func.text_get = app_details_gl_text_get_cb;
+    itc->func.content_get = app_details_gl_content_get_cb;
+    itc->func.del = app_details_gl_del_cb;
+
+    gen_item = elm_genlist_item_append(genlist,                    /* genlist object */
+                            itc,                        /* item class */
+                            (void *)item_name,                     /* item class user data */
+                            NULL,                       /* parent item */
+                            ELM_GENLIST_ITEM_NONE,      /* item type */
+                            app_details_gl_selected_cb,             /* select smart callback */
+                            (void *)item_name);                    /* 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);
+}
+
+void app_details_create_view(ug_data *data, item_info_s *app_info)
+{
+    ret_if(!data || !app_info);
+
+    g_app_info = app_info;
+
+    Evas_Object *back_btn = elm_button_add(data->naviframe);
+    elm_object_style_set(back_btn, "naviframe/back_btn/default");
+    evas_object_smart_callback_add(back_btn, "clicked", close_app_details_cb, data->naviframe);
+
+    /* Push to naviframe */
+    Evas_Object *genlist = elm_genlist_add(data->naviframe);
+    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);
+
+    app_details_gl_append(genlist, "type1", APP_DETAILS_ALLOW_NOTI);
+    app_details_gl_append(genlist, "group_index", APP_DETAILS_GROUP_INDEX);
+    /* TODO: Show this items only if API allows [ */
+    app_details_gl_append(genlist, "multiline", APP_DETAILS_POPUP_NOTI);
+    app_details_gl_append(genlist, "type1", APP_DETAILS_APP_BADGE);
+    /* ] */
+    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);
+}
index d09d1342695db3121175888c0ca88402a3a104f2..4beb4f70370d67d6961c04327b5f131151462509 100755 (executable)
@@ -20,6 +20,7 @@
 #include "set-scedule-info.h"
 #include "allowed-calls.h"
 #include "lock_screen_content.h"
+#include "app-details.h"
 
 #define ICON_SIZE 82
 
@@ -100,6 +101,13 @@ void gl_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
        Elm_Object_Item *it = (Elm_Object_Item*)event_info;
        elm_genlist_item_selected_set(it, EINA_FALSE);
 
+       void *item_data = elm_object_item_data_get(it);
+       if(item_data)
+       {
+           app_details_create_view(g_ug_data, (item_info_s*)item_data);
+           return;
+       }
+
        Evas_Object *check = elm_object_item_part_content_get(it, "elm.swallow.end");
        if (!check) {
                check = elm_object_item_part_content_get(it, "elm.icon.right");
@@ -149,6 +157,16 @@ Evas_Object* create_icon(Evas_Object *parent, char* icon)
 
 }
 
+Evas_Object *create_on_off_check(Evas_Object *parent)
+{
+    Evas_Object *check = elm_check_add(parent);
+    elm_object_style_set(check, "on&off");
+    evas_object_show(check);
+    evas_object_pass_events_set(check, 1);
+    evas_object_propagate_events_set(check, 0);
+    return check;
+}
+
 Evas_Object* create_custom_layout(Evas_Object *parent, char* group_name)
 {
     Evas_Object *layout = create_layout(parent);
@@ -230,24 +248,16 @@ static Evas_Object* gl_content_get_cb(void *data, Evas_Object *obj, const char *
     {
         if(data_list->item_style == ITEM_STYLE_TYPE_ONE)
         {
-            content = elm_check_add(obj);
-            elm_object_style_set(content, "on&off");
+            content = create_on_off_check(obj);
             elm_check_state_set(content, data_list->allow_to_notify);
-            evas_object_show(content);
-            evas_object_pass_events_set(content, 1);
             evas_object_smart_callback_add(content, "changed", _allow_to_nofity_check_changed_cb, data_list);
-            evas_object_propagate_events_set(content, 0);
             return content;
         }
         else if(data_list->item_style == ITEM_STYLE_DEFAULT)
         {
-            content = elm_check_add(obj);
-            elm_object_style_set(content, "on&off");
+            content = create_on_off_check(obj);
             elm_check_state_set(content, data_list->do_not_disturb_except);
-            evas_object_show(content);
-            evas_object_pass_events_set(content, 1);
             evas_object_smart_callback_add(content, "changed", _excepted_check_changed_cb, data_list);
-            evas_object_propagate_events_set(content, 0);
             return content;
         }
         else if(data_list->item_style == ITEM_STYLE_RADIO)
@@ -349,6 +359,7 @@ void append_gl_radio_item_list(Evas_Object *genlist, Eina_List* list, char *styl
 void append_gl_item_list(Evas_Object *genlist, Eina_List* list, int style) {
     NOTISET_TRACE_BEGIN;
 
+    Elm_Object_Item *gen_item = NULL;
        Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
        ret_if(!itc);
 
@@ -372,13 +383,14 @@ void append_gl_item_list(Evas_Object *genlist, Eina_List* list, int style) {
        while (list) {
                item = (item_info_s*)eina_list_data_get(list);
                item->item_style = style;
-               elm_genlist_item_append(genlist,                                                /* genlist object */
+               gen_item = elm_genlist_item_append(genlist,                                             /* genlist object */
                                                                itc,                                                    /* item class */
                                                                item,                                                   /* item class user data */
                                                                NULL,                                                   /* parent item */
                                                                ELM_GENLIST_ITEM_NONE,                  /* item type */
                                                                gl_selected_cb,                                 /* select smart callback */
                                                                NULL);                                          /* smart callback user data */
+               elm_object_item_data_set(gen_item, item);
                list = eina_list_next(list);
        }
        elm_genlist_item_class_free(itc);
@@ -488,24 +500,16 @@ static Evas_Object* _gl_option_content_get_cb(void *data, Evas_Object *obj, cons
     if(!strcmp(data, "do-not-disturb") && !strcmp(part, "elm.swallow.end"))
     {
         Evas_Object *check = NULL;
-        check = elm_check_add(obj);
-        elm_object_style_set(check, "on&off");
+        check = create_on_off_check(obj);
         elm_check_state_set(check, get_do_not_disturb());
-        evas_object_show(check);
-        evas_object_pass_events_set(check, 1);
         evas_object_smart_callback_add(check, "changed", _do_not_disturb_check_changed_cb, NULL);
-        evas_object_propagate_events_set(check, 0);
         return check;
     }
 
     if(!strcmp(data, "set-schedule") && !strcmp("elm.swallow.end", part))
     {
-        Evas_Object *check = elm_check_add(obj);
-        elm_object_style_set(check, "on&off");
+        Evas_Object *check = create_on_off_check(obj);
         elm_check_state_set(check, get_schedule());
-        evas_object_show(check);
-        evas_object_pass_events_set(check, 1);
-        evas_object_propagate_events_set(check, 0);
         evas_object_smart_callback_add(check, "changed", set_schedule_check_changed_cb, NULL);
         return check;
     }
@@ -532,13 +536,9 @@ static Evas_Object* _gl_app_notif_allow_all_content_get_cb(void *data, Evas_Obje
 {
        if (!strcmp(part, "elm.swallow.end") ) {
                Evas_Object *check = NULL;
-               check = elm_check_add(obj);
-               elm_object_style_set(check, "on&off");
+               check = create_on_off_check(obj);
                elm_check_state_set(check, get_allow_all());
-               evas_object_show(check);
-               evas_object_pass_events_set(check, 1);
                evas_object_smart_callback_add(check, "changed", _app_notif_allow_all_check_changed_cb, obj);
-               evas_object_propagate_events_set(check, 0);
                return check;
        }
        return NULL;
index b47c84bc37fb0ec71afe0bfa0df12c9c1a981a21..02097f91c10777f6887223bddb0687aeaa81189d 100755 (executable)
@@ -324,6 +324,29 @@ out:
 
 }
 
+bool get_allow_to_nofity(char *pkg_name)
+{
+    NOTISET_TRACE_BEGIN;
+    int err = NOTIFICATION_ERROR_NONE;
+    bool state = false;
+    notification_setting_h setting = NULL;
+
+    err = notification_setting_get_setting_by_package_name(pkg_name, &setting);
+    if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
+        NOTISET_ERR("notification_setting_get_setting_by_package_name [%d]\n", err);
+        goto out;
+    }
+
+    notification_setting_get_allow_to_notify(setting, &state);
+    NOTISET_DBG("notification_setting_get_allow_to_notify [%d]\n", state);
+
+out:
+    if (setting)
+        notification_setting_free_notification(setting);
+    return state;
+
+}
+
 bool set_allow_to_nofity(char *pkg_name, bool state)
 {
     NOTISET_TRACE_BEGIN;