From 17a856b49742633ae54be79c8550dfdc38dc51da Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Feb 2015 00:57:16 +0900 Subject: [PATCH 01/16] Apply CCtxPopup to CContextView Change-Id: I7e9e6099da3b963da617f43461b5747994331216 Signed-off-by: Kim Tae Soo --- CMakeLists.txt | 1 + include/Info.h | 3 + include/common.h | 4 +- include/context-view.h | 10 ++- include/define.h | 2 + src/views/Info.cpp | 11 +++ src/views/PlayListCtxPopup.cpp | 145 +++++++++++++++++++++++++++++++++++ src/views/PlayListCtxPopup.h | 21 ++++++ src/views/PlaySettingCtxPopup.cpp | 2 +- src/views/context-view.cpp | 154 +++++++++++--------------------------- 10 files changed, 237 insertions(+), 116 deletions(-) create mode 100644 src/views/PlayListCtxPopup.cpp create mode 100644 src/views/PlayListCtxPopup.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c286f96..31c660e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,7 @@ SET(SRCS src/main.cpp src/views/SourceCtxPopup.cpp src/views/SortCtxPopup.cpp src/views/PlaySettingCtxPopup.cpp + src/views/PlayListCtxPopup.cpp src/playback/playlist-mgr.cpp src/playback/music-controller.cpp src/playback/playback-mgr.cpp diff --git a/include/Info.h b/include/Info.h index f0da1b3..d4c35b0 100644 --- a/include/Info.h +++ b/include/Info.h @@ -13,6 +13,9 @@ public: static void SetPlaybackSettingType(int type); static int PlaybackSettingType(void); + + static void SetPlayListDbId(int dbId); + static int PlayListDbId(void); }; diff --git a/include/common.h b/include/common.h index d0a76f8..1f09007 100644 --- a/include/common.h +++ b/include/common.h @@ -147,10 +147,12 @@ struct SParcel { // this values should be defined #define KEY_PLAY "Play" -#define KEY_ENTER "Enter" #define KEY_NEXT "Next" #define KEY_PREVIOUS "Previous" #define KEY_EXIT "Exit" + +// Temp Definition +#define KEY_ENTER "Return" #define KEY_BACK "Escape" #define KEY_MENU "Super_L" diff --git a/include/context-view.h b/include/context-view.h index 8212262..7679dd1 100644 --- a/include/context-view.h +++ b/include/context-view.h @@ -18,6 +18,8 @@ #define __CONTEXT_VIEW_H__ +#include + struct SContentInfo; struct SRltvCtnt; @@ -43,12 +45,12 @@ private: static int sm_CbSortPlaylist(const void *d1, const void *d2); static void sm_CbPopupDeleted(void *data, Evas *e, Evas_Object *obj, void *ei); - static void sm_CbPopupBtnClicked(void *data, Evas_Object *obj, void *ei); - void m_OnPopupBtnClicked(Evas_Object *obj); - static Eina_Bool sm_CbSelectIdler(void *dt); Eina_Bool m_OnSelectIdler(void); + static void sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text); + void m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text); + private: @@ -81,7 +83,7 @@ private: bool m_CreateMoreinfoLayout(SRltvCtnt *rctnt, Evas_Object *img); bool m_CreateInfoPart(void); bool m_CreateFullView(void); - Evas_Object *m_CreatePlaylistPopup(void); + CCtxPopup *m_CreatePlaylistPopup(void); Evas_Object *m_CreateRemovePopup(Evas_Object *base, const char *msg, Evas_Object_Event_Cb _close_cb, Evas_Smart_Cb _remove_cb, Evas_Smart_Cb _cancel_cb, void *dt); diff --git a/include/define.h b/include/define.h index 29ac199..27ae431 100644 --- a/include/define.h +++ b/include/define.h @@ -416,5 +416,7 @@ #define POSITION_SOURCE_POPUP_Y 155 #define POSITION_PLAY_SETTING_POPUP_X 212 #define POSITION_PLAY_SETTING_POPUP_Y 705 +#define POSITION_PLAY_LIST_POPUP_X 1644 +#define POSITION_PLAY_LIST_POPUP_Y 1020 #endif /* __DEFINE_H__ */ diff --git a/src/views/Info.cpp b/src/views/Info.cpp index d878b0a..19db11a 100644 --- a/src/views/Info.cpp +++ b/src/views/Info.cpp @@ -29,6 +29,7 @@ struct SInfo { int sourceType; int sortType; int playbackSettingType; + int playListDb; }; static SInfo g_info; @@ -61,4 +62,14 @@ void CInfo::SetPlaybackSettingType(int type) int CInfo::PlaybackSettingType(void) { return g_info.playbackSettingType; +} + +void CInfo::SetPlayListDbId(int dbId) +{ + g_info.playListDb = dbId; +} + +int CInfo::PlayListDbId(void) +{ + return g_info.playListDb; } \ No newline at end of file diff --git a/src/views/PlayListCtxPopup.cpp b/src/views/PlayListCtxPopup.cpp new file mode 100644 index 0000000..b6aad93 --- /dev/null +++ b/src/views/PlayListCtxPopup.cpp @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2014 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. +*/ + +#include +#include +#include +#include "i18n.h" +#include "define.h" +#include "dbg.h" +#include "common.h" +#include "Info.h" +#include "CtxPopup.h" +#include +#include +#include +#include "PlayListCtxPopup.h" + + +struct SPlayListCtxPopup { + char **settingTexts; + char **btnIds; + int *dbIds; + int listSize; +}; + + +void CPlayListCtxPopup::t_OnConfiguration(void) +{ + t_SetList((const char **)m->settingTexts, m->listSize, 0, + CCtxPopup::TOPBTN_BASE, (const char **)m->btnIds, + POSITION_PLAY_LIST_POPUP_X, POSITION_PLAY_LIST_POPUP_Y, + MUSIC_STYLE_LIST_POPUP, + MUSIC_STYLE_TOPTEXT_BTN, MUSIC_STYLE_MIDDLETEXT_BTN, MUSIC_STYLE_BOTTOMTEXT_BTN); +} + +void CPlayListCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev) +{ + if (!obj) + return; + + int index = -1; + const char *id = (const char*)evas_object_data_get(obj, BTN_ID); + + if (!id) + return; + + // Find Index + int i; + for (i = 0; i < m->listSize; i++) { + if (m->btnIds[i] && !strcmp(m->btnIds[i], id)) { + index = i; + break; + } + } + + if (index == -1) + return; + + CInfo::SetPlayListDbId(m->dbIds[index]); + + CCtxPopup::t_OnBtnClicked(obj, ev); + + Destroy(); +} + + +bool CPlayListCtxPopup::Create(Evas_Object* base, const SCallback* callback, Eina_List *playList) +{ + Eina_List *l = NULL; + SCtxtPlaylistItem *item = NULL; + int i; + void *obj = NULL; + + m = new SPlayListCtxPopup; + if (!m) { + _ERR("Memory Alloc Failed!!"); + return false; + } + + m->listSize = eina_list_count(playList); + if (m->listSize == 0) { + _DBG("Playlist is empty."); + delete m; + return false; + } + + m->settingTexts = new char*[m->listSize]; + m->btnIds = new char*[m->listSize]; + m->dbIds = new int[m->listSize]; + + i = 0; + EINA_LIST_FOREACH(playList, l, obj) { + item = (SCtxtPlaylistItem *)obj; + m->settingTexts[i] = new char[strlen(N_(item->name)) + 1]; + m->btnIds[i] = new char[strlen(item->name) + 1]; + m->dbIds[i] = item->id; + + strcpy(m->settingTexts[i], N_(item->name)); + strcpy(m->btnIds[i], item->name); + + i++; + } + + bool r = CCtxPopup::Create(base, callback, true); + if (r == false) { + _ERR("CCtxPopup::Create failed"); + delete m; + return false; + } + + return true; +} + + +void CPlayListCtxPopup::Destroy(void) +{ + CCtxPopup::Destroy(); + + int i; + + for (i = 0; i < m->listSize; i++) { + delete[] m->settingTexts[i]; + delete[] m->btnIds[i]; + } + + delete[] m->settingTexts; + delete[] m->btnIds; + delete[] m->dbIds; + delete m; + + m = NULL; +} \ No newline at end of file diff --git a/src/views/PlayListCtxPopup.h b/src/views/PlayListCtxPopup.h new file mode 100644 index 0000000..29888d2 --- /dev/null +++ b/src/views/PlayListCtxPopup.h @@ -0,0 +1,21 @@ +#ifndef __PLAYLIST_CTX_POPUP_H__ +#define __PLAYLIST_CTX_POPUP_H__ + +#include + +class CPlayListCtxPopup : public CCtxPopup { +private: + struct SPlayListCtxPopup *m; + +protected: + virtual void t_OnConfiguration(void); + virtual void t_OnBtnClicked(Evas_Object* obj, void* ev); + +public: + CPlayListCtxPopup() : m(0) {} + + bool Create(Evas_Object* base, const SCallback* callback, Eina_List *playList); + virtual void Destroy(void); +}; + +#endif /* __PLAYLIST_CTX_POPUP_H__ */ diff --git a/src/views/PlaySettingCtxPopup.cpp b/src/views/PlaySettingCtxPopup.cpp index f0c3d61..8645226 100644 --- a/src/views/PlaySettingCtxPopup.cpp +++ b/src/views/PlaySettingCtxPopup.cpp @@ -42,7 +42,7 @@ const char *settingBtnId[TOTAL_SETTING_BTNS] = { void CPlaySettingCtxPopup::t_OnConfiguration(void) { - t_SetList(settingText, TOTAL_SETTING_BTNS, (int)CInfo::PlaybackSettingType(), + t_SetList(settingText, TOTAL_SETTING_BTNS, 0, CCtxPopup::TOPBTN_BASE, settingBtnId, POSITION_PLAY_SETTING_POPUP_X, POSITION_PLAY_SETTING_POPUP_Y, MUSIC_STYLE_SETTING_POPUP, diff --git a/src/views/context-view.cpp b/src/views/context-view.cpp index 30c68f3..49b5f07 100644 --- a/src/views/context-view.cpp +++ b/src/views/context-view.cpp @@ -33,6 +33,8 @@ #include "BaseView.h" #include "ViewMgr.h" #include "context-view.h" +#include "PlayListCtxPopup.h" +#include "Info.h" #define _GET_PRIV(o) evas_object_data_get(o, "CTMDATA"); #define _SET_PRIV(o, data) evas_object_data_set(o, "CTMDATA", data); @@ -101,6 +103,7 @@ struct SContextView { Evas_Object *first_line[TABLE_MAX_COL]; Evas_Object *last_line[TABLE_MAX_COL]; Evas_Object *popup; + CPlayListCtxPopup *ctxpopup; Ecore_Idler *idler; CMusicController *mhandle; CViewMgr *vmgr; @@ -269,32 +272,10 @@ void CContextView::sm_CbPopupDeleted(void *data, Evas *e, Evas_Object *obj, void } -void CContextView::sm_CbPopupBtnClicked(void *data, Evas_Object *obj, void *ei) -{ - CContextView *root = (CContextView *)data; - if (root) - root->m_OnPopupBtnClicked(obj); -} - - -void CContextView::m_OnPopupBtnClicked(Evas_Object *obj) -{ - SCtxtPlaylistItem *item = (SCtxtPlaylistItem *)_GET_PRIV(obj); - - if (!item) { - _ERR("Invalid argument."); - return; - } - - m->lid = item->id; - m->idler = ecore_idler_add(sm_CbSelectIdler, this); -} - - Eina_Bool CContextView::sm_CbSelectIdler(void *dt) { CContextView *root = (CContextView *)dt; - Eina_Bool r; + Eina_Bool r = ECORE_CALLBACK_CANCEL; if (root) r = root->m_OnSelectIdler(); @@ -321,6 +302,21 @@ Eina_Bool CContextView::m_OnSelectIdler(void) } +void CContextView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text) +{ + CContextView *root = (CContextView*)cookie; + if (root) + root->m_CbCtxPopupBtnSelected(instance, text); +} + + +void CContextView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text) +{ + m->lid = CInfo::PlayListDbId(); + m->idler = ecore_idler_add(sm_CbSelectIdler, this); +} + + Evas_Object *CContextView::m_AddScroller(Evas_Object *base) { Evas_Object *scroller = NULL; @@ -1115,103 +1111,37 @@ bool CContextView::m_CreateFullView(void) } -Evas_Object *CContextView::m_CreatePlaylistPopup(void) +CCtxPopup *CContextView::m_CreatePlaylistPopup(void) { - Evas_Object *popup = NULL, *box = NULL, *btn = NULL, *scr = NULL, *firstbtn = NULL; - Eina_List *l = NULL, *list = NULL; - struct SCtxtPlaylistItem *item = NULL; - void *obj = NULL; - int i, tc; - - popup = elm_ctxpopup_add(m->base); - if (!popup) { - _ERR("elm_ctxpopup_add failed."); - return NULL; - } - - box = elm_box_add(popup); - if (!box) { - _ERR("elm_box_add failed."); - evas_object_del(popup); - return NULL; - } - - evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0); - evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0); + CPlayListCtxPopup *ctxpopup = NULL; + Eina_List *list = NULL; + bool r; list = CMediadata::PlaylistsForCtxt(); if (!list || eina_list_count(list) == 0) { _ERR("Fetching list of playlists failed"); - evas_object_del(popup); return NULL; } list = eina_list_sort(list, 0, sm_CbSortPlaylist); - elm_object_style_set(popup, MUSIC_STYLE_LIST_POPUP); - evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, - sm_CbPopupDeleted, list); - - btn = NULL; - firstbtn = NULL; - i = 0; - tc = eina_list_count(list); - - EINA_LIST_FOREACH(list, l, obj) { - item = (SCtxtPlaylistItem *)obj; - btn = elm_button_add(box); - if (!btn) { - _ERR("elm_button_add failed."); - evas_object_del(popup); - return NULL; - } - if (i == 0) { - elm_object_style_set(btn, MUSIC_STYLE_TOPTEXT_BTN); - firstbtn = btn; - } - else if (i == tc - 1) { - _INFO(); - elm_object_style_set(btn, MUSIC_STYLE_BOTTOMTEXT_BTN); - elm_object_signal_emit(btn, MUSIC_SIGNAL_HIDELINE, - MUSIC_CONTEXT_VIEW); - } - else { - elm_object_style_set(btn, MUSIC_STYLE_MIDDLETEXT_BTN); - } - - i++; - elm_object_text_set(btn, item->name); - evas_object_show(btn); - elm_box_pack_end(box, btn); - _SET_PRIV(btn, item); - - evas_object_smart_callback_add(btn, MUSIC_SIGNAL_CLICKED, - sm_CbPopupBtnClicked, this); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_MOVE, - _object_mouse_moved, NULL); - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - sm_CbPopupKeyPressed, m); - } - - scr = m_AddScroller(popup); - if (!scr) { - evas_object_del(popup); + ctxpopup = new CPlayListCtxPopup; + if (!ctxpopup) { + _ERR("Memory alloc failed"); return NULL; } - elm_object_content_set(scr, box); - elm_object_content_set(popup, scr); - elm_object_part_content_set(m->base, MUSIC_PART_PLIST_POPUP, popup); - - elm_ctxpopup_direction_priority_set(popup, (Elm_Ctxpopup_Direction)0, (Elm_Ctxpopup_Direction)0, (Elm_Ctxpopup_Direction)0, (Elm_Ctxpopup_Direction)0); - - if (firstbtn && btn) { - elm_object_focus_set(firstbtn, EINA_TRUE); - elm_object_focus_next_object_set(firstbtn, btn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(btn, firstbtn, ELM_FOCUS_DOWN); + CCtxPopup::SCallback cb; + cb.onSelected = sm_CbCtxPopupBtnSelected; + cb.cookie = this; + r = ctxpopup->Create(m->base, &cb, list); + if (!r) { + _ERR("PlayListCtxpopup Creation failed"); + delete ctxpopup; + return NULL; } - return popup; + return ctxpopup; } @@ -1282,11 +1212,15 @@ Evas_Object *CContextView::m_CreateRemovePopup(Evas_Object *base, const char *ms void CContextView::m_DestroyPopup(void) { - if (!m->popup) - return; + if (m->popup) + evas_object_del(m->popup); + + if (m->ctxpopup && m->ctxpopup->FlagCreate()) + m->ctxpopup->Destroy(); - evas_object_del(m->popup); m->popup = NULL; + delete m->ctxpopup; + m->ctxpopup = NULL; } @@ -1316,8 +1250,8 @@ void CContextView::m_HandleBtnSelected(int btnType) break; case CONTEXT_VIEW_BUTTON_ADDTO: - m->popup = m_CreatePlaylistPopup(); - if (!m->popup) + m->ctxpopup = (CPlayListCtxPopup *)m_CreatePlaylistPopup(); + if (!m->ctxpopup) _create_message_box(m->base, MUSIC_TEXT_NOLIST_MSG); break; -- 2.7.4 From ad852012d873569d64375a4b7e94b7c6b1f0be80 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Feb 2015 14:50:32 +0900 Subject: [PATCH 02/16] Bug Fix - Creating playlist error (only one song is added) Change-Id: Ied11901e3551bb740e6f58aee611c9defebf4762 Signed-off-by: Kim Tae Soo --- src/data/mediadata.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data/mediadata.cpp b/src/data/mediadata.cpp index 9e9c04e..935fbbc 100644 --- a/src/data/mediadata.cpp +++ b/src/data/mediadata.cpp @@ -1226,9 +1226,10 @@ bool CMediadata::InsertPlaylist(const char *name, Eina_List *idlist) return false; } - EINA_LIST_FOREACH(idlist, l, obj) + EINA_LIST_FOREACH(idlist, l, obj) { id = (char *)obj; media_playlist_add_media(ph, id); + } media_playlist_update_to_db(ph); -- 2.7.4 From 22575140d58510e53bf16e777ba4437a051b8ae4 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Feb 2015 17:50:16 +0900 Subject: [PATCH 03/16] Support remote key control Change-Id: Ifffb0d9b51d5f1030eedecf3d4b7a4251ec1ae8f Signed-off-by: Kim Tae Soo --- include/common.h | 3 +++ src/views/album-layout.cpp | 6 ++++-- src/views/album-songs-layout.cpp | 6 ++++-- src/views/base-view.cpp | 9 ++++++--- src/views/category-layout.cpp | 10 ++++++---- src/views/context-view.cpp | 15 ++++++++++----- src/views/entry-popup.cpp | 10 ++++------ src/views/folder-layout.cpp | 6 ++++-- src/views/playback-view.cpp | 28 ++++++++++++++++------------ src/views/song-layout.cpp | 6 ++++-- 10 files changed, 61 insertions(+), 38 deletions(-) diff --git a/include/common.h b/include/common.h index 1f09007..0594435 100644 --- a/include/common.h +++ b/include/common.h @@ -155,6 +155,9 @@ struct SParcel { #define KEY_ENTER "Return" #define KEY_BACK "Escape" #define KEY_MENU "Super_L" +#define KEY_ENTER_REMOTE "KP_Enter" +#define KEY_BACK_REMOTE "XF86Close" +#define KEY_MENU_REMOTE "XF86MenuKB" #define SORT_BY_ARTIST_AZ "SORT_BY_ARTIST_AZ" #define SORT_BY_ARTIST_ZA "SORT_BY_ARTIST_ZA" diff --git a/src/views/album-layout.cpp b/src/views/album-layout.cpp index b6fff7e..867043f 100644 --- a/src/views/album-layout.cpp +++ b/src/views/album-layout.cpp @@ -603,7 +603,8 @@ void CAlbumLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_D { switch (id) { case ALBUM_LAYOUT: - if (!strcmp(ev->keyname, KEY_BACK)) { + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { SParcel parcel; parcel.ctxtInfo = NULL; parcel.updateType = E_FOCUS_UPDATE; @@ -619,7 +620,8 @@ void CAlbumLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_D SContentInfo *ctxtinfo = NULL; SAlbumItemInfo *itinfo = NULL; - if (strcmp(ev->keyname, KEY_MENU)) + if (strcmp(ev->keyname, KEY_MENU) && + strcmp(ev->keyname, KEY_MENU_REMOTE)) return; it = elm_object_focused_item_get(obj); diff --git a/src/views/album-songs-layout.cpp b/src/views/album-songs-layout.cpp index c310f8d..414b27e 100644 --- a/src/views/album-songs-layout.cpp +++ b/src/views/album-songs-layout.cpp @@ -597,7 +597,8 @@ void CAlbumSongsLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_ switch (id) { case ALBUM_SONGS_LAYOUT: - if (!strcmp(ev->keyname, KEY_BACK)) { + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { SParcel parcel; parcel.ctxtInfo = NULL; parcel.updateType = E_DEPTH_UPDATE; @@ -613,7 +614,8 @@ void CAlbumSongsLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_ SContentInfo *ctxtinfo = NULL; SAlbumSongsItemInfo *itinfo = NULL; - if (strcmp(ev->keyname, KEY_MENU)) + if (strcmp(ev->keyname, KEY_MENU) && + strcmp(ev->keyname, KEY_MENU_REMOTE)) return; it = elm_object_focused_item_get(obj); diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index 233636b..49e2a33 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -914,7 +914,8 @@ void CMusicBaseView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key m->mhandle->Stop(); elm_exit(); } - else if (!strcmp(ev->keyname, KEY_ENTER)) { + else if (!strcmp(ev->keyname, KEY_ENTER) || + !strcmp(ev->keyname, KEY_ENTER_REMOTE)) { if (elm_object_focus_get(m->c_grpbtn)) { m_UpdateCurrentLayout(true); } @@ -941,7 +942,8 @@ void CMusicBaseView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key case BASE_VIEW_PLAY_BUTTON: case BASE_VIEW_SORT_BUTTON: case BASE_VIEW_SOURCE_BUTTON: - if (!strcmp(ev->keyname, KEY_BACK)) + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) elm_object_focus_set(m->c_grpbtn, EINA_TRUE); break; @@ -951,7 +953,8 @@ void CMusicBaseView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key case BASE_VIEW_GROUP_GENRE: case BASE_VIEW_GROUP_FOLDER: case BASE_VIEW_GROUP_PLAYLIST: - if (!strcmp(ev->keyname, KEY_BACK)) { + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { m->mhandle->Stop(); elm_exit(); } diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index 9ecf1c9..2aa8a20 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -1689,7 +1689,8 @@ void CCategoryLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Ke int count; Eina_List *alist = NULL; - if (!strcmp(ev->keyname, KEY_BACK)) { + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { if (t.depth == E_DEPTH_CATEGORY) { SParcel parcel; parcel.ctxtInfo = NULL; @@ -1734,9 +1735,10 @@ void CCategoryLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Ke if (!obj) return; - if (strcmp(ev->keyname, KEY_MENU) || t.depth == - E_DEPTH_SELECT_LIST || t.depth == - E_DEPTH_SHOW_LIST) + if ((strcmp(ev->keyname, KEY_MENU) && + strcmp(ev->keyname, KEY_MENU_REMOTE)) || + t.depth == E_DEPTH_SELECT_LIST || + t.depth == E_DEPTH_SHOW_LIST) return; it = elm_object_focused_item_get(obj); diff --git a/src/views/context-view.cpp b/src/views/context-view.cpp index 49b5f07..514a1c8 100644 --- a/src/views/context-view.cpp +++ b/src/views/context-view.cpp @@ -185,7 +185,8 @@ void CContextView::m_OnPopUpKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key if (!ev->keyname) return; - if (!strcmp(ev->keyname, KEY_BACK)) + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) m_DestroyPopup(); } @@ -1471,7 +1472,8 @@ void CContextView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_D switch (id) { case CONTEXT_VIEW: { - if (!strcmp(ev->keyname, KEY_BACK)) { + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { if (m->ctxtinfo && m->ctxtinfo->close) m->ctxtinfo->close(m->ctxtinfo->cbdata); } @@ -1503,7 +1505,8 @@ void CContextView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up case CONTEXT_VIEW_BUTTON_REMOVESONG: case CONTEXT_VIEW_BUTTON_DELETE: { - if (strcmp(ev->keyname, KEY_ENTER)) + if (strcmp(ev->keyname, KEY_ENTER) && + strcmp(ev->keyname, KEY_ENTER_REMOTE)) return; m_HandleBtnSelected(id); @@ -1515,7 +1518,8 @@ void CContextView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up if (!obj || !ev) return; - if (strcmp(ev->keyname, KEY_ENTER)) + if (strcmp(ev->keyname, KEY_ENTER) && + strcmp(ev->keyname, KEY_ENTER_REMOTE)) return; m_HandleMoreinfoSelected(obj); @@ -1527,7 +1531,8 @@ void CContextView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up if (!obj || !ev) return; - if (strcmp(ev->keyname, KEY_ENTER)) + if (strcmp(ev->keyname, KEY_ENTER) && + strcmp(ev->keyname, KEY_ENTER_REMOTE)) return; elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTENT_CLICKED, diff --git a/src/views/entry-popup.cpp b/src/views/entry-popup.cpp index e963760..17966c7 100644 --- a/src/views/entry-popup.cpp +++ b/src/views/entry-popup.cpp @@ -25,9 +25,6 @@ #include #include "entry-popup.h" -//#define KEY_SELECT "Select" -#define KEY_POPUP_ENTER "Return" - struct SEntryPopup { Evas_Object *layout; @@ -144,10 +141,11 @@ void CEntryPopup::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Do if (!ev->keyname) return; - if (strcmp(ev->keyname, KEY_BACK) == 0) + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) Destroy(); - // Keyname should be checked!!! - else if (strcmp(ev->keyname, KEY_POPUP_ENTER/*KEY_SELECT*/) == 0) { + else if (!strcmp(ev->keyname, KEY_ENTER) || + !strcmp(ev->keyname, KEY_ENTER_REMOTE)) { str = elm_entry_entry_get(obj); if (m->cbEntryName && str) m->cbEntryName(m->data, str); diff --git a/src/views/folder-layout.cpp b/src/views/folder-layout.cpp index 8249f74..cf818f7 100644 --- a/src/views/folder-layout.cpp +++ b/src/views/folder-layout.cpp @@ -934,7 +934,8 @@ void CFolderLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_ switch (id) { case FOLDER_LAYOUT: { - if (!strcmp(ev->keyname, KEY_BACK)) { + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { if (m->depth == E_DEPTH_SONG) { m->depth = E_DEPTH_FOLDER; m_UpdateFolderGrid(false); @@ -962,7 +963,8 @@ void CFolderLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_ if (!obj) return; - if (strcmp(ev->keyname, KEY_MENU)) + if (strcmp(ev->keyname, KEY_MENU) && + strcmp(ev->keyname, KEY_MENU_REMOTE)) return; it = elm_object_focused_item_get(obj); diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index 5b9400b..f3cea5f 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -1051,23 +1051,24 @@ void CPlaybackView::m_KeyPreviousUnpress(void) void CPlaybackView::m_HandleKeyPress(char *keyname) { - if (strcmp(keyname, (char*)KEY_EXIT) == 0) + if (!strcmp(keyname, (char *)KEY_EXIT)) m_KeyExitPress(); - else if (strcmp(keyname, (char*)KEY_BACK) == 0) + else if (!strcmp(keyname, (char *)KEY_BACK) || + !strcmp(keyname, (char *)KEY_BACK_REMOTE)) m_KeyBackPress(); - else if (strcmp(keyname, (char*)KEY_PLAY) == 0) + else if (!strcmp(keyname, (char *)KEY_PLAY)) m_KeyPlayPress(); - else if (strcmp(keyname, (char*)KEY_PAUSE) == 0) + else if (!strcmp(keyname, (char *)KEY_PAUSE)) m_KeyPausePress(); - else if (strcmp(keyname, (char*)KEY_NEXT) == 0) + else if (!strcmp(keyname, (char *)KEY_NEXT)) m_KeyNextPress(); - else if (strcmp(keyname, (char*)KEY_PREVIOUS) == 0) + else if (!strcmp(keyname, (char *)KEY_PREVIOUS)) m_KeyPreviousPress(); - else if (strcmp(keyname, (char*)KEY_VOLUMEUP) == 0) + else if (!strcmp(keyname, (char *)KEY_VOLUMEUP)) m->pHandleVolume->Up(); - else if (strcmp(keyname, (char*)KEY_VOLUMEDOWN) == 0) + else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN)) m->pHandleVolume->Down(); - else if (strcmp(keyname, (char*)KEY_MUTE) == 0) + else if (!strcmp(keyname, (char *)KEY_MUTE)) m->pHandleVolume->Mute(); } @@ -1837,7 +1838,8 @@ void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_ break; case EO_ERROR_POPUP_BUTTON: - if (!strcmp(ev->keyname, KEY_BACK)) { + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { m_DestroyErrorPopup(); elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE); } @@ -1849,7 +1851,8 @@ void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_ SContentInfo *ctxtinfo = NULL; SItemInfo *itinfo = NULL; - if (strcmp(ev->keyname, KEY_MENU)) + if (strcmp(ev->keyname, KEY_MENU) && + strcmp(ev->keyname, KEY_MENU_REMOTE)) return; it = elm_object_focused_item_get(obj); @@ -1895,7 +1898,8 @@ void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_ } case EO_BOX: - if (!strcmp(ev->keyname, KEY_BACK)) { + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { _ERR("eoCtxPopup BACK key pressed "); m_DestroySettingsPopup(); elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE); diff --git a/src/views/song-layout.cpp b/src/views/song-layout.cpp index f2a10c2..3af52ea 100644 --- a/src/views/song-layout.cpp +++ b/src/views/song-layout.cpp @@ -623,7 +623,8 @@ void CSongLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Do switch (id) { case SONG_LAYOUT: { - if (!strcmp(ev->keyname, KEY_BACK)) { + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { SParcel parcel; parcel.ctxtInfo = NULL; parcel.updateType = E_FOCUS_UPDATE; @@ -640,7 +641,8 @@ void CSongLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Do SContentInfo *ctxtinfo = NULL; SSongItemInfo *itinfo = NULL; - if (strcmp(ev->keyname, KEY_MENU)) + if (strcmp(ev->keyname, KEY_MENU) && + strcmp(ev->keyname, KEY_MENU_REMOTE)) return; it = elm_object_focused_item_get(obj); -- 2.7.4 From e1b0a15d6cc93410e4b8cc1fde03236f1f234dae Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Feb 2015 21:11:02 +0900 Subject: [PATCH 04/16] Remove unnecessary code Change-Id: I2f25204c462ca7e086cdd3a75dc7be6b5b912f93 Signed-off-by: Kim Tae Soo --- src/views/category-layout.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index 2aa8a20..5516167 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -1424,7 +1424,6 @@ void CCategoryLayout::m_EmptyLayout(bool sort_flag) m->albumCover = NULL; evas_object_hide(Layout()); - elm_object_part_content_unset(t.base, MUSIC_PART_CONTENT); } @@ -1521,7 +1520,6 @@ void CCategoryLayout::t_UpdateLayoutWithFocus(void) { elm_object_tree_focus_allow_set(t.base, EINA_FALSE); t_UpdateLayout(false); - elm_object_part_content_set(t.base, MUSIC_PART_CONTENT, Layout()); evas_object_show(Layout()); m_RemoveFocusIdler(); m->focus_idler = ecore_idler_add(sm_CbFocusIdler, this); @@ -1659,7 +1657,6 @@ void CCategoryLayout::t_OnShow(void) t.depth = E_DEPTH_CATEGORY; t_UpdateLayout(false); - elm_object_part_content_set(t.base, MUSIC_PART_CONTENT, Layout()); evas_object_show(Layout()); } @@ -1672,7 +1669,6 @@ void CCategoryLayout::Update(bool focusFlag) if (t.depth != E_DEPTH_CATEGORY) return; t_UpdateLayout(true); - elm_object_part_content_set(t.base, MUSIC_PART_CONTENT, Layout()); evas_object_show(Layout()); return; } -- 2.7.4 From ff705a0ccbcb136728285b9633486cf4151ef65c Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Feb 2015 21:32:40 +0900 Subject: [PATCH 05/16] Remove unnecessary code. Change-Id: I37efae4102cd2df66f7792908b0393d052806d74 Signed-off-by: Kim Tae Soo --- src/views/category-layout.cpp | 3 --- src/views/folder-layout.cpp | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index 5516167..4582028 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -130,7 +130,6 @@ Eina_Bool CCategoryLayout::m_OnFocusIdler(void) SCatItemInfo *itinfo = NULL; m->focus_idler = NULL; - elm_object_tree_focus_allow_set(t.base, EINA_TRUE); if (t.depth == E_DEPTH_CATEGORY) { it = m_FindItemByInfo(m->it_infolist, t.c_catinfo); @@ -1518,7 +1517,6 @@ void CCategoryLayout::t_UpdateLayout(bool sort_flag) void CCategoryLayout::t_UpdateLayoutWithFocus(void) { - elm_object_tree_focus_allow_set(t.base, EINA_FALSE); t_UpdateLayout(false); evas_object_show(Layout()); m_RemoveFocusIdler(); @@ -1669,7 +1667,6 @@ void CCategoryLayout::Update(bool focusFlag) if (t.depth != E_DEPTH_CATEGORY) return; t_UpdateLayout(true); - evas_object_show(Layout()); return; } diff --git a/src/views/folder-layout.cpp b/src/views/folder-layout.cpp index cf818f7..a9c9310 100644 --- a/src/views/folder-layout.cpp +++ b/src/views/folder-layout.cpp @@ -311,7 +311,7 @@ void CFolderLayout::m_OnCtxtUpdate(EActionType type, int lid) m->mhandle->SetCurrentSong(sinfo->Id()); } - _update_playback_view((EAddType)type, m->parent->Layout(), m->focused_item); + _update_playback_view((EAddType)type, Layout(), m->focused_item); } void CFolderLayout::sm_CbCtxtClose(void *dt) @@ -458,7 +458,7 @@ void CFolderLayout::m_GotoPlayback(int mode, char *id) m->mhandle->SetCurrentSong(id); } - _update_playback_view((EAddType)mode, CExtBaseLayout::Layout(), NULL); + _update_playback_view((EAddType)mode, Layout(), NULL); } -- 2.7.4 From 285d6cd73ab1e959dea15fbec8a1321440a0345b Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 25 Feb 2015 22:02:22 +0900 Subject: [PATCH 06/16] Code arrangement Change-Id: I96f26ba182ee1abcd7714d1d90c6ce2087c0cbdb Signed-off-by: Kim Tae Soo --- include/category-layout.h | 2 +- src/views/category-layout.cpp | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/category-layout.h b/include/category-layout.h index f849c29..db3d722 100644 --- a/include/category-layout.h +++ b/include/category-layout.h @@ -63,7 +63,7 @@ protected: private: static Eina_Bool sm_CbFocusIdler(void *dt); - Eina_Bool m_OnFocusIdler(void); + void m_OnFocusIdler(void); static void sm_CbEntrynameSet(void *dt, const char *name); void m_OnEntrynameSet(const char *name); diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index 4582028..41cdf98 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -116,15 +116,14 @@ Eina_Bool CCategoryLayout::sm_CbFocusIdler(void *dt) { CCategoryLayout *root = (CCategoryLayout *)dt; - Eina_Bool ret = EINA_FALSE; if (root) - ret = root->m_OnFocusIdler(); + root->m_OnFocusIdler(); - return ret; + return ECORE_CALLBACK_CANCEL; } -Eina_Bool CCategoryLayout::m_OnFocusIdler(void) +void CCategoryLayout::m_OnFocusIdler(void) { Elm_Object_Item *it = NULL; SCatItemInfo *itinfo = NULL; @@ -142,8 +141,6 @@ Eina_Bool CCategoryLayout::m_OnFocusIdler(void) } else elm_object_focus_set(m->def_foc_btn, EINA_TRUE); - - return ECORE_CALLBACK_CANCEL; } -- 2.7.4 From 7a37e073bf434bf5516cf1a1f774ea2caf97bb2f Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Thu, 26 Feb 2015 18:58:04 +0900 Subject: [PATCH 07/16] Fix bug Change-Id: I20f14ca1dec010ff6180bb5e67e5ba0ed2044c84 Signed-off-by: Kim Tae Soo --- src/views/category-layout.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index 41cdf98..d7a345c 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -130,6 +130,8 @@ void CCategoryLayout::m_OnFocusIdler(void) m->focus_idler = NULL; + elm_object_tree_focus_allow_set(t.base, EINA_TRUE); + if (t.depth == E_DEPTH_CATEGORY) { it = m_FindItemByInfo(m->it_infolist, t.c_catinfo); if (!it) { @@ -1366,13 +1368,11 @@ void CCategoryLayout::m_SortCatgrid(void) void CCategoryLayout::m_EmptyLayout(bool sort_flag) { if (t.grid) { - elm_gengrid_clear(t.grid); evas_object_del(t.grid); t.grid = NULL; } if (m->glist) { - elm_genlist_clear(m->glist); evas_object_del(m->glist); m->glist = NULL; } @@ -1418,8 +1418,6 @@ void CCategoryLayout::m_EmptyLayout(bool sort_flag) if (m->albumCover) evas_object_del(m->albumCover); m->albumCover = NULL; - - evas_object_hide(Layout()); } @@ -1514,6 +1512,8 @@ void CCategoryLayout::t_UpdateLayout(bool sort_flag) void CCategoryLayout::t_UpdateLayoutWithFocus(void) { + elm_object_tree_focus_allow_set(t.base, EINA_FALSE); + t_UpdateLayout(false); evas_object_show(Layout()); m_RemoveFocusIdler(); @@ -1540,6 +1540,8 @@ bool CCategoryLayout::Create(CLayoutMgr *mgr) return false; } + memset(&t, 0, sizeof(SCategoryLayoutProtected)); + vmgr = CViewMgr::GetInstance(); if (!vmgr) { _ERR(" get view mgr failed "); -- 2.7.4 From 07860158c20205e861672d83fcae78478de0c458 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Thu, 26 Feb 2015 23:19:19 +0900 Subject: [PATCH 08/16] Fix bugs Change-Id: I64add489861bae00553f17d2aaf5274731fc3aed Signed-off-by: Kim Tae Soo --- src/data/album_info.cpp | 2 +- src/data/category_info.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/album_info.cpp b/src/data/album_info.cpp index 2bf3111..a131b6e 100644 --- a/src/data/album_info.cpp +++ b/src/data/album_info.cpp @@ -59,7 +59,7 @@ void CAlbumInfo::Destroy() if (!m) return; - CNameInfo::Destroy(); + CExtNameInfo::Destroy(); delete[] m->artist; delete[] m->genre; diff --git a/src/data/category_info.cpp b/src/data/category_info.cpp index 9270e2d..5de39ea 100644 --- a/src/data/category_info.cpp +++ b/src/data/category_info.cpp @@ -82,7 +82,7 @@ void CCategoryInfo::Destroy(void) if (!m) return; - CNameInfo::Destroy(); + CExtNameInfo::Destroy(); eina_list_free(m->albumList); if (m->memberList) { -- 2.7.4 From 39517464d8d1959b8e20cf9db3b72ceaa2143d2a Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Fri, 27 Feb 2015 14:11:12 +0900 Subject: [PATCH 09/16] Modify to use default popup style Change-Id: Idb3a7902efad462335c978792f6f683bfcd3320d Signed-off-by: Kim Tae Soo --- src/views/PlayListCtxPopup.cpp | 2 +- src/views/PlaySettingCtxPopup.cpp | 2 +- src/views/SortCtxPopup.cpp | 2 +- src/views/SourceCtxPopup.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/PlayListCtxPopup.cpp b/src/views/PlayListCtxPopup.cpp index b6aad93..3067497 100644 --- a/src/views/PlayListCtxPopup.cpp +++ b/src/views/PlayListCtxPopup.cpp @@ -42,7 +42,7 @@ void CPlayListCtxPopup::t_OnConfiguration(void) t_SetList((const char **)m->settingTexts, m->listSize, 0, CCtxPopup::TOPBTN_BASE, (const char **)m->btnIds, POSITION_PLAY_LIST_POPUP_X, POSITION_PLAY_LIST_POPUP_Y, - MUSIC_STYLE_LIST_POPUP, + NULL, MUSIC_STYLE_TOPTEXT_BTN, MUSIC_STYLE_MIDDLETEXT_BTN, MUSIC_STYLE_BOTTOMTEXT_BTN); } diff --git a/src/views/PlaySettingCtxPopup.cpp b/src/views/PlaySettingCtxPopup.cpp index 8645226..a6e45fe 100644 --- a/src/views/PlaySettingCtxPopup.cpp +++ b/src/views/PlaySettingCtxPopup.cpp @@ -45,7 +45,7 @@ void CPlaySettingCtxPopup::t_OnConfiguration(void) t_SetList(settingText, TOTAL_SETTING_BTNS, 0, CCtxPopup::TOPBTN_BASE, settingBtnId, POSITION_PLAY_SETTING_POPUP_X, POSITION_PLAY_SETTING_POPUP_Y, - MUSIC_STYLE_SETTING_POPUP, + NULL, MUSIC_STYLE_SETTING_BTN_T, MUSIC_STYLE_SETTING_BTN_T, MUSIC_STYLE_SETTING_BTN_B); } diff --git a/src/views/SortCtxPopup.cpp b/src/views/SortCtxPopup.cpp index ad5aa01..d72cfd3 100644 --- a/src/views/SortCtxPopup.cpp +++ b/src/views/SortCtxPopup.cpp @@ -105,7 +105,7 @@ void CSortCtxPopup::t_OnConfiguration(void) t_SetList(sortText, arraySize, (int)CInfo::SortType(), CCtxPopup::TOPBTN_SORT, sortBtnIds, POSITION_SORT_POPUP_X, POSITION_SORT_POPUP_Y, - MUSIC_STYLE_HOVER_CTXPOPUP, + NULL, MUSIC_STYLE_HOVER_ENTRY, MUSIC_STYLE_HOVER_ENTRY, MUSIC_STYLE_HOVER_ENTRY); } diff --git a/src/views/SourceCtxPopup.cpp b/src/views/SourceCtxPopup.cpp index 5a29ebd..e6cadaa 100644 --- a/src/views/SourceCtxPopup.cpp +++ b/src/views/SourceCtxPopup.cpp @@ -46,7 +46,7 @@ void CSourceCtxPopup::t_OnConfiguration(void) t_SetList(sourceText, size, (int)CInfo::SourceType(), CCtxPopup::TOPBTN_SOURCE, srcBtnIds, POSITION_SOURCE_POPUP_X, POSITION_SOURCE_POPUP_Y, - MUSIC_STYLE_HOVER_CTXPOPUP, + NULL, MUSIC_STYLE_HOVER_ENTRY, MUSIC_STYLE_HOVER_ENTRY, MUSIC_STYLE_HOVER_ENTRY); } -- 2.7.4 From bd8082cc888cc850d515d2977b0908fca77186f8 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Mon, 2 Mar 2015 09:04:07 +0900 Subject: [PATCH 10/16] Fix memory leak Change-Id: Ib98d7a50a3245ea42552155cb5f5b08d6f8c6d52 Signed-off-by: Kim Tae Soo --- src/data/mediadata.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/mediadata.cpp b/src/data/mediadata.cpp index 935fbbc..e1b1072 100644 --- a/src/data/mediadata.cpp +++ b/src/data/mediadata.cpp @@ -664,6 +664,7 @@ void CMediadata::m_DeleteCategoryList(ECategoryType type) EINA_LIST_FREE(m->playlistslist, obj) { catinfo = (CCategoryInfo *)obj; catinfo->Destroy(); + delete catinfo; } m->playlistslist = NULL; -- 2.7.4 From 7dd581b99463e89386ba98b5413a1fa0f23b7de6 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Mon, 2 Mar 2015 18:26:12 +0900 Subject: [PATCH 11/16] Refactoring of CCategoryLayout Change-Id: Iee8981a2d2aceff44a6d53445709cc9d0a8eeb68 Signed-off-by: Kim Tae Soo --- CMakeLists.txt | 1 + include/category-layout.h | 14 +- include/category-songs-layout.h | 107 +++ include/define.h | 3 + src/views/base-view.cpp | 8 +- src/views/category-layout.cpp | 730 ++++----------------- src/views/category-songs-layout.cpp | 1222 +++++++++++++++++++++++++++++++++++ 7 files changed, 1458 insertions(+), 627 deletions(-) create mode 100644 include/category-songs-layout.h create mode 100644 src/views/category-songs-layout.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 31c660e..0ab5516 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,7 @@ SET(SRCS src/main.cpp src/views/category-layout.cpp src/views/folder-layout.cpp src/views/album-songs-layout.cpp + src/views/category-songs-layout.cpp src/views/entry-popup.cpp src/views/base-view.cpp src/views/playback-view.cpp diff --git a/include/category-layout.h b/include/category-layout.h index db3d722..1a89dcb 100644 --- a/include/category-layout.h +++ b/include/category-layout.h @@ -19,7 +19,7 @@ class CCategoryLayout : public CExtBaseLayout, public CListenerMgr, - public IKeyDownListener, public IMouseMoveListener, public IMouseClickedListener, + public IKeyDownListener, public IMouseMoveListener, public IRealizedListener, public IUnrealizedListener, public IActivatedListener { private: struct SCategoryLayout *m; @@ -102,22 +102,17 @@ private: SCatItemInfo *m_FindItemInfo(Eina_List *list, Elm_Object_Item *item); void m_GotoPlayback(int mode, char *id); Eina_List *m_GetSelectedList(Eina_List *infolist, int type); - void m_AddSelectedSongs(void); - void m_RemoveSelectedSongs(void); void m_AddAlbumsToPlayback(int mode); void m_AddSongsToPlayback(int mode); - Evas_Object *m_AddAlbumCover(void); Evas_Object *m_AddGrid(void); void m_AddCategoryItem(Elm_Gengrid_Item_Class *grid_item, ECategoryType type, void *info); void m_AddButtons(void); - void m_AddSelectlistButtons(void); - void m_CreateSongsTopSection(void); - void m_CreateSongList(void); void m_CreateAlbumgrid(void); void m_CreateCatgrid(bool sort_flag); void m_SortCatgrid(void); void m_EmptyLayout(bool sort_flag); + void m_ShowCategorySongs(void); protected: bool t_SetEdje(const char *layout); @@ -138,7 +133,6 @@ public: CExtBaseLayout(pLayoutId), IKeyDownListener(this), IMouseMoveListener(this), - IMouseClickedListener(this), IRealizedListener(this), IUnrealizedListener(this), IActivatedListener(this), @@ -152,10 +146,12 @@ public: virtual void Update(bool focusFlag); + void CreateEntryPopup(void); + void SetEmptyStatusHandleCallback(void(*handleEmptyStatusCb)(void *cookie, bool emptyStatus), void *cookie); + public: virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev); - virtual void OnMouseClicked(int id, Evas_Object *obj); virtual void OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item); virtual void OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item); virtual void OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item); diff --git a/include/category-songs-layout.h b/include/category-songs-layout.h new file mode 100644 index 0000000..37586ca --- /dev/null +++ b/include/category-songs-layout.h @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2014 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. +*/ + +#ifndef __CATEGORY_SONGS_LAYOUT_H__ +#define __CATEGORY_SONGS_LAYOUT_H__ + + +#include "category-layout.h" +struct SCategorySongsItemsInfo; + +class CCategorySongsLayout : public CExtBaseLayout, public CListenerMgr, + public IKeyDownListener, public IMouseMoveListener, public IMouseClickedListener, + public IActivatedListener { +public: + enum EDepth { + DEPTH_SELECT_LIST, + DEPTH_SHOW_LIST, + DEPTH_SONG_LIST + }; + + enum ESelectType { + SELECT_TYPE_CREATE, + SELECT_TYPE_ADD, + SELECT_TYPE_REMOVE + }; + +private: + struct SCategorySongsLayout *m; + +private: + static Eina_Bool sm_CbFocusIdler(void *dt); + void m_OnFocusIdler(void); + + static char *sm_CbGetSelectlistItemText(void *data, Evas_Object *obj, const char *part); + static char *sm_CbGetListItemText(void *data, Evas_Object *obj, const char *part); + static void sm_CbRemoveListItem(void *data, Evas_Object *obj); + static void sm_CbGoToPlaybackView(void *cookie, int mode, char *mediaId); + + static void sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid); + void m_OnCtxtUpdate(EActionType type, int lid); + + static void sm_CbCtxtClose(void *dt); + void m_OnCtxtClose(void); + + static void sm_CbSongItemSelect(void *data, Evas_Object *obj, void *event_info); + void m_OnSongItemSelect(Evas_Object *obj, Elm_Object_Item *event_info); + + static void sm_CbSelectlistItemSelect(void *data, Evas_Object *obj, void *event_info); + void m_OnSelectlistItemSelect(Evas_Object *obj, Elm_Object_Item *event_info); + +private: + void m_RemoveFocusIdler(void); + SCategorySongsItemsInfo *m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item); + void m_UpdateSongList(void); + void m_EmptySongList(void); + inline int m_ConvertToMin(int milsec); + void m_GotoPlayback(int mode, char *id); + Evas_Object *m_AddAlbumCover(void); + void m_AddButtons(void); + void m_AddSelectlistButtons(void); + void m_CreateSongsTopSection(void); + void m_CreateSongList(void); + Eina_List *m_GetSelectedList(Eina_List *infolist, int type); + void m_AddSelectedSongs(void); + void m_RemoveSelectedSongs(void); + bool m_SetEdje(const char *szLayout); + +protected: + virtual void t_OnShow(void); + +public: + CCategorySongsLayout(const char *pLayoutId) : + CExtBaseLayout(pLayoutId), + IKeyDownListener(this), + IMouseMoveListener(this), + IMouseClickedListener(this), + IActivatedListener(this), + m(0) {} + virtual ~CCategorySongsLayout() {} + + bool Create(CLayoutMgr *mgr, CCategoryLayout *parent); + virtual void Destroy(void); + + void SetParameter(EDepth depth, ESelectType selType, CCategoryInfo *catInfo, CAlbumInfo *albumInfo); + +public: + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); + virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev); + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item); +}; + + +#endif /*__CATEGORY_SONGS_LAYOUT_H__*/ \ No newline at end of file diff --git a/include/define.h b/include/define.h index 27ae431..5a056d9 100644 --- a/include/define.h +++ b/include/define.h @@ -241,6 +241,9 @@ #define MUSIC_CATEGORY_ARTIST_LAYOUT "MUSIC_CATEGORY_ARTIST_LAYOUT" #define MUSIC_CATEGORY_GENRE_LAYOUT "MUSIC_CATEGORY_GENRE_LAYOUT" #define MUSIC_CATEGORY_PLAYLISTS_LAYOUT "MUSIC_CATEGORY_PLAYLISTS_LAYOUT" +#define MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT "MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT" +#define MUSIC_CATEGORY_GENRE_SONGS_LAYOUT "MUSIC_CATEGORY_GENRE_SONGS_LAYOUT" +#define MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT "MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT" #define MUSIC_CATEGORY_ALBUM_LAYOUT "MUSIC_CATEGORY_ALBUM_LAYOUT" #define MUSIC_CATEGORY_SONGS_LAYOUT "MUSIC_CATEGORY_SONGS_LAYOUT" #define MUSIC_CATEGORY_SELECTLIST_LAYOUT "MUSIC_CATEGORY_SELECTLIST_LAYOUT" diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index 49e2a33..8247cdb 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -749,14 +749,17 @@ bool CMusicBaseView::Create(void *data) m->layoutArtist = new CArtistLayout(MUSIC_CATEGORY_ARTIST_LAYOUT); m->layoutArtist->Create(m->lmgr); + m->layoutArtist->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this); lmgr->AddLayout(m->layoutArtist); m->layoutGenre = new CGenreLayout(MUSIC_CATEGORY_GENRE_LAYOUT); m->layoutGenre->Create(m->lmgr); + m->layoutGenre->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this); lmgr->AddLayout(m->layoutGenre); m->layoutPlaylists = new CPlaylistLayout(MUSIC_CATEGORY_PLAYLISTS_LAYOUT); m->layoutPlaylists->Create(m->lmgr); + m->layoutPlaylists->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this); lmgr->AddLayout(m->layoutPlaylists); m->layoutFolder = new CFolderLayout(MUSIC_FOLDER_LAYOUT); @@ -890,7 +893,10 @@ void CMusicBaseView::t_OnUpdate(void *data) if (!layout_id) return; - if (!strcmp(layout_id, MUSIC_ALBUM_SONGS_LAYOUT)) { + if (!strcmp(layout_id, MUSIC_ALBUM_SONGS_LAYOUT) || + !strcmp(layout_id, MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT) || + !strcmp(layout_id, MUSIC_CATEGORY_GENRE_SONGS_LAYOUT) || + !strcmp(layout_id, MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT)) { m_ShowCurrentLayout(); m_UpdateCurrentLayout(true); } diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index d7a345c..a1b9134 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -39,6 +39,7 @@ #include "category-layout.h" #include "base-view.h" #include "Info.h" +#include "category-songs-layout.h" #define TOTAL_ADD_BTNS 3 #define TOTAL_SELECT_BTNS 3 @@ -49,13 +50,9 @@ enum EObjectType { CATEGORY_LAYOUT, CATEGORY_LAYOUT_GENGRID, - CATEGORY_LAYOUT_GENLIST, CATEGORY_LAYOUT_PLAY_BUTTON, CATEGORY_LAYOUT_NEXT_BUTTON, CATEGORY_LAYOUT_LAST_BUTTON, - CATEGORY_LAYOUT_SELECT_ALL_BUTTON, - CATEGORY_LAYOUT_DONE_BUTTON, - CATEGORY_LAYOUT_CANCEL_BUTTON }; enum EAddBtns { @@ -64,12 +61,6 @@ enum EAddBtns { ABTN_LAST }; -enum ESelectBtns { - SBTN_SELECT_ALL, - SBTN_DONE, - SBTN_CANCEL -}; - enum EIdType { ID_TYPE_MEDIA, ID_TYPE_MEMBER @@ -83,13 +74,15 @@ struct SBtnInfo { EObjectType type; }; +struct SCallback { + void(*cbHandleEmptyStatus)(void *cookie, bool emptyStatus); + void *cookie; +}; + struct SCategoryLayout { Evas_Object *win; Evas_Object *layout; - Evas_Object *glist; Evas_Object *add_btn[TOTAL_ADD_BTNS]; - Evas_Object *select_btn[TOTAL_SELECT_BTNS]; - Evas_Object *albumCover; Evas_Object *def_foc_btn; Eina_List *catlist; Eina_List *alblist; @@ -100,9 +93,13 @@ struct SCategoryLayout { CLayoutMgr *lmgr; CViewMgr *vmgr; CSongInfo *c_sinfo; + CCategorySongsLayout *layoutCatSongs; + SCallback callback; int total_duration; int count; + const char *catSongLayoutId; + SCategoryLayout() { memset(this, 0, sizeof(SCategoryLayout)); } @@ -141,7 +138,7 @@ void CCategoryLayout::m_OnFocusIdler(void) elm_gengrid_item_show(it, ELM_GENGRID_ITEM_SCROLLTO_IN); elm_object_item_focus_set(it, EINA_TRUE); } - else + else if (t.depth == E_DEPTH_ALBUM) elm_object_focus_set(m->def_foc_btn, EINA_TRUE); } @@ -189,193 +186,6 @@ void CCategoryLayout::m_OnEntrynameSet(const char *name) } -char *CCategoryLayout::sm_CbGetSelectlistItemText(void *data, Evas_Object *obj, const char *part) -{ - SCatItemInfo *itinfo = (SCatItemInfo *)data; - char *str = NULL; - int index; - - if (!itinfo || !obj || !part) - return NULL; - - if (!strcmp(part, "elm.text")) { - str = itinfo->sinfo->Name(); - - index = elm_genlist_item_index_get(itinfo->item); - if ((index & 1) == 1) - elm_object_item_signal_emit(itinfo->item, - MUSIC_SIGNAL_EVEN_ROW, MUSIC_BASE_VIEW); - else - elm_object_item_signal_emit(itinfo->item, - MUSIC_SIGNAL_ODD_ROW, MUSIC_BASE_VIEW); - - if (itinfo->check_status) - elm_object_item_signal_emit(itinfo->item, - MUSIC_SIGNAL_CHECK_ON, MUSIC_BASE_VIEW); - else - elm_object_item_signal_emit(itinfo->item, - MUSIC_SIGNAL_CHECK_OFF, MUSIC_BASE_VIEW); - } - else if (!strcmp(part, "elm.text1")) { - str = itinfo->sinfo->Artist(); - } - else if (!strcmp(part, "elm.text2")) { - str = itinfo->sinfo->Album(); - } - - if (str) - return strdup(str); - - return NULL; -} - - -char *CCategoryLayout::sm_CbGetListItemText(void *data, Evas_Object *obj, const char *part) -{ - SCatItemInfo *itinfo = (SCatItemInfo *)data; - CSongInfo *sinfo = NULL; - char buf[MAX_LENGTH]; - char *timestr = NULL; - int duration; - int index; - - if (!itinfo || !obj || !part) - return NULL; - - sinfo = itinfo->sinfo; - - snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY); - - if (!strcmp(part, "elm.text")) { - index = elm_genlist_item_index_get(itinfo->item); - if ((index & 1) == 1) { - elm_object_item_signal_emit(itinfo->item, - MUSIC_SIGNAL_EVEN_ROW, MUSIC_BASE_VIEW); - } - else { - elm_object_item_signal_emit(itinfo->item, - MUSIC_SIGNAL_ODD_ROW, MUSIC_BASE_VIEW); - } - snprintf(buf, sizeof(buf), "%d", index); - } - else if (!strcmp(part, "elm.text1")) { - snprintf(buf, sizeof(buf), "%s", sinfo->Name()); - } - else if (!strcmp(part, "elm.text2")) { - snprintf(buf, sizeof(buf), "%s", sinfo->Artist()); - } - else if (!strcmp(part, "elm.text3")) { - duration = sinfo->Duration(); - timestr = _get_timestr_from_milseconds(duration); - if (timestr) { - snprintf(buf, sizeof(buf), "%s", timestr); - free(timestr); - } - } - - if (strcmp(buf, MUSIC_STR_EMPTY)) - return strdup(buf); - - return NULL; -} - - -void CCategoryLayout::sm_CbRemoveListItem(void *data, Evas_Object *obj) -{ - free(data); -} - - -void CCategoryLayout::sm_CbSongItemSelect(void *data, Evas_Object *obj, void *event_info) -{ - CCategoryLayout *root = (CCategoryLayout *)data; - if (root) - root->m_OnSongItemSelect(obj, (Elm_Object_Item *)event_info); -} - - -void CCategoryLayout::m_OnSongItemSelect(Evas_Object *obj, Elm_Object_Item *event_info) -{ - SCatItemInfo *itinfo = NULL; - char *id = NULL; - - if (!m || !obj) - return; - - itinfo = m_FindItemInfo(m->it_infolist, (Elm_Object_Item *)event_info); - if (!itinfo) { - _ERR(" no item info found "); - return; - } - - if (!m->c_sinfo) { - m->c_sinfo = new CSongInfo; - } - - if (!m->c_sinfo->FlagCreate()) { - m->c_sinfo->Create(); - } - - m->c_sinfo->Duplicate(itinfo->sinfo); - if (!m->c_sinfo) - return; - - id = m->c_sinfo->Id(); - if (!id) { - m->c_sinfo->Destroy(); - delete m->c_sinfo; - m->c_sinfo = NULL; - return; - } - - m_GotoPlayback(ADD_TYPE_FRESH, id); -} - - -void CCategoryLayout::sm_CbSelectlistItemSelect(void *data, Evas_Object *obj, void *event_info) -{ - CCategoryLayout *root = (CCategoryLayout *)data; - if (root) - root->m_OnSelectlistItemSelect(obj, (Elm_Object_Item *)event_info); -} - - -void CCategoryLayout::m_OnSelectlistItemSelect(Evas_Object *obj, Elm_Object_Item *event_info) -{ - SCatItemInfo *itinfo = NULL; - int tc; - - if (!obj) - return; - - itinfo = m_FindItemInfo(m->it_infolist, (Elm_Object_Item *)event_info); - if (!itinfo) { - _ERR(" no item info found "); - return; - } - - tc = eina_list_count(m->it_infolist); - if (itinfo->check_status) { - if (tc == m->count) - elm_object_text_set(m->select_btn[SBTN_SELECT_ALL], - _(MUSIC_TEXT_SELECT_ALL)); - m->count = m->count - 1; - elm_object_item_signal_emit(itinfo->item, - MUSIC_SIGNAL_CHECK_OFF, MUSIC_BASE_VIEW); - itinfo->check_status = false; - } - else { - m->count = m->count + 1; - if (tc == m->count) - elm_object_text_set(m->select_btn[SBTN_SELECT_ALL], - _(MUSIC_TEXT_DESELECT_ALL)); - elm_object_item_signal_emit(itinfo->item, - MUSIC_SIGNAL_CHECK_ON, MUSIC_BASE_VIEW); - itinfo->check_status = true; - } -} - - void CCategoryLayout::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid) { CCategoryLayout *root = (CCategoryLayout *)dt; @@ -819,54 +629,6 @@ Eina_List *CCategoryLayout::m_GetSelectedList(Eina_List *infolist, int type) } -void CCategoryLayout::m_AddSelectedSongs(void) -{ - Eina_List *idlist = NULL; - int lid; - - if (!t.c_catinfo || !t.c_catinfo->FlagCreate()) - return; - - lid = t.c_catinfo->CategoryId(); - idlist = m_GetSelectedList(m->it_infolist, (int)ID_TYPE_MEDIA); - - if (!lid || !idlist) - return; - - if (!m->pMusicController->MediaAddmediaPlaylist(lid, idlist)) { - _ERR(" Failed to add songs to playlist "); - return; - } - - t.depth = E_DEPTH_CATEGORY; - t_UpdateLayoutWithFocus(); -} - - -void CCategoryLayout::m_RemoveSelectedSongs(void) -{ - Eina_List *idlist = NULL; - int lid; - - if (!t.c_catinfo || !t.c_catinfo->FlagCreate()) - return; - - lid = t.c_catinfo->CategoryId(); - idlist = m_GetSelectedList(m->it_infolist, (int)ID_TYPE_MEMBER); - - if (!lid || !idlist) - return; - - if (!m->pMusicController->MediaRemovemediaPlaylist(lid, idlist)) { - _ERR(" Failed to remove songs from playlist "); - return; - } - - t.depth = E_DEPTH_CATEGORY; - t_UpdateLayoutWithFocus(); -} - - void CCategoryLayout::m_AddAlbumsToPlayback(int mode) { Eina_List *l = NULL, *sl = NULL; @@ -927,21 +689,6 @@ void CCategoryLayout::m_AddSongsToPlayback(int mode) } -Evas_Object *CCategoryLayout::m_AddAlbumCover(void) -{ - Evas_Object *album_cover = NULL; - - album_cover = elm_image_add(Layout()); - if (!album_cover) - return NULL; - - evas_object_size_hint_weight_set(album_cover, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - - return album_cover; -} - - Evas_Object *CCategoryLayout::m_AddGrid(void) { Evas_Object *grid = NULL; @@ -1046,196 +793,6 @@ void CCategoryLayout::m_AddButtons(void) } -void CCategoryLayout::m_AddSelectlistButtons(void) -{ - int i; - Evas_Object *btn = NULL; - SBtnInfo btninfo[TOTAL_SELECT_BTNS]; - - btninfo[SBTN_SELECT_ALL].name = MUSIC_TEXT_SELECT_ALL; - btninfo[SBTN_SELECT_ALL].part = MUSIC_PART_LIST_SELECT_ALL; - btninfo[SBTN_SELECT_ALL].style = MUSIC_STYLE_LIST_BTN; - btninfo[SBTN_SELECT_ALL].type = CATEGORY_LAYOUT_SELECT_ALL_BUTTON; - - btninfo[SBTN_DONE].name = MUSIC_TEXT_LIST_DONE; - btninfo[SBTN_DONE].part = MUSIC_PART_LIST_DONE_BTN; - btninfo[SBTN_DONE].style = MUSIC_STYLE_LIST_BTN; - btninfo[SBTN_DONE].type = CATEGORY_LAYOUT_DONE_BUTTON; - - btninfo[SBTN_CANCEL].name = MUSIC_TEXT_LIST_CANCEL; - btninfo[SBTN_CANCEL].part = MUSIC_PART_LIST_CANCEL_BTN; - btninfo[SBTN_CANCEL].style = MUSIC_STYLE_LIST_BTN; - btninfo[SBTN_CANCEL].type = CATEGORY_LAYOUT_CANCEL_BUTTON; - - if (t.sel_type == SELECT_CREATE) { - elm_object_part_text_set(Layout(), MUSIC_PART_LIST_MSG, - _(MUSIC_TEXT_LIST_CREATE_MSG)); - } - else if (t.sel_type == SELECT_ADD) { - elm_object_part_text_set(Layout(), MUSIC_PART_LIST_MSG, - _(MUSIC_TEXT_LIST_ADD_MSG)); - } - else if (t.sel_type == SELECT_REMOVE) { - elm_object_part_text_set(Layout(), MUSIC_PART_LIST_MSG, - _(MUSIC_TEXT_LIST_REMOVE_MSG)); - } - - for (i = 0; i < TOTAL_SELECT_BTNS; i++) { - btn = elm_button_add(Layout()); - if (!btn) - continue; - - evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - elm_object_text_set(btn, _(btninfo[i].name)); - elm_object_style_set(btn, btninfo[i].style); - - Connect(btn, btninfo[i].type, TYPE_MOUSE_MOVE | TYPE_CLICKED); - - elm_object_part_content_set(Layout(), btninfo[i].part, btn); - m->select_btn[i] = btn; - } - - elm_object_focus_set(btn, EINA_TRUE); - m->def_foc_btn = btn; -} - - -void CCategoryLayout::m_CreateSongsTopSection(void) -{ - char *path = NULL; - char buf[MAX_LENGTH]; - - m_AddButtons(); - - m->albumCover = m_AddAlbumCover(); - if (!m->albumCover) - return; - - if (t.depth == E_DEPTH_SHOW_LIST) - path = t.c_catinfo->ThumbnailPath(); - else - path = t.c_alinfo->ThumbnailPath(); - - if (path) { - elm_image_file_set(m->albumCover, path, NULL); - elm_image_aspect_fixed_set(m->albumCover, EINA_FALSE); - } - else { - snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, - MUSIC_IMAGE_DEFAULT_THUMB_126); - elm_image_file_set(m->albumCover, buf, NULL); - elm_image_no_scale_set(m->albumCover, EINA_TRUE); - } - elm_object_part_content_set(Layout(), MUSIC_PART_ALBUM_THUMB, m->albumCover); - - if (t.depth == E_DEPTH_SHOW_LIST) { - elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_NAME, - t.c_catinfo->Name()); - } - else { - elm_object_part_text_set(Layout(), - MUSIC_PART_CATEGORY_NAME, - t.c_catinfo->Name()); - elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_NAME, - t.c_alinfo->Name()); - elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_ARTIST, - t.c_alinfo->Artist()); - } - - snprintf(buf, sizeof(buf), "%d %s", - m_ConvertToMin(m->total_duration), _("min")); - elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_TIME, buf); - snprintf(buf, sizeof(buf), "%d", eina_list_count(m->songlist)); - elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_SONGCOUNT, buf); -} - - -void CCategoryLayout::m_CreateSongList(void) -{ - Evas_Object *genlist = NULL; - Elm_Genlist_Item_Class *list_item = NULL; - bool r; - CSongInfo *sinfo = NULL; - void *obj = NULL; - Eina_List *l = NULL; - SCatItemInfo *itinfo = NULL; - Elm_Object_Item *item = NULL; - int dur; - void (*item_select_fn)(void *, Evas_Object *, void *) = NULL; - - genlist = elm_genlist_add(Layout()); - if (!genlist) - return; - - elm_genlist_homogeneous_set(genlist, EINA_TRUE); - - evas_object_size_hint_weight_set(genlist, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_part_content_set(Layout(), MUSIC_PART_SONGLIST, genlist); - - Connect(genlist, CATEGORY_LAYOUT_GENLIST, TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_ACTIVATED); - - m->glist = genlist; - - list_item = elm_genlist_item_class_new(); - if (!list_item) { - evas_object_del(genlist); - _ERR(" elm_genlist_item_class_new failed "); - return; - } - list_item->func.content_get = NULL; - list_item->func.state_get = NULL; - list_item->func.del = sm_CbRemoveListItem; - m->count = 0; - - if (t.depth == E_DEPTH_SELECT_LIST) { - list_item->func.text_get = sm_CbGetSelectlistItemText; - list_item->item_style = MUSIC_STYLE_SELECT_LIST; - item_select_fn = sm_CbSelectlistItemSelect; - if (t.sel_type == SELECT_REMOVE) { - r = m->pMusicController->MediaGetList(LIST_TYPE_PLAYLISTS_SONG, t.c_catinfo, &(m->songlist)); - } - else { - r = m->pMusicController->MediaGetList(LIST_TYPE_SONG, NULL, &(m->songlist)); - } - } - else { - list_item->func.text_get = sm_CbGetListItemText; - list_item->item_style = MUSIC_STYLE_ALBUM_SONGLIST; - item_select_fn = sm_CbSongItemSelect; - if (t.depth == E_DEPTH_SHOW_LIST) - r = m->pMusicController->MediaGetList(LIST_TYPE_PLAYLISTS_SONG, t.c_catinfo, &(m->songlist)); - else - r = m->pMusicController->MediaGetList(LIST_TYPE_ALBUM_SONG, t.c_alinfo, &(m->songlist)); - } - - if (r == false) { - _ERR(" Fetching song list from media failed "); - evas_object_del(genlist); - elm_genlist_item_class_free(list_item); - return; - } - - EINA_LIST_FOREACH(m->songlist, l, obj) { - sinfo = (CSongInfo *)obj; - itinfo = (SCatItemInfo *)calloc(1, sizeof(*itinfo)); - if (!itinfo) - return; - - itinfo->sinfo = sinfo; - item = elm_genlist_item_append(genlist, list_item, - itinfo, NULL, ELM_GENLIST_ITEM_NONE, - item_select_fn, this); - itinfo->item = item; - m->it_infolist = eina_list_append(m->it_infolist, itinfo); - dur = sinfo->Duration(); - m->total_duration = m->total_duration + dur; - } - elm_genlist_item_class_free(list_item); -} - - void CCategoryLayout::m_CreateAlbumgrid(void) { CAlbumInfo *alinfo = NULL; @@ -1246,9 +803,11 @@ void CCategoryLayout::m_CreateAlbumgrid(void) char buf[MAX_LENGTH]; Elm_Gengrid_Item_Class *grid_item = NULL; - t.grid = m_AddGrid(); - if (!t.grid) - return; + if (!t.grid) { + t.grid = m_AddGrid(); + if (!t.grid) + return; + } grid_item = elm_gengrid_item_class_new(); if (!grid_item) { @@ -1306,9 +865,11 @@ void CCategoryLayout::m_CreateCatgrid(bool sort_flag) Eina_List *l = NULL; Elm_Gengrid_Item_Class *grid_item = NULL; - t.grid = m_AddGrid(); - if (!t.grid) - return; + if (!t.grid) { + t.grid = m_AddGrid(); + if (!t.grid) + return; + } grid_item = elm_gengrid_item_class_new(); if (!grid_item) { @@ -1368,13 +929,7 @@ void CCategoryLayout::m_SortCatgrid(void) void CCategoryLayout::m_EmptyLayout(bool sort_flag) { if (t.grid) { - evas_object_del(t.grid); - t.grid = NULL; - } - - if (m->glist) { - evas_object_del(m->glist); - m->glist = NULL; + elm_gengrid_clear(t.grid); } if (!sort_flag) { @@ -1408,16 +963,23 @@ void CCategoryLayout::m_EmptyLayout(bool sort_flag) evas_object_del(m->add_btn[i]); m->add_btn[i] = NULL; } +} + + +void CCategoryLayout::m_ShowCategorySongs(void) +{ + elm_object_part_content_unset(t.base, MUSIC_PART_CONTENT); + + bool emptyStatus = m->layoutCatSongs->EmptyStatus(); - for (i = 0; i < TOTAL_SELECT_BTNS; i++) { - if (m->select_btn[i]) - evas_object_del(m->select_btn[i]); - m->select_btn[i] = NULL; + if (emptyStatus == false) { + elm_object_part_content_set(t.base, MUSIC_PART_CONTENT, m->layoutCatSongs->Layout()); + m->lmgr->Show(m->catSongLayoutId); } - if (m->albumCover) - evas_object_del(m->albumCover); - m->albumCover = NULL; + if (m->callback.cbHandleEmptyStatus != NULL) { + m->callback.cbHandleEmptyStatus(m->callback.cookie, emptyStatus); + } } @@ -1442,12 +1004,8 @@ void CCategoryLayout::t_UpdateLayout(bool sort_flag) parcel.ctxtInfo = NULL; if (t.depth == E_DEPTH_SONG) { - if (!t_SetEdje(MUSIC_CATEGORY_SONGS_LAYOUT)) { - _ERR(" get layout failed "); - return; - } - m_CreateSongList(); - m_CreateSongsTopSection(); + m->layoutCatSongs->SetParameter(CCategorySongsLayout::DEPTH_SONG_LIST, (CCategorySongsLayout::ESelectType)t.sel_type, t.c_catinfo, t.c_alinfo); + m_ShowCategorySongs(); parcel.updateType = E_LAYOUT_UPDATE; parcel.layoutId = MUSIC_CATEGORY_SONGS_LAYOUT; @@ -1455,12 +1013,8 @@ void CCategoryLayout::t_UpdateLayout(bool sort_flag) m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); } else if (t.depth == E_DEPTH_SHOW_LIST) { - if (!t_SetEdje(MUSIC_ALBUM_SONGS_LAYOUT)) { - _ERR(" get layout failed "); - return; - } - m_CreateSongList(); - m_CreateSongsTopSection(); + m->layoutCatSongs->SetParameter(CCategorySongsLayout::DEPTH_SHOW_LIST, (CCategorySongsLayout::ESelectType)t.sel_type, t.c_catinfo, t.c_alinfo); + m_ShowCategorySongs(); parcel.updateType = E_LAYOUT_UPDATE; parcel.layoutId = MUSIC_CATEGORY_SONGS_LAYOUT; @@ -1481,19 +1035,13 @@ void CCategoryLayout::t_UpdateLayout(bool sort_flag) m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); } else if (t.depth == E_DEPTH_SELECT_LIST) { - if (!t_SetEdje(MUSIC_CATEGORY_SELECTLIST_LAYOUT)) { - _ERR(" get layout failed "); - return; - } - m_CreateSongList(); - m_AddSelectlistButtons(); + m->layoutCatSongs->SetParameter(CCategorySongsLayout::DEPTH_SELECT_LIST, (CCategorySongsLayout::ESelectType)t.sel_type, t.c_catinfo, t.c_alinfo); + m_ShowCategorySongs(); parcel.updateType = E_LAYOUT_UPDATE; parcel.layoutId = MUSIC_CATEGORY_SELECTLIST_LAYOUT; parcel.keyEvent = NULL; m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); - elm_object_focus_next_object_set(m->glist, - m->select_btn[SBTN_DONE], ELM_FOCUS_RIGHT); } else { if (!t_SetEdje(MUSIC_CATEGORY_LAYOUT)) { @@ -1512,12 +1060,20 @@ void CCategoryLayout::t_UpdateLayout(bool sort_flag) void CCategoryLayout::t_UpdateLayoutWithFocus(void) { - elm_object_tree_focus_allow_set(t.base, EINA_FALSE); + bool needFocusIdler = false; + + if (t.depth == E_DEPTH_ALBUM || t.depth == E_DEPTH_CATEGORY) + needFocusIdler = true; + + if (needFocusIdler) + elm_object_tree_focus_allow_set(t.base, EINA_FALSE); t_UpdateLayout(false); - evas_object_show(Layout()); - m_RemoveFocusIdler(); - m->focus_idler = ecore_idler_add(sm_CbFocusIdler, this); + + if (needFocusIdler) { + m_RemoveFocusIdler(); + m->focus_idler = ecore_idler_add(sm_CbFocusIdler, this); + } } @@ -1601,12 +1157,46 @@ bool CCategoryLayout::Create(CLayoutMgr *mgr) return false; } + if (!strcmp(LayoutId(), MUSIC_CATEGORY_ARTIST_LAYOUT)) + m->catSongLayoutId = MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT; + else if (!strcmp(LayoutId(), MUSIC_CATEGORY_GENRE_LAYOUT)) + m->catSongLayoutId = MUSIC_CATEGORY_GENRE_SONGS_LAYOUT; + else if (!strcmp(LayoutId(), MUSIC_CATEGORY_PLAYLISTS_LAYOUT)) + m->catSongLayoutId = MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT; + + m->layoutCatSongs = new CCategorySongsLayout((const char *)m->catSongLayoutId); + if (!m->layoutCatSongs) { + _ERR(" Memory alloc failed "); + delete t.epopup; + CExtBaseLayout::Destroy(); + evas_object_del(layout); + delete m; + m = NULL; + return false; + } + + r = m->layoutCatSongs->Create(mgr, this); + if (!r) { + _ERR(" CCategorySongsLayout creation failed "); + delete m->layoutCatSongs; + delete t.epopup; + CExtBaseLayout::Destroy(); + evas_object_del(layout); + delete m; + m = NULL; + return false; + } + + mgr->AddLayout(m->layoutCatSongs); + m->win = win; t.base = base; m->vmgr = vmgr; m->pMusicController = pMusicController; m->lmgr = mgr; t.depth = E_DEPTH_CATEGORY; + m->callback.cbHandleEmptyStatus = NULL; + m->callback.cookie = NULL; t_UpdateLayout(false); @@ -1621,8 +1211,13 @@ void CCategoryLayout::Destroy(void) ASSERT(m); Disconnect(Layout()); + + m->layoutCatSongs->Destroy(); + delete m->layoutCatSongs; + if (t.epopup->FlagCreate()) t.epopup->Destroy(); + delete t.epopup; m_RemoveFocusIdler(); m_EmptyLayout(false); @@ -1635,11 +1230,6 @@ void CCategoryLayout::Destroy(void) t.c_alinfo->Destroy(); delete t.c_alinfo; - if (m->c_sinfo && m->c_sinfo->FlagCreate()) - m->c_sinfo->Destroy(); - delete m->c_sinfo; - - delete t.epopup; CExtBaseLayout::Destroy(); evas_object_del(Layout()); @@ -1673,6 +1263,26 @@ void CCategoryLayout::Update(bool focusFlag) } +void CCategoryLayout::CreateEntryPopup(void) +{ + ASSERT(m); + + if (t.epopup->FlagCreate()) + t.epopup->Destroy(); + + t.epopup->Create(t.base, MUSIC_STR_EMPTY, sm_CbEntrynameSet, this); +} + + +void CCategoryLayout::SetEmptyStatusHandleCallback(void(*handleEmptyStatusCb)(void *cookie, bool emptyStatus), void *cookie) +{ + ASSERT(m); + + m->callback.cbHandleEmptyStatus = handleEmptyStatusCb; + m->callback.cookie = cookie; +} + + void CCategoryLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { switch (id) { @@ -1718,7 +1328,6 @@ void CCategoryLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Ke break; case CATEGORY_LAYOUT_GENGRID: - case CATEGORY_LAYOUT_GENLIST: { Elm_Object_Item *it = NULL; SContentInfo *ctxtinfo = NULL; @@ -1806,110 +1415,6 @@ void CCategoryLayout::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_ } break; - case CATEGORY_LAYOUT_GENLIST: - { - Elm_Object_Item *item; - - if (!obj) - return; - - item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x, - ev->cur.canvas.y, NULL); - - if (!elm_object_item_focus_get(item)) - elm_object_item_focus_set(item, EINA_TRUE); - } - break; - - case CATEGORY_LAYOUT_PLAY_BUTTON: - case CATEGORY_LAYOUT_NEXT_BUTTON: - case CATEGORY_LAYOUT_LAST_BUTTON: - case CATEGORY_LAYOUT_SELECT_ALL_BUTTON: - case CATEGORY_LAYOUT_DONE_BUTTON: - case CATEGORY_LAYOUT_CANCEL_BUTTON: - if (!elm_object_focus_get(obj)) - elm_object_focus_set(obj, EINA_TRUE); - break; - - default: - break; - } -} - - -void CCategoryLayout::OnMouseClicked(int id, Evas_Object *obj) -{ - switch (id) { - case CATEGORY_LAYOUT_PLAY_BUTTON: - m_GotoPlayback(ADD_TYPE_FRESH, NULL); - break; - - case CATEGORY_LAYOUT_NEXT_BUTTON: - m_GotoPlayback(ADD_TYPE_NEXT, NULL); - break; - - case CATEGORY_LAYOUT_LAST_BUTTON: - m_GotoPlayback(ADD_TYPE_END, NULL); - break; - - case CATEGORY_LAYOUT_SELECT_ALL_BUTTON: - { - Eina_List *l = NULL; - SCatItemInfo *itinfo = NULL; - void *list_obj = NULL; - int tc; - - tc = eina_list_count(m->it_infolist); - - if (m->count == tc) { - elm_object_text_set(m->select_btn[SBTN_SELECT_ALL], - _(MUSIC_TEXT_SELECT_ALL)); - m->count = 0; - EINA_LIST_FOREACH(m->it_infolist, l, list_obj) { - itinfo = (SCatItemInfo *)list_obj; - itinfo->check_status = false; - } - elm_genlist_realized_items_update(m->glist); - - return; - } - - elm_object_text_set(m->select_btn[SBTN_SELECT_ALL], - _(MUSIC_TEXT_DESELECT_ALL)); - m->count = tc; - EINA_LIST_FOREACH(m->it_infolist, l, list_obj) { - itinfo = (SCatItemInfo *)list_obj; - itinfo->check_status = true; - } - elm_genlist_realized_items_update(m->glist); - } - break; - - case CATEGORY_LAYOUT_DONE_BUTTON: - { - if (t.sel_type == SELECT_ADD) { - m_AddSelectedSongs(); - return; - } - else if (t.sel_type == SELECT_REMOVE) { - m_RemoveSelectedSongs(); - return; - } - - if (t.epopup->FlagCreate()) - t.epopup->Destroy(); - - t.epopup->Create(t.base, MUSIC_STR_EMPTY, sm_CbEntrynameSet, this); - } - break; - - case CATEGORY_LAYOUT_CANCEL_BUTTON: - { - t.depth = E_DEPTH_CATEGORY; - t_UpdateLayoutWithFocus(); - } - break; - default: break; } @@ -1953,15 +1458,6 @@ void CCategoryLayout::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *ite m_OnItemSelect(item, NULL, NULL); break; - case CATEGORY_LAYOUT_GENLIST: - { - if (t.depth == E_DEPTH_SELECT_LIST) - m_OnSelectlistItemSelect(obj, item); - else - m_OnSongItemSelect(obj, item); - } - break; - default: break; } diff --git a/src/views/category-songs-layout.cpp b/src/views/category-songs-layout.cpp new file mode 100644 index 0000000..7d40d26 --- /dev/null +++ b/src/views/category-songs-layout.cpp @@ -0,0 +1,1222 @@ +/* +* Copyright (c) 2014 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. +*/ + +#include +#include +#include +#include "AppCommon.h" +#include "dbg.h" +#include "i18n.h" +#include "define.h" +#include "song_info.h" +#include "album_info.h" +#include "category_info.h" +#include "music-controller.h" +#include "LayoutMgr.h" +#include "common.h" +#include "common-ui.h" +#include "BaseView.h" +#include "ExtBaseLayout.h" +#include "ViewMgr.h" +#include "InputHandler.h" +#include "category-songs-layout.h" +#include "base-view.h" +#include "category-layout.h" + +#define TOTAL_ADD_BTNS 3 +#define TOTAL_SELECT_BTNS 3 + + +enum EObjectType { + CATEGORY_SONGS_LAYOUT, + CATEGORY_SONGS_GENLIST, + CATEGORY_SONGS_PLAY_BUTTON, + CATEGORY_SONGS_NEXT_BUTTON, + CATEGORY_SONGS_LAST_BUTTON, + CATEGORY_SONGS_SELECT_ALL_BUTTON, + CATEGORY_SONGS_DONE_BUTTON, + CATEGORY_SONGS_CANCEL_BUTTON +}; + +enum EAddBtns { + ABTN_PLAY, + ABTN_NEXT, + ABTN_LAST +}; + +enum ESelectBtns { + SBTN_SELECT_ALL, + SBTN_DONE, + SBTN_CANCEL +}; + +enum EIdType { + ID_TYPE_MEDIA, + ID_TYPE_MEMBER +}; + +struct SCategorySongsItemsInfo { + CSongInfo *sinfo; + Elm_Object_Item *item; + bool check_status; +}; + +struct SCategorySongsLayout { + Evas_Object *win; + Evas_Object *base; + Evas_Object *songlist; + Elm_Object_Item *focused_item; + Evas_Object *add_btn[TOTAL_ADD_BTNS]; + Evas_Object *select_btn[TOTAL_SELECT_BTNS]; + Evas_Object *def_foc_btn; + Evas_Object *albumCover; + Ecore_Idler *focus_idler; + + CMusicController* mhandle; + CLayoutMgr *mgr; + CViewMgr *vmgr; + SContentInfo *ctxtinfo; + Eina_List *slist; + Eina_List *it_infolist; + Elm_Genlist_Item_Class *item_class; + int total_duration; + CCategoryLayout *parent; + int count; + + CCategorySongsLayout::EDepth depth; + CCategorySongsLayout::ESelectType selectType; + CCategoryInfo *catInfo; + CAlbumInfo *albumInfo; + + SCategorySongsLayout() { + memset(this, 0, sizeof(SCategorySongsLayout)); + } + + ~SCategorySongsLayout() { + } +}; + + +struct SBtnInfo { + const char *name; + const char *part; + const char *style; + const char *icon; + EObjectType type; +}; + + +Eina_Bool CCategorySongsLayout::sm_CbFocusIdler(void *dt) +{ + CCategorySongsLayout *root = (CCategorySongsLayout *)dt; + + if (root) + root->m_OnFocusIdler(); + + return ECORE_CALLBACK_CANCEL; +} + + +void CCategorySongsLayout::m_OnFocusIdler(void) +{ + m->focus_idler = NULL; + elm_object_tree_focus_allow_set(m->base, EINA_TRUE); + elm_object_focus_set(m->def_foc_btn, EINA_TRUE); +} + + +char *CCategorySongsLayout::sm_CbGetSelectlistItemText(void *data, Evas_Object *obj, const char *part) +{ + SCategorySongsItemsInfo *itinfo = (SCategorySongsItemsInfo *)data; + char *str = NULL; + int index; + + if (!itinfo || !obj || !part) + return NULL; + + if (!strcmp(part, "elm.text")) { + str = itinfo->sinfo->Name(); + + index = elm_genlist_item_index_get(itinfo->item); + if ((index & 1) == 1) + elm_object_item_signal_emit(itinfo->item, + MUSIC_SIGNAL_EVEN_ROW, MUSIC_BASE_VIEW); + else + elm_object_item_signal_emit(itinfo->item, + MUSIC_SIGNAL_ODD_ROW, MUSIC_BASE_VIEW); + + if (itinfo->check_status) + elm_object_item_signal_emit(itinfo->item, + MUSIC_SIGNAL_CHECK_ON, MUSIC_BASE_VIEW); + else + elm_object_item_signal_emit(itinfo->item, + MUSIC_SIGNAL_CHECK_OFF, MUSIC_BASE_VIEW); + } + else if (!strcmp(part, "elm.text1")) { + str = itinfo->sinfo->Artist(); + } + else if (!strcmp(part, "elm.text2")) { + str = itinfo->sinfo->Album(); + } + + if (str) + return strdup(str); + + return NULL; +} + + + +char *CCategorySongsLayout::sm_CbGetListItemText(void *data, Evas_Object *obj, const char *part) +{ + SCategorySongsItemsInfo *itinfo = (SCategorySongsItemsInfo *)data; + CSongInfo *sinfo = NULL; + char buf[MAX_LENGTH]; + char *timestr = NULL; + int duration; + int index; + + if (!itinfo || !obj) + return NULL; + + sinfo = itinfo->sinfo; + + snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY); + + if (!strcmp(part, "elm.text")) { + index = elm_genlist_item_index_get(itinfo->item); + if ((index & 1) == 1) { + elm_object_item_signal_emit(itinfo->item, + MUSIC_SIGNAL_EVEN_ROW, MUSIC_BASE_VIEW); + } + else { + elm_object_item_signal_emit(itinfo->item, + MUSIC_SIGNAL_ODD_ROW, MUSIC_BASE_VIEW); + } + snprintf(buf, sizeof(buf), "%d", index); + } + else if (!strcmp(part, "elm.text1")) + snprintf(buf, sizeof(buf), "%s", sinfo->Name()); + else if (!strcmp(part, "elm.text2")) + snprintf(buf, sizeof(buf), "%s", sinfo->Artist()); + else if (!strcmp(part, "elm.text3")) { + duration = sinfo->Duration(); + timestr = _get_timestr_from_milseconds(duration); + if (timestr) { + snprintf(buf, sizeof(buf), "%s", timestr); + free(timestr); + } + } + + if (strcmp(buf, MUSIC_STR_EMPTY)) + return strdup(buf); + + return NULL; +} + + +void CCategorySongsLayout::sm_CbRemoveListItem(void *data, Evas_Object *obj) +{ + free(data); +} + + +void CCategorySongsLayout::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid) +{ + CCategorySongsLayout *root = (CCategorySongsLayout*)dt; + + if (root) + root->m_OnCtxtUpdate(type, lid); +} + + +void CCategorySongsLayout::m_OnCtxtUpdate(EActionType type, int lid) +{ + Eina_List *list = NULL; + EAddType mode; + + if (!m->ctxtinfo || !m->ctxtinfo->context) + return; + + if (type == ACTION_TYPE_ADDNEXT) + mode = ADD_TYPE_NEXT; + else + mode = ADD_TYPE_END; + + list = eina_list_append(list, m->ctxtinfo->context); + if (type == ACTION_TYPE_ADDTO) { + if (!m->mhandle->MediaAddsongsPlaylist(lid, list)) + _ERR(" Adding songs to playlist failed "); + else + _create_message_box(m->base, MUSIC_TEXT_ADDTO_MSG); + + return; + } + + m->mhandle->UpdatePlaylist(list, mode); + eina_list_free(list); + + if (type == ACTION_TYPE_PLAY) { + m->mhandle->Stop(); + m->mhandle->SetCurrentSong(((CSongInfo *)m->ctxtinfo->context)->Id()); + } + + _update_playback_view((EAddType)type, Layout(), m->focused_item); +} + + +void CCategorySongsLayout::sm_CbCtxtClose(void *dt) +{ + CCategorySongsLayout *root = (CCategorySongsLayout*)dt; + + if (root) + root->m_OnCtxtClose(); +} + + +void CCategorySongsLayout::m_OnCtxtClose(void) +{ + m->vmgr->PopView(); + m->vmgr->PushView(MUSIC_BASE_VIEW, NULL); + elm_object_item_focus_set(m->focused_item, EINA_TRUE); +} + + +void CCategorySongsLayout::sm_CbSongItemSelect(void *data, Evas_Object *obj, void *event_info) +{ + CCategorySongsLayout *root = (CCategorySongsLayout *)data; + if (root) + root->m_OnSongItemSelect(obj, (Elm_Object_Item *)event_info); +} + + +void CCategorySongsLayout::m_OnSongItemSelect(Evas_Object *obj, Elm_Object_Item *event_info) +{ + SCategorySongsItemsInfo *itinfo = NULL; + char *id = NULL; + + if (!m || !obj) + return; + + itinfo = m_FindItemInfoFromItem(m->it_infolist, (Elm_Object_Item *)event_info); + if (!itinfo) { + _ERR(" no item info found "); + return; + } + + id = itinfo->sinfo->Id(); + if (!id) { + return; + } + + m_GotoPlayback(ADD_TYPE_FRESH, id); +} + + +void CCategorySongsLayout::sm_CbSelectlistItemSelect(void *data, Evas_Object *obj, void *event_info) +{ + CCategorySongsLayout *root = (CCategorySongsLayout *)data; + if (root) + root->m_OnSelectlistItemSelect(obj, (Elm_Object_Item *)event_info); +} + + +void CCategorySongsLayout::m_OnSelectlistItemSelect(Evas_Object *obj, Elm_Object_Item *event_info) +{ + SCategorySongsItemsInfo *itinfo = NULL; + int tc; + + if (!obj) + return; + + itinfo = m_FindItemInfoFromItem(m->it_infolist, (Elm_Object_Item *)event_info); + if (!itinfo) { + _ERR(" no item info found "); + return; + } + + tc = eina_list_count(m->it_infolist); + if (itinfo->check_status) { + if (tc == m->count) + elm_object_text_set(m->select_btn[SBTN_SELECT_ALL], + _(MUSIC_TEXT_SELECT_ALL)); + m->count = m->count - 1; + elm_object_item_signal_emit(itinfo->item, + MUSIC_SIGNAL_CHECK_OFF, MUSIC_BASE_VIEW); + itinfo->check_status = false; + } + else { + m->count = m->count + 1; + if (tc == m->count) + elm_object_text_set(m->select_btn[SBTN_SELECT_ALL], + _(MUSIC_TEXT_DESELECT_ALL)); + elm_object_item_signal_emit(itinfo->item, + MUSIC_SIGNAL_CHECK_ON, MUSIC_BASE_VIEW); + itinfo->check_status = true; + } +} + + +void CCategorySongsLayout::m_RemoveFocusIdler(void) +{ + if (!m->focus_idler) + return; + + ecore_idler_del(m->focus_idler); + m->focus_idler = NULL; +} + + +SCategorySongsItemsInfo *CCategorySongsLayout::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item) +{ + Eina_List *l = NULL; + SCategorySongsItemsInfo *itinfo = NULL; + void *obj = NULL; + + EINA_LIST_FOREACH(list, l, obj) { + itinfo = (SCategorySongsItemsInfo *)obj; + if (itinfo->item == item) + return itinfo; + } + + return NULL; +} + + +void CCategorySongsLayout::m_UpdateSongList(void) +{ + CSongInfo *sinfo = NULL; + void *obj = NULL; + Eina_List *l = NULL; + SCategorySongsItemsInfo *itinfo = NULL; + Elm_Object_Item *item = NULL; + int dur = 0; + void(*item_select_fn)(void *, Evas_Object *, void *) = NULL; + + if (!m->songlist || !m->item_class) + return; + + /* Remove existing songlist and prepare afresh */ + m_EmptySongList(); + + if (m->depth == DEPTH_SELECT_LIST) { + item_select_fn = sm_CbSelectlistItemSelect; + if (m->selectType == SELECT_TYPE_REMOVE) + m->mhandle->MediaGetList(LIST_TYPE_PLAYLISTS_SONG, m->catInfo, &(m->slist)); + else + m->mhandle->MediaGetList(LIST_TYPE_SONG, NULL, &(m->slist)); + } + else { + item_select_fn = sm_CbSongItemSelect; + if (m->depth == DEPTH_SHOW_LIST) + m->mhandle->MediaGetList(LIST_TYPE_PLAYLISTS_SONG, m->catInfo, &(m->slist)); + else + m->mhandle->MediaGetList(LIST_TYPE_ALBUM_SONG, m->albumInfo, &(m->slist)); + } + + EINA_LIST_FOREACH(m->slist, l, obj) { + sinfo = (CSongInfo *)obj; + itinfo = (SCategorySongsItemsInfo *)calloc(1, sizeof(*itinfo)); + if (!itinfo) + return; + + itinfo->sinfo = sinfo; + item = elm_genlist_item_append(m->songlist, m->item_class, + itinfo, NULL, ELM_GENLIST_ITEM_NONE, item_select_fn, this); + itinfo->item = item; + m->it_infolist = eina_list_append(m->it_infolist, itinfo); + dur = sinfo->Duration(); + m->total_duration = m->total_duration + dur; + } +} + +void CCategorySongsLayout::m_EmptySongList(void) +{ + if (m->songlist) + elm_genlist_clear(m->songlist); + + if (m->slist) + eina_list_free(m->slist); + m->slist = NULL; + + if (m->it_infolist) + eina_list_free(m->it_infolist); + m->it_infolist = NULL; + + if (m->albumCover) + evas_object_del(m->albumCover); + m->albumCover = NULL; + + int i; + + for (i = 0; i < TOTAL_ADD_BTNS; i++) { + if (m->add_btn[i]) + evas_object_del(m->add_btn[i]); + m->add_btn[i] = NULL; + } + + for (i = 0; i < TOTAL_SELECT_BTNS; i++) { + if (m->select_btn[i]) + evas_object_del(m->select_btn[i]); + m->select_btn[i] = NULL; + } + + m->total_duration = 0; +} + + +int CCategorySongsLayout::m_ConvertToMin(int milsec) +{ + int min; + min = milsec / 60000; /*milli seconds per minute*/ + + return min; +} + + +void CCategorySongsLayout::m_GotoPlayback(int mode, char *id) +{ + Eina_List *list = NULL; + Eina_List *l = NULL; + SCategorySongsItemsInfo *itinfo = NULL; + void *obj = NULL; + + if (!m->it_infolist || eina_list_count(m->it_infolist) == 0) { + _ERR(" No songs for playback "); + return; + } + + EINA_LIST_FOREACH(m->it_infolist, l, obj) { + itinfo = (SCategorySongsItemsInfo *)obj; + list = eina_list_append(list, itinfo->sinfo); + } + + m->mhandle->UpdatePlaylist(list, mode); + eina_list_free(list); + + if (mode == ADD_TYPE_FRESH) { + m->mhandle->Stop(); + if (id) /* If want to play selected song */ + m->mhandle->SetCurrentSong(id); + } + + _update_playback_view((EAddType)mode, Layout(), NULL); +} + + +Evas_Object *CCategorySongsLayout::m_AddAlbumCover(void) +{ + Evas_Object *album_cover = NULL; + + album_cover = elm_image_add(Layout()); + if (!album_cover) + return NULL; + + evas_object_size_hint_weight_set(album_cover, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + + return album_cover; +} + + +void CCategorySongsLayout::m_AddButtons(void) +{ + int i; + Evas_Object *img = NULL; + char buf[MAX_LENGTH]; + SBtnInfo btninfo[TOTAL_ADD_BTNS]; + + btninfo[ABTN_PLAY].name = MUSIC_STR_PLAY; + btninfo[ABTN_PLAY].part = MUSIC_PART_CATEGORY_PLAYBTN; + btninfo[ABTN_PLAY].style = MUSIC_STYLE_ADD_PLAY_BTN; + btninfo[ABTN_PLAY].icon = MUSIC_IMAGE_ADD_PLAY; + btninfo[ABTN_PLAY].type = CATEGORY_SONGS_PLAY_BUTTON; + + btninfo[ABTN_NEXT].name = MUSIC_STR_ADDNEXT; + btninfo[ABTN_NEXT].part = MUSIC_PART_CATEGORY_NEXTBTN; + btninfo[ABTN_NEXT].style = MUSIC_STYLE_ADD_NEXT_BTN; + btninfo[ABTN_NEXT].icon = MUSIC_IMAGE_ADD_NEXT; + btninfo[ABTN_NEXT].type = CATEGORY_SONGS_NEXT_BUTTON; + + btninfo[ABTN_LAST].name = MUSIC_STR_ADDLAST; + btninfo[ABTN_LAST].part = MUSIC_PART_CATEGORY_LASTBTN; + btninfo[ABTN_LAST].style = MUSIC_STYLE_ADD_LAST_BTN; + btninfo[ABTN_LAST].icon = MUSIC_IMAGE_ADD_LAST; + btninfo[ABTN_LAST].type = CATEGORY_SONGS_LAST_BUTTON; + + if (m->depth == DEPTH_SHOW_LIST) { + btninfo[ABTN_PLAY].part = MUSIC_PART_ALBUM_PLAYBTN; + btninfo[ABTN_NEXT].part = MUSIC_PART_ALBUM_NEXTBTN; + btninfo[ABTN_LAST].part = MUSIC_PART_ALBUM_LASTBTN; + } + + for (i = 0; i < TOTAL_ADD_BTNS; i++) { + m->add_btn[i] = elm_button_add(Layout()); + if (!m->add_btn[i]) + continue; + + evas_object_size_hint_weight_set(m->add_btn[i], + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_text_set(m->add_btn[i], _(btninfo[i].name)); + elm_object_style_set(m->add_btn[i], btninfo[i].style); + + Connect(m->add_btn[i], btninfo[ABTN_LAST].type, TYPE_CLICKED | TYPE_MOUSE_MOVE); + + img = elm_image_add(m->add_btn[i]); + if (img) { + snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, + btninfo[i].icon); + elm_image_file_set(img, buf, NULL); + elm_object_part_content_set(m->add_btn[i], + MUSIC_PART_ELM_SWALLOWICON, img); + } + + elm_object_part_content_set(Layout(), btninfo[i].part, m->add_btn[i]); + } + + elm_object_focus_set(m->add_btn[ABTN_PLAY], EINA_TRUE); + m->def_foc_btn = m->add_btn[ABTN_PLAY]; +} + + +void CCategorySongsLayout::m_AddSelectlistButtons(void) +{ + int i; + Evas_Object *btn = NULL; + SBtnInfo btninfo[TOTAL_SELECT_BTNS]; + + btninfo[SBTN_SELECT_ALL].name = MUSIC_TEXT_SELECT_ALL; + btninfo[SBTN_SELECT_ALL].part = MUSIC_PART_LIST_SELECT_ALL; + btninfo[SBTN_SELECT_ALL].style = MUSIC_STYLE_LIST_BTN; + btninfo[SBTN_SELECT_ALL].type = CATEGORY_SONGS_SELECT_ALL_BUTTON; + + btninfo[SBTN_DONE].name = MUSIC_TEXT_LIST_DONE; + btninfo[SBTN_DONE].part = MUSIC_PART_LIST_DONE_BTN; + btninfo[SBTN_DONE].style = MUSIC_STYLE_LIST_BTN; + btninfo[SBTN_DONE].type = CATEGORY_SONGS_DONE_BUTTON; + + btninfo[SBTN_CANCEL].name = MUSIC_TEXT_LIST_CANCEL; + btninfo[SBTN_CANCEL].part = MUSIC_PART_LIST_CANCEL_BTN; + btninfo[SBTN_CANCEL].style = MUSIC_STYLE_LIST_BTN; + btninfo[SBTN_CANCEL].type = CATEGORY_SONGS_CANCEL_BUTTON; + + switch (m->selectType) { + case SELECT_TYPE_CREATE: + elm_object_part_text_set(Layout(), MUSIC_PART_LIST_MSG, + _(MUSIC_TEXT_LIST_CREATE_MSG)); + break; + + case SELECT_TYPE_ADD: + elm_object_part_text_set(Layout(), MUSIC_PART_LIST_MSG, + _(MUSIC_TEXT_LIST_ADD_MSG)); + break; + + case SELECT_TYPE_REMOVE: + elm_object_part_text_set(Layout(), MUSIC_PART_LIST_MSG, + _(MUSIC_TEXT_LIST_REMOVE_MSG)); + break; + } + + for (i = 0; i < TOTAL_SELECT_BTNS; i++) { + btn = elm_button_add(Layout()); + if (!btn) + continue; + + evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_object_text_set(btn, _(btninfo[i].name)); + elm_object_style_set(btn, btninfo[i].style); + + Connect(btn, btninfo[i].type, TYPE_MOUSE_MOVE | TYPE_CLICKED); + + elm_object_part_content_set(Layout(), btninfo[i].part, btn); + m->select_btn[i] = btn; + } + + elm_object_focus_set(btn, EINA_TRUE); + m->def_foc_btn = btn; +} + + +void CCategorySongsLayout::m_CreateSongsTopSection(void) +{ + char *path = NULL; + char buf[MAX_LENGTH]; + + m_AddButtons(); + + m->albumCover = m_AddAlbumCover(); + if (!m->albumCover) + return; + + if (m->depth == DEPTH_SHOW_LIST) + path = m->catInfo->ThumbnailPath(); + else + path = m->albumInfo->ThumbnailPath(); + + if (path) { + elm_image_file_set(m->albumCover, path, NULL); + elm_image_aspect_fixed_set(m->albumCover, EINA_FALSE); + } + else { + snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, + MUSIC_IMAGE_DEFAULT_THUMB_126); + elm_image_file_set(m->albumCover, buf, NULL); + elm_image_no_scale_set(m->albumCover, EINA_TRUE); + } + elm_object_part_content_set(Layout(), MUSIC_PART_ALBUM_THUMB, m->albumCover); + + if (m->depth == DEPTH_SHOW_LIST) { + elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_NAME, + m->catInfo->Name()); + } + else { + elm_object_part_text_set(Layout(), + MUSIC_PART_CATEGORY_NAME, + m->catInfo->Name()); + elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_NAME, + m->albumInfo->Name()); + elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_ARTIST, + m->albumInfo->Artist()); + } + + snprintf(buf, sizeof(buf), "%d %s", + m_ConvertToMin(m->total_duration), _("min")); + elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_TIME, buf); + snprintf(buf, sizeof(buf), "%d", eina_list_count(m->slist)); + elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_SONGCOUNT, buf); +} + + + +void CCategorySongsLayout::m_CreateSongList(void) +{ + Evas_Object *genlist = NULL; + Elm_Genlist_Item_Class *list_item = NULL; + Evas_Object *layout = Layout(); + + if (!m->songlist) { + genlist = elm_genlist_add(layout); + if (!genlist) + return; + + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + evas_object_size_hint_weight_set(genlist, + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_content_set(layout, MUSIC_PART_SONGLIST, genlist); + Connect(genlist, CATEGORY_SONGS_GENLIST, TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_ACTIVATED); + m->songlist = genlist; + } + + list_item = elm_genlist_item_class_new(); + if (!list_item) { + evas_object_del(genlist); + _ERR(" elm_genlist_item_class_new failed "); + return; + } + + if (m->depth == DEPTH_SELECT_LIST) { + list_item->item_style = MUSIC_STYLE_SELECT_LIST; + list_item->func.text_get = sm_CbGetSelectlistItemText; + } + else { + list_item->item_style = MUSIC_STYLE_ALBUM_SONGLIST; + list_item->func.text_get = sm_CbGetListItemText; + } + list_item->func.content_get = NULL; + list_item->func.state_get = NULL; + list_item->func.del = sm_CbRemoveListItem; + m->item_class = list_item; + + m_UpdateSongList(); +} + + +Eina_List *CCategorySongsLayout::m_GetSelectedList(Eina_List *infolist, int type) +{ + Eina_List *idlist = NULL, *l = NULL; + SCategorySongsItemsInfo *itinfo = NULL; + void *obj = NULL; + char *id = NULL; + EIdType eType = (EIdType)type; + + if (!infolist) + return NULL; + + idlist = NULL; + EINA_LIST_FOREACH(infolist, l, obj) { + itinfo = (SCategorySongsItemsInfo *)obj; + if (!itinfo->check_status) + continue; + + if (eType == ID_TYPE_MEDIA) { + id = itinfo->sinfo->Id(); + if (id) + idlist = eina_list_append(idlist, id); + } + else { + idlist = eina_list_append(idlist, + itinfo->sinfo); + } + } + + return idlist; +} + + +void CCategorySongsLayout::m_AddSelectedSongs(void) +{ + Eina_List *idlist = NULL; + int lid; + + if (!m->catInfo || !m->catInfo->FlagCreate()) + return; + + lid = m->catInfo->CategoryId(); + idlist = m_GetSelectedList(m->it_infolist, (int)ID_TYPE_MEDIA); + + if (!lid || !idlist) + return; + + if (!m->mhandle->MediaAddmediaPlaylist(lid, idlist)) { + _ERR(" Failed to add songs to playlist "); + return; + } + + SParcel parcel; + parcel.ctxtInfo = NULL; + parcel.updateType = E_DEPTH_UPDATE; + parcel.layoutId = LayoutId(); + parcel.keyEvent = NULL; + m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); +} + + +void CCategorySongsLayout::m_RemoveSelectedSongs(void) +{ + Eina_List *idlist = NULL; + int lid; + + if (!m->catInfo || !m->catInfo->FlagCreate()) + return; + + lid = m->catInfo->CategoryId(); + idlist = m_GetSelectedList(m->it_infolist, (int)ID_TYPE_MEMBER); + + if (!lid || !idlist) + return; + + if (!m->mhandle->MediaRemovemediaPlaylist(lid, idlist)) { + _ERR(" Failed to remove songs from playlist "); + return; + } + + SParcel parcel; + parcel.ctxtInfo = NULL; + parcel.updateType = E_DEPTH_UPDATE; + parcel.layoutId = LayoutId(); + parcel.keyEvent = NULL; + m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); +} + + + +bool CCategorySongsLayout::m_SetEdje(const char *szLayout) +{ + ASSERT(szLayout); + if (!elm_layout_file_set(Layout(), EDJEFILE, szLayout)) { + _ERR(" elm szLayout file set failed "); + return false; + } + return true; +} + + +bool CCategorySongsLayout::Create(CLayoutMgr *mgr, CCategoryLayout *parent) +{ + ASSERT(!m); + + Evas_Object *base = NULL; + Evas_Object *win = NULL; + Evas_Object *layout = NULL; + CMusicController *mhandle; + CViewMgr *vmgr; + + if (!mgr) + return false; + + m = new SCategorySongsLayout; + if (!m) { + _ERR(" calloc failed "); + return false; + } + + vmgr = CViewMgr::GetInstance(); + if (!vmgr) { + _ERR(" get view mgr failed "); + delete m; + m = NULL; + return false; + } + + base = mgr->Base(); + if (!base) { + _ERR(" get base failed "); + delete m; + m = NULL; + return false; + } + + win = vmgr->Window(); + if (!win) { + _ERR(" vimewmgr get win failed "); + delete m; + m = NULL; + return false; + } + + mhandle = CMusicController::GetInstance(); + if (!mhandle) { + _ERR(" music controller get music instance failed "); + delete m; + m = NULL; + return false; + } + + layout = _add_base(base, MUSIC_CATEGORY_SONGS_LAYOUT); + if (!layout) { + _ERR(" get layout failed "); + delete m; + m = NULL; + return false; + } + + bool r = CExtBaseLayout::Create(layout); + if (!r) { + _ERR(" CBaseLayout creation failed "); + evas_object_del(layout); + delete m; + m = NULL; + return false; + } + + m->win = win; + m->base = base; + m->vmgr = vmgr; + m->mhandle = mhandle; + m->mgr = mgr; + m->parent = parent; + m->catInfo = new CCategoryInfo; + m->albumInfo = new CAlbumInfo; + + Connect(layout, CATEGORY_SONGS_LAYOUT, TYPE_KEY_DOWN); + + return true; +} + +void CCategorySongsLayout::Destroy(void) +{ + ASSERT(m); + + if (m->catInfo->FlagCreate()) { + m->catInfo->Destroy(); + } + delete m->catInfo; + + if (m->albumInfo->FlagCreate()) { + m->albumInfo->Destroy(); + } + delete m->albumInfo; + + m_RemoveFocusIdler(); + m_EmptySongList(); + CExtBaseLayout::Destroy(); + evas_object_del(Layout()); + + free(m->ctxtinfo); + delete m; + m = NULL; +} + + +void CCategorySongsLayout::SetParameter(EDepth depth, ESelectType selType, CCategoryInfo *catInfo, CAlbumInfo *albumInfo) +{ + ASSERT(m); + + m->depth = depth; + m->selectType = selType; + + if (m->catInfo->FlagCreate()) + m->catInfo->Destroy(); + + if (m->albumInfo->FlagCreate()) + m->albumInfo->Destroy(); + + if (catInfo && catInfo->FlagCreate()) { + m->catInfo->Create(); + m->catInfo->Duplicate(catInfo); + } + + if (albumInfo && albumInfo->FlagCreate()) { + m->albumInfo->Create(); + m->albumInfo->Duplicate(albumInfo); + } +} + + +void CCategorySongsLayout::t_OnShow(void) +{ + ASSERT(m); + + SParcel parcel; + parcel.ctxtInfo = NULL; + + m_EmptySongList(); + + if (m->depth == DEPTH_SONG_LIST) { + if (!m_SetEdje(MUSIC_CATEGORY_SONGS_LAYOUT)) { + _ERR(" get layout failed "); + return; + } + m_CreateSongList(); + m_CreateSongsTopSection(); + } + else if (m->depth == DEPTH_SHOW_LIST) { + if (!m_SetEdje(MUSIC_ALBUM_SONGS_LAYOUT)) { + _ERR(" get layout failed "); + return; + } + m_CreateSongList(); + m_CreateSongsTopSection(); + } + else if (m->depth == DEPTH_SELECT_LIST) { + if (!m_SetEdje(MUSIC_CATEGORY_SELECTLIST_LAYOUT)) { + _ERR(" get layout failed "); + return; + } + m_CreateSongList(); + m_AddSelectlistButtons(); + + elm_object_focus_next_object_set(m->songlist, + m->select_btn[SBTN_DONE], ELM_FOCUS_RIGHT); + } + + elm_object_tree_focus_allow_set(m->base, EINA_FALSE); + m_RemoveFocusIdler(); + m->focus_idler = ecore_idler_add(sm_CbFocusIdler, this); +} + + +void CCategorySongsLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + switch (id) + { + case CATEGORY_SONGS_LAYOUT: + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { + SParcel parcel; + parcel.ctxtInfo = NULL; + parcel.updateType = E_DEPTH_UPDATE; + parcel.layoutId = LayoutId(); + parcel.keyEvent = NULL; + m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); + } + break; + + case CATEGORY_SONGS_GENLIST: + { + Elm_Object_Item *it = NULL; + SContentInfo *ctxtinfo = NULL; + SCategorySongsItemsInfo *itinfo = NULL; + + if (strcmp(ev->keyname, KEY_MENU) && + strcmp(ev->keyname, KEY_MENU_REMOTE)) + return; + + it = elm_object_focused_item_get(obj); + if (!it) { + _ERR(" unable to get focused item "); + return; + } + m->focused_item = it; + + if (m->ctxtinfo) { + free(m->ctxtinfo); + m->ctxtinfo = NULL; + } + + ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo)); + if (!ctxtinfo) + return; + + itinfo = m_FindItemInfoFromItem(m->it_infolist, it); + if (!itinfo) { + free(ctxtinfo); + return; + } + + ctxtinfo->type = CONTEXT_TYPE_SONG; + ctxtinfo->context = itinfo->sinfo; + ctxtinfo->cbdata = this; + ctxtinfo->update = sm_CbCtxtUpdate; + ctxtinfo->close = sm_CbCtxtClose; + + m->ctxtinfo = ctxtinfo; + + SParcel parcel; + parcel.ctxtInfo = ctxtinfo; + if (!m->vmgr->PushView(MUSIC_CONTEXT_VIEW, &parcel)) + _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed"); + } + break; + + default: + break; + } +} + + +void CCategorySongsLayout::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev) +{ + switch (id) { + case CATEGORY_SONGS_GENLIST: + { + Elm_Object_Item *item; + + item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x, + ev->cur.canvas.y, NULL); + + if (!elm_object_item_focus_get(item)) + elm_object_item_focus_set(item, EINA_TRUE); + } + break; + + case CATEGORY_SONGS_PLAY_BUTTON: + case CATEGORY_SONGS_NEXT_BUTTON: + case CATEGORY_SONGS_LAST_BUTTON: + case CATEGORY_SONGS_SELECT_ALL_BUTTON: + case CATEGORY_SONGS_DONE_BUTTON: + case CATEGORY_SONGS_CANCEL_BUTTON: + { + if (!elm_object_focus_get(obj)) + elm_object_focus_set(obj, EINA_TRUE); + } + break; + + default: + break; + } +} + + +void CCategorySongsLayout::OnMouseClicked(int id, Evas_Object *obj) +{ + switch (id) + { + case CATEGORY_SONGS_PLAY_BUTTON: + m_GotoPlayback(ADD_TYPE_FRESH, NULL); + break; + + case CATEGORY_SONGS_NEXT_BUTTON: + m_GotoPlayback(ADD_TYPE_NEXT, NULL); + break; + + case CATEGORY_SONGS_LAST_BUTTON: + m_GotoPlayback(ADD_TYPE_END, NULL); + break; + + case CATEGORY_SONGS_SELECT_ALL_BUTTON: + { + Eina_List *l = NULL; + SCategorySongsItemsInfo *itinfo = NULL; + void *list_obj = NULL; + int tc; + + tc = eina_list_count(m->it_infolist); + + if (m->count == tc) { + elm_object_text_set(m->select_btn[SBTN_SELECT_ALL], + _(MUSIC_TEXT_SELECT_ALL)); + m->count = 0; + EINA_LIST_FOREACH(m->it_infolist, l, list_obj) { + itinfo = (SCategorySongsItemsInfo *)list_obj; + itinfo->check_status = false; + } + elm_genlist_realized_items_update(m->songlist); + + return; + } + + elm_object_text_set(m->select_btn[SBTN_SELECT_ALL], + _(MUSIC_TEXT_DESELECT_ALL)); + m->count = tc; + EINA_LIST_FOREACH(m->it_infolist, l, list_obj) { + itinfo = (SCategorySongsItemsInfo *)list_obj; + itinfo->check_status = true; + } + elm_genlist_realized_items_update(m->songlist); + } + break; + + case CATEGORY_SONGS_DONE_BUTTON: + { + if (m->selectType == SELECT_TYPE_ADD) { + m_AddSelectedSongs(); + return; + } + else if (m->selectType == SELECT_TYPE_REMOVE) { + m_RemoveSelectedSongs(); + return; + } + + m->parent->CreateEntryPopup(); + } + break; + + case CATEGORY_SONGS_CANCEL_BUTTON: + { + SParcel parcel; + parcel.ctxtInfo = NULL; + parcel.updateType = E_DEPTH_UPDATE; + parcel.layoutId = LayoutId(); + parcel.keyEvent = NULL; + m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); + } + break; + + + default: + break; + } +} + + +void CCategorySongsLayout::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + switch (id) { + case CATEGORY_SONGS_GENLIST: + if (m->depth == DEPTH_SELECT_LIST) { + m_OnSelectlistItemSelect(obj, item); + } + else { + m_OnSongItemSelect(obj, item); + } + break; + + default: + break; + } +} \ No newline at end of file -- 2.7.4 From 8601fed879cdbe0e2b00a5a1c9bea14fc9124b7f Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 3 Mar 2015 08:21:31 +0900 Subject: [PATCH 12/16] Fix memory leak to add RemoveView for each views in CApp::OnTerminate funcion. Change-Id: I477d16386c589e8326c37d9c5acb47872c71f1a3 Signed-off-by: Kim Tae Soo --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 9a1a145..918efb4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -111,6 +111,10 @@ public: virtual void OnTerminate(void) { + CViewMgr::GetInstance()->RemoveView(m_cBaseView); + CViewMgr::GetInstance()->RemoveView(m_cPlaybackView); + CViewMgr::GetInstance()->RemoveView(m_cContextView); + CSortMgr::Finalize(); CViewMgr::Finalize(); CMusicController::Finalize(); -- 2.7.4 From f7d8af6bede9c89bf0472490ef534299e4e087d8 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 3 Mar 2015 20:53:04 +0900 Subject: [PATCH 13/16] Move key definitions to "define.h" Change-Id: Ic33a10ea4ab337661f0a5b3e499a7da45101ee82 Signed-off-by: Kim Tae Soo --- include/common.h | 20 -------------------- include/define.h | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/include/common.h b/include/common.h index 0594435..b913ab8 100644 --- a/include/common.h +++ b/include/common.h @@ -145,24 +145,4 @@ struct SParcel { const char *keyEvent; }; -// this values should be defined -#define KEY_PLAY "Play" -#define KEY_NEXT "Next" -#define KEY_PREVIOUS "Previous" -#define KEY_EXIT "Exit" - -// Temp Definition -#define KEY_ENTER "Return" -#define KEY_BACK "Escape" -#define KEY_MENU "Super_L" -#define KEY_ENTER_REMOTE "KP_Enter" -#define KEY_BACK_REMOTE "XF86Close" -#define KEY_MENU_REMOTE "XF86MenuKB" - -#define SORT_BY_ARTIST_AZ "SORT_BY_ARTIST_AZ" -#define SORT_BY_ARTIST_ZA "SORT_BY_ARTIST_ZA" -#define SORT_BY_ALBUM_AZ "SORT_BY_ALBUM_AZ" -#define SORT_BY_ALBUM_ZA "SORT_BY_ALBUM_ZA" - - #endif /* __COMMON_H__ */ diff --git a/include/define.h b/include/define.h index 5a056d9..2d778b4 100644 --- a/include/define.h +++ b/include/define.h @@ -422,4 +422,25 @@ #define POSITION_PLAY_LIST_POPUP_X 1644 #define POSITION_PLAY_LIST_POPUP_Y 1020 +/* TEMP KEY DEFINITION */ +#define KEY_VOLUMEUP "F9" +#define KEY_VOLUMEDOWN "F10" +#define KEY_ENTER "Return" +#define KEY_BACK "Escape" +#define KEY_MENU "Super_L" +#define KEY_ENTER_REMOTE "KP_Enter" +#define KEY_BACK_REMOTE "XF86Close" +#define KEY_MENU_REMOTE "XF86MenuKB" +/* SHOULD BE DEFINED */ +#define KEY_PLAY "Play" +#define KEY_NEXT "Next" +#define KEY_PREVIOUS "Previous" +#define KEY_EXIT "Exit" + +/* SORTING ID */ +#define SORT_BY_ARTIST_AZ "SORT_BY_ARTIST_AZ" +#define SORT_BY_ARTIST_ZA "SORT_BY_ARTIST_ZA" +#define SORT_BY_ALBUM_AZ "SORT_BY_ALBUM_AZ" +#define SORT_BY_ALBUM_ZA "SORT_BY_ALBUM_ZA" + #endif /* __DEFINE_H__ */ -- 2.7.4 From 2e1771f817df0d1ccb79ce483ef334251bce7971 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 4 Mar 2015 08:22:36 +0900 Subject: [PATCH 14/16] [JIRA:TT-1] Fix double eina_list_free Change-Id: I3fd0a01a3531a646fc2cc676547e75dba2deca49 Signed-off-by: Kim Tae Soo --- include/define.h | 12 ++++++++++++ src/data/category_info.cpp | 1 + src/views/category-layout.cpp | 22 +++++++++------------- src/views/category-songs-layout.cpp | 30 ++---------------------------- src/views/song-layout.cpp | 3 ++- 5 files changed, 26 insertions(+), 42 deletions(-) diff --git a/include/define.h b/include/define.h index 2d778b4..08ade04 100644 --- a/include/define.h +++ b/include/define.h @@ -443,4 +443,16 @@ #define SORT_BY_ALBUM_AZ "SORT_BY_ALBUM_AZ" #define SORT_BY_ALBUM_ZA "SORT_BY_ALBUM_ZA" +/* for debugging */ +#define _eina_list_free(list) \ +{ \ + if (!list) \ + return; \ + if (list->__magic != 0x98761237) { \ + int *a = 0; \ + *a = 1; \ + } \ + eina_list_free(list); \ +} + #endif /* __DEFINE_H__ */ diff --git a/src/data/category_info.cpp b/src/data/category_info.cpp index 5de39ea..803d902 100644 --- a/src/data/category_info.cpp +++ b/src/data/category_info.cpp @@ -19,6 +19,7 @@ #include #include "dbg.h" #include "i18n.h" +#include "define.h" #include "category_info.h" diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index a1b9134..2b188de 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -933,26 +933,22 @@ void CCategoryLayout::m_EmptyLayout(bool sort_flag) } if (!sort_flag) { - if (m->catlist) { + if (m->catlist) eina_list_free(m->catlist); - m->catlist = NULL; - } + m->catlist = NULL; } - if (m->alblist) { - eina_list_free(m->alblist); - m->alblist = NULL; - } + // This value is just referenced from CCategoryInfo. + // So should not freed here. + m->alblist = NULL; - if (m->songlist) { + if (m->songlist) eina_list_free(m->songlist); - m->songlist = NULL; - } + m->songlist = NULL; - if (m->it_infolist) { + if (m->it_infolist) eina_list_free(m->it_infolist); - m->it_infolist = NULL; - } + m->it_infolist = NULL; m->total_duration = 0; diff --git a/src/views/category-songs-layout.cpp b/src/views/category-songs-layout.cpp index 7d40d26..4ba866a 100644 --- a/src/views/category-songs-layout.cpp +++ b/src/views/category-songs-layout.cpp @@ -919,8 +919,6 @@ bool CCategorySongsLayout::Create(CLayoutMgr *mgr, CCategoryLayout *parent) m->mhandle = mhandle; m->mgr = mgr; m->parent = parent; - m->catInfo = new CCategoryInfo; - m->albumInfo = new CAlbumInfo; Connect(layout, CATEGORY_SONGS_LAYOUT, TYPE_KEY_DOWN); @@ -931,16 +929,6 @@ void CCategorySongsLayout::Destroy(void) { ASSERT(m); - if (m->catInfo->FlagCreate()) { - m->catInfo->Destroy(); - } - delete m->catInfo; - - if (m->albumInfo->FlagCreate()) { - m->albumInfo->Destroy(); - } - delete m->albumInfo; - m_RemoveFocusIdler(); m_EmptySongList(); CExtBaseLayout::Destroy(); @@ -958,22 +946,8 @@ void CCategorySongsLayout::SetParameter(EDepth depth, ESelectType selType, CCate m->depth = depth; m->selectType = selType; - - if (m->catInfo->FlagCreate()) - m->catInfo->Destroy(); - - if (m->albumInfo->FlagCreate()) - m->albumInfo->Destroy(); - - if (catInfo && catInfo->FlagCreate()) { - m->catInfo->Create(); - m->catInfo->Duplicate(catInfo); - } - - if (albumInfo && albumInfo->FlagCreate()) { - m->albumInfo->Create(); - m->albumInfo->Duplicate(albumInfo); - } + m->catInfo = catInfo; + m->albumInfo = albumInfo; } diff --git a/src/views/song-layout.cpp b/src/views/song-layout.cpp index 3af52ea..fa48d2c 100644 --- a/src/views/song-layout.cpp +++ b/src/views/song-layout.cpp @@ -404,7 +404,8 @@ void CSongLayout::m_EmptySongList(bool sort_flag) elm_genlist_clear(m->songlist); if (!sort_flag) { - eina_list_free(m->slist); + if (m->slist) + eina_list_free(m->slist); m->slist = NULL; } -- 2.7.4 From 5bbbb74e07f94130c2d5a2d2dc667ed3b60d3ced Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 4 Mar 2015 11:22:49 +0900 Subject: [PATCH 15/16] Fix Bug: When CSortCtxPopup is created, the case of song layout is not considered Change-Id: Ic3244c0613e286f7f774ce828cd2846730c335a1 Signed-off-by: Kim Tae Soo --- src/views/base-view.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index 8247cdb..b729090 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -329,12 +329,15 @@ void CMusicBaseView::m_CreateCtxPopup(int btnType) } else if (btnType == BTN_SORT) { CSortCtxPopup *sortCtxPopup = NULL; - CSortCtxPopup::ESortBtnType sortBtnType; + CSortCtxPopup::ESortBtnType sortBtnType = CSortCtxPopup::TYPE_SONG; m->btntype = btnType; layout_id = m->lmgr->Layout()->LayoutId(); sortCtxPopup = new CSortCtxPopup; if (layout_id) { - if (!strcmp(layout_id, MUSIC_ALBUM_LAYOUT)) { + if (!strcmp(layout_id, MUSIC_SONG_LAYOUT)) { + sortBtnType = CSortCtxPopup::TYPE_SONG; + } + else if (!strcmp(layout_id, MUSIC_ALBUM_LAYOUT)) { sortBtnType = CSortCtxPopup::TYPE_ALBUM; } else if (!strcmp(layout_id, MUSIC_FOLDER_LAYOUT)) { -- 2.7.4 From e90ae864248be0f1503b22a75a611a40ac996bd8 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 4 Mar 2015 11:48:48 +0900 Subject: [PATCH 16/16] Fix Bug: Buttons doesn't work properly in CCategorySongsLayout Change-Id: I2af5c0addee17b285fdb2e7b5b71ccd3bf1fa654 Signed-off-by: Kim Tae Soo --- src/views/category-songs-layout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/category-songs-layout.cpp b/src/views/category-songs-layout.cpp index 4ba866a..a110318 100644 --- a/src/views/category-songs-layout.cpp +++ b/src/views/category-songs-layout.cpp @@ -573,7 +573,7 @@ void CCategorySongsLayout::m_AddButtons(void) elm_object_text_set(m->add_btn[i], _(btninfo[i].name)); elm_object_style_set(m->add_btn[i], btninfo[i].style); - Connect(m->add_btn[i], btninfo[ABTN_LAST].type, TYPE_CLICKED | TYPE_MOUSE_MOVE); + Connect(m->add_btn[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE); img = elm_image_add(m->add_btn[i]); if (img) { -- 2.7.4