Fix for 45027
[apps/osp/Gallery.git] / src / GlAlbumListForm.cpp
index e04444d..1e09917 100644 (file)
@@ -42,10 +42,8 @@ static const int W_FOLDER_SIZE = 348;
 static const int H_FOLDER_SIZE = 348;
 
 AlbumListForm::AlbumListForm(void)
-       : __isHWBackButtonExist(false)
-       , __itemCount(0)
+       : __itemCount(0)
        , __pAlbumViewIconList(null)
-       , __pContextMenuMore(null)
        , __pOptionMenu(null)
        , __pPresentationModel(null)
 
@@ -75,12 +73,9 @@ 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));
 
+       SetOrientation(ORIENTATION_AUTOMATIC);
+       AddOrientationEventListener(*this);
 
        __pPresentationModel = AlbumListPresentationModel::GetInstance();
        __pPresentationModel->ClearThumbnailRequests();
@@ -165,13 +160,13 @@ AlbumListForm::InitializeFooter(void)
 
        if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
        {
-               pFooter->SetBackButton();
                SetFormBackEventListener(this);
+               pFooter->SetShowState(false);
        }
        else
        {
+               pFooter->SetShowState(true);
                pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
-               pFooter->SetBackButton();
                pFooter->RemoveAllItems();
 
                FooterItem itemCamera;
@@ -185,47 +180,16 @@ AlbumListForm::InitializeFooter(void)
                pFooter->AddItem(itemCamera);
                delete pBitmap1;
 
-
-               if( __isHWBackButtonExist == false )
-               {
-                       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;
-
-                       __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);
-               }
-
+               __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);
        }
+
        pFooter->AddActionEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -238,19 +202,25 @@ AlbumListForm::CreateIconListView(void)
        AppLogDebug("ENTER");
        Dimension itemSize(W_FOLDER_SIZE, H_FOLDER_SIZE);
 
-       __pAlbumViewIconList = static_cast<IconListView*>(GetControl(L"IDC_ICONLISTVIEW_ALBUM_LIST"));
-       AppAssert(__pAlbumViewIconList);
-
+       __pAlbumViewIconList = new IconListView();
+       __pAlbumViewIconList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height),
+                   Dimension(W_FOLDER_SIZE, H_FOLDER_SIZE), ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
        __pAlbumViewIconList->SetItemProvider(*this);
        __pAlbumViewIconList->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
        __pAlbumViewIconList->AddIconListViewItemEventListener(*this);
 
+
+
        Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
+
        if (pBitmap != null)
        {
                __pAlbumViewIconList->SetBitmapOfEmptyList(pBitmap);
                delete pBitmap;
        }
+       __pAlbumViewIconList->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
+
+       AddControl(__pAlbumViewIconList);
 
        __pAlbumViewIconList->SetShowState(true);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -358,11 +328,6 @@ AlbumListForm::OnTerminating(void)
        AppLogDebug("ENTER");
        __pPresentationModel->RemovePresentationModelListener(*this);
        __pPresentationModel->RemoveContentEventListener(*this);
-       if (__pContextMenuMore != null)
-       {
-               delete __pContextMenuMore;
-               __pContextMenuMore = null;
-       }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -384,7 +349,7 @@ AlbumListForm::OnActionPerformed(const Control& source, int actionId)
                                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);
+                               new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, this);
        }
        break;
 
@@ -394,22 +359,6 @@ AlbumListForm::OnActionPerformed(const Control& source, int actionId)
        }
        break;
 
-       case IDA_FOOTER_MORE:
-       {
-               if (__pContextMenuMore->GetShowState() == false && __pPresentationModel->GetFolderCount() != 0)
-               {
-                       Rectangle rect = source.GetBounds();
-                       __pContextMenuMore->SetAnchorPosition(Point(rect.width/10, rect.y));
-                       __pContextMenuMore->SetShowState(true);
-                       __pContextMenuMore->Show();
-               }
-               else
-               {
-                       __pContextMenuMore->SetShowState(false);
-               }
-       }
-       break;
-
        default:
                break;
        }
@@ -424,7 +373,7 @@ AlbumListForm::OnFormBackRequested(Form& source)
        {
                AppLogDebug("APP_CONTROL_MODE_PICK");
                GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
-               if (pApp != null)
+               if (pApp != null && pApp->GetFrameActivated() == true)
                {
                        if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
                        {
@@ -470,15 +419,6 @@ AlbumListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
        }
        __itemCount = __pPresentationModel->GetFolderCount();
 
-       if ( __itemCount == 0 )
-       {
-               GetFooter()->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
-       }
-       else
-       {
-               GetFooter()->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
-       }
-
        if (__pAlbumViewIconList != null)
        {
                __pAlbumViewIconList->UpdateList();
@@ -501,12 +441,7 @@ AlbumListForm::OnContentUpdated(void)
 {
        AppLogDebug("ENTER");
 
-       if(__pContextMenuMore != null && __pContextMenuMore ->GetShowState() == true)
-       {
-               __pContextMenuMore->SetShowState(false);
-       }
-
-       if ( __pOptionMenu != null && __pOptionMenu ->GetShowState() == true)
+       if (__pOptionMenu != null && __pOptionMenu ->GetShowState() == true)
        {
                __pOptionMenu->SetShowState(false);
                __pOptionMenu->Show();
@@ -516,7 +451,6 @@ AlbumListForm::OnContentUpdated(void)
        {
                if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_IMAGE)
                {
-                       __pPresentationModel->ClearThumbnailRequests(false);
                        __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_IMAGE);
                }
                else if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_VIDEO)
@@ -536,16 +470,6 @@ AlbumListForm::OnContentUpdated(void)
        __itemCount = __pPresentationModel->GetFolderCount();
        __pAlbumViewIconList->UpdateList();
 
-       if (__itemCount == 0 )
-       {
-               GetFooter()->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
-       }
-       else
-       {
-               GetFooter()->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
-       }
-
-       GetFooter()->Invalidate(true);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -565,6 +489,17 @@ AlbumListForm::OnThumbnailDecoded(const int index)
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
+void
+AlbumListForm::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);
+}
+
 result
 AlbumListForm::Update(void)
 {
@@ -579,12 +514,58 @@ void
 AlbumListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
 {
 
-       if ( __pOptionMenu == null )
+       if (__pOptionMenu == null || GetItemCount() == 0)
        {
-               return ;
+               return;
        }
 
        __pOptionMenu->SetShowState(true);
        __pOptionMenu->Show();
+}
+
+void
+AlbumListForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
+{
+       if (__pAlbumViewIconList != null)
+       {
+               RemoveControl(__pAlbumViewIconList);
+       }
+
+       __pAlbumViewIconList = new IconListView();
+
+       if (orientationStatus == ORIENTATION_STATUS_PORTRAIT)
+       {
+       __pAlbumViewIconList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height),
+                   Dimension(W_FOLDER_SIZE, H_FOLDER_SIZE), ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
+       }
+       else if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+       {
+               int horizontalSpacing = 8;
+               int verticalSpacing = 60;
+        int height = 424;
+        int width = 410;
+
+               __pAlbumViewIconList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height),
+                                   Dimension(width, height), ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
+
+               __pAlbumViewIconList->SetItemSpacing(horizontalSpacing, verticalSpacing);
+               __pAlbumViewIconList->SetMargin(MARGIN_TYPE_TOP,60);
+       }
+
+       Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
+
+       if (pBitmap != null)
+       {
+               __pAlbumViewIconList->SetBitmapOfEmptyList(pBitmap);
+               delete pBitmap;
+       }
+
+       __pAlbumViewIconList->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
+
+       __pAlbumViewIconList->SetItemProvider(*this);
+       __pAlbumViewIconList->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
+       __pAlbumViewIconList->AddIconListViewItemEventListener(*this);
+
+       AddControl(__pAlbumViewIconList);
 
 }