remove - backspace key
[apps/osp/Gallery.git] / src / GlAlbumListEditorForm.cpp
index d799d71..55530cd 100644 (file)
@@ -43,9 +43,10 @@ static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Val
 static const String RESERVED_CAMERA_PATH = Environment::GetMediaPath() + L"Camera" + DIRECTORY_SEPARATOR;
 static const String RESERVED_CAMERA_PATH_EXT = Environment::GetExternalStoragePath() + L"Camera" + DIRECTORY_SEPARATOR;
 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 = 600;
+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;
@@ -53,13 +54,10 @@ static const int H_DELETE_BUTTON = 80;
 
 static const int FORMAT_BUFFER_SIZE = 256;
 
-static const int X_POSITION_SHARE_CONTEXTMENU = 280;
-static const int Y_POSITION_SHARE_CONTEXTMENU = 1140;
-
 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)
@@ -95,6 +93,10 @@ AlbumListEditorForm::OnInitializing(void)
 {
        AppLogDebug("ENTER");
        result r = E_SUCCESS;
+
+       SetOrientation(ORIENTATION_AUTOMATIC);
+       AddOrientationEventListener(*this);
+
        __pPresentationModel = AlbumListPresentationModel::GetInstance();
        __pPresentationModel->ClearThumbnailRequests();
        r = __pPresentationModel->AddPresentationModelListener(this);
@@ -141,10 +143,10 @@ void
 AlbumListEditorForm::OnContentUpdated(void)
 {
        AppLogDebug("ENTER");
-       int maxCount = __pPresentationModel->GetFolderCount();\r
-       if(__pDeletePopup != null)
+       int maxCount = __pPresentationModel->GetFolderCount();
+       if (__pDeletePopup != null)
        {
-               if(__pDeletePopup->IsVisible() == true)
+               if (__pDeletePopup->IsVisible() == true)
                {
                        __pDeletePopup->Destroy();
                        __pDeletePopup = null;
@@ -152,10 +154,10 @@ AlbumListEditorForm::OnContentUpdated(void)
                }
        }
 
-       for (int i = 0; i < maxCount; ++i)\r
-       {\r
-               __pEditorFolderIconList->SetItemChecked(i, false);\r
-       }\r
+       for (int i = 0; i < maxCount; ++i)
+       {
+               __pEditorFolderIconList->SetItemChecked(i, false);
+       }
        SceneManager* pSceneManager = SceneManager::GetInstance();
        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -168,19 +170,12 @@ AlbumListEditorForm::InitializeControl(void)
        result r = E_SUCCESS;
        String tempString;
 
+       __pSelectCountLabel = static_cast<Label*>(GetControl(L"IDC_LABEL_ALBUM_LIST_EDITOR_SELECTED"));
+               AppAssert(__pSelectCountLabel);
+
        CreateIconListView();
        __checkedCount = GetCheckedFolderCount();
 
-       __pSelectCountLabel = static_cast<Label*>(GetControl(L"IDC_LABEL_ALBUM_LIST_EDITOR_SELECTED"));
-       AppAssert(__pSelectCountLabel);
-
-       __pShareContextMenu = new (std::nothrow) ContextMenu();
-       r = __pShareContextMenu->Construct(Point(X_POSITION_SHARE_CONTEXTMENU, Y_POSITION_SHARE_CONTEXTMENU),
-                       CONTEXT_MENU_STYLE_LIST);
-       r = __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
-                       IDA_CONTEXT_MENU_MESSAGE);
-       r = __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), IDA_CONTEXT_MENU_EMAIL);
-       __pShareContextMenu->AddActionEventListener(*this);
 
        r = InitializePopup();
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -196,6 +191,7 @@ AlbumListEditorForm::InitializePopup(void)
        {
                __pDeletePopup = new (std::nothrow) Popup();
                __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
+               __pDeletePopup->SetPropagatedKeyEventListener(this);
 
                Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
 
@@ -206,8 +202,7 @@ AlbumListEditorForm::InitializePopup(void)
                pLabel->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
 
                Button* pDeleteButton = new (std::nothrow) Button();
-               pDeleteButton->Construct(
-                               Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_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),
                                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);
@@ -216,16 +211,14 @@ 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, H_DELETE_BUTTON),
-                                               ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
+               pCancelButton->Construct(Rectangle(10, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON),
+                               ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
                pCancelButton->SetActionId(IDA_DELETE_POPUP_CANCEL);
                pCancelButton->AddActionEventListener(*this);
 
-               __pDeletePopup->AddControl(*pLabel);
-               __pDeletePopup->AddControl(*pDeleteButton);
-               __pDeletePopup->AddControl(*pCancelButton);
+               __pDeletePopup->AddControl(pLabel);
+               __pDeletePopup->AddControl(pDeleteButton);
+               __pDeletePopup->AddControl(pCancelButton);
        }
        else
        {
@@ -241,12 +234,31 @@ void
 AlbumListEditorForm::CreateIconListView(void)
 {
        AppLogDebug("ENTER");
-       __pEditorFolderIconList = static_cast<IconListView*>(GetControl(L"IDC_ICONLISTVIEW_ALBUM_LIST_EDITOR"));
-       AppAssert(__pEditorFolderIconList);
 
+
+       __pEditorFolderIconList = new IconListView();
+       __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);
+       __pEditorFolderIconList->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT);
+       __pEditorFolderIconList->SetTouchAnimationEnabled(false);
        __pEditorFolderIconList->SetItemProvider(*this);
+       __pEditorFolderIconList->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
        __pEditorFolderIconList->AddIconListViewItemEventListener(*this);
+
+       Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
+
+       if (pBitmap != null)
+       {
+               __pEditorFolderIconList->SetBitmapOfEmptyList(pBitmap);
+               delete pBitmap;
+       }
+
+       __pEditorFolderIconList->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
+
+       AddControl(__pEditorFolderIconList);
+
        __pEditorFolderIconList->SetShowState(true);
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -268,9 +280,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();
 
@@ -321,8 +333,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();
@@ -330,8 +342,9 @@ AlbumListEditorForm::CreateItem(int index)
                if (pEditAlbumBitmap != NULL)
                {
                        pEditAlbumBitmap->Construct(*pEditAlbumCanvas, Rectangle(0, 0, canvasWidth, canvasHeight));
-                       delete pEditAlbumCanvas;
+
                }
+               delete pEditAlbumCanvas;
 
                albumName = pAlbumInfo->GetAlbumName();
                String reservedCameraName = ResourceManager::GetString(L"IDS_MEDIABR_BODY_CAMERA_ROLL_ABB");
@@ -340,7 +353,7 @@ AlbumListEditorForm::CreateItem(int index)
 
                if (index == 0 || (reservedCameraName.Equals(albumName, true) &&
                        (RESERVED_CAMERA_PATH.Equals(albumPath, true) || RESERVED_CAMERA_PATH_EXT.Equals(albumPath, true)))
-                       || RESERVED_MEDIA_PATH.Equals(albumPath, true))
+                       || RESERVED_MEDIA_PATH.Equals(albumPath, true) || RESERVED_EXTERNAL_MEDIA_PATH.Equals(albumPath, true))
                {
                        // rename disabled
                }
@@ -355,6 +368,15 @@ AlbumListEditorForm::CreateItem(int index)
                }
        }
 
+       if (pBitmapRenameBg)
+       {
+               delete pBitmapRenameBg;
+       }
+       if (pBitmapRename)
+       {
+               delete pBitmapRename;
+       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return pIconListviewItem;
@@ -413,6 +435,14 @@ 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)
+       {
+               __pEditorFolderIconList->SetItemChecked(index,true);
+       }
+       else
+       {
+               __pEditorFolderIconList->SetItemChecked(index,false);
+       }
        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pSelectedIndex);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
@@ -533,11 +563,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()));
@@ -573,6 +603,21 @@ AlbumListEditorForm::OnActionPerformed(const Control& source, int actionId)
 
        case IDA_FOOTER_SHARE:
        {
+
+               if (__pShareContextMenu != NULL)
+               {
+                       delete __pShareContextMenu;
+                       __pShareContextMenu = null;
+               }
+
+               __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);
+                __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);
+               __pShareContextMenu->SetFocusable(true);
+               __pShareContextMenu->AddActionEventListener(*this);
                __pShareContextMenu->SetShowState(true);
                __pShareContextMenu->Show();
        }
@@ -625,39 +670,44 @@ AlbumListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
                const SceneId& currentSceneId, IList* pArgs)
 {
        AppLogDebug("ENTER OnSceneActivatedN");
-       __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_ALL);
-
-       int count = __pPresentationModel->GetFolderCount();
+       String tempString;
 
-       for ( int index = 0 ; index < count ; index++ )
-       {
-               __pEditorFolderIconList->SetItemChecked(index,false);
-       }
 
-       __pEditorFolderIconList->UpdateList();
+       int count = __pPresentationModel->GetFolderCount();
 
        __pPresentationModel->AddContentEventListener(this);
 
        __checkedCount = GetCheckedFolderCount();
 
-       String tempString;
-
-       if (__checkedCount == 0)
+       if (previousSceneId == IDSCN_ALBUM_NAME_EDITOR)
        {
-               tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
-       }
-       else if (__checkedCount == 1)
-       {
-               tempString = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
+
+               if (__checkedCount ==  0)
+               {
+                       tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
+               }
+               else
+               {
+                       tempString.Format(FORMAT_BUFFER_SIZE,
+                                       ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), __checkedCount);
+               }
        }
        else
        {
-               tempString.Format(FORMAT_BUFFER_SIZE,
-                               ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), __checkedCount);
+               __pPresentationModel->InitializeAlbumInfoList(CONTENT_TYPE_ALL);
+
+               for (int index = 0; index < count; ++index)
+               {
+                       __pEditorFolderIconList->SetItemChecked(index,false);
+               }
+
+               __pEditorFolderIconList->UpdateList();
+
+               tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
        }
 
        __pSelectCountLabel->SetText(tempString);
-       __pSelectCountLabel->RequestRedraw();
+       __pSelectCountLabel->Invalidate(true);
 
        SetButtonState();
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -668,6 +718,18 @@ AlbumListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const Sce
 {
        AppLogDebug("ENTER");
        __pPresentationModel->RemoveContentEventListener(*this);
+
+       if (nextSceneId != IDSCN_ALBUM_NAME_EDITOR)
+       {
+               int loopCount = __pPresentationModel->GetFolderCount();
+
+               for (int count = 0; count < loopCount; ++count)
+               {
+                       __pEditorFolderIconList->SetItemChecked(count,false);
+               }
+               __pEditorFolderIconList->UpdateList();
+       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -703,6 +765,20 @@ void AlbumListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum Fi
        SceneManager* pSceneManager = SceneManager::GetInstance();
        AppAssert(pSceneManager);
        pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+bool AlbumListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
+{
+       AppLogDebug("ENTER");
+
+       if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
+       {
+               __pDeletePopup->SetShowState(false);
+               __pDeletePopup->Show();
+       }
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+       return false;
 }
 
 result
@@ -779,7 +855,7 @@ AlbumListEditorForm::OnRequestMessage(void)
                r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE,
                                null, null, pDataList, null);
 
-               if(r == E_MAX_EXCEEDED)
+               if (r == E_MAX_EXCEEDED)
                {
                        MessageBox messageBox;
                        messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
@@ -854,7 +930,7 @@ AlbumListEditorForm::OnRequestEmail(void)
                r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
                                new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, null);
 
-               if(r == E_MAX_EXCEEDED)
+               if (r == E_MAX_EXCEEDED)
                {
                        MessageBox messageBox;
                        messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
@@ -904,3 +980,64 @@ AlbumListEditorForm::SetButtonState(void)
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
+
+
+void
+AlbumListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
+{
+
+       IList* pIndexList = GetItemCheckedIndexListN();
+
+       if (__pEditorFolderIconList != null)
+       {
+               RemoveControl(__pEditorFolderIconList);
+       }
+
+       __pEditorFolderIconList = new IconListView();
+
+       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);
+       }
+       else if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+       {
+               int horizontalSpacing = 8;
+               int verticalSpacing = 60;
+        int height = 424;
+        int width = 410;
+
+        __pEditorFolderIconList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height - __pSelectCountLabel->GetHeight()),
+                                   Dimension(width, height), ICON_LIST_VIEW_STYLE_MARK, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
+
+        __pEditorFolderIconList->SetItemSpacing(horizontalSpacing, verticalSpacing);
+        __pEditorFolderIconList->SetMargin(MARGIN_TYPE_TOP,40);
+       }
+
+       Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
+
+       if (pBitmap != null)
+       {
+               __pEditorFolderIconList->SetBitmapOfEmptyList(pBitmap);
+               delete pBitmap;
+       }
+
+       __pEditorFolderIconList->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT);
+       __pEditorFolderIconList->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
+       __pEditorFolderIconList->SetTouchAnimationEnabled(false);
+       __pEditorFolderIconList->SetItemProvider(*this);
+       __pEditorFolderIconList->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
+       __pEditorFolderIconList->AddIconListViewItemEventListener(*this);
+
+       AddControl(__pEditorFolderIconList);
+
+       int loopCount = pIndexList->GetCount();
+       int index = -1;
+       for (int count = 0; count < loopCount; ++count)
+       {
+               Integer* pRealIndex = static_cast<Integer*>(pIndexList->GetAt(count));
+                index = pRealIndex->ToInt();
+               __pEditorFolderIconList->SetItemChecked(index, true);
+               __pEditorFolderIconList->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
+       }
+}