2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file: MfSubFolderSelection.cpp
19 * @brief: This file contains the implementation of SubFolderSelection class,
20 * which acts an AppControl for the SubDirectories.
23 #include "MfMyFilesApp.h"
24 #include "MfSubFolderSelection.h"
25 #include "MfSceneRegister.h"
26 #include "MfUtility.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Base::Utility;
32 using namespace Tizen::Content;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Io;
35 using namespace Tizen::Locales;
36 using namespace Tizen::Media;
37 using namespace Tizen::System;
38 using namespace Tizen::Telephony;
39 using namespace Tizen::Ui;
40 using namespace Tizen::Ui::Controls;
41 using namespace Tizen::Ui::Scenes;
44 SubFolderSelection::SubFolderSelection(void)
45 : __pReceivedFilename(null)
48 , __pMoreContextMenu(null)
49 , __pLabelDisplayPath(null)
50 , __pFileEventManager(null)
55 SubFolderSelection::~SubFolderSelection(void)
57 if (__pHomeButton != null)
62 if (__pUpButton != null)
66 if (__pMoreContextMenu != null)
68 delete __pMoreContextMenu;
70 if (__pFileEventManager != null)
72 __pFileEventManager->RemovePath(_rootMediaPath);
73 delete __pFileEventManager;
78 SubFolderSelection::operator =(const SubFolderSelection& pSubFolderSelection)
83 SubFolderSelection::SubFolderSelection(const SubFolderSelection& pSubFolderSelection)
90 SubFolderSelection::Initialize(void)
93 Form::Construct(L"IDL_SUB_FOLDER_FILE_SELECTION");
99 SubFolderSelection::OnInitializing(void)
101 AppLogDebug("Entry");
102 result r = E_SUCCESS;
111 String buttonExportHere;
113 ButtonItem footerItemMenu;
114 int xPos = 0, yPos = 0;
116 CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_SELECTION;
118 AppResource* pAppResource = null;
119 Bitmap* pBitmapHomeButton = null;
120 Bitmap* pBitmapUpButton = null;
121 Bitmap* pBitmapHomeButtonPress = null;
122 Bitmap* pBitmapUpButtonPress = null;
123 Bitmap* pBitmap = null;
124 Bitmap* pBitmapPress = null;
125 Bitmap* pBitmapDisabled = null;
127 __pReceivedFilename = new (std::nothrow) String();
129 _pListView = static_cast< ListView* >(GetControl("IDC_SUB_FOLDER_SELECTION_LISTVIEW"));
130 TryCatch(_pListView != null, , "Failed to get list view control");
132 _pListView->AddListViewItemEventListener(*this);
133 _pListView->SetItemProvider(*this);
134 _pListView->SetShowState(false);
136 _selectionMode = ((MyFilesApp*) Application::GetInstance())->GetCurrentSelectionMode();
137 _currentFileType = ((MyFilesApp*) Application::GetInstance())->GetCurrentFileType();
138 _currentViewStyle = ((MyFilesApp*) Application::GetInstance())->GetCurrentView();
139 _currentExportFileType = ((MyFilesApp*) Application::GetInstance())->GetCurrentExportFileType();
141 __pLabelDisplayPath = static_cast< Label* >(GetControl("IDC_SUB_FOLDER_SELECTION_LABEL_DISPLAY_PATH"));
142 TryCatch(__pLabelDisplayPath != null, , "Label is Null");
144 pAppResource = UiApp::GetInstance()->GetAppResource();
145 TryCatch(pAppResource != null, , "Resource manager not found!");
147 displayPath = defaultPhoneBody;
148 displayPath.Append("/");
150 //pAppResource->GetString(L"IDS_MF_BUTTON_HOME", buttonHome);
151 pAppResource->GetString(L"IDS_COM_POP_ATTACH", buttonAttach);
152 pAppResource->GetString(L"IDS_COM_POP_CANCEL", buttonCancel);
153 pAppResource->GetString(L"IDS_EXPORT_HERE", buttonExportHere);
154 //pAppResource->GetString(L"IDS_MF_TAB_UP", buttonUp);
155 pBitmap = pAppResource->GetBitmapN(IDB_MORE, BITMAP_PIXEL_FORMAT_ARGB8888);
156 pBitmapPress = pAppResource->GetBitmapN(IDB_MORE_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
157 pBitmapDisabled = pAppResource->GetBitmapN(IDB_MORE_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888);
158 pBitmapHomeButton = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
159 pBitmapUpButton = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
160 pBitmapHomeButtonPress = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
161 pBitmapUpButtonPress = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
163 __displayPath = displayPath;
165 _pFolderBitmap = pAppResource->GetBitmapN(IDB_FOLDER, BITMAP_PIXEL_FORMAT_ARGB8888);
166 _pDummyImage = pAppResource->GetBitmapN(IDB_DUMMY_IMG, BITMAP_PIXEL_FORMAT_ARGB8888);
168 _pAudioPlay = MfUtility::MergeBitmapN(IDB_PLAY_OUTER_CIRCLE, IDB_PLAY, 64, 64);
169 _pAudioPause = MfUtility::MergeBitmapN(IDB_PLAY_OUTER_CIRCLE, IDB_PAUSE, 64, 64);
171 _pFooter = GetFooter();
173 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
175 pAppResource->GetString(L"IDS_EXPORT", buttonExport);
177 footerItemMenu.Construct(BUTTON_ITEM_STYLE_ICON, IDA_BTN_MORE);
180 pBitmap->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
181 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmap);
183 if (pBitmapPress != null)
185 pBitmapPress->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
186 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapPress);
188 if (pBitmapDisabled != null)
190 pBitmapDisabled->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
191 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapDisabled);
193 if (_pFooter != null)
195 _pFooter->GetPosition(xPos, yPos);
197 __pMoreContextMenu = new (std::nothrow) ContextMenu();
198 __pMoreContextMenu->Construct(Point(0 , yPos), CONTEXT_MENU_STYLE_LIST);
199 __pMoreContextMenu->AddActionEventListener(*this);
200 __pMoreContextMenu->SetShowState(true);
203 _pHeader = GetHeader();
204 TryCatch(_pHeader != null, , "Header is Null");
206 __pHomeButton = new (std::nothrow) ButtonItem();
207 __pHomeButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_HOME);
208 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapHomeButton);
209 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapHomeButtonPress);
211 __pUpButton = new (std::nothrow) ButtonItem();
212 __pUpButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_UP);
213 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapUpButton);
214 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapUpButtonPress);
216 _pHeader->SetButton(BUTTON_POSITION_LEFT, *__pHomeButton);
217 _pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pUpButton);
218 _pHeader->AddActionEventListener(*this);
220 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
222 _pExport = new (std::nothrow) FooterItem();
223 r = _pExport->Construct(IDA_BTN_EXPORT);
224 _pExport->SetText(buttonExportHere);
229 _pAttach = new (std::nothrow) FooterItem();
230 r = _pAttach->Construct(IDA_BTN_ATTACH);
231 _pAttach->SetText(buttonAttach);
234 TryCatch(_pFooter != null, , "Footer is Null");
236 if (_pFooter != null)
238 _pFooter->RemoveAllButtons();
239 _pFooter->RemoveAllItems();
240 _pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
242 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
244 _pFooter->AddItem(*_pExport);
245 _pFooter->SetButton(BUTTON_POSITION_LEFT, footerItemMenu);
246 //_pFooter->AddItem(*_pCreateFolder);
250 _pFooter->AddItem(*_pAttach);
253 //_pFooter->AddItem(*_pCancel);
254 _pFooter->AddActionEventListener(*this);
255 _pFooter->SetBackButton();
256 SetFormBackEventListener(this);
257 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
259 _pFooter->SetItemEnabled(0, false);
261 _pFooter->Invalidate(true);
264 CreateLabelControl();
266 _defaultListViewBounds = _pListView->GetBounds();
268 _pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
269 TryCatch(_pFolderEntryPM != null, , "Failed to allocate memory");
270 _pFolderEntryPM->Construct();
271 _pFolderEntryPM->SetSourceForm(createitemsource);
273 _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath();
274 _rootStoragePath = BasePresentationModel::GetSdCardPath();
276 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
278 _pFolderEntryPM->SetFolderEntryType(_currentFileType);
279 _pFolderEntryPM->SetFolderEntryPath(_rootMediaPath);
280 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
281 TryCatch(_pFilenames != null, , "MfMyFilesApp::Failed to allocate Memory to Filenames ArrayList");
284 _pThumbnailManager = ThumbnailManager::GetInstance();
285 TryCatch(_pThumbnailManager != null, , "Thumbnail Manager not found!");
287 _pFileManager = FolderEntryEditorPresentationModel::GetInstance();
288 TryCatch(_pFileManager != null, , "File Manager not found!");
290 InitializeAppRegistry();
292 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
294 __pLabelDisplayPath->SetShowState(true);
295 _pLabelNumberOfItems->SetShowState(false);
298 _pCallManager = new (std::nothrow) CallManager();
300 r = _pCallManager->Construct(*this);
301 TryCatch(r == E_SUCCESS, , "Failed to Construct CallManager");
303 AppLogDebug("Exit %s", GetErrorMessage(r));
306 DataBindingContext* pContext = null;
308 pContext = GetDataBindingContextN();
309 TryCatch(pContext != null, , "Failed to Fetch the DataBinding Context");
311 pContext->Bind(L"ID_APPCONTROL_DISPLAY_PATH", L"IDC_SUB_FOLDER_SELECTION_LABEL_DISPLAY_PATH", L"text", __displayPath, DATA_BINDING_DATA_TYPE_STRING, DATA_BINDING_FLOW_TWO_WAY, DATA_BINDING_TRIGGER_EXPLICIT, null, null, null);
317 delete pBitmapHomeButton;
318 delete pBitmapUpButton;
319 delete pBitmapHomeButtonPress;
320 delete pBitmapUpButtonPress;
321 delete pBitmapDisabled;
324 AppLogDebug("Exit: %s", GetErrorMessage(r));
328 if (pBitmapHomeButton != null)
330 delete pBitmapHomeButton;
331 pBitmapHomeButton = null;
334 if (pBitmapUpButton != null)
336 delete pBitmapUpButton;
337 pBitmapUpButton = null;
339 if (pBitmapHomeButtonPress != null)
341 delete pBitmapHomeButtonPress;
342 pBitmapHomeButtonPress = null;
344 if (pBitmapUpButtonPress != null)
346 delete pBitmapUpButtonPress;
347 pBitmapUpButtonPress = null;
350 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
355 SubFolderSelection::OnTerminating(void)
357 result r = E_SUCCESS;
359 _pHeader = GetHeader();
360 if (_pHeader != null)
362 _pHeader->RemoveAllButtons();
363 _pHeader->RemoveAllItems();
366 _pFooter = GetFooter();
367 if (_pFooter != null)
369 _pFooter->RemoveAllButtons();
370 _pFooter->RemoveAllItems();
377 SubFolderSelection::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
379 //empty implementation
383 SubFolderSelection::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
385 //empty implementation
389 SubFolderSelection::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
391 AppLogDebug("Entry");
392 result r = E_SUCCESS;
394 String selectedCount;
395 String selectedRootMediaPath;
396 DirectoryEntry* pDirStr = null;
398 int selectedItemsCount = 0;
400 AppResource* pAppResource = null;
401 SceneManager* pSceneManager = null;
402 ArrayList* pArgs = null;
403 bool itemStatus = false;
404 Integer currentIndex = index;
405 RelativeLayout* pLayout = null;
407 pArgs = new (std::nothrow) ArrayList();
410 pSceneManager = SceneManager::GetInstance();
411 pAppResource = Application::GetInstance()->GetAppResource();
412 TryCatch(pAppResource != null, , "Resource manager not found!");
414 pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles);
415 pAppResource->GetString(L"IDS_COM_BODY_SELECTED", selectedCount);
417 itemStatus = _pFileManager->GetCheckedList()->ContainsKey(currentIndex /*,itemStatus*/);
419 if (elementId == CONTENT_LIST_ITEM_TYPE_PLAY || elementId == CONTENT_LIST_ITEM_TYPE_PAUSE)
421 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
422 TryCatch(pDirStr != null, , "pDirStr is null");
426 listView.SetItemChecked(index, false);
430 listView.SetItemChecked(index, true);
433 if (_pAudioPlayer == null)
436 LoadMusicPlayer(pDirStr->GetFullFilePath(), PLAYER_STATE_INITIALIZED);
437 _previousAudioSelected = index;
438 _currentAudioPlayIndex = index;
439 _pListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
444 if (_previousAudioSelected == index)
446 if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING)
448 _pAudioPlayer->Pause();
452 LoadMusicPlayer(pDirStr->GetFullFilePath(), PLAYER_STATE_INITIALIZED);
457 _pAudioPlayer->Stop();
458 _pAudioPlayer->Close();
459 _pListView->RefreshList(_previousAudioSelected, LIST_REFRESH_TYPE_ITEM_MODIFY);
460 _previousAudioSelected = index;
462 LoadMusicPlayer(pDirStr->GetFullFilePath(), PLAYER_STATE_STOPPED);
464 _currentAudioPlayIndex = index;
465 _pListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
466 //listView.SetItemChecked(index, false);
470 if (_pFilenames != null) //start of FILENAME check if
472 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
474 if (pDirStr != null) //start of NULL check if
476 if (pDirStr->IsDirectory()) // start of DIRECTORY CHECK if
478 selectedRootMediaPath = pDirStr->GetFullFilePath();
479 nextFilename = pDirStr->GetFileName();
481 if (_rootMediaPath != null)
483 _rootMediaPath.Clear();
484 _rootMediaPath.Append(selectedRootMediaPath);
487 if (_pAudioPlayer != null)
489 if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING || _pAudioPlayer->GetState() == PLAYER_STATE_PAUSED)
491 _pAudioPlayer->Stop();
492 _pAudioPlayer->Close();
495 FolderNavigationPresentationModel::SetCurrentFilePath(_rootMediaPath);
497 pArgs->Add(&nextFilename);
498 pArgs->Add(&_rootMediaPath);
499 ClearSelectedItems(listView);
500 pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
501 } // end of DIRECTORY CHECK if
502 else //start of FILE CHECK else
504 if (listView.IsItemChecked(index) == true)
506 _pFileManager->AddCheckedListEntry(index, pDirStr);
510 _pFileManager->RemoveCheckedListEntry(index);
513 if (_selectionMode == SELECTION_MODE_SINGE)
515 if (listView.IsItemChecked(_storePreviousIndex) == true && _storePreviousIndex != index)
517 listView.SetItemChecked(_storePreviousIndex, false);
518 _pListView->RefreshList(_storePreviousIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
519 _pFileManager->RemoveCheckedListEntry(_storePreviousIndex);
521 _storePreviousIndex = index;
523 } //end of FILE CHECK else
524 } //end of NULL check if
526 for (itemcount = 0; itemcount <= GetItemCount(); itemcount++)
528 if (listView.IsItemChecked(itemcount) == true)
530 selectedItemsCount++;
534 if (selectedItemsCount != 0)
536 r = _pFooter->SetItemEnabled(0, true);
540 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
542 _pFooter->SetItemEnabled(0, false);
546 if (_selectionMode == SELECTION_MODE_MULTIPLE) // start of MULTIPLE_MODE_SELECTION if
549 pLayout = dynamic_cast <RelativeLayout*> (Form::GetLayoutN());
552 pLayout->SetRelation(*_pListView, _pLabelNumberOfItems,RECT_EDGE_RELATION_BOTTOM_TO_TOP);
555 if (selectedItemsCount > 0)
557 _itemSelectedCount.Clear();
558 _itemSelectedCount.Append(selectedCount);
559 _itemSelectedCount.Append(L"\x200E");
560 _itemSelectedCount.Append(L"(");
561 _itemSelectedCount.Append(selectedItemsCount);
562 _itemSelectedCount.Append(L")");
563 _itemSelectedCount.Append(L"\x200E");
564 _pLabelNumberOfItems->SetText(_itemSelectedCount);
568 _itemSelectedCount.Clear();
569 _itemSelectedCount.Append(selectFiles);
570 _pLabelNumberOfItems->SetText(_itemSelectedCount);
573 _pLabelNumberOfItems->Invalidate(true);
577 } //end of FILENAME check if
579 _pFooter->Invalidate(true);
581 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
585 if (_pFolderEntryPM != null)
587 delete _pFolderEntryPM;
588 _pFolderEntryPM = null;
590 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
594 SubFolderSelection::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
596 //empty implementation
600 SubFolderSelection::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
601 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
604 RelativeLayout* pLayout = null;
606 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
608 ((MyFilesApp*) Application::GetInstance())->SetAudioNotificationListener(this);
609 _itemSelectedCount.Clear();
611 if (_pFileManager != null)
613 if (!_pFileManager->IsCheckedListNull())
615 _pFileManager->ClearCheckedList();
618 if (_selectionMode == SELECTION_MODE_SINGE) // start of MULTIPLE_MODE_SELECTION if
620 pLayout = dynamic_cast <RelativeLayout*> (Form::GetLayoutN());
623 pLayout->SetRelation(*_pListView, this ,RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
631 __pReceivedFilename->Clear();
632 __pReceivedFilename->Append(*static_cast<String*>(pArgs->GetAt(0)));
636 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
638 String headerDisplayPath = FolderNavigationPresentationModel::GetCurrentPath();
639 SetHeaderTitleText(headerDisplayPath);
640 __pReceivedFilename->Clear();
644 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
648 pArgs->RemoveAll(false);
654 SubFolderSelection::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
655 const Tizen::Ui::Scenes::SceneId& nextSceneId)
657 DeviceManager::RemoveAllDeviceEventListeners();
658 ((MyFilesApp*)Application::GetInstance())->SetCurrentView(null);
659 ((MyFilesApp*) Application::GetInstance())->SetAudioNotificationListener(null);
660 _pFolderEntryPM->StopThumbnailManager(true);
662 if(__pFileEventManager != null)
664 __pFileEventManager->RemovePath(_rootMediaPath);
665 delete __pFileEventManager;
666 __pFileEventManager = null;
671 SubFolderSelection::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
673 AppLogDebug("Entry");
676 Bitmap* pBitmapCreateFolder = null;
677 AppResource* pAppResource = null;
678 pAppResource = UiApp::GetInstance()->GetAppResource();
679 if (pAppResource != null)
681 pAppResource->GetString(L"IDS_COM_BODY_CREATE_FOLDER", createFolder);
682 pBitmapCreateFolder = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
690 _pFolderEntryPM->InitThumbnailManager();
696 ShowParentDirectoryView();
697 _pFolderEntryPM->InitThumbnailManager();
703 __pMoreContextMenu->RemoveAllItems();
704 __pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
705 __pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
706 __pMoreContextMenu->AddItem(createFolder, IDA_BTN_CREATE_FOLDER, *pBitmapCreateFolder, null, null);
707 __pMoreContextMenu->SetShowState(true);
708 __pMoreContextMenu->Show();
714 SubBaseOnActionPerformed(source, actionId);
718 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
722 SubFolderSelection::ShowParentDirectoryView(void)
724 AppLogDebug("Entry");
725 result r = E_SUCCESS;
729 displayPath = defaultPhoneBody;
730 displayPath.Append("/");
732 ParentPath = FolderNavigationPresentationModel::GetParentPath();
733 //_pFileManager->ClearCheckedList();
735 if (FolderNavigationPresentationModel::GetCurrentPath() == BasePresentationModel::GetMediaPath() || FolderNavigationPresentationModel::GetCurrentPath() == BasePresentationModel::GetSdCardPath())
737 _pFileManager->ClearCheckedList();
742 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
747 if (_pAudioPlayer != null)
749 if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING || _pAudioPlayer->GetState() == PLAYER_STATE_PAUSED)
751 _pAudioPlayer->Stop();
752 _pAudioPlayer->Close();
755 _rootMediaPath.Clear();
756 _rootMediaPath.Append(ParentPath);
758 FolderNavigationPresentationModel::SetCurrentFilePath(_rootMediaPath);
760 SetParentDisplayPath();
761 SetHeaderTitleText(ParentPath);
763 //Remove the current files from the filenames list
764 if (_pFolderEntryPM != null)
766 _pFolderEntryPM->SetFolderEntryPath(ParentPath);
767 //Get the files in the parent path of the current view
768 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
769 TryCatch(_pFilenames != null, , "Failed to fetch ArrayList from the ContentBrowser!");
772 if (_pListView != null)
774 _pListView->UpdateList();
775 _storePreviousIndex = 0;
779 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
783 if (_pFolderEntryPM != null)
785 delete _pFolderEntryPM;
786 _pFolderEntryPM = null;
788 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
792 SubFolderSelection::SetParentDisplayPath(void)
796 String parentDisplayPath;
800 DataBindingContext* pContext = null;
801 pContext = GetDataBindingContextN();
803 if (pContext != null)
805 //Update binding on the source to fetch the current display path.
806 pContext->UpdateBinding(L"ID_APPCONTROL_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_SOURCE);
810 StringTokenizer tokenizer(__displayPath, delim);
812 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
813 //it is the last token
814 while (tokenizer.HasMoreTokens())
816 int tokenCount = tokenizer.GetTokenCount();
820 tokenizer.GetNextToken(token);
821 parentDisplayPath.Append(token);
822 parentDisplayPath.Append(L"/");
830 //Set the display path to that of the generated filepath from the tokenizer
831 __displayPath = parentDisplayPath;
834 if (pContext != null)
836 //Update Binding on the Target control to display the currently constructed path.
837 pContext->UpdateBinding(L"ID_APPCONTROL_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
840 if (pContext != null)
846 if (__pLabelDisplayPath != null)
848 __pLabelDisplayPath->SetText(__displayPath);
849 __pLabelDisplayPath->Invalidate(true);
854 SubFolderSelection::SetHeaderTitleText(Tizen::Base::String& filePath)
857 String parentFileName;
858 String delimiter(L"/");
859 StringTokenizer tokenizer(filePath, delimiter);
861 AppResource* pAppResource = null;
863 pAppResource = UiApp::App::GetInstance()->GetAppResource();
865 if (filePath == BasePresentationModel::GetMediaPath())
867 if (pAppResource != null)
869 pAppResource->GetString(L"IDS_MF_TAB_PHONE", parentFileName);
872 else if (filePath == BasePresentationModel::GetSdCardPath())
874 if (pAppResource != null)
876 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", parentFileName);
881 while (tokenizer.HasMoreTokens())
883 int tokenCount = tokenizer.GetTokenCount();
887 tokenizer.GetNextToken(parentFileName);
891 tokenizer.GetNextToken(token);
896 if (_pHeader != null)
898 if (!parentFileName.IsEmpty())
900 _pHeader->SetTitleText(parentFileName);
901 _pHeader->Invalidate(true);
907 SubFolderSelection::SetNextDisplayPath(void)
914 DataBindingContext* pContext = null;
915 pContext = GetDataBindingContextN();
918 fullPath = FolderNavigationPresentationModel::GetCurrentPath();
919 //fullPath = __rootMediaPath;
921 StringTokenizer tokenizer(fullPath, delim);
924 switch (_storageType)
926 case MEMORY_TYPE_PHONE:
932 case MEMORY_TYPE_SD_CARD:
943 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
944 //it is the last token
945 while (tokenizer.HasMoreTokens())
950 tokenizer.GetNextToken(token);
954 tokenizer.GetNextToken(token);
955 //dislayPath.Append(L"/");
956 displayPath.Append(token);
957 displayPath.Append(L"/");
961 if (__pLabelDisplayPath != null)
963 __displayPath.Append(displayPath);
964 __pLabelDisplayPath->SetText(__displayPath);
965 __pLabelDisplayPath->Invalidate(true);
970 if (pContext != null)
972 //UpdateBinding on the target label control.
973 pContext->UpdateBinding(L"ID_APPCONTROL_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
976 if (pContext != null)
984 SubFolderSelection::OnDataBindingSourceUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
986 //Empty Implementation.
990 SubFolderSelection::OnDataBindingTargetUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
992 //Empty Implementation.
996 SubFolderSelection::OnDataBindingValidationFailed(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Ui::DataBindingDestinationType destType)
998 //Empty Implementation.
1002 SubFolderSelection::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
1004 bool setMediaPath = false;
1005 MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
1006 String unmounted = sdCardStatusUnmounted;
1007 String removed = usbDeviceStatusRemoved;
1009 IList* pArgs = null;
1011 SceneManager* pSceneManager = null;
1013 if (state == unmounted || state == removed)
1015 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
1016 if (state == unmounted)
1018 if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
1020 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1021 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1022 setMediaPath = true;
1026 if (state == removed)
1028 if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
1030 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1031 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1032 setMediaPath = true;
1038 pSceneManager = SceneManager::GetInstance();
1039 pArgs = new (std::nothrow) ArrayList();
1040 pArgs->Add(new (std::nothrow) Integer(APPCONTROL_STATE_SELECTED));
1042 if (pSceneManager != null)
1044 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), pArgs);
1051 SubFolderSelection::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1054 ComponentType currentDeviceType;
1059 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
1065 currentDeviceType = COMPONENT_TYPE_USB;
1075 OnDeviceChange(currentDeviceType, state);
1079 SubFolderSelection::OnPlayerEndOfClip(void)
1081 if (_pListView != null)
1083 _pListView->RefreshList(_currentAudioPlayIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1089 SubFolderSelection::OnSceneTransitionCompleted (const Tizen::Ui::Scenes::SceneId &previousSceneId, const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1091 AppLogDebug("ENTER");
1092 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1093 AppResource* pAppResource = null;
1099 String received_Filepath;
1100 int receivedStorageType = -1;
1101 Tizen::Base::String parentPath;
1102 result r = E_SUCCESS;
1103 pAppResource = Application::GetInstance()->GetAppResource();
1104 TryCatch(pAppResource != null, , "Resource manager not found!");
1106 pAppResource->GetString(L"IDS_COM_OPT_IMPORT", importText);
1107 pAppResource->GetString(L"IDS_MF_TAB_PHONE", phone);
1108 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCard);
1109 pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", external);
1111 sdCard.Append(L"/");
1112 external.Append(L"/");
1114 if (_pListView != null)
1116 _pListView->SetShowState(true);
1119 if (__pFileEventManager != null)
1121 delete __pFileEventManager;
1122 __pFileEventManager = null;
1125 __pFileEventManager = new (std::nothrow)FileEventManager();
1126 __pFileEventManager->Construct(*this);
1128 r = __pFileEventManager->AddPath(_rootMediaPath, FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_CREATE );
1129 AppLogDebug("Result is %s",GetErrorMessage(r));
1132 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT || _currentViewStyle == APPCONTROL_VIEW_IMPORT)
1134 AppLogDebug("inside view check");
1136 String backupCalendarpath;
1137 String backupContactpath;
1138 backupPath = BasePresentationModel::GetMediaPath();
1139 backupPath.Append("Backup");
1140 if (!File::IsFileExist(backupPath))
1142 Directory::Create(backupPath, true);
1145 if ((_currentViewStyle == APPCONTROL_VIEW_IMPORT && _currentFileType == FILE_TYPE_CALENDER_TYPE)
1146 || (_currentViewStyle == APPCONTROL_VIEW_EXPORT && _currentExportFileType == EXPORT_TYPE_CALENDAR))
1148 backupCalendarpath.Append(backupPath);
1149 backupCalendarpath.Append("/");
1150 backupCalendarpath.Append("Calendar");
1151 if (!File::IsFileExist(backupCalendarpath))
1153 r = Directory::Create(backupCalendarpath, true);
1154 AppLogDebug("Result is %s",GetErrorMessage(r));
1157 if ((_currentViewStyle == APPCONTROL_VIEW_IMPORT && _currentFileType == FILE_TYPE_CONTACTS_TYPE)
1158 || (_currentViewStyle == APPCONTROL_VIEW_EXPORT && _currentExportFileType == EXPORT_TYPE_CONTACTS))
1160 backupContactpath.Append(backupPath);
1161 backupContactpath.Append("/");
1162 backupContactpath.Append("Contacts");
1163 if (!File::IsFileExist(backupContactpath))
1165 r = Directory::Create(backupContactpath, true);
1166 AppLogDebug("Result is %s",GetErrorMessage(r));
1170 /*_pFolderEntryPM->SetFolderEntryType(_currentFileType);
1171 _pFolderEntryPM->SetFolderEntryPath(_rootMediaPath);
1172 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1176 if (__pReceivedFilename != null)
1178 //pReceived_Filename = static_cast< String* >(pArgs->GetAt(0));
1179 received_Filepath = FolderNavigationPresentationModel::GetCurrentPath();
1180 receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
1182 if (__pReceivedFilename != null && !__pReceivedFilename->IsEmpty())
1184 _pHeader = GetHeader();
1185 if (_pHeader != null)
1187 _pHeader->SetTitleText(*__pReceivedFilename);
1188 _pHeader->Invalidate(true);
1191 if (received_Filepath != null)
1194 //Clear the rootMediaPath and set it to the received filepath.
1195 //if (_rootMediaPath != null)
1197 _rootMediaPath.Clear();
1198 _rootMediaPath.Append(received_Filepath);
1201 if (__pLabelDisplayPath != null)
1203 switch (receivedStorageType)
1205 case MEMORY_TYPE_PHONE:
1207 __displayPath = phone;
1208 _storageType = MEMORY_TYPE_PHONE;
1209 //AppResource::GetInstance()->GetString(L"IDS_MF_TAB_PHONE", __tabSelected);
1213 case MEMORY_TYPE_SD_CARD:
1215 __displayPath = sdCard;
1216 _storageType = MEMORY_TYPE_SD_CARD;
1217 //AppResource::GetInstance()->GetString(L"IDS_SD_CARD", __tabSelected);
1221 case MEMORY_TYPE_EXTERNAL:
1223 __displayPath = external;
1224 _storageType = MEMORY_TYPE_EXTERNAL;
1230 //Empty Implementation.
1235 //Call the function to set the DisplayPath of the label.
1236 SetNextDisplayPath();
1243 _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath();
1246 parentPath.Append(_rootMediaPath);
1248 if (_pFolderEntryPM != null)
1250 _pFolderEntryPM->SetFolderEntryPath(parentPath);
1251 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1252 TryCatch(_pFilenames != null, , "Failed to allocate Memory to Filenames ArrayList");
1253 _pFolderEntryPM->InitThumbnailManager();
1256 if (_pListView != null)
1258 _pListView->UpdateList();
1261 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
1262 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
1265 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
1269 SubFolderSelection::OnSceneTransitionStarted (const Tizen::Ui::Scenes::SceneId ¤tSceneId, const Tizen::Ui::Scenes::SceneId &nextSceneId)
1273 void SubFolderSelection::OnPlayerAudioFocusChanged (void)
1275 int AudioPlayerState = _pAudioPlayer->GetState();
1277 AppLogDebug("SubFolderSelectionForm %d ++", AudioPlayerState);
1278 if (AudioPlayerState == PLAYER_STATE_PAUSED)
1280 AppLogDebug("Pause");
1281 AppLogDebug("Refreshing %d", _currentAudioPlayIndex);
1282 _pListView->RefreshList(_currentAudioPlayIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1285 AppLogDebug("SubFolderSelectionForm--");
1289 SubFolderSelection::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1291 AppLogDebug("SubFolderSelection::OnFileEventOccured:%S", path.GetPointer());
1293 if (_pAudioPlayer != null)
1295 if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING || _pAudioPlayer->GetState() == PLAYER_STATE_PAUSED)
1297 _pAudioPlayer->Stop();
1298 _pAudioPlayer->Close();
1299 _currentAudioPlayIndex = -1;
1300 _previousAudioSelected = -1;
1304 if ((events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_TO ) || (events & FILE_EVENT_TYPE_CREATE))
1306 if (_pFolderEntryPM!=null)
1308 _pFolderEntryPM->RefreshFolderEntries();
1311 if (_pListView != null && _pListView->IsVisible())
1313 _pListView->UpdateList();
1318 if (_pFolderEntryPM!=null)
1320 _pFolderEntryPM->InitThumbnailManager();
1326 SubFolderSelection::OnAudioNotificationReceived(void)
1328 int AudioPlayerState;
1330 if (_pAudioPlayer != null)
1332 AudioPlayerState = _pAudioPlayer->GetState();
1333 if (AudioPlayerState == PLAYER_STATE_PLAYING)
1335 _pAudioPlayer->Pause();
1336 _pListView->RefreshList(_currentAudioPlayIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);