HW key changes
[apps/osp/Gallery.git] / src / GlAlbumListForm.cpp
index 0b9d4c1..e04444d 100644 (file)
@@ -42,10 +42,13 @@ static const int W_FOLDER_SIZE = 348;
 static const int H_FOLDER_SIZE = 348;
 
 AlbumListForm::AlbumListForm(void)
-       : __itemCount(0)
+       : __isHWBackButtonExist(false)
+       , __itemCount(0)
        , __pAlbumViewIconList(null)
        , __pContextMenuMore(null)
+       , __pOptionMenu(null)
        , __pPresentationModel(null)
+
 {
        AppLogDebug("ENTER");
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -72,6 +75,12 @@ AlbumListForm::OnInitializing(void)
 {
        AppLogDebug("ENTER");
        result r = E_SUCCESS;
+       GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
+
+        __isHWBackButtonExist = false;
+        __isHWBackButtonExist = pApp->IsHwKeySupported();
+       AppLogDebug("EXIT(%s)", GetErrorMessage(r));
+
 
        __pPresentationModel = AlbumListPresentationModel::GetInstance();
        __pPresentationModel->ClearThumbnailRequests();
@@ -176,30 +185,44 @@ AlbumListForm::InitializeFooter(void)
                pFooter->AddItem(itemCamera);
                delete pBitmap1;
 
-               ButtonItem footerMore;
-               footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
 
-               Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
-               Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
-               Bitmap* pBitmapMorePressed = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_PRESSED);
-
-               if (pBitmapMore != null && pBitmapMoreDim != null && pBitmapMorePressed != null)
+               if( __isHWBackButtonExist == false )
                {
-                       footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
-                       footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
-                       footerMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapMorePressed);
-               }
+                       ButtonItem footerMore;
+                       footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
 
-               pFooter->SetButton(BUTTON_POSITION_LEFT, footerMore);
-               delete pBitmapMore;
-               delete pBitmapMoreDim;
-               delete pBitmapMorePressed;
+                       Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
+                       Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
+                       Bitmap* pBitmapMorePressed = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_PRESSED);
 
-               __pContextMenuMore = new (std::nothrow) ContextMenu();
-               __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
-               __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
-               __pContextMenuMore->SetShowState(false);
-               __pContextMenuMore->AddActionEventListener(*this);
+                       if (pBitmapMore != null && pBitmapMoreDim != null && pBitmapMorePressed != null)
+                       {
+                               footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
+                               footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
+                               footerMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapMorePressed);
+                       }
+
+                       pFooter->SetButton(BUTTON_POSITION_LEFT, footerMore);
+                       delete pBitmapMore;
+                       delete pBitmapMoreDim;
+                       delete pBitmapMorePressed;
+
+                       __pContextMenuMore = new (std::nothrow) ContextMenu();
+                       __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
+                       __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
+                       __pContextMenuMore->SetShowState(false);
+                       __pContextMenuMore->AddActionEventListener(*this);
+               }
+               else
+               {
+                           __pOptionMenu = new (std::nothrow) OptionMenu();
+                           __pOptionMenu->Construct();
+                           __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"),IDA_FOOTER_EDIT);
+                           __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
+                           __pOptionMenu->SetShowState(false);
+                           __pOptionMenu->AddActionEventListener(*this);
+                           SetFormMenuEventListener(this);
+               }
 
                SetFormBackEventListener(this);
        }
@@ -478,6 +501,17 @@ AlbumListForm::OnContentUpdated(void)
 {
        AppLogDebug("ENTER");
 
+       if(__pContextMenuMore != null && __pContextMenuMore ->GetShowState() == true)
+       {
+               __pContextMenuMore->SetShowState(false);
+       }
+
+       if ( __pOptionMenu != null && __pOptionMenu ->GetShowState() == true)
+       {
+               __pOptionMenu->SetShowState(false);
+               __pOptionMenu->Show();
+       }
+
        if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
        {
                if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_IMAGE)
@@ -501,6 +535,7 @@ AlbumListForm::OnContentUpdated(void)
 
        __itemCount = __pPresentationModel->GetFolderCount();
        __pAlbumViewIconList->UpdateList();
+
        if (__itemCount == 0 )
        {
                GetFooter()->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
@@ -509,6 +544,8 @@ AlbumListForm::OnContentUpdated(void)
        {
                GetFooter()->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
        }
+
+       GetFooter()->Invalidate(true);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -537,3 +574,17 @@ AlbumListForm::Update(void)
 
        return r;
 }
+
+void
+AlbumListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
+{
+
+       if ( __pOptionMenu == null )
+       {
+               return ;
+       }
+
+       __pOptionMenu->SetShowState(true);
+       __pOptionMenu->Show();
+
+}