summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-08-26 11:36:10 +0900
committerJehun Lim <jehun.lim@samsung.com>2015-08-26 16:31:46 +0900
commit596d2e1a64ac037c78387b9778dca83685bfe083 (patch)
tree6f39b22e554f736e674bfeac65d98b7d805e68ac
parent9b868fbc021126fb22001f1fe3ac98c7b02d103b (diff)
downloadair_mediahub-596d2e1a64ac037c78387b9778dca83685bfe083.tar.gz
air_mediahub-596d2e1a64ac037c78387b9778dca83685bfe083.tar.bz2
air_mediahub-596d2e1a64ac037c78387b9778dca83685bfe083.zip
base: add notify to inform of updating favorite value
Change-Id: Ie2618c02913ccf5b52bdf5d570c90ca152b2b592 Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--include/util/util.h2
-rw-r--r--include/view.h2
-rw-r--r--include/view/base.h1
-rw-r--r--res/edc/mediahub-theme.edc1
-rw-r--r--res/edc/widgets/notify.edc160
-rw-r--r--src/util/util.c42
-rw-r--r--src/view/action_menu.c26
-rw-r--r--src/view/base.c54
8 files changed, 282 insertions, 6 deletions
diff --git a/include/util/util.h b/include/util/util.h
index dfc2d53..17bf998 100644
--- a/include/util/util.h
+++ b/include/util/util.h
@@ -26,6 +26,8 @@ Evas_Object *util_add_gengrid(Evas_Object *base, int item_size_x,
int item_size_y, Eina_Bool horizontal);
Evas_Object *util_add_genlist(Evas_Object *base);
Evas_Object *util_add_image(Evas_Object *base, const char *file);
+Evas_Object *util_add_notify(Evas_Object *base, const char *notify_style,
+ const char *label_style, const char *text, double time);
Evas_Object *util_add_scroller(Evas_Object *base);
Evas_Object *util_add_table(Evas_Object *base, int padding_x, int padding_y);
diff --git a/include/view.h b/include/view.h
index 01e6765..755c6e8 100644
--- a/include/view.h
+++ b/include/view.h
@@ -46,6 +46,8 @@ enum update_type {
UPDATE_FAVORITE,
UPDATE_RECENT,
UPDATE_FOCUS_STATE,
+ UPDATE_TOAST_SHOW,
+ UPDATE_TOAST_HIDE,
};
#endif /* __AIR_MEDIAHUB_VIEW_H__ */
diff --git a/include/view/base.h b/include/view/base.h
index d30855c..03fa4e7 100644
--- a/include/view/base.h
+++ b/include/view/base.h
@@ -44,5 +44,6 @@
#define STYLE_BTN_MENU "base_btn_menu"
#define STYLE_BTN_INDEX "base_btn_index"
#define STYLE_BASE_PROGRESS "base_recent_progress"
+#define STYLE_TOAST_FAVORITE "base_toast_favorite"
#endif /* __AIR_MEDIAHUB_VIEW_BASE_H__ */
diff --git a/res/edc/mediahub-theme.edc b/res/edc/mediahub-theme.edc
index f1981b6..e74c2b6 100644
--- a/res/edc/mediahub-theme.edc
+++ b/res/edc/mediahub-theme.edc
@@ -20,5 +20,6 @@ collections {
#include "widgets/button.edc"
#include "widgets/gengrid.edc"
#include "widgets/genlist.edc"
+ #include "widgets/notify.edc"
#include "widgets/slider.edc"
}
diff --git a/res/edc/widgets/notify.edc b/res/edc/widgets/notify.edc
new file mode 100644
index 0000000..20bf305
--- /dev/null
+++ b/res/edc/widgets/notify.edc
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ */
+
+group {
+ name: "elm/notify/bottom_left/base_toast_favorite";
+ parts {
+ part {
+ name: "padding.bottom.left";
+ type: SPACER;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1.relative: 0.0 1.0;
+ rel2.relative: 0.0 1.0;
+ min: 40 40;
+ align: 0.0 1.0;
+ fixed: 1 1;
+ }
+ }
+ part {
+ name: "base";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "padding.bottom.left";
+ relative: 1.0 0.0;
+ }
+ rel2 {
+ to: "padding.bottom.left";
+ relative: 1.0 0.0;
+ }
+ min: 536 70;
+ align: 0.0 1.0;
+ color: COLOR_ITEM_BG;
+ fixed: 1 1;
+ }
+ }
+ part {
+ name: "border_top";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1.to: "base";
+ rel2 {
+ to: "base";
+ relative: 1.0 0.0;
+ }
+ min: 0 1;
+ align: 0.5 0.0;
+ color: COLOR_ITEM_BORDER;
+ fixed: 0 1;
+ }
+ }
+ part {
+ name: "border_left";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "border_top";
+ relative: 0.0 1.0;
+ }
+ rel2 {
+ to: "base";
+ relative: 0.0 1.0;
+ }
+ min: 1 0;
+ align: 0.0 0.5;
+ color: COLOR_ITEM_BORDER;
+ fixed: 1 0;
+ }
+ }
+ part {
+ name: "border_right";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "border_top";
+ relative: 1.0 1.0;
+ }
+ rel2 {
+ to: "base";
+ relative: 1.0 1.0;
+ }
+ min: 1 0;
+ align: 1.0 0.5;
+ color: COLOR_ITEM_BORDER;
+ fixed: 1 0;
+ }
+ }
+ part {
+ name: "border_bottom";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 {
+ to: "border_left";
+ relative: 1.0 1.0;
+ }
+ rel2 {
+ to: "border_right";
+ relative: 0.0 1.0;
+ }
+ min: 0 1;
+ align: 0.5 1.0;
+ color: COLOR_ITEM_BORDER;
+ fixed: 0 1;
+ }
+ }
+ part {
+ name: "elm.swallow.content";
+ type: SWALLOW;
+ description {
+ state: "default" 0.0;
+ rel1.to: "base";
+ rel2.to: "base";
+ }
+ }
+ }
+}
+
+group {
+ name: "elm/label/base/base_toast_favorite";
+ parts {
+ part {
+ name: "elm.text";
+ type: TEXT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ text {
+ font: FONT_LIGHT;
+ size: 28;
+ align: 0.5 0.5;
+ }
+ color: COLOR_TEXT_TITLE;
+ }
+ }
+ }
+}
diff --git a/src/util/util.c b/src/util/util.c
index d5c5356..d7b0e06 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -129,6 +129,48 @@ Evas_Object *util_add_image(Evas_Object *base, const char *file)
return image;
}
+Evas_Object *util_add_notify(Evas_Object *base, const char *notify_style,
+ const char *label_style, const char *text, double time)
+{
+ Evas_Object *notify, *label;
+
+ if (!base)
+ return NULL;
+
+ notify = elm_notify_add(base);
+ if (!notify) {
+ _ERR("failed to create notify object");
+ return NULL;
+ }
+
+ if (notify_style)
+ elm_object_style_set(notify, notify_style);
+
+ evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_notify_align_set(notify, 0.0, 1.0);
+ elm_notify_timeout_set(notify, time);
+
+ label = elm_label_add(notify);
+ if (!label) {
+ _ERR("failed to create label object");
+ evas_object_del(notify);
+ return NULL;
+ }
+
+ if (label_style)
+ elm_object_style_set(label, label_style);
+
+ elm_object_content_set(notify, label);
+
+ if (text)
+ elm_object_text_set(label, text);
+
+ evas_object_show(notify);
+
+ return notify;
+}
+
Evas_Object *util_add_scroller(Evas_Object *base)
{
Evas_Object *scr;
diff --git a/src/view/action_menu.c b/src/view/action_menu.c
index 1946ed3..4cfd499 100644
--- a/src/view/action_menu.c
+++ b/src/view/action_menu.c
@@ -180,6 +180,7 @@ static bool _livetv_clicked(struct _priv *priv)
static bool _favorite_clicked(struct _priv *priv, Evas_Object *obj)
{
app_media_info *mi;
+ struct view_update_data vdata;
int r;
bool favorite;
@@ -192,34 +193,45 @@ static bool _favorite_clicked(struct _priv *priv, Evas_Object *obj)
mi = app_media_get_info(priv->am);
if (!mi) {
_ERR("failed to get app media info");
- media_content_disconnect();
- return false;
+ goto err;
}
r = app_contents_favorite_check(CONTENTS_MEDIA,
mi->media_id, &favorite);
if (r != APP_CONTENTS_ERROR_NONE) {
_ERR("failed to check favorite");
- media_content_disconnect();
- return false;
+ goto err;
}
r = app_contents_favorite_set(CONTENTS_MEDIA,
mi->media_id, !favorite);
if (r != APP_CONTENTS_ERROR_NONE) {
_ERR("failed to set favorite");
- media_content_disconnect();
- return false;
+ goto err;
}
app_media_update(priv->am);
+ mi = app_media_get_info(priv->am);
+ if (!mi) {
+ _ERR("failed to get app media info");
+ goto err;
+ }
+
+ vdata.id = mi->media_id;
+
viewmgr_update_view(VIEW_BASE, UPDATE_CONTENT_ITEM, NULL);
+ viewmgr_update_view(VIEW_BASE, UPDATE_TOAST_SHOW, &vdata);
+
viewmgr_hide_view(VIEW_ACTION_MENU);
media_content_disconnect();
return true;
+
+err:
+ media_content_disconnect();
+ return false;
}
static bool _delete_clicked(struct _priv *priv, Evas_Object *obj)
@@ -872,6 +884,8 @@ static void _show(void *view_data)
evas_object_show(priv->base);
+ viewmgr_update_view(VIEW_BASE, UPDATE_TOAST_HIDE, NULL);
+
elm_object_focus_set(priv->tv_btn, EINA_TRUE);
}
diff --git a/src/view/base.c b/src/view/base.c
index 6ec6a6e..4db00f3 100644
--- a/src/view/base.c
+++ b/src/view/base.c
@@ -28,13 +28,19 @@
#include "define.h"
#include "layout.h"
#include "view.h"
+#include "util/util.h"
#define TITLE_TEXT "Media Hub"
+#define TEXT_FAVORITE_ADDED "Added to your favorite."
+#define TEXT_FAVORITE_REMOVED "Removed from your favorite."
+
#define VIDEO_COPYRIGHT "Unknown"
#define BOX_PADDING_SIZE 80
+#define TIME_TOAST_FAVORITE 5.0
+
enum _layout_type {
E_LAYOUT_MOVIE = 0,
E_LAYOUT_GALLERY,
@@ -46,6 +52,8 @@ struct _priv {
Evas_Object *win;
Evas_Object *base;
Evas_Object *btn[E_LAYOUT_MAX];
+ Evas_Object *notify;
+
Evas_Object *focused_btn;
layoutmgr *lmgr;
@@ -473,6 +481,41 @@ static bool _draw_items(struct _priv *priv)
return true;
}
+static void _hide_toast_favorite(struct _priv *priv)
+{
+ if (priv->notify)
+ evas_object_hide(priv->notify);
+}
+
+static void _show_toast_favorite(struct _priv *priv, const char *id)
+{
+ Evas_Object *notify;
+ int r;
+ bool favorite;
+
+ r = app_contents_favorite_check(CONTENTS_MEDIA, id, &favorite);
+ if (r != APP_CONTENTS_ERROR_NONE) {
+ _ERR("failed to check favorite");
+ return;
+ }
+
+ if (favorite)
+ notify = util_add_notify(priv->base, STYLE_TOAST_FAVORITE,
+ STYLE_TOAST_FAVORITE, TEXT_FAVORITE_ADDED,
+ TIME_TOAST_FAVORITE);
+ else
+ notify = util_add_notify(priv->base, STYLE_TOAST_FAVORITE,
+ STYLE_TOAST_FAVORITE, TEXT_FAVORITE_REMOVED,
+ TIME_TOAST_FAVORITE);
+
+ if (!notify) {
+ _ERR("failed to add notify object");
+ return;
+ }
+
+ priv->notify = notify;
+}
+
static Evas_Object *_create(Evas_Object *win, void *data)
{
struct _priv *priv;
@@ -601,6 +644,17 @@ static void _update(void *view_data, int update_type, void *data)
g_menu_item[priv->current_layout].layout_id,
update_type, NULL);
break;
+ case UPDATE_TOAST_SHOW:
+ if (!data)
+ goto err;
+
+ vdata = data;
+
+ _show_toast_favorite(priv, vdata->id);
+ break;
+ case UPDATE_TOAST_HIDE:
+ _hide_toast_favorite(priv);
+ break;
case UPDATE_FAVORITE:
if (!data)
goto err;