Fixed the thumbnail to have its unique background color 73/44973/2
authorHyojung Jo <hj903.jo@samsung.com>
Thu, 30 Jul 2015 07:47:24 +0000 (16:47 +0900)
committerHyojung Jo <hj903.jo@samsung.com>
Thu, 30 Jul 2015 08:37:33 +0000 (17:37 +0900)
Change-Id: I56a0b171d9da65ed8d6927fd2abdeb37c66f408f
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
include/data/app.h
src/data/app.c
src/grid/grid_myapps.c

index 0ef2b15..ddae320 100644 (file)
@@ -25,6 +25,10 @@ Eina_List *get_app_list(void);
 char *get_app_id(struct app_data *adata);
 char *get_app_name(struct app_data *adata);
 char *get_app_icon(struct app_data *adata);
+bool get_app_icon_bg_color(struct app_data *adata,
+               int *r, int *g, int *b, int *a);
+bool get_app_text_bg_color(struct app_data *adata,
+               int *r, int *g, int *b, int *a);
 void free_app_list(Eina_List *list);
 
 #endif /* __AIR_APPS_APP_H__ */
index cc65a3e..559ab19 100644 (file)
 #include "define.h"
 #include "data/app.h"
 
+/* It is temporarily used. */
+#define COUNT_COLOR 7
+
+struct color {
+       int r;
+       int g;
+       int b;
+       int a;
+};
+
+static struct color color_icon[] = {
+       {104, 99, 93, 255},
+       {73, 155, 173, 255},
+       {92, 122, 190, 255},
+       {97, 109, 124, 255},
+       {219, 162, 96, 255},
+       {79, 187, 165, 255},
+       {169, 54, 54, 255},
+       {255, 255, 255, 255}
+};
+
+static struct color color_text[] =
+{
+       {93, 88, 82, 255},
+       {55, 143, 162, 255},
+       {75, 102, 163, 255},
+       {86, 98, 113, 255},
+       {194, 133, 62, 255},
+       {47, 175, 149, 255},
+       {155, 46, 46, 255},
+       {255, 255, 255, 255}
+};
+
+
 struct app_data {
        char *appid;
        char *name;
        char *icon;
        bool is_locked;
        bool is_favorite;
+       struct color icon_bg;
+       struct color text_bg;
 };
 
+static int _get_color_index(const char *str)
+{
+       int i, value = 0;
+
+       if (!str)
+               return 0;
+
+       for (i = 0; i < strlen(str); i++)
+               value += *str;
+
+       return value % COUNT_COLOR;
+}
+
 static int _get_app_data_foreach(pkgmgrinfo_appinfo_h handle, void *data)
 {
        Eina_List **list;
        struct app_data *adata;
        char *appid, *name, *icon;
        bool is_favorite, nodisplay;
-       int r;
+       int r, idx;
 
        if (!data)
                return -1;
@@ -77,6 +126,15 @@ static int _get_app_data_foreach(pkgmgrinfo_appinfo_h handle, void *data)
 
        adata->is_favorite = is_favorite;
 
+       /* FIXME: The color will be changed to 'algorithm color' */
+       if (!strcmp(appid, STR_BROWSER_ID))
+               idx = COUNT_COLOR;
+       else
+               idx = _get_color_index(name);
+
+       adata->icon_bg = color_icon[idx];
+       adata->text_bg = color_text[idx];
+
        /* Browser should be displayed first according to GUI guide */
        if (!strcmp(appid, STR_BROWSER_ID))
                *list = eina_list_prepend(*list, adata);
@@ -126,6 +184,38 @@ char *get_app_icon(struct app_data *adata)
        return adata->icon;
 }
 
+bool get_app_icon_bg_color(struct app_data *adata,
+               int *r, int *g, int *b, int *a)
+{
+       if (!adata) {
+               _ERR("Invalid argument.");
+               return false;
+       }
+
+       *r = adata->icon_bg.r;
+       *g = adata->icon_bg.g;
+       *b = adata->icon_bg.b;
+       *a = adata->icon_bg.a;
+
+       return true;
+}
+
+bool get_app_text_bg_color(struct app_data *adata,
+               int *r, int *g, int *b, int *a)
+{
+       if (!adata) {
+               _ERR("Invalid argument.");
+               return false;
+       }
+
+       *r = adata->text_bg.r;
+       *g = adata->text_bg.g;
+       *b = adata->text_bg.b;
+       *a = adata->text_bg.a;
+
+       return true;
+}
+
 void free_app_list(Eina_List *list)
 {
        struct app_data *adata;
index 9bfff97..61b268e 100644 (file)
 #include "define.h"
 #include "data/app.h"
 
-/* It is temporarily used. */
-#define COUNT_COLOR 7
-
-struct color {
-       int r;
-       int g;
-       int b;
-       int a;
-};
-
-static struct color color_icon[] = {
-       {84, 79, 73, 255},
-       {92, 122, 190, 255},
-       {73, 155, 173, 255},
-       {79, 187, 165, 255},
-       {97, 109, 124, 255},
-       {169, 54, 54, 255},
-       {206, 118, 70, 255},
-       {255, 255, 255, 255}
-};
-
-static struct color color_text[] =
-{
-       {73, 68, 62, 255},
-       {75, 102, 163, 255},
-       {55, 143, 162, 255},
-       {47, 175, 149, 255},
-       {86, 98, 113, 255},
-       {155, 46, 46, 255},
-       {200, 99, 45, 255},
-       {255, 255, 255, 255}
-};
-
 static char *_text_get(void *data, Evas_Object *obj, const char *part)
 {
        struct app_data *adata;
@@ -79,7 +46,7 @@ static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part)
        struct app_data *adata;
        Evas_Object *img, *ly, *icon_bg, *text_bg;
        char *icon, *img_path;
-       int idx, w, h;
+       int w, h, r, g, b, a;
 
        if (!data || !obj) {
                _ERR("Invalid argument.");
@@ -136,19 +103,21 @@ static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part)
                        return NULL;;
                }
 
-               /* FIXME: The color will be changed as GUI later. */
-               if (!strcmp(get_app_id(adata), STR_BROWSER_ID))
-                       idx = COUNT_COLOR;
-               else
-                       idx = rand() % (COUNT_COLOR - 1);
+               if (!get_app_icon_bg_color(adata, &r, &g, &b, &a)) {
+                       _ERR("Get color failed.");
+                       evas_object_del(ly);
+                       return NULL;
+               }
+
+               evas_object_color_set(icon_bg, r, g, b, a);
 
-               evas_object_color_set(icon_bg,
-                               color_icon[idx].r, color_icon[idx].g,
-                               color_icon[idx].b, color_icon[idx].a);
+               if (!get_app_text_bg_color(adata, &r, &g, &b, &a)) {
+                       _ERR("Get color failed.");
+                       evas_object_del(ly);
+                       return NULL;
+               }
 
-               evas_object_color_set(text_bg,
-                               color_text[idx].r, color_text[idx].g,
-                               color_text[idx].b, color_text[idx].a);
+               evas_object_color_set(text_bg, r, g, b, a);
 
                elm_object_part_content_set(ly, PART_THUMB_ICON_BG, icon_bg);
                elm_object_part_content_set(ly, PART_THUMB_TEXT_BG, text_bg);