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 delete __pFileEventManager;
77 SubFolderSelection::operator =(const SubFolderSelection& pSubFolderSelection)
82 SubFolderSelection::SubFolderSelection(const SubFolderSelection& pSubFolderSelection)
89 SubFolderSelection::Initialize(void)
92 Form::Construct(L"IDL_SUB_FOLDER_FILE_SELECTION");
98 SubFolderSelection::OnInitializing(void)
100 AppLogDebug("Entry");
101 result r = E_SUCCESS;
110 String buttonExportHere;
112 ButtonItem footerItemMenu;
113 int xPos = 0, yPos = 0;
115 CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_SELECTION;
117 AppResource* pAppResource = null;
118 Bitmap* pBitmapHomeButton = null;
119 Bitmap* pBitmapUpButton = null;
120 Bitmap* pBitmapHomeButtonPress = null;
121 Bitmap* pBitmapUpButtonPress = null;
122 Bitmap* pBitmap = null;
123 Bitmap* pBitmapPress = null;
124 Bitmap* pBitmapDisabled = null;
126 __pReceivedFilename = new (std::nothrow) String();
128 _pListView = static_cast< ListView* >(GetControl("IDC_SUB_FOLDER_SELECTION_LISTVIEW"));
129 TryCatch(_pListView != null, , "Failed to get list view control");
131 _pListView->AddListViewItemEventListener(*this);
132 _pListView->SetItemProvider(*this);
133 _pListView->SetShowState(false);
135 _selectionMode = ((MyFilesApp*) Application::GetInstance())->GetCurrentSelectionMode();
136 _currentFileType = ((MyFilesApp*) Application::GetInstance())->GetCurrentFileType();
137 _currentViewStyle = ((MyFilesApp*) Application::GetInstance())->GetCurrentView();
138 _currentExportFileType = ((MyFilesApp*) Application::GetInstance())->GetCurrentExportFileType();
140 __pLabelDisplayPath = static_cast< Label* >(GetControl("IDC_SUB_FOLDER_SELECTION_LABEL_DISPLAY_PATH"));
141 TryCatch(__pLabelDisplayPath != null, , "Label is Null");
143 pAppResource = UiApp::GetInstance()->GetAppResource();
144 TryCatch(pAppResource != null, , "Resource manager not found!");
146 displayPath = defaultPhoneBody;
147 displayPath.Append("/");
149 //pAppResource->GetString(L"IDS_MF_BUTTON_HOME", buttonHome);
150 pAppResource->GetString(L"IDS_COM_POP_ATTACH", buttonAttach);
151 pAppResource->GetString(L"IDS_COM_POP_CANCEL", buttonCancel);
152 pAppResource->GetString(L"IDS_EXPORT_HERE", buttonExportHere);
153 //pAppResource->GetString(L"IDS_MF_TAB_UP", buttonUp);
154 pBitmap = pAppResource->GetBitmapN(IDB_MORE, BITMAP_PIXEL_FORMAT_ARGB8888);
155 pBitmapPress = pAppResource->GetBitmapN(IDB_MORE_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
156 pBitmapDisabled = pAppResource->GetBitmapN(IDB_MORE_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888);
157 pBitmapHomeButton = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
158 pBitmapUpButton = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
159 pBitmapHomeButtonPress = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
160 pBitmapUpButtonPress = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
162 __displayPath = displayPath;
164 _pFolderBitmap = pAppResource->GetBitmapN(IDB_FOLDER, BITMAP_PIXEL_FORMAT_ARGB8888);
165 _pDummyImage = pAppResource->GetBitmapN(IDB_DUMMY_IMG, BITMAP_PIXEL_FORMAT_ARGB8888);
167 _pAudioPlay = MfUtility::MergeBitmapN(IDB_PLAY_OUTER_CIRCLE, IDB_PLAY, 64, 64);
168 _pAudioPause = MfUtility::MergeBitmapN(IDB_PLAY_OUTER_CIRCLE, IDB_PAUSE, 64, 64);
170 _pFooter = GetFooter();
172 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
174 pAppResource->GetString(L"IDS_EXPORT", buttonExport);
176 footerItemMenu.Construct(BUTTON_ITEM_STYLE_ICON, IDA_BTN_MORE);
179 pBitmap->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
180 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmap);
182 if (pBitmapPress != null)
184 pBitmapPress->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
185 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapPress);
187 if (pBitmapDisabled != null)
189 pBitmapDisabled->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
190 footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapDisabled);
192 if (_pFooter != null)
194 _pFooter->GetPosition(xPos, yPos);
196 __pMoreContextMenu = new (std::nothrow) ContextMenu();
197 __pMoreContextMenu->Construct(Point(0 , yPos), CONTEXT_MENU_STYLE_LIST);
198 __pMoreContextMenu->AddActionEventListener(*this);
199 __pMoreContextMenu->SetShowState(true);
202 _pHeader = GetHeader();
203 TryCatch(_pHeader != null, , "Header is Null");
205 __pHomeButton = new (std::nothrow) ButtonItem();
206 __pHomeButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_HOME);
207 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapHomeButton);
208 __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapHomeButtonPress);
210 __pUpButton = new (std::nothrow) ButtonItem();
211 __pUpButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_UP);
212 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapUpButton);
213 __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapUpButtonPress);
215 _pHeader->SetButton(BUTTON_POSITION_LEFT, *__pHomeButton);
216 _pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pUpButton);
217 _pHeader->AddActionEventListener(*this);
219 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
221 _pExport = new (std::nothrow) FooterItem();
222 r = _pExport->Construct(IDA_BTN_EXPORT);
223 _pExport->SetText(buttonExportHere);
228 _pAttach = new (std::nothrow) FooterItem();
229 r = _pAttach->Construct(IDA_BTN_ATTACH);
230 _pAttach->SetText(buttonAttach);
233 TryCatch(_pFooter != null, , "Footer is Null");
235 if (_pFooter != null)
237 _pFooter->RemoveAllButtons();
238 _pFooter->RemoveAllItems();
239 _pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
241 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
243 _pFooter->AddItem(*_pExport);
244 _pFooter->SetButton(BUTTON_POSITION_LEFT, footerItemMenu);
245 //_pFooter->AddItem(*_pCreateFolder);
249 _pFooter->AddItem(*_pAttach);
252 //_pFooter->AddItem(*_pCancel);
253 _pFooter->AddActionEventListener(*this);
254 _pFooter->SetBackButton();
255 SetFormBackEventListener(this);
256 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
258 _pFooter->SetItemEnabled(0, false);
260 _pFooter->Invalidate(true);
263 CreateLabelControl();
265 _defaultListViewBounds = _pListView->GetBounds();
267 _pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
268 TryCatch(_pFolderEntryPM != null, , "Failed to allocate memory");
269 _pFolderEntryPM->Construct();
270 _pFolderEntryPM->SetSourceForm(createitemsource);
272 _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath();
273 _rootStoragePath = BasePresentationModel::GetSdCardPath();
275 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
277 _pFolderEntryPM->SetFolderEntryType(_currentFileType);
278 _pFolderEntryPM->SetFolderEntryPath(_rootMediaPath);
279 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
280 TryCatch(_pFilenames != null, , "MfMyFilesApp::Failed to allocate Memory to Filenames ArrayList");
283 _pThumbnailManager = ThumbnailManager::GetInstance();
284 TryCatch(_pThumbnailManager != null, , "Thumbnail Manager not found!");
286 _pFileManager = FolderEntryEditorPresentationModel::GetInstance();
287 TryCatch(_pFileManager != null, , "File Manager not found!");
289 InitializeAppRegistry();
291 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
293 __pLabelDisplayPath->SetShowState(true);
294 _pLabelNumberOfItems->SetShowState(false);
297 _pCallManager = new (std::nothrow) CallManager();
299 r = _pCallManager->Construct(*this);
300 TryCatch(r == E_SUCCESS, , "Failed to Construct CallManager");
302 AppLogDebug("Exit %s", GetErrorMessage(r));
305 DataBindingContext* pContext = null;
307 pContext = GetDataBindingContextN();
308 TryCatch(pContext != null, , "Failed to Fetch the DataBinding Context");
310 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);
316 delete pBitmapHomeButton;
317 delete pBitmapUpButton;
318 delete pBitmapHomeButtonPress;
319 delete pBitmapUpButtonPress;
320 delete pBitmapDisabled;
323 AppLogDebug("Exit: %s", GetErrorMessage(r));
327 if (pBitmapHomeButton != null)
329 delete pBitmapHomeButton;
330 pBitmapHomeButton = null;
333 if (pBitmapUpButton != null)
335 delete pBitmapUpButton;
336 pBitmapUpButton = null;
338 if (pBitmapHomeButtonPress != null)
340 delete pBitmapHomeButtonPress;
341 pBitmapHomeButtonPress = null;
343 if (pBitmapUpButtonPress != null)
345 delete pBitmapUpButtonPress;
346 pBitmapUpButtonPress = null;
349 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
354 SubFolderSelection::OnTerminating(void)
356 result r = E_SUCCESS;
358 _pHeader = GetHeader();
359 if (_pHeader != null)
361 _pHeader->RemoveAllButtons();
362 _pHeader->RemoveAllItems();
365 _pFooter = GetFooter();
366 if (_pFooter != null)
368 _pFooter->RemoveAllButtons();
369 _pFooter->RemoveAllItems();
376 SubFolderSelection::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
378 //empty implementation
382 SubFolderSelection::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
384 //empty implementation
388 SubFolderSelection::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
390 AppLogDebug("Entry");
391 result r = E_SUCCESS;
393 String selectedCount;
394 String selectedRootMediaPath;
395 DirectoryEntry* pDirStr = null;
397 int selectedItemsCount = 0;
399 AppResource* pAppResource = null;
400 SceneManager* pSceneManager = null;
401 ArrayList* pArgs = null;
402 bool itemStatus = false;
403 Integer currentIndex = index;
404 RelativeLayout* pLayout = null;
406 pArgs = new (std::nothrow) ArrayList();
409 pSceneManager = SceneManager::GetInstance();
410 pAppResource = Application::GetInstance()->GetAppResource();
411 TryCatch(pAppResource != null, , "Resource manager not found!");
413 pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles);
414 pAppResource->GetString(L"IDS_COM_BODY_SELECTED", selectedCount);
416 itemStatus = _pFileManager->GetCheckedList()->ContainsKey(currentIndex /*,itemStatus*/);
418 if (elementId == CONTENT_LIST_ITEM_TYPE_PLAY || elementId == CONTENT_LIST_ITEM_TYPE_PAUSE)
420 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
421 TryCatch(pDirStr != null, , "pDirStr is null");
425 listView.SetItemChecked(index, false);
429 listView.SetItemChecked(index, true);
432 if (_pAudioPlayer == null)
435 LoadMusicPlayer(pDirStr->GetFullFilePath(), PLAYER_STATE_INITIALIZED);
436 _previousAudioSelected = index;
437 _currentAudioPlayIndex = index;
438 _pListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
443 if (_previousAudioSelected == index)
445 if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING)
447 _pAudioPlayer->Pause();
451 LoadMusicPlayer(pDirStr->GetFullFilePath(), PLAYER_STATE_INITIALIZED);
456 _pAudioPlayer->Stop();
457 _pAudioPlayer->Close();
458 _pListView->RefreshList(_previousAudioSelected, LIST_REFRESH_TYPE_ITEM_MODIFY);
459 _previousAudioSelected = index;
461 LoadMusicPlayer(pDirStr->GetFullFilePath(), PLAYER_STATE_STOPPED);
463 _currentAudioPlayIndex = index;
464 _pListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
465 //listView.SetItemChecked(index, false);
469 if (_pFilenames != null) //start of FILENAME check if
471 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
473 if (pDirStr != null) //start of NULL check if
475 if (pDirStr->IsDirectory()) // start of DIRECTORY CHECK if
477 selectedRootMediaPath = pDirStr->GetFullFilePath();
478 nextFilename = pDirStr->GetFileName();
480 if (_rootMediaPath != null)
482 _rootMediaPath.Clear();
483 _rootMediaPath.Append(selectedRootMediaPath);
486 if (_pAudioPlayer != null)
488 if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING || _pAudioPlayer->GetState() == PLAYER_STATE_PAUSED)
490 _pAudioPlayer->Stop();
491 _pAudioPlayer->Close();
494 FolderNavigationPresentationModel::SetCurrentFilePath(_rootMediaPath);
496 pArgs->Add(&nextFilename);
497 pArgs->Add(&_rootMediaPath);
498 ClearSelectedItems(listView);
499 pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
500 } // end of DIRECTORY CHECK if
501 else //start of FILE CHECK else
503 if (listView.IsItemChecked(index) == true)
505 _pFileManager->AddCheckedListEntry(index, pDirStr);
509 _pFileManager->RemoveCheckedListEntry(index);
512 if (_selectionMode == SELECTION_MODE_SINGE)
514 if (listView.IsItemChecked(_storePreviousIndex) == true && _storePreviousIndex != index)
516 listView.SetItemChecked(_storePreviousIndex, false);
517 _pListView->RefreshList(_storePreviousIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
518 _pFileManager->RemoveCheckedListEntry(_storePreviousIndex);
520 _storePreviousIndex = index;
522 } //end of FILE CHECK else
523 } //end of NULL check if
525 for (itemcount = 0; itemcount <= GetItemCount(); itemcount++)
527 if (listView.IsItemChecked(itemcount) == true)
529 selectedItemsCount++;
533 if (selectedItemsCount != 0)
535 r = _pFooter->SetItemEnabled(0, true);
539 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
541 _pFooter->SetItemEnabled(0, false);
545 if (_selectionMode == SELECTION_MODE_MULTIPLE) // start of MULTIPLE_MODE_SELECTION if
548 pLayout = dynamic_cast <RelativeLayout*> (Form::GetLayoutN());
551 pLayout->SetRelation(*_pListView, _pLabelNumberOfItems,RECT_EDGE_RELATION_BOTTOM_TO_TOP);
554 if (selectedItemsCount > 0)
556 _itemSelectedCount.Clear();
557 _itemSelectedCount.Append(selectedCount);
558 _itemSelectedCount.Append(L"\x200E");
559 _itemSelectedCount.Append(L"(");
560 _itemSelectedCount.Append(selectedItemsCount);
561 _itemSelectedCount.Append(L")");
562 _itemSelectedCount.Append(L"\x200E");
563 _pLabelNumberOfItems->SetText(_itemSelectedCount);
567 _itemSelectedCount.Clear();
568 _itemSelectedCount.Append(selectFiles);
569 _pLabelNumberOfItems->SetText(_itemSelectedCount);
572 _pLabelNumberOfItems->Invalidate(true);
576 } //end of FILENAME check if
578 _pFooter->Invalidate(true);
580 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
584 if (_pFolderEntryPM != null)
586 delete _pFolderEntryPM;
587 _pFolderEntryPM = null;
589 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
593 SubFolderSelection::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
595 //empty implementation
599 SubFolderSelection::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
600 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
603 RelativeLayout* pLayout = null;
605 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
607 ((MyFilesApp*) Application::GetInstance())->SetAudioNotificationListener(this);
608 _itemSelectedCount.Clear();
610 if (_pFileManager != null)
612 if (!_pFileManager->IsCheckedListNull())
614 _pFileManager->ClearCheckedList();
617 if (_selectionMode == SELECTION_MODE_SINGE) // start of MULTIPLE_MODE_SELECTION if
619 pLayout = dynamic_cast <RelativeLayout*> (Form::GetLayoutN());
622 pLayout->SetRelation(*_pListView, this ,RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
630 __pReceivedFilename->Clear();
631 __pReceivedFilename->Append(*static_cast<String*>(pArgs->GetAt(0)));
635 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
637 String headerDisplayPath = FolderNavigationPresentationModel::GetCurrentPath();
638 SetHeaderTitleText(headerDisplayPath);
639 __pReceivedFilename->Clear();
643 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
647 pArgs->RemoveAll(false);
653 SubFolderSelection::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
654 const Tizen::Ui::Scenes::SceneId& nextSceneId)
656 DeviceManager::RemoveAllDeviceEventListeners();
657 ((MyFilesApp*)Application::GetInstance())->SetCurrentView(null);
658 ((MyFilesApp*) Application::GetInstance())->SetAudioNotificationListener(null);
659 _pFolderEntryPM->StopThumbnailManager(true);
661 if(__pFileEventManager != null)
663 __pFileEventManager->RemovePath(_rootMediaPath);
668 SubFolderSelection::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
670 AppLogDebug("Entry");
673 Bitmap* pBitmapCreateFolder = null;
674 AppResource* pAppResource = null;
675 pAppResource = UiApp::GetInstance()->GetAppResource();
676 if (pAppResource != null)
678 pAppResource->GetString(L"IDS_COM_BODY_CREATE_FOLDER", createFolder);
679 pBitmapCreateFolder = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
687 _pFolderEntryPM->InitThumbnailManager();
693 ShowParentDirectoryView();
694 _pFolderEntryPM->InitThumbnailManager();
700 __pMoreContextMenu->RemoveAllItems();
701 __pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
702 __pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
703 __pMoreContextMenu->AddItem(createFolder, IDA_BTN_CREATE_FOLDER, *pBitmapCreateFolder, null, null);
704 __pMoreContextMenu->SetShowState(true);
705 __pMoreContextMenu->Show();
711 SubBaseOnActionPerformed(source, actionId);
715 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
719 SubFolderSelection::ShowParentDirectoryView(void)
721 AppLogDebug("Entry");
722 result r = E_SUCCESS;
726 displayPath = defaultPhoneBody;
727 displayPath.Append("/");
729 ParentPath = FolderNavigationPresentationModel::GetParentPath();
730 //_pFileManager->ClearCheckedList();
732 if (FolderNavigationPresentationModel::GetCurrentPath() == BasePresentationModel::GetMediaPath() || FolderNavigationPresentationModel::GetCurrentPath() == BasePresentationModel::GetSdCardPath())
734 _pFileManager->ClearCheckedList();
739 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
744 if (_pAudioPlayer != null)
746 if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING || _pAudioPlayer->GetState() == PLAYER_STATE_PAUSED)
748 _pAudioPlayer->Stop();
749 _pAudioPlayer->Close();
752 _rootMediaPath.Clear();
753 _rootMediaPath.Append(ParentPath);
755 FolderNavigationPresentationModel::SetCurrentFilePath(_rootMediaPath);
757 SetParentDisplayPath();
758 SetHeaderTitleText(ParentPath);
760 //Remove the current files from the filenames list
761 if (_pFolderEntryPM != null)
763 _pFolderEntryPM->SetFolderEntryPath(ParentPath);
764 //Get the files in the parent path of the current view
765 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
766 TryCatch(_pFilenames != null, , "Failed to fetch ArrayList from the ContentBrowser!");
769 if (_pListView != null)
771 _pListView->UpdateList();
772 _storePreviousIndex = 0;
776 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
780 if (_pFolderEntryPM != null)
782 delete _pFolderEntryPM;
783 _pFolderEntryPM = null;
785 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
789 SubFolderSelection::SetParentDisplayPath(void)
793 String parentDisplayPath;
797 DataBindingContext* pContext = null;
798 pContext = GetDataBindingContextN();
800 if (pContext != null)
802 //Update binding on the source to fetch the current display path.
803 pContext->UpdateBinding(L"ID_APPCONTROL_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_SOURCE);
807 StringTokenizer tokenizer(__displayPath, delim);
809 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
810 //it is the last token
811 while (tokenizer.HasMoreTokens())
813 int tokenCount = tokenizer.GetTokenCount();
817 tokenizer.GetNextToken(token);
818 parentDisplayPath.Append(token);
819 parentDisplayPath.Append(L"/");
827 //Set the display path to that of the generated filepath from the tokenizer
828 __displayPath = parentDisplayPath;
831 if (pContext != null)
833 //Update Binding on the Target control to display the currently constructed path.
834 pContext->UpdateBinding(L"ID_APPCONTROL_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
837 if (pContext != null)
843 if (__pLabelDisplayPath != null)
845 __pLabelDisplayPath->SetText(__displayPath);
846 __pLabelDisplayPath->Invalidate(true);
851 SubFolderSelection::SetHeaderTitleText(Tizen::Base::String& filePath)
854 String parentFileName;
855 String delimiter(L"/");
856 StringTokenizer tokenizer(filePath, delimiter);
858 AppResource* pAppResource = null;
860 pAppResource = UiApp::App::GetInstance()->GetAppResource();
862 if (filePath == BasePresentationModel::GetMediaPath())
864 if (pAppResource != null)
866 pAppResource->GetString(L"IDS_MF_TAB_PHONE", parentFileName);
869 else if (filePath == BasePresentationModel::GetSdCardPath())
871 if (pAppResource != null)
873 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", parentFileName);
878 while (tokenizer.HasMoreTokens())
880 int tokenCount = tokenizer.GetTokenCount();
884 tokenizer.GetNextToken(parentFileName);
888 tokenizer.GetNextToken(token);
893 if (_pHeader != null)
895 if (!parentFileName.IsEmpty())
897 _pHeader->SetTitleText(parentFileName);
898 _pHeader->Invalidate(true);
904 SubFolderSelection::SetNextDisplayPath(void)
911 DataBindingContext* pContext = null;
912 pContext = GetDataBindingContextN();
915 fullPath = FolderNavigationPresentationModel::GetCurrentPath();
916 //fullPath = __rootMediaPath;
918 StringTokenizer tokenizer(fullPath, delim);
921 switch (_storageType)
923 case MEMORY_TYPE_PHONE:
929 case MEMORY_TYPE_SD_CARD:
940 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
941 //it is the last token
942 while (tokenizer.HasMoreTokens())
947 tokenizer.GetNextToken(token);
951 tokenizer.GetNextToken(token);
952 //dislayPath.Append(L"/");
953 displayPath.Append(token);
954 displayPath.Append(L"/");
958 if (__pLabelDisplayPath != null)
960 __displayPath.Append(displayPath);
961 __pLabelDisplayPath->SetText(__displayPath);
962 __pLabelDisplayPath->Invalidate(true);
967 if (pContext != null)
969 //UpdateBinding on the target label control.
970 pContext->UpdateBinding(L"ID_APPCONTROL_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
973 if (pContext != null)
981 SubFolderSelection::OnDataBindingSourceUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
983 //Empty Implementation.
987 SubFolderSelection::OnDataBindingTargetUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
989 //Empty Implementation.
993 SubFolderSelection::OnDataBindingValidationFailed(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Ui::DataBindingDestinationType destType)
995 //Empty Implementation.
999 SubFolderSelection::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
1001 bool setMediaPath = false;
1002 MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
1003 String unmounted = sdCardStatusUnmounted;
1004 String removed = usbDeviceStatusRemoved;
1006 IList* pArgs = null;
1008 SceneManager* pSceneManager = null;
1010 if (state == unmounted || state == removed)
1012 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
1013 if (state == unmounted)
1015 if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
1017 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1018 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1019 setMediaPath = true;
1023 if (state == removed)
1025 if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
1027 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1028 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1029 setMediaPath = true;
1035 pSceneManager = SceneManager::GetInstance();
1036 pArgs = new (std::nothrow) ArrayList();
1037 pArgs->Add(new (std::nothrow) Integer(APPCONTROL_STATE_SELECTED));
1039 if (pSceneManager != null)
1041 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), pArgs);
1048 SubFolderSelection::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1051 ComponentType currentDeviceType;
1056 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
1062 currentDeviceType = COMPONENT_TYPE_USB;
1072 OnDeviceChange(currentDeviceType, state);
1076 SubFolderSelection::OnPlayerEndOfClip(void)
1078 if (_pListView != null)
1080 _pListView->RefreshList(_currentAudioPlayIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1086 SubFolderSelection::OnSceneTransitionCompleted (const Tizen::Ui::Scenes::SceneId &previousSceneId, const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1088 AppLogDebug("ENTER");
1089 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1090 AppResource* pAppResource = null;
1096 String received_Filepath;
1097 int receivedStorageType = -1;
1098 Tizen::Base::String parentPath;
1099 result r = E_SUCCESS;
1100 pAppResource = Application::GetInstance()->GetAppResource();
1101 TryCatch(pAppResource != null, , "Resource manager not found!");
1103 pAppResource->GetString(L"IDS_COM_OPT_IMPORT", importText);
1104 pAppResource->GetString(L"IDS_MF_TAB_PHONE", phone);
1105 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCard);
1106 pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", external);
1108 sdCard.Append(L"/");
1109 external.Append(L"/");
1111 if (_pListView != null)
1113 _pListView->SetShowState(true);
1116 if (__pFileEventManager != null)
1118 delete __pFileEventManager;
1119 __pFileEventManager = null;
1122 __pFileEventManager = new (std::nothrow)FileEventManager();
1123 __pFileEventManager->Construct(*this);
1125 r = __pFileEventManager->AddPath(_rootMediaPath, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
1126 AppLogDebug("Result is %s",GetErrorMessage(r));
1129 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT || _currentViewStyle == APPCONTROL_VIEW_IMPORT)
1131 AppLogDebug("inside view check");
1133 String backupCalendarpath;
1134 String backupContactpath;
1135 backupPath = BasePresentationModel::GetMediaPath();
1136 backupPath.Append("Backup");
1137 if (!File::IsFileExist(backupPath))
1139 Directory::Create(backupPath, true);
1142 if ((_currentViewStyle == APPCONTROL_VIEW_IMPORT && _currentFileType == FILE_TYPE_CALENDER_TYPE)
1143 || (_currentViewStyle == APPCONTROL_VIEW_EXPORT && _currentExportFileType == EXPORT_TYPE_CALENDAR))
1145 backupCalendarpath.Append(backupPath);
1146 backupCalendarpath.Append("/");
1147 backupCalendarpath.Append("Calendar");
1148 if (!File::IsFileExist(backupCalendarpath))
1150 r = Directory::Create(backupCalendarpath, true);
1151 AppLogDebug("Result is %s",GetErrorMessage(r));
1154 if ((_currentViewStyle == APPCONTROL_VIEW_IMPORT && _currentFileType == FILE_TYPE_CONTACTS_TYPE)
1155 || (_currentViewStyle == APPCONTROL_VIEW_EXPORT && _currentExportFileType == EXPORT_TYPE_CONTACTS))
1157 backupContactpath.Append(backupPath);
1158 backupContactpath.Append("/");
1159 backupContactpath.Append("Contacts");
1160 if (!File::IsFileExist(backupContactpath))
1162 r = Directory::Create(backupContactpath, true);
1163 AppLogDebug("Result is %s",GetErrorMessage(r));
1167 /*_pFolderEntryPM->SetFolderEntryType(_currentFileType);
1168 _pFolderEntryPM->SetFolderEntryPath(_rootMediaPath);
1169 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1173 if (__pReceivedFilename != null)
1175 //pReceived_Filename = static_cast< String* >(pArgs->GetAt(0));
1176 received_Filepath = FolderNavigationPresentationModel::GetCurrentPath();
1177 receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
1179 if (__pReceivedFilename != null && !__pReceivedFilename->IsEmpty())
1181 _pHeader = GetHeader();
1182 if (_pHeader != null)
1184 _pHeader->SetTitleText(*__pReceivedFilename);
1185 _pHeader->Invalidate(true);
1188 if (received_Filepath != null)
1191 //Clear the rootMediaPath and set it to the received filepath.
1192 //if (_rootMediaPath != null)
1194 _rootMediaPath.Clear();
1195 _rootMediaPath.Append(received_Filepath);
1198 if (__pLabelDisplayPath != null)
1200 switch (receivedStorageType)
1202 case MEMORY_TYPE_PHONE:
1204 __displayPath = phone;
1205 _storageType = MEMORY_TYPE_PHONE;
1206 //AppResource::GetInstance()->GetString(L"IDS_MF_TAB_PHONE", __tabSelected);
1210 case MEMORY_TYPE_SD_CARD:
1212 __displayPath = sdCard;
1213 _storageType = MEMORY_TYPE_SD_CARD;
1214 //AppResource::GetInstance()->GetString(L"IDS_SD_CARD", __tabSelected);
1218 case MEMORY_TYPE_EXTERNAL:
1220 __displayPath = external;
1221 _storageType = MEMORY_TYPE_EXTERNAL;
1227 //Empty Implementation.
1232 //Call the function to set the DisplayPath of the label.
1233 SetNextDisplayPath();
1240 _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath();
1243 parentPath.Append(_rootMediaPath);
1245 if (_pFolderEntryPM != null)
1247 _pFolderEntryPM->SetFolderEntryPath(parentPath);
1248 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1249 TryCatch(_pFilenames != null, , "Failed to allocate Memory to Filenames ArrayList");
1250 _pFolderEntryPM->InitThumbnailManager();
1253 if (_pListView != null)
1255 _pListView->UpdateList();
1258 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
1259 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
1262 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
1266 SubFolderSelection::OnSceneTransitionStarted (const Tizen::Ui::Scenes::SceneId ¤tSceneId, const Tizen::Ui::Scenes::SceneId &nextSceneId)
1270 void SubFolderSelection::OnPlayerAudioFocusChanged (void)
1272 int AudioPlayerState = _pAudioPlayer->GetState();
1274 AppLogDebug("SubFolderSelectionForm %d ++", AudioPlayerState);
1275 if (AudioPlayerState == PLAYER_STATE_PAUSED)
1277 AppLogDebug("Pause");
1278 AppLogDebug("Refreshing %d", _currentAudioPlayIndex);
1279 _pListView->RefreshList(_currentAudioPlayIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1282 AppLogDebug("SubFolderSelectionForm--");
1286 SubFolderSelection::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1288 AppLogDebug("SubFolderSelection::OnFileEventOccured:%S", path.GetPointer());
1290 if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_TO ))
1292 if (_pFolderEntryPM!=null)
1294 _pFolderEntryPM->RefreshFolderEntries();
1297 if (_pListView != null && _pListView->IsVisible())
1299 _pListView->UpdateList();
1302 if (_pFolderEntryPM!=null)
1304 AppLogDebug("inside file event");
1305 _pFolderEntryPM->InitThumbnailManager();
1311 SubFolderSelection::OnAudioNotificationReceived(void)
1313 int AudioPlayerState;
1315 if (_pAudioPlayer != null)
1317 AudioPlayerState = _pAudioPlayer->GetState();
1318 if (AudioPlayerState == PLAYER_STATE_PLAYING)
1320 _pAudioPlayer->Pause();
1321 _pListView->RefreshList(_currentAudioPlayIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);