diff options
author | jinwoo.shin <jw0227.shin@samsung.com> | 2015-06-24 15:34:12 +0900 |
---|---|---|
committer | jinwoo.shin <jw0227.shin@samsung.com> | 2015-06-24 15:37:04 +0900 |
commit | 77a6c887f27be06204211247be98b1df5da86870 (patch) | |
tree | 71b3cca22bc9bae9c67ca15bfc8e851219c7a7a1 | |
parent | d3171e6ed13b93e382d1081141473aa7a065840d (diff) | |
download | air_infosquare-77a6c887f27be06204211247be98b1df5da86870.tar.gz air_infosquare-77a6c887f27be06204211247be98b1df5da86870.tar.bz2 air_infosquare-77a6c887f27be06204211247be98b1df5da86870.zip |
Add notification view implementation
Change-Id: I6fe2a777b6f6eecefa495308a13de79615fbb71d
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
-rw-r--r-- | data/view/notification_view.edc | 311 | ||||
-rw-r--r-- | images/btn_bar_clearall_dis.png (renamed from images/btn_clearall_dis.png) | bin | 3429 -> 3429 bytes | |||
-rw-r--r-- | images/btn_bar_clearall_foc.png (renamed from images/btn_clearall_foc.png) | bin | 3423 -> 3423 bytes | |||
-rw-r--r-- | images/btn_bar_clearall_nor.png (renamed from images/btn_clearall_nor.png) | bin | 3450 -> 3450 bytes | |||
-rw-r--r-- | include/define.h | 10 | ||||
-rw-r--r-- | include/strings.h | 8 | ||||
-rw-r--r-- | src/notification_view.c | 225 |
7 files changed, 543 insertions, 11 deletions
diff --git a/data/view/notification_view.edc b/data/view/notification_view.edc index 00b7a0f..26f0fc0 100644 --- a/data/view/notification_view.edc +++ b/data/view/notification_view.edc @@ -19,12 +19,317 @@ group { name: GRP_NOTIFICATION_VIEW; images { - image, "btn_clearall_dis.png" COMP; - image, "btn_clearall_foc.png" COMP; - image, "btn_clearall_nor.png" COMP; + image, "btn_bar_clearall_dis.png" COMP; + image, "btn_bar_clearall_foc.png" COMP; + image, "btn_bar_clearall_nor.png" COMP; } parts { + part { + name, PART_NOTIFICATION_TITLE_BG; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + rel1.relative, 0.0 0.0; + rel2.relative, 1.0 0.0; + color, 255 255 255 255; + min, 0 104; + align, 0.0 0.0; + fixed, 1 1; + visible, 1; + } + } + part { + name, PART_NOTIFICATION_TITLE; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + rel1.to, PART_NOTIFICATION_TITLE_BG; + rel2.to, PART_NOTIFICATION_TITLE_BG; + text { + font, FONT_REGULAR; + text, STR_NOTIFICATION_TITLE; + size, 46; + align, 0.5 0.5; + } + color, 51 51 51 255; + min, 0 104; + align, 0.0 0.0; + fixed, 1 1; + visible, 1; + } + } + part { + name, PART_NOTIFICATION_CLEAR_BG; + type, RECT; + scale, 1; + description { + rel1 { + to, PART_NOTIFICATION_TITLE; + relative, 1.0 0.0; + } + rel2 { + to, PART_NOTIFICATION_TITLE; + relative, 1.0 1.0; + } + min, 82 104; + align, 1.0 0.0; + fixed, 1 1; + visible, 0; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + color, 0 119 246 255; + visible, 1; + } + } + part { + name, PART_NOTIFICATION_CLEAR; + type, IMAGE; + scale, 1; + description { + state, "default" 0.0; + rel1.to, PART_NOTIFICATION_CLEAR_BG; + rel2.to, PART_NOTIFICATION_CLEAR_BG; + image.normal, "btn_bar_clearall_nor.png"; + align, 0.0 0.0; + fixed, 1 1; + visible, 1; + } + description { + state, "disabled" 0.0; + inherit, "default" 0.0; + image.normal, "btn_bar_clearall_dis.png"; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + image.normal, "btn_bar_clearall_foc.png"; + } + } + part { + name, PART_NOTIFICATION_CONTENT_BG; + type, RECT; + scale, 1; + description { + rel1 { + to_y, PART_NOTIFICATION_TITLE_BG; + relative, 0.0 1.0; + } + min, 0 976; + color, 244 244 244 255; + fixed, 1 1; + visible, 1; + } + } + part { + name, "padding.notification.content"; + type, SPACER; + scale, 1; + description { + rel1 { + to_y, PART_NOTIFICATION_CONTENT_BG; + relative, 0.0 0.0; + } + rel2 { + to_y, PART_NOTIFICATION_CONTENT_BG; + relative, 1.0 0.0; + } + min, 0 132; + fixed, 1 1; + } + description { + state, "no_notification" 0.0; + inherit, "default" 0.0; + min, 0 196; + } + } + part { + name, PART_CONTENT; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "padding.notification.content"; + relative, 0.0 1.0; + } + rel2 { + to, "padding.notification.content"; + relative, 1.0 1.0; + } + min, 0 678; + align, 0.0 0.0; + fixed, 0 1; + visible, 1; + } + description { + state, "no_notification" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + part { + name, PART_NOTIFICATION_NO_NOTIFICATION_BG; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to_y, "padding.notification.content"; + relative, 0.5 1.0; + } + rel2 { + to_y, "padding.notification.content"; + relative, 0.5 1.0; + } + color, 229 229 229 255; + min, 1796 788; + align, 0.5 0.0; + fixed, 1 1; + visible, 0; + } + description { + state, "no_notification" 0.0; + inherit, "default" 0.0; + visible, 1; + } + + part { + name, PART_NOTIFICATION_NO_NOTIFICATION; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + text { + font, FONT_REGULAR; + text, STR_NONOTIFICATION; + size, 40; + align, 0.5 0.5; + } + color, 0 0 0 179; + align, 0.0 0.0; + fixed, 0 1; + visible, 0; + } + description { + state, "no_notification" 0.0; + inherit, "default" 0.0; + visible, 1; + } + } + } } programs { + program { + name, "no_notification"; + signal, SIGNAL_NO_NOTIFICATION; + source, SOURCE_PROGRAM; + action, STATE_SET "no_notification" 0.0; + target, PART_CONTENT; + target, "padding.notification.content"; + target, PART_NOTIFICATION_NO_NOTIFICATION; + target, PART_NOTIFICATION_NO_NOTIFICATION_BG; + } + program { + name, "notification"; + signal, SIGNAL_NOTIFICATION; + action, STATE_SET "default" 0.0; + source, SOURCE_PROGRAM; + target, PART_CONTENT; + target, "padding.notification.content"; + target, PART_NOTIFICATION_NO_NOTIFICATION; + target, PART_NOTIFICATION_NO_NOTIFICATION_BG; + } + } +} +group { + name: GRP_NOTIFICATION_CATEGORY; + parts { + part { + name, "margin.left"; + type, SPACER; + scale, 1; + description { + rel1.relative, 0.0 0.0; + rel2.relative, 0.0 1.0; + state, "default" 0.0; + min, 62 0; + align, 0.0 0.0; + fixed, 1 1; + } + } + part { + name, PART_NOTIFICATION_CATEGORY_TITLE; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to_x, "margin.left"; + relative, 1.0 0.0; + } + rel2.relative, 1.0 0.0; + text { + font, FONT_LIGHT; + size, 36; + align, 0.0 0.5; + min, 1 1; + ellipsis, -1; + } + min, 0 36; + color, 77 77 77 255; + align, 0.0 0.0; + fixed, 0 1; + visible, 1; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + color, 255 255 255 255; + } + } + part { + name, "padding.notification.category.content"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to_y, PART_NOTIFICATION_CATEGORY_TITLE; + relative, 0.0 1.0; + } + rel2 { + to_y, PART_NOTIFICATION_CATEGORY_TITLE; + relative, 1.0 1.0; + } + min, 0 28; + align, 0.0 0.0; + fixed, 0 1; + } + } + part { + name, PART_CONTENT; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to_x, "margin.left"; + to_y, "padding.notification.category.content"; + relative, 1.0 1.0; + } + rel2 { + to_y, "padding.notification.category.content"; + relative, 1.0 1.0; + } + min, 0 614; + align, 0.0 0.0; + fixed, 0 1; + visible, 1; + } + } } } diff --git a/images/btn_clearall_dis.png b/images/btn_bar_clearall_dis.png Binary files differindex fb138ea..fb138ea 100644 --- a/images/btn_clearall_dis.png +++ b/images/btn_bar_clearall_dis.png diff --git a/images/btn_clearall_foc.png b/images/btn_bar_clearall_foc.png Binary files differindex 950c901..950c901 100644 --- a/images/btn_clearall_foc.png +++ b/images/btn_bar_clearall_foc.png diff --git a/images/btn_clearall_nor.png b/images/btn_bar_clearall_nor.png Binary files differindex 8b63be7..8b63be7 100644 --- a/images/btn_clearall_nor.png +++ b/images/btn_bar_clearall_nor.png diff --git a/include/define.h b/include/define.h index fc67269..2928002 100644 --- a/include/define.h +++ b/include/define.h @@ -40,6 +40,16 @@ /* Definitions for notification view */ #define NOTIFICATION_VIEW "NOTIFICATION_VIEW" #define GRP_NOTIFICATION_VIEW "grp.notification.view" +#define PART_NOTIFICATION_TITLE "part.notification.title" +#define PART_NOTIFICATION_TITLE_BG "part.notification.title.bg" +#define PART_NOTIFICATION_CLEAR "part.notification.clear" +#define PART_NOTIFICATION_CLEAR_BG "part.notification.clear.bg" +#define PART_NOTIFICATION_NO_NOTIFICATION "part.notification.no_notification" +#define PART_NOTIFICATION_CONTENT "part.notification.content" +#define PART_NOTIFICATION_CONTENT_BG "part.notification.content.bg" +#define GRP_NOTIFICATION_CATEGORY "grp.notification.category" +#define PART_NOTIFICATION_CATEGORY_TITLE "part.notification.category.title" +#define PART_NOTIFICATION_CATEGORY_CONTENT "part.notification.category.content" /* Definitions for infosquare view */ #define SQUARE_VIEW "SQUARE_VIEW" diff --git a/include/strings.h b/include/strings.h index 0e8a11d..964dc7a 100644 --- a/include/strings.h +++ b/include/strings.h @@ -20,6 +20,14 @@ #define STR_NOTIFICATION_TITLE "Notification Center" #define STR_NONOTIFICATION "No Notification" #define STR_CLEAR_ALL "Clear All" +#define STR_CATEGORY_TODAY "Today" +#define STR_CATEGORY_ONGOING "On going" +#define STR_CATEGORY_TV "TV" +#define STR_CATEGORY_COMMUNICATION "Communication" +#define STR_CATEGORY_EVENT "Event" +#define STR_CATEGORY_THINGS "Things" +#define STR_CATEGORY_INFORMATION "Information & Notification" +#define STR_CATEGORY_FILE "File" #define STR_SQUARE_TITLE STR_NOTIFICATION_TITLE #define STR_NOTIFICATION_LIST_TITLE "Recent Notification" diff --git a/src/notification_view.c b/src/notification_view.c index 6a0bea3..b4ec9a4 100644 --- a/src/notification_view.c +++ b/src/notification_view.c @@ -18,17 +18,203 @@ #include <viewmgr.h> #include <inputmgr.h> #include <app_debug.h> +#include <notification.h> +#include <notification_noti.h> #include "define.h" +#define STYLE_GRID_ITEM "default_2text" +#define PART_ITEM_CONTENT "elm.text2" + +#define NOTIFICATION_CATEGORY_PADDING_X 62 +#define NOTIFICATION_CATEGORY_PADDING_Y 0 +#define NOTIFICATION_CATEGORY_HEIGHT 620 +#define NOTIFICATION_ITEM_WIDTH 489 +#define NOTIFICATION_ITEM_HEIGHT 134 +#define NOTIFICATION_ITEM_PADDING 26 +#define NOTIFICATION_ITEMS_IN_COL 4.0 + +enum notification_category { + CATEGORY_FIRST = 0, + CATEGORY_TODAY = CATEGORY_FIRST, + CATEGORY_ONGOING, + CATEGORY_TV, + CATEGORY_COMMUNICATION, + CATEGORY_EVENT, + CATEGORY_THINGS, + CATEGORY_INFORMATION, + CATEGORY_FILE, + CATEGORY_MAX +}; + struct _priv { Evas_Object *base; + Evas_Object *clear_btn; + Evas_Object *category_container; + Evas_Object *category[CATEGORY_MAX]; + Elm_Gengrid_Item_Class *grid_class; }; +static const char *_get_category_title(int category) +{ + switch (category) { + case CATEGORY_TODAY: + return STR_CATEGORY_TODAY; + case CATEGORY_ONGOING: + return STR_CATEGORY_ONGOING; + case CATEGORY_TV: + return STR_CATEGORY_TV; + case CATEGORY_COMMUNICATION: + return STR_CATEGORY_COMMUNICATION; + case CATEGORY_EVENT: + return STR_CATEGORY_EVENT; + case CATEGORY_THINGS: + return STR_CATEGORY_THINGS; + case CATEGORY_INFORMATION: + return STR_CATEGORY_INFORMATION; + case CATEGORY_FILE: + return STR_CATEGORY_FILE; + default: + return NULL; + } +} + +static void _draw_category(struct _priv *priv, int category, + notification_list_h noti_list) +{ + notification_h noti; + Evas_Object *ly; + int count = 0, col, w; + + if (category < CATEGORY_FIRST || + category >= CATEGORY_MAX) { + _ERR("Undefined category"); + return; + } + + ly = elm_layout_add(priv->category_container); + elm_layout_file_set(ly, EDJEFILE, GRP_NOTIFICATION_CATEGORY); + evas_object_size_hint_align_set(ly, 0.0, 0.0); + + elm_object_part_text_set(ly, PART_NOTIFICATION_CATEGORY_TITLE, + _get_category_title(category)); + + priv->category[category] = elm_gengrid_add(ly); + elm_gengrid_item_size_set(priv->category[category], + NOTIFICATION_ITEM_WIDTH, NOTIFICATION_ITEM_HEIGHT); + elm_gengrid_align_set(priv->category[category], 0.0, 0.0); + elm_gengrid_horizontal_set(priv->category[category], EINA_TRUE); + elm_scroller_policy_set(priv->category[category], + ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + evas_object_size_hint_weight_set(priv->category[category], + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_content_set(ly, priv->category[category]); + + elm_box_pack_end(priv->category_container, ly); + evas_object_show(ly); + + while (noti_list != NULL) { + noti = notification_list_get_data(noti_list); + elm_gengrid_item_append(priv->category[category], + priv->grid_class, noti, NULL, noti); + + noti_list = notification_list_remove(noti_list, noti); + count++; + } + + col = ceil(count / NOTIFICATION_ITEMS_IN_COL); + w = col * NOTIFICATION_ITEM_WIDTH + + (col - 1) * NOTIFICATION_ITEM_PADDING; + evas_object_size_hint_min_set(priv->category[category], + w, NOTIFICATION_CATEGORY_HEIGHT); +} + +static void _update_list(struct _priv *priv) +{ + notification_list_h noti_list = NULL; + + elm_box_clear(priv->category_container); + + notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬i_list); + if (noti_list) { + elm_object_signal_emit(priv->base, + SIGNAL_NOTIFICATION, SOURCE_PROGRAM); + + _draw_category(priv, CATEGORY_TODAY, noti_list); + } else { + elm_object_signal_emit(priv->base, + SIGNAL_NO_NOTIFICATION, SOURCE_PROGRAM); + } +} + +static char *_grid_label_get(void *data, + Evas_Object *obj, + const char *part) +{ + notification_h noti = data; + char *buf = NULL; + + if (!noti) + return NULL; + + if (!strcmp(part, PART_TITLE)) { + notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &buf); + if (!buf) + notification_get_pkgname(noti, &buf); + + return buf ? strdup(buf) : NULL; + } else if (!strcmp(part, PART_ITEM_CONTENT)) { + notification_get_text(noti, + NOTIFICATION_TEXT_TYPE_CONTENT, &buf); + return buf ? strdup(buf) : NULL; + } + + return NULL; +} + +static Evas_Object *_grid_content_get(void *data, + Evas_Object *obj, + const char *part) +{ + notification_h noti = data; + char *icon_path = NULL; + + if (!noti) + return NULL; + + if (!strcmp(part, PART_ICON)) { + notification_get_image(noti, + NOTIFICATION_IMAGE_TYPE_ICON, + &icon_path); + + if (!icon_path) + return NULL; + + Evas_Object *icon = elm_image_add(obj); + + elm_image_file_set(icon, icon_path, NULL); + evas_object_show(icon); + + return icon; + } + + return NULL; +} + +static void _grid_del(void *data, Evas_Object *obj) +{ + notification_h noti = data; + + if (!noti) + return; + + notification_free(noti); +} + static Evas_Object *_create(Evas_Object *win, void *data) { struct _priv *priv; - Evas_Object *base; + Evas_Object *scroller; if (!win) { _ERR("failed to get win object"); @@ -41,22 +227,41 @@ static Evas_Object *_create(Evas_Object *win, void *data) return NULL; } - base = elm_layout_add(win); - if (!base) { + priv->base = elm_layout_add(win); + if (!priv->base) { _ERR("failed to create base object"); free(priv); return NULL; } - elm_layout_file_set(base, EDJEFILE, GRP_NOTIFICATION_VIEW); + elm_layout_file_set(priv->base, EDJEFILE, GRP_NOTIFICATION_VIEW); - evas_object_size_hint_weight_set(base, + evas_object_size_hint_weight_set(priv->base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, base); + elm_win_resize_object_add(win, priv->base); + + scroller = elm_scroller_add(priv->base); + evas_object_size_hint_align_set(scroller, 0.0, 0.0); + elm_object_content_set(priv->base, scroller); + + priv->category_container = elm_box_add(priv->base); + elm_object_content_set(priv->base, priv->category_container); + elm_box_align_set(priv->category_container, 0.0, 0.0); + elm_box_horizontal_set(priv->category_container, EINA_TRUE); + elm_box_padding_set(priv->category_container, + NOTIFICATION_CATEGORY_PADDING_X, + NOTIFICATION_CATEGORY_PADDING_Y); + evas_object_show(priv->category_container); + + priv->grid_class = elm_gengrid_item_class_new(); + priv->grid_class->item_style = STYLE_GRID_ITEM; + priv->grid_class->func.text_get = _grid_label_get; + priv->grid_class->func.content_get = _grid_content_get; + priv->grid_class->func.state_get = NULL; + priv->grid_class->func.del = _grid_del; - priv->base = base; viewmgr_set_view_data(NOTIFICATION_VIEW, priv); - return base; + return priv->base; } static void _show(void *view_data) @@ -70,6 +275,8 @@ static void _show(void *view_data) priv = (struct _priv *) view_data; + _update_list(priv); + evas_object_show(priv->base); } @@ -100,6 +307,8 @@ static void _destroy(void *view_data) evas_object_del(priv->base); + elm_gengrid_item_class_free(priv->grid_class); + free(priv); } |