Add error view for no channel and no signal 93/43993/2
authorjinwoo.shin <jw0227.shin@samsung.com>
Thu, 16 Jul 2015 04:44:53 +0000 (13:44 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Thu, 16 Jul 2015 04:54:01 +0000 (13:54 +0900)
Change-Id: I99d426fb19b72817e14b16e3d1f98491136b764b
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
CMakeLists.txt
data/live-tv.edc
data/view/error.edc [new file with mode: 0644]
include/define.h
include/strings.h
include/view.h
src/layout_channelinfo_search.c
src/main.c
src/view_channelnumber.c
src/view_error.c [new file with mode: 0644]

index 9b42838..34340b1 100644 (file)
@@ -44,6 +44,7 @@ SET(SRCS src/main.c
                src/layout_channelinfo_list.c
                src/layout_channelinfo_search.c
                src/view_channelnumber.c
+               src/view_error.c
                src/util.c
                src/tv_service.c)
 
index 8a77133..2c43574 100644 (file)
@@ -19,4 +19,5 @@
 collections {
        #include "view/channelinfo.edc"
        #include "view/channelnumber.edc"
+       #include "view/error.edc"
 }
diff --git a/data/view/error.edc b/data/view/error.edc
new file mode 100644 (file)
index 0000000..2d1b3e9
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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 "../../include/define.h"
+
+group {
+       name, GRP_VIEW_ERROR;
+       parts {
+               part {
+                       name, "bg";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 244 244 244 255;
+                       }
+               }
+               part {
+                       name, "part.error";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1.relative, 0.5 0.5;
+                               rel2.relative, 0.5 0.5;
+                               min, 0 82;
+                               align, 0.5 0.5;
+                               fixed, 0 1;
+                       }
+
+                       part {
+                               name, PART_ERROR_TITLE;
+                               type, TEXT;
+                               scale, 1;
+                               description {
+                                       rel1.relative, 0.0 0.0;
+                                       rel2.relative, 1.0 0.0;
+                                       text {
+                                               font, FONT_LIGHT;
+                                               size, 28;
+                                               align, 0.5 0.5;
+                                               min, 1 0;
+                                               ellipsis, -1;
+                                       }
+                                       color, 103 103 103 255;
+                                       min, 0 36;
+                                       align, 0.5 0.0;
+                                       fixed, 1 1;
+                               }
+                       }
+                       part {
+                               name, PART_ERROR_TEXT;
+                               type, TEXT;
+                               scale, 1;
+                               description {
+                                       rel1.relative, 0.0 1.0;
+                                       rel2.relative, 1.0 1.0;
+                                       text {
+                                               font, FONT_LIGHT;
+                                               size, 28;
+                                               align, 0.5 0.5;
+                                               min, 1 0;
+                                               ellipsis, -1;
+                                       }
+                                       color, 116 116 116 255;
+                                       min, 0 36;
+                                       align, 0.5 1.0;
+                                       fixed, 1 1;
+                               }
+                       }
+               }
+       }
+}
index 79000c3..372275a 100644 (file)
@@ -73,4 +73,9 @@
 #define PART_CHANNELNUMBER_LIST "part.channelnumber.list"
 #define GRP_CHANNELNUMBER_LIST_ITEM "grp.channelnumber.list.item"
 
+#define VIEW_ERROR "VIEW_ERROR"
+#define GRP_VIEW_ERROR "grp.view.error"
+#define PART_ERROR_TITLE "part.error.title"
+#define PART_ERROR_TEXT "part.error.text"
+
 #endif /* __LIVETV_DEFINE_H__*/
index cb65a19..486c0bd 100644 (file)
@@ -20,5 +20,9 @@
 #define STR_NOTITLE "No Information"
 #define STR_NOTIME "No Data"
 #define STR_CHANNEL_PREFIX "CH."
+#define STR_NOCHANNEL_TITLE "No Channel"
+#define STR_NOCHANNEL_TEXT "The channel is not found"
+#define STR_NOSIGNAL_TITLE "Weak or No Signal"
+#define STR_NOSIGNAL_TEXT "Check the antenna cable connection"
 
 #endif /* __AIR_LIVETV_STRINGS_H__*/
index 936f0fe..8e0fc8e 100644 (file)
 #ifndef __LIVETV_VIEW_H__
 #define __LIVETV_VIEW_H__
 
+#include "tv.h"
+
 enum _update_type {
        UPDATE_TYPE_TIMER,
        UPDATE_TYPE_INPUT_KEY_DOWN,
        UPDATE_TYPE_INPUT_KEY_UP,
+       UPDATE_TYPE_NOCHANNEL,
+       UPDATE_TYPE_NOSIGNAL,
 };
 
 void draw_channel_info(Evas_Object *obj, const struct tv_channel_info *channel_info);
 
 view_class *view_channelnumber_get_vclass(void);
 view_class *view_channelinfo_get_vclass(void);
+view_class *view_error_get_vclass(void);
 
 #endif /* __LIVETV_VIEW_H__*/
index ef62aca..bdaabae 100644 (file)
@@ -92,9 +92,8 @@ static void _release_channel_handler(Evas_Object *obj)
 
        child = elm_box_children_get(obj);
 
-       EINA_LIST_FOREACH(child, l, ly) {
+       EINA_LIST_FOREACH(child, l, ly)
                inputmgr_remove_callback(ly, &channel_handler);
-       }
 
        if (child)
                eina_list_free(child);
index 9cdc317..c806937 100644 (file)
@@ -229,6 +229,7 @@ static bool _create(void *data)
 
        viewmgr_add_view(view_channelinfo_get_vclass(), NULL);
        viewmgr_add_view(view_channelnumber_get_vclass(), NULL);
+       viewmgr_add_view(view_error_get_vclass(), NULL);
 
        r = tv_create();
        if (r < 0) {
@@ -269,6 +270,7 @@ static void _terminate(void *data)
 
                viewmgr_remove_view(VIEW_CHANNELINFO);
                viewmgr_remove_view(VIEW_CHANNELNUMBER);
+               viewmgr_remove_view(VIEW_ERROR);
                viewmgr_destroy();
 
                evas_object_del(ad->win);
index f478b31..ada44ad 100644 (file)
@@ -152,9 +152,8 @@ static void _release_channel_handler(Evas_Object *obj)
 
        child = elm_box_children_get(obj);
 
-       EINA_LIST_FOREACH(child, l, ly) {
+       EINA_LIST_FOREACH(child, l, ly)
                inputmgr_remove_callback(ly, &channel_handler);
-       }
 
        if (child)
                eina_list_free(child);
diff --git a/src/view_error.c b/src/view_error.c
new file mode 100644 (file)
index 0000000..2983c25
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+
+#include <Elementary.h>
+#include <viewmgr.h>
+#include <app_debug.h>
+
+#include "define.h"
+#include "view.h"
+
+struct _priv {
+       Evas_Object *base;
+};
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+       struct _priv *priv;
+
+       if (!win) {
+               _ERR("failed to get win object");
+               return NULL;
+       }
+
+       priv = calloc(1, sizeof(*priv));
+       if (!priv) {
+               _ERR("failed to allocate priv");
+               return NULL;
+       }
+
+       priv->base = elm_layout_add(win);
+       if (!priv->base) {
+               _ERR("failed to create base object");
+               free(priv);
+               return NULL;
+       }
+       elm_layout_file_set(priv->base, EDJEFILE, GRP_VIEW_ERROR);
+
+       evas_object_size_hint_weight_set(priv->base,
+                       EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(win, priv->base);
+
+       viewmgr_set_view_data(VIEW_ERROR, priv);
+
+       return priv->base;
+}
+
+static void _show(void *view_data)
+{
+       struct _priv *priv;
+
+       if (!view_data) {
+               _ERR("failed to get view data");
+               return;
+       }
+
+       priv = view_data;
+
+       evas_object_show(priv->base);
+}
+
+static void _hide(void *view_data)
+{
+       struct _priv *priv;
+
+       if (!view_data) {
+               _ERR("failed to get view data");
+               return;
+       }
+
+       priv = view_data;
+
+       evas_object_hide(priv->base);
+}
+
+static void _destroy(void *view_data)
+{
+       struct _priv *priv;
+
+       if (!view_data) {
+               _ERR("failed to get view data");
+               return;
+       }
+
+       priv = view_data;
+
+       evas_object_del(priv->base);
+
+       free(priv);
+}
+
+static void _update(void *view_data, int type, void *data)
+{
+       struct _priv *priv;
+
+       if (!view_data) {
+               _ERR("failed to get view data");
+               return;
+       }
+
+       priv = view_data;
+
+       if (type == UPDATE_TYPE_NOCHANNEL) {
+               elm_object_part_text_set(priv->base,
+                               PART_ERROR_TITLE, STR_NOCHANNEL_TITLE);
+               elm_object_part_text_set(priv->base,
+                               PART_ERROR_TEXT, STR_NOCHANNEL_TEXT);
+       } else if (type == UPDATE_TYPE_NOSIGNAL) {
+               elm_object_part_text_set(priv->base,
+                               PART_ERROR_TITLE, STR_NOSIGNAL_TITLE);
+               elm_object_part_text_set(priv->base,
+                               PART_ERROR_TEXT, STR_NOSIGNAL_TEXT);
+       }
+}
+
+static view_class vclass = {
+       .view_id = VIEW_ERROR,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy,
+       .update = _update,
+};
+
+view_class *view_error_get_vclass(void)
+{
+       return &vclass;
+}