Add Remote Key define and flow
[profile/tv/apps/native/filebrowser.git] / src / views / BaseView / FbBaseView.cpp
index bfd7c2c..b646fad 100644 (file)
@@ -27,7 +27,6 @@
 #include "dbg.h"
 #include <MediaContentDbListener.h>
 #include <UsbConnectionListener.h>
-#include "SortName.h"
 #include "Popup.h"
 #include "InputHandler.h"
 
@@ -44,6 +43,9 @@
 #include <LayoutMgr.h>
 #include <BaseLayout.h>
 #include "FbAllLayout.h"
+#include "FbPhotoLayout.h"
+#include "FbVideoLayout.h"
+#include "FbMusicLayout.h"
 
 #define TOTAL_GROUP_BTNS       4
 #define TOTAL_TOP_BTNS         2
@@ -86,11 +88,15 @@ struct SFbBaseView {
        Evas_Object *eoBtnSort;
 
        CCtxPopup   *pCtxPopup;
-
        CPopup      *pPopup;
 
-       CLayoutMgr    *pLayoutMgr;
-       CFbAllLayout *pFbAllLayout;
+       CLayoutMgr     *pLayoutMgr;
+
+       char*          *pCurrentLayoutId;
+       CFbAllLayout   *pFbAllLayout;
+       //CFbPhotoLayout *pFbPhotoLayout;
+       //CFbMusicLayout *pFbMusicLayout;
+       //CFbVideoLayout *pFbVideoLayout;
 
        SFbBaseView() {
                int a;
@@ -122,9 +128,10 @@ struct SFbBaseView {
                virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) {
                        if (!strcmp(ev->keyname, KEY_EXIT))
                                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->eoSelectedBtnGroup)) {
                                        m->pFbAllLayout->SetFocus(EINA_TRUE);
+                                       // TODO: Each layout SetFocus???
                                }
                        }
                }
@@ -144,12 +151,20 @@ struct SFbBaseView {
                        switch (instance->Type()) {
                        case CCtxPopup::TOPBTN_SORT:
                                elm_object_text_set(m->eoBtnSort, text);
+#if 1
                                m->pFbAllLayout->Update(true);
+#else
+                               m->pLayoutMgr->Show(Current_layout);
+#endif
                                break;
 
                        case CCtxPopup::TOPBTN_SOURCE:
                                elm_object_text_set(m->eoBtnSource, text);
+#if 1
                                m->pFbAllLayout->Update(false);
+#else
+                               m->pLayoutMgr->Show(Current_layout);
+#endif
                                break;
 
                        default:
@@ -161,7 +176,7 @@ struct SFbBaseView {
                CHandlerButton(SFbBaseView *ins) : IKeyDownListener(this), IMouseMoveListener(this), IMouseClickedListener(this) { m = ins; }
 
                virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) {
-                       if (!strcmp(ev->keyname, KEY_BACK))
+                       if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE))
                                elm_object_focus_set(m->eoSelectedBtnGroup, EINA_TRUE);
                }
                virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev) {
@@ -200,7 +215,7 @@ struct SFbBaseView {
                                elm_object_focus_set(obj, EINA_TRUE);
                }
                virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) {
-                       if (!strcmp(ev->keyname, KEY_BACK))
+                       if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE))
                                elm_exit();
                }
                virtual void OnMouseClicked(int id, Evas_Object *obj) {
@@ -211,7 +226,30 @@ struct SFbBaseView {
                        m->eoSelectedBtnGroup = obj;
                        elm_object_signal_emit(m->eoSelectedBtnGroup, FBR_SIGNAL_GROUP_SELECTED, "");
 
+#if 1
                        m->pFbAllLayout->Update(false);
+                       // TODO: not update, it should be "Show" as each layout
+#else
+                       switch(id)
+                       {
+                               case E_GRP_ALL:
+                                       m->pLayoutMgr->Show(FB_ALL_LAYOUT);
+                                       break;
+                               case E_GRP_PHOTO:
+                                       m->pLayoutMgr->Show(FB_PHOTO_LAYOUT);
+                                       break;
+                               case E_GRP_VIDEO:
+                                       m->pLayoutMgr->Show(FB_VIDEO_LAYOUT);
+                                       break;
+                               case E_GRP_MUSIC:
+                                       m->pLayoutMgr->Show(FB_MUSIC_LAYOUT);
+                                       break;
+                               default:
+                                       _DBG("Fix it: it can not make it , MouseClicked");
+                                       break;
+
+                       }
+#endif
                }
        } *pHandlerGroup[TOTAL_GROUP_BTNS];
 };
@@ -388,7 +426,8 @@ void CFbBaseView::t_CreateLeftSession(void)
                elm_object_style_set(m->eoBtnGroup[i], FBR_STYLE_GROUPBTN);
                elm_object_text_set(m->eoBtnGroup[i], _(btninfo[i].txt));
                
-               m->pHandlerGroup[i]->Connect(m->eoBtnGroup[i]);
+               m->pHandlerGroup[i]->Connect(m->eoBtnGroup[i], i);
+
                ic = elm_image_add(m->eoBtnGroup[i]);
                if (!ic)
                        continue;
@@ -416,7 +455,11 @@ void CFbBaseView::t_CreateFullView(void)
        t_CreateTopSession();
        t_CreateLeftSession();
        _DBG("UpdateLayout");
+#if 1
        m->pFbAllLayout->Update(false);
+#else
+       m->pLayoutMgr->Show(Current_layout);
+#endif
 }
 
 void CFbBaseView::t_SetSelectedGroupButton(Evas_Object* obj)
@@ -448,6 +491,7 @@ void CFbBaseView::t_OnShow(void)
 
 void CFbBaseView::t_OnUpdate(void *data)
 {
+       // TODO: When does this function is called? If it don't be used, Remove it.
        _DBG();
        m->pFbAllLayout->Action();
 }
@@ -496,16 +540,36 @@ bool CFbBaseView::Create(void *data)
                }
                _CHECK(m->pLayoutMgr = new CLayoutMgr)
                _CHECK(m->pLayoutMgr->Create(eoBase, NULL))
-               _CHECK(m->pFbAllLayout = new CFbAllLayout(FB_BASE_LAYOUT))
+               _CHECK(m->pFbAllLayout = new CFbAllLayout(FB_ALL_LAYOUT))
+               //_CHECK(m->pFbPhotoLayout = new CFbPhotoLayout(FB_PHOTO_LAYOUT))
+               //_CHECK(m->pFbVideoLayout = new CFbVideoLayout(FB_VIDEO_LAYOUT))
+               //_CHECK(m->pFbMusicLayout = new CFbMusicLayout(FB_MUSIC_LAYOUT))
                _CHECK(m->pFbAllLayout->Create(m->pLayoutMgr, NULL))
+               //_CHECK(m->pFbPhotoLayout->Create(m->pLayoutMgr, NULL))
+               //_CHECK(m->pFbVideoLayout->Create(m->pLayoutMgr, NULL))
+               //_CHECK(m->pFbMusicLayout->Create(m->pLayoutMgr, NULL))
                _CHECK(m->pLayoutMgr->AddLayout(m->pFbAllLayout))
+               //_CHECK(m->pLayoutMgr->AddLayout(m->pFbPhotoLayout))
+               //_CHECK(m->pLayoutMgr->AddLayout(m->pFbVideoLayout))
+               //_CHECK(m->pLayoutMgr->AddLayout(m->pFbMusicLayout))
                _CHECK(CUsbConnectionListener::Create())
+               _CHECK(CMediaContentDbUpdateListener::Create())
 
                _WHEN_SUCCESS{}
 
+               _CHECK_FAIL{ CMediaContentDbUpdateListener::Destroy(); }
                _CHECK_FAIL{ CUsbConnectionListener::Destroy(); }
+               //_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbMusicLayout); }
+               //_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbVideoLayout); }
+               //_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbPhotoLayout); }
                _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbAllLayout); }
+               //_CHECK_FAIL{ m->pFbMusicLayout->Destroy(); }
+               //_CHECK_FAIL{ m->pFbVideoLayout->Destroy(); }
+               //_CHECK_FAIL{ m->pFbPhotoLayout->Destroy(); }
                _CHECK_FAIL{ m->pFbAllLayout->Destroy(); }
+               //_CHECK_FAIL{ delete m->pFbMusicLayout; m->pFbMusicLayout = NULL; }
+               //_CHECK_FAIL{ delete m->pFbVideoLayout; m->pFbVideoLayout = NULL; }
+               //_CHECK_FAIL{ delete m->pFbPhotoLayout; m->pFbPhotoLayout = NULL; }
                _CHECK_FAIL{ delete m->pFbAllLayout; m->pFbAllLayout = NULL; }
                _CHECK_FAIL{ m->pLayoutMgr->Destroy(); }
                _CHECK_FAIL{ delete m->pLayoutMgr; m->pLayoutMgr = NULL; }
@@ -516,9 +580,9 @@ bool CFbBaseView::Create(void *data)
 
 
        // original create grid
-       m->pLayoutMgr->Show(FB_BASE_LAYOUT);
        CInfo::SetSortType(0/*CSort::SORT_NAME_AZ*/);
        evas_object_data_set(eoBase, BASE_VIEW_DATA, this);
+       m->pLayoutMgr->Show(FB_ALL_LAYOUT);
        t_CreateFullView();
        elm_object_focus_allow_set(eoBase, EINA_FALSE);
        m->pHandlerBase->Connect(eoBase);
@@ -531,8 +595,23 @@ void CFbBaseView::Destroy(void)
        ASSERT(m);
 
        CBaseView::Destroy();
+       CMediaContentDbUpdateListener::Destroy();
        CUsbConnectionListener::Destroy();
 
+#if 0
+       m->pLayoutMgr->RemoveLayout(m->pFbMusicLayout);
+       m->pFbMusicLayout->Destroy();
+       delete m->pFbMusicLayout;
+       
+       m->pLayoutMgr->RemoveLayout(m->pFbVideoLayout);
+       m->pFbVideoLayout->Destroy();
+       delete m->pFbVideoLayout;
+
+       m->pLayoutMgr->RemoveLayout(m->pFbPhotoLayout);
+       m->pFbPhotoLayout->Destroy();
+       delete m->pFbPhotoLayout;
+#endif
+
        m->pLayoutMgr->RemoveLayout(m->pFbAllLayout);
        m->pFbAllLayout->Destroy();
        delete m->pFbAllLayout;
@@ -578,6 +657,7 @@ void CFbBaseView::OnConnect(void)
 
 void CFbBaseView::OnUpdated(const SEntity *entity)
 {
+       _DBG();
        m->pPopup->Destroy();
        delete m->pPopup;
        m->pPopup = NULL;
@@ -588,7 +668,11 @@ void CFbBaseView::OnUpdated(const SEntity *entity)
                m->pCtxPopup = NULL;
        }
        if (CInfo::SourceType() != E_TV) {
+#if 1
                m->pFbAllLayout->Update(false);
+#else
+               m->pLayoutMgr->Show(Current_layout);
+#endif
                elm_object_focus_set(t_SelectedGroupButton(), EINA_TRUE);
        }
 }