Add channelinfo and channelinfo list layout 11/42811/1
authorjinwoo.shin <jw0227.shin@samsung.com>
Thu, 2 Jul 2015 12:16:50 +0000 (21:16 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Thu, 2 Jul 2015 12:16:50 +0000 (21:16 +0900)
Change-Id: If688f404955c9b9037f2efc99d835a135f02de73
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
14 files changed:
CMakeLists.txt
data/CMakeLists.txt
data/view/channelinfo.edc
include/define.h
include/layout_channelinfo_list.h [new file with mode: 0644]
include/util.h [new file with mode: 0644]
include/view_channelinfo.h
res/images/btn_navigation_down.png [new file with mode: 0644]
res/images/btn_navigation_up.png [new file with mode: 0644]
src/layout_channelinfo.c
src/layout_channelinfo_list.c [new file with mode: 0644]
src/main.c
src/util.c [new file with mode: 0644]
src/view_channelinfo.c

index 566aebf..58ce3f2 100644 (file)
@@ -41,6 +41,8 @@ SET(SRCS src/main.c
                src/tv.c
                src/view_channelinfo.c
                src/layout_channelinfo.c
+               src/layout_channelinfo_list.c
+               src/util.c
                src/tv_service.c)
 
 SET(TARGET_EDJ "${PROJECT_NAME}.edj")
index c2bb8f9..500ddff 100644 (file)
@@ -14,7 +14,7 @@
 #
 
 ADD_CUSTOM_TARGET(${TARGET_EDJ}
-               COMMAND edje_cc -id images
+               COMMAND edje_cc -id ../res/images
                ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.edc
                ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_EDJ}
                DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.edc
@@ -23,7 +23,7 @@ ADD_DEPENDENCIES(${PROJECT_NAME} ${TARGET_EDJ})
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_EDJ} DESTINATION ${EDJEDIR})
 
 ADD_CUSTOM_TARGET(${THEME_EDJ}
-               COMMAND edje_cc -id images -sd sounds
+               COMMAND edje_cc -id ../res/images -sd ../res/sounds
                ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-theme.edc
                ${CMAKE_CURRENT_BINARY_DIR}/${THEME_EDJ}
                DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-theme.edc
index b30785c..4d8bafe 100644 (file)
@@ -36,6 +36,186 @@ group {
 }
 
 group {
+       name, GRP_CHANNELINFO_LIST;
+       images {
+               image, "btn_navigation_up.png" COMP;
+               image, "btn_navigation_down.png" COMP;
+       }
+       parts {
+               part {
+                       name, "bg";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 536 486;
+                               align, 0.0 0.5;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, "part.navigation_up";
+                       type, IMAGE;
+                       scale, 1;
+                       description {
+                               image.normal, "btn_navigation_up.png";
+                               rel1 {
+                                       to, "bg";
+                                       relative, 0.5 0.0;
+                               }
+                               rel2 {
+                                       to, "bg";
+                                       relative, 0.5 0.0;
+                               }
+                               min, 98 34;
+                               align, 0.5 0.0;
+                               fixed, 1 1;
+                               visible, 1;
+                       }
+               }
+               part {
+                       name, "padding.next_channel";
+                       type, SPACER;
+                       description {
+                               rel1 {
+                                       to_y, "part.navigation_up";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to_y, "part.navigation_up";
+                                       relative, 1.0 1.0;
+                               }
+                               min, 0 20;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, PART_CHANNELINFO_LIST_NEXT;
+                       type, SWALLOW;
+                       description {
+                               rel1 {
+                                       to_y, "padding.next_channel";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to_y, "padding.next_channel";
+                                       relative, 1.0 1.0;
+                               }
+                               min, 536 70;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, "padding.current_channel";
+                       type, SPACER;
+                       description {
+                               rel1 {
+                                       to_y, PART_CHANNELINFO_LIST_NEXT;
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to_y, PART_CHANNELINFO_LIST_NEXT;
+                                       relative, 1.0 1.0;
+                               }
+                               min, 0 32;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, PART_CHANNELINFO_LIST_CURRENT;
+                       type, SWALLOW;
+                       description {
+                               rel1 {
+                                       to_y, "padding.current_channel";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to_y, "padding.current_channel";
+                                       relative, 1.0 1.0;
+                               }
+                               min, 536 174;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, "padding.prev_channel";
+                       type, SPACER;
+                       description {
+                               rel1 {
+                                       to_y, PART_CHANNELINFO_LIST_CURRENT;
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to_y, PART_CHANNELINFO_LIST_CURRENT;
+                                       relative, 1.0 1.0;
+                               }
+                               min, 0 32;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, PART_CHANNELINFO_LIST_PREV;
+                       type, SWALLOW;
+                       description {
+                               rel1 {
+                                       to_y, "padding.prev_channel";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to_y, "padding.prev_channel";
+                                       relative, 1.0 1.0;
+                               }
+                               min, 536 70;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, "padding.navigation_down";
+                       type, SPACER;
+                       description {
+                               rel1 {
+                                       to_y, PART_CHANNELINFO_LIST_PREV;
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to_y, PART_CHANNELINFO_LIST_PREV;
+                                       relative, 1.0 1.0;
+                               }
+                               min, 0 20;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, "part.navigation_down";
+                       type, IMAGE;
+                       scale, 1;
+                       description {
+                               image.normal, "btn_navigation_down.png";
+                               rel1 {
+                                       to_y, "padding.navigation_down";
+                                       relative, 0.5 1.0;
+                               }
+                               rel2 {
+                                       to_y, "padding.navigation_down";
+                                       relative, 0.5 1.0;
+                               }
+                               min, 98 34;
+                               align, 0.5 0.0;
+                               fixed, 1 1;
+                               visible, 1;
+                       }
+               }
+       }
+}
+
+group {
        name, GRP_CHANNELINFO;
        parts {
                part {
@@ -44,10 +224,8 @@ group {
                        scale, 1;
                        description {
                                state, "default" 0.0;
-                               rel1.relative, 1.0 0.5;
-                               rel2.relative, 1.0 0.5;
                                min, 536 174;
-                               align, 1.0 0.5;
+                               align, 0.0 0.5;
                                fixed, 1 1;
                        }
                        description {
@@ -265,3 +443,109 @@ group {
                }
        }
 }
+
+group {
+       name, GRP_CHANNELINFO_SIMPLE;
+       parts {
+               part {
+                       name, "bg";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 536 70;
+                               align, 1.0 0.5;
+                               fixed, 1 1;
+                               visible, 0;
+                       }
+               }
+               part {
+                       name, "padding.left";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "bg";
+                                       relative, 0.0 0.0;
+                               }
+                               rel2 {
+                                       to, "bg";
+                                       relative, 0.0 0.0;
+                               }
+                               min, 28 0;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, PART_CHANNELINFO_CHANNEL;
+                       type, TEXT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "padding.left";
+                                       relative, 1.0 0.0;
+                               }
+                               rel2 {
+                                       to, "padding.left";
+                                       relative, 1.0 0.0;
+                               }
+                               text {
+                                       font, FONT_LIGHT;
+                                       size, 32;
+                                       align, 0.0 0.5;
+                               }
+                               color, COLOR_TEXT_TRANS;
+                               min, 480 32;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, "padding.title";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, PART_CHANNELINFO_CHANNEL;
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to, PART_CHANNELINFO_CHANNEL;
+                                       relative, 0.0 1.0;
+                               }
+                               min, 0 6;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, PART_CHANNELINFO_TITLE;
+                       type, TEXT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "padding.title";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to, "padding.title";
+                                       relative, 0.0 1.0;
+                               }
+                               text {
+                                       font, FONT_LIGHT;
+                                       size, 32;
+                                       align, 0.0 0.5;
+                               }
+                               color, COLOR_TEXT_TRANS;
+                               min, 480 32;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+       }
+}
index e544292..83dd802 100644 (file)
@@ -37,6 +37,7 @@
 #define COLOR_BG_FOCUSED 0 119 246 255
 #define COLOR_TEXT_NORMAL 51 51 51 255
 #define COLOR_TEXT_FOCUSED 255 255 255 255
+#define COLOR_TEXT_TRANS 255 255 255 217
 
 #define IMG_LOCKED_NOR IMAGEDIR"ic_thumbnail_lock_01_nor.png"
 #define IMG_LOCKED_FOC IMAGEDIR"ic_thumbnail_lock_01_foc.png"
 
 #define VIEW_CHANNELINFO "VIEW_CHANNELINFO"
 #define LAYOUT_CHANNELINFO "LAYOUT_CHANNELINFO"
+#define LAYOUT_CHANNELINFO_LIST "LAYOUT_CHANNELINFO_LIST"
+
 #define GRP_VIEW_CHANNELINFO "grp.view.channelinfo"
+
+#define GRP_CHANNELINFO_LIST "grp.channelinfo.list"
+#define PART_CHANNELINFO_LIST_NEXT "part.channelinfo.list.next"
+#define PART_CHANNELINFO_LIST_CURRENT "part.channelinfo.list.current"
+#define PART_CHANNELINFO_LIST_PREV "part.channelinfo.list.prev"
+
 #define GRP_CHANNELINFO "grp.channelinfo"
+#define GRP_CHANNELINFO_SIMPLE "grp.channelinfo.simple"
 #define PART_CHANNELINFO_CHANNEL "part.channelinfo.channel"
 #define PART_CHANNELINFO_TITLE "part.channelinfo.title"
 #define PART_CHANNELINFO_TIME "part.channelinfo.time"
diff --git a/include/layout_channelinfo_list.h b/include/layout_channelinfo_list.h
new file mode 100644 (file)
index 0000000..3b7e8ab
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 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 __LAYOUT_CHANNELINFO_LIST_H__
+#define __LAYOUT_CHANNELINFO_LIST_H__
+
+layout_class *layout_channelinfo_list_get_lclass(void);
+
+#endif /* __LAYOUT_CHANNELINFO_H__*/
diff --git a/include/util.h b/include/util.h
new file mode 100644 (file)
index 0000000..25afbc3
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 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_add_layout(Evas_Object *parent, const char *group);
+Evas_Object *util_add_box(Evas_Object *parent, bool horizon);
+Evas_Object *util_add_scroller(Evas_Object *parent, const char *part);
+Evas_Object *util_add_icon(Evas_Object *parent, const char *file,
+               const char *part);
+
+#endif
index f5b01e2..f9e5068 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __LIVETV_VIEW_CHANNELINFO_H__
 #define __LIVETV_VIEW_CHANNELINFO_H__
 
+void draw_channel_info(Evas_Object *obj, const struct tv_channel_info *channel_info);
+
 view_class *view_channelinfo_get_vclass(void);
 
 #endif /* __LIVETV_VIEW_CHANNELINFO_H__*/
diff --git a/res/images/btn_navigation_down.png b/res/images/btn_navigation_down.png
new file mode 100644 (file)
index 0000000..b935681
Binary files /dev/null and b/res/images/btn_navigation_down.png differ
diff --git a/res/images/btn_navigation_up.png b/res/images/btn_navigation_up.png
new file mode 100644 (file)
index 0000000..f6c1df3
Binary files /dev/null and b/res/images/btn_navigation_up.png differ
index 0a5af8a..345adb7 100644 (file)
 
 #include "define.h"
 #include "tv.h"
-
-#define HIDE_DUR 10.0
-#define BUF_MAX 128
-#define STATUS_BOX_PADDING 10
+#include "view_channelinfo.h"
 
 struct _priv {
        Evas_Object *base;
        Evas_Object *layout;
 
-       Ecore_Timer *hide_timer;
        layoutmgr *lmgr;
        const struct tv_channel_info *channel_info;
 };
 
-static int _get_program_time(char *buf, int buf_len, time_t start_time,
-               time_t end_time)
-{
-       struct tm tm;
-       int r;
-
-       if (start_time >= end_time) {
-               _ERR("invalid time");
-               return -1;
-       }
-
-       localtime_r(&start_time, &tm);
-       r = strftime(buf, buf_len, "%I:%M %P -", &tm);
-       if (r <= 0)
-               return -1;
-
-       localtime_r(&end_time, &tm);
-       r = strftime(buf + r, buf_len - r, " %I:%M %P", &tm);
-       if (r <= 0)
-               return -1;
-
-       return 0;
-}
-
-static Eina_Bool _hide_timer(void *data)
-{
-       struct _priv *priv;
-
-       if (!data)
-               return ECORE_CALLBACK_CANCEL;
-
-       priv = data;
-
-       priv->hide_timer = NULL;
-
-       viewmgr_hide_view(VIEW_CHANNELINFO);
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static void _start_hide_timer(struct _priv *priv)
-{
-       if (priv->hide_timer)
-               ecore_timer_reset(priv->hide_timer);
-       else
-               priv->hide_timer = ecore_timer_add(HIDE_DUR, _hide_timer, priv);
-}
-
-static void _stop_hide_timer(struct _priv *priv)
-{
-       if (priv->hide_timer) {
-               ecore_timer_del(priv->hide_timer);
-               priv->hide_timer = NULL;
-       }
-}
-
-static void _add_icon(Evas_Object *box, const char *file)
-{
-       Evas_Object *ic;
-
-       ic = elm_icon_add(box);
-       if (!ic) {
-               _ERR("failed to create icon");
-               return;
-       }
-
-       elm_image_file_set(ic, file, NULL);
-       elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
-       elm_image_no_scale_set(ic, EINA_TRUE);
-       evas_object_show(ic);
-
-       elm_box_pack_end(box, ic);
-}
-
-static void _pack_icon_box(struct _priv *priv,
-               const struct tv_channel_info *channel_info)
-{
-       Evas_Object *box;
-
-       if (!priv) {
-               _ERR("failed to get priv");
-               return;
-       }
-
-       box = elm_box_add(priv->layout);
-       if (!box) {
-               _ERR("failed to create box");
-               return;
-       }
-       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
-                       EVAS_HINT_EXPAND);
-       elm_box_horizontal_set(box, EINA_TRUE);
-       elm_box_padding_set(box, STATUS_BOX_PADDING, 0);
-       elm_box_align_set(box, 1.0, 0.5);
-       elm_object_part_content_set(priv->layout, PART_CHANNELINFO_STATUS, box);
-
-       if (channel_info->locked)
-               _add_icon(box, IMG_LOCKED_NOR);
-       if (channel_info->favorite)
-               _add_icon(box, IMG_FAVORITE_NOR);
-}
-
-static void _load_channel_text(struct _priv *priv,
-               const struct tv_channel_info *channel_info)
-{
-       char buf[BUF_MAX];
-
-       if (!priv || !channel_info) {
-               _ERR("failed to get priv and channel info");
-               return;
-       }
-
-       if (channel_info->channel_minor > 0 &&
-                       channel_info->channel_minor < MINOR_MAX)
-               snprintf(buf, sizeof(buf), "%lu-%lu %s",
-                               channel_info->channel_major,
-                               channel_info->channel_minor,
-                               channel_info->channel_name);
-       else
-               snprintf(buf, sizeof(buf), "%lu %s",
-                               channel_info->channel_major,
-                               channel_info->channel_name);
-
-       elm_object_part_text_set(priv->layout,
-                       PART_CHANNELINFO_CHANNEL, buf);
-
-       elm_object_part_text_set(priv->layout,
-                       PART_CHANNELINFO_TITLE,
-                       STR_NOTITLE);
-       elm_object_part_text_set(priv->layout,
-                       PART_CHANNELINFO_TIME,
-                       STR_NOTIME);
-}
-
-static void _load_program_info(struct _priv *priv,
-               const struct tv_program_info *prog)
-{
-       char buf[BUF_MAX];
-       int r;
-
-       if (!priv || !prog) {
-               _ERR("failed to get priv and program data");
-               return;
-       }
-
-       if (prog->start_time && prog->end_time) {
-               r = _get_program_time(buf, sizeof(buf),
-                               prog->start_time,
-                               prog->end_time);
-               if (!r)
-                       elm_object_part_text_set(priv->layout,
-                                       PART_CHANNELINFO_TIME, buf);
-       }
-
-       if (strlen(prog->prog_title) > 0)
-               elm_object_part_text_set(priv->layout,
-                               PART_CHANNELINFO_TITLE, prog->prog_title);
-}
-
-static void _tv_program_cb(Eina_List *prog_list, void *data)
-{
-       struct _priv *priv;
-       struct tv_program_info *prog = NULL;
-
-       if (!data) {
-               _ERR("failed to get data");
-               return;
-       }
-
-       priv = data;
-
-       prog = (struct tv_program_info *) eina_list_nth(prog_list, 0);
-       if (prog) {
-               if (priv->channel_info &&
-                               prog->service_id != priv->channel_info->service_id)
-                       return;
-               else
-                       _load_program_info(priv, prog);
-       } else {
-               _ERR("failed to get tv_program_info");
-       }
-
-       _start_hide_timer(priv);
-}
-
 static void _update_channel_info(struct _priv *priv)
 {
-       struct tv_program_request *prog_req;
-       int r;
-
        if (priv->channel_info) {
                tv_channel_del_info(priv->channel_info);
                priv->channel_info = NULL;
@@ -238,21 +46,10 @@ static void _update_channel_info(struct _priv *priv)
                return;
        }
 
-       _stop_hide_timer(priv);
-
-       _load_channel_text(priv, priv->channel_info);
-       _pack_icon_box(priv, priv->channel_info);
-
-       prog_req = calloc(1, sizeof(*prog_req));
-       prog_req->tv_program_cb = _tv_program_cb;
-       prog_req->user_data = priv;
-       r = tv_epg_get_program(priv->channel_info->service_id,
-                       prog_req);
-       if (r < 0)
-               _start_hide_timer(priv);
+       draw_channel_info(priv->layout, priv->channel_info);
 }
 
-bool _create(layoutmgr *lmgr, void *data)
+static bool _create(layoutmgr *lmgr, void *data)
 {
        struct _priv *priv;
        Evas_Object *base, *layout;
@@ -292,7 +89,7 @@ error:
        return false;
 }
 
-void _destroy(void *layout_data)
+static void _destroy(void *layout_data)
 {
        struct _priv *priv;
 
@@ -306,13 +103,11 @@ void _destroy(void *layout_data)
                priv->channel_info = NULL;
        }
 
-       _stop_hide_timer(priv);
-
        evas_object_del(priv->layout);
        free(priv);
 }
 
-void _show(void *layout_data)
+static void _show(void *layout_data)
 {
        struct _priv *priv;
 
@@ -326,7 +121,7 @@ void _show(void *layout_data)
        evas_object_show(priv->layout);
 }
 
-void _hide(void *layout_data)
+static void _hide(void *layout_data)
 {
        struct _priv *priv;
 
@@ -335,12 +130,10 @@ void _hide(void *layout_data)
 
        priv = layout_data;
 
-       _stop_hide_timer(priv);
-
        evas_object_hide(priv->layout);
 }
 
-void _update(void *layout_data, int update_type, int *data)
+static void _update(void *layout_data, int update_type, void *data)
 {
 }
 
diff --git a/src/layout_channelinfo_list.c b/src/layout_channelinfo_list.c
new file mode 100644 (file)
index 0000000..eb37091
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2014 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 <Elementary.h>
+#include <layoutmgr.h>
+#include <inputmgr.h>
+#include <viewmgr.h>
+#include <app_debug.h>
+
+#include "define.h"
+#include "util.h"
+#include "tv.h"
+#include "view_channelinfo.h"
+
+struct _priv {
+       Evas_Object *base;
+       Evas_Object *layout;
+       Evas_Object *prev_channel;
+       Evas_Object *current_channel;
+       Evas_Object *next_channel;
+
+       layoutmgr *lmgr;
+};
+
+static void _update_channel_info(struct _priv *priv)
+{
+       const struct tv_channel_info *current_channel;
+
+       current_channel = tv_channel_get_info();
+       if (!current_channel) {
+               _ERR("failed to get channel info");
+
+               return;
+       }
+
+       draw_channel_info(priv->current_channel, current_channel);
+
+       tv_channel_del_info(current_channel);
+}
+
+static bool _create(layoutmgr *lmgr, void *data)
+{
+       struct _priv *priv;
+
+       priv = calloc(1, sizeof(*priv));
+       if (!priv) {
+               _ERR("failed to allocate priv");
+               return false;
+       }
+
+       priv->base = layoutmgr_get_base(lmgr);
+
+       priv->layout = elm_layout_add(priv->base);
+       if (!priv->layout) {
+               _ERR("failed to create layout");
+               return false;
+       }
+       if (!elm_layout_file_set(priv->layout, EDJEFILE, GRP_CHANNELINFO_LIST))
+               goto error;
+       elm_object_content_set(priv->base, priv->layout);
+
+       priv->next_channel = util_add_layout(priv->layout,
+                       GRP_CHANNELINFO_SIMPLE);
+       if (!priv->next_channel)
+               goto error;
+       elm_object_part_content_set(priv->layout,
+                       PART_CHANNELINFO_LIST_NEXT, priv->next_channel);
+
+       priv->current_channel = util_add_layout(priv->layout, GRP_CHANNELINFO);
+       if (!priv->current_channel)
+               goto error;
+       elm_object_part_content_set(priv->layout,
+                       PART_CHANNELINFO_LIST_CURRENT, priv->current_channel);
+
+       priv->prev_channel = util_add_layout(priv->layout,
+                       GRP_CHANNELINFO_SIMPLE);
+       if (!priv->prev_channel)
+               goto error;
+       elm_object_part_content_set(priv->layout,
+                       PART_CHANNELINFO_LIST_PREV, priv->prev_channel);
+
+       priv->lmgr = lmgr;
+
+       layoutmgr_set_layout_data(lmgr, LAYOUT_CHANNELINFO_LIST, priv);
+
+       return true;
+
+error:
+       _ERR("failed to create layout");
+
+       if (priv->layout)
+               evas_object_del(priv->layout);
+       if (priv->prev_channel)
+               evas_object_del(priv->prev_channel);
+       if (priv->current_channel)
+               evas_object_del(priv->current_channel);
+       if (priv->next_channel)
+               evas_object_del(priv->next_channel);
+
+       free(priv);
+
+       return false;
+}
+
+static void _destroy(void *layout_data)
+{
+       struct _priv *priv;
+
+       if (!layout_data)
+               return;
+
+       priv = layout_data;
+
+       evas_object_del(priv->layout);
+       free(priv);
+}
+
+static void _show(void *layout_data)
+{
+       struct _priv *priv;
+
+       if (!layout_data)
+               return;
+
+       priv = layout_data;
+
+       _update_channel_info(priv);
+
+       evas_object_show(priv->layout);
+}
+
+static void _hide(void *layout_data)
+{
+       struct _priv *priv;
+
+       if (!layout_data)
+               return;
+
+       priv = layout_data;
+
+       evas_object_hide(priv->layout);
+}
+
+static void _update(void *layout_data, int update_type, void *data)
+{
+}
+
+static layout_class lclass = {
+       .layout_id = LAYOUT_CHANNELINFO_LIST,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy,
+       .update = _update,
+};
+
+layout_class *layout_channelinfo_list_get_lclass(void)
+{
+       return &lclass;
+}
index 4a9b31d..e3acd73 100644 (file)
@@ -21,8 +21,8 @@
 #include <app_debug.h>
 
 #include "define.h"
-#include "view_channelinfo.h"
 #include "tv.h"
+#include "view_channelinfo.h"
 
 #define KEY_MAX 256
 
diff --git a/src/util.c b/src/util.c
new file mode 100644 (file)
index 0000000..43c098e
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2014 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 "util.h"
+#include "define.h"
+
+Evas_Object *util_add_layout(Evas_Object *parent, const char *group)
+{
+       Evas_Object *ly;
+
+       if (!parent) {
+               _ERR("failed to get parent");
+               return NULL;
+       }
+
+       ly = elm_layout_add(parent);
+       if (!ly) {
+               _ERR("failed to create layout");
+               return NULL;
+       }
+       elm_layout_file_set(ly, EDJEFILE, group);
+
+       evas_object_show(ly);
+
+       return ly;
+}
+
+Evas_Object *util_add_box(Evas_Object *parent, bool horizon)
+{
+       Evas_Object *box;
+
+       if (!parent) {
+               _ERR("failed to get parent");
+               return NULL;
+       }
+
+       box = elm_box_add(parent);
+       if (!box) {
+               _ERR("failed to create box");
+               return NULL;
+       }
+
+       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
+                       EVAS_HINT_EXPAND);
+       elm_object_content_set(parent, box);
+       if (horizon)
+               elm_box_horizontal_set(box, EINA_TRUE);
+       else
+               elm_box_horizontal_set(box, EINA_FALSE);
+
+       evas_object_show(box);
+
+       return box;
+}
+
+Evas_Object *util_add_scroller(Evas_Object *parent, const char *part)
+{
+       Evas_Object *scroll;
+
+       if (!parent) {
+               _ERR("failed to get parent");
+               return NULL;
+       }
+
+       scroll = elm_scroller_add(parent);
+       if (!scroll) {
+               _ERR("failed to create scroll");
+               return NULL;
+       }
+
+       evas_object_size_hint_weight_set(scroll, EVAS_HINT_EXPAND,
+                       EVAS_HINT_EXPAND);
+
+       if (part)
+               elm_object_part_content_set(parent, part, scroll);
+
+       evas_object_show(scroll);
+
+       return scroll;
+}
+
+Evas_Object *util_add_icon(Evas_Object *parent, const char *file,
+               const char *part)
+{
+       Evas_Object *ic;
+
+       if (!parent) {
+               _ERR("failed to get parent");
+               return NULL;
+       }
+
+       ic = elm_icon_add(parent);
+       if (!ic) {
+               _ERR("failed to create icon");
+               return NULL;
+       }
+
+       if (file)
+               elm_image_file_set(ic, file, NULL);
+
+       if (part)
+               elm_object_part_content_set(parent, part, ic);
+
+       elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
+       elm_image_no_scale_set(ic, EINA_TRUE);
+       evas_object_show(ic);
+
+       return ic;
+
+}
index 7c9a593..aab1685 100644 (file)
 #include "define.h"
 #include "tv.h"
 #include "layout_channelinfo.h"
+#include "layout_channelinfo_list.h"
+
+#define HIDE_DUR 10.0
+#define BUF_MAX 128
+#define STATUS_BOX_PADDING 10
+
+enum _update_type {
+       START_HIDE_TIMER,
+       STOP_HIDE_TIMER
+};
 
 struct _priv {
        Evas_Object *base;
+       Ecore_Timer *hide_timer;
 
        layoutmgr *lmgr;
 };
 
+static int _get_program_time(char *buf, int buf_len, time_t start_time,
+               time_t end_time)
+{
+       struct tm tm;
+       int r;
+
+       if (start_time >= end_time) {
+               _ERR("invalid time");
+               return -1;
+       }
+
+       localtime_r(&start_time, &tm);
+       r = strftime(buf, buf_len, "%I:%M %P -", &tm);
+       if (r <= 0)
+               return -1;
+
+       localtime_r(&end_time, &tm);
+       r = strftime(buf + r, buf_len - r, " %I:%M %P", &tm);
+       if (r <= 0)
+               return -1;
+
+       return 0;
+}
+
+static Eina_Bool _hide_timer(void *data)
+{
+       struct _priv *priv;
+
+       if (!data)
+               return ECORE_CALLBACK_CANCEL;
+
+       priv = data;
+
+       priv->hide_timer = NULL;
+
+       viewmgr_hide_view(VIEW_CHANNELINFO);
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
+static void _start_hide_timer(struct _priv *priv)
+{
+       if (priv->hide_timer)
+               ecore_timer_reset(priv->hide_timer);
+       else
+               priv->hide_timer = ecore_timer_add(HIDE_DUR, _hide_timer, priv);
+}
+
+static void _stop_hide_timer(struct _priv *priv)
+{
+       if (priv->hide_timer) {
+               ecore_timer_del(priv->hide_timer);
+               priv->hide_timer = NULL;
+       }
+}
+
+static void _add_icon(Evas_Object *box, const char *file)
+{
+       Evas_Object *ic;
+
+       ic = elm_icon_add(box);
+       if (!ic) {
+               _ERR("failed to create icon");
+               return;
+       }
+
+       elm_image_file_set(ic, file, NULL);
+       elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
+       elm_image_no_scale_set(ic, EINA_TRUE);
+       evas_object_show(ic);
+
+       elm_box_pack_end(box, ic);
+}
+
+static void _pack_icon_box(Evas_Object *obj,
+               const struct tv_channel_info *channel_info)
+{
+       Evas_Object *box;
+
+       box = elm_box_add(obj);
+       if (!box) {
+               _ERR("failed to create box");
+               return;
+       }
+       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
+                       EVAS_HINT_EXPAND);
+       elm_box_horizontal_set(box, EINA_TRUE);
+       elm_box_padding_set(box, STATUS_BOX_PADDING, 0);
+       elm_box_align_set(box, 1.0, 0.5);
+       elm_object_part_content_set(obj, PART_CHANNELINFO_STATUS, box);
+
+       if (channel_info->locked)
+               _add_icon(box, IMG_LOCKED_NOR);
+       if (channel_info->favorite)
+               _add_icon(box, IMG_FAVORITE_NOR);
+}
+
+static void _load_channel_text(Evas_Object *obj,
+               const struct tv_channel_info *channel_info)
+{
+       char buf[BUF_MAX];
+
+       if (channel_info->channel_minor > 0 &&
+                       channel_info->channel_minor < MINOR_MAX)
+               snprintf(buf, sizeof(buf), "%lu-%lu %s",
+                               channel_info->channel_major,
+                               channel_info->channel_minor,
+                               channel_info->channel_name);
+       else
+               snprintf(buf, sizeof(buf), "%lu %s",
+                               channel_info->channel_major,
+                               channel_info->channel_name);
+
+       elm_object_part_text_set(obj,
+                       PART_CHANNELINFO_CHANNEL, buf);
+
+       elm_object_part_text_set(obj,
+                       PART_CHANNELINFO_TITLE,
+                       STR_NOTITLE);
+       elm_object_part_text_set(obj,
+                       PART_CHANNELINFO_TIME,
+                       STR_NOTIME);
+}
+
+static void _load_program_info(Evas_Object *obj,
+               const struct tv_program_info *prog)
+{
+       char buf[BUF_MAX];
+       int r;
+
+       if (prog->start_time && prog->end_time) {
+               r = _get_program_time(buf, sizeof(buf),
+                               prog->start_time,
+                               prog->end_time);
+               if (!r)
+                       elm_object_part_text_set(obj,
+                                       PART_CHANNELINFO_TIME, buf);
+       }
+
+       if (strlen(prog->prog_title) > 0)
+               elm_object_part_text_set(obj,
+                               PART_CHANNELINFO_TITLE, prog->prog_title);
+}
+
+static void _tv_program_cb(Eina_List *prog_list, void *data)
+{
+       Evas_Object *obj;
+       struct tv_program_info *prog = NULL;
+
+       if (!data) {
+               _ERR("failed to get data");
+               return;
+       }
+
+       obj = data;
+
+       prog = (struct tv_program_info *) eina_list_nth(prog_list, 0);
+       if (prog)
+               _load_program_info(obj, prog);
+       else
+               _ERR("failed to get tv_program_info");
+
+       viewmgr_update_view(VIEW_CHANNELINFO, START_HIDE_TIMER);
+}
+
+void draw_channel_info(Evas_Object *obj,
+               const struct tv_channel_info *channel_info)
+{
+       struct tv_program_request *prog_req;
+       int r;
+       int current_service;
+
+       if (!obj || !channel_info) {
+               _ERR("Invalid argument");
+
+               return;
+       }
+
+       r = tv_get_current_service_id(&current_service);
+       if (r < 0)
+               current_service = -1;
+
+       viewmgr_update_view(VIEW_CHANNELINFO, (void *) STOP_HIDE_TIMER);
+
+       _load_channel_text(obj, channel_info);
+       _pack_icon_box(obj, channel_info);
+
+       prog_req = calloc(1, sizeof(*prog_req));
+       prog_req->tv_program_cb = _tv_program_cb;
+       prog_req->user_data = obj;
+
+       if (channel_info->service_id == current_service)
+               r = tv_epg_get_program(channel_info->service_id, prog_req);
+       else
+               r = tv_epg_get_cache_program(channel_info->service_id,
+                               prog_req);
+
+       if (r < 0)
+               viewmgr_update_view(VIEW_CHANNELINFO,
+                               (void *) START_HIDE_TIMER);
+}
+
 static Evas_Object *_create(Evas_Object *win, void *data)
 {
        struct _priv *priv;
@@ -59,6 +272,8 @@ static Evas_Object *_create(Evas_Object *win, void *data)
 
        priv->lmgr = layoutmgr_create(priv->base);
        layoutmgr_add_layout(priv->lmgr, layout_channelinfo_get_lclass(), NULL);
+       layoutmgr_add_layout(priv->lmgr,
+                       layout_channelinfo_list_get_lclass(), NULL);
 
        viewmgr_set_view_data(VIEW_CHANNELINFO, priv);
 
@@ -107,6 +322,7 @@ static void _destroy(void *view_data)
        priv = view_data;
 
        layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO);
+       layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO_LIST);
        layoutmgr_destroy(priv->lmgr);
 
        evas_object_del(priv->base);
@@ -114,12 +330,34 @@ static void _destroy(void *view_data)
        free(priv);
 }
 
+static void _update(void *view_data, void *data)
+{
+       struct _priv *priv;
+
+       if (!view_data) {
+               _ERR("failed to get view data");
+               return;
+       }
+
+       priv = view_data;
+
+       switch ((int) data) {
+       case START_HIDE_TIMER:
+               _start_hide_timer(priv);
+               break;
+       case STOP_HIDE_TIMER:
+               _stop_hide_timer(priv);
+               break;
+       }
+}
+
 static view_class vclass = {
        .view_id = VIEW_CHANNELINFO,
        .create = _create,
        .show = _show,
        .hide = _hide,
        .destroy = _destroy,
+       .update = _update
 };
 
 view_class *view_channelinfo_get_vclass(void)