Add notification detail popup 75/45075/2 accepted/tizen/tv/20150803.003143 submit/tizen/20150802.084009
authorjinwoo.shin <jw0227.shin@samsung.com>
Fri, 31 Jul 2015 07:53:58 +0000 (16:53 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Fri, 31 Jul 2015 07:58:28 +0000 (16:58 +0900)
Change-Id: Ib02e64bec5f4e34c81989bef69e1c6000c7dc1d3
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
CMakeLists.txt
include/define.h
include/util.h [new file with mode: 0644]
src/notification_view.c
src/square_view.c
src/util.c [new file with mode: 0644]

index eb89b99..a6785e6 100644 (file)
@@ -39,7 +39,8 @@ ENDIF(NOT DEFINED MANIFESTDIR)
 
 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")
index aa4ae9e..365faa6 100644 (file)
@@ -41,6 +41,8 @@
 #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"
diff --git a/include/util.h b/include/util.h
new file mode 100644 (file)
index 0000000..d2e0553
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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
index 24811d6..ebec5bb 100644 (file)
@@ -23,6 +23,7 @@
 #include <notification_internal.h>
 
 #include "define.h"
+#include "util.h"
 
 #define STYLE_CATEGORY_TITLE "category_btn"
 #define STYLE_GRID_ITEM "notification_item"
@@ -511,35 +512,18 @@ static void _base_key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
        }
 }
 
-static void _clear_notification(void)
-{
-       notification_list_h noti_list = NULL;
-       notification_h noti;
-
-       notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &noti_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,
index 9dbcbf2..b34788a 100644 (file)
@@ -23,9 +23,9 @@
 #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
@@ -156,6 +156,8 @@ static void _update_list(struct _priv *priv)
                                        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,
@@ -247,7 +249,7 @@ static void _create_button(struct _priv *priv)
                        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,
@@ -258,7 +260,7 @@ static void _create_button(struct _priv *priv)
        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)
@@ -397,16 +399,31 @@ static void _base_key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
 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;
        }
 }
@@ -414,14 +431,24 @@ static void _button_key_up_cb(int id, void *data, Evas *e,
 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;
        }
 }
diff --git a/src/util.c b/src/util.c
new file mode 100644 (file)
index 0000000..90fe646
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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, &noti_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);
+       }
+}