2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file: MfSubBaseFolderEntryForm.cpp
19 * @brief: This file contains the implementation of SubBaseFolderEntryForm class, which acts as a base form for
20 * the TopMostFileFolderListForm and SubFileFolderListForm.
23 #include "MfSubBaseFolderEntryForm.h"
25 using namespace Tizen::App;
26 using namespace Tizen::App::Package;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Base::Utility;
30 using namespace Tizen::Content;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Io;
33 using namespace Tizen::Locales;
34 using namespace Tizen::Media;
35 using namespace Tizen::System;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
40 SubBaseFolderEntryForm::SubBaseFolderEntryForm(void)
41 : _pFileEventManager(null)
42 , _pPackageManager(null)
44 , _pCancelDeletion(null)
45 , _pCancelSortBy(null)
46 , _pCancelViewAs(null)
48 , _pFileProgressingCancelButton(null)
49 , _pIconListViewContextMenu(null)
50 , _pMoreContextMenu(null)
57 , _pIconListView(null)
58 , _pFileProgressingHeaderLabel(null)
59 , _pFileProgressingLabel(null)
60 , _pLabelDisplayPath(null)
63 , _pSortByListView(null)
64 , _pViewAsListView(null)
66 , _pDeleteConfirmationPopUp(null)
67 , _pFileProgressingPopup(null)
70 , _pLongPressGestureDetector(null)
71 , _pBaseItemProvider(null)
72 , _pCustomListViewForPopup(null)
74 , _pFolderEntryPM(null)
75 , _pMediaMetaData(null)
76 , _pThumbnailItemProvider(null)
77 , _pThumbnailManager(null)
79 _bIsTopLevelDirectory = false;
80 _bIsDirectoryEmpty = false;
81 _bBackFromAppControl = false;
82 _bIsDeleteFromContextSwipe = false;
84 _flagViewAsStatus = 0;
91 _selectedItemIndex = -1;
94 SubBaseFolderEntryForm::~SubBaseFolderEntryForm(void)
98 if (_pFolderEntryPM != null)
100 delete _pFolderEntryPM;
103 if (_pMoreContextMenu != null)
105 delete _pMoreContextMenu;
108 if (_pOptionMenu != null)
113 if (_pViewAsPopup != null)
115 delete _pViewAsPopup;
118 if (_pDeleteConfirmationPopUp != null)
120 delete _pDeleteConfirmationPopUp;
123 if (_pCustomListViewForPopup != null)
125 delete _pCustomListViewForPopup;
128 if (_pMediaMetaData != null)
130 delete _pMediaMetaData;
133 if (_pSortByPopup != null)
135 delete _pSortByPopup;
138 if (_pFileProgressingPopup != null)
140 delete _pFileProgressingPopup;
143 if (_pThumbnailItemProvider != null)
145 delete _pThumbnailItemProvider;
148 if (_pBaseItemProvider != null)
150 delete _pBaseItemProvider;
158 if (_pSortBy != null)
163 if (_pSearch != null)
173 if (_pFileEventManager != null)
175 delete _pFileEventManager;
178 if (_pIconListViewContextMenu != null)
180 delete _pIconListViewContextMenu;
184 SubBaseFolderEntryForm&
185 SubBaseFolderEntryForm::operator =(const SubBaseFolderEntryForm& pSubBaseFolderEntryForm)
190 SubBaseFolderEntryForm::SubBaseFolderEntryForm(const SubBaseFolderEntryForm& pSubBaseFolderEntryForm)
196 SubBaseFolderEntryForm::CreateFooterControls(void)
198 AppLogDebug("ENTER");
199 //Create Footer and controls contained within the footer
200 result r = E_SUCCESS;
202 AppResource* pAppResource = null;
206 ButtonItem footerItemMenu;
208 pAppResource = Application::GetInstance()->GetAppResource();
210 if (pAppResource != null)
212 pAppResource->GetString(L"IDS_MF_SK3_EDIT", buttonEdit);
213 pAppResource->GetString(L"IDS_COM_BUTTON_SHARE", buttonShare);
218 _pEdit = new (std::nothrow) FooterItem();
219 _pEdit->Construct(IDA_BTN_EDIT);
220 _pEdit->SetText(buttonEdit);
225 _pShare = new (std::nothrow) FooterItem();
226 _pShare->Construct(IDA_BTN_SHARE);
227 _pShare->SetText(buttonShare);
230 //Get the Footer and set the FooterItems.
231 _pFooter = GetFooter();
232 if (_pFooter != null)
234 _pFooter->RemoveAllButtons();
235 _pFooter->RemoveAllItems();
237 _pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
238 _pFooter->AddItem(*_pEdit);
239 _pFooter->AddItem(*_pShare);
241 //Set am ActionEventListener to the Footer
242 _pFooter->AddActionEventListener(*this);
243 _pFooter->SetItemEnabled(0, false);
244 _pFooter->SetItemEnabled(1, false);
245 _pFooter->Invalidate(true);
252 SubBaseFolderEntryForm::CreateDeleteConfirmationPopUp(void)
254 result r = E_SUCCESS;
255 Rectangle popupBounds;
257 //Create a new popup control
258 _pDeleteConfirmationPopUp = new (std::nothrow) Popup();
259 _pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
261 _pDeleteFile = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
262 TryCatch(_pDeleteFile != null, , "MfMyFilesApp::Button For Popup not created!");
264 _pDeleteFile->SetActionId(IDA_DELETE_FILE);
265 _pDeleteFile->AddActionEventListener(*this);
266 _pDeleteFile->SetShowState(true);
268 _pCancelDeletion = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
269 TryCatch(_pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
271 _pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
272 _pCancelDeletion->AddActionEventListener(*this);
273 _pCancelDeletion->SetShowState(true);
279 if (_pDeleteConfirmationPopUp != null)
281 delete _pDeleteConfirmationPopUp;
282 _pDeleteConfirmationPopUp = null;
289 SubBaseFolderEntryForm::ShowSortByPopup(void)
294 //Set the showstate of the popup to true. so that it's displayed on the form.
295 if (_pSortByPopup != null)
297 _pSortByPopup->SetShowState(true);
298 _pSortByPopup->Invalidate(true);
299 _pSortByPopup->Show();
302 SetDefaultSelectionForSortByPopUp();
307 SubBaseFolderEntryForm::HideSortByPopup(void)
309 //Set the showstate of the popup to false. so that it's hidden on the form.
310 if (_pSortByPopup != null && _pSortByPopup->IsVisible())
312 _pSortByPopup->SetShowState(false);
318 SubBaseFolderEntryForm::LoadRenameForm(int index)
320 result r = E_SUCCESS;
321 _renameOrCreate = SELECT_RENAME;
322 ArrayList* pArg = null;
323 Integer* pSourceSelected = null;
324 SceneManager* pSceneManager = null;
325 DirectoryEntry* pDirectory = null;
327 if(_pFilenames != null)
329 pDirectory = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
330 TryCatch(pDirectory != null, , "failed to allocate memeory to cast to DirectoryEntry");
333 pArg = new (std::nothrow) ArrayList();
334 r = pArg->Construct();
336 pSourceSelected = new (std::nothrow) Integer(_renameOrCreate);
338 pArg->Add(pSourceSelected);
339 TryCatch(r == E_SUCCESS, , "failed to construct parg");
341 //pArg->Add(__rootMediaPath);
342 pArg->Add(pDirectory);
343 TryCatch(r == E_SUCCESS, , "failed to construct parg");
345 pSceneManager = SceneManager::GetInstance();
346 TryCatch(pSceneManager != null, , "failed to Get SceneManager instance");
348 //pSceneManager->GoForward(SCENE_RENAME_FORM, pArg, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
349 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
351 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
355 if (pSourceSelected != null)
357 delete pSourceSelected;
358 pSourceSelected = null;
360 if (pDirectory != null)
373 SubBaseFolderEntryForm::LoadSearchForm(void)
375 ArrayList* pTopLevelDirectoryList = null;
376 ArrayList* pFilepathList = null;
377 SceneManager* pSceneManager = null;
379 pTopLevelDirectoryList= new (std::nothrow) ArrayList();
380 if (pTopLevelDirectoryList != null && _pFilenames != null)
382 pFilepathList = new (std::nothrow) ArrayList();
383 if (pFilepathList != null)
385 pFilepathList->Construct();
386 pFilepathList->AddItems(*_pFilenames);
387 pTopLevelDirectoryList->Add(pFilepathList);
391 TryCatch(pTopLevelDirectoryList != null, , "failed to Get SceneManager instance");
393 pSceneManager = SceneManager::GetInstance();
394 TryCatch(pSceneManager != null, , "failed to Get SceneManager instance");
396 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pTopLevelDirectoryList);
402 if (pFilepathList != null)
404 delete pFilepathList;
405 pFilepathList = null;
408 if (pTopLevelDirectoryList != null)
410 delete pTopLevelDirectoryList;
411 pTopLevelDirectoryList = null;
416 SubBaseFolderEntryForm::ShowViewAsPopup(void)
418 //Call functions to create the popups.
419 CreateViewAsPopupControl();
421 //Set the showstate of the popup to true. so that it's displayed on the form.
422 if (_pViewAsPopup != null)
424 _pViewAsPopup->SetShowState(true);
425 _pViewAsPopup->Show();
428 SetDefaultSelectionForViewAsPopUp();
432 SubBaseFolderEntryForm::HideViewAsPopup(void)
434 //Set the showstate of the popup to false. so that it's hidden on the form.
435 if (_pViewAsPopup != null && _pViewAsPopup->IsVisible())
437 _pViewAsPopup->SetShowState(false);
442 SubBaseFolderEntryForm::LoadCreateFolderForm(void)
444 //Load the CreateFolder view in the current directory.
445 result r = E_SUCCESS;
446 Integer* pSourceSelected = null;
447 SceneManager* pSceneManager = null;
448 ArrayList* pArg = null;
450 pSourceSelected = new (std::nothrow) Integer(SELECT_CREATE_FOLDER);
452 pArg = new (std::nothrow) ArrayList();
453 TryCatch(pArg != null, , "Failed to allocate memory for pArg");
455 r = pArg->Construct();
456 TryCatch(r == E_SUCCESS, , "failed to construct parg");
458 r = pArg->Add(pSourceSelected);
459 TryCatch(r == E_SUCCESS, , "Failed to Add Arguments pArg");
461 pSceneManager = SceneManager::GetInstance();
462 TryCatch(pSceneManager != null, , "failed to construct parg");
464 //pSceneManager->GoForward(SCENE_CREATE_FOLDER_FORM, pArg, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
465 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
470 if (pSourceSelected != null)
472 delete pSourceSelected;
482 SubBaseFolderEntryForm::LoadDetailForm(Tizen::Base::String& Fullpath)
484 result r = E_SUCCESS;
486 SceneManager* pSceneManager = null;
487 ArrayList* pList = null;
488 String* pFullFilePath = null;
490 pList = new (std::nothrow) ArrayList();
491 TryCatch(pList != null, , "Failed to allocate memory for pList");
493 r = pList->Construct();
494 TryCatch(r == E_SUCCESS, , "Failed to Add Construct pList");
496 pFullFilePath = new (std::nothrow) String(Fullpath);
497 TryCatch(pFullFilePath != null, , "Failed to allocate memory for pFullFilePath");
499 r = pList->Add(pFullFilePath);
500 TryCatch(r == E_SUCCESS, , "Failed to Add Arguments pList");
502 pSceneManager = SceneManager::GetInstance();
503 TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");
505 //pSceneManager->GoForward(SCENE_FILE_DETAIL_FORM, pList, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
506 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
507 AppLogDebug("Exit: %s", GetErrorMessage(r));
511 AppLogDebug("Exit: %s", GetErrorMessage(r));
512 if (pFullFilePath != null)
514 delete pFullFilePath;
515 pFullFilePath = null;
527 SubBaseFolderEntryForm::LoadEditForm(void)
529 AppLogDebug("ENTER");
530 //__pFileListPM->SetFileEventListener(null);
531 SceneManager* pSceneManager = SceneManager::GetInstance();
532 ArrayList* pArgs = null;
534 pArgs = new (std::nothrow) ArrayList();
535 //pArgs->Construct();
541 pArgs->Add(* new (std::nothrow) Integer(_editOrShare));
543 pArgs->Add(*_pFolderEntryPM);
546 if (pSceneManager != null)
548 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
562 SubBaseFolderEntryForm::ShowFileProgressingPopup(void)
564 CreateFileProgressingPopup();
566 if (_pFileProgressingPopup != null)
568 _pFileProgressingPopup->SetShowState(true);
569 _pFileProgressingPopup->Show();
574 SubBaseFolderEntryForm::HideFileProgressingPopup(void)
576 if (_pFileProgressingPopup != null)
578 _pFileProgressingPopup->SetShowState(false);
580 if (_pFileProgressingPopup != null)
582 delete _pFileProgressingPopup;
583 _pFileProgressingPopup = null;
589 SubBaseFolderEntryForm::CreateFileProgressingPopup(void)
591 AppLogDebug("Enter");
592 result r = E_SUCCESS;
595 //String fileProgress;
597 if (_pFileProgressingPopup != null)
599 AppLogDebug("_pFileProgressingPopup is not null");
603 AppResource* pAppResource = null;
604 pAppResource = UiApp::GetInstance()->GetAppResource();
605 TryCatch(pAppResource != null, , "Failed to fetch AppResource");
607 //pAppResource->GetString(L"IDS_FILE_PROCESSING", popUpTitle);
608 pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
609 //pAppResource->GetString(L"IDS_FILE_PROGRESS", fileProgress);
611 _pFileProgressingPopup = new (std::nothrow) Popup();
612 _pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
613 TryCatch(_pFileProgressingPopup != null, , "Failed to allocate memory to FileProgressing Popup.");
615 //_pFileProgressingPopup->SetTitleText(popUpTitle); //Not in UI
618 _pFileProgressingCancelButton = static_cast< Button* >(_pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
619 TryCatch(_pFileProgressingCancelButton != null, , "Failed to fetch _pFileProgressingCancelButton.");
621 _pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
622 _pFileProgressingCancelButton->AddActionEventListener(*this);
623 _pFileProgressingCancelButton->SetShowState(true);
625 _pFileProgressingProgress = static_cast< Progress* >(_pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
626 TryCatch(_pFileProgressingProgress != null, , "Failed to fetch _pFileProgressingProgress.");
628 _pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
629 _pFileProgressingProgress->SetValue(0);
631 _pFileProgressingHeaderLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
632 TryCatch(_pFileProgressingHeaderLabel != null, , "Failed to fetch _pFileProgressingHeaderLabel.");
634 _pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
635 _pFileProgressingHeaderLabel->SetText(deleting);
636 _pFileProgressingHeaderLabel->SetShowState(true);
637 _pFileProgressingHeaderLabel->Invalidate(true);
640 _pFileProgressingLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
641 TryCatch(_pFileProgressingLabel != null, , "Failed to fetch _pFileProgressingLabel.");
643 _pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
644 //_pFileProgressingLabel->SetText(fileProgress);
645 _pFileProgressingLabel->SetShowState(true);
652 if (_pFileProgressingPopup != null)
654 delete _pFileProgressingPopup;
655 _pFileProgressingPopup = null;
662 SubBaseFolderEntryForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
664 int x_FooterPosition = 0;
665 int y_FooterPosition = 0;
666 int x_ContextMenu = 0;
667 int y_ContextMenu = 0;
669 Rectangle listViewBounds(GetClientAreaBounds().x, H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, GetClientAreaBounds().height);
670 Rectangle labelBounds(GetClientAreaBounds().x, 0, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL);
672 _pFooter = GetFooter();
673 if (_pFooter != null)
675 _pFooter->GetPosition(x_FooterPosition, y_FooterPosition);
678 x_ContextMenu = x_FooterPosition + 3 * (listViewBounds.width / 4);
679 y_ContextMenu = y_FooterPosition;
681 switch (orientationStatus)
683 case ORIENTATION_STATUS_PORTRAIT:
685 if (_pListView != null)
687 _pListView->SetBounds(listViewBounds);
689 if (_pIconListView != null)
691 _pIconListView->SetBounds(listViewBounds);
693 if (_pMoreContextMenu != null)
695 _pMoreContextMenu->SetAnchorPosition(Point(x_ContextMenu, y_ContextMenu));
697 /* if (__pLabelDisplayPath != null)
699 __pLabelDisplayPath->SetBounds(labelBounds);
704 case ORIENTATION_STATUS_LANDSCAPE:
706 if (_pListView != null)
708 _pListView->SetBounds(listViewBounds);
710 if (_pIconListView != null)
712 _pIconListView->SetBounds(listViewBounds);
714 if (_pMoreContextMenu != null)
716 _pMoreContextMenu->SetAnchorPosition(Point(x_ContextMenu, y_ContextMenu));
718 /* if (__pLabelDisplayPath != null)
720 __pLabelDisplayPath->SetBounds(labelBounds);
736 SubBaseFolderEntryForm::OnFileManagingStart(void)
738 ShowFileProgressingPopup();
742 SubBaseFolderEntryForm::OnFileManagingStop(FileManagingResult fileManagingResult)
744 //Empty Implementation.
748 SubBaseFolderEntryForm::HideFileExtension(void)
750 int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
751 String viewStyleKeyName(L"ListDisplayType");
753 result r = E_SUCCESS;
755 AppRegistry* pAppRegistry = null;
756 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
759 if (pAppRegistry != null)
761 r = pAppRegistry->Set(_extensionKeyName, hideExtensionKeyValue);
762 r = pAppRegistry->Save();
764 r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
767 if (_pMoreContextMenu != null)
769 r = _pMoreContextMenu->SetItemAt(2, _showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
770 AppLogDebug("error %s", GetErrorMessage(r));
773 if (_pOptionMenu != null)
775 r = _pOptionMenu->SetItemAt(3, _showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
776 AppLogDebug("error %s", GetErrorMessage(r));
779 //Update the corresponding List.
780 if (listViewDisplayType == VIEW_TYPE_AS_THUMBNAILS)
782 if (_pIconListView != null)
784 _pIconListView->SetShowState(true);
785 _pIconListView->UpdateList();
790 if (_pListView != null)
792 _pListView->UpdateList();
793 _pListView->SetShowState(true);
797 if (_pMoreContextMenu != null)
799 delete _pMoreContextMenu;
800 _pMoreContextMenu = null;
805 AppLogDebug("Exit : %s", GetErrorMessage(r));
809 SubBaseFolderEntryForm::ShowFileExtension(void)
811 int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
812 String viewStyleKeyName(L"ListDisplayType");
814 result r = E_SUCCESS;
816 AppRegistry* pAppRegistry = null;
817 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
819 if (pAppRegistry != null)
821 r = pAppRegistry->Set(_extensionKeyName, showExtensionKeyValue);
822 r = pAppRegistry->Save();
824 r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
827 if (_pMoreContextMenu != null)
829 r = _pMoreContextMenu->SetItemAt(2, _hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
830 AppLogDebug("error %s", GetErrorMessage(r));
833 if (_pOptionMenu != null)
835 r = _pOptionMenu->SetItemAt(3, _hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
836 AppLogDebug("error %s", GetErrorMessage(r));
838 if (listViewDisplayType == VIEW_TYPE_AS_THUMBNAILS)
840 if (_pIconListView != null)
842 _pIconListView->UpdateList();
843 _pIconListView->SetShowState(true);
848 if (_pListView != null)
850 _pListView->UpdateList();
851 _pListView->SetShowState(true);
855 if (_pMoreContextMenu != null)
857 delete _pMoreContextMenu;
858 _pMoreContextMenu = null;
862 AppLogDebug("Exit: %s", GetErrorMessage(r));
867 SubBaseFolderEntryForm::HideDeleteConfirmationPopup(void)
869 if (_pDeleteConfirmationPopUp != null && _pDeleteConfirmationPopUp->IsVisible())
871 _pDeleteConfirmationPopUp->SetShowState(false);
876 SubBaseFolderEntryForm::ShowDeleteConfirmationPopup(void)
878 CreateDeleteConfirmationPopUp();
880 if (_pDeleteConfirmationPopUp != null)
882 _pDeleteConfirmationPopUp->SetShowState(true);
883 _pDeleteConfirmationPopUp->Show();
888 SubBaseFolderEntryForm::CreateViewAsPopupControl(void)
890 AppLogDebug("ENTER");
891 //Creates a popup control for the ViewAs context item asking which view is to be shown
893 result r = E_SUCCESS;
895 if (_pViewAsPopup != null)
897 AppLogDebug("_pViewAsPopup is not null");
901 String viewAsPopupTitle;
903 String sortByPopupTitle;
905 // Label* pViewAsPanelLabel = null;
907 // Label* pViewAsPopupLabel = null;
909 // Bitmap* pPanelBackground = null;
910 // Bitmap* pPopUpBackground = null;
912 // pPanelBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, BITMAP_PIXEL_FORMAT_ARGB8888);
913 // pPopUpBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_CENTER, BITMAP_PIXEL_FORMAT_ARGB8888);
915 //Create a new popup control
916 _pViewAsPopup = new (std::nothrow) Popup();
917 _pViewAsPopup->Construct(L"IDL_VIEW_AS_POPUP");
919 //The cancel button inside the popup, hides the popup when clicked.
920 _pCancelViewAs = static_cast< Button* >(_pViewAsPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
921 TryCatch(_pCancelViewAs != null, , "MfMyFilesApp::Button For Popup not created!");
923 _pCancelViewAs->SetActionId(IDA_BTN_POPUP_CANCEL);
924 _pCancelViewAs->AddActionEventListener(*this);
925 _pCancelViewAs->SetShowState(true);
927 // pViewAsPanelLabel = static_cast< Label* >(_pViewAsPopup->GetControl(L"IDC_LABEL_BOTTOM_BACKGROUND", true));
928 // TryCatch(pViewAsPanelLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
930 // pViewAsPopupLabel = static_cast< Label* >(_pViewAsPopup->GetControl(L"IDC_LABEL_POPUP_BACKGROUND", true));
931 // TryCatch(pViewAsPopupLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
933 // pPanelBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, pViewAsPanelLabel->GetWidth(), pViewAsPanelLabel->GetHeight());
934 // pPopUpBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, pViewAsPopupLabel->GetWidth(), pViewAsPopupLabel->GetHeight());
936 // if (pPanelBackground != null)
938 // pViewAsPanelLabel->SetBackgroundBitmap(*pPanelBackground);
941 // if (pPopUpBackground != null)
943 // pViewAsPopupLabel->SetBackgroundBitmap(*pPopUpBackground);
946 //The listview control which is to be added inside the popup. The itemprovider and listener are
947 //implemented in another class because this class already contains an instance of Listview control
948 //attached to an ItemProvider.
950 _pViewAsPopup->SetControlAlwaysOnTop(*_pCancelViewAs, true);
953 _pViewAsListView = static_cast< ListView* >(_pViewAsPopup->GetControl(L"IDC_LISTVIEW_VIEW_AS", true));
954 TryCatch(_pViewAsListView != null, , "MfMyFilesApp::ListView Control For Popup not created!");
956 _pViewAsListView->SetShowState(true);
957 _pViewAsListView->AddListViewItemEventListener(*_pCustomListViewForPopup);
958 _pViewAsListView->SetItemProvider(*_pCustomListViewForPopup);
959 _pViewAsListView->SetName(L"VIEW_AS_LISTVIEW");
960 _pViewAsListView->SetItemDividerColor(Color::GetColor(COLOR_ID_GREY));
962 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
964 // if (pPanelBackground != null)
966 // delete pPanelBackground;
967 // pPanelBackground = null;
969 // if (pPopUpBackground != null)
971 // delete pPopUpBackground;
972 // pPopUpBackground = null;
977 if (_pViewAsPopup != null)
979 delete _pViewAsPopup;
980 _pViewAsPopup = null;
983 if (_pCustomListViewForPopup != null)
985 delete _pCustomListViewForPopup;
986 _pCustomListViewForPopup = null;
989 // if (pPanelBackground != null)
991 // delete pPanelBackground;
992 // pPanelBackground = null;
995 // if (pPopUpBackground != null)
997 // delete pPopUpBackground;
998 // pPopUpBackground = null;
1004 SubBaseFolderEntryForm::ShowMoreContextMenu(void)
1006 String extensionStatus;
1008 AppRegistry* pAppRegistry = null;
1009 result r = E_SUCCESS;
1010 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1012 //Show ContextMenu with More Options
1013 if (pAppRegistry != null)
1015 r = pAppRegistry->Get(_extensionKeyName, extensionStatus);
1018 if (_pMoreContextMenu != null)
1020 if (extensionStatus == _hideExtension)
1022 r = _pMoreContextMenu->SetItemAt(2, _showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
1026 r = _pMoreContextMenu->SetItemAt(2, _hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
1029 _pMoreContextMenu->SetShowState(true);
1030 _pMoreContextMenu->Show();
1033 AppLogDebug("Exit: %s", GetErrorMessage(r));
1037 SubBaseFolderEntryForm::OnListViewItemStateChangedNotify(ViewType listViewStyle)
1039 AppLogDebug("ENTER");
1041 int popupSource = POP_UP_VIEW_AS;
1042 int sortType = SORT_BY_TYPE_NAME_ASCENDING;
1043 int thumbnailRequestId = 0;
1045 AppRegistry* pAppRegistry = null;
1046 String sortByKeyName(L"SortBy");
1048 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1050 if (_pCustomListViewForPopup != null)
1052 popupSource = _pCustomListViewForPopup->GetSelectionPopup();
1055 pAppRegistry->Get(sortByKeyName, sortType);
1057 if (popupSource == POP_UP_VIEW_AS)
1059 _flagViewAsStatus = listViewStyle;
1061 if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_CATEGORY_SEARCH_FORM)
1063 if (_pBaseItemProvider != null)
1065 _pBaseItemProvider->SetSecondaryBitmap();
1069 if (_pBaseItemProvider != null)
1071 _pBaseItemProvider->GetFontSizeAndItemHeight();
1082 if (_pFolderEntryPM != null)
1084 thumbnailRequestId = _pFolderEntryPM->GetCurrentReqId() + 1;
1085 _pFolderEntryPM->SetCurrentReqId(thumbnailRequestId);
1086 if (_pFolderEntryPM != null && _pFolderEntryPM->GetSourceForm() != CREATE_ITEM_SOURCE_SPLIT_PANEL_DIR_TREE)
1088 _pFolderEntryPM->SortFolderEntries();
1092 if (_pListView != null && _pListView->IsVisible())
1094 _pListView->UpdateList();
1096 else if (_pIconListView != null && _pIconListView->GetShowState())
1098 _pIconListView->UpdateList();
1101 if (_pFolderEntryPM != null)
1103 _pFolderEntryPM->InitThumbnailManager();
1108 if (_pMoreContextMenu != null)
1110 delete _pMoreContextMenu;
1111 _pMoreContextMenu = null;
1115 SubBaseFolderEntryForm::OnIconListViewItemStateChangeNotify()
1117 if (_pIconListView != null && _pIconListView->GetShowState())
1119 _pIconListView->UpdateList();
1123 SubBaseFolderEntryForm::OnFooterStateChangeNotify(void)
1125 SetFooterVisibility();
1127 _pFooter = GetFooter();
1128 if (_pFooter != null)
1130 _pFooter->Invalidate(true);
1135 SubBaseFolderEntryForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1137 AppLogDebug("OnAppControlCompleteResponseReceived");
1138 result r = E_SUCCESS;
1139 CustomAppControl::GetInstance()->SetAppControlInUse(null);
1141 if (GetLastResult() == E_FILE_NOT_FOUND)
1143 _pFolderEntryPM->RefreshFolderEntries();
1144 if (_pListView != null && _pListView->IsVisible())
1146 r = _pListView->UpdateList();
1148 else if (_pIconListView != null && _pIconListView->GetShowState())
1150 r = _pIconListView->UpdateList();
1152 _pFolderEntryPM->InitThumbnailManager();
1157 SubBaseFolderEntryForm::SetDefaultSelectionForSortByPopUp(void)
1159 result r = E_SUCCESS;
1161 int defaultSortPopUpSelect = 0;
1163 int sortType = SORT_BY_TYPE_NAME_ASCENDING;
1165 int uncheckItem1 = 0;
1166 int uncheckItem2 = 0;
1167 int uncheckItem3 = 0;
1168 int uncheckItem4 = 0;
1169 int uncheckItem5 = 0;
1171 String sortByKeyName(L"SortBy");
1173 AppRegistry* pAppRegistry = null;
1175 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1177 r = pAppRegistry->Get(sortByKeyName, sortType);
1178 TryCatch(r == E_SUCCESS, , "Failed To Get Value From AppRegistry");
1183 case SORT_BY_TYPE_NAME_ASCENDING:
1185 defaultSortPopUpSelect = 0;
1194 case SORT_BY_TYPE_NAME_DESCENDING:
1196 defaultSortPopUpSelect = 1;
1205 case SORT_BY_TYPE_DATE_RECENT:
1207 defaultSortPopUpSelect = 2;
1217 case SORT_BY_TYPE_DATE_OLDEST:
1219 defaultSortPopUpSelect = 3;
1228 case SORT_BY_TYPE_SIZE_ASCENDING:
1230 defaultSortPopUpSelect = 4;
1239 case SORT_BY_TYPE_SIZE_DESCENDING:
1241 defaultSortPopUpSelect = 4;
1250 case SORT_BY_TYPE_ASCENDING:
1252 defaultSortPopUpSelect = 5;
1262 case SORT_BY_TYPE_DESCENDING:
1264 defaultSortPopUpSelect = 5;
1276 defaultSortPopUpSelect = 0;
1277 AppLogDebug("UnSupported case reached");
1282 if (_pCustomListViewForPopup != null)
1284 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_SORT_BY);
1287 if (_pSortByPopup != null && _pSortByListView != null)
1289 _pSortByListView->UpdateList();
1290 _pSortByListView->SetItemChecked(defaultSortPopUpSelect, true);
1291 _pSortByListView->SetItemChecked(uncheckItem1, false);
1292 _pSortByListView->SetItemChecked(uncheckItem2, false);
1293 _pSortByListView->SetItemChecked(uncheckItem3, false);
1294 _pSortByListView->SetItemChecked(uncheckItem4, false);
1295 _pSortByListView->SetItemChecked(uncheckItem5, false);
1297 _pSortByListView->Invalidate(true);
1306 SubBaseFolderEntryForm::SwitchViewType(void)
1308 String viewStyleKeyName(L"ListDisplayType");
1310 switch (_flagViewAsStatus)
1313 case VIEW_TYPE_AS_DETAILED_LIST:
1315 if (_pIconListView != null )
1317 _pIconListView->SetShowState(false);
1319 if (_pListView != null)
1321 _pListView->UpdateList();
1322 if (_selectedItemIndex == -1)
1324 _pListView->ScrollToItem(0);
1326 _pListView->SetShowState(true);
1332 case VIEW_TYPE_AS_NORMAL_LIST:
1334 if (_pIconListView != null )
1336 _pIconListView->SetShowState(false);
1339 if (_pListView != null)
1341 _pListView->UpdateList();
1342 if (_selectedItemIndex == -1)
1344 _pListView->ScrollToItem(0);
1346 _pListView->SetShowState(true);
1351 case VIEW_TYPE_AS_THUMBNAILS:
1353 if (_pListView != null )
1355 _pListView->SetShowState(false);
1357 if (_pIconListView != null)
1359 _pIconListView->UpdateList();
1360 if (_selectedItemIndex == -1)
1362 _pIconListView->ScrollToItem(0);
1364 _pIconListView->SetShowState(true);
1371 if (_pListView != null)
1373 _pListView->UpdateList();
1381 SubBaseFolderEntryForm::SetNextDisplayPath(void)
1388 fullPath = FolderNavigationPresentationModel::GetCurrentPath();
1390 StringTokenizer tokenizer(fullPath, delim);
1393 DataBindingContext* pContext = null;
1394 pContext = GetDataBindingContextN();
1398 switch (_storageType)
1400 case MEMORY_TYPE_PHONE:
1406 case MEMORY_TYPE_SD_CARD:
1419 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1420 //it is the last token
1421 while (tokenizer.HasMoreTokens())
1426 tokenizer.GetNextToken(token);
1430 tokenizer.GetNextToken(token);
1431 displayPath.Append(token);
1432 displayPath.Append(L"/");
1438 if (_pLabelDisplayPath != null)
1440 _displayPath.Append(displayPath);
1442 String displayPathToAppend(L"\x200E");
1443 displayPathToAppend.Append(_displayPath);
1445 _pLabelDisplayPath->SetText(displayPathToAppend);
1446 _pLabelDisplayPath->Invalidate(true);
1450 if (pContext != null)
1452 //UpdateBinding on the target label control.
1453 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
1456 if (pContext != null)
1464 FolderEntryPresentationModel*
1465 SubBaseFolderEntryForm::GetFolderEntryPresentationModel(void)
1467 return _pFolderEntryPM;
1471 SubBaseFolderEntryForm::DeleteFile(String& filePath)
1473 AppLogDebug("ENTER");
1474 result r = E_SUCCESS;
1476 //_pFolderEntryPM->SetFileEventListener(null);
1477 //((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1479 _pFileManager->DeleteFolderEntries(&filePath);
1481 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1486 SubBaseFolderEntryForm::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1488 AppLogDebug("ENTER");
1489 DirectoryEntry* pDirStr = null;
1496 _editOrShare = FILE_MANAGE_EDIT;
1497 //If filenames is not empty then Load the edit form.
1498 if (_pFilenames->GetCount() != 0)
1500 //_pFolderEntryPM->SetFileEventListener(null);
1509 AppLogDebug("Share Button Clicked!");
1511 _editOrShare = FILE_MANAGE_SHARE;
1512 if (_pFilenames->GetCount() != 0)
1514 //_pFolderEntryPM->SetFileEventListener(null);
1523 if (_pFilenames->GetCount() > 0)
1525 CreateMoreContextMenu();
1526 ShowMoreContextMenu();
1531 case IDA_CONTEXT_MENU_BTN_SORT_BY:
1533 //Show the SortBy PopUp.
1534 if (_pCustomListViewForPopup != null)
1536 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_SORT_BY);
1542 case IDA_CONTEXT_MENU_CREATE_FOLDER:
1544 //Load the CreateFolder Form.
1545 //_pFolderEntryPM->SetFileEventListener(null);
1546 _renameOrCreate = SELECT_CREATE_FOLDER;
1548 if (_pMoreContextMenu != null)
1550 delete _pMoreContextMenu;
1551 _pMoreContextMenu = null;
1554 LoadCreateFolderForm();
1558 case IDA_CONTEXT_MENU_VIEW_AS:
1560 //Show the ViewAs Popup
1561 if (_pCustomListViewForPopup != null)
1563 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_VIEW_AS);
1570 case IDA_BTN_POPUP_CANCEL:
1572 //Hide the ViewAs PopUp and redraw the form.
1577 case IDA_BTN_SORT_POPUP_CANCEL:
1579 //Hide the SortBy PopUp and redraw the form.
1584 case IDA_CONTEXT_MENU_BTN_SEARCH:
1586 //Load the SearchForm
1591 case IDA_DELETE_FILE:
1593 HideDeleteConfirmationPopup();
1595 if (_pDeleteConfirmationPopUp != null)
1597 delete _pDeleteConfirmationPopUp;
1598 _pDeleteConfirmationPopUp = null;
1602 if (_pFilenames != null)
1604 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(_indexToDelete));
1606 if (pDirStr != null)
1608 _filePath = pDirStr->GetFullFilePath();
1610 _indexTracker = _indexToDelete;
1611 //Call the DeleteFile Function.
1612 DeleteFile(_filePath);
1616 case IDA_CANCEL_DELETION:
1618 HideDeleteConfirmationPopup();
1619 _bIsDeleteFromContextSwipe = false;
1621 if (_pDeleteConfirmationPopUp != null)
1623 delete _pDeleteConfirmationPopUp;
1624 _pDeleteConfirmationPopUp = null;
1629 case IDA_BTN_ANIMATION_POPUP_CANCEL:
1631 AppLogDebug("IDA_BTN_ANIMATION_POPUP_CANCEL");
1632 HideFileProgressingPopup();
1633 _pFileManager->ForceStopWorkerThread();
1637 case IDA_ICONLISTVIEW_DETAILS:
1639 if (_pIconListViewContextMenu != null)
1641 delete _pIconListViewContextMenu;
1642 _pIconListViewContextMenu = null;
1645 if (_bIsTopLevelDirectory == false)
1647 if (_currentIndex != INVALID_LIST_INDEX && _pFilenames != null)
1649 pDirStr = static_cast <DirectoryEntry*>(_pFilenames->GetAt(_currentIndex));
1651 if (pDirStr != null)
1653 fullPath = pDirStr->GetFullFilePath();
1659 switch (_currentIndex)
1662 FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetMediaPath());
1663 fullPath = FolderNavigationPresentationModel::GetMediaPath();
1664 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
1667 FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetSdCardPath());
1668 fullPath = FolderNavigationPresentationModel::GetSdCardPath();
1669 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
1673 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetUsbPath());
1674 fullPath = FolderNavigationPresentationModel::GetUsbPath();
1675 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_EXTERNAL);
1680 LoadDetailForm(fullPath);
1684 case IDA_ICONLISTVIEW_DELETE:
1686 _bIsDeleteFromContextSwipe = true;
1688 if (_pIconListViewContextMenu != null)
1690 delete _pIconListViewContextMenu;
1691 _pIconListViewContextMenu = null;
1694 ShowDeleteConfirmationPopup();
1696 _indexToDelete = _currentIndex;
1701 case IDA_ICONLISTVIEW_RENAME:
1703 if (_pIconListViewContextMenu != null)
1705 delete _pIconListViewContextMenu;
1706 _pIconListViewContextMenu = null;
1709 if (_currentIndex != INVALID_LIST_INDEX && _pFilenames != null)
1711 pDirStr = static_cast <DirectoryEntry*>(_pFilenames->GetAt(_currentIndex));
1713 if (pDirStr != null)
1715 _currentFileName.Clear();
1716 _currentFileName = pDirStr->GetFileName();
1720 _renameIndex = _currentIndex;
1721 _renameOrCreate = SELECT_RENAME;
1723 //Load the Rename View of the item selected.
1724 LoadRenameForm(_currentIndex);
1737 SubBaseFolderEntryForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
1739 DirectoryEntry* pDirStr = null;
1740 _selectedItemIndex = index;
1741 if (_pFilenames != null)
1743 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
1745 if (pDirStr != null)
1749 case IDA_CONTEXT_DETAIL:
1752 _filePath = pDirStr->GetFullFilePath();
1753 LoadDetailForm(_filePath);
1757 case IDA_CONTEXT_RENAME:
1759 if (_pFileEventManager != null)
1761 _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1764 _currentFileName.Clear();
1765 _currentFileName = pDirStr->GetFileName();
1766 _renameIndex = index;
1767 _renameOrCreate = SELECT_RENAME;
1768 //Load the Rename View of the item selected.
1769 LoadRenameForm(index);
1773 case IDA_CONTEXT_DELETE:
1775 if (_pFileEventManager != null)
1777 _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1780 _bIsDeleteFromContextSwipe = true;
1782 _indexToDelete = index;
1784 ShowDeleteConfirmationPopup();
1790 //Empty Implementation.
1799 SubBaseFolderEntryForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
1801 result res = E_SUCCESS;
1802 AppLogDebug("Enter");
1804 if (_pFolderEntryPM)
1806 if (pThumbReq != null)
1808 if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
1810 if (pThumbReq->pBitmap != null)
1812 delete pThumbReq->pBitmap;
1818 if (pThumbReq != null)
1820 if (pThumbReq->GetCurrentRequestId() != _pFolderEntryPM->GetCurrentReqId())
1822 if (pThumbReq->pBitmap != null)
1824 delete pThumbReq->pBitmap;
1826 AppLogDebug("mismatch in id so returning");
1832 if (pThumbReq->iRquestId < _pFilenames->GetCount())
1834 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
1835 if (_pListView && _pListView->IsVisible())
1837 res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1839 else if (_pIconListView && _pIconListView->GetShowState())
1841 res = _pIconListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1845 AppLogDebug("Thumbnail Request is not valid");
1849 _pFolderEntryPM->OnThumbnailResponseFailed();
1852 AppLogDebug("Exit %s", GetErrorMessage(res));
1857 SubBaseFolderEntryForm::CreateSortByPopup(void)
1859 result r = E_SUCCESS;
1861 if (_pSortByPopup != null)
1863 AppLogDebug("_pSortByPopup is not null");
1867 String cancelButton;
1868 String sortByPopupTitle;
1870 // Label* pSortByPanelLabel = null;
1871 // Label* pSortByPopupLabel = null;
1873 // Bitmap* pPanelBackground = null;
1874 // Bitmap* pPopUpBackground = null;
1876 // pPanelBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, BITMAP_PIXEL_FORMAT_ARGB8888);
1877 //pPopUpBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_CENTER, BITMAP_PIXEL_FORMAT_ARGB8888);
1878 // pPopUpBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, 512, 632);
1879 // pPanelBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, 612, 96);
1881 _pSortByPopup = new (std::nothrow) Popup();
1882 _pSortByPopup->Construct(L"IDL_SORT_BY_POPUP");
1884 _pCancelSortBy = static_cast< Button* >(_pSortByPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1885 TryCatch(_pCancelSortBy != null, , "MfMyFilesApp::Button For Popup not created!");
1887 _pCancelSortBy->SetActionId(IDA_BTN_SORT_POPUP_CANCEL);
1888 _pCancelSortBy->AddActionEventListener(*this);
1889 _pCancelSortBy->SetShowState(true);
1891 // pSortByPanelLabel = static_cast< Label* >(_pSortByPopup->GetControl(L"IDC_LABEL_PANEL_BACKGROUND", true));
1892 // TryCatch(pSortByPanelLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
1894 // pSortByPopupLabel = static_cast< Label* >(_pSortByPopup->GetControl(L"IDC_LABEL_POPUP_BACKGROUND", true));
1895 // TryCatch(pSortByPopupLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
1897 // if (pPanelBackground != null)
1899 // pSortByPanelLabel->SetBackgroundBitmap(*pPanelBackground);
1902 // if (pPopUpBackground != null)
1904 // pSortByPopupLabel->SetBackgroundBitmap(*pPopUpBackground);
1908 _pSortByListView = static_cast< ListView* >(_pSortByPopup->GetControl(L"IDC_LISTVIEW_SORT_BY", true));
1909 TryCatch(_pSortByListView != null, , "MfMyFilesApp::ListView Control For Popup not created!");
1911 _pSortByListView->SetShowState(true);
1912 _pSortByListView->AddListViewItemEventListener(*_pCustomListViewForPopup);
1913 _pSortByListView->SetItemProvider(*_pCustomListViewForPopup);
1914 _pSortByListView->SetName(L"SORT_BY_LISTVIEW");
1915 _pSortByListView->SetItemDividerColor(Color::GetColor(COLOR_ID_GREY));
1917 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1919 // _pSortByPopup->SetControlAlwaysAtBottom(*pSortByPanelLabel, true);
1920 // _pSortByPopup->SetControlAlwaysAtBottom(*pSortByPopupLabel, true);
1921 _pSortByPopup->SetControlAlwaysOnTop(*_pSortByListView, true);
1922 _pSortByPopup->SetControlAlwaysOnTop(*_pCancelSortBy, true);
1924 // if (pPanelBackground != null)
1926 // delete pPanelBackground;
1927 // pPanelBackground = null;
1929 // if (pPopUpBackground != null)
1931 // delete pPopUpBackground;
1932 // pPopUpBackground = null;
1937 if (_pCustomListViewForPopup != null)
1939 delete _pCustomListViewForPopup;
1940 _pCustomListViewForPopup = null;
1943 if (_pSortByPopup != null)
1945 delete _pSortByPopup;
1946 _pSortByPopup = null;
1949 // if (pPanelBackground != null)
1951 // delete pPanelBackground;
1952 // pPanelBackground = null;
1955 // if (pPopUpBackground != null)
1957 // delete pPopUpBackground;
1958 // pPopUpBackground = null;
1965 SubBaseFolderEntryForm::CreateMoreContextMenu(void)
1967 result r = E_SUCCESS;
1969 if (_pMoreContextMenu != null)
1977 AppResource* pAppResource = null;
1978 AppRegistry* pAppRegistry = null;
1981 String extensionVisibility;
1984 String buttonCreateFolder;
1986 Bitmap* pBitmapSortbyContextItem = null;
1987 Bitmap* pBitmapSearchContextItem = null;
1988 Bitmap* pBitmapCreateFolderContextItem = null;
1990 pAppResource = Application::GetInstance()->GetAppResource();
1992 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1994 if (pAppResource != null)
1996 pAppResource->GetString(L"IDS_MF_OPT_VIEW_AS", viewAs);
1997 pAppResource->GetString(L"IDS_MF_SK3_SORT_BY", sortBy);
1998 pAppResource->GetString(L"IDS_MF_SK3_SEARCH", search);
1999 pAppResource->GetString(L"IDS_MF_OPT_CREATE_FOLDER", buttonCreateFolder);
2000 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
2001 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
2002 pBitmapSortbyContextItem = pAppResource->GetBitmapN(IDB_POPUP_SORTBY_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2003 pBitmapSearchContextItem = pAppResource->GetBitmapN(IDB_POPUP_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2004 pBitmapCreateFolderContextItem = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2007 pAppRegistry->Get(_extensionKeyName, extensionVisibility);
2009 _pFooter = GetFooter();
2010 if (_pFooter != null)
2012 _pFooter->GetPosition(xPosition, yPosition);
2015 xPosition += 3 * (GetClientAreaBounds().width / 4);
2017 //Create the ContextMenu
2018 _pMoreContextMenu = new (std::nothrow) ContextMenu();
2019 _pMoreContextMenu->Construct(Point(0, yPosition), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
2020 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
2021 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
2023 if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_TOP_LEVEL_DIRECTORY_FORM)
2025 _pMoreContextMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2029 if (_bIsDirectoryEmpty == false)
2031 if (CheckSearchHistory() == false)
2033 _pMoreContextMenu->AddItem(search, IDA_CONTEXT_MENU_BTN_SEARCH, *pBitmapSearchContextItem, null, null);
2036 _pMoreContextMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2037 _pMoreContextMenu->AddItem(sortBy, IDA_CONTEXT_MENU_BTN_SORT_BY, *pBitmapSortbyContextItem, null, null);
2039 if (extensionVisibility == _hideExtension)
2041 _pMoreContextMenu->AddItem(_showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
2045 _pMoreContextMenu->AddItem(_hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
2049 if (SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2051 _pMoreContextMenu->AddItem(buttonCreateFolder, IDA_CONTEXT_MENU_CREATE_FOLDER, *pBitmapCreateFolderContextItem, null, null);
2055 //Set the ContextMenu's ActionEventListener
2056 _pMoreContextMenu->AddActionEventListener(*this);
2057 //_pMoreContextMenu->SetAnchorPosition(Point(xPosition, yPosition));
2058 _pMoreContextMenu->SetShowState(true);
2060 delete pBitmapSortbyContextItem;
2061 delete pBitmapSearchContextItem;
2062 delete pBitmapCreateFolderContextItem;
2067 SubBaseFolderEntryForm::SetDefaultSelectionForViewAsPopUp(void)
2069 result r = E_SUCCESS;
2071 int defaultViewAsPopUpSelect = 0;
2072 int uncheckItem1 = 0;
2073 int uncheckItem2 = 0;
2075 int viewType = VIEW_TYPE_AS_NONE;
2076 String viewStyleKeyName(L"ListDisplayType");
2078 AppRegistry* pAppRegistry = null;
2080 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2082 r = pAppRegistry->Get(viewStyleKeyName, viewType);
2087 case VIEW_TYPE_AS_DETAILED_LIST:
2089 defaultViewAsPopUpSelect = 1;
2095 case VIEW_TYPE_AS_NORMAL_LIST:
2097 defaultViewAsPopUpSelect = 0;
2103 case VIEW_TYPE_AS_THUMBNAILS:
2105 defaultViewAsPopUpSelect = 2;
2113 //Empty Implementation.
2119 if (_pCustomListViewForPopup != null)
2121 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_VIEW_AS);
2124 if (_pViewAsPopup != null && _pViewAsListView != null)
2126 _pViewAsListView->UpdateList();
2127 _pViewAsListView->SetItemChecked(defaultViewAsPopUpSelect, true);
2128 _pViewAsListView->SetItemChecked(uncheckItem1, false);
2129 _pViewAsListView->SetItemChecked(uncheckItem2, false);
2130 _pViewAsListView->Invalidate(true);
2137 SubBaseFolderEntryForm::SetFooterVisibility(void)
2139 AppLogDebug("Entry");
2140 int folderCount=0, fileCount=0;
2142 _pFooter = GetFooter();
2144 if( _pFolderEntryPM )
2145 _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(), folderCount, fileCount);
2147 if (folderCount ==0 && fileCount == 0)
2149 _bIsDirectoryEmpty = true;
2150 _pFooter->SetItemEnabled(0, false);
2151 _pFooter->SetItemEnabled(1, false);
2155 _bIsDirectoryEmpty = false;
2156 _pFooter->SetItemEnabled(0, true);
2160 _pFooter->SetItemEnabled(1, true);
2164 _pFooter->SetItemEnabled(1, false);
2168 _pFooter->Invalidate(true);
2172 SubBaseFolderEntryForm::CheckSearchHistory(void)
2174 bool searchHistoryStatus = false;
2177 SceneManager* pSceneManager = SceneManager::GetInstance();
2178 IListT< SceneId >* pSceneList = pSceneManager->GetSceneHistoryN();
2180 if (pSceneList != null)
2182 itemCount = pSceneList->GetCount() - 1;
2183 pSceneList->GetAt(itemCount, searchScene);
2184 while (searchScene != IDSCN_SEARCH_FORM && itemCount >= 0)
2187 pSceneList->GetAt(itemCount, searchScene);
2191 if (searchScene == IDSCN_SEARCH_FORM)
2193 AppLogDebug("Search scene present");
2194 searchHistoryStatus = true;
2198 AppLogDebug("Search scene not present");
2199 searchHistoryStatus = false;
2204 pSceneList->RemoveAll();
2208 return searchHistoryStatus;
2213 SubBaseFolderEntryForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
2215 //Empty Implementation
2219 SubBaseFolderEntryForm::OnLongPressGestureDetected(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector)
2222 if (_currentIndex != INVALID_LIST_INDEX)
2224 ShowIconListViewContextMenu();
2229 SubBaseFolderEntryForm::OnLongPressGestureCanceled(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector)
2231 //Empty Implementation.
2235 SubBaseFolderEntryForm::CreateIconListViewContextMenu(void)
2237 if (_pIconListViewContextMenu != null)
2242 result r = E_SUCCESS;
2248 String buttonCreateFolder;
2250 AppResource* pAppResource = null;
2251 //AppRegistry* pAppRegistry = null;
2252 pAppResource = Application::GetInstance()->GetAppResource();
2254 //pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2256 if (pAppResource != null)
2258 pAppResource->GetString(L"IDS_MF_SK_DETAILS", Details);
2259 pAppResource->GetString(L"IDS_MF_SK3_DELETE", Delete);
2260 pAppResource->GetString(L"IDS_MF_BODY_RENAME_ABB", Rename);
2263 //Create the ContextMenu
2264 _pIconListViewContextMenu = new (std::nothrow) ContextMenu();
2266 _pIconListViewContextMenu->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_AUTO);
2267 _pIconListViewContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
2268 _pIconListViewContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
2271 _pIconListViewContextMenu->AddItem(Details, IDA_ICONLISTVIEW_DETAILS);
2272 if (_bIsTopLevelDirectory == false)
2274 _pIconListViewContextMenu->AddItem(Rename, IDA_ICONLISTVIEW_RENAME);
2275 _pIconListViewContextMenu->AddItem(Delete, IDA_ICONLISTVIEW_DELETE);
2278 //Set the ContextMenu's ActionEventListener
2279 _pIconListViewContextMenu->AddActionEventListener(*this);
2280 _pIconListViewContextMenu->SetFocusable(true);
2281 _pIconListViewContextMenu->SetShowState(true);
2287 SubBaseFolderEntryForm::ShowIconListViewContextMenu(void)
2290 CreateIconListViewContextMenu();
2291 int headerHeight = 0;
2293 int y_Anchor_Position = 0;
2295 Header* pHeader = GetHeader();
2296 headerHeight = pHeader->GetHeight();
2299 y_Anchor_Position = _currentPosition.y + headerHeight + H_DISPLAY_PATH_LABEL + 60;
2301 if (_bIsTopLevelDirectory)
2303 y_Anchor_Position = y_Anchor_Position + H_CATEGORY_PANEL;
2306 if (_pIconListViewContextMenu != null)
2308 _pIconListViewContextMenu->SetAnchorPosition(Point(_currentPosition.x, y_Anchor_Position));
2309 _pIconListViewContextMenu->SetShowState(true);
2310 _pIconListViewContextMenu->Show();
2315 SubBaseFolderEntryForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
2317 _currentPosition.x = currentPosition.x;
2318 _currentPosition.y = currentPosition.y;
2320 if (_pIconListView != null)
2322 _currentIndex = _pIconListView->GetItemIndexFromPosition(_currentPosition);
2329 SubBaseFolderEntryForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2331 //Empty Implementation
2335 SubBaseFolderEntryForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2337 //Empty Implementation
2341 SubBaseFolderEntryForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2343 //Empty Implementation
2346 SubBaseFolderEntryForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2348 //Empty Implementation
2352 SubBaseFolderEntryForm::SetCurrentDirectoryFlag(bool isTopDirectory)
2354 _bIsTopLevelDirectory = isTopDirectory;
2357 SubBaseFolderEntryForm::OnAppControlCompleted(void)
2359 AppLogDebug("Enter");
2360 if (_pFolderEntryPM!=null)
2362 if (_pFolderEntryPM->GetSourceForm() != CREATE_ITEM_SOURCE_CATEGORY_SEARCH_FORM)
2364 SetFooterVisibility();
2368 GetHeader()->Invalidate(true);
2370 if( !_bBackFromAppControl )
2373 if (_pListView != null && _pListView->IsVisible())
2375 _pListView->UpdateList();
2377 else if (_pIconListView != null && _pIconListView->GetShowState())
2379 _pIconListView->UpdateList();
2382 if (_pFolderEntryPM!=null)
2384 _pFolderEntryPM->InitThumbnailManager();
2386 _pFileEventManager->RemovePath(_fileEventPath);
2387 _bBackFromAppControl = false;
2388 AppLogDebug("Exit");
2392 SubBaseFolderEntryForm::OnSceneIdChanged(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& previousSceneId)
2394 if ( _pFolderEntryPM !=null)
2396 if( currentSceneId.CompareTo(IDSCN_SUB_DIRECTORY_FORM))
2398 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST_TWO);
2400 else if (currentSceneId.CompareTo(IDSCN_SUB_DIRECTORY_FORM1))
2402 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);
2408 SubBaseFolderEntryForm::OnSettingValueChanged(SettingKey settingKey)
2410 AppLogDebug("Entry");
2412 if (settingKey == SETTING_KEY_FONT_SIZE)
2414 if (_pBaseItemProvider != null)
2416 _pBaseItemProvider->GetFontSizeAndItemHeight();
2420 if (_pListView != null && _pListView->IsVisible())
2422 _pListView->UpdateList();
2424 else if (_pIconListView != null && _pIconListView->GetShowState())
2426 _pIconListView->UpdateList();
2431 SubBaseFolderEntryForm::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
2433 AppLogDebug("Enter");
2434 if (_pFilenames->GetCount() >0 || SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2437 if (_pOptionMenu != null)
2439 _pOptionMenu->SetShowState(true);
2440 _pOptionMenu->Show();
2449 SubBaseFolderEntryForm::CreateOptionMenu(void)
2451 if (_pOptionMenu != null)
2453 _pOptionMenu->RemoveAllItems();
2454 delete _pOptionMenu;
2455 _pOptionMenu = null;
2458 _pOptionMenu = new (std::nothrow) OptionMenu();
2459 _pOptionMenu->Construct();
2462 _pOptionMenu->AddItem("Item1",ID_OPTIONMENU_ITEM1);
2463 _pOptionMenu->AddItem("Item2",ID_OPTIONMENU_ITEM2);
2466 AppResource* pAppResource = null;
2467 AppRegistry* pAppRegistry = null;
2470 String extensionVisibility;
2473 String buttonCreateFolder;
2475 Bitmap* pBitmapSortbyContextItem = null;
2476 Bitmap* pBitmapSearchContextItem = null;
2477 Bitmap* pBitmapCreateFolderContextItem = null;
2479 pAppResource = Application::GetInstance()->GetAppResource();
2481 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2483 if (pAppResource != null)
2485 pAppResource->GetString(L"IDS_MF_OPT_VIEW_AS", viewAs);
2486 pAppResource->GetString(L"IDS_MF_SK3_SORT_BY", sortBy);
2487 pAppResource->GetString(L"IDS_MF_SK3_SEARCH", search);
2488 pAppResource->GetString(L"IDS_MF_OPT_CREATE_FOLDER", buttonCreateFolder);
2489 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
2490 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
2491 pBitmapSortbyContextItem = pAppResource->GetBitmapN(IDB_POPUP_SORTBY_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2492 pBitmapSearchContextItem = pAppResource->GetBitmapN(IDB_POPUP_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2493 pBitmapCreateFolderContextItem = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2496 pAppRegistry->Get(_extensionKeyName, extensionVisibility);
2498 if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_TOP_LEVEL_DIRECTORY_FORM)
2500 _pOptionMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2504 if (_bIsDirectoryEmpty == false)
2506 if (CheckSearchHistory() == false)
2508 _pOptionMenu->AddItem(search, IDA_CONTEXT_MENU_BTN_SEARCH, *pBitmapSearchContextItem, null, null);
2511 _pOptionMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2512 _pOptionMenu->AddItem(sortBy, IDA_CONTEXT_MENU_BTN_SORT_BY, *pBitmapSortbyContextItem, null, null);
2514 if (extensionVisibility == hideExtensionKeyValue)
2516 _pOptionMenu->AddItem(_showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
2520 _pOptionMenu->AddItem(_hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
2524 if (SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2526 _pOptionMenu->AddItem(buttonCreateFolder, IDA_CONTEXT_MENU_CREATE_FOLDER, *pBitmapCreateFolderContextItem, null, null);
2530 _pOptionMenu->AddActionEventListener(*this);
2532 delete pBitmapSortbyContextItem;
2533 delete pBitmapSearchContextItem;
2534 delete pBitmapCreateFolderContextItem;