From: chitta.rs Date: Sat, 20 Apr 2013 13:49:09 +0000 (+0530) Subject: Issue related to OnFileEventOccured() call back fixed X-Git-Tag: accepted/tizen_2.1/20130425.024242~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7abae01f8d8ef97dfaa711ac6f9255593faeb0f5;p=apps%2Fosp%2FMyFiles.git Issue related to OnFileEventOccured() call back fixed Change-Id: I01d920c8d40b474bf935630d992956381f3a442f --- diff --git a/inc/MfBaseForm.h b/inc/MfBaseForm.h index d2b81c9..0d82626 100644 --- a/inc/MfBaseForm.h +++ b/inc/MfBaseForm.h @@ -130,6 +130,7 @@ public: virtual void OnIconListViewItemStateChangeNotify(void); virtual void OnThumbnailReceived(ThumbRequest* pThumbReq); + void OnAppControlCompleted(void){} }; #endif diff --git a/inc/MfFileManageForm.h b/inc/MfFileManageForm.h index f41477d..98b9d4d 100644 --- a/inc/MfFileManageForm.h +++ b/inc/MfFileManageForm.h @@ -178,6 +178,7 @@ public: * @param [ComponentType, String]deviceType, of the storage device, state, the current state of the storage device. * @return No Return Values. */ + void OnAppControlCompleted(void){} void OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state); private: diff --git a/inc/MfIListViewStateChangeListener.h b/inc/MfIListViewStateChangeListener.h index bef26a4..f893828 100644 --- a/inc/MfIListViewStateChangeListener.h +++ b/inc/MfIListViewStateChangeListener.h @@ -67,6 +67,7 @@ public: * @return No Return Values. */ virtual void OnThumbnailReceived(ThumbRequest* pThumbReq) = 0; + virtual void OnAppControlCompleted(void) = 0; }; #endif diff --git a/inc/MfSearchForm.h b/inc/MfSearchForm.h index 1e63b88..50cdae4 100644 --- a/inc/MfSearchForm.h +++ b/inc/MfSearchForm.h @@ -118,6 +118,7 @@ public: virtual void OnListViewItemStateChangedNotify(ViewType viewType); virtual void OnThumbnailReceived(ThumbRequest* pThumbReq); + void OnAppControlCompleted(void) ; //IDeviceEventListener virtual void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state); @@ -161,6 +162,7 @@ private: bool __bCheckArgsNull; bool __isCurrentDirectoryRenamed; bool __bIsResultList; + bool __backFromAppControl; int __itemCount; int __searchItemIndex; int __selectedItemIndexForRename; diff --git a/inc/MfSplitPanelFileManageForm.h b/inc/MfSplitPanelFileManageForm.h index c13e290..12ac26d 100644 --- a/inc/MfSplitPanelFileManageForm.h +++ b/inc/MfSplitPanelFileManageForm.h @@ -77,6 +77,7 @@ public: * @return No Return Values.*/ virtual void OnThumbnailReceived(ThumbRequest* pThumbReq); + void OnAppControlCompleted(void){} // IFileNotificationListener void OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs); diff --git a/inc/MfSplitPanelForm.h b/inc/MfSplitPanelForm.h index 5f366fc..7f1b6d7 100644 --- a/inc/MfSplitPanelForm.h +++ b/inc/MfSplitPanelForm.h @@ -80,6 +80,7 @@ public: * @return No Return Values. */ virtual void OnThumbnailReceived(ThumbRequest* pThumbReq); + void OnAppControlCompleted(void){} //IFileEventNotification void OnFileEventExecuted(const Tizen::Base::String& path, const unsigned long eventId); diff --git a/inc/MfSubBaseFileManageForm.h b/inc/MfSubBaseFileManageForm.h index b5bbc32..c682a37 100644 --- a/inc/MfSubBaseFileManageForm.h +++ b/inc/MfSubBaseFileManageForm.h @@ -69,6 +69,7 @@ protected: void SubBaseOnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView& iconListView, int index, Tizen::Ui::Controls::IconListViewItemStatus status); void SubBaseOnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs); void SubBaseOnThumbnailReceived(ThumbRequest* pThumbReq); + void OnAppControlCompleted(void) {} /* * A private member function taking and returning no arguments. * @fn CopyFile diff --git a/inc/MfSubBaseFolderEntryForm.h b/inc/MfSubBaseFolderEntryForm.h index 284cc17..7c4fb77 100644 --- a/inc/MfSubBaseFolderEntryForm.h +++ b/inc/MfSubBaseFolderEntryForm.h @@ -99,6 +99,7 @@ public: * @return No Return Values. */ virtual void OnThumbnailReceived(ThumbRequest* pThumbReq); + void OnAppControlCompleted(void){} /*! @fn OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status) * @brief Called when the state of an element in the ListContextItem is changed. diff --git a/inc/MfSubBaseMoveCopy.h b/inc/MfSubBaseMoveCopy.h index df1b21c..31ab092 100644 --- a/inc/MfSubBaseMoveCopy.h +++ b/inc/MfSubBaseMoveCopy.h @@ -214,6 +214,7 @@ protected: * @return [FileListPresentationModel*] A pointer to the filelistpresentation model. */ void OnThumbnailReceived(ThumbRequest* pThumbReq); + void OnAppControlCompleted(void){} //IListViewItemEventListener /* diff --git a/inc/MfSubBaseSelectionForm.h b/inc/MfSubBaseSelectionForm.h index 0294f23..ccf5838 100644 --- a/inc/MfSubBaseSelectionForm.h +++ b/inc/MfSubBaseSelectionForm.h @@ -92,6 +92,7 @@ public: * @return [FileListPresentationModel*] A pointer to the filelistpresentation model. */ virtual void OnThumbnailReceived(ThumbRequest* pThumbReq); + void OnAppControlCompleted(void){} protected: /* diff --git a/inc/MfSubFolderMoveCopy.h b/inc/MfSubFolderMoveCopy.h index c42f8d5..8862d5c 100644 --- a/inc/MfSubFolderMoveCopy.h +++ b/inc/MfSubFolderMoveCopy.h @@ -118,6 +118,7 @@ class SubFolderMoveCopy virtual FolderEntryPresentationModel* GetFolderEntryPresentationModel(void); void OnThumbnailReceived(ThumbRequest* pThumbReq); + void OnAppControlCompleted(void) {} private: /* diff --git a/inc/MfTypes.h b/inc/MfTypes.h index 31e2856..ff18306 100644 --- a/inc/MfTypes.h +++ b/inc/MfTypes.h @@ -412,15 +412,6 @@ enum AnnexStyle ANNEX_STYLE_DETAILED }; -/*class IListViewStateChangeListener -{ -public: - virtual void OnListViewItemStateChangedNotify(ViewType viewType) = 0; - virtual void OnFooterStateChangeNotify(void) {} - virtual void OnThumbnailReceived(ThumbRequest* pThumbReq) = 0; - virtual ~IListViewStateChangeListener(void){} -};*/ - //!Enumerator containing the AppControlState enum AppControlState { diff --git a/src/MfBaseItemProvider.cpp b/src/MfBaseItemProvider.cpp index 38e8798..abb9911 100644 --- a/src/MfBaseItemProvider.cpp +++ b/src/MfBaseItemProvider.cpp @@ -227,7 +227,7 @@ BaseItemProvider::GetItemCount(void) __pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(), dirCount, fileCount); itemCount = fileCount; } - AppLogDebug("Exit"); + AppLogDebug("Exit % d ", itemCount); return itemCount; } @@ -385,6 +385,7 @@ BaseItemProvider::CreateNormalListViewItem(int listItemIndex, int listItemWidth) contentType = ContentManagerUtil::CheckContentType(fullFilePath); if (pFileDetails->GetBitmap() == null && pFileDetails->IstDummy()) { + AppLogDebug("Item Index : %d", listItemIndex); if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)) { if (pFileDetails != null) @@ -406,6 +407,7 @@ BaseItemProvider::CreateNormalListViewItem(int listItemIndex, int listItemWidth) { AppLogDebug("BITMAP FOUND from cachemanager NO: Index[ %d] Path[%S]", listItemIndex, cacheImagePath.GetPointer()); pFileDetails->SetDummy(true); + pFileDetails->SetLoadBitmap(true); pCustomItem->SetThumbnail(__pDummyImage); } } diff --git a/src/MfCategorySearch.cpp b/src/MfCategorySearch.cpp index 7538bcf..5ff0714 100644 --- a/src/MfCategorySearch.cpp +++ b/src/MfCategorySearch.cpp @@ -245,6 +245,7 @@ CategorySearch::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listVi return; } + _indexTracker = index; // if (elementId == CONTENT_LIST_ITEM_TYPE_RENAME || elementId == DETAILED_LIST_ELEMENTS_RENAME) if (status == LIST_ITEM_STATUS_MORE) { @@ -282,9 +283,16 @@ CategorySearch::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listVi _pFileEventManager = null; } _pathOfSelectedFile = pCheckedEntry->GetFullFilePath(); + AppLogDebug("Selected File path : %S", _pathOfSelectedFile.GetPointer()); + _pFileEventManager = new (std::nothrow)FileEventManager(); _pFileEventManager->Construct(*this); - _pFileEventManager->AddPath(_pathOfSelectedFile, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_DELETE ); + + String FileName = pCheckedEntry->GetFileName() + "." + pCheckedEntry->GetFileExtension(); + String parentDirectoryOfSelectedFile = L""; + _pathOfSelectedFile.SubString(0, _pathOfSelectedFile.GetLength() - FileName.GetLength() , parentDirectoryOfSelectedFile); + + _pFileEventManager->AddPath(parentDirectoryOfSelectedFile, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_MOVED_FROM); if (pCustomAppControl != null) { @@ -553,7 +561,7 @@ CategorySearch::GetFileName(Tizen::Base::String* fileName) void CategorySearch::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId) { - if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE)) + /*if ((events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_TO) || (events & FILE_EVENT_TYPE_MOVED_FROM)) { if (_pFolderEntryPM!=null) { @@ -571,7 +579,84 @@ CategorySearch::OnFileEventOccured(const unsigned long events,const Tizen::Base: { _pFolderEntryPM->InitThumbnailManager(); } + }*/ + + + AppLogDebug("TopMostFolderFileListForm::OnFileEventOccured:%S", path.GetPointer()); + + //Scan the directory + + static unsigned short bRotate = 0; + HashMap* pCacheList = null; + DirectoryEntry* pCurrentEntry = null; + bool cacheKeyStatus = false; + String cachePath; + + if( !(bRotate ^ 3) ) + bRotate = 0; + AppLogDebug("ContentManager::ScanFile:%S", path.GetPointer()); + + if ((events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO )) + { + if ( (events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_MOVED_TO) ) + { + if ( bRotate & 1) + bRotate |= 2; + AppLogDebug("Items were rotated afted creation: %d", bRotate); + } + if ( (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM)) + { + bRotate |= 1; + AppLogDebug("Items were rotated after deletion: %d", bRotate); + + AppLogDebug("Items to delete: %d", _indexTracker); + pCacheList = CacheManager::GetInstance()->GetCacheHashMap(); + if (pCacheList != null) + { + pCurrentEntry = static_cast(_pFilenames->GetAt(_indexTracker)); + + if (pCurrentEntry != null) + { + cachePath = pCurrentEntry->GetFullFilePath(); + } + + cacheKeyStatus = pCacheList->ContainsKey(cachePath); + + if (cacheKeyStatus) + { + CacheManager::GetInstance()->RemoveCacheEntry(cachePath); + } + } + } + if (_pFolderEntryPM!=null) + { + _pFolderEntryPM->RefreshFolderEntries(); + } + + if (_pListView != null && _pListView->IsVisible()) + { + _pListView->UpdateList(); + } + + if (_pIconListView != null && _pIconListView->IsVisible()) + { + _pIconListView->UpdateList(); + } + + if (_pFolderEntryPM!=null) + { + if (!(bRotate ^ 3) ) + { + { + AppLogDebug("Items were rotated : %d", bRotate); + //CacheManager::GetInstance()->ClearCache(); + } + } + /* AppLogDebug("InitThumbnailManager"); + _pFolderEntryPM->InitThumbnailManager();*/ + } } + } void diff --git a/src/MfMyFilesApp.cpp b/src/MfMyFilesApp.cpp index 15ab71a..f400568 100644 --- a/src/MfMyFilesApp.cpp +++ b/src/MfMyFilesApp.cpp @@ -312,6 +312,8 @@ MyFilesApp::OnForeground(void) { pCurrentFrame->SetEnabled(true); } + + __pCurrentListToUpdate->OnAppControlCompleted(); } void diff --git a/src/MfSearchForm.cpp b/src/MfSearchForm.cpp index d42ca06..930738e 100644 --- a/src/MfSearchForm.cpp +++ b/src/MfSearchForm.cpp @@ -60,6 +60,7 @@ SearchForm::SearchForm(void) __isSearchStarted = false; __bCheckArgsNull = false; __isCurrentDirectoryRenamed = false; + __backFromAppControl = false; __itemCount = -1; __searchItemIndex = INVALID_LIST_INDEX; @@ -554,7 +555,7 @@ SearchForm::OnListViewItemStateChanged(ListView& listView, int index, int elemen if (pCustomAppControl != null) { pCustomAppControl->SetAppControlListener(this); - __pFileEventManager->AddPath(parentDirectoryOfSelectedFile, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE ); + __pFileEventManager->AddPath(parentDirectoryOfSelectedFile, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE ); AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(__pathOfSelectedFile); if (pAppControlInUse != null) CustomAppControl::SetAppControlInUse(pAppControlInUse); @@ -1787,15 +1788,9 @@ SearchForm::StartSearch(void) void SearchForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId) { - if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO )) + if ((events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO )) { - __pSearchBar->SetMode(__searchBarMode); - - if (__searchText.IsEmpty() == false) - StartSearch(); - - if (__pListView != null) - __pListView->UpdateList(); + __backFromAppControl = true; } } @@ -1879,3 +1874,20 @@ SearchForm::GetParentFolderPath(Tizen::Base::String* filePath) } } +void +SearchForm::OnAppControlCompleted(void) +{ + AppLogDebug("OnAppControlCompleted++"); + if ( __backFromAppControl==true ) + { + __pSearchBar->SetMode(__searchBarMode); + + if (__searchText.IsEmpty() == false) + StartSearch(); + + if (__pListView != null) + __pListView->UpdateList(); + __backFromAppControl = false; + } + AppLogDebug("OnAppControlCompleted--"); +} diff --git a/src/MfSubBaseFileManageForm.cpp b/src/MfSubBaseFileManageForm.cpp index 98eafb5..dd534b7 100644 --- a/src/MfSubBaseFileManageForm.cpp +++ b/src/MfSubBaseFileManageForm.cpp @@ -1060,7 +1060,7 @@ void SubBaseFileManageForm::SetFooterVisibility(int mode) { AppLogDebug("ENTRY mode = %d",mode); - int folderCount = 0, fileCount = 0; + _pFooter = GetFooter(); if (mode == DISABLE_FOOTER_ITEM) diff --git a/src/MfSubBaseSelectionForm.cpp b/src/MfSubBaseSelectionForm.cpp index 7e49a82..c1f7380 100644 --- a/src/MfSubBaseSelectionForm.cpp +++ b/src/MfSubBaseSelectionForm.cpp @@ -1,924 +1,924 @@ -// -// Copyright (c) 2012 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -/** - * @file: MfSubBaseSelectionForm.cpp - * @brief: This file contains implementation of SubBaseSelection class, which acts as a view for traversing SubDirectories - * in the AppControl. - */ - -#include "MfMyFilesApp.h" -#include "MfSceneRegister.h" -#include "MfSubBaseSelectionForm.h" - -using namespace Tizen::App; -using namespace Tizen::Base; -using namespace Tizen::Base::Collection; -using namespace Tizen::Base::Utility; -using namespace Tizen::Content; -using namespace Tizen::Graphics; -using namespace Tizen::Io; -using namespace Tizen::Locales; -using namespace Tizen::Media; -using namespace Tizen::System; -using namespace Tizen::Ui; -using namespace Tizen::Ui::Controls; -using namespace Tizen::Ui::Scenes; - -SubBaseSelection::SubBaseSelection(void) -: _pFilenames(null) -, _pFooter(null) -, _pAttach(null) -//, _pCancel(null) -, _pCreateFolder(null) -, _pExport(null) -, _pImport(null) -, _pHeader(null) -, _pLabelNumberOfItems(null) -, _pListView(null) -, _pAudioPause(null) -, _pAudioPlay(null) -, _pAudioPlayPressed(null) -, _pDummyImage(null) -, _pFolderBitmap(null) -, _pAudioPlayer(null) -, _pFileManager(null) -, _pFolderEntryPM(null) -, _pThumbnailManager(null) -{ - //,_listAnnexStyle(null) - _selectionMode = SELECTION_MODE_MULTIPLE; - _storedSortStyle = SORT_BY_TYPE_DATE_RECENT; - _storePreviousIndex = -1; - _currentViewStyle = APPCONTROL_VIEW_DEFAULT; - _currentExportFileType = EXPORT_TYPE_CONTACTS; - _currentFileType = FILE_TYPE_ALL; - _previousAudioSelected = -1; - _annexStyle = ANNEX_STYLE_NORMAL; - _storageType = MEMORY_TYPE_PHONE; - _currentAudioPlayIndex = -1; - __defaultListViewBounds = Rectangle(0,0,0,0); -} - -SubBaseSelection::~SubBaseSelection(void) -{ -/* if (_pCancel != null) - { - delete _pCancel; - }*/ - - if (_pAttach != null) - { - delete _pAttach; - } - - if (_pImport != null) - { - delete _pImport; - } - - if (_pExport != null) - { - delete _pExport; - } - - if (_pCreateFolder != null) - { - delete _pCreateFolder; - } - - if (_pAudioPlayer != null) - { - delete _pAudioPlayer; - } - - if (_pFolderEntryPM != null) - { - delete _pFolderEntryPM; - } - - if (_pAudioPlay != null) - { - delete _pAudioPlay; - } - - if (_pAudioPause != null) - { - delete _pAudioPause; - } - - if (_pAudioPlayPressed != null) - { - delete _pAudioPlayPressed; - } - - if (_pFolderBitmap != null) - { - delete _pFolderBitmap; - } - - if (_pDummyImage != null) - { - delete _pDummyImage; - } -} - -SubBaseSelection& -SubBaseSelection::operator =(const SubBaseSelection& pSubBaseSelection) -{ - return *this; -} - -SubBaseSelection::SubBaseSelection(const SubBaseSelection& pSubBaseSelection) -{ - //Do Nothing -} - -void -SubBaseSelection::OnPlayerOpened(result r) -{ - //empty implementation -} - -void -SubBaseSelection::OnPlayerEndOfClip(void) -{ - //empty implementation -} - -void -SubBaseSelection::OnPlayerBuffering(int percent) -{ - //empty implementation -} - -void -SubBaseSelection::OnPlayerErrorOccurred(PlayerErrorReason r) -{ - //empty implementation -} - -void -SubBaseSelection::OnPlayerInterrupted(void) -{ - //empty implementation -} - -void -SubBaseSelection::OnPlayerReleased(void) -{ - //empty implementation -} - -void -SubBaseSelection::OnPlayerSeekCompleted(result r) -{ - //empty implementation -} - -Tizen::Ui::Controls::ListItemBase* -SubBaseSelection::CreateItem(int index, int itemWidth) -{ - AppLogDebug("Entry"); - CustomItem* pCustomItem = null; - if (_currentViewStyle == APPCONTROL_VIEW_EXPORT) - { - pCustomItem = CreateExportListViewItem(index, itemWidth); - } - else - { - pCustomItem = CreateDefaultContentItem(index, itemWidth); - } - return pCustomItem; -} - -bool -SubBaseSelection::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) -{ - if (pItem != null) - { - delete pItem; - pItem = null; - } - - return true; -} - -int -SubBaseSelection::GetItemCount(void) -{ - AppLogDebug("Entry"); - int itemCount = 0; - - if (_pFilenames != null) - { - AppResource* pAppResource = null; - String selectFiles; - - pAppResource = Application::GetInstance()->GetAppResource(); - TryCatch(pAppResource != null, , "Resource manager not found!"); - - pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles); - - if (_currentViewStyle == APPCONTROL_VIEW_IMPORT) - { - itemCount = _pFilenames->GetCount(); - } - - else - { - if (_pFilenames->GetCount() == 0) - { - if (_pLabelNumberOfItems->GetShowState() == true) - { - _pLabelNumberOfItems->SetShowState(false); - _pLabelNumberOfItems->Draw(); - - if (_selectionMode == SELECTION_MODE_MULTIPLE) - { - _pListView->SetSize(__defaultListViewBounds.width, __defaultListViewBounds.height); - _pListView->Invalidate(true); - } - } - } - else - { - if (_pLabelNumberOfItems->GetShowState() == false && _selectionMode != SELECTION_MODE_SINGE && _currentViewStyle == APPCONTROL_VIEW_DEFAULT) - { - _pLabelNumberOfItems->SetShowState(true); - } - - if (_selectionMode == SELECTION_MODE_MULTIPLE) - { - _pListView->SetSize(__defaultListViewBounds.width, __defaultListViewBounds.height - _pLabelNumberOfItems->GetHeight()); - _pListView->Invalidate(true); - } - _itemSelectedCount.Clear(); - _itemSelectedCount.Append(selectFiles); - _pLabelNumberOfItems->SetText(_itemSelectedCount); - _pLabelNumberOfItems->Invalidate(true); - } - } - AppLogDebug("Exit %s", GetErrorMessage(GetLastResult())); - itemCount = _pFilenames->GetCount(); - } - else - { - itemCount = 0; - } - return itemCount; - CATCH: - AppLogDebug("Failed to get count"); - return 0; -} - -ContentListItem* -SubBaseSelection::CreateDefaultContentItem(int index, int itemWidth) -{ - AppLogDebug("Entry"); - result r = E_SUCCESS; - Font font; - String filename; - String folderIconPath; - String fontName; - String searchedString; - String cacheImagePath; - - PlayerState audioPlayerStatus; - ContentType contentType = CONTENT_TYPE_UNKNOWN; - - ContentListItem* pCustomItem = null; - Bitmap* pFetchedCacheImage = null; - Bitmap* pThumbnailImage = null; - HashMap* pCacheList = null; - - Dimension thumbnailDimension(W_LISTVIEW_ITEM_BITMAP, H_LISTVIEW_ITEM_BITMAP); - Dimension textDimension(itemWidth - W_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW); - AppResource* pAppResource = null; - DirectoryEntry* pFileDetails = null; - - int w_Title = 0; - - w_Title = itemWidth - ((W_LISTVIEW_ITEM_BITMAP * 4) + (4 * X_LISTVIEW)); - TryCatch(_pFilenames != null, , "Filename list if empty!"); - - pAppResource = Application::GetInstance()->GetAppResource(); - TryCatch(pAppResource != null, , "Resource manager not found!"); - - pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW); - TryCatch(pCustomItem != null, , "Failed to alloated customitem"); - - pFileDetails = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index)); - if (pFileDetails != null) - { - filename = pFileDetails->GetFileName(); - - contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath()); - pCacheList = CacheManager::GetInstance()->GetCacheHashMap(); - if (_pThumbnailManager != null) - { - if (pFileDetails->IsDirectory()) - { - pCustomItem->SetThumbnail(_pFolderBitmap); - _annexStyle = ANNEX_STYLE_NORMAL; - pCustomItem->SetListAnnexStyle(_annexStyle); - } - else - { - if (pFileDetails->GetBitmap() == null) - { - if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)) - { - if (pFileDetails != null) - { - cacheImagePath = pFileDetails->GetFullFilePath(); - AppLogDebug("cache path is %S",cacheImagePath.GetPointer()); - } - - if ((pCacheList->GetValue(cacheImagePath)) != null) - { - pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath)); - } - } - - if (pFetchedCacheImage != null) - { - AppLogDebug("image taken from cachemanager"); - pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath); - pCustomItem->SetThumbnail(pThumbnailImage); - } - else - { - pFileDetails->SetDummy(true); - pCustomItem->SetThumbnail(_pDummyImage); - AppLogDebug("call to thumbnail manager"); - } - - //r = _pFolderEntryPM->InitThumbnailManager(index); - } - else - { - pCustomItem->SetThumbnail(pFileDetails->GetBitmap()); - } - - if (_selectionMode == SELECTION_MODE_SINGE) - { - _annexStyle = ANNEX_STYLE_RADIO; - pCustomItem->SetListAnnexStyle(_annexStyle); - } - else if (_selectionMode == SELECTION_MODE_MULTIPLE) - { - _annexStyle = ANNEX_STYLE_MARK; - pCustomItem->SetListAnnexStyle(_annexStyle); - } - else if (_selectionMode == SELECTION_MODE_NONE) - { - _annexStyle = ANNEX_STYLE_NORMAL; - pCustomItem->SetListAnnexStyle(_annexStyle); - } - - if (contentType == CONTENT_TYPE_AUDIO) - { - if (_pAudioPlayer != null) - { - audioPlayerStatus = _pAudioPlayer->GetState(); - - if (audioPlayerStatus == PLAYER_STATE_CLOSED) - { - pCustomItem->SetAudioBitmap(_pAudioPlay, null); - } - - if (_currentAudioPlayIndex == index) - { - if (audioPlayerStatus == PLAYER_STATE_PLAYING) - { - pCustomItem->SetAudioBitmap(null, _pAudioPause); - } - //else if (audioPlayerStatus == PLAYER_STATE_PAUSED || audioPlayerStatus == PLAYER_STATE_ENDOFCLIP) - else - { - pCustomItem->SetAudioBitmap(_pAudioPlay, null); - } - } - else - { - pCustomItem->SetAudioBitmap(_pAudioPlay, null); - } - } - else - { - pCustomItem->SetAudioBitmap(_pAudioPlay, null); - } - } - } - } - } - - if (!filename.IsEmpty()) - { - pCustomItem->SetTitle(filename, searchedString); - } - pCustomItem->MakeAppControlFormListItem(); - - AppLogDebug("Exit %s", GetErrorMessage(r)); - - return pCustomItem; - - CATCH: - //Free EnrichedText - if (_pAudioPlay != null) - { - delete _pAudioPlay; - _pAudioPlay = null; - } - - if (_pAudioPause != null) - { - delete _pAudioPause; - _pAudioPause = null; - } - - AppLogDebug("Exit %s", GetErrorMessage(GetLastResult())); - return null; -} - -void -SubBaseSelection::OnThumbnailReceived(ThumbRequest* pThumbReq) -{ - result res = E_SUCCESS; - AppLogDebug("Enter"); - - if (_pFolderEntryPM) - { - if (pThumbReq != null) - { - if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm()) - { - if (pThumbReq->pBitmap != null) - { - AppLogDebug("This Bitmap is not requested from same form"); - delete pThumbReq->pBitmap; - } - return; - } - } - - if (pThumbReq) - { - if (pThumbReq->iRquestId < _pFilenames->GetCount()) - { - - _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId); - - if (_pListView && _pListView->IsVisible()) - { - res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY); - } - } - } - else - { - _pFolderEntryPM->OnThumbnailResponseFailed(); - } - } - AppLogDebug("Exit %s", GetErrorMessage(res)); - return; -} - -void -SubBaseSelection::OnListViewItemStateChangedNotify(ViewType viewType) -{ - //empty Implementation -} - -void -SubBaseSelection::InitializePlayer(void) -{ - _pAudioPlayer = new (std::nothrow) Player(); - - if (_pAudioPlayer != null) - { - _pAudioPlayer->Construct(*this); - } -} - -void -SubBaseSelection::LoadMusicPlayer(const Tizen::Base::String& mediaFilepath, Tizen::Media::PlayerState PlayerCurrentState) -{ - result r = E_SUCCESS; - if (_pAudioPlayer != null && mediaFilepath.IsEmpty() == false) - { - if (_pAudioPlayer->GetState() != PLAYER_STATE_PAUSED) - { - if (_pAudioPlayer != null) - { - delete _pAudioPlayer; - _pAudioPlayer = null; - } - _pAudioPlayer = new (std::nothrow) Player(); - _pAudioPlayer->Construct(*this); - } - - r = _pAudioPlayer->OpenFile(mediaFilepath, false); - r = _pAudioPlayer->Play(); - r = _pAudioPlayer->SetLooping(false); - r = _pAudioPlayer->SetVolume(100); - } - AppLogDebug("Exit: %s", GetErrorMessage(r)); -} - -result -SubBaseSelection::InitializeAppRegistry(void) -{ - AppLogDebug("Entry"); - result r = E_SUCCESS; - int previousSortValue = 0; - AppRegistry* pAppRegistry = null; - String sortbyKeyName(L"SortBy"); - SortByType sortStyle = SORT_BY_TYPE_DATE_RECENT; - - pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry(); - - r = pAppRegistry->Add(sortbyKeyName, sortStyle); - - if (r == E_SUCCESS) - { - r = pAppRegistry->Save(); - } - else if (r == E_KEY_ALREADY_EXIST) - { - pAppRegistry->Get(sortbyKeyName, previousSortValue); - _storedSortStyle = static_cast< SortByType >(previousSortValue); - if (_storedSortStyle != null) - { - pAppRegistry->Set(sortbyKeyName, sortStyle); - r = pAppRegistry->Save(); - } - } - - AppLogDebug("Exit %s", GetErrorMessage(r)); - return r; -} - -result -SubBaseSelection::CreateLabelControl(void) -{ - AppLogDebug("Entry"); - result r = E_SUCCESS; - Color backgroundColor(68, 68, 68); - //Color textColor(Color(76, 81, 88)); - - _pLabelNumberOfItems = static_cast< Label* >(GetControl(L"IDC_LABEL_SELECTED")); - TryCatch(_pLabelNumberOfItems != null, , "applog: allocation failed for __pLabelNumberOfItems"); - -// _pLabelNumberOfItems->Construct(Rectangle(0, GetClientAreaBounds().height - H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL), _itemSelectedCount); -// _pLabelNumberOfItems->SetBackgroundColor(backgroundColor); -// _pLabelNumberOfItems->SetTextColor(Color::GetColor(COLOR_ID_WHITE)); - _pLabelNumberOfItems->SetTextHorizontalAlignment(ALIGNMENT_CENTER); -// _pLabelNumberOfItems->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); - _pLabelNumberOfItems->SetTextConfig(ID_FONT_SIZE_26, LABEL_TEXT_STYLE_BOLD); - - if (_selectionMode == SELECTION_MODE_SINGE) - { - _pLabelNumberOfItems->SetShowState(false); - } - else - { - if (_currentViewStyle != APPCONTROL_VIEW_IMPORT) - { - _pLabelNumberOfItems->SetShowState(true); - } - } - -// r = AddControl(*_pLabelNumberOfItems); - AppLogDebug("Exit %s", GetErrorMessage(r)); - return r; - CATCH: - AppLogDebug("Exit %s", GetErrorMessage(r)); - r = GetLastResult(); - return r; -} - - -void -SubBaseSelection::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId) -{ - AppLogDebug("Entry"); - String mediaPath; - String storagePath; - - switch (actionId) - { - case IDA_BTN_ATTACH: - { - UiApp* pApp = UiApp::GetInstance(); - ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected(); - ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED); - - if (pApp != null) - { - pApp->Terminate(); - } - } - break; -/* - case IDA_BTN_CANCEL: - { - - } - break;*/ - - case IDA_BTN_IMPORT: - { - UiApp* pApp = UiApp::GetInstance(); - - ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected(); - ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED); - - if (pApp != null) - { - pApp->Terminate(); - } - } - break; - - case IDA_BTN_EXPORT: - { - UiApp* pApp = UiApp::GetInstance(); - - ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected(); - ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED); - - if (pApp != null) - { - pApp->Terminate(); - } - } - break; - - case IDA_BTN_CREATE_FOLDER: - { - ArrayList* pArg = null; - Integer* pSourceSelected = null; - SceneManager* pSceneManager = null; - - pSceneManager = SceneManager::GetInstance(); - - pArg = new (std::nothrow) ArrayList(); - pArg->Construct(); - pSourceSelected = new (std::nothrow) Integer(SELECT_CREATE_FOLDER); - pArg->Add(pSourceSelected); - - _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath(); - pArg->Add(&_rootMediaPath); - - if (pSceneManager != null) - { - pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg); - } - } - break; - - default: - break; - } - AppLogDebug("Exit %s", GetErrorMessage(GetLastResult())); -} - -void -SubBaseSelection::ClearSelectedItems(Tizen::Ui::Controls::ListView& listView) -{ - ArrayList* pCheckedKeys = null; - int itemCount = 0; - if (_pFileManager != null) - { - pCheckedKeys = static_cast< ArrayList* >(_pFileManager->GetCheckedList()->GetKeysN()); - AppLogDebug("Get count is %d",pCheckedKeys->GetCount()); - for (itemCount=0; itemCountGetCount();itemCount++) - { - Integer* currentIndex = static_cast(pCheckedKeys->GetAt(itemCount)); - listView.SetItemChecked(currentIndex->ToInt(), false); - } - _pFileManager->ClearCheckedList(); - } -} - -void -SubBaseSelection::ResetFooter(void) -{ - AppResource* pAppResource = null; - String selectFiles; - - pAppResource = Application::GetInstance()->GetAppResource(); - pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles); - - if (_pListView != null) - { - ClearSelectedItems(*_pListView); - _pFooter->SetItemEnabled(0,false); - _pFooter->Invalidate(true); - _itemSelectedCount.Clear(); - _itemSelectedCount.Append(selectFiles); - _pLabelNumberOfItems->SetText(_itemSelectedCount); - _pLabelNumberOfItems->Invalidate(true); - } -} - -void -SubBaseSelection::OnPlayerAudioFocusChanged (void) -{ - //Empty Implementation. -} - -void -SubBaseSelection::OnFormBackRequested(Form& source) -{ - String currentPath; - String parentPath; - result r = E_SUCCESS; - SceneManager* pSceneManager = null; - pSceneManager = SceneManager::GetInstance(); - currentPath = FolderNavigationPresentationModel::GetCurrentPath(); - - if (_currentViewStyle != APPCONTROL_VIEW_EXPORT) - { - ResetFooter(); - } - - if (_pAudioPlayer != null) - { - if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING) - { - _pAudioPlayer->Stop(); - } - } - if (currentPath == BasePresentationModel::GetMediaPath() || currentPath == BasePresentationModel::GetSdCardPath()) - { - FolderNavigationPresentationModel::SetCurrentFilePath(currentPath); - ShowHomeView(); - } - else - { - parentPath = FolderNavigationPresentationModel::GetParentPath(); - - FolderNavigationPresentationModel::SetCurrentFilePath(parentPath); - r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null); - } -} - -void -SubBaseSelection::ShowHomeView(void) -{ - SceneManager* pSceneManager = null; - String topMostFileSelection(L"ScnTempForm"); - pSceneManager = SceneManager::GetInstance(); - if (pSceneManager != null) - { - IList* pArgs = new (std::nothrow) ArrayList(); - pArgs->Add(new (std::nothrow) Integer(APPCONTROL_STATE_SELECTED)); - if (pSceneManager->IsSceneAlive(topMostFileSelection)) - { - pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), pArgs); - } - else - { - pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), pArgs); - } - } -} - -ContentListItem* -SubBaseSelection::CreateExportListViewItem(int listItemIndex, int listItemWidth) -{ - AppLogDebug("ENTER"); - - Font font; - - String filename; - String folderIconPath; - String imageIconPath; - String fontName; - String searchedText; - String fileExtension; - String creationDate; - String searchedString; - String selectAll; - String fullFilePath; - String cacheImagePath; - - HashMap* pCacheList = null; - Bitmap* pFetchedCacheImage = null; - Bitmap* pThumbnailImage = null; - - DateTime dateCreated; - Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP); - Dimension textDimension(listItemWidth - W_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW); - - DirectoryEntry* pFileDetails = null; - - ContentListItem* pCustomItem = null; - ContentType contentType = CONTENT_TYPE_UNKNOWN; - - //AppRegistry* pAppRegistry = null; - //pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry(); - - TryCatch(_pFilenames != null, , "MfMyFilesApp::Filename list if empty!"); - TryCatch(_pFilenames->GetCount() != 0, , "MfMyFilesApp::Filename count is Zero!"); - - pCustomItem = new (std::nothrow) ContentListItem(listItemWidth, H_ITEM_LISTVIEW); - TryCatch(pCustomItem != null, , "MfMyFilesApp::Failed to allocate Memory to pCustomItem"); - - //Get the Directory Entry for the element at index from the Filenames list. - - pFileDetails = static_cast< DirectoryEntry* >(_pFilenames->GetAt(listItemIndex)); - TryCatch(pFileDetails != null, , "MfMyFilesApp::Failed to fetch FileDetails from __pFileNames!"); - - pCacheList = CacheManager::GetInstance()->GetCacheHashMap(); - - //Set the filename of the element at index index - filename = pFileDetails->GetFileName(); - fullFilePath = pFileDetails->GetFullFilePath(); - - //If the registry key value is set for show extension append the extension of the filename else do not. - - if (!pFileDetails->GetFileExtension().IsEmpty()) - { - filename = filename + "." + pFileDetails->GetFileExtension(); - } - - - if (pFileDetails->IsDirectory()) - { - pCustomItem->SetThumbnail(_pFolderBitmap); - } - else - { - pCustomItem->SetDescColor(Color::GetColor(COLOR_ID_GREY)); - - contentType = ContentManagerUtil::CheckContentType(fullFilePath); - - if (pFileDetails->GetBitmap() == null && pFileDetails->IstDummy()) - { - if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)) - { - if (pFileDetails != null) - { - cacheImagePath = pFileDetails->GetFullFilePath(); - AppLogDebug("cache path is %S",cacheImagePath.GetPointer()); - } - - if ((pCacheList->GetValue(cacheImagePath)) != null) - { - pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath)); - } - } - - if (pFetchedCacheImage != null) - { - AppLogDebug("image taken from cachemanager"); - pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath); - pCustomItem->SetThumbnail(pThumbnailImage); - } - else - { - pFileDetails->SetDummy(true); - pCustomItem->SetThumbnail(_pDummyImage); - AppLogDebug("call to thumbnail manager"); - } - } - else - { - AppLogDebug("BITMAP FOUND : NOT NEED TO DO GETTHUMBNAIL"); - pCustomItem->SetThumbnail(pFileDetails->GetBitmap()); - } - } - - pCustomItem->SetTitle(filename, searchedText); - - pCustomItem->Make(); - - AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult())); - - return pCustomItem; - -CATCH: - if (pCustomItem != null) - { - delete pCustomItem; - pCustomItem = null; - } - return null; -} +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file: MfSubBaseSelectionForm.cpp + * @brief: This file contains implementation of SubBaseSelection class, which acts as a view for traversing SubDirectories + * in the AppControl. + */ + +#include "MfMyFilesApp.h" +#include "MfSceneRegister.h" +#include "MfSubBaseSelectionForm.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::Content; +using namespace Tizen::Graphics; +using namespace Tizen::Io; +using namespace Tizen::Locales; +using namespace Tizen::Media; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +SubBaseSelection::SubBaseSelection(void) +: _pFilenames(null) +, _pFooter(null) +, _pAttach(null) +//, _pCancel(null) +, _pCreateFolder(null) +, _pExport(null) +, _pImport(null) +, _pHeader(null) +, _pLabelNumberOfItems(null) +, _pListView(null) +, _pAudioPause(null) +, _pAudioPlay(null) +, _pAudioPlayPressed(null) +, _pDummyImage(null) +, _pFolderBitmap(null) +, _pAudioPlayer(null) +, _pFileManager(null) +, _pFolderEntryPM(null) +, _pThumbnailManager(null) +{ + //,_listAnnexStyle(null) + _selectionMode = SELECTION_MODE_MULTIPLE; + _storedSortStyle = SORT_BY_TYPE_DATE_RECENT; + _storePreviousIndex = -1; + _currentViewStyle = APPCONTROL_VIEW_DEFAULT; + _currentExportFileType = EXPORT_TYPE_CONTACTS; + _currentFileType = FILE_TYPE_ALL; + _previousAudioSelected = -1; + _annexStyle = ANNEX_STYLE_NORMAL; + _storageType = MEMORY_TYPE_PHONE; + _currentAudioPlayIndex = -1; + __defaultListViewBounds = Rectangle(0,0,0,0); +} + +SubBaseSelection::~SubBaseSelection(void) +{ +/* if (_pCancel != null) + { + delete _pCancel; + }*/ + + if (_pAttach != null) + { + delete _pAttach; + } + + if (_pImport != null) + { + delete _pImport; + } + + if (_pExport != null) + { + delete _pExport; + } + + if (_pCreateFolder != null) + { + delete _pCreateFolder; + } + + if (_pAudioPlayer != null) + { + delete _pAudioPlayer; + } + + if (_pFolderEntryPM != null) + { + delete _pFolderEntryPM; + } + + if (_pAudioPlay != null) + { + delete _pAudioPlay; + } + + if (_pAudioPause != null) + { + delete _pAudioPause; + } + + if (_pAudioPlayPressed != null) + { + delete _pAudioPlayPressed; + } + + if (_pFolderBitmap != null) + { + delete _pFolderBitmap; + } + + if (_pDummyImage != null) + { + delete _pDummyImage; + } +} + +SubBaseSelection& +SubBaseSelection::operator =(const SubBaseSelection& pSubBaseSelection) +{ + return *this; +} + +SubBaseSelection::SubBaseSelection(const SubBaseSelection& pSubBaseSelection) +{ + //Do Nothing +} + +void +SubBaseSelection::OnPlayerOpened(result r) +{ + //empty implementation +} + +void +SubBaseSelection::OnPlayerEndOfClip(void) +{ + //empty implementation +} + +void +SubBaseSelection::OnPlayerBuffering(int percent) +{ + //empty implementation +} + +void +SubBaseSelection::OnPlayerErrorOccurred(PlayerErrorReason r) +{ + //empty implementation +} + +void +SubBaseSelection::OnPlayerInterrupted(void) +{ + //empty implementation +} + +void +SubBaseSelection::OnPlayerReleased(void) +{ + //empty implementation +} + +void +SubBaseSelection::OnPlayerSeekCompleted(result r) +{ + //empty implementation +} + +Tizen::Ui::Controls::ListItemBase* +SubBaseSelection::CreateItem(int index, int itemWidth) +{ + AppLogDebug("Entry"); + CustomItem* pCustomItem = null; + if (_currentViewStyle == APPCONTROL_VIEW_EXPORT) + { + pCustomItem = CreateExportListViewItem(index, itemWidth); + } + else + { + pCustomItem = CreateDefaultContentItem(index, itemWidth); + } + return pCustomItem; +} + +bool +SubBaseSelection::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + if (pItem != null) + { + delete pItem; + pItem = null; + } + + return true; +} + +int +SubBaseSelection::GetItemCount(void) +{ + AppLogDebug("Entry"); + int itemCount = 0; + + if (_pFilenames != null) + { + AppResource* pAppResource = null; + String selectFiles; + + pAppResource = Application::GetInstance()->GetAppResource(); + TryCatch(pAppResource != null, , "Resource manager not found!"); + + pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles); + + if (_currentViewStyle == APPCONTROL_VIEW_IMPORT) + { + itemCount = _pFilenames->GetCount(); + } + + else + { + if (_pFilenames->GetCount() == 0) + { + if (_pLabelNumberOfItems->GetShowState() == true) + { + _pLabelNumberOfItems->SetShowState(false); + _pLabelNumberOfItems->Draw(); + + if (_selectionMode == SELECTION_MODE_MULTIPLE) + { + _pListView->SetSize(__defaultListViewBounds.width, __defaultListViewBounds.height); + _pListView->Invalidate(true); + } + } + } + else + { + if (_pLabelNumberOfItems->GetShowState() == false && _selectionMode != SELECTION_MODE_SINGE && _currentViewStyle == APPCONTROL_VIEW_DEFAULT) + { + _pLabelNumberOfItems->SetShowState(true); + } + + if (_selectionMode == SELECTION_MODE_MULTIPLE) + { + _pListView->SetSize(__defaultListViewBounds.width, __defaultListViewBounds.height - _pLabelNumberOfItems->GetHeight()); + _pListView->Invalidate(true); + } + _itemSelectedCount.Clear(); + _itemSelectedCount.Append(selectFiles); + _pLabelNumberOfItems->SetText(_itemSelectedCount); + _pLabelNumberOfItems->Invalidate(true); + } + } + AppLogDebug("Exit %s", GetErrorMessage(GetLastResult())); + itemCount = _pFilenames->GetCount(); + } + else + { + itemCount = 0; + } + return itemCount; + CATCH: + AppLogDebug("Failed to get count"); + return 0; +} + +ContentListItem* +SubBaseSelection::CreateDefaultContentItem(int index, int itemWidth) +{ + AppLogDebug("Entry"); + result r = E_SUCCESS; + Font font; + String filename; + String folderIconPath; + String fontName; + String searchedString; + String cacheImagePath; + + PlayerState audioPlayerStatus; + ContentType contentType = CONTENT_TYPE_UNKNOWN; + + ContentListItem* pCustomItem = null; + Bitmap* pFetchedCacheImage = null; + Bitmap* pThumbnailImage = null; + HashMap* pCacheList = null; + + Dimension thumbnailDimension(W_LISTVIEW_ITEM_BITMAP, H_LISTVIEW_ITEM_BITMAP); + Dimension textDimension(itemWidth - W_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW); + AppResource* pAppResource = null; + DirectoryEntry* pFileDetails = null; + + int w_Title = 0; + + w_Title = itemWidth - ((W_LISTVIEW_ITEM_BITMAP * 4) + (4 * X_LISTVIEW)); + TryCatch(_pFilenames != null, , "Filename list if empty!"); + + pAppResource = Application::GetInstance()->GetAppResource(); + TryCatch(pAppResource != null, , "Resource manager not found!"); + + pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW); + TryCatch(pCustomItem != null, , "Failed to alloated customitem"); + + pFileDetails = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index)); + if (pFileDetails != null) + { + filename = pFileDetails->GetFileName(); + + contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath()); + pCacheList = CacheManager::GetInstance()->GetCacheHashMap(); + if (_pThumbnailManager != null) + { + if (pFileDetails->IsDirectory()) + { + pCustomItem->SetThumbnail(_pFolderBitmap); + _annexStyle = ANNEX_STYLE_NORMAL; + pCustomItem->SetListAnnexStyle(_annexStyle); + } + else + { + if (pFileDetails->GetBitmap() == null) + { + if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)) + { + if (pFileDetails != null) + { + cacheImagePath = pFileDetails->GetFullFilePath(); + AppLogDebug("cache path is %S",cacheImagePath.GetPointer()); + } + + if ((pCacheList->GetValue(cacheImagePath)) != null) + { + pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath)); + } + } + + if (pFetchedCacheImage != null) + { + AppLogDebug("image taken from cachemanager"); + pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath); + pCustomItem->SetThumbnail(pThumbnailImage); + } + else + { + pFileDetails->SetDummy(true); + pCustomItem->SetThumbnail(_pDummyImage); + AppLogDebug("call to thumbnail manager"); + } + + //r = _pFolderEntryPM->InitThumbnailManager(index); + } + else + { + pCustomItem->SetThumbnail(pFileDetails->GetBitmap()); + } + + if (_selectionMode == SELECTION_MODE_SINGE) + { + _annexStyle = ANNEX_STYLE_RADIO; + pCustomItem->SetListAnnexStyle(_annexStyle); + } + else if (_selectionMode == SELECTION_MODE_MULTIPLE) + { + _annexStyle = ANNEX_STYLE_MARK; + pCustomItem->SetListAnnexStyle(_annexStyle); + } + else if (_selectionMode == SELECTION_MODE_NONE) + { + _annexStyle = ANNEX_STYLE_NORMAL; + pCustomItem->SetListAnnexStyle(_annexStyle); + } + + if (contentType == CONTENT_TYPE_AUDIO) + { + if (_pAudioPlayer != null) + { + audioPlayerStatus = _pAudioPlayer->GetState(); + + if (audioPlayerStatus == PLAYER_STATE_CLOSED) + { + pCustomItem->SetAudioBitmap(_pAudioPlay, null); + } + + if (_currentAudioPlayIndex == index) + { + if (audioPlayerStatus == PLAYER_STATE_PLAYING) + { + pCustomItem->SetAudioBitmap(null, _pAudioPause); + } + //else if (audioPlayerStatus == PLAYER_STATE_PAUSED || audioPlayerStatus == PLAYER_STATE_ENDOFCLIP) + else + { + pCustomItem->SetAudioBitmap(_pAudioPlay, null); + } + } + else + { + pCustomItem->SetAudioBitmap(_pAudioPlay, null); + } + } + else + { + pCustomItem->SetAudioBitmap(_pAudioPlay, null); + } + } + } + } + } + + if (!filename.IsEmpty()) + { + pCustomItem->SetTitle(filename, searchedString); + } + pCustomItem->MakeAppControlFormListItem(); + + AppLogDebug("Exit %s", GetErrorMessage(r)); + + return pCustomItem; + + CATCH: + //Free EnrichedText + if (_pAudioPlay != null) + { + delete _pAudioPlay; + _pAudioPlay = null; + } + + if (_pAudioPause != null) + { + delete _pAudioPause; + _pAudioPause = null; + } + + AppLogDebug("Exit %s", GetErrorMessage(GetLastResult())); + return null; +} + +void +SubBaseSelection::OnThumbnailReceived(ThumbRequest* pThumbReq) +{ + result res = E_SUCCESS; + AppLogDebug("Enter"); + + if (_pFolderEntryPM) + { + if (pThumbReq != null) + { + if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm()) + { + if (pThumbReq->pBitmap != null) + { + AppLogDebug("This Bitmap is not requested from same form"); + delete pThumbReq->pBitmap; + } + return; + } + } + + if (pThumbReq) + { + if (pThumbReq->iRquestId < _pFilenames->GetCount()) + { + + _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId); + + if (_pListView && _pListView->IsVisible()) + { + res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY); + } + } + } + else + { + _pFolderEntryPM->OnThumbnailResponseFailed(); + } + } + AppLogDebug("Exit %s", GetErrorMessage(res)); + return; +} + +void +SubBaseSelection::OnListViewItemStateChangedNotify(ViewType viewType) +{ + //empty Implementation +} + +void +SubBaseSelection::InitializePlayer(void) +{ + _pAudioPlayer = new (std::nothrow) Player(); + + if (_pAudioPlayer != null) + { + _pAudioPlayer->Construct(*this); + } +} + +void +SubBaseSelection::LoadMusicPlayer(const Tizen::Base::String& mediaFilepath, Tizen::Media::PlayerState PlayerCurrentState) +{ + result r = E_SUCCESS; + if (_pAudioPlayer != null && mediaFilepath.IsEmpty() == false) + { + if (_pAudioPlayer->GetState() != PLAYER_STATE_PAUSED) + { + if (_pAudioPlayer != null) + { + delete _pAudioPlayer; + _pAudioPlayer = null; + } + _pAudioPlayer = new (std::nothrow) Player(); + _pAudioPlayer->Construct(*this); + } + + r = _pAudioPlayer->OpenFile(mediaFilepath, false); + r = _pAudioPlayer->Play(); + r = _pAudioPlayer->SetLooping(false); + r = _pAudioPlayer->SetVolume(100); + } + AppLogDebug("Exit: %s", GetErrorMessage(r)); +} + +result +SubBaseSelection::InitializeAppRegistry(void) +{ + AppLogDebug("Entry"); + result r = E_SUCCESS; + int previousSortValue = 0; + AppRegistry* pAppRegistry = null; + String sortbyKeyName(L"SortBy"); + SortByType sortStyle = SORT_BY_TYPE_DATE_RECENT; + + pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry(); + + r = pAppRegistry->Add(sortbyKeyName, sortStyle); + + if (r == E_SUCCESS) + { + r = pAppRegistry->Save(); + } + else if (r == E_KEY_ALREADY_EXIST) + { + pAppRegistry->Get(sortbyKeyName, previousSortValue); + _storedSortStyle = static_cast< SortByType >(previousSortValue); + if (_storedSortStyle != null) + { + pAppRegistry->Set(sortbyKeyName, sortStyle); + r = pAppRegistry->Save(); + } + } + + AppLogDebug("Exit %s", GetErrorMessage(r)); + return r; +} + +result +SubBaseSelection::CreateLabelControl(void) +{ + AppLogDebug("Entry"); + result r = E_SUCCESS; + Color backgroundColor(68, 68, 68); + //Color textColor(Color(76, 81, 88)); + + _pLabelNumberOfItems = static_cast< Label* >(GetControl(L"IDC_LABEL_SELECTED")); + TryCatch(_pLabelNumberOfItems != null, , "applog: allocation failed for __pLabelNumberOfItems"); + +// _pLabelNumberOfItems->Construct(Rectangle(0, GetClientAreaBounds().height - H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL), _itemSelectedCount); +// _pLabelNumberOfItems->SetBackgroundColor(backgroundColor); +// _pLabelNumberOfItems->SetTextColor(Color::GetColor(COLOR_ID_WHITE)); + _pLabelNumberOfItems->SetTextHorizontalAlignment(ALIGNMENT_CENTER); +// _pLabelNumberOfItems->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + _pLabelNumberOfItems->SetTextConfig(ID_FONT_SIZE_26, LABEL_TEXT_STYLE_BOLD); + + if (_selectionMode == SELECTION_MODE_SINGE) + { + _pLabelNumberOfItems->SetShowState(false); + } + else + { + if (_currentViewStyle != APPCONTROL_VIEW_IMPORT) + { + _pLabelNumberOfItems->SetShowState(true); + } + } + +// r = AddControl(*_pLabelNumberOfItems); + AppLogDebug("Exit %s", GetErrorMessage(r)); + return r; + CATCH: + AppLogDebug("Exit %s", GetErrorMessage(r)); + r = GetLastResult(); + return r; +} + + +void +SubBaseSelection::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + AppLogDebug("Entry"); + String mediaPath; + String storagePath; + + switch (actionId) + { + case IDA_BTN_ATTACH: + { + UiApp* pApp = UiApp::GetInstance(); + ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected(); + ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED); + + if (pApp != null) + { + pApp->Terminate(); + } + } + break; +/* + case IDA_BTN_CANCEL: + { + + } + break;*/ + + case IDA_BTN_IMPORT: + { + UiApp* pApp = UiApp::GetInstance(); + + ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected(); + ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED); + + if (pApp != null) + { + pApp->Terminate(); + } + } + break; + + case IDA_BTN_EXPORT: + { + UiApp* pApp = UiApp::GetInstance(); + + ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected(); + ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED); + + if (pApp != null) + { + pApp->Terminate(); + } + } + break; + + case IDA_BTN_CREATE_FOLDER: + { + ArrayList* pArg = null; + Integer* pSourceSelected = null; + SceneManager* pSceneManager = null; + + pSceneManager = SceneManager::GetInstance(); + + pArg = new (std::nothrow) ArrayList(); + pArg->Construct(); + pSourceSelected = new (std::nothrow) Integer(SELECT_CREATE_FOLDER); + pArg->Add(pSourceSelected); + + _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath(); + pArg->Add(&_rootMediaPath); + + if (pSceneManager != null) + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg); + } + } + break; + + default: + break; + } + AppLogDebug("Exit %s", GetErrorMessage(GetLastResult())); +} + +void +SubBaseSelection::ClearSelectedItems(Tizen::Ui::Controls::ListView& listView) +{ + ArrayList* pCheckedKeys = null; + int itemCount = 0; + if (_pFileManager != null) + { + pCheckedKeys = static_cast< ArrayList* >(_pFileManager->GetCheckedList()->GetKeysN()); + AppLogDebug("Get count is %d",pCheckedKeys->GetCount()); + for (itemCount=0; itemCountGetCount();itemCount++) + { + Integer* currentIndex = static_cast(pCheckedKeys->GetAt(itemCount)); + listView.SetItemChecked(currentIndex->ToInt(), false); + } + _pFileManager->ClearCheckedList(); + } +} + +void +SubBaseSelection::ResetFooter(void) +{ + AppResource* pAppResource = null; + String selectFiles; + + pAppResource = Application::GetInstance()->GetAppResource(); + pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles); + + if (_pListView != null) + { + ClearSelectedItems(*_pListView); + _pFooter->SetItemEnabled(0,false); + _pFooter->Invalidate(true); + _itemSelectedCount.Clear(); + _itemSelectedCount.Append(selectFiles); + _pLabelNumberOfItems->SetText(_itemSelectedCount); + _pLabelNumberOfItems->Invalidate(true); + } +} + +void +SubBaseSelection::OnPlayerAudioFocusChanged (void) +{ + //Empty Implementation. +} + +void +SubBaseSelection::OnFormBackRequested(Form& source) +{ + String currentPath; + String parentPath; + result r = E_SUCCESS; + SceneManager* pSceneManager = null; + pSceneManager = SceneManager::GetInstance(); + currentPath = FolderNavigationPresentationModel::GetCurrentPath(); + + if (_currentViewStyle != APPCONTROL_VIEW_EXPORT) + { + ResetFooter(); + } + + if (_pAudioPlayer != null) + { + if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING) + { + _pAudioPlayer->Stop(); + } + } + if (currentPath == BasePresentationModel::GetMediaPath() || currentPath == BasePresentationModel::GetSdCardPath()) + { + FolderNavigationPresentationModel::SetCurrentFilePath(currentPath); + ShowHomeView(); + } + else + { + parentPath = FolderNavigationPresentationModel::GetParentPath(); + + FolderNavigationPresentationModel::SetCurrentFilePath(parentPath); + r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null); + } +} + +void +SubBaseSelection::ShowHomeView(void) +{ + SceneManager* pSceneManager = null; + String topMostFileSelection(L"ScnTempForm"); + pSceneManager = SceneManager::GetInstance(); + if (pSceneManager != null) + { + IList* pArgs = new (std::nothrow) ArrayList(); + pArgs->Add(new (std::nothrow) Integer(APPCONTROL_STATE_SELECTED)); + if (pSceneManager->IsSceneAlive(topMostFileSelection)) + { + pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), pArgs); + } + else + { + pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), pArgs); + } + } +} + +ContentListItem* +SubBaseSelection::CreateExportListViewItem(int listItemIndex, int listItemWidth) +{ + AppLogDebug("ENTER"); + + Font font; + + String filename; + String folderIconPath; + String imageIconPath; + String fontName; + String searchedText; + String fileExtension; + String creationDate; + String searchedString; + String selectAll; + String fullFilePath; + String cacheImagePath; + + HashMap* pCacheList = null; + Bitmap* pFetchedCacheImage = null; + Bitmap* pThumbnailImage = null; + + DateTime dateCreated; + Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP); + Dimension textDimension(listItemWidth - W_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW); + + DirectoryEntry* pFileDetails = null; + + ContentListItem* pCustomItem = null; + ContentType contentType = CONTENT_TYPE_UNKNOWN; + + //AppRegistry* pAppRegistry = null; + //pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry(); + + TryCatch(_pFilenames != null, , "MfMyFilesApp::Filename list if empty!"); + TryCatch(_pFilenames->GetCount() != 0, , "MfMyFilesApp::Filename count is Zero!"); + + pCustomItem = new (std::nothrow) ContentListItem(listItemWidth, H_ITEM_LISTVIEW); + TryCatch(pCustomItem != null, , "MfMyFilesApp::Failed to allocate Memory to pCustomItem"); + + //Get the Directory Entry for the element at index from the Filenames list. + + pFileDetails = static_cast< DirectoryEntry* >(_pFilenames->GetAt(listItemIndex)); + TryCatch(pFileDetails != null, , "MfMyFilesApp::Failed to fetch FileDetails from __pFileNames!"); + + pCacheList = CacheManager::GetInstance()->GetCacheHashMap(); + + //Set the filename of the element at index index + filename = pFileDetails->GetFileName(); + fullFilePath = pFileDetails->GetFullFilePath(); + + //If the registry key value is set for show extension append the extension of the filename else do not. + + if (!pFileDetails->GetFileExtension().IsEmpty()) + { + filename = filename + "." + pFileDetails->GetFileExtension(); + } + + + if (pFileDetails->IsDirectory()) + { + pCustomItem->SetThumbnail(_pFolderBitmap); + } + else + { + pCustomItem->SetDescColor(Color::GetColor(COLOR_ID_GREY)); + + contentType = ContentManagerUtil::CheckContentType(fullFilePath); + + if (pFileDetails->GetBitmap() == null && pFileDetails->IstDummy()) + { + if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)) + { + if (pFileDetails != null) + { + cacheImagePath = pFileDetails->GetFullFilePath(); + AppLogDebug("cache path is %S",cacheImagePath.GetPointer()); + } + + if ((pCacheList->GetValue(cacheImagePath)) != null) + { + pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath)); + } + } + + if (pFetchedCacheImage != null) + { + AppLogDebug("image taken from cachemanager"); + pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath); + pCustomItem->SetThumbnail(pThumbnailImage); + } + else + { + pFileDetails->SetDummy(true); + pCustomItem->SetThumbnail(_pDummyImage); + AppLogDebug("call to thumbnail manager"); + } + } + else + { + AppLogDebug("BITMAP FOUND : NOT NEED TO DO GETTHUMBNAIL"); + pCustomItem->SetThumbnail(pFileDetails->GetBitmap()); + } + } + + pCustomItem->SetTitle(filename, searchedText); + + pCustomItem->Make(); + + AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult())); + + return pCustomItem; + +CATCH: + if (pCustomItem != null) + { + delete pCustomItem; + pCustomItem = null; + } + return null; +} diff --git a/src/MfSubFolderFileListForm.cpp b/src/MfSubFolderFileListForm.cpp index 7789ab4..759f184 100644 --- a/src/MfSubFolderFileListForm.cpp +++ b/src/MfSubFolderFileListForm.cpp @@ -997,10 +997,8 @@ void SubFolderFileListForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs) { Integer* pFileProcessingResult = null; - HashMap* pCacheList = null; - DirectoryEntry* pCurrentEntry = null; - bool cacheKeyStatus = false; String cachePath; + TryCatch(pArgs != null, , "Argument list received is invalid!"); pFileProcessingResult = (Integer*) pArgs->GetAt(0); diff --git a/src/MfTopLevelDirectoryMoveCopy.cpp b/src/MfTopLevelDirectoryMoveCopy.cpp index 032495e..7973430 100644 --- a/src/MfTopLevelDirectoryMoveCopy.cpp +++ b/src/MfTopLevelDirectoryMoveCopy.cpp @@ -1,752 +1,752 @@ -// -// Copyright (c) 2012 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -/** - * @file: MfTopLevelDirectoryMoveCopy.cpp - * @brief: - */ - -#include "MfTopLevelDirectoryMoveCopy.h" -#include "MfTypes.h" -#include "MfSceneRegister.h" - -using namespace Tizen::App; -using namespace Tizen::Base; -using namespace Tizen::Graphics; -using namespace Tizen::System; -using namespace Tizen::Ui; -using namespace Tizen::Ui::Controls; -using namespace Tizen::Ui::Scenes; -using namespace Tizen::Base::Collection; - -MfTopLevelDirectoryMoveCopy::MfTopLevelDirectoryMoveCopy(void) -: __pFolderList(null) -, __pPhone(null) -, __pMemoryCard(null) -, __pExternalStorage(null) -, __pPhonePress(null) -, __pMemoryCardPress(null) -, __pExternalStoragePress(null) -, __pFormFooter(null) -, __footerItemMovePaste(null) - -{ - //Empty Implementation. -} - -MfTopLevelDirectoryMoveCopy::~MfTopLevelDirectoryMoveCopy(void) -{ - AppLogDebug("Enter"); - - if (__pFolderList != null) - { - __pFolderList->RemoveAll(true); - delete __pFolderList; - } - - if (__pPhone != null) - { - delete __pPhone; - } - - if (__pMemoryCard != null) - { - delete __pMemoryCard; - } - - if (__pExternalStorage != null) - { - delete __pExternalStorage; - } - - if (__pPhonePress != null) - { - delete __pPhonePress; - } - - if (__pMemoryCardPress != null) - { - delete __pMemoryCardPress; - } - - if (__pExternalStoragePress != null) - { - delete __pExternalStoragePress; - } -} - -bool -MfTopLevelDirectoryMoveCopy::Initialize(void) -{ - Form::Construct(L"IDL_TOP_LEVEL_DIRECTORY_COPY_MOVE"); - return true; -} - -result -MfTopLevelDirectoryMoveCopy::OnInitializing(void) -{ - AppLogDebug("Enter"); - result r = E_SUCCESS; - AppResource* pAppResource = null; - - String headerDisplayText; - String buttonSearch; - String contextItemText; - String phoneStorage; - String* phonetext = null; - - ButtonItem footerItemMenu; - Header* pHeader = null; - - pAppResource = UiApp::GetInstance()->GetAppResource(); - if (pAppResource != null) - { - pAppResource->GetString(L"IDS_COM_BODY_MY_FILES", headerDisplayText); - pAppResource->GetString(L"IDS_MF_SK3_SEARCH", buttonSearch); - pAppResource->GetString(L"IDS_MF_SK_DETAILS", contextItemText); - pAppResource->GetString(L"IDS_MF_TAB_PHONE", phoneStorage); - - __pPhone = pAppResource->GetBitmapN(IDB_PHONE_ICON); - __pMemoryCard = pAppResource->GetBitmapN(IDB_SDCARD_ICON_TOP_LEVEL); - __pExternalStorage = pAppResource->GetBitmapN(IDB_EXTERNAL_ICON); - __pPhonePress = pAppResource->GetBitmapN(IDB_PHONE_ICON_PRESSED); - __pMemoryCardPress = pAppResource->GetBitmapN(IDB_SDCARD_ICON_PRESSED); - __pExternalStoragePress = pAppResource->GetBitmapN(IDB_EXTERNAL_ICON_PRESSED); - } - - - phonetext = new (std::nothrow) String(phoneStorage); - - __pFolderList = new (std::nothrow) ArrayList(); - //TryCatch(__pFolderList != null, , "MfMyFilesApp::Failed to Allocate memory to pTabList!"); - __pFolderList->Construct(); - - __pFolderList->Add(phonetext); - - __listItemCount = __pFolderList->GetCount(); - - - pHeader = GetHeader(); - if (pHeader != null) - { - pHeader-> SetTitleText(headerDisplayText); - } - __pFormFooter = GetFooter(); - SetFormBackEventListener(this); - - __footerItemMovePaste = new (std::nothrow) FooterItem(); - __footerItemMovePaste->Construct(IDA_BTN_FOOTER); - - if (__pFormFooter != null) - { - __pFormFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); - __pFormFooter->AddActionEventListener(*this); - __pFormFooter->SetBackButton(); - } - - __pListView = static_cast< ListView* >(GetControl("IDC_LISTVIEW_TOP_LEVEL_DIR_COPY_MOVE")); - if (__pListView != null) - { - __pListView->AddListViewItemEventListener(*this); - __pListView->SetItemProvider(*this); - __pListView->SetShowState(true); - } - - __pIconListView = static_cast< IconListView* >(GetControl("IDC_ICONLISTVIEW_TOP_MOVECOPY")); - if (__pIconListView != null) - { - __pIconListView->AddIconListViewItemEventListener(*this); - __pIconListView->SetItemProvider(*this); - __pIconListView->SetShowState(false); - } - - AppLogDebug("Exit"); - return r; -} - -result -MfTopLevelDirectoryMoveCopy::OnTerminating(void) -{ - __pFormFooter = GetFooter(); - if (__pFormFooter != null) - { - __pFormFooter->RemoveAllItems(); - __pFormFooter->RemoveAllButtons(); - } - return E_SUCCESS; -} - -void -MfTopLevelDirectoryMoveCopy::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) -{ - //Empty Implementation. -} - -void -MfTopLevelDirectoryMoveCopy::OnFormBackRequested(Tizen::Ui::Controls::Form& source) -{ - AppLogDebug("Enter"); - SceneManager* pSceneManager = SceneManager::GetInstance(); - if (pSceneManager != null) - { - pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_EDIT_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_DESTROY_OPTION_DESTROY), null); - } - return; - AppLogDebug("Exit"); -} - -void -MfTopLevelDirectoryMoveCopy::OnListViewContextItemStateChanged (Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status) -{ - //Empty Implementation. -} - -void -MfTopLevelDirectoryMoveCopy::OnListViewItemStateChanged (Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) -{ - AppLogDebug("Enter"); - //SceneManager* pSceneManager = SceneManager::GetInstance(); - ArrayList* pArgs = null; - Integer* pSourceForm = null; - - pArgs = new (std::nothrow) ArrayList(); - // FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath()); - pArgs->Construct(); - - switch (index) - { - case 0: - FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetMediaPath()); - FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE); - break; - case 1: - FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetSdCardPath()); - FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD); - - break; - case 2: - FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetUsbPath()); - FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_EXTERNAL); - break; - } - - //TryCatch(pArgs != null, , "pArgs is null."); - pSourceForm = new (std::nothrow) Integer(__sourceFromOption); - pArgs->Add(pSourceForm); - - SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_MOVE_COPY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pArgs); - AppLogDebug("Exit"); -} - -// IListViewItemProvider -Tizen::Ui::Controls::ListItemBase* -MfTopLevelDirectoryMoveCopy::CreateItem(int index, int itemWidth) -{ - String titleText; - String memoryCard; - String externalStorage; - String* tempStr; - - CustomItem* pItem = new CustomItem(); - AppResource* pAppResource = null; - pAppResource = UiApp::GetInstance()->GetAppResource(); - if (pAppResource != null) - { - pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", memoryCard); -#if 0 - pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", externalStorage); -#endif - } - - ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; - - pItem->Construct(Dimension(itemWidth, H_ITEM_LISTVIEW), style); - - switch (index) - { - case 0: - { - pItem->AddElement(Rectangle(X_LISTVIEW, Y_LISTVIEW, W_LISTVIEW_ITEM_BITMAP, H_LISTVIEW_ITEM_BITMAP), IDA_FORMAT_BITMAP, *__pPhone, __pPhonePress, null); - - } - break; - case 1: - { - pItem->AddElement(Rectangle(X_LISTVIEW, Y_LISTVIEW, W_LISTVIEW_ITEM_BITMAP, H_LISTVIEW_ITEM_BITMAP), IDA_FORMAT_BITMAP, *__pMemoryCard, __pMemoryCardPress, null); - - } - break; - case 2: - { - pItem->AddElement(Rectangle(X_LISTVIEW, Y_LISTVIEW, W_LISTVIEW_ITEM_BITMAP, H_LISTVIEW_ITEM_BITMAP), IDA_FORMAT_BITMAP, *__pExternalStorage, __pExternalStoragePress, null); - } - break; - default: - break; - } - - tempStr = static_cast(__pFolderList->GetAt(index)); - - titleText.Clear(); - titleText.Append(*tempStr); - - pItem->AddElement(Rectangle(W_LISTVIEW_ITEM_BITMAP + 2 * X_LISTVIEW, (H_ITEM_LISTVIEW - H_LISTVIEW_ITEM_TITLE) /2, itemWidth - (W_LISTVIEW_ITEM_BITMAP + 3 * X_LISTVIEW), H_LISTVIEW_ITEM_TITLE), - IDA_FORMAT_STRING, - titleText, - true); - - return pItem; -} - -bool -MfTopLevelDirectoryMoveCopy::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) -{ - AppLogDebug("Enter"); - if (pItem != null) - { - delete pItem; - pItem = null; - } - AppLogDebug("EXit"); - return true; -} - -bool -MfTopLevelDirectoryMoveCopy::DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem* pItem) -{ - if (pItem != null) - { - delete pItem; - pItem = null; - } - return true; -} - - -Tizen::Ui::Controls::IconListViewItem* -MfTopLevelDirectoryMoveCopy::CreateItem(int index) -{ - String titleText; - String* tempStr; - - IconListViewItem* pItem = null; - pItem = new (std::nothrow) IconListViewItem(); - - tempStr = static_cast(__pFolderList->GetAt(index)); - - titleText.Clear(); - titleText.Append(*tempStr); - - switch (index) - { - case 0: - { - pItem->Construct(*__pPhone, &titleText,__pPhonePress, null); - // pItem->AddElement(Rectangle(26, 19, 74, 74), IDA_FORMAT_BITMAP, *__pPhone, __pPhonePress, null); - - } - break; - case 1: - { - pItem->Construct(*__pMemoryCard, &titleText,__pMemoryCardPress, null); - // pItem->AddElement(Rectangle(26, 19, 74, 74), IDA_FORMAT_BITMAP, *__pMemoryCard, __pMemoryCardPress, null); - - } - break; - case 2: - { - pItem->Construct(*__pExternalStorage, &titleText,__pExternalStoragePress, null); - - // pItem->AddElement(Rectangle(26, 19, 74, 74), IDA_FORMAT_BITMAP, *__pExternalStorage, __pExternalStoragePress, null); - } - break; - default: - break; - } - - return pItem; -} - -int -MfTopLevelDirectoryMoveCopy::GetItemCount(void) -{ - AppLogDebug("Enter"); - return __listItemCount; -} - -//ISceneEventListener - -void -MfTopLevelDirectoryMoveCopy::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) -{ - AppLogDebug("Enter"); - Integer* pIsCopyOrMove = null; - - AppResource* pAppResource = null; - String footerItemText; - - pAppResource = UiApp::App::GetInstance()->GetAppResource(); - - //((MyFilesApp*) Application::GetInstance())->SetCurrentView(this); - - SceneManager::GetInstance()->AddSceneManagerEventListener(*this); - - DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this); -#if 0 - DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this); -#endif - - if (pArgs != null) - { - pIsCopyOrMove = static_cast< Integer* >(pArgs->GetAt(0)); - - if (pIsCopyOrMove != null) - { - if(pIsCopyOrMove->ToInt() == SELECT_COPY_BUTTON) - { - __sourceFromOption = SELECT_COPY_BUTTON; - if (pAppResource != null) - { - pAppResource->GetString(L"IDS_MF_SK3_PASTE_HERE", footerItemText); - - } - } - else - { - __sourceFromOption = SELECT_MOVE_BUTTON; - - if (pAppResource != null) - { - pAppResource->GetString(L"IDS_MF_SK3_MOVE_HERE", footerItemText); - - } - } - } - - __footerItemMovePaste->SetText(footerItemText); - __pFormFooter->AddItem(*__footerItemMovePaste); - __pFormFooter->SetItemEnabled(0, false); - - __pFormFooter->Invalidate(true); - - pArgs->RemoveAll(true); - delete pArgs; - pArgs = null; - } - - - AppLogDebug("Exit"); -} - -void -MfTopLevelDirectoryMoveCopy::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId) -{ - //((MyFilesApp*)Application::GetInstance())->SetCurrentView(null); - - DeviceManager::RemoveAllDeviceEventListeners(); - -} - -void -MfTopLevelDirectoryMoveCopy::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId, - const Tizen::Ui::Scenes::SceneId &nextSceneId) -{ - //Empty Implementation. -} - -void -MfTopLevelDirectoryMoveCopy::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId, - const Tizen::Ui::Scenes::SceneId ¤tSceneId) -{ - SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this); - - String deviceSateSdCard; - String deviceSateUSBStorage; - - String mounted = sdCardStatusMounted; - String unmounted = sdCardStatusUnmounted; - String inserted = usbDeviceStatusInserted; - String removed = usbDeviceStatusRemoved; - - String sdCardStorage; - String externalStorage; - String* pSDCard = null; -// String* pExternalStorage = null; - - DeviceManager::GetState(StorageCard, deviceSateSdCard); - DeviceManager::GetState(UsbClient, deviceSateUSBStorage); - - AppResource* pAppResource = null; - - pAppResource = UiApp::App::GetInstance()->GetAppResource(); - - if (pAppResource != null) - { - pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCardStorage); -#if 0 - pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", externalStorage); -#endif - - } - - __listItemCount = __pFolderList->GetCount(); - - if (deviceSateSdCard == mounted) - { - pSDCard = new (std::nothrow) String(sdCardStorage); - - __pFolderList->Add(pSDCard); - } - else if (deviceSateSdCard == unmounted && __listItemCount > 1) - { - __pFolderList->RemoveAt(__listItemCount - 1, true); - } - -#if 0 - if (deviceSateUSBStorage == inserted) - { - pExternalStorage = new (std::nothrow) String(externalStorage); - __pFolderList->Add(pExternalStorage); - } - else if (deviceSateUSBStorage == removed && __listItemCount > 1) - { - __pFolderList->RemoveAt(__listItemCount - 1); - } -#endif - - __listItemCount = __pFolderList->GetCount(); - - //__pListView->UpdateList(); - - SwitchViewType(); - -} - -void -MfTopLevelDirectoryMoveCopy::OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView& listView, int index, Tizen::Ui::Controls::IconListViewItemStatus status) -{ - AppLogDebug("Enter"); - //SceneManager* pSceneManager = SceneManager::GetInstance(); - ArrayList* pArgs = null; - Integer* pSourceForm = null; - - pArgs = new (std::nothrow) ArrayList(); - // FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath()); - pArgs->Construct(); - - switch (index) - { - case 0: - FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetMediaPath()); - FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE); - break; - case 1: - FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetSdCardPath()); - FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD); - - break; - case 2: - FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetUsbPath()); - FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_EXTERNAL); - break; - } - - //TryCatch(pArgs != null, , "pArgs is null."); - pSourceForm = new (std::nothrow) Integer(__sourceFromOption); - pArgs->Add(pSourceForm); - - SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_MOVE_COPY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pArgs); - AppLogDebug("Exit"); -} - -void -MfTopLevelDirectoryMoveCopy::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state) -{ - ComponentType currentDeviceType = COMPONENT_TYPE_NONE; - - String mounted = sdCardStatusMounted; - String unmounted = sdCardStatusUnmounted; - String inserted = usbDeviceStatusInserted; - String removed = usbDeviceStatusRemoved; - - String sdCardStorage; - String externalStorage; - - String* pSdCard = null; - String* pExternalStorage = null; - - AppResource* pAppResource = null; - - pAppResource = UiApp::App::GetInstance()->GetAppResource(); - - if (pAppResource != null) - { - pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCardStorage); -#if 0 - pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", externalStorage); -#endif - - } - - switch (deviceType) - { - case StorageCard: - { - currentDeviceType = COMPONENT_TYPE_STORAGE_CARD; - - if (state == mounted) - { - pSdCard = new (std::nothrow) String(sdCardStorage); - __pFolderList->Add(pSdCard); - - } - else if (state == unmounted) - { - __pFolderList->RemoveAt(__listItemCount - 1); - } - - __listItemCount = __pFolderList->GetCount(); - } - break; - - case UsbClient: - { - currentDeviceType = COMPONENT_TYPE_USB; - - if (state == inserted) - { - pExternalStorage = new (std::nothrow) String(externalStorage); - __pFolderList->Add(pExternalStorage); - } - else if (state == removed) - { - __pFolderList->RemoveAt(__listItemCount - 1); - } - __listItemCount = __pFolderList->GetCount(); - - } - break; - - default: - { - //Do Nothing. - } - break; - } - - __pListView->UpdateList(); - __pIconListView->UpdateList(); - - //OnDeviceChange(currentDeviceType, state); -} - - -void -MfTopLevelDirectoryMoveCopy::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus) -{ - switch (orientationStatus) - { - case ORIENTATION_STATUS_PORTRAIT: - { - //Do Nothing - } - break; - - case ORIENTATION_STATUS_LANDSCAPE: - { - //Do Nothing - } - break; - - default: - { - //Do Nothing - } - break; - } -} - -void -MfTopLevelDirectoryMoveCopy::SwitchViewType(void) -{ - result r = E_SUCCESS; - - AppRegistry* pAppRegistry = null; - - int viewType = VIEW_TYPE_AS_NONE; - - String viewStyleKeyName(L"ListDisplayType"); - - - pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry(); - r = pAppRegistry->Get(viewStyleKeyName, viewType); - - switch (viewType) - { - case VIEW_TYPE_AS_DETAILED_LIST: - { - if (__pIconListView != null && __pIconListView->IsVisible()) - { - __pIconListView->SetShowState(false); - } - if (__pListView != null) - { - __pListView->UpdateList(); - __pListView->SetShowState(true); - } - - } - break; - - case VIEW_TYPE_AS_NORMAL_LIST: - { - if (__pIconListView != null && __pIconListView->IsVisible()) - { - __pIconListView->SetShowState(false); - } - - if (__pListView != null) - { - __pListView->UpdateList(); - __pListView->SetShowState(true); - } - } - break; - - case VIEW_TYPE_AS_THUMBNAILS: - { - if (__pListView != null && __pListView->IsVisible()) - { - __pListView->SetShowState(false); - } - if (__pIconListView != null) - { - __pIconListView->UpdateList(); - __pIconListView->SetShowState(true); - } - } - break; - - default: - { - if (__pListView != null) - { - __pListView->UpdateList(); - } - } - break; - } -} +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file: MfTopLevelDirectoryMoveCopy.cpp + * @brief: + */ + +#include "MfTopLevelDirectoryMoveCopy.h" +#include "MfTypes.h" +#include "MfSceneRegister.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Base::Collection; + +MfTopLevelDirectoryMoveCopy::MfTopLevelDirectoryMoveCopy(void) +: __pFolderList(null) +, __pPhone(null) +, __pMemoryCard(null) +, __pExternalStorage(null) +, __pPhonePress(null) +, __pMemoryCardPress(null) +, __pExternalStoragePress(null) +, __pFormFooter(null) +, __footerItemMovePaste(null) + +{ + //Empty Implementation. +} + +MfTopLevelDirectoryMoveCopy::~MfTopLevelDirectoryMoveCopy(void) +{ + AppLogDebug("Enter"); + + if (__pFolderList != null) + { + __pFolderList->RemoveAll(true); + delete __pFolderList; + } + + if (__pPhone != null) + { + delete __pPhone; + } + + if (__pMemoryCard != null) + { + delete __pMemoryCard; + } + + if (__pExternalStorage != null) + { + delete __pExternalStorage; + } + + if (__pPhonePress != null) + { + delete __pPhonePress; + } + + if (__pMemoryCardPress != null) + { + delete __pMemoryCardPress; + } + + if (__pExternalStoragePress != null) + { + delete __pExternalStoragePress; + } +} + +bool +MfTopLevelDirectoryMoveCopy::Initialize(void) +{ + Form::Construct(L"IDL_TOP_LEVEL_DIRECTORY_COPY_MOVE"); + return true; +} + +result +MfTopLevelDirectoryMoveCopy::OnInitializing(void) +{ + AppLogDebug("Enter"); + result r = E_SUCCESS; + AppResource* pAppResource = null; + + String headerDisplayText; + String buttonSearch; + String contextItemText; + String phoneStorage; + String* phonetext = null; + + ButtonItem footerItemMenu; + Header* pHeader = null; + + pAppResource = UiApp::GetInstance()->GetAppResource(); + if (pAppResource != null) + { + pAppResource->GetString(L"IDS_COM_BODY_MY_FILES", headerDisplayText); + pAppResource->GetString(L"IDS_MF_SK3_SEARCH", buttonSearch); + pAppResource->GetString(L"IDS_MF_SK_DETAILS", contextItemText); + pAppResource->GetString(L"IDS_MF_TAB_PHONE", phoneStorage); + + __pPhone = pAppResource->GetBitmapN(IDB_PHONE_ICON); + __pMemoryCard = pAppResource->GetBitmapN(IDB_SDCARD_ICON_TOP_LEVEL); + __pExternalStorage = pAppResource->GetBitmapN(IDB_EXTERNAL_ICON); + __pPhonePress = pAppResource->GetBitmapN(IDB_PHONE_ICON_PRESSED); + __pMemoryCardPress = pAppResource->GetBitmapN(IDB_SDCARD_ICON_PRESSED); + __pExternalStoragePress = pAppResource->GetBitmapN(IDB_EXTERNAL_ICON_PRESSED); + } + + + phonetext = new (std::nothrow) String(phoneStorage); + + __pFolderList = new (std::nothrow) ArrayList(); + //TryCatch(__pFolderList != null, , "MfMyFilesApp::Failed to Allocate memory to pTabList!"); + __pFolderList->Construct(); + + __pFolderList->Add(phonetext); + + __listItemCount = __pFolderList->GetCount(); + + + pHeader = GetHeader(); + if (pHeader != null) + { + pHeader-> SetTitleText(headerDisplayText); + } + __pFormFooter = GetFooter(); + SetFormBackEventListener(this); + + __footerItemMovePaste = new (std::nothrow) FooterItem(); + __footerItemMovePaste->Construct(IDA_BTN_FOOTER); + + if (__pFormFooter != null) + { + __pFormFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + __pFormFooter->AddActionEventListener(*this); + __pFormFooter->SetBackButton(); + } + + __pListView = static_cast< ListView* >(GetControl("IDC_LISTVIEW_TOP_LEVEL_DIR_COPY_MOVE")); + if (__pListView != null) + { + __pListView->AddListViewItemEventListener(*this); + __pListView->SetItemProvider(*this); + __pListView->SetShowState(true); + } + + __pIconListView = static_cast< IconListView* >(GetControl("IDC_ICONLISTVIEW_TOP_MOVECOPY")); + if (__pIconListView != null) + { + __pIconListView->AddIconListViewItemEventListener(*this); + __pIconListView->SetItemProvider(*this); + __pIconListView->SetShowState(false); + } + + AppLogDebug("Exit"); + return r; +} + +result +MfTopLevelDirectoryMoveCopy::OnTerminating(void) +{ + __pFormFooter = GetFooter(); + if (__pFormFooter != null) + { + __pFormFooter->RemoveAllItems(); + __pFormFooter->RemoveAllButtons(); + } + return E_SUCCESS; +} + +void +MfTopLevelDirectoryMoveCopy::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + //Empty Implementation. +} + +void +MfTopLevelDirectoryMoveCopy::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + AppLogDebug("Enter"); + SceneManager* pSceneManager = SceneManager::GetInstance(); + if (pSceneManager != null) + { + pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_EDIT_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_DESTROY_OPTION_DESTROY), null); + } + return; + AppLogDebug("Exit"); +} + +void +MfTopLevelDirectoryMoveCopy::OnListViewContextItemStateChanged (Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status) +{ + //Empty Implementation. +} + +void +MfTopLevelDirectoryMoveCopy::OnListViewItemStateChanged (Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) +{ + AppLogDebug("Enter"); + //SceneManager* pSceneManager = SceneManager::GetInstance(); + ArrayList* pArgs = null; + Integer* pSourceForm = null; + + pArgs = new (std::nothrow) ArrayList(); + // FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath()); + pArgs->Construct(); + + switch (index) + { + case 0: + FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetMediaPath()); + FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE); + break; + case 1: + FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetSdCardPath()); + FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD); + + break; + case 2: + FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetUsbPath()); + FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_EXTERNAL); + break; + } + + //TryCatch(pArgs != null, , "pArgs is null."); + pSourceForm = new (std::nothrow) Integer(__sourceFromOption); + pArgs->Add(pSourceForm); + + SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_MOVE_COPY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pArgs); + AppLogDebug("Exit"); +} + +// IListViewItemProvider +Tizen::Ui::Controls::ListItemBase* +MfTopLevelDirectoryMoveCopy::CreateItem(int index, int itemWidth) +{ + String titleText; + String memoryCard; + String externalStorage; + String* tempStr; + + CustomItem* pItem = new CustomItem(); + AppResource* pAppResource = null; + pAppResource = UiApp::GetInstance()->GetAppResource(); + if (pAppResource != null) + { + pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", memoryCard); +#if 0 + pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", externalStorage); +#endif + } + + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + + pItem->Construct(Dimension(itemWidth, H_ITEM_LISTVIEW), style); + + switch (index) + { + case 0: + { + pItem->AddElement(Rectangle(X_LISTVIEW, Y_LISTVIEW, W_LISTVIEW_ITEM_BITMAP, H_LISTVIEW_ITEM_BITMAP), IDA_FORMAT_BITMAP, *__pPhone, __pPhonePress, null); + + } + break; + case 1: + { + pItem->AddElement(Rectangle(X_LISTVIEW, Y_LISTVIEW, W_LISTVIEW_ITEM_BITMAP, H_LISTVIEW_ITEM_BITMAP), IDA_FORMAT_BITMAP, *__pMemoryCard, __pMemoryCardPress, null); + + } + break; + case 2: + { + pItem->AddElement(Rectangle(X_LISTVIEW, Y_LISTVIEW, W_LISTVIEW_ITEM_BITMAP, H_LISTVIEW_ITEM_BITMAP), IDA_FORMAT_BITMAP, *__pExternalStorage, __pExternalStoragePress, null); + } + break; + default: + break; + } + + tempStr = static_cast(__pFolderList->GetAt(index)); + + titleText.Clear(); + titleText.Append(*tempStr); + + pItem->AddElement(Rectangle(W_LISTVIEW_ITEM_BITMAP + 2 * X_LISTVIEW, (H_ITEM_LISTVIEW - H_LISTVIEW_ITEM_TITLE) /2, itemWidth - (W_LISTVIEW_ITEM_BITMAP + 3 * X_LISTVIEW), H_LISTVIEW_ITEM_TITLE), + IDA_FORMAT_STRING, + titleText, + true); + + return pItem; +} + +bool +MfTopLevelDirectoryMoveCopy::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) +{ + AppLogDebug("Enter"); + if (pItem != null) + { + delete pItem; + pItem = null; + } + AppLogDebug("EXit"); + return true; +} + +bool +MfTopLevelDirectoryMoveCopy::DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem* pItem) +{ + if (pItem != null) + { + delete pItem; + pItem = null; + } + return true; +} + + +Tizen::Ui::Controls::IconListViewItem* +MfTopLevelDirectoryMoveCopy::CreateItem(int index) +{ + String titleText; + String* tempStr; + + IconListViewItem* pItem = null; + pItem = new (std::nothrow) IconListViewItem(); + + tempStr = static_cast(__pFolderList->GetAt(index)); + + titleText.Clear(); + titleText.Append(*tempStr); + + switch (index) + { + case 0: + { + pItem->Construct(*__pPhone, &titleText,__pPhonePress, null); + // pItem->AddElement(Rectangle(26, 19, 74, 74), IDA_FORMAT_BITMAP, *__pPhone, __pPhonePress, null); + + } + break; + case 1: + { + pItem->Construct(*__pMemoryCard, &titleText,__pMemoryCardPress, null); + // pItem->AddElement(Rectangle(26, 19, 74, 74), IDA_FORMAT_BITMAP, *__pMemoryCard, __pMemoryCardPress, null); + + } + break; + case 2: + { + pItem->Construct(*__pExternalStorage, &titleText,__pExternalStoragePress, null); + + // pItem->AddElement(Rectangle(26, 19, 74, 74), IDA_FORMAT_BITMAP, *__pExternalStorage, __pExternalStoragePress, null); + } + break; + default: + break; + } + + return pItem; +} + +int +MfTopLevelDirectoryMoveCopy::GetItemCount(void) +{ + AppLogDebug("Enter"); + return __listItemCount; +} + +//ISceneEventListener + +void +MfTopLevelDirectoryMoveCopy::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + AppLogDebug("Enter"); + Integer* pIsCopyOrMove = null; + + AppResource* pAppResource = null; + String footerItemText; + + pAppResource = UiApp::App::GetInstance()->GetAppResource(); + + //((MyFilesApp*) Application::GetInstance())->SetCurrentView(this); + + SceneManager::GetInstance()->AddSceneManagerEventListener(*this); + + DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this); +#if 0 + DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this); +#endif + + if (pArgs != null) + { + pIsCopyOrMove = static_cast< Integer* >(pArgs->GetAt(0)); + + if (pIsCopyOrMove != null) + { + if(pIsCopyOrMove->ToInt() == SELECT_COPY_BUTTON) + { + __sourceFromOption = SELECT_COPY_BUTTON; + if (pAppResource != null) + { + pAppResource->GetString(L"IDS_MF_SK3_PASTE_HERE", footerItemText); + + } + } + else + { + __sourceFromOption = SELECT_MOVE_BUTTON; + + if (pAppResource != null) + { + pAppResource->GetString(L"IDS_MF_SK3_MOVE_HERE", footerItemText); + + } + } + } + + __footerItemMovePaste->SetText(footerItemText); + __pFormFooter->AddItem(*__footerItemMovePaste); + __pFormFooter->SetItemEnabled(0, false); + + __pFormFooter->Invalidate(true); + + pArgs->RemoveAll(true); + delete pArgs; + pArgs = null; + } + + + AppLogDebug("Exit"); +} + +void +MfTopLevelDirectoryMoveCopy::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ + //((MyFilesApp*)Application::GetInstance())->SetCurrentView(null); + + DeviceManager::RemoveAllDeviceEventListeners(); + +} + +void +MfTopLevelDirectoryMoveCopy::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId, + const Tizen::Ui::Scenes::SceneId &nextSceneId) +{ + //Empty Implementation. +} + +void +MfTopLevelDirectoryMoveCopy::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId, + const Tizen::Ui::Scenes::SceneId ¤tSceneId) +{ + SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this); + + String deviceSateSdCard; + String deviceSateUSBStorage; + + String mounted = sdCardStatusMounted; + String unmounted = sdCardStatusUnmounted; + String inserted = usbDeviceStatusInserted; + String removed = usbDeviceStatusRemoved; + + String sdCardStorage; + String externalStorage; + String* pSDCard = null; +// String* pExternalStorage = null; + + DeviceManager::GetState(StorageCard, deviceSateSdCard); + DeviceManager::GetState(UsbClient, deviceSateUSBStorage); + + AppResource* pAppResource = null; + + pAppResource = UiApp::App::GetInstance()->GetAppResource(); + + if (pAppResource != null) + { + pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCardStorage); +#if 0 + pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", externalStorage); +#endif + + } + + __listItemCount = __pFolderList->GetCount(); + + if (deviceSateSdCard == mounted) + { + pSDCard = new (std::nothrow) String(sdCardStorage); + + __pFolderList->Add(pSDCard); + } + else if (deviceSateSdCard == unmounted && __listItemCount > 1) + { + __pFolderList->RemoveAt(__listItemCount - 1, true); + } + +#if 0 + if (deviceSateUSBStorage == inserted) + { + pExternalStorage = new (std::nothrow) String(externalStorage); + __pFolderList->Add(pExternalStorage); + } + else if (deviceSateUSBStorage == removed && __listItemCount > 1) + { + __pFolderList->RemoveAt(__listItemCount - 1); + } +#endif + + __listItemCount = __pFolderList->GetCount(); + + //__pListView->UpdateList(); + + SwitchViewType(); + +} + +void +MfTopLevelDirectoryMoveCopy::OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView& listView, int index, Tizen::Ui::Controls::IconListViewItemStatus status) +{ + AppLogDebug("Enter"); + //SceneManager* pSceneManager = SceneManager::GetInstance(); + ArrayList* pArgs = null; + Integer* pSourceForm = null; + + pArgs = new (std::nothrow) ArrayList(); + // FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath()); + pArgs->Construct(); + + switch (index) + { + case 0: + FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetMediaPath()); + FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE); + break; + case 1: + FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetSdCardPath()); + FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD); + + break; + case 2: + FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetUsbPath()); + FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_EXTERNAL); + break; + } + + //TryCatch(pArgs != null, , "pArgs is null."); + pSourceForm = new (std::nothrow) Integer(__sourceFromOption); + pArgs->Add(pSourceForm); + + SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_MOVE_COPY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pArgs); + AppLogDebug("Exit"); +} + +void +MfTopLevelDirectoryMoveCopy::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state) +{ + ComponentType currentDeviceType = COMPONENT_TYPE_NONE; + + String mounted = sdCardStatusMounted; + String unmounted = sdCardStatusUnmounted; + String inserted = usbDeviceStatusInserted; + String removed = usbDeviceStatusRemoved; + + String sdCardStorage; + String externalStorage; + + String* pSdCard = null; + String* pExternalStorage = null; + + AppResource* pAppResource = null; + + pAppResource = UiApp::App::GetInstance()->GetAppResource(); + + if (pAppResource != null) + { + pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCardStorage); +#if 0 + pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", externalStorage); +#endif + + } + + switch (deviceType) + { + case StorageCard: + { + currentDeviceType = COMPONENT_TYPE_STORAGE_CARD; + + if (state == mounted) + { + pSdCard = new (std::nothrow) String(sdCardStorage); + __pFolderList->Add(pSdCard); + + } + else if (state == unmounted) + { + __pFolderList->RemoveAt(__listItemCount - 1); + } + + __listItemCount = __pFolderList->GetCount(); + } + break; + + case UsbClient: + { + currentDeviceType = COMPONENT_TYPE_USB; + + if (state == inserted) + { + pExternalStorage = new (std::nothrow) String(externalStorage); + __pFolderList->Add(pExternalStorage); + } + else if (state == removed) + { + __pFolderList->RemoveAt(__listItemCount - 1); + } + __listItemCount = __pFolderList->GetCount(); + + } + break; + + default: + { + //Do Nothing. + } + break; + } + + __pListView->UpdateList(); + __pIconListView->UpdateList(); + + //OnDeviceChange(currentDeviceType, state); +} + + +void +MfTopLevelDirectoryMoveCopy::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus) +{ + switch (orientationStatus) + { + case ORIENTATION_STATUS_PORTRAIT: + { + //Do Nothing + } + break; + + case ORIENTATION_STATUS_LANDSCAPE: + { + //Do Nothing + } + break; + + default: + { + //Do Nothing + } + break; + } +} + +void +MfTopLevelDirectoryMoveCopy::SwitchViewType(void) +{ + result r = E_SUCCESS; + + AppRegistry* pAppRegistry = null; + + int viewType = VIEW_TYPE_AS_NONE; + + String viewStyleKeyName(L"ListDisplayType"); + + + pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry(); + r = pAppRegistry->Get(viewStyleKeyName, viewType); + + switch (viewType) + { + case VIEW_TYPE_AS_DETAILED_LIST: + { + if (__pIconListView != null && __pIconListView->IsVisible()) + { + __pIconListView->SetShowState(false); + } + if (__pListView != null) + { + __pListView->UpdateList(); + __pListView->SetShowState(true); + } + + } + break; + + case VIEW_TYPE_AS_NORMAL_LIST: + { + if (__pIconListView != null && __pIconListView->IsVisible()) + { + __pIconListView->SetShowState(false); + } + + if (__pListView != null) + { + __pListView->UpdateList(); + __pListView->SetShowState(true); + } + } + break; + + case VIEW_TYPE_AS_THUMBNAILS: + { + if (__pListView != null && __pListView->IsVisible()) + { + __pListView->SetShowState(false); + } + if (__pIconListView != null) + { + __pIconListView->UpdateList(); + __pIconListView->SetShowState(true); + } + } + break; + + default: + { + if (__pListView != null) + { + __pListView->UpdateList(); + } + } + break; + } +}