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: MfTopMostFolderFileListForm.cpp
19 * @brief: This file contains the implementation of TopMostFolderFileListForm class, which acts as a
20 * media explorer displaying a list of all the files in the root directory
21 * and defines a set of operations that can be done with the files like edit, view etc.
24 #include "MfMyFilesApp.h"
25 #include "MfTopMostFolderFileListForm.h"
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Base::Runtime;
31 using namespace Tizen::Base::Utility;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Io;
34 using namespace Tizen::Locales;
35 using namespace Tizen::Media;
36 using namespace Tizen::System;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
41 TopMostFolderFileListForm::TopMostFolderFileListForm(void)
49 TopMostFolderFileListForm::~TopMostFolderFileListForm(void)
51 if (__pHomeButton != null)
56 if (__pUpButton != null)
63 TopMostFolderFileListForm::Initialize(void)
65 Form::Construct(L"IDL_ROOT_DIRECTORY");
69 TopMostFolderFileListForm&
70 TopMostFolderFileListForm::operator =(const TopMostFolderFileListForm& topMostFolderFileListForm)
75 TopMostFolderFileListForm::TopMostFolderFileListForm(const TopMostFolderFileListForm& topMostFolderFileListForm)
82 TopMostFolderFileListForm::OnInitializing(void)
86 int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_TOP_FOLDER_FILE_LIST_FORM;
88 _renameOrCreate = SELECT_CREATE_FOLDER;
89 CreateItemSource createitemsource = CREATE_ITEM_SOURCE_TOP_MOST_FILE_LIST;
91 //AddOrientationEventListener(*this);
92 //SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
94 AppResource* pAppResource = null;
95 Bitmap* pBitmapHomeButton = null;
96 Bitmap* pBitmapUpButton = null;
97 Bitmap* pBitmapHomeButtonPress = null;
98 Bitmap* pBitmapUpButtonPress = null;
100 Color backgroundColor(0xAE, 0x36, 0x36, 0xFF);
103 _pLabelDisplayPath = static_cast< Label* >(GetControl("IDC_LABEL_DISPLAY_PATH"));
104 TryCatch(_pLabelDisplayPath != null, , "Label is Null");
105 pAppResource = UiApp::GetInstance()->GetAppResource();
106 TryCatch(pAppResource != null, , "MfMyFilesApp::Resource manager not found!");
108 pBitmapHomeButton = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
109 pBitmapUpButton = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
110 pBitmapHomeButtonPress = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
111 pBitmapUpButtonPress = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
113 __pHeader = GetHeader();
115 if (__pHeader != null)
117 __pHomeButton = new (std::nothrow) ButtonItem();
118 __pHomeButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_HOME);
119 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapHomeButton);
120 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapHomeButtonPress);
122 __pUpButton = new (std::nothrow) ButtonItem();
123 __pUpButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_UP);
124 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapUpButton);
125 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapUpButtonPress);
127 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pHomeButton);
128 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pUpButton);
129 __pHeader->AddActionEventListener(*this);
132 displayPath = defaultPhoneBody;
133 displayPath.Append("/");
134 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
135 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
136 _extensionKeyName.Append(L"ExtensionVisibility");
137 // Setup back event listener
138 SetFormBackEventListener(this);
140 //Call the InitializeAppRegistry() method to define the keys used throughout the application.
141 InitializeAppRegistry();
143 //Create a new instance of the pointer for FileListPresentation Model.
144 if (_pFolderEntryPM == null)
146 _pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
147 AppAssert(_pFolderEntryPM != null);
148 r = _pFolderEntryPM->Construct();
149 AppAssert(r==E_SUCCESS);
150 _pFolderEntryPM->SetSourceForm(createitemsource);
154 _pFolderEntryPM->SetFolderEntryPath(__StoragePath);
155 __ptempFilenames = _pFolderEntryPM->GetFolderEntryList();
156 if (__ptempFilenames != null && __ptempFilenames->GetCount() > 1)
159 pTabList = new (std::nothrow) ArrayList();
160 if (pTabList != null)
162 pTabList->Add(new String("Memory Card"));
163 r = CreateHeaderControls(pTabList);
168 r = CreateHeaderControls();
172 _pFileManager = FolderEntryEditorPresentationModel::GetInstance();
173 TryCatch(_pFileManager != null, , "MfMyFilesApp::File Manager not found!");
175 path = BasePresentationModel::GetMediaPath();
178 __rootMediaPath = path;
179 FolderNavigationPresentationModel::SetCurrentFilePath(path);
182 // _pFolderEntryPM->SetFolderEntryPath(__rootMediaPath);
183 // _pFilenames = _pFolderEntryPM->GetFolderEntryList();
184 // TryCatch(_pFilenames != null, , "MfMyFilesApp::Failed to allocate Memory to Filenames ArrayList");
186 // AppLogDebug("Filenames Count %d", _pFilenames->GetCount());
188 _pBaseItemProvider = new (std::nothrow) BaseItemProvider();
189 TryCatch(_pBaseItemProvider != null, , "Failed to allocate base itemprovider");
190 _pBaseItemProvider->Construct();
191 _pBaseItemProvider->SetSourceForm(createitemsource);
192 _pBaseItemProvider->SetFolderEntryProvider(this);
193 _pBaseItemProvider->SetFooterItemStateChangeListener(this);
195 _pListView = static_cast< ListView* >(GetControl("IDC_LISTVIEW_ROOT_DIRECTORY"));
196 if (_pListView != null)
198 _pListView->AddListViewItemEventListener(*this);
199 //__pListView->SetItemProvider(*this);
200 _pListView->SetItemProvider(*_pBaseItemProvider);
201 _pListView->SetShowState(true);
202 _pListView->SetBounds(0, H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, GetClientAreaBounds().height - H_DISPLAY_PATH_LABEL);
205 //Initialize the itemprovider class for the listview inside the popup
206 if (_pCustomListViewForPopup == null)
208 _pCustomListViewForPopup = new (std::nothrow) CustomListViewForPopup();
210 TryCatch(_pCustomListViewForPopup != null, , "MfMyFilesApp::ListView For Popup not created!");
212 _pCustomListViewForPopup->SetEventListener(this);
214 _pFooter = GetFooter();
215 _pThumbnailItemProvider = new (std::nothrow) ThumbnailItemProviderAndListener(path, sourceForm);
216 //__pThumbnailItemProviderAndListener->Construct(__pContentManager);
217 TryCatch(_pThumbnailItemProvider != null, , "Failed to allocate Memory to __pThumbnailItemProviderAndListener");
218 _pThumbnailItemProvider->SetFolderEntryProvider(this);
219 _pThumbnailItemProvider->SetFooterItemStateChangeListener(this);
221 _pIconListView = static_cast< IconListView* >(GetControl("IDC_ICONLISTVIEW_ROOT_THUMBNAILS"));
222 if (_pIconListView != null)
224 _pIconListView->AddIconListViewItemEventListener(*_pThumbnailItemProvider);
225 _pIconListView->SetItemProvider(*_pThumbnailItemProvider);
226 _pIconListView->SetBounds(0, H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, GetClientAreaBounds().height - H_DISPLAY_PATH_LABEL);
227 _pIconListView->SetShowState(false);
228 // _pIconListView->AddGestureDetector(*gestureDetector);
231 delete pBitmapHomeButton;
232 delete pBitmapUpButton;
233 delete pBitmapHomeButtonPress;
234 delete pBitmapUpButtonPress;
235 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
239 if (_pFolderEntryPM != null)
241 delete _pFolderEntryPM;
242 _pFolderEntryPM = null;
245 if (_pThumbnailItemProvider != null)
247 delete _pThumbnailItemProvider;
248 _pThumbnailItemProvider = null;
251 if (__pHomeButton != null)
253 delete __pHomeButton;
254 __pHomeButton = null;
257 if (__pUpButton != null)
262 if (pBitmapHomeButton != null)
264 delete pBitmapHomeButton;
265 pBitmapHomeButton = null;
268 if (pBitmapUpButton != null)
270 delete pBitmapUpButton;
271 pBitmapUpButton = null;
273 if (pBitmapHomeButtonPress != null)
275 delete pBitmapHomeButtonPress;
276 pBitmapHomeButtonPress = null;
278 if (pBitmapUpButtonPress != null)
280 delete pBitmapUpButtonPress;
281 pBitmapUpButtonPress = null;
287 TopMostFolderFileListForm::OnTerminating(void)
289 AppLogDebug("ENTER");
290 result r = E_SUCCESS;
292 _pFooter = GetFooter();
293 if (_pFooter != null)
295 _pFooter->RemoveAllButtons();
296 _pFooter->RemoveAllItems();
298 __pHeader = GetHeader();
299 if (__pHeader != null)
301 __pHeader->RemoveAllButtons();
302 __pHeader->RemoveAllItems();
308 TopMostFolderFileListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
310 SceneManager* pSceneManager = SceneManager::GetInstance();
312 SceneManager* pSceneManager = SceneManager::GetInstance();
316 if (CheckSearchHistory() == true)
319 /*searchPath = FolderNavigationPresentationModel::GetSearchPreviousPath();
321 FolderNavigationPresentationModel::SetCurrentFilePath(searchPath);
322 if (SceneManager::GetInstance()->IsSceneAlive(__previousSceneName))
324 pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneName, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_KEEP), null);
328 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
331 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
335 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
340 TopMostFolderFileListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
341 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
343 AppLogDebug("ENTER");
344 result r = E_SUCCESS;
346 String viewStyleKeyName(L"ListDisplayType");
347 AppResource* pAppResource = null;
348 AppRegistry* pAppRegistry = null;
350 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
351 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
353 TryReturn (_pFolderEntryPM !=null, , "FolderEntryPresentation Model is NULL");
355 _pFileManager->SetFileManagingListener(this);
357 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
359 if (_renameOrCreate == SELECT_RENAME)
365 int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
367 pAppResource = UiApp::GetInstance()->GetAppResource();
368 TryCatch(pAppResource != null, , "MfMyFilesApp::Resource manager not found!");
370 //Call the CreateFooterControls() to personalize the footerItems.
371 r = CreateFooterControls();
372 TryCatch(r == E_SUCCESS, , "Failed to create footer controls");
374 //SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
376 //Get the current path from the Folder Navigation Model.
377 __rootMediaPath.Clear();
378 __rootMediaPath.Append(FolderNavigationPresentationModel::GetCurrentPath());
380 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
382 r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
383 TryCatch(r == E_SUCCESS, , "Failed To Get Value From AppRegistry");
384 _flagViewAsStatus = listViewDisplayType;
386 if (_pMoreContextMenu != null)
388 _pMoreContextMenu->SetShowState(false);
391 //Fill the ArrayList with the folder entries present at RootMediaPath.
392 _pFolderEntryPM->SetFolderEntryPath(__rootMediaPath);
394 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
395 TryCatch(_pFilenames != null, , "Failed to allocate Memory to Filenames ArrayList");
397 if (_pFilenames->GetCount() == 0)
399 SetFooterVisibility(DISABLE_FOOTER_ITEM);
403 SetFooterVisibility(ENABLE_FOOTER_ITEM);
405 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
409 pArgs->RemoveAll(false);
417 pArgs->RemoveAll(false);
424 TopMostFolderFileListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
425 const Tizen::Ui::Scenes::SceneId& nextSceneId)
427 DeviceManager::RemoveAllDeviceEventListeners();
428 ((MyFilesApp*)Application::GetInstance())->SetCurrentView(null);
429 TryReturn (_pFolderEntryPM !=null, , "FolderEntryPresentation Model is NULL");
430 _pFolderEntryPM->StopThumbnailManager(true);
431 _pFolderEntryPM->SetCurrentReqId(0);
433 if(_pFileEventManager != null)
434 _pFileEventManager->RemovePath(__rootMediaPath);*/
438 TopMostFolderFileListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
440 String rootMediaPath;
443 DirectoryEntry* pDirStr = null;
445 TryReturn (_pFolderEntryPM !=null, , "FolderEntryPresentation Model is NULL");
447 if (_pFilenames != null)
449 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
452 rootMediaPath = pDirStr->GetFullFilePath();
454 if (pDirStr->IsDirectory())
456 //If the current filepath is a directory then load the SubDirectoryForm
457 filePath.Append(__rootMediaPath);
458 filePath.Append(pDirStr->GetFileName());
459 filePath.Append(L"/");
462 fileName.Append(pDirStr->GetFileName());
464 _currentFileName.Clear();
465 _currentFileName = pDirStr->GetFileName();
467 FolderNavigationPresentationModel::SetCurrentFilePath(filePath);
468 //_pFileListPM->SetFileEventListener(null);
469 LoadSubDirectoryForm(filePath, fileName);
473 _pathOfSelectedFile = rootMediaPath;
474 //Else launch the corresponding AppControl.
475 if (_pathOfSelectedFile.EndsWith(L".tpk"))
477 String* pFileUriScheme = new (std::nothrow) String(L"file://");
478 pFileUriScheme->Append(_pathOfSelectedFile);
479 AppControl* pAc = null;
480 pAc = AppManager::FindAppControlN(L"D7eOJquGtL.Installer", L"http://tizen.org/appcontrol/operation/install");
483 pAc->Start(pFileUriScheme, null, null, null);
485 delete pFileUriScheme;
489 CustomAppControl* pCustomAppControl = CustomAppControl::GetInstance();
490 if (pCustomAppControl != null)
494 pCustomAppControl->SetAppControlListener(null);
495 AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(_pathOfSelectedFile);
496 if (pAppControlInUse != null)
497 CustomAppControl::SetAppControlInUse(pAppControlInUse);
508 TopMostFolderFileListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
510 result r = E_SUCCESS;
514 String displayMediaPath;
515 String displayStoragePath;
516 String displayUsbPath;
517 String extensionStatus;
522 AppResource* pAppResource = AppResource::GetInstance();
523 Header* pHeader = null;
524 SceneManager* pSceneManager = null;
525 pSceneManager = SceneManager::GetInstance();
527 TryReturn (_pFolderEntryPM !=null, , "FolderEntryPresentation Model is NULL");
529 if (pAppResource != null)
531 displayMediaPath = defaultPhoneBody;
532 displayMediaPath.Append("/");
534 displayStoragePath = defaultSdCardBody;
535 displayStoragePath.Append("/");
537 displayUsbPath = defaultExternalStorageBody;
538 displayUsbPath.Append("/");
540 pAppResource->GetString(L"IDS_MF_TAB_PHONE", tabPhone);
541 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", tabSDCard);
542 pAppResource->GetString(L"IDS_COM_BODY_USB", tabUsb);
546 mediaPath = BasePresentationModel::GetMediaPath();
547 storagePath = BasePresentationModel::GetSdCardPath();
548 usbPath = BasePresentationModel::GetUsbPath();
549 AppLogDebug("SD Card Path is %ls", storagePath.GetPointer());
551 pHeader = GetHeader();
555 case IDA_CONTEXT_MENU_HIDE_EXTENSION:
561 case IDA_CONTEXT_MENU_SHOW_EXTENSION:
569 //Navigate to the TopFolderFileListForm.
571 homeRootPath.Append(__rootMediaPath);
573 while ((homeRootPath != BasePresentationModel::GetMediaPath()) && (homeRootPath != BasePresentationModel::GetSdCardPath()))
575 FolderNavigationPresentationModel::SetCurrentFilePath(homeRootPath);
576 homeRootPath.Clear();
577 homeRootPath = FolderNavigationPresentationModel::GetParentPath();
580 FolderNavigationPresentationModel::SetCurrentFilePath(homeRootPath);
582 if (CheckSearchHistory())
584 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
585 //TryCatch(r == E_SUCCESS, , "scene transition failed");
589 r = pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
590 //TryCatch(r == E_SUCCESS, , "scene transition failed");
603 UiApp* pApp = UiApp::GetInstance();
611 case IDA_TABBAR_ITEM_PHONE:
614 bool enableUpdate = false;
615 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
617 if (currentPath.CompareTo(mediaPath) != 0)
626 pHeader->SetItemSelected(0);
629 //_tabSelected = tabPhone;
630 //__storageType = MEMORY_TYPE_PHONE;
633 _pFolderEntryPM->SetFolderEntryPath(mediaPath);
634 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
636 __rootMediaPath.Clear();
637 __rootMediaPath.Append(mediaPath);
639 if (_pListView != null && _pListView->IsVisible())
641 _pListView->UpdateList();
642 _pListView->ScrollToItem(0);
646 if (_pIconListView != null && _pIconListView->IsVisible())
648 _pIconListView->UpdateList();
649 _pIconListView->ScrollToItem(0);
652 FolderNavigationPresentationModel::SetCurrentFilePath(mediaPath);
653 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
655 if (_pFilenames != null && _pFilenames->GetCount() == 0)
657 SetFooterVisibility(DISABLE_FOOTER_ITEM);
661 SetFooterVisibility(ENABLE_FOOTER_ITEM);
665 if (_pFolderEntryPM != null)
667 _pFolderEntryPM->InitThumbnailManager();
672 case IDA_TABBAR_ITEM_SD_CARD:
675 bool enableUpdate = false;
676 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
678 if (currentPath.CompareTo(storagePath) != 0)
687 pHeader->SetItemSelected(1);
690 //_tabSelected = tabSDCard;
692 __rootMediaPath.Clear();
693 __rootMediaPath.Append(storagePath);
695 _pFolderEntryPM->SetFolderEntryPath(storagePath);
696 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
698 if (_pFilenames->GetCount() == 0)
700 SetFooterVisibility(DISABLE_FOOTER_ITEM);
704 SetFooterVisibility(ENABLE_FOOTER_ITEM);
706 if (_pListView != null && _pListView->IsVisible())
708 _pListView->ScrollToItem(0);
709 _pListView->UpdateList();
712 if (_pIconListView != null && _pIconListView->IsVisible())
714 _pIconListView->ScrollToItem(0);
715 _pIconListView->UpdateList();
719 FolderNavigationPresentationModel::SetCurrentFilePath(storagePath);
720 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
723 if (_pFolderEntryPM != null)
725 _pFolderEntryPM->InitThumbnailManager();
730 case IDA_TABBAR_ITEM_USB:
733 bool enableUpdate = false;
734 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
736 if (currentPath.CompareTo(usbPath) != 0)
743 //_tabSelected = tabUsb;
747 pHeader->SetItemSelected(2);
750 __rootMediaPath.Clear();
751 __rootMediaPath.Append(usbPath);
753 _pFolderEntryPM->SetFolderEntryPath(usbPath);
754 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
756 if (_pListView != null && _pListView->IsVisible())
758 _pListView->ScrollToItem(0);
759 _pListView->UpdateList();
762 if (_pIconListView != null && _pIconListView->IsVisible())
764 _pIconListView->ScrollToItem(0);
765 _pIconListView->UpdateList();
768 if (_pFilenames->GetCount() == 0)
770 SetFooterVisibility(DISABLE_FOOTER_ITEM);
774 SetFooterVisibility(ENABLE_FOOTER_ITEM);
777 FolderNavigationPresentationModel::SetCurrentFilePath(usbPath);
778 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_EXTERNAL);
786 SubBaseOnActionPerformed(source, actionId);
793 TopMostFolderFileListForm::LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName)
795 result r = E_SUCCESS;
796 ArrayList* pArg = null;
797 SceneManager* pSceneManager = null;
799 pArg = new (std::nothrow) ArrayList();
802 pArg->Add(&fileName);
803 TryCatch(r == E_SUCCESS, , "Failed to Add Arguments to ArrayList");
805 pSceneManager = SceneManager::GetInstance();
806 TryCatch(pSceneManager != null, , "Failed to get SceneManager Instance");
808 //pSceneManager->GoForward(SCENE_SUB_DIRECTORY_FORM,pArg, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
809 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
825 TopMostFolderFileListForm::InitializeAppRegistry(void)
827 AppLogDebug("ENTER");
828 // 3 keys: ViewStyle, SortBy, Show/Hide File Extension
829 result r = E_SUCCESS;
831 AppRegistry* pAppRegistry = null;
832 String viewStyleKeyName(L"ListDisplayType");
833 ViewType viewStyle = VIEW_TYPE_AS_NORMAL_LIST;
835 String sortbyKeyName(L"SortBy");
836 SortByType sortStyle = SORT_BY_TYPE_DATE_RECENT;
838 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
840 r = pAppRegistry->Add(viewStyleKeyName, viewStyle);
843 r = pAppRegistry->Save();
846 r = pAppRegistry->Add(_extensionKeyName, _hideExtension);
849 r = pAppRegistry->Save();
852 r = pAppRegistry->Add(sortbyKeyName, sortStyle);
855 r = pAppRegistry->Save();
858 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
862 TopMostFolderFileListForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
864 AppLogDebug("ENTER");
865 Integer* pFileProcessingResult = null;
867 TryCatch(pArgs != null, , "Argument list received is invalid!");
868 pFileProcessingResult = (Integer*) pArgs->GetAt(0);
870 TryCatch(pFileProcessingResult != null, , "FileProcessing Result list is invalid!");
872 switch (pFileProcessingResult->ToInt())
874 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
876 AppLogDebug("FILE_PROCESSING_RESULT_DELETING_SUCCESS");
877 if (_pFilenames != null)
879 _pFilenames->RemoveAt(_indexTracker, true);
880 //r = __pListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_REMOVE);
881 _pListView->UpdateList();
883 if (_pIconListView != null && _pIconListView->IsVisible())
885 _pIconListView->UpdateList();
888 HideFileProgressingPopup();
892 case FILE_MANAGING_RESULT_DELETING_FAILED:
894 HideFileProgressingPopup();
897 case FILE_MANAGING_RESULT_THREAD_STOP:
899 HideFileProgressingPopup();
913 pArgs->RemoveAll(true);
919 TopMostFolderFileListForm::OnFileEventExecuted(const Tizen::Base::String& path, const unsigned long eventId)
921 AppLogDebug("ENTER");
924 // Tizen::Shell::NotificationManager* pNotiMgr = null;
925 TryReturn (_pFolderEntryPM !=null, , "FolderEntryPresentation Model is NULL");
927 NotificationManager* pNotiMgr = null;
928 AppResource* pAppResource = null;
929 pAppResource = UiApp::GetInstance()->GetAppResource();
930 TryCatch(pAppResource != null, , "Failed to fetch AppResource");
932 pNotiMgr = new (std::nothrow) NotificationManager();
933 TryCatch(pNotiMgr != null, , "Failed to fetch AppNotificationManager");
935 pNotiMgr->Construct();
936 badgeNumber = pNotiMgr->GetBadgeNumber();
940 //_pFolderEntryPM->SetFileEventListener(null);
944 case FILE_EVENT_TYPE_CREATE:
946 if (_pListView != null && _pListView->IsVisible())
948 _pListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
950 if (_pIconListView != null && _pIconListView->IsVisible())
952 _pIconListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
957 case FILE_EVENT_TYPE_DELETE:
959 if (_pListView != null && _pListView->IsVisible())
961 _pListView->RefreshList(__counter, LIST_REFRESH_TYPE_ITEM_REMOVE);
963 if (_pIconListView != null && _pIconListView->IsVisible())
965 if (_pThumbnailItemProvider != null)
967 __counter = _pThumbnailItemProvider->GetPressedIndex();
969 _pIconListView->RefreshList(__counter, LIST_REFRESH_TYPE_ITEM_REMOVE);
976 //Empty Implementation.
981 if (pNotiMgr != null)
989 // if (pNotiMgr != null)
998 TopMostFolderFileListForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,
999 const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1001 AppLogDebug("Enter");
1002 AppLogDebug("_rename index %d",_renameIndex);
1003 AppRegistry* pAppRegistry = null;
1004 String sortbyKeyName(L"SortBy");
1005 int sortStyle = SORT_BY_TYPE_DATE_RECENT;
1007 TryReturn (_pFolderEntryPM !=null, , "FolderEntryPresentation Model is NULL");
1009 if (_pFileEventManager != null)
1011 delete _pFileEventManager;
1012 _pFileEventManager = null;
1016 /*_pFileEventManager = new FileEventManager();
1017 _pFileEventManager->Construct(*this);
1019 _pFileEventManager->AddPath(__rootMediaPath, FILE_EVENT_TYPE_MODIFY | FILE_EVENT_TYPE_DELETE );*/
1022 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1023 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1025 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
1027 if (_renameOrCreate == SELECT_RENAME)
1029 pAppRegistry->Get(sortbyKeyName, sortStyle);
1031 if (sortStyle == SORT_BY_TYPE_NAME_ASCENDING || sortStyle == SORT_BY_TYPE_NAME_DESCENDING
1032 || sortStyle == SORT_BY_TYPE_DATE_OLDEST || sortStyle == SORT_BY_TYPE_DATE_RECENT)
1034 _pFolderEntryPM->SetFolderEntryPath(FolderNavigationPresentationModel::GetCurrentPath());
1035 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1037 if (_pListView != null && _pListView->IsVisible())
1039 _pListView->UpdateList();
1040 _pListView->ScrollToItem(0);
1042 _pFolderEntryPM->InitThumbnailManager();
1046 _pListView->RefreshList(_renameIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1048 //_pFolderEntryPM->InitThumbnailManager();
1052 if (CheckSearchHistory())
1054 __previousSceneName = previousSceneId;
1058 _pFolderEntryPM->InitThumbnailManager();
1062 TopMostFolderFileListForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId,
1063 const Tizen::Ui::Scenes::SceneId &nextSceneId)
1065 //Empty Implementation.
1069 TopMostFolderFileListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1071 switch (orientationStatus)
1073 case ORIENTATION_STATUS_LANDSCAPE:
1075 SceneManager* pSceneManager = null;
1076 pSceneManager = SceneManager::GetInstance();
1077 if (pSceneManager != null)
1079 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), null);
1089 TopMostFolderFileListForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1091 AppLogDebug("TopMostFolderFileListForm::OnFileEventOccured");
1092 if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE))
1094 _pFolderEntryPM->RefreshFolderEntries();
1096 if (_pListView != null && _pListView->IsVisible())
1098 _pListView->UpdateList();
1101 if (_pIconListView != null && _pIconListView->IsVisible())
1103 _pIconListView->UpdateList();
1105 _pFolderEntryPM->InitThumbnailManager();