NABI_SE issues resolved
[apps/osp/MyFiles.git] / src / MfSubBaseSelectionForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file: MfSubBaseSelectionForm.cpp
19  * @brief: This file contains implementation of SubBaseSelection class, which acts as a view for traversing SubDirectories
20  * in the AppControl.
21  */
22
23 #include "MfMyFilesApp.h"
24 #include "MfSceneRegister.h"
25 #include "MfSubBaseSelectionForm.h"
26
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Base::Utility;
31 using namespace Tizen::Content;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Io;
34 using namespace Tizen::Locales;
35 using namespace Tizen::Media;
36 using namespace Tizen::System;
37 using namespace Tizen::Telephony;
38 using namespace Tizen::Ui;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Ui::Scenes;
41
42 SubBaseSelection::SubBaseSelection(void)
43 : _pFilenames(null)
44 , _pFooter(null)
45 , _pAttach(null)
46 //, _pCancel(null)
47 , _pCreateFolder(null)
48 , _pExport(null)
49 , _pImport(null)
50 , _pHeader(null)
51 , _pLabelNumberOfItems(null)
52 , _pListView(null)
53 , _pAudioPause(null)
54 , _pAudioPlay(null)
55 , _pAudioPlayPressed(null)
56 , _pDummyImage(null)
57 , _pFolderBitmap(null)
58 , _pAudioPlayer(null)
59 , _pFileManager(null)
60 , _pFolderEntryPM(null)
61 , _pThumbnailManager(null)
62 , _pCallManager(null)
63 {
64         //,_listAnnexStyle(null)
65         _selectionMode = SELECTION_MODE_MULTIPLE;
66         _storedSortStyle = SORT_BY_TYPE_DATE_RECENT;
67         _storePreviousIndex = -1;
68         _currentViewStyle = APPCONTROL_VIEW_DEFAULT;
69         _currentExportFileType = EXPORT_TYPE_CONTACTS;
70         _currentFileType = FILE_TYPE_ALL;
71         _previousAudioSelected = -1;
72         _annexStyle = ANNEX_STYLE_NORMAL;
73         _storageType = MEMORY_TYPE_PHONE;
74         _currentAudioPlayIndex = -1;
75         _defaultListViewBounds = Rectangle(0,0,0,0);
76 }
77
78 SubBaseSelection::~SubBaseSelection(void)
79 {
80         if (_pAttach != null)
81         {
82                 delete _pAttach;
83         }
84
85         if (_pImport != null)
86         {
87                 delete _pImport;
88         }
89
90         if (_pExport != null)
91         {
92                 delete _pExport;
93         }
94
95         if (_pCreateFolder != null)
96         {
97                 delete _pCreateFolder;
98         }
99
100         if (_pAudioPlayer != null)
101         {
102                 delete _pAudioPlayer;
103         }
104
105         if (_pFolderEntryPM != null)
106         {
107                 delete _pFolderEntryPM;
108         }
109
110         if (_pAudioPlay != null)
111         {
112                 delete _pAudioPlay;
113         }
114
115         if (_pAudioPause != null)
116         {
117                 delete _pAudioPause;
118         }
119
120         if (_pAudioPlayPressed != null)
121         {
122                 delete _pAudioPlayPressed;
123         }
124
125         if (_pFolderBitmap != null)
126         {
127                 delete _pFolderBitmap;
128         }
129
130         if (_pDummyImage != null)
131         {
132                 delete _pDummyImage;
133         }
134
135         if (_pCallManager != null)
136         {
137                 delete _pCallManager;
138                 _pCallManager = null;
139         }
140 }
141
142 SubBaseSelection&
143 SubBaseSelection::operator =(const SubBaseSelection& pSubBaseSelection)
144 {
145         return *this;
146 }
147
148 SubBaseSelection::SubBaseSelection(const SubBaseSelection& pSubBaseSelection)
149 {
150         //Do Nothing
151 }
152
153 void
154 SubBaseSelection::OnPlayerOpened(result r)
155 {
156         //empty implementation
157 }
158
159 void
160 SubBaseSelection::OnPlayerEndOfClip(void)
161 {
162         //empty implementation
163 }
164
165 void
166 SubBaseSelection::OnPlayerBuffering(int percent)
167 {
168         //empty implementation
169 }
170
171 void
172 SubBaseSelection::OnPlayerErrorOccurred(PlayerErrorReason r)
173 {
174         //empty implementation
175 }
176
177 void
178 SubBaseSelection::OnPlayerInterrupted(void)
179 {
180         //empty implementation
181 }
182
183 void
184 SubBaseSelection::OnPlayerReleased(void)
185 {
186         //empty implementation
187 }
188
189 void
190 SubBaseSelection::OnPlayerSeekCompleted(result r)
191 {
192         //empty implementation
193 }
194
195 Tizen::Ui::Controls::ListItemBase*
196 SubBaseSelection::CreateItem(int index, int itemWidth)
197 {
198         AppLogDebug("Entry");
199         CustomItem* pCustomItem = null;
200         if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
201         {
202                 pCustomItem = CreateExportListViewItem(index, itemWidth);
203         }
204         else
205         {
206                 pCustomItem = CreateDefaultContentItem(index, itemWidth);
207         }
208         return pCustomItem;
209 }
210
211 bool
212 SubBaseSelection::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
213 {
214         if (pItem != null)
215         {
216                 delete pItem;
217                 pItem = null;
218         }
219
220         return true;
221 }
222
223 int
224 SubBaseSelection::GetItemCount(void)
225 {
226         AppLogDebug("Entry");
227         int itemCount = 0;
228
229         if (_pFilenames != null)
230         {
231                 AppResource* pAppResource = null;
232                 String selectFiles;
233
234                 pAppResource = Application::GetInstance()->GetAppResource();
235                 TryCatch(pAppResource != null, , "Resource manager not found!");
236
237                 pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles);
238
239                 if (_currentViewStyle == APPCONTROL_VIEW_IMPORT)
240                 {
241                         itemCount = _pFilenames->GetCount();
242                 }
243
244                 else
245                 {
246                 if (_pFilenames->GetCount() == 0)
247                 {
248                         if (_pLabelNumberOfItems->GetShowState() == true)
249                         {
250                                 _pLabelNumberOfItems->SetShowState(false);
251                                 _pLabelNumberOfItems->Draw();
252
253                                 if (_selectionMode == SELECTION_MODE_MULTIPLE)
254                                 {
255                                         _pListView->SetSize(_defaultListViewBounds.width, _defaultListViewBounds.height);
256                                         _pListView->Invalidate(true);
257                                 }
258                         }
259                 }
260                 else
261                 {
262                         if (_pLabelNumberOfItems->GetShowState() == false && _selectionMode != SELECTION_MODE_SINGE && _currentViewStyle == APPCONTROL_VIEW_DEFAULT)
263                         {
264                                 _pLabelNumberOfItems->SetShowState(true);
265                         }
266
267                         if (_selectionMode == SELECTION_MODE_MULTIPLE)
268                         {
269                                 _pListView->SetSize(_defaultListViewBounds.width, _defaultListViewBounds.height - _pLabelNumberOfItems->GetHeight());
270                                 _pListView->Invalidate(true);
271                         }
272                         _itemSelectedCount.Clear();
273                         _itemSelectedCount.Append(selectFiles);
274                         _pLabelNumberOfItems->SetText(_itemSelectedCount);
275                         _pLabelNumberOfItems->Invalidate(true);
276                 }
277                 }
278                 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
279                 itemCount = _pFilenames->GetCount();
280         }
281         else
282         {
283                 itemCount = 0;
284         }
285         return itemCount;
286         CATCH:
287         AppLogDebug("Failed to get count");
288         return 0;
289 }
290
291 ContentListItem*
292 SubBaseSelection::CreateDefaultContentItem(int index, int itemWidth)
293 {
294         AppLogDebug("Entry");
295         result r = E_SUCCESS;
296         Font font;
297         String filename;
298         String folderIconPath;
299         String fontName;
300         String searchedString;
301         String cacheImagePath;
302
303         PlayerState audioPlayerStatus;
304         CallStatus callStatus;
305         ContentType contentType = CONTENT_TYPE_UNKNOWN;
306
307         ContentListItem* pCustomItem = null;
308         Bitmap* pFetchedCacheImage = null;
309         Bitmap* pThumbnailImage = null;
310         HashMap* pCacheList = null;
311
312         Dimension thumbnailDimension(W_LISTVIEW_ITEM_BITMAP, H_LISTVIEW_ITEM_BITMAP);
313         Dimension textDimension(itemWidth - W_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);
314         AppResource* pAppResource = null;
315         DirectoryEntry* pFileDetails = null;
316
317         int w_Title = 0;
318
319         w_Title = itemWidth - ((W_LISTVIEW_ITEM_BITMAP * 4) + (4 * X_LISTVIEW));
320         TryCatch(_pFilenames != null, , "Filename list if empty!");
321
322         pAppResource = Application::GetInstance()->GetAppResource();
323         TryCatch(pAppResource != null, , "Resource manager not found!");
324
325         pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW);
326         TryCatch(pCustomItem != null, , "Failed to alloated customitem");
327
328         pFileDetails = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
329         if (pFileDetails != null)
330         {
331                 filename = pFileDetails->GetFileName();
332
333                 contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath());
334                 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
335                 if (_pThumbnailManager != null)
336                 {
337                         if (pFileDetails->IsDirectory())
338                         {
339                                 pCustomItem->SetThumbnail(_pFolderBitmap);
340                                 _annexStyle = ANNEX_STYLE_NORMAL;
341                                 pCustomItem->SetListAnnexStyle(_annexStyle);
342                         }
343                         else
344                         {
345                                 if (!pFileDetails->GetFileExtension().IsEmpty())
346                                 {
347                                         filename = filename + "." + pFileDetails->GetFileExtension();
348                                 }
349
350                                 if (pFileDetails->GetBitmap() == null)
351                                 {
352                                         if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))
353                                         {
354                                                 if (pFileDetails != null)
355                                                 {
356                                                         cacheImagePath = pFileDetails->GetFullFilePath();
357                                                 }
358
359                                                 if ((pCacheList->GetValue(cacheImagePath)) != null)
360                                                 {
361                                                         pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
362                                                 }
363                                         }
364
365                                         if (pFetchedCacheImage != null)
366                                         {
367                                                 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
368                                                 pCustomItem->SetThumbnail(pThumbnailImage);
369                                         }
370                                         else
371                                         {
372                                                 pFileDetails->SetDummy(true);
373                                                 pCustomItem->SetThumbnail(_pDummyImage);
374                                         }
375
376                                         //r = _pFolderEntryPM->InitThumbnailManager(index);
377                                 }
378                                 else
379                                 {
380                                         pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
381                                 }
382
383                                 if (_selectionMode == SELECTION_MODE_SINGE)
384                                 {
385                                         _annexStyle = ANNEX_STYLE_RADIO;
386                                         pCustomItem->SetListAnnexStyle(_annexStyle);
387                                 }
388                                 else if (_selectionMode == SELECTION_MODE_MULTIPLE)
389                                 {
390                                         _annexStyle = ANNEX_STYLE_MARK;
391                                         pCustomItem->SetListAnnexStyle(_annexStyle);
392                                 }
393                                 else if (_selectionMode == SELECTION_MODE_NONE)
394                                 {
395                                         _annexStyle = ANNEX_STYLE_NORMAL;
396                                         pCustomItem->SetListAnnexStyle(_annexStyle);
397                                 }
398
399
400                                 if (contentType == CONTENT_TYPE_AUDIO)
401                                 {
402                                         callStatus = _pCallManager->GetCurrentCallStatus();
403                                         if (callStatus != CALL_STATUS_UNDEFINED && callStatus == CALL_STATUS_IDLE)
404                                         {
405                                                 InitializePlayer();
406                                                 if (_pAudioPlayer != null)
407                                                 {
408                                                         audioPlayerStatus = _pAudioPlayer->GetState();
409                                                         AppLogDebug("SubBaseSelection::CreateDefaultContentItem:%d", audioPlayerStatus);
410
411
412                                                         if (audioPlayerStatus == PLAYER_STATE_CLOSED)
413                                                         {
414                                                                 pCustomItem->SetAudioBitmap(_pAudioPlay, null);
415                                                         }
416
417                                                         if (_currentAudioPlayIndex == index)
418                                                         {
419                                                                 if (audioPlayerStatus == PLAYER_STATE_PLAYING)
420                                                                 {
421                                                                         pCustomItem->SetAudioBitmap(null, _pAudioPause);
422                                                                 }
423                                                                 //else if (audioPlayerStatus == PLAYER_STATE_PAUSED || audioPlayerStatus == PLAYER_STATE_ENDOFCLIP)
424                                                                 else
425                                                                 {
426                                                                         pCustomItem->SetAudioBitmap(_pAudioPlay, null);
427                                                                 }
428                                                         }
429                                                         else
430                                                         {
431                                                                 pCustomItem->SetAudioBitmap(_pAudioPlay, null);
432                                                         }
433                                                 }
434                                                 else
435                                                 {
436                                                         pCustomItem->SetAudioBitmap(_pAudioPlay, null);
437                                                 }
438
439                                         }
440                                 }
441                         }
442                 }
443         }
444
445         if (!filename.IsEmpty())
446         {
447                 pCustomItem->SetTitle(filename, searchedString);
448         }
449         pCustomItem->MakeAppControlFormListItem();
450
451         AppLogDebug("Exit %s", GetErrorMessage(r));
452
453         return pCustomItem;
454
455         CATCH:
456         //Free EnrichedText
457         if (_pAudioPlay != null)
458         {
459                 delete _pAudioPlay;
460                 _pAudioPlay = null;
461         }
462
463         if (_pAudioPause != null)
464         {
465                 delete _pAudioPause;
466                 _pAudioPause = null;
467         }
468
469         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
470         return null;
471 }
472
473 void
474 SubBaseSelection::OnThumbnailReceived(ThumbRequest* pThumbReq)
475 {
476         result res = E_SUCCESS;
477         AppLogDebug("Enter");
478
479         if (_pFolderEntryPM)
480         {
481                 if (pThumbReq != null)
482                 {
483                         if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
484                         {
485                                 if (pThumbReq->pBitmap != null)
486                                 {
487                                         AppLogDebug("This Bitmap is not requested from same form");
488                                         delete pThumbReq->pBitmap;
489                                 }
490                                 return;
491                         }
492                 }
493
494                 if (pThumbReq)
495                 {
496                         if (pThumbReq->iRquestId < _pFilenames->GetCount())
497                         {
498
499                                 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
500
501                                 if (_pListView && _pListView->IsVisible())
502                                 {
503                                         res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
504                                 }
505                         }
506                 }
507                 else
508                 {
509                         _pFolderEntryPM->OnThumbnailResponseFailed();
510                 }
511         }
512         AppLogDebug("Exit %s", GetErrorMessage(res));
513         return;
514 }
515
516 void
517 SubBaseSelection::OnListViewItemStateChangedNotify(ViewType viewType)
518 {
519         //empty Implementation
520 }
521
522 void
523 SubBaseSelection::InitializePlayer(void)
524 {
525         AppLogDebug("SubFolderSelection::OnListViewItemStateChanged");
526         if (_pAudioPlayer == null)
527         {
528                 _pAudioPlayer = new (std::nothrow) Player();
529
530                 if (_pAudioPlayer != null)
531                 {
532                         _pAudioPlayer->Construct(*this);
533                 }
534         }
535 }
536
537 void
538 SubBaseSelection::LoadMusicPlayer(const Tizen::Base::String& mediaFilepath, Tizen::Media::PlayerState PlayerCurrentState)
539 {
540         AppLogDebug("SubFolderSelection::OnListViewItemStateChanged");
541         result r = E_SUCCESS;
542         if (_pAudioPlayer != null && mediaFilepath.IsEmpty() == false)
543         {
544                 if (_pAudioPlayer->GetState() != PLAYER_STATE_PAUSED)
545                 {
546                         if (_pAudioPlayer != null)
547                         {
548                                 delete _pAudioPlayer;
549                                 _pAudioPlayer = null;
550                         }
551                         _pAudioPlayer = new (std::nothrow) Player();
552                         _pAudioPlayer->Construct(*this);
553                 }
554
555                 r = _pAudioPlayer->OpenFile(mediaFilepath, false);
556                 r = _pAudioPlayer->Play();
557                 r = _pAudioPlayer->SetLooping(false);
558                 r = _pAudioPlayer->SetVolume(100);
559         }
560         AppLogDebug("Exit: %s", GetErrorMessage(r));
561 }
562
563 result
564 SubBaseSelection::InitializeAppRegistry(void)
565 {
566         AppLogDebug("Entry");
567         result r = E_SUCCESS;
568         int previousSortValue = 0;
569         AppRegistry* pAppRegistry = null;
570         String sortbyKeyName(L"SortBy");
571         SortByType sortStyle = SORT_BY_TYPE_DATE_RECENT;
572
573         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
574
575         r = pAppRegistry->Add(sortbyKeyName, sortStyle);
576
577         if (r == E_SUCCESS)
578         {
579                 r = pAppRegistry->Save();
580         }
581         else if (r == E_KEY_ALREADY_EXIST)
582         {
583                 pAppRegistry->Get(sortbyKeyName, previousSortValue);
584                 _storedSortStyle = static_cast< SortByType >(previousSortValue);
585                 if (_storedSortStyle != null)
586                 {
587                         pAppRegistry->Set(sortbyKeyName, sortStyle);
588                         r = pAppRegistry->Save();
589                 }
590         }
591
592         AppLogDebug("Exit %s", GetErrorMessage(r));
593         return r;
594 }
595
596 result
597 SubBaseSelection::CreateLabelControl(void)
598 {
599         AppLogDebug("Entry");
600         result r = E_SUCCESS;
601         Color backgroundColor(68, 68, 68);
602         //Color textColor(Color(76, 81, 88));
603
604         _pLabelNumberOfItems = static_cast< Label* >(GetControl(L"IDC_LABEL_SELECTED"));
605         TryCatch(_pLabelNumberOfItems != null, , "applog: allocation failed for __pLabelNumberOfItems");
606
607 //      _pLabelNumberOfItems->Construct(Rectangle(0, GetClientAreaBounds().height - H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL), _itemSelectedCount);
608 //      _pLabelNumberOfItems->SetBackgroundColor(backgroundColor);
609 //      _pLabelNumberOfItems->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
610         _pLabelNumberOfItems->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
611 //      _pLabelNumberOfItems->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
612         _pLabelNumberOfItems->SetTextConfig(ID_FONT_SIZE_26, LABEL_TEXT_STYLE_BOLD);
613
614         if (_selectionMode == SELECTION_MODE_SINGE)
615         {
616                 _pLabelNumberOfItems->SetShowState(false);
617         }
618         else
619         {
620                 if (_currentViewStyle != APPCONTROL_VIEW_IMPORT)
621                 {
622                         _pLabelNumberOfItems->SetShowState(true);
623                 }
624         }
625
626 //      r = AddControl(*_pLabelNumberOfItems);
627         AppLogDebug("Exit %s", GetErrorMessage(r));
628         return r;
629         CATCH:
630         AppLogDebug("Exit %s", GetErrorMessage(r));
631         r = GetLastResult();
632         return r;
633 }
634
635
636 void
637 SubBaseSelection::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId)
638 {
639         AppLogDebug("Entry");
640         String mediaPath;
641         String storagePath;
642
643         switch (actionId)
644         {
645         case IDA_BTN_ATTACH:
646         {
647                 UiApp* pApp = UiApp::GetInstance();
648                 ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected();
649                 ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED);
650
651                 if (pApp != null)
652                 {
653                         pApp->Terminate();
654                 }
655         }
656         break;
657 /*
658         case IDA_BTN_CANCEL:
659         {
660
661         }
662         break;*/
663
664         case IDA_BTN_IMPORT:
665         {
666                 UiApp* pApp = UiApp::GetInstance();
667
668                 ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected();
669                 ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED);
670
671                 if (pApp != null)
672                 {
673                         pApp->Terminate();
674                 }
675         }
676         break;
677
678         case IDA_BTN_EXPORT:
679         {
680                 UiApp* pApp = UiApp::GetInstance();
681
682                 ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected();
683                 ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED);
684
685                 if (pApp != null)
686                 {
687                         pApp->Terminate();
688                 }
689         }
690         break;
691
692         case IDA_BTN_CREATE_FOLDER:
693         {
694                 ArrayList* pArg = null;
695                 Integer* pSourceSelected = null;
696                 SceneManager* pSceneManager = null;
697
698                 pSceneManager = SceneManager::GetInstance();
699
700                 pArg = new (std::nothrow) ArrayList();
701                 pArg->Construct();
702                 pSourceSelected = new (std::nothrow) Integer(SELECT_CREATE_FOLDER);
703                 pArg->Add(pSourceSelected);
704
705                 _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath();
706                 pArg->Add(&_rootMediaPath);
707
708                 if (pSceneManager != null)
709                 {
710                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
711                 }
712         }
713         break;
714
715         default:
716                 break;
717         }
718         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
719 }
720
721 void
722 SubBaseSelection::ClearSelectedItems(Tizen::Ui::Controls::ListView& listView)
723 {
724         ArrayList* pCheckedKeys = null;
725         int itemCount = 0;
726         if (_pFileManager != null)
727         {
728                 pCheckedKeys = static_cast< ArrayList* >(_pFileManager->GetCheckedList()->GetKeysN());
729                 AppLogDebug("Get count is %d",pCheckedKeys->GetCount());
730                 for (itemCount=0; itemCount<pCheckedKeys->GetCount();itemCount++)
731                 {
732                         Integer* currentIndex = static_cast<Integer*>(pCheckedKeys->GetAt(itemCount));
733                         listView.SetItemChecked(currentIndex->ToInt(), false);
734                 }
735                 _pFileManager->ClearCheckedList();
736         }
737 }
738
739 void
740 SubBaseSelection::ResetFooter(void)
741 {
742         AppResource* pAppResource = null;
743         String selectFiles;
744
745         pAppResource = Application::GetInstance()->GetAppResource();
746         pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles);
747
748         if (_pListView != null)
749         {
750                 ClearSelectedItems(*_pListView);
751                 _pFooter->SetItemEnabled(0,false);
752                 _pFooter->Invalidate(true);
753                 _itemSelectedCount.Clear();
754                 _itemSelectedCount.Append(selectFiles);
755                 _pLabelNumberOfItems->SetText(_itemSelectedCount);
756                 _pLabelNumberOfItems->Invalidate(true);
757         }
758 }
759
760 void
761 SubBaseSelection::OnPlayerAudioFocusChanged (void)
762 {
763         //Empty Implementation.
764 }
765
766 void
767 SubBaseSelection::OnFormBackRequested(Form& source)
768 {
769         String currentPath;
770         String parentPath;
771         result r = E_SUCCESS;
772         SceneManager* pSceneManager = null;
773         pSceneManager = SceneManager::GetInstance();
774         currentPath = FolderNavigationPresentationModel::GetCurrentPath();
775
776         if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
777         {
778                 ResetFooter();
779         }
780
781         if (_pAudioPlayer != null)
782         {
783                 if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING)
784                 {
785                         _pAudioPlayer->Stop();
786                 }
787         }
788         if (currentPath == BasePresentationModel::GetMediaPath() || currentPath == BasePresentationModel::GetSdCardPath())
789         {
790                 FolderNavigationPresentationModel::SetCurrentFilePath(currentPath);
791                 ShowHomeView();
792         }
793         else
794         {
795                 parentPath = FolderNavigationPresentationModel::GetParentPath();
796
797                 FolderNavigationPresentationModel::SetCurrentFilePath(parentPath);
798                 r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
799         }
800 }
801
802 void
803 SubBaseSelection::ShowHomeView(void)
804 {
805         SceneManager* pSceneManager = null;
806         String topMostFileSelection(L"ScnTempForm");
807         pSceneManager = SceneManager::GetInstance();
808         if (pSceneManager != null)
809         {
810                 IList* pArgs = new (std::nothrow) ArrayList();
811                 pArgs->Add(new (std::nothrow) Integer(APPCONTROL_STATE_SELECTED));
812                 if (pSceneManager->IsSceneAlive(topMostFileSelection))
813                 {
814                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), pArgs);
815                 }
816                 else
817                 {
818                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), pArgs);
819                 }
820         }
821 }
822
823 ContentListItem*
824 SubBaseSelection::CreateExportListViewItem(int listItemIndex, int listItemWidth)
825 {
826         AppLogDebug("ENTER");
827
828         Font font;
829
830         String filename;
831         String folderIconPath;
832         String imageIconPath;
833         String fontName;
834         String searchedText;
835         String fileExtension;
836         String creationDate;
837         String searchedString;
838         String selectAll;
839         String fullFilePath;
840         String cacheImagePath;
841
842         HashMap* pCacheList = null;
843         Bitmap* pFetchedCacheImage = null;
844         Bitmap* pThumbnailImage = null;
845
846         DateTime dateCreated;
847         Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);
848         Dimension textDimension(listItemWidth - W_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);
849
850         DirectoryEntry* pFileDetails = null;
851
852         ContentListItem* pCustomItem = null;
853         ContentType contentType = CONTENT_TYPE_UNKNOWN;
854
855         //AppRegistry* pAppRegistry = null;
856         //pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
857
858         TryCatch(_pFilenames != null, , "MfMyFilesApp::Filename list if empty!");
859         TryCatch(_pFilenames->GetCount() != 0, , "MfMyFilesApp::Filename count is Zero!");
860
861         pCustomItem = new (std::nothrow) ContentListItem(listItemWidth, H_ITEM_LISTVIEW);
862         TryCatch(pCustomItem != null, , "MfMyFilesApp::Failed to allocate Memory to pCustomItem");
863
864         //Get the Directory Entry for the element at index from the Filenames list.
865
866         pFileDetails = static_cast< DirectoryEntry* >(_pFilenames->GetAt(listItemIndex));
867         TryCatch(pFileDetails != null, , "MfMyFilesApp::Failed to fetch FileDetails from __pFileNames!");
868
869         pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
870
871         //Set the filename of the element at index index
872         filename = pFileDetails->GetFileName();
873         fullFilePath = pFileDetails->GetFullFilePath();
874
875         //If the registry key value is set for show extension append the extension of the filename else do not.
876
877                 if (!pFileDetails->GetFileExtension().IsEmpty())
878                 {
879                         filename = filename + "." + pFileDetails->GetFileExtension();
880                 }
881
882
883         if (pFileDetails->IsDirectory())
884         {
885                 pCustomItem->SetThumbnail(_pFolderBitmap);
886         }
887         else
888         {
889                 pCustomItem->SetDescColor(Color::GetColor(COLOR_ID_GREY));
890
891                 contentType = ContentManagerUtil::CheckContentType(fullFilePath);
892
893                 if (pFileDetails->GetBitmap() == null && pFileDetails->IsDummy())
894                 {
895                         if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))
896                         {
897                                 if (pFileDetails != null)
898                                 {
899                                         cacheImagePath = pFileDetails->GetFullFilePath();
900                                         AppLogDebug("cache path is %S",cacheImagePath.GetPointer());
901                                 }
902
903                                 if ((pCacheList->GetValue(cacheImagePath)) != null)
904                                 {
905                                         pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
906                                 }
907                         }
908
909                         if (pFetchedCacheImage != null)
910                         {
911                                 AppLogDebug("image taken from cachemanager");
912                                 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
913                                 pCustomItem->SetThumbnail(pThumbnailImage);
914                         }
915                         else
916                         {
917                                 pFileDetails->SetDummy(true);
918                                 pCustomItem->SetThumbnail(_pDummyImage);
919                                 AppLogDebug("call to thumbnail manager");
920                         }
921                 }
922                 else
923                 {
924                         AppLogDebug("BITMAP FOUND : NOT NEED TO DO GETTHUMBNAIL");
925                         pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
926                 }
927         }
928
929         pCustomItem->SetTitle(filename, searchedText);
930
931         pCustomItem->Make();
932
933         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
934
935         return pCustomItem;
936
937 CATCH:
938         if (pCustomItem != null)
939         {
940                 delete pCustomItem;
941                 pCustomItem = null;
942         }
943         return null;
944 }
945
946 void
947 SubBaseSelection::OnTelephonyCallStatusChangedN (CallStatus     callStatus, CallInfo * pCallInfo)
948 {
949         AppLogDebug("SubBaseSelection::OnTelephonyCallStatusChangedN");
950         _pListView->UpdateList();
951 }
952
953 void
954 SubBaseSelection::OnSettingValueChanged(void)
955 {
956         //Empty Implementation.
957 }