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;
83 _bIsFileEventOccured = false;
85 _pathOfSelectedFile = L"";
87 _flagViewAsStatus = 0;
94 _selectedItemIndex = -1;
97 SubBaseFolderEntryForm::~SubBaseFolderEntryForm(void)
101 if (_pFolderEntryPM != null)
103 delete _pFolderEntryPM;
106 if (_pMoreContextMenu != null)
108 delete _pMoreContextMenu;
111 if (_pOptionMenu != null)
116 if (_pViewAsPopup != null)
118 delete _pViewAsPopup;
121 if (_pDeleteConfirmationPopUp != null)
123 delete _pDeleteConfirmationPopUp;
126 if (_pCustomListViewForPopup != null)
128 delete _pCustomListViewForPopup;
131 if (_pMediaMetaData != null)
133 delete _pMediaMetaData;
136 if (_pSortByPopup != null)
138 delete _pSortByPopup;
141 if (_pFileProgressingPopup != null)
143 delete _pFileProgressingPopup;
146 if (_pThumbnailItemProvider != null)
148 delete _pThumbnailItemProvider;
151 if (_pBaseItemProvider != null)
153 delete _pBaseItemProvider;
161 if (_pSortBy != null)
166 if (_pSearch != null)
176 if (_pFileEventManager != null)
178 delete _pFileEventManager;
181 if (_pIconListViewContextMenu != null)
183 delete _pIconListViewContextMenu;
187 SubBaseFolderEntryForm&
188 SubBaseFolderEntryForm::operator =(const SubBaseFolderEntryForm& pSubBaseFolderEntryForm)
193 SubBaseFolderEntryForm::SubBaseFolderEntryForm(const SubBaseFolderEntryForm& pSubBaseFolderEntryForm)
199 SubBaseFolderEntryForm::CreateFooterControls(void)
201 AppLogDebug("ENTER");
202 //Create Footer and controls contained within the footer
203 result r = E_SUCCESS;
205 AppResource* pAppResource = null;
209 ButtonItem footerItemMenu;
211 pAppResource = Application::GetInstance()->GetAppResource();
213 if (pAppResource != null)
215 pAppResource->GetString(L"IDS_MF_SK3_EDIT", buttonEdit);
216 pAppResource->GetString(L"IDS_COM_BUTTON_SHARE", buttonShare);
221 _pEdit = new (std::nothrow) FooterItem();
222 _pEdit->Construct(IDA_BTN_EDIT);
223 _pEdit->SetText(buttonEdit);
228 _pShare = new (std::nothrow) FooterItem();
229 _pShare->Construct(IDA_BTN_SHARE);
230 _pShare->SetText(buttonShare);
233 //Get the Footer and set the FooterItems.
234 _pFooter = GetFooter();
235 if (_pFooter != null)
237 _pFooter->RemoveAllButtons();
238 _pFooter->RemoveAllItems();
240 _pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
241 _pFooter->AddItem(*_pEdit);
242 _pFooter->AddItem(*_pShare);
244 //Set am ActionEventListener to the Footer
245 _pFooter->AddActionEventListener(*this);
246 _pFooter->SetItemEnabled(0, false);
247 _pFooter->SetItemEnabled(1, false);
248 _pFooter->Invalidate(true);
255 SubBaseFolderEntryForm::CreateDeleteConfirmationPopUp(void)
257 result r = E_SUCCESS;
258 Rectangle popupBounds;
260 //Create a new popup control
261 _pDeleteConfirmationPopUp = new (std::nothrow) Popup();
262 _pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
264 _pDeleteFile = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
265 TryCatch(_pDeleteFile != null, , "MfMyFilesApp::Button For Popup not created!");
267 _pDeleteFile->SetActionId(IDA_DELETE_FILE);
268 _pDeleteFile->AddActionEventListener(*this);
269 _pDeleteFile->SetShowState(true);
271 _pCancelDeletion = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
272 TryCatch(_pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
274 _pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
275 _pCancelDeletion->AddActionEventListener(*this);
276 _pCancelDeletion->SetShowState(true);
282 if (_pDeleteConfirmationPopUp != null)
284 delete _pDeleteConfirmationPopUp;
285 _pDeleteConfirmationPopUp = null;
292 SubBaseFolderEntryForm::ShowSortByPopup(void)
297 //Set the showstate of the popup to true. so that it's displayed on the form.
298 if (_pSortByPopup != null)
300 _pSortByPopup->SetShowState(true);
301 _pSortByPopup->Invalidate(true);
302 _pSortByPopup->Show();
305 SetDefaultSelectionForSortByPopUp();
310 SubBaseFolderEntryForm::HideSortByPopup(void)
312 //Set the showstate of the popup to false. so that it's hidden on the form.
313 if (_pSortByPopup != null && _pSortByPopup->IsVisible())
315 _pSortByPopup->SetShowState(false);
321 SubBaseFolderEntryForm::LoadRenameForm(int index)
323 result r = E_SUCCESS;
324 _renameOrCreate = SELECT_RENAME;
325 ArrayList* pArg = null;
326 Integer* pSourceSelected = null;
327 SceneManager* pSceneManager = null;
328 DirectoryEntry* pDirectory = null;
330 if(_pFilenames != null)
332 pDirectory = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
333 TryCatch(pDirectory != null, , "failed to allocate memeory to cast to DirectoryEntry");
336 pArg = new (std::nothrow) ArrayList();
337 r = pArg->Construct();
339 pSourceSelected = new (std::nothrow) Integer(_renameOrCreate);
341 pArg->Add(pSourceSelected);
342 TryCatch(r == E_SUCCESS, , "failed to construct parg");
344 //pArg->Add(__rootMediaPath);
345 pArg->Add(pDirectory);
346 TryCatch(r == E_SUCCESS, , "failed to construct parg");
348 pSceneManager = SceneManager::GetInstance();
349 TryCatch(pSceneManager != null, , "failed to Get SceneManager instance");
351 //pSceneManager->GoForward(SCENE_RENAME_FORM, pArg, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
352 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
354 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
358 if (pSourceSelected != null)
360 delete pSourceSelected;
361 pSourceSelected = null;
363 if (pDirectory != null)
376 SubBaseFolderEntryForm::LoadSearchForm(void)
378 ArrayList* pTopLevelDirectoryList = null;
379 ArrayList* pFilepathList = null;
380 SceneManager* pSceneManager = null;
382 pTopLevelDirectoryList= new (std::nothrow) ArrayList();
383 if (pTopLevelDirectoryList != null && _pFilenames != null)
385 pFilepathList = new (std::nothrow) ArrayList();
386 if (pFilepathList != null)
388 pFilepathList->Construct();
389 pFilepathList->AddItems(*_pFilenames);
390 pTopLevelDirectoryList->Add(pFilepathList);
394 TryCatch(pTopLevelDirectoryList != null, , "failed to Get SceneManager instance");
396 pSceneManager = SceneManager::GetInstance();
397 TryCatch(pSceneManager != null, , "failed to Get SceneManager instance");
399 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pTopLevelDirectoryList);
405 if (pFilepathList != null)
407 delete pFilepathList;
408 pFilepathList = null;
411 if (pTopLevelDirectoryList != null)
413 delete pTopLevelDirectoryList;
414 pTopLevelDirectoryList = null;
419 SubBaseFolderEntryForm::ShowViewAsPopup(void)
421 //Call functions to create the popups.
422 CreateViewAsPopupControl();
424 //Set the showstate of the popup to true. so that it's displayed on the form.
425 if (_pViewAsPopup != null)
427 _pViewAsPopup->SetShowState(true);
428 _pViewAsPopup->Show();
431 SetDefaultSelectionForViewAsPopUp();
435 SubBaseFolderEntryForm::HideViewAsPopup(void)
437 //Set the showstate of the popup to false. so that it's hidden on the form.
438 if (_pViewAsPopup != null && _pViewAsPopup->IsVisible())
440 _pViewAsPopup->SetShowState(false);
445 SubBaseFolderEntryForm::LoadCreateFolderForm(void)
447 //Load the CreateFolder view in the current directory.
448 result r = E_SUCCESS;
449 Integer* pSourceSelected = null;
450 SceneManager* pSceneManager = null;
451 ArrayList* pArg = null;
453 pSourceSelected = new (std::nothrow) Integer(SELECT_CREATE_FOLDER);
455 pArg = new (std::nothrow) ArrayList();
456 TryCatch(pArg != null, , "Failed to allocate memory for pArg");
458 r = pArg->Construct();
459 TryCatch(r == E_SUCCESS, , "failed to construct parg");
461 r = pArg->Add(pSourceSelected);
462 TryCatch(r == E_SUCCESS, , "Failed to Add Arguments pArg");
464 pSceneManager = SceneManager::GetInstance();
465 TryCatch(pSceneManager != null, , "failed to construct parg");
467 //pSceneManager->GoForward(SCENE_CREATE_FOLDER_FORM, pArg, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
468 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
473 if (pSourceSelected != null)
475 delete pSourceSelected;
485 SubBaseFolderEntryForm::LoadDetailForm(Tizen::Base::String& Fullpath)
487 result r = E_SUCCESS;
489 SceneManager* pSceneManager = null;
490 ArrayList* pList = null;
491 String* pFullFilePath = null;
493 pList = new (std::nothrow) ArrayList();
494 TryCatch(pList != null, , "Failed to allocate memory for pList");
496 r = pList->Construct();
497 TryCatch(r == E_SUCCESS, , "Failed to Add Construct pList");
499 pFullFilePath = new (std::nothrow) String(Fullpath);
500 TryCatch(pFullFilePath != null, , "Failed to allocate memory for pFullFilePath");
502 r = pList->Add(pFullFilePath);
503 TryCatch(r == E_SUCCESS, , "Failed to Add Arguments pList");
505 pSceneManager = SceneManager::GetInstance();
506 TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");
508 //pSceneManager->GoForward(SCENE_FILE_DETAIL_FORM, pList, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
509 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
510 AppLogDebug("Exit: %s", GetErrorMessage(r));
514 AppLogDebug("Exit: %s", GetErrorMessage(r));
515 if (pFullFilePath != null)
517 delete pFullFilePath;
518 pFullFilePath = null;
530 SubBaseFolderEntryForm::LoadEditForm(void)
532 AppLogDebug("ENTER");
533 //__pFileListPM->SetFileEventListener(null);
534 SceneManager* pSceneManager = SceneManager::GetInstance();
535 ArrayList* pArgs = null;
537 pArgs = new (std::nothrow) ArrayList();
538 //pArgs->Construct();
544 pArgs->Add(* new (std::nothrow) Integer(_editOrShare));
546 pArgs->Add(*_pFolderEntryPM);
549 if (pSceneManager != null)
551 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
565 SubBaseFolderEntryForm::ShowFileProgressingPopup(void)
567 CreateFileProgressingPopup();
569 if (_pFileProgressingPopup != null)
571 _pFileProgressingPopup->SetShowState(true);
572 _pFileProgressingPopup->Show();
577 SubBaseFolderEntryForm::HideFileProgressingPopup(void)
579 if (_pFileProgressingPopup != null)
581 _pFileProgressingPopup->SetShowState(false);
583 if (_pFileProgressingPopup != null)
585 delete _pFileProgressingPopup;
586 _pFileProgressingPopup = null;
592 SubBaseFolderEntryForm::CreateFileProgressingPopup(void)
594 AppLogDebug("Enter");
595 result r = E_SUCCESS;
598 //String fileProgress;
600 if (_pFileProgressingPopup != null)
602 AppLogDebug("_pFileProgressingPopup is not null");
606 AppResource* pAppResource = null;
607 pAppResource = UiApp::GetInstance()->GetAppResource();
608 TryCatch(pAppResource != null, , "Failed to fetch AppResource");
610 //pAppResource->GetString(L"IDS_FILE_PROCESSING", popUpTitle);
611 pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
612 //pAppResource->GetString(L"IDS_FILE_PROGRESS", fileProgress);
614 _pFileProgressingPopup = new (std::nothrow) Popup();
615 _pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
616 TryCatch(_pFileProgressingPopup != null, , "Failed to allocate memory to FileProgressing Popup.");
618 //_pFileProgressingPopup->SetTitleText(popUpTitle); //Not in UI
621 _pFileProgressingCancelButton = static_cast< Button* >(_pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
622 TryCatch(_pFileProgressingCancelButton != null, , "Failed to fetch _pFileProgressingCancelButton.");
624 _pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
625 _pFileProgressingCancelButton->AddActionEventListener(*this);
626 _pFileProgressingCancelButton->SetShowState(true);
628 _pFileProgressingProgress = static_cast< Progress* >(_pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
629 TryCatch(_pFileProgressingProgress != null, , "Failed to fetch _pFileProgressingProgress.");
631 _pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
632 _pFileProgressingProgress->SetValue(0);
634 _pFileProgressingHeaderLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
635 TryCatch(_pFileProgressingHeaderLabel != null, , "Failed to fetch _pFileProgressingHeaderLabel.");
637 _pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
638 _pFileProgressingHeaderLabel->SetText(deleting);
639 _pFileProgressingHeaderLabel->SetShowState(true);
640 _pFileProgressingHeaderLabel->Invalidate(true);
643 _pFileProgressingLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
644 TryCatch(_pFileProgressingLabel != null, , "Failed to fetch _pFileProgressingLabel.");
646 _pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
647 //_pFileProgressingLabel->SetText(fileProgress);
648 _pFileProgressingLabel->SetShowState(true);
655 if (_pFileProgressingPopup != null)
657 delete _pFileProgressingPopup;
658 _pFileProgressingPopup = null;
665 SubBaseFolderEntryForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
667 int x_FooterPosition = 0;
668 int y_FooterPosition = 0;
669 int x_ContextMenu = 0;
670 int y_ContextMenu = 0;
672 Rectangle listViewBounds(GetClientAreaBounds().x, H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, GetClientAreaBounds().height);
673 Rectangle labelBounds(GetClientAreaBounds().x, 0, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL);
675 _pFooter = GetFooter();
676 if (_pFooter != null)
678 _pFooter->GetPosition(x_FooterPosition, y_FooterPosition);
681 x_ContextMenu = x_FooterPosition + 3 * (listViewBounds.width / 4);
682 y_ContextMenu = y_FooterPosition;
684 switch (orientationStatus)
686 case ORIENTATION_STATUS_PORTRAIT:
688 if (_pListView != null)
690 _pListView->SetBounds(listViewBounds);
692 if (_pIconListView != null)
694 _pIconListView->SetBounds(listViewBounds);
696 if (_pMoreContextMenu != null)
698 _pMoreContextMenu->SetAnchorPosition(Point(x_ContextMenu, y_ContextMenu));
700 /* if (__pLabelDisplayPath != null)
702 __pLabelDisplayPath->SetBounds(labelBounds);
707 case ORIENTATION_STATUS_LANDSCAPE:
709 if (_pListView != null)
711 _pListView->SetBounds(listViewBounds);
713 if (_pIconListView != null)
715 _pIconListView->SetBounds(listViewBounds);
717 if (_pMoreContextMenu != null)
719 _pMoreContextMenu->SetAnchorPosition(Point(x_ContextMenu, y_ContextMenu));
721 /* if (__pLabelDisplayPath != null)
723 __pLabelDisplayPath->SetBounds(labelBounds);
739 SubBaseFolderEntryForm::OnFileManagingStart(void)
741 ShowFileProgressingPopup();
745 SubBaseFolderEntryForm::OnFileManagingStop(FileManagingResult fileManagingResult)
747 //Empty Implementation.
751 SubBaseFolderEntryForm::HideFileExtension(void)
753 int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
754 String viewStyleKeyName(L"ListDisplayType");
756 result r = E_SUCCESS;
758 AppRegistry* pAppRegistry = null;
759 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
762 if (pAppRegistry != null)
764 r = pAppRegistry->Set(_extensionKeyName, hideExtensionKeyValue);
765 r = pAppRegistry->Save();
767 r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
770 if (_pMoreContextMenu != null)
772 r = _pMoreContextMenu->SetItemAt(2, _showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
773 AppLogDebug("error %s", GetErrorMessage(r));
776 if (_pOptionMenu != null)
778 r = _pOptionMenu->SetItemAt(3, _showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
779 AppLogDebug("error %s", GetErrorMessage(r));
782 //Update the corresponding List.
783 if (listViewDisplayType == VIEW_TYPE_AS_THUMBNAILS)
785 if (_pIconListView != null)
787 _pIconListView->SetShowState(true);
788 _pIconListView->UpdateList();
793 if (_pListView != null)
795 _pListView->UpdateList();
796 _pListView->SetShowState(true);
800 if (_pMoreContextMenu != null)
802 delete _pMoreContextMenu;
803 _pMoreContextMenu = null;
808 AppLogDebug("Exit : %s", GetErrorMessage(r));
812 SubBaseFolderEntryForm::ShowFileExtension(void)
814 int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
815 String viewStyleKeyName(L"ListDisplayType");
817 result r = E_SUCCESS;
819 AppRegistry* pAppRegistry = null;
820 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
822 if (pAppRegistry != null)
824 r = pAppRegistry->Set(_extensionKeyName, showExtensionKeyValue);
825 r = pAppRegistry->Save();
827 r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
830 if (_pMoreContextMenu != null)
832 r = _pMoreContextMenu->SetItemAt(2, _hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
833 AppLogDebug("error %s", GetErrorMessage(r));
836 if (_pOptionMenu != null)
838 r = _pOptionMenu->SetItemAt(3, _hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
839 AppLogDebug("error %s", GetErrorMessage(r));
841 if (listViewDisplayType == VIEW_TYPE_AS_THUMBNAILS)
843 if (_pIconListView != null)
845 _pIconListView->UpdateList();
846 _pIconListView->SetShowState(true);
851 if (_pListView != null)
853 _pListView->UpdateList();
854 _pListView->SetShowState(true);
858 if (_pMoreContextMenu != null)
860 delete _pMoreContextMenu;
861 _pMoreContextMenu = null;
865 AppLogDebug("Exit: %s", GetErrorMessage(r));
870 SubBaseFolderEntryForm::HideDeleteConfirmationPopup(void)
872 if (_pDeleteConfirmationPopUp != null && _pDeleteConfirmationPopUp->IsVisible())
874 _pDeleteConfirmationPopUp->SetShowState(false);
879 SubBaseFolderEntryForm::ShowDeleteConfirmationPopup(void)
881 CreateDeleteConfirmationPopUp();
883 if (_pDeleteConfirmationPopUp != null)
885 _pDeleteConfirmationPopUp->SetShowState(true);
886 _pDeleteConfirmationPopUp->Show();
891 SubBaseFolderEntryForm::CreateViewAsPopupControl(void)
893 AppLogDebug("ENTER");
894 //Creates a popup control for the ViewAs context item asking which view is to be shown
896 result r = E_SUCCESS;
898 if (_pViewAsPopup != null)
900 AppLogDebug("_pViewAsPopup is not null");
904 String viewAsPopupTitle;
906 String sortByPopupTitle;
908 // Label* pViewAsPanelLabel = null;
910 // Label* pViewAsPopupLabel = null;
912 // Bitmap* pPanelBackground = null;
913 // Bitmap* pPopUpBackground = null;
915 // pPanelBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, BITMAP_PIXEL_FORMAT_ARGB8888);
916 // pPopUpBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_CENTER, BITMAP_PIXEL_FORMAT_ARGB8888);
918 //Create a new popup control
919 _pViewAsPopup = new (std::nothrow) Popup();
920 _pViewAsPopup->Construct(L"IDL_VIEW_AS_POPUP");
922 //The cancel button inside the popup, hides the popup when clicked.
923 _pCancelViewAs = static_cast< Button* >(_pViewAsPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
924 TryCatch(_pCancelViewAs != null, , "MfMyFilesApp::Button For Popup not created!");
926 _pCancelViewAs->SetActionId(IDA_BTN_POPUP_CANCEL);
927 _pCancelViewAs->AddActionEventListener(*this);
928 _pCancelViewAs->SetShowState(true);
930 // pViewAsPanelLabel = static_cast< Label* >(_pViewAsPopup->GetControl(L"IDC_LABEL_BOTTOM_BACKGROUND", true));
931 // TryCatch(pViewAsPanelLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
933 // pViewAsPopupLabel = static_cast< Label* >(_pViewAsPopup->GetControl(L"IDC_LABEL_POPUP_BACKGROUND", true));
934 // TryCatch(pViewAsPopupLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
936 // pPanelBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, pViewAsPanelLabel->GetWidth(), pViewAsPanelLabel->GetHeight());
937 // pPopUpBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, pViewAsPopupLabel->GetWidth(), pViewAsPopupLabel->GetHeight());
939 // if (pPanelBackground != null)
941 // pViewAsPanelLabel->SetBackgroundBitmap(*pPanelBackground);
944 // if (pPopUpBackground != null)
946 // pViewAsPopupLabel->SetBackgroundBitmap(*pPopUpBackground);
949 //The listview control which is to be added inside the popup. The itemprovider and listener are
950 //implemented in another class because this class already contains an instance of Listview control
951 //attached to an ItemProvider.
953 _pViewAsPopup->SetControlAlwaysOnTop(*_pCancelViewAs, true);
956 _pViewAsListView = static_cast< ListView* >(_pViewAsPopup->GetControl(L"IDC_LISTVIEW_VIEW_AS", true));
957 TryCatch(_pViewAsListView != null, , "MfMyFilesApp::ListView Control For Popup not created!");
959 _pViewAsListView->SetShowState(true);
960 _pViewAsListView->AddListViewItemEventListener(*_pCustomListViewForPopup);
961 _pViewAsListView->SetItemProvider(*_pCustomListViewForPopup);
962 _pViewAsListView->SetName(L"VIEW_AS_LISTVIEW");
963 _pViewAsListView->SetItemDividerColor(Color::GetColor(COLOR_ID_GREY));
965 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
967 // if (pPanelBackground != null)
969 // delete pPanelBackground;
970 // pPanelBackground = null;
972 // if (pPopUpBackground != null)
974 // delete pPopUpBackground;
975 // pPopUpBackground = null;
980 if (_pViewAsPopup != null)
982 delete _pViewAsPopup;
983 _pViewAsPopup = null;
986 if (_pCustomListViewForPopup != null)
988 delete _pCustomListViewForPopup;
989 _pCustomListViewForPopup = null;
992 // if (pPanelBackground != null)
994 // delete pPanelBackground;
995 // pPanelBackground = null;
998 // if (pPopUpBackground != null)
1000 // delete pPopUpBackground;
1001 // pPopUpBackground = null;
1007 SubBaseFolderEntryForm::ShowMoreContextMenu(void)
1009 String extensionStatus;
1011 AppRegistry* pAppRegistry = null;
1012 result r = E_SUCCESS;
1013 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1015 //Show ContextMenu with More Options
1016 if (pAppRegistry != null)
1018 r = pAppRegistry->Get(_extensionKeyName, extensionStatus);
1021 if (_pMoreContextMenu != null)
1023 if (extensionStatus == _hideExtension)
1025 r = _pMoreContextMenu->SetItemAt(2, _showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
1029 r = _pMoreContextMenu->SetItemAt(2, _hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
1032 _pMoreContextMenu->SetShowState(true);
1033 _pMoreContextMenu->Show();
1036 AppLogDebug("Exit: %s", GetErrorMessage(r));
1040 SubBaseFolderEntryForm::OnListViewItemStateChangedNotify(ViewType listViewStyle)
1042 AppLogDebug("ENTER");
1044 int popupSource = POP_UP_VIEW_AS;
1045 int sortType = SORT_BY_TYPE_NAME_ASCENDING;
1046 int thumbnailRequestId = 0;
1048 AppRegistry* pAppRegistry = null;
1049 String sortByKeyName(L"SortBy");
1051 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1053 if (_pCustomListViewForPopup != null)
1055 popupSource = _pCustomListViewForPopup->GetSelectionPopup();
1058 pAppRegistry->Get(sortByKeyName, sortType);
1060 if (popupSource == POP_UP_VIEW_AS)
1062 _flagViewAsStatus = listViewStyle;
1064 if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_CATEGORY_SEARCH_FORM)
1066 if (_pBaseItemProvider != null)
1068 _pBaseItemProvider->SetSecondaryBitmap();
1072 if (_pBaseItemProvider != null)
1074 _pBaseItemProvider->GetFontSizeAndItemHeight();
1085 if (_pFolderEntryPM != null)
1087 thumbnailRequestId = _pFolderEntryPM->GetCurrentReqId() + 1;
1088 _pFolderEntryPM->SetCurrentReqId(thumbnailRequestId);
1089 if (_pFolderEntryPM != null && _pFolderEntryPM->GetSourceForm() != CREATE_ITEM_SOURCE_SPLIT_PANEL_DIR_TREE)
1091 _pFolderEntryPM->SortFolderEntries();
1095 if (_pListView != null && _pListView->IsVisible())
1097 _pListView->UpdateList();
1099 else if (_pIconListView != null && _pIconListView->GetShowState())
1101 _pIconListView->UpdateList();
1104 if (_pFolderEntryPM != null)
1106 _pFolderEntryPM->InitThumbnailManager();
1111 if (_pMoreContextMenu != null)
1113 delete _pMoreContextMenu;
1114 _pMoreContextMenu = null;
1118 SubBaseFolderEntryForm::OnIconListViewItemStateChangeNotify()
1120 if (_pIconListView != null && _pIconListView->GetShowState())
1122 _pIconListView->UpdateList();
1126 SubBaseFolderEntryForm::OnFooterStateChangeNotify(void)
1128 SetFooterVisibility();
1130 _pFooter = GetFooter();
1131 if (_pFooter != null)
1133 _pFooter->Invalidate(true);
1138 SubBaseFolderEntryForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1140 AppLogDebug("OnAppControlCompleteResponseReceived");
1141 result r = E_SUCCESS;
1142 CustomAppControl::GetInstance()->SetAppControlInUse(null);
1144 if (GetLastResult() == E_FILE_NOT_FOUND)
1146 _pFolderEntryPM->RefreshFolderEntries();
1147 if (_pListView != null && _pListView->IsVisible())
1149 r = _pListView->UpdateList();
1151 else if (_pIconListView != null && _pIconListView->GetShowState())
1153 r = _pIconListView->UpdateList();
1155 _pFolderEntryPM->InitThumbnailManager();
1160 SubBaseFolderEntryForm::SetDefaultSelectionForSortByPopUp(void)
1162 result r = E_SUCCESS;
1164 int defaultSortPopUpSelect = 0;
1166 int sortType = SORT_BY_TYPE_NAME_ASCENDING;
1168 int uncheckItem1 = 0;
1169 int uncheckItem2 = 0;
1170 int uncheckItem3 = 0;
1171 int uncheckItem4 = 0;
1172 int uncheckItem5 = 0;
1174 String sortByKeyName(L"SortBy");
1176 AppRegistry* pAppRegistry = null;
1178 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1180 r = pAppRegistry->Get(sortByKeyName, sortType);
1181 TryCatch(r == E_SUCCESS, , "Failed To Get Value From AppRegistry");
1186 case SORT_BY_TYPE_NAME_ASCENDING:
1188 defaultSortPopUpSelect = 0;
1197 case SORT_BY_TYPE_NAME_DESCENDING:
1199 defaultSortPopUpSelect = 1;
1208 case SORT_BY_TYPE_DATE_RECENT:
1210 defaultSortPopUpSelect = 2;
1220 case SORT_BY_TYPE_DATE_OLDEST:
1222 defaultSortPopUpSelect = 3;
1231 case SORT_BY_TYPE_SIZE_ASCENDING:
1233 defaultSortPopUpSelect = 4;
1242 case SORT_BY_TYPE_SIZE_DESCENDING:
1244 defaultSortPopUpSelect = 4;
1253 case SORT_BY_TYPE_ASCENDING:
1255 defaultSortPopUpSelect = 5;
1265 case SORT_BY_TYPE_DESCENDING:
1267 defaultSortPopUpSelect = 5;
1279 defaultSortPopUpSelect = 0;
1280 AppLogDebug("UnSupported case reached");
1285 if (_pCustomListViewForPopup != null)
1287 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_SORT_BY);
1290 if (_pSortByPopup != null && _pSortByListView != null)
1292 _pSortByListView->UpdateList();
1293 _pSortByListView->SetItemChecked(defaultSortPopUpSelect, true);
1294 _pSortByListView->SetItemChecked(uncheckItem1, false);
1295 _pSortByListView->SetItemChecked(uncheckItem2, false);
1296 _pSortByListView->SetItemChecked(uncheckItem3, false);
1297 _pSortByListView->SetItemChecked(uncheckItem4, false);
1298 _pSortByListView->SetItemChecked(uncheckItem5, false);
1300 _pSortByListView->Invalidate(true);
1309 SubBaseFolderEntryForm::SwitchViewType(void)
1311 String viewStyleKeyName(L"ListDisplayType");
1313 switch (_flagViewAsStatus)
1316 case VIEW_TYPE_AS_DETAILED_LIST:
1318 if (_pIconListView != null )
1320 _pIconListView->SetShowState(false);
1322 if (_pListView != null)
1324 _pListView->UpdateList();
1325 if (_selectedItemIndex == -1)
1327 _pListView->ScrollToItem(0);
1329 _pListView->SetShowState(true);
1335 case VIEW_TYPE_AS_NORMAL_LIST:
1337 if (_pIconListView != null )
1339 _pIconListView->SetShowState(false);
1342 if (_pListView != null)
1344 _pListView->UpdateList();
1345 if (_selectedItemIndex == -1)
1347 _pListView->ScrollToItem(0);
1349 _pListView->SetShowState(true);
1354 case VIEW_TYPE_AS_THUMBNAILS:
1356 if (_pListView != null )
1358 _pListView->SetShowState(false);
1360 if (_pIconListView != null)
1362 _pIconListView->UpdateList();
1363 if (_selectedItemIndex == -1)
1365 _pIconListView->ScrollToItem(0);
1367 _pIconListView->SetShowState(true);
1374 if (_pListView != null)
1376 _pListView->UpdateList();
1384 SubBaseFolderEntryForm::SetNextDisplayPath(void)
1391 fullPath = FolderNavigationPresentationModel::GetCurrentPath();
1393 StringTokenizer tokenizer(fullPath, delim);
1396 DataBindingContext* pContext = null;
1397 pContext = GetDataBindingContextN();
1401 switch (_storageType)
1403 case MEMORY_TYPE_PHONE:
1409 case MEMORY_TYPE_SD_CARD:
1422 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1423 //it is the last token
1424 while (tokenizer.HasMoreTokens())
1429 tokenizer.GetNextToken(token);
1433 tokenizer.GetNextToken(token);
1434 displayPath.Append(token);
1435 displayPath.Append(L"/");
1441 if (_pLabelDisplayPath != null)
1443 _displayPath.Append(displayPath);
1445 String displayPathToAppend(L"\x200E");
1446 displayPathToAppend.Append(_displayPath);
1448 _pLabelDisplayPath->SetText(displayPathToAppend);
1449 _pLabelDisplayPath->Invalidate(true);
1453 if (pContext != null)
1455 //UpdateBinding on the target label control.
1456 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
1459 if (pContext != null)
1467 FolderEntryPresentationModel*
1468 SubBaseFolderEntryForm::GetFolderEntryPresentationModel(void)
1470 return _pFolderEntryPM;
1474 SubBaseFolderEntryForm::DeleteFile(String& filePath)
1476 AppLogDebug("ENTER");
1477 result r = E_SUCCESS;
1479 //_pFolderEntryPM->SetFileEventListener(null);
1480 //((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1482 _pFileManager->DeleteFolderEntries(&filePath);
1484 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1489 SubBaseFolderEntryForm::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1491 AppLogDebug("ENTER");
1492 DirectoryEntry* pDirStr = null;
1499 _editOrShare = FILE_MANAGE_EDIT;
1500 //If filenames is not empty then Load the edit form.
1501 if (_pFilenames->GetCount() != 0)
1503 //_pFolderEntryPM->SetFileEventListener(null);
1512 AppLogDebug("Share Button Clicked!");
1514 _editOrShare = FILE_MANAGE_SHARE;
1515 if (_pFilenames->GetCount() != 0)
1517 //_pFolderEntryPM->SetFileEventListener(null);
1526 if (_pFilenames->GetCount() > 0)
1528 CreateMoreContextMenu();
1529 ShowMoreContextMenu();
1534 case IDA_CONTEXT_MENU_BTN_SORT_BY:
1536 //Show the SortBy PopUp.
1537 if (_pCustomListViewForPopup != null)
1539 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_SORT_BY);
1545 case IDA_CONTEXT_MENU_CREATE_FOLDER:
1547 //Load the CreateFolder Form.
1548 //_pFolderEntryPM->SetFileEventListener(null);
1549 _renameOrCreate = SELECT_CREATE_FOLDER;
1551 if (_pMoreContextMenu != null)
1553 delete _pMoreContextMenu;
1554 _pMoreContextMenu = null;
1557 LoadCreateFolderForm();
1561 case IDA_CONTEXT_MENU_VIEW_AS:
1563 //Show the ViewAs Popup
1564 if (_pCustomListViewForPopup != null)
1566 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_VIEW_AS);
1573 case IDA_BTN_POPUP_CANCEL:
1575 //Hide the ViewAs PopUp and redraw the form.
1580 case IDA_BTN_SORT_POPUP_CANCEL:
1582 //Hide the SortBy PopUp and redraw the form.
1587 case IDA_CONTEXT_MENU_BTN_SEARCH:
1589 //Load the SearchForm
1594 case IDA_DELETE_FILE:
1596 HideDeleteConfirmationPopup();
1597 if (_pDeleteConfirmationPopUp != null)
1599 delete _pDeleteConfirmationPopUp;
1600 _pDeleteConfirmationPopUp = null;
1604 if (_pFilenames != null)
1606 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(_indexToDelete));
1608 if (pDirStr != null)
1610 _filePath = pDirStr->GetFullFilePath();
1612 _indexTracker = _indexToDelete;
1613 //Call the DeleteFile Function.
1614 DeleteFile(_filePath);
1618 case IDA_CANCEL_DELETION:
1620 HideDeleteConfirmationPopup();
1621 _bIsDeleteFromContextSwipe = false;
1623 if (_pDeleteConfirmationPopUp != null)
1625 delete _pDeleteConfirmationPopUp;
1626 _pDeleteConfirmationPopUp = null;
1631 case IDA_BTN_ANIMATION_POPUP_CANCEL:
1633 AppLogDebug("IDA_BTN_ANIMATION_POPUP_CANCEL");
1634 HideFileProgressingPopup();
1635 _pFileManager->ForceStopWorkerThread();
1639 case IDA_ICONLISTVIEW_DETAILS:
1641 if (_pIconListViewContextMenu != null)
1643 delete _pIconListViewContextMenu;
1644 _pIconListViewContextMenu = null;
1647 if (_bIsTopLevelDirectory == false)
1649 if (_currentIndex != INVALID_LIST_INDEX && _pFilenames != null)
1651 pDirStr = static_cast <DirectoryEntry*>(_pFilenames->GetAt(_currentIndex));
1653 if (pDirStr != null)
1655 fullPath = pDirStr->GetFullFilePath();
1661 switch (_currentIndex)
1664 FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetMediaPath());
1665 fullPath = FolderNavigationPresentationModel::GetMediaPath();
1666 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
1669 FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetSdCardPath());
1670 fullPath = FolderNavigationPresentationModel::GetSdCardPath();
1671 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
1675 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetUsbPath());
1676 fullPath = FolderNavigationPresentationModel::GetUsbPath();
1677 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_EXTERNAL);
1682 LoadDetailForm(fullPath);
1686 case IDA_ICONLISTVIEW_DELETE:
1688 _bIsDeleteFromContextSwipe = true;
1690 if (_pFileEventManager != null)
1692 _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1694 if (_pIconListViewContextMenu != null)
1696 delete _pIconListViewContextMenu;
1697 _pIconListViewContextMenu = null;
1700 ShowDeleteConfirmationPopup();
1702 _indexToDelete = _currentIndex;
1707 case IDA_ICONLISTVIEW_RENAME:
1710 if (_pFileEventManager != null)
1712 _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1715 if (_pIconListViewContextMenu != null)
1717 delete _pIconListViewContextMenu;
1718 _pIconListViewContextMenu = null;
1721 if (_currentIndex != INVALID_LIST_INDEX && _pFilenames != null)
1723 pDirStr = static_cast <DirectoryEntry*>(_pFilenames->GetAt(_currentIndex));
1725 if (pDirStr != null)
1727 _currentFileName.Clear();
1728 _currentFileName = pDirStr->GetFileName();
1729 _pathOfSelectedFile = pDirStr->GetFullFilePath();
1733 _renameIndex = _currentIndex;
1734 _renameOrCreate = SELECT_RENAME;
1736 //Load the Rename View of the item selected.
1737 LoadRenameForm(_currentIndex);
1750 SubBaseFolderEntryForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
1752 DirectoryEntry* pDirStr = null;
1753 _selectedItemIndex = index;
1754 if (_pFilenames != null)
1756 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
1758 if (pDirStr != null)
1762 case IDA_CONTEXT_DETAIL:
1765 _filePath = pDirStr->GetFullFilePath();
1766 LoadDetailForm(_filePath);
1770 case IDA_CONTEXT_RENAME:
1772 if (_pFileEventManager != null)
1774 _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1777 _currentFileName.Clear();
1778 _currentFileName = pDirStr->GetFileName();
1780 _pathOfSelectedFile = pDirStr->GetFullFilePath();
1781 _renameIndex = index;
1782 _renameOrCreate = SELECT_RENAME;
1783 //Load the Rename View of the item selected.
1784 LoadRenameForm(index);
1788 case IDA_CONTEXT_DELETE:
1790 if (_pFileEventManager != null)
1792 _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1795 _bIsDeleteFromContextSwipe = true;
1797 _indexToDelete = index;
1799 ShowDeleteConfirmationPopup();
1805 //Empty Implementation.
1814 SubBaseFolderEntryForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
1816 result res = E_SUCCESS;
1817 AppLogDebug("Enter");
1819 if (_pFolderEntryPM)
1821 if (pThumbReq != null)
1823 if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
1825 if (pThumbReq->pBitmap != null)
1827 delete pThumbReq->pBitmap;
1833 if (pThumbReq != null)
1835 if (pThumbReq->GetCurrentRequestId() != _pFolderEntryPM->GetCurrentReqId())
1837 if (pThumbReq->pBitmap != null)
1839 delete pThumbReq->pBitmap;
1841 AppLogDebug("mismatch in id so returning");
1847 if (pThumbReq->iRquestId < _pFilenames->GetCount())
1849 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
1850 if (_pListView && _pListView->IsVisible())
1852 res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1854 else if (_pIconListView && _pIconListView->GetShowState())
1856 res = _pIconListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1860 AppLogDebug("Thumbnail Request is not valid");
1864 _pFolderEntryPM->OnThumbnailResponseFailed();
1867 AppLogDebug("Exit %s", GetErrorMessage(res));
1872 SubBaseFolderEntryForm::CreateSortByPopup(void)
1874 result r = E_SUCCESS;
1876 if (_pSortByPopup != null)
1878 AppLogDebug("_pSortByPopup is not null");
1882 String cancelButton;
1883 String sortByPopupTitle;
1885 // Label* pSortByPanelLabel = null;
1886 // Label* pSortByPopupLabel = null;
1888 // Bitmap* pPanelBackground = null;
1889 // Bitmap* pPopUpBackground = null;
1891 // pPanelBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, BITMAP_PIXEL_FORMAT_ARGB8888);
1892 //pPopUpBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_CENTER, BITMAP_PIXEL_FORMAT_ARGB8888);
1893 // pPopUpBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, 512, 632);
1894 // pPanelBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, 612, 96);
1896 _pSortByPopup = new (std::nothrow) Popup();
1897 _pSortByPopup->Construct(L"IDL_SORT_BY_POPUP");
1899 _pCancelSortBy = static_cast< Button* >(_pSortByPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1900 TryCatch(_pCancelSortBy != null, , "MfMyFilesApp::Button For Popup not created!");
1902 _pCancelSortBy->SetActionId(IDA_BTN_SORT_POPUP_CANCEL);
1903 _pCancelSortBy->AddActionEventListener(*this);
1904 _pCancelSortBy->SetShowState(true);
1906 // pSortByPanelLabel = static_cast< Label* >(_pSortByPopup->GetControl(L"IDC_LABEL_PANEL_BACKGROUND", true));
1907 // TryCatch(pSortByPanelLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
1909 // pSortByPopupLabel = static_cast< Label* >(_pSortByPopup->GetControl(L"IDC_LABEL_POPUP_BACKGROUND", true));
1910 // TryCatch(pSortByPopupLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
1912 // if (pPanelBackground != null)
1914 // pSortByPanelLabel->SetBackgroundBitmap(*pPanelBackground);
1917 // if (pPopUpBackground != null)
1919 // pSortByPopupLabel->SetBackgroundBitmap(*pPopUpBackground);
1923 _pSortByListView = static_cast< ListView* >(_pSortByPopup->GetControl(L"IDC_LISTVIEW_SORT_BY", true));
1924 TryCatch(_pSortByListView != null, , "MfMyFilesApp::ListView Control For Popup not created!");
1926 _pSortByListView->SetShowState(true);
1927 _pSortByListView->AddListViewItemEventListener(*_pCustomListViewForPopup);
1928 _pSortByListView->SetItemProvider(*_pCustomListViewForPopup);
1929 _pSortByListView->SetName(L"SORT_BY_LISTVIEW");
1930 _pSortByListView->SetItemDividerColor(Color::GetColor(COLOR_ID_GREY));
1932 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1934 // _pSortByPopup->SetControlAlwaysAtBottom(*pSortByPanelLabel, true);
1935 // _pSortByPopup->SetControlAlwaysAtBottom(*pSortByPopupLabel, true);
1936 _pSortByPopup->SetControlAlwaysOnTop(*_pSortByListView, true);
1937 _pSortByPopup->SetControlAlwaysOnTop(*_pCancelSortBy, true);
1939 // if (pPanelBackground != null)
1941 // delete pPanelBackground;
1942 // pPanelBackground = null;
1944 // if (pPopUpBackground != null)
1946 // delete pPopUpBackground;
1947 // pPopUpBackground = null;
1952 if (_pCustomListViewForPopup != null)
1954 delete _pCustomListViewForPopup;
1955 _pCustomListViewForPopup = null;
1958 if (_pSortByPopup != null)
1960 delete _pSortByPopup;
1961 _pSortByPopup = null;
1964 // if (pPanelBackground != null)
1966 // delete pPanelBackground;
1967 // pPanelBackground = null;
1970 // if (pPopUpBackground != null)
1972 // delete pPopUpBackground;
1973 // pPopUpBackground = null;
1980 SubBaseFolderEntryForm::CreateMoreContextMenu(void)
1982 result r = E_SUCCESS;
1984 if (_pMoreContextMenu != null)
1992 AppResource* pAppResource = null;
1993 AppRegistry* pAppRegistry = null;
1996 String extensionVisibility;
1999 String buttonCreateFolder;
2001 Bitmap* pBitmapSortbyContextItem = null;
2002 Bitmap* pBitmapSearchContextItem = null;
2003 Bitmap* pBitmapCreateFolderContextItem = null;
2005 pAppResource = Application::GetInstance()->GetAppResource();
2007 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2009 if (pAppResource != null)
2011 pAppResource->GetString(L"IDS_MF_OPT_VIEW_AS", viewAs);
2012 pAppResource->GetString(L"IDS_MF_SK3_SORT_BY", sortBy);
2013 pAppResource->GetString(L"IDS_MF_SK3_SEARCH", search);
2014 pAppResource->GetString(L"IDS_MF_OPT_CREATE_FOLDER", buttonCreateFolder);
2015 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
2016 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
2017 pBitmapSortbyContextItem = pAppResource->GetBitmapN(IDB_POPUP_SORTBY_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2018 pBitmapSearchContextItem = pAppResource->GetBitmapN(IDB_POPUP_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2019 pBitmapCreateFolderContextItem = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2022 pAppRegistry->Get(_extensionKeyName, extensionVisibility);
2024 _pFooter = GetFooter();
2025 if (_pFooter != null)
2027 _pFooter->GetPosition(xPosition, yPosition);
2030 xPosition += 3 * (GetClientAreaBounds().width / 4);
2032 //Create the ContextMenu
2033 _pMoreContextMenu = new (std::nothrow) ContextMenu();
2034 _pMoreContextMenu->Construct(Point(0, yPosition), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
2035 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
2036 _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
2038 if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_TOP_LEVEL_DIRECTORY_FORM)
2040 _pMoreContextMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2044 if (_bIsDirectoryEmpty == false)
2046 if (CheckSearchHistory() == false)
2048 _pMoreContextMenu->AddItem(search, IDA_CONTEXT_MENU_BTN_SEARCH, *pBitmapSearchContextItem, null, null);
2051 _pMoreContextMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2052 _pMoreContextMenu->AddItem(sortBy, IDA_CONTEXT_MENU_BTN_SORT_BY, *pBitmapSortbyContextItem, null, null);
2054 if (extensionVisibility == _hideExtension)
2056 _pMoreContextMenu->AddItem(_showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
2060 _pMoreContextMenu->AddItem(_hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
2064 if (SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2066 _pMoreContextMenu->AddItem(buttonCreateFolder, IDA_CONTEXT_MENU_CREATE_FOLDER, *pBitmapCreateFolderContextItem, null, null);
2070 //Set the ContextMenu's ActionEventListener
2071 _pMoreContextMenu->AddActionEventListener(*this);
2072 //_pMoreContextMenu->SetAnchorPosition(Point(xPosition, yPosition));
2073 _pMoreContextMenu->SetShowState(true);
2075 delete pBitmapSortbyContextItem;
2076 delete pBitmapSearchContextItem;
2077 delete pBitmapCreateFolderContextItem;
2082 SubBaseFolderEntryForm::SetDefaultSelectionForViewAsPopUp(void)
2084 result r = E_SUCCESS;
2086 int defaultViewAsPopUpSelect = 0;
2087 int uncheckItem1 = 0;
2088 int uncheckItem2 = 0;
2090 int viewType = VIEW_TYPE_AS_NONE;
2091 String viewStyleKeyName(L"ListDisplayType");
2093 AppRegistry* pAppRegistry = null;
2095 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2097 r = pAppRegistry->Get(viewStyleKeyName, viewType);
2102 case VIEW_TYPE_AS_DETAILED_LIST:
2104 defaultViewAsPopUpSelect = 1;
2110 case VIEW_TYPE_AS_NORMAL_LIST:
2112 defaultViewAsPopUpSelect = 0;
2118 case VIEW_TYPE_AS_THUMBNAILS:
2120 defaultViewAsPopUpSelect = 2;
2128 //Empty Implementation.
2134 if (_pCustomListViewForPopup != null)
2136 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_VIEW_AS);
2139 if (_pViewAsPopup != null && _pViewAsListView != null)
2141 _pViewAsListView->UpdateList();
2142 _pViewAsListView->SetItemChecked(defaultViewAsPopUpSelect, true);
2143 _pViewAsListView->SetItemChecked(uncheckItem1, false);
2144 _pViewAsListView->SetItemChecked(uncheckItem2, false);
2145 _pViewAsListView->Invalidate(true);
2152 SubBaseFolderEntryForm::SetFooterVisibility(void)
2154 AppLogDebug("Entry");
2155 int folderCount=0, fileCount=0;
2157 _pFooter = GetFooter();
2159 if( _pFolderEntryPM )
2160 _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(), folderCount, fileCount);
2162 if (folderCount ==0 && fileCount == 0)
2164 _bIsDirectoryEmpty = true;
2165 _pFooter->SetItemEnabled(0, false);
2166 _pFooter->SetItemEnabled(1, false);
2170 _bIsDirectoryEmpty = false;
2171 _pFooter->SetItemEnabled(0, true);
2175 _pFooter->SetItemEnabled(1, true);
2179 _pFooter->SetItemEnabled(1, false);
2183 _pFooter->Invalidate(true);
2187 SubBaseFolderEntryForm::CheckSearchHistory(void)
2189 bool searchHistoryStatus = false;
2192 SceneManager* pSceneManager = SceneManager::GetInstance();
2193 IListT< SceneId >* pSceneList = pSceneManager->GetSceneHistoryN();
2195 if (pSceneList != null)
2197 itemCount = pSceneList->GetCount() - 1;
2198 pSceneList->GetAt(itemCount, searchScene);
2199 while (searchScene != IDSCN_SEARCH_FORM && itemCount >= 0)
2202 pSceneList->GetAt(itemCount, searchScene);
2206 if (searchScene == IDSCN_SEARCH_FORM)
2208 AppLogDebug("Search scene present");
2209 searchHistoryStatus = true;
2213 AppLogDebug("Search scene not present");
2214 searchHistoryStatus = false;
2219 pSceneList->RemoveAll();
2223 return searchHistoryStatus;
2228 SubBaseFolderEntryForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
2230 //Empty Implementation
2234 SubBaseFolderEntryForm::OnLongPressGestureDetected(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector)
2237 if (_currentIndex != INVALID_LIST_INDEX)
2239 ShowIconListViewContextMenu();
2244 SubBaseFolderEntryForm::OnLongPressGestureCanceled(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector)
2246 //Empty Implementation.
2250 SubBaseFolderEntryForm::CreateIconListViewContextMenu(void)
2252 if (_pIconListViewContextMenu != null)
2257 result r = E_SUCCESS;
2263 String buttonCreateFolder;
2265 AppResource* pAppResource = null;
2266 //AppRegistry* pAppRegistry = null;
2267 pAppResource = Application::GetInstance()->GetAppResource();
2269 //pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2271 if (pAppResource != null)
2273 pAppResource->GetString(L"IDS_MF_SK_DETAILS", Details);
2274 pAppResource->GetString(L"IDS_MF_SK3_DELETE", Delete);
2275 pAppResource->GetString(L"IDS_MF_BODY_RENAME_ABB", Rename);
2278 //Create the ContextMenu
2279 _pIconListViewContextMenu = new (std::nothrow) ContextMenu();
2281 _pIconListViewContextMenu->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_AUTO);
2282 _pIconListViewContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
2283 _pIconListViewContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
2286 _pIconListViewContextMenu->AddItem(Details, IDA_ICONLISTVIEW_DETAILS);
2287 if (_bIsTopLevelDirectory == false)
2289 _pIconListViewContextMenu->AddItem(Rename, IDA_ICONLISTVIEW_RENAME);
2290 _pIconListViewContextMenu->AddItem(Delete, IDA_ICONLISTVIEW_DELETE);
2293 //Set the ContextMenu's ActionEventListener
2294 _pIconListViewContextMenu->AddActionEventListener(*this);
2295 _pIconListViewContextMenu->SetFocusable(true);
2296 _pIconListViewContextMenu->SetShowState(true);
2302 SubBaseFolderEntryForm::ShowIconListViewContextMenu(void)
2305 CreateIconListViewContextMenu();
2306 int headerHeight = 0;
2308 int y_Anchor_Position = 0;
2310 Header* pHeader = GetHeader();
2311 headerHeight = pHeader->GetHeight();
2314 y_Anchor_Position = _currentPosition.y + headerHeight + H_DISPLAY_PATH_LABEL + 60;
2316 if (_bIsTopLevelDirectory)
2318 y_Anchor_Position = y_Anchor_Position + H_CATEGORY_PANEL;
2321 if (_pIconListViewContextMenu != null)
2323 _pIconListViewContextMenu->SetAnchorPosition(Point(_currentPosition.x, y_Anchor_Position));
2324 _pIconListViewContextMenu->SetShowState(true);
2325 _pIconListViewContextMenu->Show();
2330 SubBaseFolderEntryForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
2332 _currentPosition.x = currentPosition.x;
2333 _currentPosition.y = currentPosition.y;
2335 if (_pIconListView != null)
2337 _currentIndex = _pIconListView->GetItemIndexFromPosition(_currentPosition);
2344 SubBaseFolderEntryForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2346 //Empty Implementation
2350 SubBaseFolderEntryForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2352 //Empty Implementation
2356 SubBaseFolderEntryForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2358 //Empty Implementation
2361 SubBaseFolderEntryForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2363 //Empty Implementation
2367 SubBaseFolderEntryForm::SetCurrentDirectoryFlag(bool isTopDirectory)
2369 _bIsTopLevelDirectory = isTopDirectory;
2372 SubBaseFolderEntryForm::OnAppControlCompleted(void)
2374 AppLogDebug("Enter");
2375 if (_pFolderEntryPM!=null)
2377 if (_pFolderEntryPM->GetSourceForm() != CREATE_ITEM_SOURCE_CATEGORY_SEARCH_FORM)
2379 SetFooterVisibility();
2383 GetHeader()->Invalidate(true);
2385 if( !_bBackFromAppControl )
2388 if (_pListView != null && _pListView->IsVisible())
2390 _pListView->UpdateList();
2392 else if (_pIconListView != null && _pIconListView->GetShowState())
2394 _pIconListView->UpdateList();
2397 if (_pFolderEntryPM!=null)
2399 _pFolderEntryPM->InitThumbnailManager();
2401 _pFileEventManager->RemovePath(_fileEventPath);
2402 _bBackFromAppControl = false;
2403 AppLogDebug("Exit");
2407 SubBaseFolderEntryForm::OnSceneIdChanged(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& previousSceneId)
2409 if ( _pFolderEntryPM !=null)
2411 if( currentSceneId.CompareTo(IDSCN_SUB_DIRECTORY_FORM))
2413 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST_TWO);
2415 else if (currentSceneId.CompareTo(IDSCN_SUB_DIRECTORY_FORM1))
2417 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);
2423 SubBaseFolderEntryForm::OnSettingValueChanged(SettingKey settingKey)
2425 AppLogDebug("Entry");
2427 if (settingKey == SETTING_KEY_FONT_SIZE)
2429 if (_pBaseItemProvider != null)
2431 _pBaseItemProvider->GetFontSizeAndItemHeight();
2435 if (_pListView != null && _pListView->IsVisible())
2437 _pListView->UpdateList();
2439 else if (_pIconListView != null && _pIconListView->GetShowState())
2441 _pIconListView->UpdateList();
2446 SubBaseFolderEntryForm::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
2448 AppLogDebug("Enter");
2449 if (_pFilenames->GetCount() >0 || SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2452 if (_pOptionMenu != null)
2454 _pOptionMenu->SetShowState(true);
2455 _pOptionMenu->Show();
2464 SubBaseFolderEntryForm::CreateOptionMenu(void)
2466 if (_pOptionMenu != null)
2468 _pOptionMenu->RemoveAllItems();
2469 delete _pOptionMenu;
2470 _pOptionMenu = null;
2473 _pOptionMenu = new (std::nothrow) OptionMenu();
2474 _pOptionMenu->Construct();
2477 _pOptionMenu->AddItem("Item1",ID_OPTIONMENU_ITEM1);
2478 _pOptionMenu->AddItem("Item2",ID_OPTIONMENU_ITEM2);
2481 AppResource* pAppResource = null;
2482 AppRegistry* pAppRegistry = null;
2485 String extensionVisibility;
2488 String buttonCreateFolder;
2490 Bitmap* pBitmapSortbyContextItem = null;
2491 Bitmap* pBitmapSearchContextItem = null;
2492 Bitmap* pBitmapCreateFolderContextItem = null;
2494 pAppResource = Application::GetInstance()->GetAppResource();
2496 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2498 if (pAppResource != null)
2500 pAppResource->GetString(L"IDS_MF_OPT_VIEW_AS", viewAs);
2501 pAppResource->GetString(L"IDS_MF_SK3_SORT_BY", sortBy);
2502 pAppResource->GetString(L"IDS_MF_SK3_SEARCH", search);
2503 pAppResource->GetString(L"IDS_MF_OPT_CREATE_FOLDER", buttonCreateFolder);
2504 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
2505 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
2506 pBitmapSortbyContextItem = pAppResource->GetBitmapN(IDB_POPUP_SORTBY_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2507 pBitmapSearchContextItem = pAppResource->GetBitmapN(IDB_POPUP_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2508 pBitmapCreateFolderContextItem = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2511 pAppRegistry->Get(_extensionKeyName, extensionVisibility);
2513 if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_TOP_LEVEL_DIRECTORY_FORM)
2515 _pOptionMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2519 if (_bIsDirectoryEmpty == false)
2521 if (CheckSearchHistory() == false)
2523 _pOptionMenu->AddItem(search, IDA_CONTEXT_MENU_BTN_SEARCH, *pBitmapSearchContextItem, null, null);
2526 _pOptionMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2527 _pOptionMenu->AddItem(sortBy, IDA_CONTEXT_MENU_BTN_SORT_BY, *pBitmapSortbyContextItem, null, null);
2529 if (extensionVisibility == hideExtensionKeyValue)
2531 _pOptionMenu->AddItem(_showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
2535 _pOptionMenu->AddItem(_hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
2539 if (SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2541 _pOptionMenu->AddItem(buttonCreateFolder, IDA_CONTEXT_MENU_CREATE_FOLDER, *pBitmapCreateFolderContextItem, null, null);
2545 _pOptionMenu->AddActionEventListener(*this);
2547 delete pBitmapSortbyContextItem;
2548 delete pBitmapSearchContextItem;
2549 delete pBitmapCreateFolderContextItem;