summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjinwoo.shin <jw0227.shin@samsung.com>2015-07-15 19:43:14 +0900
committerjinwoo.shin <jw0227.shin@samsung.com>2015-07-15 19:43:14 +0900
commit5bd30ea364075b537e787115da47cd88f55873c2 (patch)
tree97d93eaba26c9759bcc36e289a2d374b5678cb84
parentad24aef8e4060765ab62c691f42a688ae9835ec1 (diff)
downloadair_livetv-5bd30ea364075b537e787115da47cd88f55873c2.tar.gz
air_livetv-5bd30ea364075b537e787115da47cd88f55873c2.tar.bz2
air_livetv-5bd30ea364075b537e787115da47cd88f55873c2.zip
Add channel number view for tune by channel number
Change-Id: Ied85abe9eacec42646914c348ac4045ed1e1dcfe Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
-rw-r--r--CMakeLists.txt1
-rw-r--r--data/live-tv.edc1
-rw-r--r--data/view/channelnumber.edc327
-rw-r--r--include/define.h10
-rw-r--r--include/strings.h1
-rw-r--r--include/view.h (renamed from include/view_channelinfo.h)7
-rw-r--r--src/layout_channelinfo.c2
-rw-r--r--src/layout_channelinfo_list.c2
-rw-r--r--src/layout_channelinfo_search.c2
-rw-r--r--src/main.c13
-rw-r--r--src/view_channelinfo.c4
-rw-r--r--src/view_channelnumber.c459
12 files changed, 820 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9bdcd5b..9b42838 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,6 +43,7 @@ SET(SRCS src/main.c
src/layout_channelinfo.c
src/layout_channelinfo_list.c
src/layout_channelinfo_search.c
+ src/view_channelnumber.c
src/util.c
src/tv_service.c)
diff --git a/data/live-tv.edc b/data/live-tv.edc
index 26d27bf..8a77133 100644
--- a/data/live-tv.edc
+++ b/data/live-tv.edc
@@ -18,4 +18,5 @@
collections {
#include "view/channelinfo.edc"
+ #include "view/channelnumber.edc"
}
diff --git a/data/view/channelnumber.edc b/data/view/channelnumber.edc
new file mode 100644
index 0000000..9892029
--- /dev/null
+++ b/data/view/channelnumber.edc
@@ -0,0 +1,327 @@
+/*
+ * 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_CHANNELNUMBER;
+ parts {
+ part {
+ name, "padding.channelnumber";
+ type, SPACER;
+ description {
+ state, "default" 0.0;
+ rel1.relative, 0.0 0.0;
+ rel2.relative, 0.0 0.0;
+ align, 0.0 0.0;
+ min, 62 48;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, "part.channelnumber.info";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to, "padding.channelnumber";
+ relative, 1.0 1.0;
+ }
+ rel2 {
+ to, "padding.channelnumber";
+ relative, 1.0 1.0;
+ }
+ min, 216 90;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ visible, 0;
+ }
+
+ part {
+ name, "padding.channelnumber.channel_prefix";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1.relative, 0.0 0.0;
+ rel2.relative, 0.0 0.0;
+ min, 0 34;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, "part.channelnumber.channel_prefix";
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to, "padding.channelnumber.channel_prefix";
+ relative, 0.0 1.0;
+ }
+ rel2 {
+ to, "padding.channelnumber.channel_prefix";
+ relative, 0.0 1.0;
+ }
+ text {
+ font, FONT_LIGHT;
+ text, STR_CHANNEL_PREFIX;
+ size, 46;
+ align, 1.0 0.5;
+ min, 1 0;
+ ellipsis, -1;
+ }
+ color, COLOR_TEXT_TRANS;
+ min, 0 46;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, "padding.channelnumber.channel";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to_x, "part.channelnumber.channel_prefix";
+ relative, 1.0 0.0;
+ }
+ rel2 {
+ to_x, "part.channelnumber.channel_prefix";
+ relative, 1.0 1.0;
+ }
+ min, 26 0;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, PART_CHANNELNUMBER_NUMBER;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to_x, "padding.channelnumber.channel";
+ relative, 1.0 0.0;
+ }
+ rel2 {
+ to_x, "padding.channelnumber.channel";
+ relative, 1.0 0.0;
+ }
+ text {
+ font, FONT_LIGHT;
+ size, 80;
+ align, 0.0 0.5;
+ min, 1 0;
+ ellipsis, -1;
+ }
+ color, COLOR_TEXT_TRANS;
+ min, 0 90;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ }
+ part {
+ name, "padding.list";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to, "part.channelnumber.info";
+ relative, 0.0 1.0;
+ }
+ rel2 {
+ to, "part.channelnumber.info";
+ relative, 1.0 1.0;
+ }
+ min, 0 38;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, "bg.list.border";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to, "padding.list";
+ relative, 0.0 1.0;
+ }
+ rel2 {
+ to, "padding.list";
+ relative, 1.0 1.0;
+ }
+ color, COLOR_OPTION_BORDER;
+ min, 216 224;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, "bg.list";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to, "bg.list.border";
+ relative, 0.5 0.5;
+ }
+ rel2 {
+ to, "bg.list.border";
+ relative, 0.5 0.5;
+ }
+ color, COLOR_BG_NORMAL;
+ min, 214 222;
+ align, 0.5 0.5;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, PART_CHANNELNUMBER_LIST;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to, "bg.list";
+ relative, 0.0 0.0;
+ }
+ rel2 {
+ to, "bg.list";
+ relative, 1.0 1.0;
+ }
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ }
+}
+
+group {
+ name, GRP_CHANNELNUMBER_LIST_ITEM;
+ parts {
+ part {
+ name, "bg";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, COLOR_BG_NORMAL;
+ min, 216 56;
+ align, 0.0 0.0;
+ }
+ description {
+ state, "focused" 0.0;
+ inherit, "default" 0.0;
+ color, COLOR_BG_FOCUSED;
+ }
+ }
+ 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 1.0;
+ }
+ align, 0.0 0.0;
+ min, 30 0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, "padding.right";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to, "bg";
+ relative, 1.0 0.0;
+ }
+ rel2 {
+ to, "bg";
+ relative, 1.0 1.0;
+ }
+ align, 1.0 0.0;
+ min, 30 0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, PART_TEXT;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1 {
+ to_x, "padding.left";
+ relative, 1.0 0.0;
+ }
+ rel2 {
+ to_x, "padding.right";
+ relative, 0.0 1.0;
+ }
+ text {
+ font, FONT_LIGHT;
+ size, 28;
+ align, 0.0 0.5;
+ }
+ color, COLOR_OPTION_TEXT_NORMAL;
+ align, 0.0 0.0;
+ }
+ description {
+ state, "focused" 0.0;
+ inherit, "default" 0.0;
+ color, COLOR_TEXT_FOCUSED;
+ }
+ }
+ }
+ programs {
+ program {
+ name, "focused";
+ signal, SIGNAL_FOCUSED;
+ source, SOURCE_ELM;
+ action, STATE_SET "focused" 0.0;
+ target, "bg";
+ target, PART_TEXT;
+ }
+ program {
+ name, "unfocused";
+ signal, SIGNAL_UNFOCUSED;
+ source, SOURCE_ELM;
+ action, STATE_SET "default" 0.0;
+ target, "bg";
+ target, PART_TEXT;
+ }
+ }
+}
+
diff --git a/include/define.h b/include/define.h
index 8b4760f..79000c3 100644
--- a/include/define.h
+++ b/include/define.h
@@ -22,6 +22,7 @@
#define KEY_SVCID "svcid"
#define PART_CONTENT "elm.swallow.content"
+#define PART_TEXT "elm.text"
#define SOURCE_PROGRAM "program"
#define SOURCE_ELM "elm"
@@ -38,6 +39,9 @@
#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 COLOR_OPTION_TEXT_NORMAL 87 87 87 255
+#define COLOR_OPTION_TEXT_FOCUSED 255 255 255 255
+#define COLOR_OPTION_BORDER 154 154 154 255
#define IMG_LOCKED_NOR IMAGEDIR"ic_thumbnail_lock_01_nor.png"
#define IMG_LOCKED_FOC IMAGEDIR"ic_thumbnail_lock_01_foc.png"
@@ -63,4 +67,10 @@
#define PART_CHANNELINFO_TIME "part.channelinfo.time"
#define PART_CHANNELINFO_STATUS "part.channelinfo.status"
+#define VIEW_CHANNELNUMBER "VIEW_CHANNELNUMBER"
+#define GRP_VIEW_CHANNELNUMBER "grp.view.channelnumber"
+#define PART_CHANNELNUMBER_NUMBER "part.channelnumber.number"
+#define PART_CHANNELNUMBER_LIST "part.channelnumber.list"
+#define GRP_CHANNELNUMBER_LIST_ITEM "grp.channelnumber.list.item"
+
#endif /* __LIVETV_DEFINE_H__*/
diff --git a/include/strings.h b/include/strings.h
index 026a670..cb65a19 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -19,5 +19,6 @@
#define STR_NOTITLE "No Information"
#define STR_NOTIME "No Data"
+#define STR_CHANNEL_PREFIX "CH."
#endif /* __AIR_LIVETV_STRINGS_H__*/
diff --git a/include/view_channelinfo.h b/include/view.h
index 6637f1a..936f0fe 100644
--- a/include/view_channelinfo.h
+++ b/include/view.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef __LIVETV_VIEW_CHANNELINFO_H__
-#define __LIVETV_VIEW_CHANNELINFO_H__
+#ifndef __LIVETV_VIEW_H__
+#define __LIVETV_VIEW_H__
enum _update_type {
UPDATE_TYPE_TIMER,
@@ -25,6 +25,7 @@ enum _update_type {
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);
-#endif /* __LIVETV_VIEW_CHANNELINFO_H__*/
+#endif /* __LIVETV_VIEW_H__*/
diff --git a/src/layout_channelinfo.c b/src/layout_channelinfo.c
index 00a58e0..5cdb323 100644
--- a/src/layout_channelinfo.c
+++ b/src/layout_channelinfo.c
@@ -22,7 +22,7 @@
#include "define.h"
#include "tv.h"
-#include "view_channelinfo.h"
+#include "view.h"
struct _priv {
Evas_Object *base;
diff --git a/src/layout_channelinfo_list.c b/src/layout_channelinfo_list.c
index 1bcc741..a6ab0b9 100644
--- a/src/layout_channelinfo_list.c
+++ b/src/layout_channelinfo_list.c
@@ -23,7 +23,7 @@
#include "define.h"
#include "util.h"
#include "tv.h"
-#include "view_channelinfo.h"
+#include "view.h"
enum _order {
CHANNEL_NEXT,
diff --git a/src/layout_channelinfo_search.c b/src/layout_channelinfo_search.c
index fbedb1d..ef62aca 100644
--- a/src/layout_channelinfo_search.c
+++ b/src/layout_channelinfo_search.c
@@ -23,7 +23,7 @@
#include "define.h"
#include "util.h"
#include "tv.h"
-#include "view_channelinfo.h"
+#include "view.h"
#define DIVIDER_WIDTH 536
#define DIVIDER_HEIGHT 1
diff --git a/src/main.c b/src/main.c
index b67228b..9cdc317 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,7 +22,8 @@
#include "define.h"
#include "tv.h"
-#include "view_channelinfo.h"
+#include "util.h"
+#include "view.h"
#define KEY_MAX 256
@@ -49,6 +50,14 @@ static struct key_map g_kmap[] = {
KEY_CHANNELDOWN, KEY_CHANNELDOWN_REMOTE
}
},
+ {
+ VIEW_CHANNELNUMBER,
+ {
+ KEY_0, KEY_1, KEY_2, KEY_3,
+ KEY_4, KEY_5, KEY_6, KEY_7,
+ KEY_8, KEY_9, KEY_MINUS
+ }
+ },
};
static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
@@ -219,6 +228,7 @@ static bool _create(void *data)
}
viewmgr_add_view(view_channelinfo_get_vclass(), NULL);
+ viewmgr_add_view(view_channelnumber_get_vclass(), NULL);
r = tv_create();
if (r < 0) {
@@ -258,6 +268,7 @@ static void _terminate(void *data)
inputmgr_remove_callback(ad->win, &key_handler);
viewmgr_remove_view(VIEW_CHANNELINFO);
+ viewmgr_remove_view(VIEW_CHANNELNUMBER);
viewmgr_destroy();
evas_object_del(ad->win);
diff --git a/src/view_channelinfo.c b/src/view_channelinfo.c
index 6e4296a..86618e7 100644
--- a/src/view_channelinfo.c
+++ b/src/view_channelinfo.c
@@ -22,7 +22,7 @@
#include "define.h"
#include "tv.h"
-#include "view_channelinfo.h"
+#include "view.h"
#include "layout_channelinfo.h"
#include "layout_channelinfo_list.h"
#include "layout_channelinfo_search.h"
@@ -58,7 +58,7 @@ static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
_update(data, UPDATE_TYPE_INPUT_KEY_UP, ev);
}
-void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
+static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
Evas_Event_Mouse_Move *ev)
{
viewmgr_update_view(VIEW_CHANNELINFO,
diff --git a/src/view_channelnumber.c b/src/view_channelnumber.c
new file mode 100644
index 0000000..f478b31
--- /dev/null
+++ b/src/view_channelnumber.c
@@ -0,0 +1,459 @@
+/*
+ * 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 <inputmgr.h>
+#include <app_debug.h>
+
+#include "define.h"
+#include "util.h"
+#include "tv.h"
+#include "view.h"
+
+#define HIDE_DUR 3.0
+#define BUF_MAX 128
+
+struct _priv {
+ Evas_Object *base;
+ Evas_Object *list;
+ Ecore_Timer *hide_timer;
+
+ int major;
+ int minor;
+};
+
+static void _update(void *view_data, int type, void *data);
+
+static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
+{
+ _update(data, UPDATE_TYPE_INPUT_KEY_DOWN, ev);
+}
+
+static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Up *ev)
+{
+ _update(data, UPDATE_TYPE_INPUT_KEY_UP, ev);
+}
+
+static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Mouse_Move *ev)
+{
+ viewmgr_update_view(VIEW_CHANNELNUMBER,
+ UPDATE_TYPE_TIMER, 0);
+}
+
+static input_handler key_handler = {
+ .key_down = _key_down_cb,
+ .key_up = _key_up_cb,
+ .mouse_move = _mouse_move_cb,
+};
+
+static Eina_Bool _hide_timer(void *data)
+{
+ struct _priv *priv;
+ int r;
+
+ if (!data)
+ return ECORE_CALLBACK_CANCEL;
+
+ priv = data;
+
+ priv->hide_timer = NULL;
+
+ r = tv_channel_direct_tune(priv->major, priv->minor);
+ if (r < 0)
+ _ERR("invalid channel");
+
+ viewmgr_hide_view(VIEW_CHANNELNUMBER);
+
+ 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 _tune_channel(void *data)
+{
+ int service_id;
+ int r;
+
+ if (!data) {
+ _ERR("failed to get data");
+ return;
+ }
+
+ service_id = (int) data;
+ if (service_id < 0) {
+ _ERR("failed to get service id");
+ return;
+ }
+
+ r = tv_channel_tune_with_service_id(service_id);
+ if (r < 0)
+ _ERR("failed to tune with service id");
+
+ viewmgr_hide_view(VIEW_CHANNELNUMBER);
+}
+
+static void _channel_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
+{
+ if (!strcmp(ev->keyname, KEY_ENTER) ||
+ !strcmp(ev->keyname, KEY_ENTER_REMOTE))
+ _tune_channel(data);
+}
+
+static void _channel_mouse_down_cb(int id, void *data, Evas *e,
+ Evas_Object *obj, Evas_Event_Mouse_Down *ev)
+{
+ _tune_channel(data);
+}
+
+static input_handler channel_handler = {
+ .key_down = _channel_key_down_cb,
+ .mouse_down = _channel_mouse_down_cb,
+};
+
+static void _release_channel_handler(Evas_Object *obj)
+{
+ Eina_List *child, *l;
+ Evas_Object *ly;
+
+ if (!obj)
+ return;
+
+ child = elm_box_children_get(obj);
+
+ EINA_LIST_FOREACH(child, l, ly) {
+ inputmgr_remove_callback(ly, &channel_handler);
+ }
+
+ if (child)
+ eina_list_free(child);
+}
+
+static void _update_channel_list(struct _priv *priv)
+{
+ Evas_Object *ly, *first;
+ Eina_List *channel_list, *l;
+ const struct tv_channel_info *channel_info;
+ char buf[BUF_MAX];
+
+ channel_list = tv_channel_search_by_number(priv->major, priv->minor);
+
+ _release_channel_handler(priv->list);
+ elm_box_clear(priv->list);
+
+ first = NULL;
+ ly = NULL;
+ EINA_LIST_FOREACH(channel_list, l, channel_info) {
+ ly = util_add_layout(priv->list, GRP_CHANNELNUMBER_LIST_ITEM);
+ if (!ly) {
+ _ERR("failed to create layout");
+ return;
+ }
+
+ elm_object_focus_allow_set(ly, EINA_TRUE);
+
+ snprintf(buf, sizeof(buf), "%ld %s",
+ channel_info->channel_major,
+ channel_info->channel_name);
+ elm_object_text_set(ly, buf);
+
+ inputmgr_add_callback(ly, 0, &channel_handler,
+ (void *) channel_info->service_id);
+
+ elm_box_pack_end(priv->list, ly);
+
+ if (!first) {
+ first = ly;
+ elm_object_focus_set(ly, EINA_TRUE);
+ }
+ }
+
+ if (first && ly)
+ elm_object_focus_next_object_set(first, ly, ELM_FOCUS_UP);
+
+ if (channel_list)
+ tv_channel_del_list(channel_list);
+}
+
+static void _update_number_info(struct _priv *priv)
+{
+ char buf[BUF_MAX];
+
+ if (priv->major < 0) {
+ _ERR("Wrong channel number");
+ return;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", priv->major);
+
+ elm_object_part_text_set(priv->base, PART_CHANNELNUMBER_NUMBER, buf);
+
+ _update_channel_list(priv);
+}
+
+static int _get_number(const char *keyname)
+{
+ static const char const *keys[] = {
+ KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
+ KEY_5, KEY_6, KEY_7, KEY_8, KEY_9
+ };
+
+ int i;
+
+ if (!keyname) {
+ _ERR("failed to get keyname");
+ return -1;
+ }
+
+ for (i = 0; i < sizeof(keys) / sizeof(*keys); i++) {
+ if (!strcmp(keyname, keys[i]))
+ return i;
+ }
+
+ return -1;
+}
+
+static void _number_reset(struct _priv *priv)
+{
+ priv->major = -1;
+ priv->minor = -1;
+
+ _release_channel_handler(priv->list);
+ elm_box_clear(priv->list);
+}
+
+static void _number_tuning(struct _priv *priv, const char *keyname)
+{
+ int num;
+
+ if (!priv || !keyname) {
+ _ERR("failed to get priv and keyname");
+ return;
+ }
+
+ num = _get_number(keyname);
+ if (num < 0 || (num == 0 && priv->major <= 0))
+ goto error;
+
+ if (priv->major < 0) {
+ priv->major = num;
+ } else {
+ priv->major *= 10;
+ priv->major += num;
+ }
+
+ if (priv->major > MAJOR_MAX)
+ goto error;
+
+ _update_number_info(priv);
+
+ return;
+
+error:
+ _number_reset(priv);
+}
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+ struct _priv *priv;
+ Evas_Object *scroll = NULL;
+
+ 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");
+ goto error;
+ }
+ elm_layout_file_set(priv->base, EDJEFILE, GRP_VIEW_CHANNELNUMBER);
+
+ evas_object_size_hint_weight_set(priv->base,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, priv->base);
+
+ scroll = util_add_scroller(priv->base, PART_CHANNELNUMBER_LIST);
+ if (!scroll) {
+ _ERR("failed to create scroll");
+ goto error;
+ }
+
+ elm_object_focus_allow_set(scroll, EINA_FALSE);
+
+ priv->list = util_add_box(scroll, false);
+ if (!priv->list) {
+ _ERR("failed to create box");
+ goto error;
+ }
+
+ elm_box_align_set(priv->list, 0.5, 0.0);
+
+ elm_object_focus_allow_set(priv->list, EINA_TRUE);
+ elm_object_focus_set(priv->list, EINA_TRUE);
+
+ viewmgr_set_view_data(VIEW_CHANNELNUMBER, priv);
+
+ inputmgr_add_callback(priv->base, 0, &key_handler, priv);
+
+ return priv->base;
+
+error:
+ _ERR("failed to create view");
+
+ if (priv->list)
+ evas_object_del(priv->list);
+ if (scroll)
+ evas_object_del(scroll);
+ if (priv->base)
+ evas_object_del(priv->base);
+
+ free(priv);
+
+ return NULL;
+}
+
+static void _show(void *view_data)
+{
+ struct _priv *priv;
+
+ if (!view_data) {
+ _ERR("failed to get view data");
+ return;
+ }
+
+ priv = view_data;
+
+ _start_hide_timer(priv);
+
+ evas_object_show(priv->base);
+
+ viewmgr_hide_view(VIEW_CHANNELINFO);
+}
+
+static void _hide(void *view_data)
+{
+ struct _priv *priv;
+
+ if (!view_data) {
+ _ERR("failed to get view data");
+ return;
+ }
+
+ priv = view_data;
+
+ _stop_hide_timer(priv);
+ _number_reset(priv);
+
+ 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;
+
+ inputmgr_remove_callback(priv->base, &key_handler);
+
+ 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_TIMER) {
+ _start_hide_timer(priv);
+ } else if (type == UPDATE_TYPE_INPUT_KEY_DOWN) {
+ Evas_Event_Key_Down *ev = data;
+
+ if (!ev) {
+ _ERR("failed to get ev");
+ return;
+ }
+
+ if (_get_number(ev->keyname) != -1)
+ _number_tuning(priv, ev->keyname);
+
+ _start_hide_timer(priv);
+ } else if (type == UPDATE_TYPE_INPUT_KEY_UP) {
+ Evas_Event_Key_Up *ev = data;
+
+ if (!ev) {
+ _ERR("failed to get ev");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK) ||
+ !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
+ viewmgr_hide_view(VIEW_CHANNELNUMBER);
+ }
+ }
+}
+
+static view_class vclass = {
+ .view_id = VIEW_CHANNELNUMBER,
+ .create = _create,
+ .show = _show,
+ .hide = _hide,
+ .destroy = _destroy,
+ .update = _update
+};
+
+view_class *view_channelnumber_get_vclass(void)
+{
+ return &vclass;
+}