SET(SRCS src/main.c
src/notification_view.c
- src/square_view.c)
+ src/square_view.c
+ src/util.c)
SET(TARGET_EDJ "${PROJECT_NAME}.edj")
SET(THEME_EDJ "${PROJECT_NAME}-theme.edj")
#define FONT_LIGHT "TizenSans:style=Light"
#define FONT_BOLD "TizenSans:style=Bold"
+#define KEY_NOTI "KEY_NOTI"
+
/* Definitions for notification view */
#define NOTIFICATION_VIEW "NOTIFICATION_VIEW"
#define GRP_NOTIFICATION_VIEW "grp.notification.view"
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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 <stdbool.h>
+
+#ifndef __UTIL_H__
+#define __UTIL_H__
+
+Evas_Object *util_show_notification_popup(Evas_Object *base, notification_h noti);
+void util_clear_notification(void);
+
+#endif
#include <notification_internal.h>
#include "define.h"
+#include "util.h"
#define STYLE_CATEGORY_TITLE "category_btn"
#define STYLE_GRID_ITEM "notification_item"
}
}
-static void _clear_notification(void)
-{
- notification_list_h noti_list = NULL;
- notification_h noti;
-
- notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬i_list);
- if (!noti_list)
- return;
-
- while (noti_list != NULL) {
- noti = notification_list_get_data(noti_list);
- notification_delete(noti);
-
- noti_list = notification_list_remove(noti_list, noti);
- notification_free(noti);
- }
-}
-
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))
- _clear_notification();
+ if (!strcmp(ev->keyname, KEY_ENTER) ||
+ !strcmp(ev->keyname, KEY_ENTER_REMOTE))
+ util_clear_notification();
}
static void _clear_mouse_up_cb(int id, void *data, Evas *e,
Evas_Object *obj, Evas_Event_Mouse_Up *ev)
{
- _clear_notification();
+ util_clear_notification();
}
static void _category_unfocused_cb(int id, void *data,
#include <vconf.h>
#include "define.h"
+#include "util.h"
#define KEY_USER_MESSAGE "db/setting/user_message"
-#define KEY_NOTI "KEY_NOTI"
#define CLOCK_UPDATE_DUR 1
#define NOTIFICATION_ITEM_PADDING_X 0
#define NOTIFICATION_ITEM_PADDING_Y 20
GRP_NOTIFICATION_ITEM);
elm_object_focus_allow_set(item, EINA_TRUE);
evas_object_data_set(item, KEY_NOTI, noti);
+ inputmgr_add_callback(item, BUTTON_NOTIFICATION,
+ &button_handler, priv);
notification_get_image(noti,
NOTIFICATION_IMAGE_TYPE_ICON,
PART_NOTIFICATION_CLEAR, priv->clear_btn);
evas_object_show(priv->clear_btn);
inputmgr_add_callback(priv->clear_btn,
- BUTTON_CLEAR, &button_handler, NULL);
+ BUTTON_CLEAR, &button_handler, priv);
priv->launch_btn = elm_layout_add(priv->base);
elm_layout_file_set(priv->launch_btn,
evas_object_show(priv->launch_btn);
elm_object_focus_set(priv->launch_btn, EINA_TRUE);
inputmgr_add_callback(priv->launch_btn,
- BUTTON_LAUNCH, &button_handler, NULL);
+ BUTTON_LAUNCH, &button_handler, priv);
}
static Evas_Object *_create(Evas_Object *win, void *data)
static void _button_key_up_cb(int id, void *data, Evas *e,
Evas_Object *obj, Evas_Event_Key_Up *ev)
{
+ struct _priv *priv;
+ notification_h noti;
+
switch (id) {
case BUTTON_CLEAR:
- if (!strcmp(ev->keyname, KEY_ENTER))
- notification_delete_all(NOTIFICATION_TYPE_NOTI);
+ if (!strcmp(ev->keyname, KEY_ENTER) ||
+ !strcmp(ev->keyname, KEY_ENTER_REMOTE))
+ util_clear_notification();
break;
case BUTTON_LAUNCH:
- if (!strcmp(ev->keyname, KEY_ENTER))
+ if (!strcmp(ev->keyname, KEY_ENTER) ||
+ !strcmp(ev->keyname, KEY_ENTER_REMOTE))
viewmgr_push_view(NOTIFICATION_VIEW);
break;
case BUTTON_NOTIFICATION:
+ if (!strcmp(ev->keyname, KEY_ENTER) ||
+ !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
+ priv = data;
+ noti = evas_object_data_get(obj, KEY_NOTI);
+
+ if (!priv || !noti)
+ return;
+
+ util_show_notification_popup(priv->base, noti);
+ }
break;
}
}
static void _button_mouse_up_cb(int id, void *data, Evas *e,
Evas_Object *obj, Evas_Event_Mouse_Up *ev)
{
+ struct _priv *priv;
+ notification_h noti;
+
switch (id) {
case BUTTON_CLEAR:
- notification_delete_all(NOTIFICATION_TYPE_NOTI);
+ util_clear_notification();
break;
case BUTTON_LAUNCH:
viewmgr_push_view(NOTIFICATION_VIEW);
break;
case BUTTON_NOTIFICATION:
+ priv = data;
+ noti = evas_object_data_get(obj, KEY_NOTI);
+
+ if (!priv || !noti)
+ return;
+
+ util_show_notification_popup(priv->base, noti);
break;
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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 <Elementary.h>
+#include <app_debug.h>
+#include <notification.h>
+#include <inputmgr.h>
+
+#include "define.h"
+
+enum _button_id {
+ BUTTON_OK,
+ BUTTON_CANCEL,
+};
+
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev);
+static void _clicked(int id, void *data, Evas_Object *obj);
+
+static input_handler popup_handler = {
+ .key_up = _key_up_cb,
+ .clicked = _clicked,
+};
+
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev)
+{
+ if (!data)
+ return;
+
+ if (!strcmp(ev->keyname, KEY_BACK) ||
+ !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
+ inputmgr_remove_callback(data, &popup_handler);
+ evas_object_del(data);
+ }
+}
+
+static void _clicked(int id, void *data, Evas_Object *obj)
+{
+ notification_h noti;
+
+ if (!data)
+ return;
+
+ switch (id) {
+ case BUTTON_OK:
+ noti = evas_object_data_get(data, KEY_NOTI);
+ if (noti)
+ notification_delete(noti);
+
+ inputmgr_remove_callback(data, &popup_handler);
+ evas_object_del(data);
+ break;
+ }
+}
+
+Evas_Object *util_show_notification_popup(
+ Evas_Object *base, notification_h noti)
+{
+ Evas_Object *popup, *btn1;
+ char *title = NULL;
+ char *content = NULL;
+
+ popup = elm_popup_add(base);
+ if (!popup) {
+ _ERR("create popup failed");
+ return NULL;
+ }
+
+ notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &title);
+ elm_object_part_text_set(popup, "title,text", title);
+
+ notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
+ elm_object_text_set(popup, content);
+
+ evas_object_data_set(popup, KEY_NOTI, noti);
+
+ btn1 = elm_button_add(popup);
+ elm_object_text_set(btn1, "OK");
+ elm_object_part_content_set(popup, "button1", btn1);
+ inputmgr_add_callback(btn1,
+ BUTTON_OK, &popup_handler, popup);
+ evas_object_show(btn1);
+ elm_object_focus_set(btn1, EINA_TRUE);
+
+ evas_object_show(popup);
+
+ return popup;
+}
+
+void util_clear_notification(void)
+{
+ notification_list_h noti_list = NULL;
+ notification_h noti;
+
+ notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬i_list);
+ if (!noti_list)
+ return;
+
+ while (noti_list != NULL) {
+ noti = notification_list_get_data(noti_list);
+ notification_delete(noti);
+
+ noti_list = notification_list_remove(noti_list, noti);
+ notification_free(noti);
+ }
+}