Update action menu 94/47394/1 accepted/tizen/tv/20150903.111009 submit/tizen/20150903.102204
authorjinwoo.shin <jw0227.shin@samsung.com>
Thu, 3 Sep 2015 05:16:07 +0000 (14:16 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Thu, 3 Sep 2015 05:16:07 +0000 (14:16 +0900)
Change-Id: I12d012f4d832fdc37fd27f2d22aa5886cf6e8d3c
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
15 files changed:
include/define.h
include/strings.h
res/images/btn_menu_add_ch_dis.png [new file with mode: 0644]
res/images/btn_menu_add_ch_foc.png [new file with mode: 0644]
res/images/btn_menu_add_ch_nor.png [new file with mode: 0644]
res/images/btn_menu_add_ch_sel.png [new file with mode: 0644]
res/images/btn_menu_add_remove_ch_dis.png [new file with mode: 0644]
res/images/btn_menu_add_remove_ch_foc.png [new file with mode: 0644]
res/images/btn_menu_add_remove_ch_nor.png [new file with mode: 0644]
res/images/btn_menu_add_remove_ch_sel.png [new file with mode: 0644]
res/images/btn_menu_remove_favorite_dis.png [new file with mode: 0644]
res/images/btn_menu_remove_favorite_foc.png [new file with mode: 0644]
res/images/btn_menu_remove_favorite_nor.png [new file with mode: 0644]
res/images/btn_menu_remove_favorite_sel.png [new file with mode: 0644]
src/view_action_menu.c

index 6e6279a..4ff5bfd 100644 (file)
 #define IMAGE_FAV_FOC IMAGEDIR"/btn_menu_favorite_foc.png"
 #define IMAGE_FAV_SEL IMAGEDIR"/btn_menu_favorite_sel.png"
 #define IMAGE_FAV_DIS IMAGEDIR"/btn_menu_favorite_dis.png"
+#define IMAGE_UNFAV_NOR IMAGEDIR"/btn_menu_remove_favorite_nor.png"
+#define IMAGE_UNFAV_FOC IMAGEDIR"/btn_menu_remove_favorite_foc.png"
+#define IMAGE_UNFAV_SEL IMAGEDIR"/btn_menu_remove_favorite_sel.png"
+#define IMAGE_UNFAV_DIS IMAGEDIR"/btn_menu_remove_favorite_dis.png"
 #define IMAGE_LOCK_NOR IMAGEDIR"/btn_menu_lock_nor.png"
 #define IMAGE_LOCK_FOC IMAGEDIR"/btn_menu_lock_foc.png"
 #define IMAGE_LOCK_SEL IMAGEDIR"/btn_menu_lock_sel.png"
 #define IMAGE_UNLOCK_FOC IMAGEDIR"/btn_menu_unlock_foc.png"
 #define IMAGE_UNLOCK_SEL IMAGEDIR"/btn_menu_unlock_sel.png"
 #define IMAGE_UNLOCK_DIS IMAGEDIR"/btn_menu_unlock_dis.png"
+#define IMAGE_ADD_CH_NOR IMAGEDIR"/btn_menu_add_ch_nor.png"
+#define IMAGE_ADD_CH_FOC IMAGEDIR"/btn_menu_add_ch_foc.png"
+#define IMAGE_ADD_CH_SEL IMAGEDIR"/btn_menu_add_ch_sel.png"
+#define IMAGE_ADD_CH_DIS IMAGEDIR"/btn_menu_add_ch_dis.png"
+#define IMAGE_REMOVE_CH_NOR IMAGEDIR"/btn_menu_add_remove_ch_nor.png"
+#define IMAGE_REMOVE_CH_FOC IMAGEDIR"/btn_menu_add_remove_ch_foc.png"
+#define IMAGE_REMOVE_CH_SEL IMAGEDIR"/btn_menu_add_remove_ch_sel.png"
+#define IMAGE_REMOVE_CH_DIS IMAGEDIR"/btn_menu_add_remove_ch_dis.png"
 #define IMAGE_FAVORITE_DEFAULT IMAGEDIR"/ic_default_tv.png"
 
 #define VIEW_CHANNELINFO "VIEW_CHANNELINFO"
index a1dfb08..d21f511 100644 (file)
@@ -28,6 +28,8 @@
 #define STR_BUTTON_FAVORITE "Favorite"
 #define STR_BUTTON_LOCK "Lock"
 #define STR_BUTTON_UNLOCK "Unlock"
+#define STR_BUTTON_ADD_CHANNEL "Channel"
+#define STR_BUTTON_REMOVE_CHANNEL "Channel"
 #define STR_NOFAVORITE "No favorite channels"
 #define STR_FAVORITE_TOAST "Added to your favorite."
 #define STR_UNFAVORITE_TOAST "Removed from your favorite."
diff --git a/res/images/btn_menu_add_ch_dis.png b/res/images/btn_menu_add_ch_dis.png
new file mode 100644 (file)
index 0000000..d2f2052
Binary files /dev/null and b/res/images/btn_menu_add_ch_dis.png differ
diff --git a/res/images/btn_menu_add_ch_foc.png b/res/images/btn_menu_add_ch_foc.png
new file mode 100644 (file)
index 0000000..9f59e84
Binary files /dev/null and b/res/images/btn_menu_add_ch_foc.png differ
diff --git a/res/images/btn_menu_add_ch_nor.png b/res/images/btn_menu_add_ch_nor.png
new file mode 100644 (file)
index 0000000..3e3e14b
Binary files /dev/null and b/res/images/btn_menu_add_ch_nor.png differ
diff --git a/res/images/btn_menu_add_ch_sel.png b/res/images/btn_menu_add_ch_sel.png
new file mode 100644 (file)
index 0000000..cdea71b
Binary files /dev/null and b/res/images/btn_menu_add_ch_sel.png differ
diff --git a/res/images/btn_menu_add_remove_ch_dis.png b/res/images/btn_menu_add_remove_ch_dis.png
new file mode 100644 (file)
index 0000000..b095ef7
Binary files /dev/null and b/res/images/btn_menu_add_remove_ch_dis.png differ
diff --git a/res/images/btn_menu_add_remove_ch_foc.png b/res/images/btn_menu_add_remove_ch_foc.png
new file mode 100644 (file)
index 0000000..a61de3a
Binary files /dev/null and b/res/images/btn_menu_add_remove_ch_foc.png differ
diff --git a/res/images/btn_menu_add_remove_ch_nor.png b/res/images/btn_menu_add_remove_ch_nor.png
new file mode 100644 (file)
index 0000000..ec4c147
Binary files /dev/null and b/res/images/btn_menu_add_remove_ch_nor.png differ
diff --git a/res/images/btn_menu_add_remove_ch_sel.png b/res/images/btn_menu_add_remove_ch_sel.png
new file mode 100644 (file)
index 0000000..593a830
Binary files /dev/null and b/res/images/btn_menu_add_remove_ch_sel.png differ
diff --git a/res/images/btn_menu_remove_favorite_dis.png b/res/images/btn_menu_remove_favorite_dis.png
new file mode 100644 (file)
index 0000000..a85e31f
Binary files /dev/null and b/res/images/btn_menu_remove_favorite_dis.png differ
diff --git a/res/images/btn_menu_remove_favorite_foc.png b/res/images/btn_menu_remove_favorite_foc.png
new file mode 100644 (file)
index 0000000..086e864
Binary files /dev/null and b/res/images/btn_menu_remove_favorite_foc.png differ
diff --git a/res/images/btn_menu_remove_favorite_nor.png b/res/images/btn_menu_remove_favorite_nor.png
new file mode 100644 (file)
index 0000000..fd4a972
Binary files /dev/null and b/res/images/btn_menu_remove_favorite_nor.png differ
diff --git a/res/images/btn_menu_remove_favorite_sel.png b/res/images/btn_menu_remove_favorite_sel.png
new file mode 100644 (file)
index 0000000..7a56a9f
Binary files /dev/null and b/res/images/btn_menu_remove_favorite_sel.png differ
index 4f36cf0..a73131b 100644 (file)
@@ -41,6 +41,7 @@ enum _button_id {
        BUTTON_LIVETV,
        BUTTON_FAV,
        BUTTON_LOCK,
+       BUTTON_CHANNEL,
 };
 
 enum _button_state {
@@ -138,8 +139,61 @@ static int _lock_state(void)
        return r;
 }
 
+static void _channel_clicked(void)
+{
+       const struct tv_channel_info *channel_info;
+       int r;
+
+       channel_info = tv_channel_get_info();
+       if (!channel_info) {
+               _ERR("failed to get channel info");
+               return;
+       }
+
+       if (channel_info->remembered)
+               r = tv_channel_del_channel(channel_info->service_id);
+       else
+               r = tv_channel_add_channel(channel_info->service_id);
+
+       if (r < 0)
+               _ERR("failed to set channel");
+       else {
+               if (channel_info->remembered)
+                       viewmgr_update_view(VIEW_ACTION_MENU,
+                                       UPDATE_TYPE_SHOW_TOAST,
+                                       STR_REMOVE_CHANNEL_TOAST);
+               else
+                       viewmgr_update_view(VIEW_ACTION_MENU,
+                                       UPDATE_TYPE_SHOW_TOAST,
+                                       STR_ADD_CHANNEL_TOAST);
+       }
+
+       tv_channel_del_info(channel_info);
+
+       viewmgr_hide_view(VIEW_ACTION_MENU);
+}
+
+static int _channel_state(void)
+{
+       const struct tv_channel_info *channel_info;
+       int r;
+
+       channel_info = tv_channel_get_info();
+       if (!channel_info) {
+               _ERR("failed to get channel info");
+               return STATE_INVALID;
+       }
+
+       r = channel_info->remembered ? STATE_TOGGLE : STATE_UNTOGGLE;
+
+       tv_channel_del_info(channel_info);
+
+       return r;
+}
+
 struct _button {
        int id;
+       const char *style;
        struct _button_data data[2];
 
        void (*clicked)(void);
@@ -149,12 +203,13 @@ struct _button {
 static struct _button buttons[] = {
        {
                .id = BUTTON_FAV,
+               .style = STYLE_ACTION_MENU_BTN,
                .data[UNTOGGLE] = {
                        .text = STR_BUTTON_FAVORITE,
-                       .normal = IMAGE_FAV_NOR,
-                       .focused = IMAGE_FAV_FOC,
-                       .selected = IMAGE_FAV_SEL,
-                       .disabled = IMAGE_FAV_DIS
+                       .normal = IMAGE_UNFAV_NOR,
+                       .focused = IMAGE_UNFAV_FOC,
+                       .selected = IMAGE_UNFAV_SEL,
+                       .disabled = IMAGE_UNFAV_DIS
                },
                .data[TOGGLE] = {
                        .text = STR_BUTTON_FAVORITE,
@@ -168,24 +223,45 @@ static struct _button buttons[] = {
        },
        {
                .id = BUTTON_LOCK,
+               .style = STYLE_ACTION_MENU_BTN,
                .data[UNTOGGLE] = {
                        .text = STR_BUTTON_LOCK,
-                       .normal = IMAGE_LOCK_NOR,
-                       .focused = IMAGE_LOCK_FOC,
-                       .selected = IMAGE_LOCK_SEL,
-                       .disabled = IMAGE_LOCK_DIS
-               },
-               .data[TOGGLE] = {
-                       .text = STR_BUTTON_UNLOCK,
                        .normal = IMAGE_UNLOCK_NOR,
                        .focused = IMAGE_UNLOCK_FOC,
                        .selected = IMAGE_UNLOCK_SEL,
                        .disabled = IMAGE_UNLOCK_DIS
                },
+               .data[TOGGLE] = {
+                       .text = STR_BUTTON_UNLOCK,
+                       .normal = IMAGE_LOCK_NOR,
+                       .focused = IMAGE_LOCK_FOC,
+                       .selected = IMAGE_LOCK_SEL,
+                       .disabled = IMAGE_LOCK_DIS
+               },
                .clicked = _lock_clicked,
                .state = _lock_state
        },
        {
+               .id = BUTTON_CHANNEL,
+               .style = STYLE_ACTION_MENU_BTN,
+               .data[UNTOGGLE] = {
+                       .text = STR_BUTTON_ADD_CHANNEL,
+                       .normal = IMAGE_REMOVE_CH_NOR,
+                       .focused = IMAGE_REMOVE_CH_FOC,
+                       .selected = IMAGE_REMOVE_CH_SEL,
+                       .disabled = IMAGE_REMOVE_CH_DIS
+               },
+               .data[TOGGLE] = {
+                       .text = STR_BUTTON_REMOVE_CHANNEL,
+                       .normal = IMAGE_ADD_CH_NOR,
+                       .focused = IMAGE_ADD_CH_FOC,
+                       .selected = IMAGE_ADD_CH_SEL,
+                       .disabled = IMAGE_ADD_CH_DIS
+               },
+               .clicked = _channel_clicked,
+               .state = _channel_state
+       },
+       {
                .id = BUTTON_INVALID
        }
 };
@@ -355,6 +431,17 @@ static void _update_favorite(struct _priv *priv)
        tv_channel_del_list(channel_list);
 }
 
+static void _update_menu(struct _priv *priv)
+{
+       int i;
+
+       i = 0;
+       while (buttons[i].id != BUTTON_INVALID && i < BUTTON_MAX) {
+               _update_button_state(priv->menu_btn[i], &buttons[i]);
+               i++;
+       }
+}
+
 static bool _draw_channel_info(struct _priv *priv)
 {
        Evas_Object *layout;
@@ -406,7 +493,7 @@ static bool _draw_menu_area(struct _priv *priv)
        while (buttons[i].id != BUTTON_INVALID && i < BUTTON_MAX) {
                btn = util_add_button(priv->base, NULL,
                                buttons[i].data[UNTOGGLE].text,
-                               STYLE_ACTION_MENU_BTN);
+                               buttons[i].style);
                if (!btn) {
                        _ERR("Add button failed.");
                        evas_object_del(table);
@@ -434,8 +521,6 @@ static bool _draw_menu_area(struct _priv *priv)
                inputmgr_add_callback(btn, buttons[i].id,
                                &button_handler, &buttons[i]);
 
-               _update_button_state(btn, &buttons[i]);
-
                col = i % ITEMS_IN_ROW;
                row = i / ITEMS_IN_ROW;
                elm_table_pack(table, btn, col, row, 1, 1);
@@ -565,6 +650,7 @@ static void _show(void *data)
        priv = data;
 
        _update_channel_info(priv);
+       _update_menu(priv);
        _update_favorite(priv);
 
        evas_object_show(priv->base);