Fixed prevent issue
[apps/osp/Gallery.git] / src / GlAlbumListEditorForm.cpp
index a59d0cf..5b90aac 100644 (file)
@@ -22,6 +22,7 @@
 #include "GlAlbumInfo.h"
 #include "GlAlbumListEditorForm.h"
 #include "GlAlbumListPresentationModel.h"
+#include "GlProgressAnimation.h"
 #include "GlResourceManager.h"
 #include "GlTypes.h"
 
@@ -45,19 +46,21 @@ static const String RESERVED_CAMERA_PATH_EXT = Environment::GetExternalStoragePa
 static const String RESERVED_MEDIA_PATH = Environment::GetMediaPath();
 static const String RESERVED_EXTERNAL_MEDIA_PATH = Environment::GetExternalStoragePath();
 
-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 Y_DELETE_LABEL = 32;
 
 static const int FORMAT_BUFFER_SIZE = 256;
 
 static const Color COLOR_FOLDER_BITMAP_DIM(Color::GetColor(COLOR_ID_BLACK));
 static const int ALPHA_FOLDER_BITMAP_DIM = 70;
 
-static const int IDA_ALBUM_EDIT = 503 ;
+static const int IDA_ALBUM_EDIT = 503;
 
 AlbumListEditorForm::AlbumListEditorForm(void)
        : __checkedCount(0)
@@ -67,8 +70,10 @@ AlbumListEditorForm::AlbumListEditorForm(void)
        , __pDeletePopup(null)
        , __pFileUpdateTimer(null)
        , __pPresentationModel(null)
+       , __isScanProgress(false)
 {
        AppLogDebug("ENTER");
+       _pProgressAnim = null;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -140,13 +145,40 @@ AlbumListEditorForm::OnTerminating(void)
 }
 
 void
+AlbumListEditorForm::ShowAnimation(void)
+{
+       Rectangle clientRect= GetClientAreaBounds();
+       Rectangle rect(0, 0, clientRect.width, clientRect.height);
+       _pProgressAnim = new (std::nothrow) ProgressAnimation;
+       _pProgressAnim->Construct(rect);
+       AddControl(_pProgressAnim);
+       SetControlAlwaysOnTop(*_pProgressAnim,true);
+       _pProgressAnim->SetShowState(true);
+       GetFooter()->SetEnabled(false);
+       _pProgressAnim->AnimationStart();
+       _pProgressAnim->Draw();
+}
+void
+AlbumListEditorForm::StopAnimation(void)
+{
+       if (_pProgressAnim)
+       {
+               _pProgressAnim->AnimationStop();
+               _pProgressAnim->SetShowState(false);
+               RemoveControl(_pProgressAnim);
+               GetFooter()->SetEnabled(true);
+               _pProgressAnim = null;
+       }
+}
+
+void
 AlbumListEditorForm::OnContentUpdated(void)
 {
        AppLogDebug("ENTER");
        int maxCount = __pPresentationModel->GetFolderCount();
-       if(__pDeletePopup != null)
+       if (__pDeletePopup != null)
        {
-               if(__pDeletePopup->IsVisible() == true)
+               if (__pDeletePopup->IsVisible() == true)
                {
                        __pDeletePopup->Destroy();
                        __pDeletePopup = null;
@@ -196,14 +228,13 @@ AlbumListEditorForm::InitializePopup(void)
                Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
 
                Label* pLabel = new (std::nothrow) Label();
-               pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
+               pLabel->Construct(Rectangle(0, Y_DELETE_LABEL, popupClientBounds.width, H_DELETE_LABEL),
                                ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
                pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
                pLabel->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
 
                Button* pDeleteButton = new (std::nothrow) Button();
-               pDeleteButton->Construct(
-                               Rectangle(10, 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);
@@ -212,10 +243,8 @@ AlbumListEditorForm::InitializePopup(void)
                pDeleteButton->AddActionEventListener(*this);
 
                Button* pCancelButton = new (std::nothrow) Button();
-               pCancelButton->Construct(
-                               Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
-                                               popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON),
-                                               ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
+               pCancelButton->Construct(Rectangle(16, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON),
+                               ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
                pCancelButton->SetActionId(IDA_DELETE_POPUP_CANCEL);
                pCancelButton->AddActionEventListener(*this);
 
@@ -283,9 +312,9 @@ AlbumListEditorForm::CreateItem(int index)
        Bitmap* pEditAlbumBitmap = null;
        Bitmap* pBitmapRenameBg = null;
        Bitmap* pBitmapRename = null;
-       String albumName ;
-       int canvasWidth = 64;
-       int canvasHeight = 64;
+       String albumName;
+       int canvasWidth = 75;
+       int canvasHeight = 75;
 
        IconListViewItem* pIconListviewItem = new (std::nothrow) IconListViewItem();
 
@@ -336,8 +365,8 @@ AlbumListEditorForm::CreateItem(int index)
 
                pEditAlbumCanvas = new (std::nothrow) Canvas();
                pEditAlbumCanvas->Construct(Rectangle(0, 0, canvasWidth, canvasHeight));
-               pEditAlbumCanvas->DrawBitmap(Point(0, 0), *pBitmapRenameBg);
-               pEditAlbumCanvas->DrawBitmap(Point(0, 0), *pBitmapRename);
+               pEditAlbumCanvas->DrawBitmap(Point(0, 6), *pBitmapRenameBg);
+               pEditAlbumCanvas->DrawBitmap(Point(0, 6), *pBitmapRename);
 
 
                pEditAlbumBitmap = new (std::nothrow) Bitmap();
@@ -350,6 +379,12 @@ AlbumListEditorForm::CreateItem(int index)
                delete pEditAlbumCanvas;
 
                albumName = pAlbumInfo->GetAlbumName();
+
+               if (albumName == ALL_ALBUMS_REAL_NAME)
+               {
+                       albumName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_ALL_ALBUMS");
+               }
+
                String reservedCameraName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB");
                String albumPath = pAlbumInfo->GetDirectory(0);
                albumPath.Append(DIRECTORY_SEPARATOR);
@@ -371,6 +406,15 @@ AlbumListEditorForm::CreateItem(int index)
                }
        }
 
+       if (pBitmapRenameBg)
+       {
+               delete pBitmapRenameBg;
+       }
+       if (pBitmapRename)
+       {
+               delete pBitmapRename;
+       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return pIconListviewItem;
@@ -429,7 +473,7 @@ AlbumListEditorForm::OnIconListViewOverlayBitmapSelected (IconListView &iconList
        pSelectedIndex->Add(new (std::nothrow) Integer(FILE_ACTION_MOVE));
        pSelectedIndex->Add(new (std::nothrow) Integer(index));
 
-       if( __pEditorFolderIconList->IsItemChecked(index) == false )
+       if (__pEditorFolderIconList->IsItemChecked(index) == false)
        {
                __pEditorFolderIconList->SetItemChecked(index,true);
        }
@@ -557,11 +601,11 @@ AlbumListEditorForm::GetCheckedFolderCount(void) const
        int maxCount = __pPresentationModel->GetFolderCount();
        int count = 0;
 
-       for (int i = 0 ; i < maxCount; ++i)
+       for (int i = 0; i < maxCount; ++i)
        {
                if (__pEditorFolderIconList->IsItemChecked (i))
                {
-                       count++;
+                       ++count;
                }
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -598,18 +642,38 @@ AlbumListEditorForm::OnActionPerformed(const Control& source, int actionId)
        case IDA_FOOTER_SHARE:
        {
 
-               if__pShareContextMenu != NULL)
+               if (__pShareContextMenu != NULL)
                {
                        delete __pShareContextMenu;
                        __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 + __pSelectCountLabel->GetHeight() + 5),
                                CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
+
+               if ( pBitmapMessageContextItem != null)
+               {
                 __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
-                               IDA_CONTEXT_MENU_MESSAGE);
-               __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), IDA_CONTEXT_MENU_EMAIL);
+                               IDA_CONTEXT_MENU_MESSAGE , *pBitmapMessageContextItem, null, null);
+
+                        delete pBitmapMessageContextItem;
+               }
+
+               if ( pBitmapEmailContextItem != null)
+               {
+                       __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), IDA_CONTEXT_MENU_EMAIL,
+                                       *pBitmapEmailContextItem, null, null);
+
+                        delete pBitmapEmailContextItem;
+               }
+
                __pShareContextMenu->SetFocusable(true);
                __pShareContextMenu->AddActionEventListener(*this);
                __pShareContextMenu->SetShowState(true);
@@ -651,9 +715,22 @@ AlbumListEditorForm::OnActionPerformed(const Control& source, int actionId)
 }
 
 void
+AlbumListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
+{
+       if(__isScanProgress)
+       {
+               return;
+       }
+}
+
+void
 AlbumListEditorForm::OnFormBackRequested(Form& source)
 {
        AppLogDebug("ENTER");
+       if(__isScanProgress)
+       {
+               return;
+       }
        SceneManager* pSceneManager = SceneManager::GetInstance();
        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -673,7 +750,7 @@ AlbumListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
 
        __checkedCount = GetCheckedFolderCount();
 
-       if ( previousSceneId == IDSCN_ALBUM_NAME_EDITOR )
+       if (previousSceneId == IDSCN_ALBUM_NAME_EDITOR)
        {
 
                if (__checkedCount ==  0)
@@ -690,12 +767,13 @@ AlbumListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
        {
                __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_ALL);
 
-               for ( int index = 0 ; index < count ; index++ )
+               for (int index = 0; index < count; ++index)
                {
                        __pEditorFolderIconList->SetItemChecked(index,false);
                }
 
                __pEditorFolderIconList->UpdateList();
+               __checkedCount = 0;
 
                tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
        }
@@ -713,11 +791,11 @@ AlbumListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const Sce
        AppLogDebug("ENTER");
        __pPresentationModel->RemoveContentEventListener(*this);
 
-       if (nextSceneId != IDSCN_ALBUM_NAME_EDITOR )
+       if (nextSceneId != IDSCN_ALBUM_NAME_EDITOR)
        {
                int loopCount = __pPresentationModel->GetFolderCount();
 
-               for( int count = 0 ; count < loopCount ; count++ )
+               for (int count = 0; count < loopCount; ++count)
                {
                        __pEditorFolderIconList->SetItemChecked(count,false);
                }
@@ -743,12 +821,33 @@ AlbumListEditorForm::OnThumbnailDecoded(const int index)
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
-void AlbumListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
+void
+AlbumListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
 {
        Invalidate(true);
 }
 
-void AlbumListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
+void
+AlbumListEditorForm::OnScanDirStart()
+{
+       AppLogDebug("SANTHOSH ENTER");
+       GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, false);
+       Invalidate(true);
+       __isScanProgress = true;
+       AppLogDebug("SANTHOSH EXIT");
+}
+void
+AlbumListEditorForm::OnScanDirComplete()
+{
+       AppLogDebug("SANTHOSH ENTER");
+       GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
+       Invalidate(true);
+       __isScanProgress = false;
+       AppLogDebug("SANTHOSH EXIT");
+}
+
+void
+AlbumListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
 {
        AppLogDebug("ENTER");
        __pPresentationModel->SetUpdateProgressStatus(false);
@@ -762,16 +861,17 @@ void AlbumListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum Fi
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
-bool AlbumListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
+bool
+AlbumListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
 {
        AppLogDebug("ENTER");
-       if(keyEventInfo.GetKeyCode() == KEY_BACK)
+
+       if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
        {
                __pDeletePopup->SetShowState(false);
                __pDeletePopup->Show();
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
-
        return false;
 }
 
@@ -982,14 +1082,14 @@ AlbumListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tize
 
        IList* pIndexList = GetItemCheckedIndexListN();
 
-       if( __pEditorFolderIconList != null )
+       if (__pEditorFolderIconList != null)
        {
                RemoveControl(__pEditorFolderIconList);
        }
 
        __pEditorFolderIconList = new IconListView();
 
-       if( orientationStatus == ORIENTATION_STATUS_PORTRAIT )
+       if (orientationStatus == ORIENTATION_STATUS_PORTRAIT)
        {
                __pEditorFolderIconList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height- __pSelectCountLabel->GetHeight()),
                    Dimension(348, 348), ICON_LIST_VIEW_STYLE_MARK, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
@@ -1026,8 +1126,8 @@ AlbumListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tize
        AddControl(__pEditorFolderIconList);
 
        int loopCount = pIndexList->GetCount();
-       int index = -1 ;
-       for(int count = 0 ; count < loopCount; count ++)
+       int index = -1;
+       for (int count = 0; count < loopCount; ++count)
        {
                Integer* pRealIndex = static_cast<Integer*>(pIndexList->GetAt(count));
                 index = pRealIndex->ToInt();
@@ -1035,5 +1135,9 @@ AlbumListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tize
                __pEditorFolderIconList->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
        }
 
+       if (_pProgressAnim != null)
+       {
+               _pProgressAnim->ChangeOrientation(Form::GetBounds());
+               _pProgressAnim->Invalidate(true);
+       }
 }
-