View: Added the favorite icon when the app is favorite 38/43338/2
authorHyojung Jo <hj903.jo@samsung.com>
Wed, 8 Jul 2015 07:30:59 +0000 (16:30 +0900)
committerHyojung Jo <hj903.jo@samsung.com>
Wed, 8 Jul 2015 07:49:47 +0000 (16:49 +0900)
Change-Id: Ifeac2fa88f3f8a71cc8d7b769c158ab9ac6bf102
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
include/define.h
res/images/ic_thumbnail_favorite_01.png [new file with mode: 0644]
res/widget/gengrid.edc
src/view/view_base.c

index b6c1e36ba718787c0667a69ca3ddc5cb29e30ca4..7ee324f0852ef809247a5847ba32c99e94fd7968 100644 (file)
@@ -35,6 +35,7 @@
 #define PART_GENGRID "part.gengrid"
 #define PART_APP_COUNT "part.app.count"
 #define PART_NO_CONTENTS "part.no.contents"
+#define PART_FAVORITE_ICON "part.favorite.icon"
 
 /* Style */
 #define STYLE_MENU_BTN "style.menu.button"
@@ -47,6 +48,7 @@
 #define SIG_ITEM_FOCUSED "item_focused"
 #define SIG_ITEM_SELECTED "item_selected"
 #define SIG_SOURCE_EDC "edc"
+#define SIG_FAVORITE "favorite"
 
 /* Font */
 #define FONT_TIZENSANS_REGULAR "TizenSans"
@@ -69,4 +71,7 @@
 #define SIZE_BOX_PAD_H (40 + 40)
 #define SIZE_BOX_PAD_V 0
 
+/* Image */
+#define FAVORITE_ICON_PNG "ic_thumbnail_favorite_01.png"
+
 #endif /* __AIR_APPS_DEFINE_H__ */
diff --git a/res/images/ic_thumbnail_favorite_01.png b/res/images/ic_thumbnail_favorite_01.png
new file mode 100644 (file)
index 0000000..f60b784
Binary files /dev/null and b/res/images/ic_thumbnail_favorite_01.png differ
index ee38a06ad2ace7fcb25ff35ec74fcad0fa347d07..42b44ef0dcab3635827978277366d0b9501f7e90 100644 (file)
@@ -19,6 +19,10 @@ group {
        data.item, "focus_highlight" "on";
        data.item, "texts" "elm.text";
        data.item, "contents" "elm.swallow.icon";
+       images {
+               image, FAVORITE_ICON_PNG COMP;
+       }
+
        parts {
                part {
                        name, "padding.bottom.right";
@@ -129,6 +133,43 @@ group {
                        }
                }
 
+               part {
+                       name, "padding.favorite";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 164 12;
+                               rel2.relative, 0.0 0.0;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+
+               part {
+                       name, PART_FAVORITE_ICON;
+                       type, IMAGE;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 40 40;
+                               image.normal, FAVORITE_ICON_PNG;
+                               rel1 {
+                                       to, "padding.favorite";
+                                       relative, 1.0 1.0;
+                               }
+                               rel2.to, "padding.favorite";
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                               visible, 0;
+                       }
+                       description {
+                               state, "visible" 0.0;
+                               inherit, "default" 0.0;
+                               visible, 1;
+                       }
+               }
+
                part {
                        name, "elm.swallow.icon";
                        type, SWALLOW;
@@ -290,5 +331,13 @@ group {
                        name, "item_selected";
                        action, SIGNAL_EMIT SIG_ITEM_SELECTED SIG_SOURCE_EDC;
                }
+
+               program {
+                       name, "favorite";
+                       signal, "favorite";
+                       source, PART_FAVORITE_ICON;
+                       action, STATE_SET "visible" 0.0;
+                       target, PART_FAVORITE_ICON;
+               }
        }
 }
index e57f54662728f9e23a642fd7c86c13d8863825ac..9b5f369be40838c8b06115797349d9cde56428d3 100644 (file)
@@ -20,6 +20,7 @@
 #include <viewmgr.h>
 #include <gridmgr.h>
 #include <inputmgr.h>
+#include <app_contents.h>
 #include <app_debug.h>
 
 #include "define.h"
@@ -179,7 +180,7 @@ static void _grid_item_selected_cb(void *data, Elm_Object_Item *it,
                _ERR("Invalid argument.");
                return;
        }
-       adata = (struct app_data *)elm_object_item_data_get(it);
+       adata = elm_object_item_data_get(it);
 
        r = aul_open_app(get_app_id(adata));
        if (r == AUL_R_EINVAL) {
@@ -193,15 +194,32 @@ static void _grid_item_selected_cb(void *data, Elm_Object_Item *it,
 static void _grid_realized_cb(int id, void *data, Evas_Object *obj,
                Elm_Object_Item *item)
 {
+       struct app_data *adata;
+       bool isfavorite;
+       int r;
+
        if (!data || !item) {
                _ERR("Invalid argument.");
                return;
        }
 
+       adata = elm_object_item_data_get(item);
+
        elm_object_item_signal_callback_add(item, SIG_ITEM_FOCUSED,
                        SIG_SOURCE_EDC, _grid_item_focused_cb, data);
        elm_object_item_signal_callback_add(item, SIG_ITEM_SELECTED,
                        SIG_SOURCE_EDC, _grid_item_selected_cb, data);
+
+       r = app_contents_favorite_check(CONTENTS_APP, get_app_id(adata),
+                       &isfavorite);
+       if (r != APP_CONTENTS_ERROR_NONE) {
+               _ERR("Favorite check failed.");
+               return;
+       }
+
+       if (isfavorite)
+               elm_object_item_signal_emit(item, SIG_FAVORITE,
+                               PART_FAVORITE_ICON);
 }
 
 static void _grid_unrealized_cb(int id, void *data, Evas_Object *obj,