N_SE-43925
[apps/osp/Gallery.git] / src / GlFileListForm.cpp
index a64f182..4a9d3ac 100644 (file)
@@ -23,6 +23,7 @@
 #include "GlAllListPanel.h"
 #include "GlFileListForm.h"
 #include "GlFileListPresentationModel.h"
+#include "GlGalleryApp.h"
 #include "GlResourceManager.h"
 #include "GlSlideSettingListener.h"
 #include "GlSlideShowPopUp.h"
@@ -38,7 +39,8 @@ using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Content;
 
 FileListForm::FileListForm(void)
-       : __pContextMenuMore(null)
+       : __menuState(true)
+       , __pOptionMenu(null)
        , __pPopUp(null)
        , __pPresentationModel(null)
 {
@@ -68,6 +70,8 @@ FileListForm::OnInitializing(void)
        Header* pHeader = GetHeader();
        TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
 
+          SetFormMenuEventListener(this);
+
        __pPresentationModel = FileListPresentationModel::GetInstance();
        __pPresentationModel->ClearThumbnailRequests();
 
@@ -77,11 +81,13 @@ FileListForm::OnInitializing(void)
        {
                __pPopUp->Initialize();
                __pPopUp->SetEventListner(this);
-               AddControl(*__pPopUp);
+               AddControl(__pPopUp);
        }
 
        InitializeFooter();
        SetFormBackEventListener(this);
+       SetOrientation(ORIENTATION_AUTOMATIC);
+       AddOrientationEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -92,11 +98,12 @@ FileListForm::OnTerminating(void)
 {
        AppLogDebug("ENTER");
 
-       if (__pContextMenuMore != null)
+       if ( __pOptionMenu != null )
        {
-               delete __pContextMenuMore;
-               __pContextMenuMore = null;
+               delete __pOptionMenu;
+               __pOptionMenu = null;
        }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -120,26 +127,6 @@ FileListForm::OnActionPerformed(const Control& source, int actionId)
 
        switch (actionId)
        {
-       case IDA_FOOTER_MORE:
-       {
-               AppLogDebug("ITEMCOUNT(%d)", __pPresentationModel->GetCurrentAlbumContentInfoCount());
-
-               InitializeFooter();
-
-               if (__pContextMenuMore->GetShowState() == false)
-               {
-                       Rectangle rect = source.GetBounds();
-                       __pContextMenuMore->SetAnchorPosition(Point(rect.width / 10, rect.y));
-                       __pContextMenuMore->SetShowState(true);
-                       __pContextMenuMore->Show();
-               }
-               else
-               {
-                       __pContextMenuMore->SetShowState(false);
-               }
-       }
-       break;
-
        case IDA_FOOTER_EDIT:
        {
                if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
@@ -178,7 +165,7 @@ FileListForm::OnActionPerformed(const Control& source, int actionId)
                pDataList->Construct();
                pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
                __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
-                               null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
+                               null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, this);
        }
        break;
 
@@ -199,6 +186,24 @@ FileListForm::OnFormBackRequested(Form& source)
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
+void
+FileListForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
+{
+
+
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       pSceneManager->GetCurrentScene();
+
+       if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
+       {
+               AllListPanel* pListPanel = dynamic_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+               if (pListPanel != null)
+               {
+                       pListPanel->ChangeOrientation();
+               }
+       }
+}
+
 result
 FileListForm::InitializeFooter(void)
 {
@@ -210,25 +215,6 @@ FileListForm::InitializeFooter(void)
        pFooter->RemoveAllItems();
        pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
 
-       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)
-       {
-               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;
-
        FooterItem itemCamera;
        itemCamera.Construct(IDA_FOOTER_CAMERA);
        Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
@@ -238,33 +224,31 @@ FileListForm::InitializeFooter(void)
        }
        pFooter->AddItem(itemCamera);
 
-       if (__pContextMenuMore != null)
+
+       if (__pOptionMenu != null)
        {
-               delete __pContextMenuMore;
-               __pContextMenuMore = null;
+               delete __pOptionMenu;
+               __pOptionMenu = null;
        }
 
-       __pContextMenuMore = new (std::nothrow) ContextMenu();
-       __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
+       __pOptionMenu = new (std::nothrow) OptionMenu();
+       __pOptionMenu->Construct();
 
        if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
        {
-               __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
+               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
        }
 
        if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
        {
-               __pContextMenuMore->SetEnabled(false);
+               __pOptionMenu->SetEnabled(false);
        }
        else
        {
-               __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
-               __pContextMenuMore->SetShowState(false);
-               __pContextMenuMore->AddActionEventListener(*this);
+               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
+               __pOptionMenu->AddActionEventListener(*this);
        }
 
-       pFooter->SetBackButton();
-
        pFooter->AddActionEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -292,6 +276,7 @@ FileListForm::OnSlideSettingPopUpItemSelected(int index)
 
        if (index == 0)
        {
+               result r = E_SUCCESS;
                ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
                pArrayList->Construct();
                int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
@@ -306,8 +291,17 @@ FileListForm::OnSlideSettingPopUpItemSelected(int index)
                pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
                pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
 
-               __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
+               r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
                                new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
+
+               if (r == E_MAX_EXCEEDED)
+               {
+                       MessageBox messageBox;
+                       messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
+                                       MSGBOX_STYLE_NONE, 3000);
+                       int modalResult;
+                       messageBox.ShowAndWait(modalResult);
+               }
        }
        else if (index == 1)
        {
@@ -317,3 +311,39 @@ FileListForm::OnSlideSettingPopUpItemSelected(int index)
                pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
        }
 }
+
+void
+FileListForm::SetMenuState(bool state)
+{
+       __menuState = state;
+}
+
+void
+FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
+{
+
+       if (__menuState == true )
+       {
+               InitializeFooter();
+
+               if ( __pOptionMenu == null )
+               {
+                       return ;
+               }
+
+               __pOptionMenu->SetShowState(true);
+               __pOptionMenu->Show();
+       }
+
+}
+
+void
+FileListForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId,
+                       AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
+{
+       AppLogDebug("OnAppControlCompleteResponseReceived : %d", appControlResult);
+
+       GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
+       TryReturnVoid(pGalleryApp != null, "pGalleryApp is null");
+       pGalleryApp->SetFrameEnabled(true);
+}