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: 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(_pFileEventManager != null)
53 _pFileEventManager->RemovePath(__currentDirectoryPath);
54 delete _pFileEventManager;
55 _pFileEventManager = null;
58 if (__pHomeButton != null)
63 if (__pUpButton != null)
69 SubFolderFileListForm&
70 SubFolderFileListForm::operator =(const SubFolderFileListForm& pSubFolderFileListForm)
75 SubFolderFileListForm::SubFolderFileListForm(const SubFolderFileListForm& pSubFolderFileListForm)
77 __pHomeButton = pSubFolderFileListForm.__pHomeButton;
78 __pUpButton = pSubFolderFileListForm.__pUpButton;
79 __pHeader = pSubFolderFileListForm.__pHeader;
80 _pLabelDisplayPath = pSubFolderFileListForm._pLabelDisplayPath;
84 SubFolderFileListForm::Initialize(void)
86 Form::Construct(L"IDL_SUB_DIRECTORY");
91 SubFolderFileListForm::OnInitializing(void)
93 AppLogDebug("SubFolderFileListForm::Initializing");
96 int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SUB_FOLDER_FILE_LIST_FORM;
97 CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST;
100 String ThumbnailProviderPath;
101 String rootParentPath;
103 String extensionVisibility;
105 SceneId currentSceneId;
106 AppResource* pAppResource = null;
107 Bitmap* pBitmapHomeButton = null;
108 Bitmap* pBitmapUpButton = null;
109 Bitmap* pBitmapHomeButtonPress = null;
110 Bitmap* pBitmapUpButtonPress = null;
113 String SubDirectorySceneOne(L"ScnSubDirectoryForm"), SubDirecorySceneTwo(L"ScnSubDirectoryForm1");
116 _renameOrCreate = SELECT_CREATE_FOLDER;
120 DataBindingContext* pContext = null;
121 Bitmap* pHomeBitmap = null;
122 Bitmap* pUpBitmap = null;
125 Color formBgColor = GetBackgroundColor();
127 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
129 pAppResource = UiApp::App::GetInstance()->GetAppResource();
130 TryCatch(pAppResource != null, , "Resource manager not found!");
132 //Set FormBackEvent Listener
133 SetFormBackEventListener(this);
135 //Get the label control from IDL_SUB_DIRECTORY
136 _pLabelDisplayPath = static_cast< Label* >(GetControl("IDC_LABEL_DISPLAY_PATH"));
137 TryCatch(_pLabelDisplayPath != null, , "Label is Null");
138 _pLabelDisplayPath->SetBounds(0, 0, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL);
140 //pAppResource->GetString(L"IDS_MF_BUTTON_HOME", buttonHome);
141 //pAppResource->GetString(L"IDS_MF_TAB_UP", buttonUp);
142 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
143 pAppResource->GetString(L"IDS_MF_TAB_PHONE", displayPath);
144 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
145 pBitmapHomeButton = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
146 pBitmapUpButton = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
147 pBitmapHomeButtonPress = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
148 pBitmapUpButtonPress = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
149 extensionVisibility = fileExtenstionKeyName;
150 displayPath.Append("/");
152 __pHeader = GetHeader();
154 if (__pHeader != null)
156 __pHomeButton = new (std::nothrow) ButtonItem();
157 __pHomeButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_HOME);
158 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapHomeButton);
159 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapHomeButtonPress);
161 __pUpButton = new (std::nothrow) ButtonItem();
162 __pUpButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_UP);
163 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapUpButton);
164 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapUpButtonPress);
166 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pHomeButton);
167 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pUpButton);
168 __pHeader->AddActionEventListener(*this);
169 __pHeader->Invalidate(true);
172 _extensionKeyName.Append(extensionVisibility);
174 //Pointer for FileListPresentationModel object
175 _pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
176 TryCatch(_pFolderEntryPM != null, , "Content Manager not found!");
177 _pFolderEntryPM->Construct();
179 currentSceneId = SceneManager::GetInstance()->GetCurrentSceneId();
180 AppLogDebug("Current Scene Id : %S", currentSceneId.GetPointer());
182 createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST;
184 _pFolderEntryPM->SetSourceForm(createitemsource);
186 _pFileManager = FolderEntryEditorPresentationModel::GetInstance();
187 TryCatch(_pFileManager != null, , "File Manager not found!");
189 //String that contains the path of the file to be displayed on the ListView
190 _displayPath = displayPath;
192 path = BasePresentationModel::GetMediaPath();
193 __currentDirectoryPath.Append(path);
195 //Initialize the itemprovider class for the listview inside the popup
196 if (_pCustomListViewForPopup == null)
198 _pCustomListViewForPopup = new (std::nothrow) CustomListViewForPopup();
200 TryCatch(_pCustomListViewForPopup != null, , "MfMyFilesApp::ListView For Popup not created!");
202 _pCustomListViewForPopup->SetEventListener(this);
204 _pBaseItemProvider = new (std::nothrow) BaseItemProvider();
205 TryCatch(_pBaseItemProvider != null, , "Failed to allocate base itemprovider");
206 _pBaseItemProvider->Construct();
207 _pBaseItemProvider->SetSourceForm(createitemsource);
208 _pBaseItemProvider->SetFolderEntryProvider(this);
209 _pBaseItemProvider->SetFooterItemStateChangeListener(this);
211 //Get the ListView Control from IDL_SUB_DIRECTORY and set the ItemProvider and Listener
212 _pListView = static_cast< ListView* >(GetControl("IDC_LISTVIEW"));
213 TryCatch(_pListView != null, , "__pListView is Null");
214 _pListView->AddListViewItemEventListener(*this);
215 _pListView->SetItemProvider(*_pBaseItemProvider);
216 _pListView->SetShowState(false);
218 _pFooter = GetFooter();
220 if (_pThumbnailItemProvider == null)
222 _pThumbnailItemProvider = new (std::nothrow) ThumbnailItemProviderAndListener(__currentDirectoryPath, sourceForm);
223 _pThumbnailItemProvider->SetFolderEntryProvider(this);
225 TryCatch(_pThumbnailItemProvider != null, , "Failed to allocate Memory to __pSubFolderThumbnailsProvider");
227 _pThumbnailItemProvider->SetFooterItemStateChangeListener(this);
229 _pIconListView = static_cast< IconListView* >(GetControl("IDC_ICONLISTVIEW_SUB_DIRECTORY_THUMBNAILS"));
230 TryCatch(_pIconListView != null, , "__pIconListviewSubThumbnails is Null");
231 _pIconListView->AddIconListViewItemEventListener(*_pThumbnailItemProvider);
232 _pIconListView->AddTouchEventListener(*this);
233 _pIconListView->SetItemProvider(*_pThumbnailItemProvider);
234 _pIconListView->SetShowState(false);
236 _pLongPressGestureDetector = new (std::nothrow) TouchLongPressGestureDetector();
237 _pLongPressGestureDetector->Construct();
240 pContext = GetDataBindingContextN();
241 TryCatch(pContext != null, , "Failed to Fetch the DataBinding Context");
243 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);
248 delete pBitmapHomeButton;
249 delete pBitmapUpButton;
250 delete pBitmapHomeButtonPress;
251 delete pBitmapUpButtonPress;
252 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
257 if (_pCustomListViewForPopup != null)
259 delete _pCustomListViewForPopup;
260 _pCustomListViewForPopup = null;
263 if (pBitmapHomeButton != null)
265 delete pBitmapHomeButton;
266 pBitmapHomeButton = null;
269 if (pBitmapUpButton != null)
271 delete pBitmapUpButton;
272 pBitmapUpButton = null;
274 if (pBitmapHomeButtonPress != null)
276 delete pBitmapHomeButtonPress;
277 pBitmapHomeButtonPress = null;
279 if (pBitmapUpButtonPress != null)
281 delete pBitmapUpButtonPress;
282 pBitmapUpButtonPress = null;
288 SubFolderFileListForm::OnTerminating(void)
290 result r = E_SUCCESS;
291 //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);
293 _pFooter = GetFooter();
294 if (_pFooter != null)
296 _pFooter->RemoveAllButtons();
297 _pFooter->RemoveAllItems();
300 __pHeader = GetHeader();
301 if (__pHeader != null)
303 __pHeader->RemoveAllButtons();
304 __pHeader->RemoveAllItems();
311 SubFolderFileListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
313 SceneManager* pSceneManager = SceneManager::GetInstance();
314 result r = E_SUCCESS;
321 AppLogDebug("Scene History");
322 bool searchHistory = CheckSearchHistory();
323 String currentPath = FolderNavigationPresentationModel::GetCurrentPath();
326 SceneManager* pSceneManager = SceneManager::GetInstance();
328 if (CheckSearchHistory() == true)
331 parentPath = FolderNavigationPresentationModel::GetSearchPreviousPath();
332 AppLogDebug("ParentPath is %S", parentPath.GetPointer());
333 FolderNavigationPresentationModel::SetCurrentFilePath(parentPath);
334 AppLogDebug("__previousSceneName is %S", __previousSceneName.GetPointer());
336 //pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
339 if (parentPath == currentPath)
341 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
345 if (__previousSceneName == IDSCN_SUB_DIRECTORY_FORM1 || __previousSceneName == IDSCN_SUB_DIRECTORY_FORM)
347 String searchPath = FolderNavigationPresentationModel::GetCurrentPath();
349 FolderNavigationPresentationModel::SetSearchPreviousPath(searchPath);
350 if (SceneManager::GetInstance()->IsSceneAlive(__previousSceneName))
352 r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
353 AppLogDebug("result is %s", GetErrorMessage(r));
357 pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
358 AppLogDebug("result is %s", GetErrorMessage(r));
363 r = pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneName, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
364 AppLogDebug("result is %s", GetErrorMessage(r));
368 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
372 //ShowParentDirectoryView();
373 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
374 if (currentPath == BasePresentationModel::GetMediaPath() || currentPath == BasePresentationModel::GetSdCardPath())
376 FolderNavigationPresentationModel::SetCurrentFilePath(currentPath);
381 parentPath = FolderNavigationPresentationModel::GetParentPath();
383 FolderNavigationPresentationModel::SetCurrentFilePath(parentPath);
384 r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
390 SubFolderFileListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
391 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
393 AppLogDebug("OnSceneActivatedN ENTER");
395 int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
397 int sourceForm = THUMBNAIL_PROVIDER_SOURCEID_SUB_FOLDER_FILE_LIST_FORM;
398 CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST;
400 result r = E_SUCCESS;
402 String viewStyleKeyName(L"ListDisplayType");
408 String received_Filepath;
409 String* pReceived_Filename = null;
410 int receivedStorageType = null;
412 AppRegistry* pAppRegistry = null;
413 AppResource* pAppResource = null;
415 pAppResource = UiApp::GetInstance()->GetAppResource();
416 TryCatch(pAppResource != null, , "Failed to fetch AppResource");
418 //Create the FooterControls of IDL_SUB_DIRECTORY
419 r = CreateFooterControls();
420 TryCatch(r == E_SUCCESS, , "Failed to create footer controls");
422 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
424 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
426 pAppResource->GetString(L"IDS_MF_TAB_PHONE", phone);
427 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCard);
428 pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", external);
432 external.Append(L"/");
434 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
435 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
437 SetCurrentDirectoryFlag(false);
439 if (_pBaseItemProvider != null)
441 _pBaseItemProvider->SetSourceForm(createitemsource);
444 if (_pFileManager != null)
446 _pFileManager->SetFileManagingListener(this);
449 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
451 if (_renameOrCreate == SELECT_RENAME)
457 receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
459 if (_pLabelDisplayPath != null)
461 switch (receivedStorageType)
463 case MEMORY_TYPE_PHONE:
465 _displayPath = phone;
466 _storageType = MEMORY_TYPE_PHONE;
470 case MEMORY_TYPE_SD_CARD:
472 _displayPath = sdCard;
473 _storageType = MEMORY_TYPE_SD_CARD;
477 case MEMORY_TYPE_EXTERNAL:
479 _displayPath = external;
480 _storageType = MEMORY_TYPE_EXTERNAL;
492 r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
493 TryCatch(r == E_SUCCESS, , "Failed to get values from AppRegistry");
495 _flagViewAsStatus = listViewDisplayType;
497 if (_pMoreContextMenu != null)
499 _pMoreContextMenu->SetShowState(false);
505 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
511 pReceived_Filename = static_cast< String* >(pArgs->GetAt(0));
513 received_Filepath = FolderNavigationPresentationModel::GetCurrentPath();
514 receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
516 if (pReceived_Filename != null)
518 check.Append(*pReceived_Filename);
519 __pHeader = GetHeader();
521 if (__pHeader != null)
523 __pHeader->SetTitleText(check);
524 __pHeader->Invalidate(true);
528 __currentDirectoryPath.Clear();
529 __currentDirectoryPath.Append(received_Filepath);
531 //Get the Directory Entries for the received Filepath.
532 if (_pFolderEntryPM != null)
534 _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);
535 _pFolderEntryPM->SetFolderEntryPath(received_Filepath);
536 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
537 TryCatch(_pFilenames != null, , "Failed to allocate Memory to __pFilenames");
541 if (_pThumbnailItemProvider != null)
543 _pThumbnailItemProvider->SetCreateItemSource(sourceForm);
544 _pThumbnailItemProvider->SetFolderEntryProvider(this);
547 SetNextDisplayPath();
548 SetHeaderTitleText(__currentDirectoryPath);
553 //Empty Arguments Received.
555 __currentDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
556 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);
699 delete _pFileEventManager;
700 _pFileEventManager = null;
706 SubFolderFileListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
708 //When state is changed, push the parent filepath to the stack and save the selected path as
709 //root path so that listview can be refreshed to this path the next time. If Up button is click in
710 //the mean time, refresh the root path to be pushed to the parent path (changed in ShowParentView())
712 AppLogDebug("ENTER");
714 String tempRootMediaPath;
715 String filePathToPush;
717 bool searchHistory = false;
718 //result r = E_FAILURE;
719 DirectoryEntry* pDirStr = null;
721 ArrayList* pArgs = new (std::nothrow) ArrayList();
725 SceneManager* pSceneManager = SceneManager::GetInstance();
726 SceneId currentSceneId = pSceneManager->GetCurrentSceneId();
728 if (_pFilenames != null)
730 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
733 //temprootmediapath gives the full file path of the selected item
734 tempRootMediaPath = pDirStr->GetFullFilePath();
736 if (pDirStr->IsDirectory())
738 //Append the name of the file to the existing path
739 nextFilename = pDirStr->GetFileName();
740 _currentFileName.Clear();
741 _currentFileName = pDirStr->GetFileName();
743 //tempRootMediaPath.Append(L"/");
744 //Set the full file path as future parent filepath, changed when Up button is
746 if (__currentDirectoryPath != null)
748 __currentDirectoryPath.Clear();
749 //__currentDirectoryPath.Append(tempRootMediaPath);
750 __currentDirectoryPath = pDirStr->GetFullFilePath();
752 FolderNavigationPresentationModel::SetCurrentFilePath(__currentDirectoryPath);
754 pArgs->Add(&nextFilename);
756 searchHistory = CheckSearchHistory();
759 searchPath = FolderNavigationPresentationModel::GetParentPath();
760 FolderNavigationPresentationModel::SetSearchPreviousPath(searchPath);
763 pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
767 _indexTracker = index; //For OnFileEventOccured (RemoveCacheEntry)
768 _pathOfSelectedFile = tempRootMediaPath;
769 //It's not a directory, Launch the AppControl.
770 if (_pathOfSelectedFile.EndsWith(L".tpk") || _pathOfSelectedFile.EndsWith(L".wgt"))
772 String* pFileUriScheme = new (std::nothrow) String(L"file://");
773 pFileUriScheme->Append(_pathOfSelectedFile);
775 AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/view", pFileUriScheme, null, null, null, null);
776 delete pFileUriScheme;
780 CustomAppControl* pCustomAppControl = CustomAppControl::GetInstance();
781 if (pCustomAppControl != null)
785 pCustomAppControl->SetAppControlListener(null);
786 fileForAppControl = _pathOfSelectedFile;
787 AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(_pathOfSelectedFile);
788 if (pAppControlInUse != null)
789 CustomAppControl::SetAppControlInUse(pAppControlInUse);
801 SubFolderFileListForm::ShowHomeView(void)
803 AppLogDebug("Enter");
804 SceneManager* pSceneManager = null;
805 result r = E_SUCCESS;
806 pSceneManager = SceneManager::GetInstance();
807 if (pSceneManager != null)
809 if (CheckSearchHistory())
811 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
812 TryCatch(r == E_SUCCESS, , "scene transition failed");
816 r = pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
817 TryCatch(r == E_SUCCESS, , "scene transition failed");
821 if (_pFolderEntryPM != null)
823 _pFolderEntryPM->InitThumbnailManager();
833 SubFolderFileListForm::SetParentDisplayPath(void)
835 //Sets the display path for the parent directory using the current path.
839 String parentDisplayPath;
842 DataBindingContext* pContext = null;
843 pContext = GetDataBindingContextN();
845 if (pContext != null)
847 //Update binding on the source to fetch the current display path.
848 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_SOURCE);
852 StringTokenizer tokenizer(_displayPath, delim);
854 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
855 //it is the last token
856 while (tokenizer.HasMoreTokens())
858 int tokenCount = tokenizer.GetTokenCount();
862 tokenizer.GetNextToken(token);
863 parentDisplayPath.Append(token);
864 parentDisplayPath.Append(L"/");
872 //Set the display path to that of the generated filepath from the tokenizer
873 _displayPath = parentDisplayPath;
875 if (_pLabelDisplayPath != null)
877 _pLabelDisplayPath->SetText(_displayPath);
878 _pLabelDisplayPath->Invalidate(true);
881 if (pContext != null)
883 //Update Binding on the Target control to display the currently constructed path.
884 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
887 if (pContext != null)
895 SubFolderFileListForm::ShowParentDirectoryView(void)
897 AppLogDebug("ENTER");
898 //Shows the files of the above/parent directory
899 CreateItemSource sourceForm = CREATE_ITEM_SOURCE_NONE;
903 result r = E_SUCCESS;
908 String backUpCurrentPath;
910 backUpCurrentPath = FolderNavigationPresentationModel::GetCurrentPath();
912 displayPath = defaultPhoneBody;
913 displayPath.Append("/");
916 if (backUpCurrentPath == BasePresentationModel::GetMediaPath() || backUpCurrentPath == BasePresentationModel::GetSdCardPath() || backUpCurrentPath == BasePresentationModel::GetUsbPath())
918 //It is the homeview, so call showhomeview
920 TryCatch(r == E_SUCCESS, , "scene transition failed");
925 ParentPath = FolderNavigationPresentationModel::GetParentPath();
927 //RemovePath to remove FileEventListener
928 if(_pFileEventManager != null)
930 _pFileEventManager->RemovePath(__currentDirectoryPath);
932 __currentDirectoryPath.Clear();
933 __currentDirectoryPath.Append(ParentPath);
935 //AddPath to add FileEventListener for Parent Directory Path
936 if(_pFileEventManager != null)
938 _pFileEventManager->AddPath(__currentDirectoryPath, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
941 FolderNavigationPresentationModel::SetCurrentFilePath(__currentDirectoryPath);
943 if (_pFolderEntryPM != null)
945 _pFolderEntryPM->GetFolderEntryCount(__currentDirectoryPath, folderCount, fileCount);
948 SetParentDisplayPath();
949 SetHeaderTitleText(ParentPath);
951 //Remove the current files from the filenames list
952 if (_pFolderEntryPM != null)
954 //__pContentManager->ClearList();
955 _pFolderEntryPM->SetFolderEntryPath(ParentPath);
956 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
957 TryCatch(_pFilenames != null, , "Failed to fetch ArrayList from the ContentBrowser!");
959 sourceForm = _pFolderEntryPM->GetSourceForm();
960 AppLogDebug("Current Source Form is : %d",sourceForm);
962 _pFolderEntryPM->InitThumbnailManager();
966 SetFooterVisibility();
968 //Get the files in the parent path of the current view
970 //Update the icon list to view the files of the parent directory
971 if (_pListView != null && _pListView->IsVisible())
973 r = _pListView->UpdateList();
976 if (_pIconListView != null && _pIconListView->IsVisible())
978 r = _pIconListView->UpdateList();
981 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
985 FolderNavigationPresentationModel::SetCurrentFilePath(backUpCurrentPath);
990 SubFolderFileListForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
992 AppLogDebug("Enter");
994 Integer* pFileProcessingResult = null;
997 TryCatch(pArgs != null, , "Argument list received is invalid!");
998 pFileProcessingResult = (Integer*) pArgs->GetAt(0);
1000 TryCatch(pFileProcessingResult != null, , "FileProcessing Result list is invalid!");
1002 switch (pFileProcessingResult->ToInt())
1004 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1006 AppLogDebug("FILE DELETION SUCCESSFUL");
1007 HideFileProgressingPopup();
1011 case FILE_MANAGING_RESULT_DELETING_FAILED:
1013 HideFileProgressingPopup();
1016 case FILE_MANAGING_RESULT_THREAD_STOP:
1018 HideFileProgressingPopup();
1028 _pFolderEntryPM->InitThumbnailManager(); //for thumbnail issues/disappering images/defulat images etc...
1030 SetFooterVisibility();
1034 pArgs->RemoveAll(true);
1041 SubFolderFileListForm::OnDataBindingSourceUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
1043 //Empty Implementation.
1047 SubFolderFileListForm::OnDataBindingTargetUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
1049 //Empty Implementation.
1053 SubFolderFileListForm::OnDataBindingValidationFailed(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Ui::DataBindingDestinationType destType)
1055 //Empty Implementation.
1059 SubFolderFileListForm::OnFileEventExecuted(const Tizen::Base::String& path, const unsigned long eventId)
1061 AppLogDebug("ENTER");
1063 int badgeNumber = 0;
1064 result r = E_SUCCESS;
1066 // Tizen::Shell::NotificationManager* pNotiMgr = null;
1068 NotificationManager* pNotiMgr = null;
1069 AppResource* pAppResource = null;
1070 pAppResource = UiApp::GetInstance()->GetAppResource();
1071 TryCatch(pAppResource != null, , "Failed to fetch AppResource");
1073 pNotiMgr = new (std::nothrow) NotificationManager();
1074 TryCatch(pNotiMgr != null, , "Failed to fetch AppNotificationManager");
1076 pNotiMgr->Construct();
1077 badgeNumber = pNotiMgr->GetBadgeNumber();
1080 if (_pFolderEntryPM != null)
1082 //_pFolderEntryPM->SetFileEventListener(null);
1083 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1084 TryCatch(_pFilenames != null, , "File Names List retrieval failed");
1089 case FILE_EVENT_TYPE_CREATE:
1091 if (_pListView != null && _pListView->IsVisible())
1093 _pListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
1095 if (_pIconListView != null && _pIconListView->IsVisible())
1097 _pIconListView->RefreshList(_pFilenames->GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD);
1103 case FILE_EVENT_TYPE_DELETE:
1105 if (_pListView != null && _pListView->IsVisible())
1107 _pListView->RefreshList(__counter, LIST_REFRESH_TYPE_ITEM_REMOVE);
1109 if (_pIconListView != null && _pIconListView->IsVisible())
1111 if (_pThumbnailItemProvider != null)
1113 __counter = _pThumbnailItemProvider->GetPressedIndex();
1115 _pIconListView->RefreshList(__counter, LIST_REFRESH_TYPE_ITEM_REMOVE);
1121 case FILE_EVENT_TYPE_DELETE_SELF:
1134 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1136 if (pNotiMgr != null)
1144 if (pNotiMgr != null)
1153 SubFolderFileListForm::SetHeaderTitleText(Tizen::Base::String& filePath)
1156 String parentFileName;
1157 String delimiter(L"/");
1158 StringTokenizer tokenizer(filePath, delimiter);
1160 AppResource* pAppResource = null;
1162 pAppResource = UiApp::App::GetInstance()->GetAppResource();
1164 if (filePath == BasePresentationModel::GetMediaPath())
1166 if (pAppResource != null)
1168 pAppResource->GetString(L"IDS_MF_TAB_PHONE", parentFileName);
1171 else if (filePath == BasePresentationModel::GetSdCardPath())
1173 if (pAppResource != null)
1175 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", parentFileName);
1180 while (tokenizer.HasMoreTokens())
1182 int tokenCount = tokenizer.GetTokenCount();
1184 if (tokenCount == 1)
1186 tokenizer.GetNextToken(parentFileName);
1190 tokenizer.GetNextToken(token);
1195 __pHeader = GetHeader();
1196 if (__pHeader != null)
1198 if (!parentFileName.IsEmpty())
1200 __pHeader->SetTitleText(parentFileName);
1201 __pHeader->Invalidate(true);
1207 SubFolderFileListForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
1209 bool setMediaPath = false;
1210 MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
1211 String unmounted = sdCardStatusUnmounted;
1212 String removed = usbDeviceStatusRemoved;
1215 SceneManager* pSceneManager = null;
1217 if (state == unmounted || state == removed)
1219 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
1220 if (state == unmounted)
1222 if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
1224 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1225 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1226 setMediaPath = true;
1230 if (state == removed)
1232 if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
1234 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1235 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1236 setMediaPath = true;
1242 pSceneManager = SceneManager::GetInstance();
1243 if (pSceneManager != null)
1245 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), null);
1252 SubFolderFileListForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1254 ComponentType currentDeviceType;
1259 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
1265 currentDeviceType = COMPONENT_TYPE_USB;
1275 OnDeviceChange(currentDeviceType, state);
1279 SubFolderFileListForm::OnSceneTransitionCompleted (const Tizen::Ui::Scenes::SceneId &previousSceneId, const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1281 AppLogDebug("Enter");
1283 AppRegistry* pAppRegistry = null;
1284 String sortbyKeyName(L"SortBy");
1285 int sortStyle = SORT_BY_TYPE_DATE_RECENT;
1287 int folderCount = 0;
1289 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1290 pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1292 _pLongPressGestureDetector->AddLongPressGestureEventListener(*this);
1293 if (_pIconListView != null)
1295 _pIconListView->AddGestureDetector(*_pLongPressGestureDetector);
1298 if (_pFileEventManager != null)
1300 delete _pFileEventManager;
1301 _pFileEventManager = null;
1304 _pFileEventManager = new (std::nothrow)FileEventManager();
1305 _pFileEventManager->Construct(*this);
1307 _pFileEventManager->AddPath(__currentDirectoryPath, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
1309 _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(),folderCount, fileCount);
1311 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
1313 if (_renameOrCreate == SELECT_RENAME)
1315 pAppRegistry->Get(sortbyKeyName, sortStyle);
1317 if (sortStyle == SORT_BY_TYPE_NAME_ASCENDING || sortStyle == SORT_BY_TYPE_NAME_DESCENDING
1318 || sortStyle == SORT_BY_TYPE_DATE_OLDEST || sortStyle == SORT_BY_TYPE_DATE_RECENT)
1320 _pFolderEntryPM->SetFolderEntryPath(FolderNavigationPresentationModel::GetCurrentPath());
1321 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1323 if (_pListView != null && _pListView->IsVisible())
1325 _pListView->UpdateList();
1326 _pListView->ScrollToItem(0);
1328 if (_pIconListView != null && _pIconListView->IsVisible())
1330 _pIconListView->UpdateList();
1331 _pIconListView->ScrollToItem(0);
1333 _pFolderEntryPM->InitThumbnailManager();
1337 if (_pListView != null && _pListView->IsVisible())
1338 _pListView->RefreshList(_renameIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1339 if (_pIconListView != null && _pIconListView->IsVisible())
1340 _pIconListView->RefreshList(_renameIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1343 SetFooterVisibility();
1349 if (CheckSearchHistory())
1351 __previousSceneName = previousSceneId;
1356 SetFooterVisibility();
1358 if (_pFilenames->GetCount() == 0)
1360 _bIsDirectoryEmpty = true;
1364 _bIsDirectoryEmpty = false;
1367 if (_pFolderEntryPM != null)
1369 _pFolderEntryPM->InitThumbnailManager();
1374 SubFolderFileListForm::OnSceneTransitionStarted (const Tizen::Ui::Scenes::SceneId ¤tSceneId, const Tizen::Ui::Scenes::SceneId &nextSceneId)
1376 //Empty Implementation.
1380 SubFolderFileListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1382 AppLogDebug("ENTER");
1383 switch (orientationStatus)
1385 case ORIENTATION_STATUS_LANDSCAPE:
1387 SceneManager* pSceneManager = null;
1388 pSceneManager = SceneManager::GetInstance();
1389 if (pSceneManager != null)
1391 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), null);
1401 SubFolderFileListForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1403 AppLogDebug("TopMostFolderFileListForm::OnFileEventOccured:%S", path.GetPointer());
1405 //Scan the directory
1407 HashMap* pCacheList = null;
1408 DirectoryEntry* pCurrentEntry = null;
1409 bool cacheKeyStatus = false;
1412 //result r = ContentManager::ScanDirectory(__currentDirectoryPath,true,null,reqId);
1413 //AppLogDebug("ContentManager::ScanDirectory:%s", GetErrorMessage(r));
1415 if ((events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))
1417 _bBackFromAppControl = true;
1418 if ( (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM))
1420 AppLogDebug("Items to delete: %d", _indexTracker);
1421 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1422 if (pCacheList != null)
1424 pCurrentEntry = static_cast<DirectoryEntry*>(_pFilenames->GetAt(_indexTracker));
1426 if (pCurrentEntry != null)
1428 cachePath = pCurrentEntry->GetFullFilePath();
1431 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1435 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1439 if (_pFolderEntryPM!=null)
1441 if ( (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) )
1442 _pFilenames->RemoveAt(_indexTracker);
1444 _pFolderEntryPM->RefreshFolderEntries();
1447 if (_pListView != null && _pListView->IsVisible())
1449 _pListView->UpdateList();
1452 if (_pIconListView != null && _pIconListView->IsVisible())
1454 _pIconListView->UpdateList();
1457 if (_pFolderEntryPM!=null && ( (events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_MOVED_TO)))
1459 _pFolderEntryPM->InitThumbnailManager();
1465 SubFolderFileListForm::OnContentScanCompleted (RequestId reqId, const Tizen::Base::String &scanPath, result r)
1467 AppLogDebug("Enter");
1468 AppLogDebug("Exit");
1471 SubFolderFileListForm::OnAppControlCompleted(void)
1473 SubBaseFolderEntryForm::OnAppControlCompleted();