2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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: MfSubFolderFileListForm.cpp
19 * @brief: This file contains the implementation of SubFolderFileListForm class, which acts as a media explorer displaying a list of all the files in the sub directories of the root directory opt/Media/
20 * and defines a set of operations that can be done with the files like edit, view etc.
23 #include "MfSubFolderFileListForm.h"
24 #include "MfSearchForm.h"
26 using namespace Tizen::App;
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 SubFolderFileListForm::SubFolderFileListForm(void)
48 SubFolderFileListForm::~SubFolderFileListForm(void)
50 DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD,*this);
51 if (__pHomeButton != null)
56 if (__pUpButton != null)
62 SubFolderFileListForm&
63 SubFolderFileListForm::operator =(const SubFolderFileListForm& pSubFolderFileListForm)
68 SubFolderFileListForm::SubFolderFileListForm(const SubFolderFileListForm& pSubFolderFileListForm)
70 __pHomeButton = pSubFolderFileListForm.__pHomeButton;
71 __pUpButton = pSubFolderFileListForm.__pUpButton;
72 __pHeader = pSubFolderFileListForm.__pHeader;
73 _pLabelDisplayPath = pSubFolderFileListForm._pLabelDisplayPath;
77 SubFolderFileListForm::Initialize(void)
79 Form::Construct(L"IDL_SUB_DIRECTORY");
84 SubFolderFileListForm::OnInitializing(void)
86 AppLogDebug("SubFolderFileListForm::Initializing");
89 int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SUB_FOLDER_FILE_LIST_FORM;
90 CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST;
93 String ThumbnailProviderPath;
94 String rootParentPath;
98 String extensionVisibility;
100 SceneId currentSceneId;
101 AppResource* pAppResource = null;
102 Bitmap* pBitmapHomeButton = null;
103 Bitmap* pBitmapUpButton = null;
104 Bitmap* pBitmapHomeButtonPress = null;
105 Bitmap* pBitmapUpButtonPress = null;
107 //AddOrientationEventListener(*this);
108 //SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
110 String SubDirectorySceneOne(L"ScnSubDirectoryForm"), SubDirecorySceneTwo(L"ScnSubDirectoryForm1");
113 _renameOrCreate = SELECT_CREATE_FOLDER;
117 DataBindingContext* pContext = null;
118 Bitmap* pHomeBitmap = null;
119 Bitmap* pUpBitmap = null;
122 Color formBgColor = GetBackgroundColor();
124 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
126 pAppResource = UiApp::App::GetInstance()->GetAppResource();
127 TryCatch(pAppResource != null, , "Resource manager not found!");
129 //Set FormBackEvent Listener
130 SetFormBackEventListener(this);
132 //Set Orientation Event Listener
133 // AddOrientationEventListener(*this);
134 // SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
136 //Get the label control from IDL_SUB_DIRECTORY
137 _pLabelDisplayPath = static_cast< Label* >(GetControl("IDC_LABEL_DISPLAY_PATH"));
138 TryCatch(_pLabelDisplayPath != null, , "Label is Null");
139 _pLabelDisplayPath->SetBounds(0, 0, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL);
141 //pAppResource->GetString(L"IDS_MF_BUTTON_HOME", buttonHome);
142 //pAppResource->GetString(L"IDS_MF_TAB_UP", buttonUp);
143 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
144 pAppResource->GetString(L"IDS_MF_TAB_PHONE", displayPath);
145 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
146 pBitmapHomeButton = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
147 pBitmapUpButton = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
148 pBitmapHomeButtonPress = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
149 pBitmapUpButtonPress = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
150 extensionVisibility = fileExtenstionKeyName;
151 displayPath.Append("/");
153 __pHeader = GetHeader();
155 if (__pHeader != null)
157 __pHomeButton = new (std::nothrow) ButtonItem();
158 __pHomeButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_HOME);
159 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapHomeButton);
160 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapHomeButtonPress);
162 __pUpButton = new (std::nothrow) ButtonItem();
163 __pUpButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_UP);
164 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapUpButton);
165 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapUpButtonPress);
167 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pHomeButton);
168 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pUpButton);
169 __pHeader->AddActionEventListener(*this);
170 __pHeader->Invalidate(true);
173 _extensionKeyName.Append(extensionVisibility);
175 //Pointer for FileListPresentationModel object
176 _pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
177 TryCatch(_pFolderEntryPM != null, , "Content Manager not found!");
178 _pFolderEntryPM->Construct();
180 currentSceneId = SceneManager::GetInstance()->GetCurrentSceneId();
181 AppLogDebug("Current Scene Id : %S", currentSceneId.GetPointer());
183 createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST;
185 _pFolderEntryPM->SetSourceForm(createitemsource);
187 _pFileManager = FolderEntryEditorPresentationModel::GetInstance();
188 TryCatch(_pFileManager != null, , "File Manager not found!");
190 //String that contains the path of the file to be displayed on the ListView
191 _displayPath = displayPath;
193 path = BasePresentationModel::GetMediaPath();
194 __currentDirectoryPath.Append(path);
196 //Initialize the itemprovider class for the listview inside the popup
197 if (_pCustomListViewForPopup == null)
199 _pCustomListViewForPopup = new (std::nothrow) CustomListViewForPopup();
201 TryCatch(_pCustomListViewForPopup != null, , "MfMyFilesApp::ListView For Popup not created!");
203 _pCustomListViewForPopup->SetEventListener(this);
205 _pBaseItemProvider = new (std::nothrow) BaseItemProvider();
206 TryCatch(_pBaseItemProvider != null, , "Failed to allocate base itemprovider");
207 _pBaseItemProvider->Construct();
208 _pBaseItemProvider->SetSourceForm(createitemsource);
209 _pBaseItemProvider->SetFolderEntryProvider(this);
210 _pBaseItemProvider->SetFooterItemStateChangeListener(this);
212 //Get the ListView Control from IDL_SUB_DIRECTORY and set the ItemProvider and Listener
213 _pListView = static_cast< ListView* >(GetControl("IDC_LISTVIEW"));
214 TryCatch(_pListView != null, , "__pListView is Null");
215 _pListView->AddListViewItemEventListener(*this);
216 _pListView->SetItemProvider(*_pBaseItemProvider);
217 _pListView->SetShowState(false);
219 _pFooter = GetFooter();
221 if (_pThumbnailItemProvider == null)
223 _pThumbnailItemProvider = new (std::nothrow) ThumbnailItemProviderAndListener(__currentDirectoryPath, sourceForm);
224 _pThumbnailItemProvider->SetFolderEntryProvider(this);
226 TryCatch(_pThumbnailItemProvider != null, , "Failed to allocate Memory to __pSubFolderThumbnailsProvider");
228 _pThumbnailItemProvider->SetFooterItemStateChangeListener(this);
230 _pIconListView = static_cast< IconListView* >(GetControl("IDC_ICONLISTVIEW_SUB_DIRECTORY_THUMBNAILS"));
231 TryCatch(_pIconListView != null, , "__pIconListviewSubThumbnails is Null");
232 _pIconListView->AddIconListViewItemEventListener(*_pThumbnailItemProvider);
233 _pIconListView->AddTouchEventListener(*this);
234 _pIconListView->SetItemProvider(*_pThumbnailItemProvider);
235 _pIconListView->SetShowState(false);
237 _pLongPressGestureDetector = new (std::nothrow) TouchLongPressGestureDetector();
238 _pLongPressGestureDetector->Construct();
241 pContext = GetDataBindingContextN();
242 TryCatch(pContext != null, , "Failed to Fetch the DataBinding Context");
244 pContext->Bind(L"ID_DISPLAY_PATH", L"IDC_LABEL_DISPLAY_PATH", L"text", _displayPath, DATA_BINDING_DATA_TYPE_STRING, DATA_BINDING_FLOW_TWO_WAY, DATA_BINDING_TRIGGER_EXPLICIT, null, null, null);
249 delete pBitmapHomeButton;
250 delete pBitmapUpButton;
251 delete pBitmapHomeButtonPress;
252 delete pBitmapUpButtonPress;
253 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
258 if (_pCustomListViewForPopup != null)
260 delete _pCustomListViewForPopup;
261 _pCustomListViewForPopup = null;
264 if (pBitmapHomeButton != null)
266 delete pBitmapHomeButton;
267 pBitmapHomeButton = null;
270 if (pBitmapUpButton != null)
272 delete pBitmapUpButton;
273 pBitmapUpButton = null;
275 if (pBitmapHomeButtonPress != null)
277 delete pBitmapHomeButtonPress;
278 pBitmapHomeButtonPress = null;
280 if (pBitmapUpButtonPress != null)
282 delete pBitmapUpButtonPress;
283 pBitmapUpButtonPress = null;
289 SubFolderFileListForm::OnTerminating(void)
291 result r = E_SUCCESS;
292 //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);
294 _pFooter = GetFooter();
295 if (_pFooter != null)
297 _pFooter->RemoveAllButtons();
298 _pFooter->RemoveAllItems();
301 __pHeader = GetHeader();
302 if (__pHeader != null)
304 __pHeader->RemoveAllButtons();
305 __pHeader->RemoveAllItems();
312 SubFolderFileListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
314 SceneManager* pSceneManager = SceneManager::GetInstance();
315 result r = E_SUCCESS;
322 AppLogDebug("Scene History");
323 bool searchHistory = CheckSearchHistory();
324 String currentPath = FolderNavigationPresentationModel::GetCurrentPath();
327 SceneManager* pSceneManager = SceneManager::GetInstance();
329 if (CheckSearchHistory() == true)
332 parentPath = FolderNavigationPresentationModel::GetSearchPreviousPath();
333 AppLogDebug("ParentPath is %S", parentPath.GetPointer());
334 FolderNavigationPresentationModel::SetCurrentFilePath(parentPath);
335 AppLogDebug("__previousSceneName is %S", __previousSceneName.GetPointer());
337 //pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
340 if (parentPath == currentPath)
342 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
346 if (__previousSceneName == IDSCN_SUB_DIRECTORY_FORM1 || __previousSceneName == IDSCN_SUB_DIRECTORY_FORM)
348 String searchPath = FolderNavigationPresentationModel::GetCurrentPath();
350 FolderNavigationPresentationModel::SetSearchPreviousPath(searchPath);
351 if (SceneManager::GetInstance()->IsSceneAlive(__previousSceneName))
353 r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
354 AppLogDebug("result is %s", GetErrorMessage(r));
358 pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
359 AppLogDebug("result is %s", GetErrorMessage(r));
364 r = pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneName, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
365 AppLogDebug("result is %s", GetErrorMessage(r));
369 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
373 //ShowParentDirectoryView();
374 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
375 if (currentPath == BasePresentationModel::GetMediaPath() || currentPath == BasePresentationModel::GetSdCardPath())
377 FolderNavigationPresentationModel::SetCurrentFilePath(currentPath);
382 parentPath = FolderNavigationPresentationModel::GetParentPath();
384 FolderNavigationPresentationModel::SetCurrentFilePath(parentPath);
385 r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
391 SubFolderFileListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
392 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
394 AppLogDebug("OnSceneActivatedN ENTER");
396 int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
398 int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SUB_FOLDER_FILE_LIST_FORM;
399 CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST;
401 result r = E_SUCCESS;
403 String viewStyleKeyName(L"ListDisplayType");
409 String received_Filepath;
410 String* pReceived_Filename = null;
411 int receivedStorageType = null;
413 AppRegistry* pAppRegistry = null;
414 AppResource* pAppResource = null;
416 pAppResource = UiApp::GetInstance()->GetAppResource();
417 TryCatch(pAppResource != null, , "Failed to fetch AppResource");
419 //Create the FooterControls of IDL_SUB_DIRECTORY
420 r = CreateFooterControls();
421 TryCatch(r == E_SUCCESS, , "Failed to create footer controls");
423 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
425 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
427 pAppResource->GetString(L"IDS_MF_TAB_PHONE", phone);
428 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCard);
429 pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", external);
433 external.Append(L"/");
435 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
436 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
438 SetCurrentDirectoryFlag(false);
440 if (_pBaseItemProvider != null)
442 _pBaseItemProvider->SetSourceForm(createitemsource);
445 if (_pFileManager != null)
447 _pFileManager->SetFileManagingListener(this);
450 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
452 if (_renameOrCreate == SELECT_RENAME)
458 receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
460 if (_pLabelDisplayPath != null)
462 switch (receivedStorageType)
464 case MEMORY_TYPE_PHONE:
466 _displayPath = phone;
467 _storageType = MEMORY_TYPE_PHONE;
471 case MEMORY_TYPE_SD_CARD:
473 _displayPath = sdCard;
474 _storageType = MEMORY_TYPE_SD_CARD;
478 case MEMORY_TYPE_EXTERNAL:
480 _displayPath = external;
481 _storageType = MEMORY_TYPE_EXTERNAL;
493 r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
494 TryCatch(r == E_SUCCESS, , "Failed to get values from AppRegistry");
496 _flagViewAsStatus = listViewDisplayType;
498 if (_pMoreContextMenu != null)
500 _pMoreContextMenu->SetShowState(false);
506 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
512 pReceived_Filename = static_cast< String* >(pArgs->GetAt(0));
514 received_Filepath = FolderNavigationPresentationModel::GetCurrentPath();
515 receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
517 if (pReceived_Filename != null)
519 check.Append(*pReceived_Filename);
520 __pHeader = GetHeader();
522 if (__pHeader != null)
524 __pHeader->SetTitleText(check);
525 __pHeader->Invalidate(true);
529 __currentDirectoryPath.Clear();
530 __currentDirectoryPath.Append(received_Filepath);
532 //Get the Directory Entries for the received Filepath.
533 if (_pFolderEntryPM != null)
535 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);
536 _pFolderEntryPM->SetFolderEntryPath(received_Filepath);
537 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
538 TryCatch(_pFilenames != null, , "Failed to allocate Memory to __pFilenames");
542 if (_pThumbnailItemProvider != null)
544 _pThumbnailItemProvider->SetCreateItemSource(sourceForm);
545 _pThumbnailItemProvider->SetFolderEntryProvider(this);
548 SetNextDisplayPath();
549 SetHeaderTitleText(__currentDirectoryPath);
554 //Empty Arguments Received.
556 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
557 parentPath.Append(__currentDirectoryPath);
558 SetNextDisplayPath();
559 SetHeaderTitleText(__currentDirectoryPath);
561 if (_pFolderEntryPM != null)
563 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);
564 _pFolderEntryPM->SetFolderEntryPath(parentPath);
565 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
566 TryCatch(_pFilenames != null, , "Failed to allocate Memory to Filenames ArrayList");
569 if (_pThumbnailItemProvider != null)
571 _pThumbnailItemProvider->SetCreateItemSource(sourceForm);
572 _pThumbnailItemProvider->SetFolderEntryProvider(this);
576 //_pFileListPM->SetFileEventListener(this);
577 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
582 pArgs->RemoveAll(false);
590 pArgs->RemoveAll(false);
597 SubFolderFileListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
599 AppLogDebug("ENTER");
601 result r = E_SUCCESS;
602 SceneManager* pSceneManager = null;
603 pSceneManager = SceneManager::GetInstance();
609 //Navigate to the TopFolderFileListForm.
611 homeRootPath.Append(__currentDirectoryPath);
613 while ((homeRootPath != BasePresentationModel::GetMediaPath()) && (homeRootPath != BasePresentationModel::GetSdCardPath()))
615 FolderNavigationPresentationModel::SetCurrentFilePath(homeRootPath);
616 homeRootPath.Clear();
617 homeRootPath = FolderNavigationPresentationModel::GetParentPath();
620 FolderNavigationPresentationModel::SetCurrentFilePath(homeRootPath);
622 if (CheckSearchHistory())
624 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
625 //TryCatch(r == E_SUCCESS, , "scene transition failed");
629 r = pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
630 //TryCatch(r == E_SUCCESS, , "scene transition failed");
637 bool searchHistory = CheckSearchHistory();
639 //Navigate to the ParentForm.
642 __previousSceneName = SceneManager::GetInstance()->GetCurrentSceneId();
643 AppLogDebug("__previousSceneName is %S", __previousSceneName.GetPointer());
644 previousPath = FolderNavigationPresentationModel::GetCurrentPath();
645 AppLogDebug("previousPath is %S", previousPath.GetPointer());
646 FolderNavigationPresentationModel::SetSearchPreviousPath(previousPath);
648 ShowParentDirectoryView();
652 case IDA_CONTEXT_MENU_HIDE_EXTENSION:
654 __currentDirectoryPath.Clear();
655 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
661 case IDA_CONTEXT_MENU_SHOW_EXTENSION:
663 __currentDirectoryPath.Clear();
664 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
672 SubBaseOnActionPerformed(source, actionId);
676 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
680 SubFolderFileListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
681 const Tizen::Ui::Scenes::SceneId& nextSceneId)
683 ((MyFilesApp*)Application::GetInstance())->SetCurrentView(null);
685 DeviceManager::RemoveAllDeviceEventListeners();
687 if (_pIconListView != null)
689 _pIconListView->RemoveGestureDetector(*_pLongPressGestureDetector);
692 TryReturn(_pFolderEntryPM!=null, , "FolderEntryPresentationModel is NULL") ;
693 _pFolderEntryPM->StopThumbnailManager(true);
694 _pFolderEntryPM->SetCurrentReqId(0);
696 if(_pFileEventManager != null)
698 _pFileEventManager->RemovePath(__currentDirectoryPath);
704 SubFolderFileListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
706 //When state is changed, push the parent filepath to the stack and save the selected path as
707 //root path so that listview can be refreshed to this path the next time. If Up button is click in
708 //the mean time, refresh the root path to be pushed to the parent path (changed in ShowParentView())
710 AppLogDebug("ENTER");
712 String tempRootMediaPath;
713 String filePathToPush;
715 bool searchHistory = false;
716 //result r = E_FAILURE;
717 DirectoryEntry* pDirStr = null;
719 ArrayList* pArgs = new (std::nothrow) ArrayList();
723 SceneManager* pSceneManager = SceneManager::GetInstance();
724 SceneId currentSceneId = pSceneManager->GetCurrentSceneId();
726 if (_pFilenames != null)
728 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
731 //temprootmediapath gives the full file path of the selected item
732 tempRootMediaPath = pDirStr->GetFullFilePath();
734 if (pDirStr->IsDirectory())
736 //Append the name of the file to the existing path
737 nextFilename = pDirStr->GetFileName();
738 _currentFileName.Clear();
739 _currentFileName = pDirStr->GetFileName();
741 //tempRootMediaPath.Append(L"/");
742 //Set the full file path as future parent filepath, changed when Up button is
744 if (__currentDirectoryPath != null)
746 __currentDirectoryPath.Clear();
747 //__currentDirectoryPath.Append(tempRootMediaPath);
748 __currentDirectoryPath = pDirStr->GetFullFilePath();
750 FolderNavigationPresentationModel::SetCurrentFilePath(__currentDirectoryPath);
752 pArgs->Add(&nextFilename);
754 searchHistory = CheckSearchHistory();
757 searchPath = FolderNavigationPresentationModel::GetParentPath();
758 FolderNavigationPresentationModel::SetSearchPreviousPath(searchPath);
761 pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
765 _indexTracker = index; //For OnFileEventOccured (RemoveCacheEntry)
766 _pathOfSelectedFile = tempRootMediaPath;
767 //It's not a directory, Launch the AppControl.
768 if (_pathOfSelectedFile.EndsWith(L".tpk") || _pathOfSelectedFile.EndsWith(L".wgt"))
770 String* pFileUriScheme = new (std::nothrow) String(L"file://");
771 pFileUriScheme->Append(_pathOfSelectedFile);
773 AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/view", pFileUriScheme, null, null, null, null);
774 delete pFileUriScheme;
778 CustomAppControl* pCustomAppControl = CustomAppControl::GetInstance();
779 if (pCustomAppControl != null)
783 pCustomAppControl->SetAppControlListener(null);
784 fileForAppControl = _pathOfSelectedFile;
785 AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(_pathOfSelectedFile);
786 if (pAppControlInUse != null)
787 CustomAppControl::SetAppControlInUse(pAppControlInUse);
799 SubFolderFileListForm::ShowHomeView(void)
801 AppLogDebug("Enter");
802 SceneManager* pSceneManager = null;
803 result r = E_SUCCESS;
804 pSceneManager = SceneManager::GetInstance();
805 if (pSceneManager != null)
807 if (CheckSearchHistory())
809 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
810 TryCatch(r == E_SUCCESS, , "scene transition failed");
814 r = pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
815 TryCatch(r == E_SUCCESS, , "scene transition failed");
819 if (_pFolderEntryPM != null)
821 _pFolderEntryPM->InitThumbnailManager();
831 SubFolderFileListForm::SetParentDisplayPath(void)
833 //Sets the display path for the parent directory using the current path.
837 String parentDisplayPath;
840 DataBindingContext* pContext = null;
841 pContext = GetDataBindingContextN();
843 if (pContext != null)
845 //Update binding on the source to fetch the current display path.
846 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_SOURCE);
850 StringTokenizer tokenizer(_displayPath, delim);
852 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
853 //it is the last token
854 while (tokenizer.HasMoreTokens())
856 int tokenCount = tokenizer.GetTokenCount();
860 tokenizer.GetNextToken(token);
861 parentDisplayPath.Append(token);
862 parentDisplayPath.Append(L"/");
870 //Set the display path to that of the generated filepath from the tokenizer
871 _displayPath = parentDisplayPath;
873 if (_pLabelDisplayPath != null)
875 _pLabelDisplayPath->SetText(_displayPath);
876 _pLabelDisplayPath->Invalidate(true);
879 if (pContext != null)
881 //Update Binding on the Target control to display the currently constructed path.
882 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
885 if (pContext != null)
893 SubFolderFileListForm::ShowParentDirectoryView(void)
895 AppLogDebug("ENTER");
896 //Shows the files of the above/parent directory
897 CreateItemSource sourceForm = CREATE_ITEM_SOURCE_NONE;
901 result r = E_SUCCESS;
906 String backUpCurrentPath;
908 backUpCurrentPath = FolderNavigationPresentationModel::GetCurrentPath();
910 // if(backUpCurrentPath == BasePresentationModel::GetMediaPath() || backUpCurrentPath == BasePresentationModel::GetSdCardPath())
915 displayPath = defaultPhoneBody;
916 displayPath.Append("/");
918 SetFooterVisibility(ENABLE_FOOTER_ITEM);
920 if (backUpCurrentPath == BasePresentationModel::GetMediaPath() || backUpCurrentPath == BasePresentationModel::GetSdCardPath() || backUpCurrentPath == BasePresentationModel::GetUsbPath())
922 //It is the homeview, so call showhomeview
924 TryCatch(r == E_SUCCESS, , "scene transition failed");
929 ParentPath = FolderNavigationPresentationModel::GetParentPath();
931 //RemovePath to remove FileEventListener
932 if(_pFileEventManager != null)
934 _pFileEventManager->RemovePath(__currentDirectoryPath);
936 __currentDirectoryPath.Clear();
937 __currentDirectoryPath.Append(ParentPath);
939 //AddPath to add FileEventListener for Parent Directory Path
940 if(_pFileEventManager != null)
942 _pFileEventManager->AddPath(__currentDirectoryPath, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
945 FolderNavigationPresentationModel::SetCurrentFilePath(__currentDirectoryPath);
947 if (_pFolderEntryPM != null)
949 _pFolderEntryPM->GetFolderEntryCount(__currentDirectoryPath, folderCount, fileCount);
952 SetParentDisplayPath();
953 SetHeaderTitleText(ParentPath);
954 SetFooterVisibility(ENABLE_FOOTER_ITEM);
958 _pFooter = GetFooter();
961 _pFooter->SetItemEnabled(1, false);
962 _pFooter->Invalidate(true);
965 //Remove the current files from the filenames list
966 if (_pFolderEntryPM != null)
968 //__pContentManager->ClearList();
969 _pFolderEntryPM->SetFolderEntryPath(ParentPath);
970 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
971 TryCatch(_pFilenames != null, , "Failed to fetch ArrayList from the ContentBrowser!");
973 sourceForm = _pFolderEntryPM->GetSourceForm();
974 AppLogDebug("Current Source Form is : %d",sourceForm);
976 /*if ( sourceForm == CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST )
977 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST_TWO);
979 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);*/
981 _pFolderEntryPM->InitThumbnailManager();
985 //Get the files in the parent path of the current view
987 //Update the icon list to view the files of the parent directory
988 if (_pListView != null && _pListView->IsVisible())
990 r = _pListView->UpdateList();
993 if (_pIconListView != null && _pIconListView->IsVisible())
995 r = _pIconListView->UpdateList();
998 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1002 FolderNavigationPresentationModel::SetCurrentFilePath(backUpCurrentPath);
1007 SubFolderFileListForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
1009 Integer* pFileProcessingResult = null;
1012 TryCatch(pArgs != null, , "Argument list received is invalid!");
1013 pFileProcessingResult = (Integer*) pArgs->GetAt(0);
1015 TryCatch(pFileProcessingResult != null, , "FileProcessing Result list is invalid!");
1017 switch (pFileProcessingResult->ToInt())
1019 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1021 AppLogDebug("FILE DELETION SUCCESSFULL");
1022 HideFileProgressingPopup();
1026 case FILE_MANAGING_RESULT_DELETING_FAILED:
1028 HideFileProgressingPopup();
1031 case FILE_MANAGING_RESULT_THREAD_STOP:
1033 HideFileProgressingPopup();
1043 SetFooterVisibility(DISABLE_FOOTER_ITEM);
1047 pArgs->RemoveAll(true);
1054 SubFolderFileListForm::OnDataBindingSourceUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
1056 //Empty Implementation.
1060 SubFolderFileListForm::OnDataBindingTargetUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
1062 //Empty Implementation.
1066 SubFolderFileListForm::OnDataBindingValidationFailed(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Ui::DataBindingDestinationType destType)
1068 //Empty Implementation.
1072 SubFolderFileListForm::OnFileEventExecuted(const Tizen::Base::String& path, const unsigned long eventId)
1074 AppLogDebug("ENTER");
1076 int badgeNumber = 0;
1077 result r = E_SUCCESS;
1079 // Tizen::Shell::NotificationManager* pNotiMgr = null;
1081 NotificationManager* pNotiMgr = null;
1082 AppResource* pAppResource = null;
1083 pAppResource = UiApp::GetInstance()->GetAppResource();
1084 TryCatch(pAppResource != null, , "Failed to fetch AppResource");
1086 pNotiMgr = new (std::nothrow) NotificationManager();
1087 TryCatch(pNotiMgr != null, , "Failed to fetch AppNotificationManager");
1089 pNotiMgr->Construct();
1090 badgeNumber = pNotiMgr->GetBadgeNumber();
1093 if (_pFolderEntryPM != null)
1095 //_pFolderEntryPM->SetFileEventListener(null);
1096 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1097 TryCatch(_pFilenames != null, , "File Names List retrieval failed");
1102 case FILE_EVENT_TYPE_CREATE:
1104 if (_pListView != null && _pListView->IsVisible())
1106 _pListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
1108 if (_pIconListView != null && _pIconListView->IsVisible())
1110 _pIconListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
1116 case FILE_EVENT_TYPE_DELETE:
1118 if (_pListView != null && _pListView->IsVisible())
1120 _pListView->RefreshList(__counter, LIST_REFRESH_TYPE_ITEM_REMOVE);
1122 if (_pIconListView != null && _pIconListView->IsVisible())
1124 if (_pThumbnailItemProvider != null)
1126 __counter = _pThumbnailItemProvider->GetPressedIndex();
1128 _pIconListView->RefreshList(__counter, LIST_REFRESH_TYPE_ITEM_REMOVE);
1134 case FILE_EVENT_TYPE_DELETE_SELF:
1147 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1149 if (pNotiMgr != null)
1157 if (pNotiMgr != null)
1166 SubFolderFileListForm::SetHeaderTitleText(Tizen::Base::String& filePath)
1169 String parentFileName;
1170 String delimiter(L"/");
1171 StringTokenizer tokenizer(filePath, delimiter);
1173 AppResource* pAppResource = null;
1175 pAppResource = UiApp::App::GetInstance()->GetAppResource();
1177 if (filePath == BasePresentationModel::GetMediaPath())
1179 if (pAppResource != null)
1181 pAppResource->GetString(L"IDS_MF_TAB_PHONE", parentFileName);
1184 else if (filePath == BasePresentationModel::GetSdCardPath())
1186 if (pAppResource != null)
1188 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", parentFileName);
1193 while (tokenizer.HasMoreTokens())
1195 int tokenCount = tokenizer.GetTokenCount();
1197 if (tokenCount == 1)
1199 tokenizer.GetNextToken(parentFileName);
1203 tokenizer.GetNextToken(token);
1208 __pHeader = GetHeader();
1209 if (__pHeader != null)
1211 if (!parentFileName.IsEmpty())
1213 __pHeader->SetTitleText(parentFileName);
1214 __pHeader->Invalidate(true);
1220 SubFolderFileListForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
1222 bool setMediaPath = false;
1223 MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
1224 String unmounted = sdCardStatusUnmounted;
1225 String removed = usbDeviceStatusRemoved;
1228 SceneManager* pSceneManager = null;
1230 if (state == unmounted || state == removed)
1232 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
1233 if (state == unmounted)
1235 if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
1237 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1238 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1239 setMediaPath = true;
1243 if (state == removed)
1245 if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
1247 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1248 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1249 setMediaPath = true;
1255 pSceneManager = SceneManager::GetInstance();
1256 if (pSceneManager != null)
1258 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
1265 SubFolderFileListForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1267 ComponentType currentDeviceType;
1272 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
1278 currentDeviceType = COMPONENT_TYPE_USB;
1288 OnDeviceChange(currentDeviceType, state);
1292 SubFolderFileListForm::OnSceneTransitionCompleted (const Tizen::Ui::Scenes::SceneId &previousSceneId, const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1294 AppLogDebug("Enter");
1296 AppRegistry* pAppRegistry = null;
1297 String sortbyKeyName(L"SortBy");
1298 int sortStyle = SORT_BY_TYPE_DATE_RECENT;
1300 int folderCount = 0;
1302 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1303 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1305 _pLongPressGestureDetector->AddLongPressGestureEventListener(*this);
1306 if (_pIconListView != null)
1308 _pIconListView->AddGestureDetector(*_pLongPressGestureDetector);
1311 if (_pFileEventManager != null)
1313 delete _pFileEventManager;
1314 _pFileEventManager = null;
1317 _pFileEventManager = new (std::nothrow)FileEventManager();
1318 _pFileEventManager->Construct(*this);
1320 _pFileEventManager->AddPath(__currentDirectoryPath, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
1322 _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(),folderCount, fileCount);
1324 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
1326 if (_renameOrCreate == SELECT_RENAME)
1328 pAppRegistry->Get(sortbyKeyName, sortStyle);
1330 if (sortStyle == SORT_BY_TYPE_NAME_ASCENDING || sortStyle == SORT_BY_TYPE_NAME_DESCENDING
1331 || sortStyle == SORT_BY_TYPE_DATE_OLDEST || sortStyle == SORT_BY_TYPE_DATE_RECENT)
1333 _pFolderEntryPM->SetFolderEntryPath(FolderNavigationPresentationModel::GetCurrentPath());
1334 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1336 if (_pListView != null && _pListView->IsVisible())
1338 _pListView->UpdateList();
1339 _pListView->ScrollToItem(0);
1341 if (_pIconListView != null && _pIconListView->IsVisible())
1343 _pIconListView->UpdateList();
1344 _pIconListView->ScrollToItem(0);
1346 _pFolderEntryPM->InitThumbnailManager();
1350 if (_pListView != null && _pListView->IsVisible())
1351 _pListView->RefreshList(_renameIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1352 if (_pIconListView != null && _pIconListView->IsVisible())
1353 _pIconListView->RefreshList(_renameIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1359 if (CheckSearchHistory())
1361 __previousSceneName = previousSceneId;
1366 if (_pFilenames != null && _pFilenames->GetCount() == 0)
1368 _bIsDirectoryEmpty = true;
1370 SetFooterVisibility(DISABLE_FOOTER_ITEM);
1375 _bIsDirectoryEmpty = false;
1377 SetFooterVisibility(ENABLE_FOOTER_ITEM);
1381 _pFooter = GetFooter();
1384 _pFooter->SetItemEnabled(1, false);
1385 _pFooter->Invalidate(true);
1390 if (_pFolderEntryPM != null)
1392 _pFolderEntryPM->InitThumbnailManager();
1397 SubFolderFileListForm::OnSceneTransitionStarted (const Tizen::Ui::Scenes::SceneId ¤tSceneId, const Tizen::Ui::Scenes::SceneId &nextSceneId)
1399 //Empty Implementation.
1403 SubFolderFileListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1405 AppLogDebug("ENTER");
1406 switch (orientationStatus)
1408 case ORIENTATION_STATUS_LANDSCAPE:
1410 SceneManager* pSceneManager = null;
1411 pSceneManager = SceneManager::GetInstance();
1412 if (pSceneManager != null)
1414 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), null);
1424 SubFolderFileListForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1426 AppLogDebug("TopMostFolderFileListForm::OnFileEventOccured:%S", path.GetPointer());
1428 //Scan the directory
1430 HashMap* pCacheList = null;
1431 DirectoryEntry* pCurrentEntry = null;
1432 bool cacheKeyStatus = false;
1435 //result r = ContentManager::ScanDirectory(__currentDirectoryPath,true,null,reqId);
1436 //AppLogDebug("ContentManager::ScanDirectory:%s", GetErrorMessage(r));
1438 if ((events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))
1440 _bBackFromAppControl = true;
1441 if ( (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM))
1443 AppLogDebug("Items to delete: %d", _indexTracker);
1444 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1445 if (pCacheList != null)
1447 pCurrentEntry = static_cast<DirectoryEntry*>(_pFilenames->GetAt(_indexTracker));
1449 if (pCurrentEntry != null)
1451 cachePath = pCurrentEntry->GetFullFilePath();
1454 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1458 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1462 if (_pFolderEntryPM!=null)
1464 _pFolderEntryPM->RefreshFolderEntries();
1467 if (_pListView != null && _pListView->IsVisible())
1469 _pListView->UpdateList();
1472 if (_pIconListView != null && _pIconListView->IsVisible())
1474 _pIconListView->UpdateList();
1477 if (_pFolderEntryPM!=null && ( (events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_MOVED_TO)))
1479 _pFolderEntryPM->InitThumbnailManager();
1485 SubFolderFileListForm::OnContentScanCompleted (RequestId reqId, const Tizen::Base::String &scanPath, result r)
1487 AppLogDebug("Enter");
1488 AppLogDebug("Exit");
1491 SubFolderFileListForm::OnAppControlCompleted(void)
1493 SubBaseFolderEntryForm::OnAppControlCompleted();