From: Hyojung Jo Date: Mon, 31 Aug 2015 06:45:07 +0000 (+0900) Subject: View: Draw toast when contents is set to unfavorite X-Git-Tag: accepted/tizen/tv/20150902.055618~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd70b5ac9d5a208353c263fa532aa08c939eaf60;p=profile%2Ftv%2Fapps%2Fnative%2Fair_favorite.git View: Draw toast when contents is set to unfavorite Change-Id: I65416c18d1b715ca31eddb27cb56fa7db1cb3d6b Signed-off-by: Hyojung Jo --- diff --git a/include/define.h b/include/define.h index b0a87c9..449c5b2 100644 --- a/include/define.h +++ b/include/define.h @@ -18,8 +18,8 @@ #define __AIR_FAVORITE_DEFINE_H__ /* View ID */ -#define VIEW_ID_BASE "VIEW_ID_BASE" -#define VIEW_ID_ACTION_MENU "VIEW_ID_ACTION_MENU" +#define VIEW_BASE "VIEW_BASE" +#define VIEW_ACTION_MENU "VIEW_ACTION_MENU" /* Group */ #define GRP_VIEW_BASE "grp.view.base" @@ -49,6 +49,7 @@ #define STYLE_LIVETV_BTN "style.livetv.button" #define STYLE_ACTION_MENU_FAV_BTN "style.action.menu.favorite.button" #define STYLE_ACTION_MENU_LOCK_BTN "style.action.menu.lock.button" +#define STYLE_TOAST "style.toast" /* Signal */ #define SIG_FOCUSED "focused" @@ -86,6 +87,7 @@ #define STR_CNT_WEBS "bookmark" #define STR_BROWSER "Web Browser" #define STR_LIVETV "Live TV" +#define STR_REMOVE_FAVORITE "Removed from your favorite." /* Font */ #define FONT_TIZENSANS_REGULAR "TizenSans" @@ -103,6 +105,7 @@ #define SIZE_APP_ICON_MAX 100 #define SIZE_ACTION_TABLE_BORDER 0 #define SIZE_COL_MAX 4 +#define SIZE_TOAST_TIMEOUT 5.0 /* Count */ #define COUNT_MENU 6 diff --git a/include/view.h b/include/view.h index a32afa3..159fd2e 100644 --- a/include/view.h +++ b/include/view.h @@ -23,6 +23,7 @@ view_class *view_action_menu_get_vclass(void); enum update_type { UPDATE_DATA = 0, UPDATE_GRID, + UPDATE_SHOW_TOAST, }; #endif /* __AIR_APPS_VIEW_H__ */ diff --git a/src/main.c b/src/main.c index 5fea085..2f75d0e 100644 --- a/src/main.c +++ b/src/main.c @@ -89,8 +89,8 @@ static void _terminate(void *data) ad->win = NULL; } - viewmgr_remove_view(VIEW_ID_BASE); - viewmgr_remove_view(VIEW_ID_ACTION_MENU); + viewmgr_remove_view(VIEW_BASE); + viewmgr_remove_view(VIEW_ACTION_MENU); viewmgr_destroy(); } @@ -107,7 +107,7 @@ static void _app_control(app_control_h control, void *data) if (ad->win) elm_win_activate(ad->win); - if (!viewmgr_push_view(VIEW_ID_BASE)) + if (!viewmgr_push_view(VIEW_BASE)) _ERR("Push view failed."); } diff --git a/src/view/view_action_menu.c b/src/view/view_action_menu.c index 52d8aed..81cafdd 100644 --- a/src/view/view_action_menu.c +++ b/src/view/view_action_menu.c @@ -81,7 +81,7 @@ static void _livetv_selected(void) return; } - viewmgr_hide_view(VIEW_ID_ACTION_MENU); + viewmgr_hide_view(VIEW_ACTION_MENU); } static void _favorite_selected(struct grid_data *gdata) @@ -91,8 +91,9 @@ static void _favorite_selected(struct grid_data *gdata) return; } - viewmgr_update_view(VIEW_ID_BASE, UPDATE_GRID, gdata); - viewmgr_hide_view(VIEW_ID_ACTION_MENU); + viewmgr_update_view(VIEW_BASE, UPDATE_GRID, gdata); + viewmgr_update_view(VIEW_BASE, UPDATE_SHOW_TOAST, STR_REMOVE_FAVORITE); + viewmgr_hide_view(VIEW_ACTION_MENU); } static void _clicked_cb(int id, void *data, Evas_Object *obj) @@ -134,7 +135,7 @@ static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) - viewmgr_hide_view(VIEW_ID_ACTION_MENU); + viewmgr_hide_view(VIEW_ACTION_MENU); } static input_handler _btn_input_handler = { @@ -239,7 +240,7 @@ static Evas_Object *_create(Evas_Object *win, void *data) priv->win = win; priv->base = base; - if (!viewmgr_set_view_data(VIEW_ID_ACTION_MENU, priv)) { + if (!viewmgr_set_view_data(VIEW_ACTION_MENU, priv)) { _ERR("Set view data failed."); evas_object_del(base); free(priv); @@ -313,7 +314,7 @@ static void _destroy(void *data) } static view_class _vclass = { - .view_id = VIEW_ID_ACTION_MENU, + .view_id = VIEW_ACTION_MENU, .create = _create, .show = _show, .hide = _hide, diff --git a/src/view/view_base.c b/src/view/view_base.c index d3b04de..26cb993 100644 --- a/src/view/view_base.c +++ b/src/view/view_base.c @@ -43,6 +43,7 @@ struct _priv { Evas_Object *base; Evas_Object *box; Evas_Object *menu[COUNT_MENU]; + Evas_Object *notify; int cur_menu_id; }; @@ -331,8 +332,11 @@ static void _grid_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, if (!gdata) return; - viewmgr_update_view(VIEW_ID_ACTION_MENU, UPDATE_DATA, gdata); - viewmgr_show_view(VIEW_ID_ACTION_MENU); + if (priv->notify) + evas_object_hide(priv->notify); + + viewmgr_update_view(VIEW_ACTION_MENU, UPDATE_DATA, gdata); + viewmgr_show_view(VIEW_ACTION_MENU); } } @@ -473,7 +477,7 @@ static Evas_Object *_create(Evas_Object *win, void *data) } } - if (!viewmgr_set_view_data(VIEW_ID_BASE, priv)) { + if (!viewmgr_set_view_data(VIEW_BASE, priv)) { _ERR("Set view data failed."); gridmgr_destroy(gmgr); goto err; @@ -521,13 +525,27 @@ static void _hide(void *data) static void _update(void *view_data, int update_type, void *data) { + struct _priv *priv; + if (!view_data) { _ERR("Get data failed."); return; } + priv = view_data; - if (update_type == UPDATE_GRID) - _update_current_grid(view_data); + switch (update_type) { + case UPDATE_GRID: + _update_current_grid(priv); + break; + + case UPDATE_SHOW_TOAST: + priv->notify = utils_add_notify(priv->base, (char *)data, + STYLE_TOAST, STYLE_TOAST, SIZE_TOAST_TIMEOUT); + break; + + default: + _ERR("Unhandled update type."); + } } static void _destroy(void *data) @@ -558,7 +576,7 @@ static void _destroy(void *data) } static view_class _vclass = { - .view_id = VIEW_ID_BASE, + .view_id = VIEW_BASE, .create = _create, .show = _show, .hide = _hide,