diff options
author | Hyojung Jo <hj903.jo@samsung.com> | 2015-02-25 21:18:08 +0900 |
---|---|---|
committer | Hyojung Jo <hj903.jo@samsung.com> | 2015-02-25 21:18:46 +0900 |
commit | 0e69827107576dd5eef7c55d9ee96f9e2f4c044f (patch) | |
tree | 4283da5d4ac570348a31f715d0e2e0be899ad929 | |
parent | 8e15a35754c394b8ec5e0e5ceb02c82eabf1ffdb (diff) | |
download | applauncher-0e69827107576dd5eef7c55d9ee96f9e2f4c044f.tar.gz applauncher-0e69827107576dd5eef7c55d9ee96f9e2f4c044f.tar.bz2 applauncher-0e69827107576dd5eef7c55d9ee96f9e2f4c044f.zip |
Modified the Related apps of Context View.
Change-Id: I6b5b288b1ae52d00680e62da080ff0394d8ede49
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
-rw-r--r-- | data/app-launcher-tv-ref.edc | 7 | ||||
-rw-r--r-- | include/ContextView.h | 4 | ||||
-rw-r--r-- | include/define.h | 2 | ||||
-rw-r--r-- | src/layout/AppsBaseLayout.cpp | 2 | ||||
-rw-r--r-- | src/view/ContextView.cpp | 192 |
5 files changed, 98 insertions, 109 deletions
diff --git a/data/app-launcher-tv-ref.edc b/data/app-launcher-tv-ref.edc index 9a02b88..80ee6f9 100644 --- a/data/app-launcher-tv-ref.edc +++ b/data/app-launcher-tv-ref.edc @@ -821,6 +821,7 @@ collections { } group { name, GRP_CTMPAGE; + data.item: "focus_highlight" "on"; images { image, CONTEXTUAL_MENU_BG_PNG COMP; image, FOCUSED_APP_BG_PNG COMP; @@ -843,7 +844,7 @@ collections { type, RECT; description { state, "default" 0.0; - color, 0 0 0 204; + color, 0 0 0 218; align, 0.0 0.0; fixed, 1 1; } @@ -872,7 +873,7 @@ collections { relative, 0.0 0.0; to, "padding_focused_app"; } - color, 28 36 49 204; + color, 28 36 49 228; fixed, 1 1; } } @@ -1324,7 +1325,7 @@ collections { description { state, "default" 0.0; min, 238 229; - color, 42 50 64 255; + color, 42 50 64 228; } description { state, "focused" 0.0; diff --git a/include/ContextView.h b/include/ContextView.h index a038c28..6a41715 100644 --- a/include/ContextView.h +++ b/include/ContextView.h @@ -18,7 +18,8 @@ #define __CONTEXT_VIEW_H__ -#include <ail.h> +#include <pkgmgr-info.h> +#include <package_manager.h> class CContextView : public CBaseView, @@ -38,6 +39,7 @@ private: static void sm_CbBaseBack(void *data, Evas_Object *obj, void *ev); static void sm_CbCtgrBtnBack(void *data, Evas_Object *obj, void *ev); static void sm_CbPopupBack(void *data, Evas_Object *obj, void *ev); + static int sm_CbAppList(pkgmgrinfo_appinfo_h handle, void *data); private: void m_ContextButtonSelected(Evas_Object *obj); diff --git a/include/define.h b/include/define.h index 3a830bc..ad90c89 100644 --- a/include/define.h +++ b/include/define.h @@ -21,7 +21,7 @@ #define KEY_DOWN "Down" #define KEY_LEFT "Left" #define KEY_RIGHT "Right" -#define KEY_ENTER "Enter" +#define KEY_ENTER "Return" #define KEY_MENU "Super_L" #define KEY_BACK "Escape" diff --git a/src/layout/AppsBaseLayout.cpp b/src/layout/AppsBaseLayout.cpp index 149be7a..98e3f7d 100644 --- a/src/layout/AppsBaseLayout.cpp +++ b/src/layout/AppsBaseLayout.cpp @@ -108,7 +108,7 @@ void CAppsBaseLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Ke return; } else if (!strcmp(ev->keyname, KEY_BACK)) { action = E_FOCUS_MENU; - m->vmgr->UpdateView((const char *)APPS_BASE_VIEW,(void *)&action); + m->vmgr->UpdateView((const char *)APPS_BASE_VIEW, (void *)&action); return; } else if (!strcmp(ev->keyname, KEY_LEFT) && ainfo->CoordY() == 0) { action = E_FOCUS_MENU; diff --git a/src/view/ContextView.cpp b/src/view/ContextView.cpp index 53fa491..5d7e179 100644 --- a/src/view/ContextView.cpp +++ b/src/view/ContextView.cpp @@ -70,21 +70,24 @@ struct SContextView { char *app_thumbland; int max_x; int max_y; + int cur_x; + int cur_y; + int idx[CTXT_MENU_BTN_SIZE]; CViewMgr *vmgr; }; void CContextView::m_ContextButtonSelected(Evas_Object *obj) { - enum ctxt_menu_type type; + ctxt_menu_type *type; if (!obj) { _ERR("Invalid argument."); return; } - type = *(enum ctxt_menu_type *)_GET_PRIV(obj); + type = (ctxt_menu_type *)_GET_PRIV(obj); - switch (type) { + switch (*type) { case CTXT_MENU_FAVORITE: m_FavoriteSelected(obj); break; @@ -163,7 +166,7 @@ void CContextView::OnMouseClicked(int id, Evas_Object *obj) void CContextView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) { - enum ctxt_menu_type type = *(enum ctxt_menu_type *)_GET_PRIV(obj); + ctxt_menu_type *type; Evas_Object *img; int r; @@ -171,7 +174,9 @@ void CContextView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) case EO_CTXT_BTN: elm_object_signal_emit(obj, SIG_FOCUSED, PART_CTXT_MENUBTN_BG); - if (type == CTXT_MENU_FAVORITE) { + type = (ctxt_menu_type *)_GET_PRIV(obj); + + if (*type == CTXT_MENU_FAVORITE) { img = elm_image_add(obj); if (!img) { _ERR("elm_image_add failed."); @@ -203,7 +208,7 @@ void CContextView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) void CContextView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) { - enum ctxt_menu_type type = *(enum ctxt_menu_type *)_GET_PRIV(obj); + ctxt_menu_type *type; Evas_Object *img; int r; @@ -211,7 +216,9 @@ void CContextView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) case EO_CTXT_BTN: elm_object_signal_emit(obj, SIG_UNFOCUSED, PART_CTXT_MENUBTN_BG); - if (type == CTXT_MENU_FAVORITE) { + type = (ctxt_menu_type *)_GET_PRIV(obj); + + if (*type == CTXT_MENU_FAVORITE) { img = elm_image_add(obj); if (!img) { _ERR("elm_image_add failed."); @@ -246,17 +253,19 @@ void CContextView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_D { switch (id) { case EO_BASE: - if (strcmp(ev->keyname, KEY_BACK)) - return; - - if (!CViewMgr::GetInstance()->PopView()) { + if (!strcmp(ev->keyname, KEY_BACK) && !CViewMgr::GetInstance()->PopView()) { _ERR("Pop View failed."); CViewMgr::Finalize(); } break; case EO_CTXT_BTN: - m_ContextButtonSelected(obj); + if (!strcmp(ev->keyname, KEY_BACK) && !CViewMgr::GetInstance()->PopView()) { + _ERR("Pop View failed."); + CViewMgr::Finalize(); + } else if (!strcmp(ev->keyname, KEY_ENTER)) { + m_ContextButtonSelected(obj); + } break; case EO_CTGR_BTN: @@ -750,7 +759,6 @@ end: bool CContextView::m_DrawAppInfo(void) { Evas_Object *img, *img1; - char versiontxt[20]; int r, cur_idx; img = elm_image_add(m->base); @@ -787,18 +795,7 @@ bool CContextView::m_DrawAppInfo(void) elm_object_part_text_set(m->base, PART_FOCUSED_APP_CATEGORY, app_content_category_get_name(cur_idx)); - if (strcmp(m->app_version, TXT_NULL)) { - snprintf(versiontxt, sizeof(versiontxt), "%s %s", VERSION, - m->app_version); - elm_object_part_text_set(m->base, PART_FOCUSED_APP_VER, - versiontxt); - } else { - elm_object_part_text_set(m->base, PART_FOCUSED_APP_VER, - STR_VERSION_UNKNOWN); - } - - /* FIXME: The size of app is not provided. It must be modified later. */ - elm_object_part_text_set(m->base, PART_FOCUSED_APP_SIZE, "400MB"); + elm_object_part_text_set(m->base, PART_FOCUSED_APP_VER, STR_VERSION_UNKNOWN); return true; } @@ -892,11 +889,12 @@ bool CContextView::m_DrawContextButtons(void) m->ctxt_menubtn[i] = ly; m->ctxt_menulbl[i] = lbl; + m->idx[i] = i; Connect(ly, EO_CTXT_BTN, TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED); - _SET_PRIV(ly, (void *)(intptr_t)i); + _SET_PRIV(ly, (void *)&m->idx[i]); } elm_object_focus_set(m->ctxt_menubtn[0], EINA_TRUE); @@ -959,91 +957,70 @@ Evas_Object *CContextView::m_LoadAppInfo(char *name, char *icon) /** * @Loads the contents of table object */ -bool CContextView::m_LoadTableContents(void) +int CContextView::sm_CbAppList(pkgmgrinfo_appinfo_h handle, void *data) { - GList *l; - pkgmgrinfo_appinfo_h pah; - int index, i, cur_x = 0, cur_y = 0, r; - char *contents_id, *name, *icon; + ASSERT(data); + + CContextView *This = (CContextView *)data; + SContextView *m = (SContextView *)This->m; + char *appid, *name, *icon; + int r; + bool nodisplay; Evas_Object *thumb; - if (!m->table) - return false; + if (!m->table) { + _ERR("table object is NULL."); + return -1; + } - m->first_thumb = NULL; + r = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay); + if (r != PMINFO_R_OK) + return -1; - elm_table_clear(m->table, EINA_TRUE); + if (nodisplay) + return 0; - index = app_content_category_get_by_id(APP_CC_APPS, m->pkgname); + r = pkgmgrinfo_appinfo_get_appid(handle, &appid); + if (r != PMINFO_R_OK) + return -1; - l = app_content_category_get_by_category(index); - for (i = 0; i < (int)g_list_length(l); i++) { - contents_id = (char *)g_list_nth_data(l, i); - if (!contents_id) - continue; + r = pkgmgrinfo_appinfo_get_label(handle, &name); + if (r != PMINFO_R_OK) + return -1; - r = pkgmgrinfo_appinfo_get_appinfo(contents_id, &pah); - if (r != PMINFO_R_OK) { - _ERR("pkgmgrinfo_appinfo_get_appinfo failed."); - return false; - } + r = pkgmgrinfo_appinfo_get_icon(handle, &icon); + if (r != PMINFO_R_OK) + return -1; - r = pkgmgrinfo_appinfo_get_label(pah, &name); - if (r != PMINFO_R_OK) { - _ERR("pkgmgrinfo_appinfo_get_label failed."); - goto err; - } + if (!appid || !name || !icon || m->cur_y >= m->max_y || m->cur_x >= m->max_x) + return -1; - r = pkgmgrinfo_appinfo_get_icon(pah, &icon); - if (r != PMINFO_R_OK) { - _ERR("pkgmgrinfo_appinfo_get_icon failed."); - goto err; - } + thumb = This->m_LoadAppInfo(name, icon); + if (!thumb) + return -1; - if (!name || !icon) - goto err; + if (m->cur_x == 0 && m->cur_y == 0) + m->first_thumb = thumb; - thumb = m_LoadAppInfo(name, icon); - if (!thumb) - goto err; + if (m->cur_y == 0) + elm_object_focus_next_object_set(thumb, thumb, ELM_FOCUS_LEFT); + if (m->cur_y == m->max_y - 1) + elm_object_focus_next_object_set(thumb, thumb, ELM_FOCUS_RIGHT); + if (m->cur_x == 0) + elm_object_focus_next_object_set(thumb, m->ctxt_menubtn[0], ELM_FOCUS_UP); - if (cur_x == 0 && cur_y == 0) - m->first_thumb = thumb; - - if (cur_y == 0) - elm_object_focus_next_object_set(thumb, thumb, ELM_FOCUS_LEFT); - if (cur_y == m->max_y - 1) - elm_object_focus_next_object_set(thumb, thumb, ELM_FOCUS_RIGHT); - if (cur_x == 0) - elm_object_focus_next_object_set(thumb, m->ctxt_menubtn[0], - ELM_FOCUS_UP); - - m->last_line_thumb[cur_y] = thumb; - elm_table_pack(m->table, thumb, cur_y++, cur_x, 1, 1); - evas_object_show(thumb); - if (cur_y >= m->max_y) { - cur_x++; - cur_y = 0; - } + m->last_line_thumb[m->cur_y] = thumb; + elm_table_pack(m->table, thumb, m->cur_y++, m->cur_x, 1, 1); + evas_object_show(thumb); - _SET_PRIV(thumb, contents_id); - pkgmgrinfo_appinfo_destroy_appinfo(pah); + if (m->cur_y >= m->max_y) { + m->cur_x++; + m->cur_y = 0; } - for (i = 0; i < CTXT_MENU_BTN_SIZE; i++) - elm_object_focus_next_object_set(m->ctxt_menubtn[i], - m->first_thumb, ELM_FOCUS_DOWN); - - for (i = 0; i < RELATED_TABLE_MAX_COL; i++) - elm_object_focus_next_object_set(m->last_line_thumb[i], - m->last_line_thumb[i], ELM_FOCUS_DOWN); + _SET_PRIV(thumb, appid); - return true; - -err: - pkgmgrinfo_appinfo_destroy_appinfo(pah); - - return false; + return 0; } /** @@ -1052,6 +1029,7 @@ err: bool CContextView::m_DrawRelatedApps(void) { Evas_Object *scroller, *table; + int i, r; scroller = _add_scroller(m->base); if (!scroller) { @@ -1069,13 +1047,27 @@ bool CContextView::m_DrawRelatedApps(void) m->table = table; m->max_x = RELATED_TABLE_MAX_ROW; m->max_y = RELATED_TABLE_MAX_COL; + m->cur_x = 0; + m->cur_y = 0; + m->first_thumb = NULL; + + elm_table_clear(m->table, EINA_TRUE); - if (!m_LoadTableContents()) { - _ERR("_add_table_contents failed."); - evas_object_del(table); + r = pkgmgrinfo_appinfo_get_usr_installed_list((pkgmgrinfo_app_list_cb)sm_CbAppList, + getuid(), this); + if (r != PMINFO_R_OK) { + evas_object_del(scroller); return false; } + for (i = 0; i < CTXT_MENU_BTN_SIZE; i++) + elm_object_focus_next_object_set(m->ctxt_menubtn[i], + m->first_thumb, ELM_FOCUS_DOWN); + + for (i = 0; i < RELATED_TABLE_MAX_COL; i++) + elm_object_focus_next_object_set(m->last_line_thumb[i], + m->last_line_thumb[i], ELM_FOCUS_DOWN); + elm_object_content_set(scroller, table); elm_object_part_content_set(m->base, PART_RELAPP_TABLE, scroller); @@ -1173,27 +1165,21 @@ bool CContextView::Create(void *data) if (ainfo->Appid()) m->pkgname = strdup(ainfo->Appid()); - free(m->app_pkgid); if (ainfo->Pkgid()) m->app_pkgid = strdup(ainfo->Pkgid()); - free(m->app_title); if (ainfo->Name()) m->app_title = strdup(ainfo->Name()); - free(m->app_icon); if (ainfo->Icon()) m->app_icon = strdup(ainfo->Icon()); - free(m->app_category); if (ainfo->Category()) m->app_category = strdup(ainfo->Category()); - free(m->app_version); if (ainfo->Version()) m->app_version = strdup(ainfo->Version()); - free(m->app_thumbland); if (thumbland) m->app_thumbland = strdup(thumbland); |