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__ */
#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;
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);
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;
#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;
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.");
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);