Fixed prevent issue
[apps/osp/Gallery.git] / src / GlFileListEditorForm.cpp
index 2c33ea5..30f36f9 100644 (file)
@@ -25,6 +25,7 @@
 #include "GlFileListPresentationModel.h"
 #include "GlGalleryApp.h"
 #include "GlImageListEditorPanel.h"
+#include "GlProgressAnimation.h"
 #include "GlResourceManager.h"
 #include "GlSlideSettingListener.h"
 #include "GlSlideShowPopUp.h"
@@ -43,13 +44,15 @@ using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Base::Utility;
 
-static const int GAP_W_POPUP_ITEM = 5;
-static const int W_DELETE_POPUP = 620;
-static const int H_DELETE_POPUP = 300;
-static const int H_DELETE_LABEL = 180;
-static const int Y_DELETE_BUTTON = 180;
-static const int H_DELETE_BUTTON = 80;
+static const int GAP_W_POPUP_ITEM = 10;
+static const int W_DELETE_POPUP = 688;
+static const int H_DELETE_POPUP = 230;
+static const int H_DELETE_LABEL = 80;
+static const int Y_DELETE_BUTTON = 132;
+static const int H_DELETE_BUTTON = 74;
+static const int W_DELETE_BUTTON = 318;
 static const int H_TOAST_LABEL = 48;
+static const int Y_DELETE_LABEL = 32;
 
 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
@@ -68,9 +71,11 @@ FileListEditorForm::FileListEditorForm(void)
        , __pFileMove(null)
        , __isCopyOperation(false)
        , __pPresentationModel(null)
+       , __isScanProgress(false)
 {
        AppLogDebug("ENTER");
        _overlayMsg = false;
+       _pProgressAnim = null;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -104,12 +109,46 @@ result
 FileListEditorForm::Initialize(void)
 {
        AppLogDebug("ENTER");
-       result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
+       result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE | FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE);
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return r;
 }
 
+void
+FileListEditorForm::ShowAnimation()
+{
+       AppLogDebug("ENTER");
+       Rectangle clientRect= GetClientAreaBounds();
+       Rectangle rect(0, 0, clientRect.width, clientRect.height);
+       _pProgressAnim = new (std::nothrow) ProgressAnimation;
+       _pProgressAnim->Construct(rect);
+       AddControl(_pProgressAnim);
+       _pProgressAnim->SetShowState(true);
+       GetFooter()->SetEnabled(false);
+       _pProgressAnim->AnimationStart();
+       _pProgressAnim->Draw();
+       _overlayMsg = true;
+       AppLogDebug("EXIT");
+}
+
+void
+FileListEditorForm::StopAnimation(void)
+{
+       AppLogDebug("ENTER");
+       if (_pProgressAnim)
+       {
+               _pProgressAnim->AnimationStop();
+               _pProgressAnim->SetShowState(false);
+               RemoveControl(_pProgressAnim);
+               GetFooter()->SetEnabled(true);
+               _pProgressAnim = null;
+               _overlayMsg = false;
+       }
+       AppLogDebug("EXIT");
+}
+
 result
 FileListEditorForm::OnInitializing(void)
 {
@@ -120,15 +159,6 @@ FileListEditorForm::OnInitializing(void)
        SetOrientation(ORIENTATION_AUTOMATIC);
        AddOrientationEventListener(*this);
 
-       __pPopUp = new (std::nothrow) SlideShowPopUp();
-
-       if (__pPopUp != null)
-       {
-               __pPopUp->Initialize();
-               __pPopUp->SetEventListner(this);
-               AddControl(__pPopUp);
-       }
-
        __pPresentationModel = FileListPresentationModel::GetInstance();
        __pPresentationModel->ClearThumbnailRequests();
 
@@ -262,20 +292,6 @@ FileListEditorForm::InitializeFooter(void)
 
                __pOptionMenu = new (std::nothrow) OptionMenu();
                __pOptionMenu->Construct();
-               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
-                               IDA_CONTEXT_MENU_MORE_MOVE);
-               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
-                               IDA_CONTEXT_MENU_MORE_COPY);
-
-               if (checkedCount > 1)
-               {
-                       __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
-                                       IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
-               }
-
-               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
-               __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
-
                __pOptionMenu->AddActionEventListener(*this);
 
                if (__pContentDirectoryNameList != null)
@@ -368,28 +384,45 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                        __pShareContextMenu = null;
                }
 
+               Bitmap* pBitmapEmailContextItem = null;
+               Bitmap* pBitmapMessageContextItem = null;
+               pBitmapEmailContextItem = ResourceManager::GetBitmapN(IDB_IMAGE_CONTEXT_EMAIL_ICON);
+               pBitmapMessageContextItem = ResourceManager::GetBitmapN(IDB_IMAGE_CONTEXT_MESSAGE_ICON);
+
                __pShareContextMenu = new (std::nothrow) ContextMenu();
                __pShareContextMenu->Construct(Point(GetClientAreaBounds().width/3 + 15, GetClientAreaBounds().height),
                                CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
-               __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
-                               IDA_CONTEXT_MENU_SHARE_MESSAGE);
-               __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
-                               IDA_CONTEXT_MENU_SHARE_EMAIL);
+
+               if ( pBitmapMessageContextItem != null)
+               {
+                       __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
+                               IDA_CONTEXT_MENU_SHARE_MESSAGE, *pBitmapMessageContextItem, null, null);
+                       delete pBitmapMessageContextItem;
+               }
+
+               if ( pBitmapEmailContextItem != null)
+               {
+                       __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
+                               IDA_CONTEXT_MENU_SHARE_EMAIL, *pBitmapEmailContextItem, null, null);
+                       delete pBitmapEmailContextItem;
+               }
                __pShareContextMenu->SetFocusable(true);
                __pShareContextMenu->AddActionEventListener(*this);
 
-                       Rectangle rect = source.GetBounds();
-                       if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
-                       {
-                               __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
-                       }
-                       else
-                       {
-                               __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
-                       }
 
-                       __pShareContextMenu->SetShowState(true);
-                       __pShareContextMenu->Show();
+               Rectangle rect = source.GetBounds();
+
+               if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
+               {
+                       __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
+               }
+               else
+               {
+                       __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
+               }
+
+               __pShareContextMenu->SetShowState(true);
+               __pShareContextMenu->Show();
 
        }
        break;
@@ -474,8 +507,17 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
 
        case IDA_CONTEXT_MENU_MORE_SLIDE_SHOW:
        {
+               if (__pPopUp != NULL)
+               {
+                       delete __pPopUp;
+                       __pPopUp = NULL;
+               }
+               __pPopUp = new (std::nothrow) SlideShowPopUp();
+
                if (__pPopUp != null)
                {
+                       __pPopUp->Initialize();
+                       __pPopUp->SetEventListner(this);
                        __pPopUp->SetShowState(true);
                        __pPopUp->Show();
                }
@@ -709,11 +751,9 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                        {
                                                delete __pFileMove;
                                                IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
-                                               GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
                                                __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
                                                if (__isCopyOperation)
                                                {
-                                                       AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
                                                        __pFileMove->SetCopy();
                                                }
 
@@ -754,11 +794,9 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
                                        {
                                                delete __pFileMove;
                                                IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
-                                               GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
                                                __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
                                                if (__isCopyOperation)
                                                {
-                                                       AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
                                                        __pFileMove->SetCopy();
                                                }
                                                result r = __pFileMove->StartTimer();
@@ -788,6 +826,27 @@ FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
        Invalidate(true);
 }
 
+
+void
+FileListEditorForm::OnScanDirStart()
+{
+       AppLogDebug("ENTER");
+       GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, false);
+       __isScanProgress = true;
+       Invalidate(true);
+       AppLogDebug("EXIT");
+}
+void
+FileListEditorForm::OnScanDirComplete()
+{
+       AppLogDebug("ENTER");
+       GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
+       __isScanProgress = false;
+       Invalidate(true);
+       AppLogDebug("EXIT");
+}
+
+
 bool
 FileListEditorForm::GetOverlayStatus(void) const
 {
@@ -797,6 +856,7 @@ FileListEditorForm::GetOverlayStatus(void) const
 void
 FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
 {
+       AppLogDebug("ENTER");
        _overlayMsg = false;
        __pPresentationModel->SetUpdateProgressStatus(false);
        if (res != COMPLETE_SUCCESS)
@@ -811,6 +871,7 @@ FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActi
                AppAssert(pSceneManager);
                pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
        }
+       AppLogDebug("EXIT");
 }
 
 void
@@ -883,14 +944,14 @@ FileListEditorForm::SetUpPopup(void)
        Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
 
        Label* pLabelText = new (std::nothrow) Label();
-       pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
+       pLabelText->Construct(Rectangle(0, Y_DELETE_LABEL, popupClientBounds.width, H_DELETE_LABEL),
                        ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
        pLabelText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
        pLabelText->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
        __pDeletePopup->AddControl(pLabelText);
 
        Button* pDeleteButton = new (std::nothrow) Button();
-       pDeleteButton->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON),
+       pDeleteButton->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON),
                        ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
        pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
        pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
@@ -900,7 +961,7 @@ FileListEditorForm::SetUpPopup(void)
        __pDeletePopup->AddControl(pDeleteButton);
 
        Button* pButtonCancel = new (std::nothrow) Button();
-       pButtonCancel->Construct(Rectangle(10, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON),
+       pButtonCancel->Construct(Rectangle(16, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON),
                        ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
        pButtonCancel->SetActionId(IDA_DELETE_POPUP_CANCEL);
        pButtonCancel->AddActionEventListener(*this);
@@ -982,11 +1043,13 @@ FileListEditorForm::RefreshFolderList(void)
 
                loopCount = __pContentDirectoryNameList->GetCount();
 
+               String dirAllAlbums = L"All albums";
+
                for (int i = 0; i < loopCount; ++i)
                {
                        pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
 
-                       if (*pDirName != __pPresentationModel->GetCurrentAlbumName())
+                       if (*pDirName != __pPresentationModel->GetCurrentAlbumName() || *pDirName == dirAllAlbums)
                        {
                                __pOptionMenu->AddItem(*(new (std::nothrow) String(*pDirName)),
                                                IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
@@ -1002,6 +1065,12 @@ FileListEditorForm::OnFormBackRequested(Form& source)
 {
        AppLogDebug("ENTER");
 
+       if(__isScanProgress)
+       {
+               AppLog (" Skip the call");
+               return;
+       }
+
        SceneManager* pSceneManager = SceneManager::GetInstance();
        TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
 
@@ -1137,6 +1206,13 @@ FileListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen
                        pEditorPanel->ChangeOrientation();
                }
        }
+
+       if (_pProgressAnim != null)
+       {
+               _pProgressAnim->ChangeOrientation(Form::GetBounds());
+               _pProgressAnim->Invalidate(true);
+       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -1145,7 +1221,7 @@ FileListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo
 {
        AppLogDebug("ENTER");
 
-       if(keyEventInfo.GetKeyCode() == KEY_BACK)
+       if(keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
        {
                _overlayMsg = false;
                __pDeletePopup->SetShowState(false);
@@ -1278,6 +1354,10 @@ FileListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const Scen
 void
 FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
 {
+       if(__isScanProgress)
+       {
+               return;
+       }
 
        SceneManager* pSceneManager = SceneManager::GetInstance();
        int checkedCount = 0;
@@ -1304,6 +1384,11 @@ FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
                __pShareContextMenu->SetShowState(false);
        }
 
+       if (checkedCount < 2 &&  __pPresentationModel->GetCurrentAlbumName() == ALL_ALBUMS_REAL_NAME  )
+       {
+          return;  // no option Menu items in this case
+       }
+
        if (checkedCount > 0)
        {
                if (__pOptionMenu == null)
@@ -1312,10 +1397,14 @@ FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
                }
 
                __pOptionMenu->RemoveAllItems();
+
+               if ( __pPresentationModel->GetCurrentAlbumName() != ALL_ALBUMS_REAL_NAME )
+               {
                __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
                                IDA_CONTEXT_MENU_MORE_MOVE);
                __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
                                IDA_CONTEXT_MENU_MORE_COPY);
+               }
 
                if (checkedCount > 1)
                {
@@ -1323,10 +1412,19 @@ FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
                                        IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
                }
 
+               if ( __pPresentationModel->GetCurrentAlbumName() != ALL_ALBUMS_REAL_NAME )
+               {
                __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
                __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
+               }
 
                __pOptionMenu->SetShowState(true);
                __pOptionMenu->Show();
        }
 }
+
+void
+FileListEditorForm::SetProgressState(const bool progressState)
+{
+       __isScanProgress = progressState;
+}