group {
name: GRP_SQUARE_VIEW;
images {
- image, "btn_noti_list_clearall_dis.png" COMP;
- image, "btn_noti_list_clearall_foc.png" COMP;
- image, "btn_noti_list_clearall_nor.png" COMP;
image, "ic_info_time.png" COMP;
}
parts {
}
}
part {
- name, PART_NOTIFICATION_CLEAR_BG;
- type, RECT;
+ name, PART_NOTIFICATION_CLEAR;
+ type, SWALLOW;
scale, 1;
description {
state, "default" 0.0;
rel1.relative, 1.0 0.0;
rel2.relative, 1.0 0.0;
- color, 48 48 48 255;
align, 1.0 0.0;
min, 99 65;
fixed, 1 1;
}
- part {
- name, PART_NOTIFICATION_CLEAR_ICON;
- type, IMAGE;
- scale, 1;
- description {
- state, "default" 0.0;
- image.normal, "btn_noti_list_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_noti_list_clearall_dis.png";
- }
- description {
- state, "focused" 0.0;
- inherit, "default" 0.0;
- image.normal, "btn_noti_list_clearall_foc.png";
- }
- }
}
part {
name, "padding.notification.list_title";
min, 0 0;
align, 0.0 0.0;
fixed, 1 1;
- visible, 1;
}
}
}
}
}
}
+
+group {
+ name: GRP_NOTIFICATION_ITEM;
+ parts {
+ part {
+ name, "border_bg";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 489 112;
+ color, 51 51 51 255;
+ visible, 1;
+ }
+ description {
+ state, "focused" 0.0;
+ inherit, "default" 0.0;
+ color, 64 171 233 255;
+ }
+ }
+ part {
+ name, "bg";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to, "border_bg";
+ relative, 0.5 0.5;
+ }
+ rel2 {
+ to, "border_bg";
+ relative, 0.5 0.5;
+ }
+ min, 485 108;
+ color, 0 0 0 255;
+ align, 0.5 0.5;
+ fixed, 1 1;
+ visible, 1;
+ }
+ description {
+ state, "focused" 0.0;
+ inherit, "default" 0.0;
+ min, 481 104;
+ color, 46 46 46 51;
+ }
+ }
+ part {
+ name, "padding.icon";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1.relative, 0.0 0.0;
+ rel2.relative, 0.0 0.0;
+ min, 28 0;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, PART_ICON;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to_x, "padding.icon";
+ relative, 1.0 0.5;
+ }
+ rel2 {
+ to_x, "padding.icon";
+ relative, 1.0 0.5;
+ }
+ align, 0.0 0.5;
+ min, 54 54;
+ fixed, 1 1;
+ visible, 1;
+ }
+ }
+ part {
+ name, "padding.text";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to_x, PART_ICON;
+ relative, 1.0 0.5;
+ }
+ rel2 {
+ to_x, PART_ICON;
+ relative, 1.0 0.5;
+ }
+ min, 26 0;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, PART_TEXT;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to, "padding.text";
+ relative, 1.0 0.5;
+ }
+ rel2 {
+ to, "padding.text";
+ relative, 1.0 0.5;
+ }
+ text {
+ font, "TizenSans";
+ size, 27;
+ align, 0.0 0.5;
+ }
+ min, 354 27;
+ align, 0.0 0.5;
+ fixed, 1 1;
+ visible, 1;
+ }
+ }
+ }
+}
+
+group {
+ name: GRP_NOTIFICATION_CLEAR;
+ images {
+ image, "btn_noti_list_clearall_dis.png" COMP;
+ image, "btn_noti_list_clearall_foc.png" COMP;
+ image, "btn_noti_list_clearall_nor.png" COMP;
+ }
+ parts {
+ part {
+ name, PART_NOTIFICATION_CLEAR_BG;
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1.relative, 1.0 0.0;
+ rel2.relative, 1.0 0.0;
+ color, 48 48 48 255;
+ align, 1.0 0.0;
+ min, 99 65;
+ fixed, 1 1;
+ }
+ part {
+ name, PART_NOTIFICATION_CLEAR_ICON;
+ type, IMAGE;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ image.normal, "btn_noti_list_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_noti_list_clearall_dis.png";
+ }
+ description {
+ state, "focused" 0.0;
+ inherit, "default" 0.0;
+ image.normal, "btn_noti_list_clearall_foc.png";
+ }
+ }
+ }
+ }
+}
+
#define KEY_USER_MESSAGE "db/setting/user_message"
#define CLOCK_UPDATE_DUR 1
+#define NOTIFICATION_ITEM_PADDING_X 0
+#define NOTIFICATION_ITEM_PADDING_Y 20
+
+static void _clear_key_up_cb(int id, void *data,
+ Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev);
+static void _clear_clicked_cb(int id, void *data, Evas_Object *obj);
struct _priv {
Evas_Object *base;
+ Evas_Object *list;
+ Evas_Object *clear_btn;
Ecore_Timer *clock_timer;
+ notification_list_h noti_list;
+};
+
+static input_handler clear_handler = {
+ .key_up = _clear_key_up_cb,
+ .clicked = _clear_clicked_cb
};
static void _print_user_message(struct _priv *priv)
if (strftime(buf, sizeof(buf), "%p", &tm) > 0)
elm_object_part_text_set(priv->base, PART_INFO_TIME_AM_PM, buf);
else
- elm_object_part_text_set(priv->base, PART_INFO_TIME_AM_PM, STR_DEFAULT_TIME_AM_PM);
+ elm_object_part_text_set(priv->base,
+ PART_INFO_TIME_AM_PM, STR_DEFAULT_TIME_AM_PM);
if (strftime(buf, sizeof(buf), "%I", &tm) > 0)
elm_object_part_text_set(priv->base, PART_INFO_TIME_HOUR, buf);
else
- elm_object_part_text_set(priv->base, PART_INFO_TIME_HOUR, STR_DEFAULT_TIME_HOUR);
+ elm_object_part_text_set(priv->base,
+ PART_INFO_TIME_HOUR, STR_DEFAULT_TIME_HOUR);
if (strftime(buf, sizeof(buf), "%M", &tm) > 0)
- elm_object_part_text_set(priv->base, PART_INFO_TIME_MINUTE, buf);
+ elm_object_part_text_set(priv->base,
+ PART_INFO_TIME_MINUTE, buf);
else
- elm_object_part_text_set(priv->base, PART_INFO_TIME_MINUTE, STR_DEFAULT_TIME_MINUTE);
+ elm_object_part_text_set(priv->base,
+ PART_INFO_TIME_MINUTE, STR_DEFAULT_TIME_MINUTE);
if (strftime(buf, sizeof(buf), "%A, %B %d", &tm) > 0)
elm_object_part_text_set(priv->base, PART_INFO_DATE, buf);
else
- elm_object_part_text_set(priv->base, PART_INFO_DATE, STR_DEFAULT_DATE);
+ elm_object_part_text_set(priv->base,
+ PART_INFO_DATE, STR_DEFAULT_DATE);
}
static void _print_info(struct _priv *priv)
_print_date_time(priv);
}
+static void _update_list(struct _priv *priv)
+{
+ Evas_Object *icon, *item;
+ notification_h noti = NULL;
+ notification_list_h get_list = NULL;
+ char *title = NULL, *icon_path = NULL;
+
+ elm_box_clear(priv->list);
+
+ if (priv->noti_list) {
+ notification_free_list(priv->noti_list);
+ priv->noti_list = NULL;
+ }
+
+ notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &priv->noti_list);
+ if (priv->noti_list) {
+ elm_object_signal_emit(priv->base,
+ SIGNAL_NOTIFICATION, SOURCE_PROGRAM);
+ elm_object_disabled_set(priv->clear_btn, EINA_FALSE);
+
+ get_list = notification_list_get_head(priv->noti_list);
+ noti = notification_list_get_data(get_list);
+ while (get_list != NULL) {
+ item = elm_layout_add(priv->list);
+ elm_layout_file_set(item, EDJEFILE,
+ GRP_NOTIFICATION_ITEM);
+ elm_object_focus_allow_set(item, EINA_TRUE);
+
+ notification_get_image(noti,
+ NOTIFICATION_IMAGE_TYPE_ICON,
+ &icon_path);
+ if (icon_path) {
+ icon = elm_image_add(item);
+ elm_image_file_set(icon, icon_path, NULL);
+ elm_object_part_content_set(item,
+ PART_ICON, icon);
+ evas_object_show(icon);
+ }
+
+ notification_get_text(noti,
+ NOTIFICATION_TEXT_TYPE_TITLE, &title);
+ if (!title)
+ notification_get_pkgname(noti, &title);
+ elm_object_text_set(item, title);
+
+ elm_box_pack_end(priv->list, item);
+
+ evas_object_show(item);
+
+ get_list = notification_list_get_next(get_list);
+ noti = notification_list_get_data(get_list);
+ }
+ } else {
+ elm_object_signal_emit(priv->base,
+ SIGNAL_NO_NOTIFICATION, SOURCE_PROGRAM);
+ elm_object_disabled_set(priv->clear_btn, EINA_TRUE);
+ }
+}
+
static Eina_Bool _update_clock(void *data)
{
struct _priv *priv;
if (priv->clock_timer)
ecore_timer_reset(priv->clock_timer);
else
- priv->clock_timer = ecore_timer_add(CLOCK_UPDATE_DUR, _update_clock, priv);
+ priv->clock_timer =
+ ecore_timer_add(CLOCK_UPDATE_DUR,
+ _update_clock, priv);
}
void stop_clock_timer(struct _priv *priv)
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");
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_SQUARE_VIEW);
-
- evas_object_size_hint_weight_set(base,
+ elm_layout_file_set(priv->base, EDJEFILE, GRP_SQUARE_VIEW);
+ 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);
+ if (!scroller)
+ goto error;
+ elm_object_part_content_set(priv->base,
+ PART_NOTIFICATION_LIST, scroller);
+ evas_object_show(scroller);
+
+ priv->list = elm_box_add(priv->base);
+ if (!priv->list) {
+ evas_object_del(scroller);
+ goto error;
+ }
+ elm_box_align_set(priv->list, 0.0, 0.0);
+ elm_box_padding_set(priv->list,
+ NOTIFICATION_ITEM_PADDING_X,
+ NOTIFICATION_ITEM_PADDING_Y);
+ evas_object_show(priv->list);
+ elm_object_content_set(scroller, priv->list);
+
+ priv->clear_btn = elm_layout_add(priv->base);
+ elm_layout_file_set(priv->clear_btn, EDJEFILE, GRP_NOTIFICATION_CLEAR);
+ elm_object_focus_allow_set(priv->clear_btn, EINA_TRUE);
+ elm_object_part_content_set(priv->base,
+ PART_NOTIFICATION_CLEAR, priv->clear_btn);
+ evas_object_show(priv->clear_btn);
+
+ inputmgr_add_callback(priv->clear_btn, 0, &clear_handler, NULL);
- priv->base = base;
viewmgr_set_view_data(SQUARE_VIEW, priv);
- return base;
+ return priv->base;
+
+error:
+ _ERR("failed to create view");
+
+ evas_object_del(priv->base);
+ free(priv);
+
+ return NULL;
}
static void _show(void *view_data)
priv = (struct _priv *) view_data;
_print_info(priv);
+ _update_list(priv);
evas_object_show(priv->base);
priv = (struct _priv *) view_data;
- start_clock_timer(priv);
+ if (priv->noti_list) {
+ notification_free_list(priv->noti_list);
+ priv->noti_list = NULL;
+ }
+
+ stop_clock_timer(priv);
evas_object_del(priv->base);
free(priv);
}
+static void _clear_key_up_cb(int id, void *data, Evas *e,
+ Evas_Object *obj, Evas_Event_Key_Up *ev)
+{
+ if (!strcmp(ev->keyname, KEY_ENTER))
+ notification_delete_all(NOTIFICATION_TYPE_NOTI);
+}
+
+static void _clear_clicked_cb(int id, void *data, Evas_Object *obj)
+{
+ notification_delete_all(NOTIFICATION_TYPE_NOTI);
+}
+
static view_class vclass = {
.view_id = SQUARE_VIEW,
.create = _create,