4879419307c85a09f9d8bf41bfe5ed04139315b3
[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->GetBitmap() == null)
346                                 {
347                                         if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))
348                                         {
349                                                 if (pFileDetails != null)
350                                                 {
351                                                         cacheImagePath = pFileDetails->GetFullFilePath();
352                                                 }
353
354                                                 if ((pCacheList->GetValue(cacheImagePath)) != null)
355                                                 {
356                                                         pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
357                                                 }
358                                         }
359
360                                         if (pFetchedCacheImage != null)
361                                         {
362                                                 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
363                                                 pCustomItem->SetThumbnail(pThumbnailImage);
364                                         }
365                                         else
366                                         {
367                                                 pFileDetails->SetDummy(true);
368                                                 pCustomItem->SetThumbnail(_pDummyImage);
369                                         }
370
371                                         //r = _pFolderEntryPM->InitThumbnailManager(index);
372                                 }
373                                 else
374                                 {
375                                         pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
376                                 }
377
378                                 if (_selectionMode == SELECTION_MODE_SINGE)
379                                 {
380                                         _annexStyle = ANNEX_STYLE_RADIO;
381                                         pCustomItem->SetListAnnexStyle(_annexStyle);
382                                 }
383                                 else if (_selectionMode == SELECTION_MODE_MULTIPLE)
384                                 {
385                                         _annexStyle = ANNEX_STYLE_MARK;
386                                         pCustomItem->SetListAnnexStyle(_annexStyle);
387                                 }
388                                 else if (_selectionMode == SELECTION_MODE_NONE)
389                                 {
390                                         _annexStyle = ANNEX_STYLE_NORMAL;
391                                         pCustomItem->SetListAnnexStyle(_annexStyle);
392                                 }
393
394
395                                 if (contentType == CONTENT_TYPE_AUDIO)
396                                 {
397                                         callStatus = _pCallManager->GetCurrentCallStatus();
398                                         if (callStatus != CALL_STATUS_UNDEFINED && callStatus == CALL_STATUS_IDLE)
399                                         {
400                                                 InitializePlayer();
401                                                 if (_pAudioPlayer != null)
402                                                 {
403                                                         audioPlayerStatus = _pAudioPlayer->GetState();
404                                                         AppLogDebug("SubBaseSelection::CreateDefaultContentItem:%d", audioPlayerStatus);
405
406
407                                                         if (audioPlayerStatus == PLAYER_STATE_CLOSED)
408                                                         {
409                                                                 pCustomItem->SetAudioBitmap(_pAudioPlay, null);
410                                                         }
411
412                                                         if (_currentAudioPlayIndex == index)
413                                                         {
414                                                                 if (audioPlayerStatus == PLAYER_STATE_PLAYING)
415                                                                 {
416                                                                         pCustomItem->SetAudioBitmap(null, _pAudioPause);
417                                                                 }
418                                                                 //else if (audioPlayerStatus == PLAYER_STATE_PAUSED || audioPlayerStatus == PLAYER_STATE_ENDOFCLIP)
419                                                                 else
420                                                                 {
421                                                                         pCustomItem->SetAudioBitmap(_pAudioPlay, null);
422                                                                 }
423                                                         }
424                                                         else
425                                                         {
426                                                                 pCustomItem->SetAudioBitmap(_pAudioPlay, null);
427                                                         }
428                                                 }
429                                                 else
430                                                 {
431                                                         pCustomItem->SetAudioBitmap(_pAudioPlay, null);
432                                                 }
433
434                                         }
435                                 }
436                         }
437                 }
438         }
439
440         if (!filename.IsEmpty())
441         {
442                 pCustomItem->SetTitle(filename, searchedString);
443         }
444         pCustomItem->MakeAppControlFormListItem();
445
446         AppLogDebug("Exit %s", GetErrorMessage(r));
447
448         return pCustomItem;
449
450         CATCH:
451         //Free EnrichedText
452         if (_pAudioPlay != null)
453         {
454                 delete _pAudioPlay;
455                 _pAudioPlay = null;
456         }
457
458         if (_pAudioPause != null)
459         {
460                 delete _pAudioPause;
461                 _pAudioPause = null;
462         }
463
464         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
465         return null;
466 }
467
468 void
469 SubBaseSelection::OnThumbnailReceived(ThumbRequest* pThumbReq)
470 {
471         result res = E_SUCCESS;
472         AppLogDebug("Enter");
473
474         if (_pFolderEntryPM)
475         {
476                 if (pThumbReq != null)
477                 {
478                         if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
479                         {
480                                 if (pThumbReq->pBitmap != null)
481                                 {
482                                         AppLogDebug("This Bitmap is not requested from same form");
483                                         delete pThumbReq->pBitmap;
484                                 }
485                                 return;
486                         }
487                 }
488
489                 if (pThumbReq)
490                 {
491                         if (pThumbReq->iRquestId < _pFilenames->GetCount())
492                         {
493
494                                 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
495
496                                 if (_pListView && _pListView->IsVisible())
497                                 {
498                                         res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
499                                 }
500                         }
501                 }
502                 else
503                 {
504                         _pFolderEntryPM->OnThumbnailResponseFailed();
505                 }
506         }
507         AppLogDebug("Exit %s", GetErrorMessage(res));
508         return;
509 }
510
511 void
512 SubBaseSelection::OnListViewItemStateChangedNotify(ViewType viewType)
513 {
514         //empty Implementation
515 }
516
517 void
518 SubBaseSelection::InitializePlayer(void)
519 {
520         AppLogDebug("SubFolderSelection::OnListViewItemStateChanged");
521         if (_pAudioPlayer == null)
522         {
523                 _pAudioPlayer = new (std::nothrow) Player();
524
525                 if (_pAudioPlayer != null)
526                 {
527                         _pAudioPlayer->Construct(*this);
528                 }
529         }
530 }
531
532 void
533 SubBaseSelection::LoadMusicPlayer(const Tizen::Base::String& mediaFilepath, Tizen::Media::PlayerState PlayerCurrentState)
534 {
535         AppLogDebug("SubFolderSelection::OnListViewItemStateChanged");
536         result r = E_SUCCESS;
537         if (_pAudioPlayer != null && mediaFilepath.IsEmpty() == false)
538         {
539                 if (_pAudioPlayer->GetState() != PLAYER_STATE_PAUSED)
540                 {
541                         if (_pAudioPlayer != null)
542                         {
543                                 delete _pAudioPlayer;
544                                 _pAudioPlayer = null;
545                         }
546                         _pAudioPlayer = new (std::nothrow) Player();
547                         _pAudioPlayer->Construct(*this);
548                 }
549
550                 r = _pAudioPlayer->OpenFile(mediaFilepath, false);
551                 r = _pAudioPlayer->Play();
552                 r = _pAudioPlayer->SetLooping(false);
553                 r = _pAudioPlayer->SetVolume(100);
554         }
555         AppLogDebug("Exit: %s", GetErrorMessage(r));
556 }
557
558 result
559 SubBaseSelection::InitializeAppRegistry(void)
560 {
561         AppLogDebug("Entry");
562         result r = E_SUCCESS;
563         int previousSortValue = 0;
564         AppRegistry* pAppRegistry = null;
565         String sortbyKeyName(L"SortBy");
566         SortByType sortStyle = SORT_BY_TYPE_DATE_RECENT;
567
568         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
569
570         r = pAppRegistry->Add(sortbyKeyName, sortStyle);
571
572         if (r == E_SUCCESS)
573         {
574                 r = pAppRegistry->Save();
575         }
576         else if (r == E_KEY_ALREADY_EXIST)
577         {
578                 pAppRegistry->Get(sortbyKeyName, previousSortValue);
579                 _storedSortStyle = static_cast< SortByType >(previousSortValue);
580                 if (_storedSortStyle != null)
581                 {
582                         pAppRegistry->Set(sortbyKeyName, sortStyle);
583                         r = pAppRegistry->Save();
584                 }
585         }
586
587         AppLogDebug("Exit %s", GetErrorMessage(r));
588         return r;
589 }
590
591 result
592 SubBaseSelection::CreateLabelControl(void)
593 {
594         AppLogDebug("Entry");
595         result r = E_SUCCESS;
596         Color backgroundColor(68, 68, 68);
597         //Color textColor(Color(76, 81, 88));
598
599         _pLabelNumberOfItems = static_cast< Label* >(GetControl(L"IDC_LABEL_SELECTED"));
600         TryCatch(_pLabelNumberOfItems != null, , "applog: allocation failed for __pLabelNumberOfItems");
601
602 //      _pLabelNumberOfItems->Construct(Rectangle(0, GetClientAreaBounds().height - H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL), _itemSelectedCount);
603 //      _pLabelNumberOfItems->SetBackgroundColor(backgroundColor);
604 //      _pLabelNumberOfItems->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
605         _pLabelNumberOfItems->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
606 //      _pLabelNumberOfItems->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
607         _pLabelNumberOfItems->SetTextConfig(ID_FONT_SIZE_26, LABEL_TEXT_STYLE_BOLD);
608
609         if (_selectionMode == SELECTION_MODE_SINGE)
610         {
611                 _pLabelNumberOfItems->SetShowState(false);
612         }
613         else
614         {
615                 if (_currentViewStyle != APPCONTROL_VIEW_IMPORT)
616                 {
617                         _pLabelNumberOfItems->SetShowState(true);
618                 }
619         }
620
621 //      r = AddControl(*_pLabelNumberOfItems);
622         AppLogDebug("Exit %s", GetErrorMessage(r));
623         return r;
624         CATCH:
625         AppLogDebug("Exit %s", GetErrorMessage(r));
626         r = GetLastResult();
627         return r;
628 }
629
630
631 void
632 SubBaseSelection::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId)
633 {
634         AppLogDebug("Entry");
635         String mediaPath;
636         String storagePath;
637
638         switch (actionId)
639         {
640         case IDA_BTN_ATTACH:
641         {
642                 UiApp* pApp = UiApp::GetInstance();
643                 ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected();
644                 ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED);
645
646                 if (pApp != null)
647                 {
648                         pApp->Terminate();
649                 }
650         }
651         break;
652 /*
653         case IDA_BTN_CANCEL:
654         {
655
656         }
657         break;*/
658
659         case IDA_BTN_IMPORT:
660         {
661                 UiApp* pApp = UiApp::GetInstance();
662
663                 ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected();
664                 ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED);
665
666                 if (pApp != null)
667                 {
668                         pApp->Terminate();
669                 }
670         }
671         break;
672
673         case IDA_BTN_EXPORT:
674         {
675                 UiApp* pApp = UiApp::GetInstance();
676
677                 ((MyFilesApp*) Application::GetInstance())->SetAppControlSelected();
678                 ((MyFilesApp*) Application::GetInstance())->AddAppControlResult(APP_CTRL_RESULT_SUCCEEDED);
679
680                 if (pApp != null)
681                 {
682                         pApp->Terminate();
683                 }
684         }
685         break;
686
687         case IDA_BTN_CREATE_FOLDER:
688         {
689                 ArrayList* pArg = null;
690                 Integer* pSourceSelected = null;
691                 SceneManager* pSceneManager = null;
692
693                 pSceneManager = SceneManager::GetInstance();
694
695                 pArg = new (std::nothrow) ArrayList();
696                 pArg->Construct();
697                 pSourceSelected = new (std::nothrow) Integer(SELECT_CREATE_FOLDER);
698                 pArg->Add(pSourceSelected);
699
700                 _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath();
701                 pArg->Add(&_rootMediaPath);
702
703                 if (pSceneManager != null)
704                 {
705                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
706                 }
707         }
708         break;
709
710         default:
711                 break;
712         }
713         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
714 }
715
716 void
717 SubBaseSelection::ClearSelectedItems(Tizen::Ui::Controls::ListView& listView)
718 {
719         ArrayList* pCheckedKeys = null;
720         int itemCount = 0;
721         if (_pFileManager != null)
722         {
723                 pCheckedKeys = static_cast< ArrayList* >(_pFileManager->GetCheckedList()->GetKeysN());
724                 AppLogDebug("Get count is %d",pCheckedKeys->GetCount());
725                 for (itemCount=0; itemCount<pCheckedKeys->GetCount();itemCount++)
726                 {
727                         Integer* currentIndex = static_cast<Integer*>(pCheckedKeys->GetAt(itemCount));
728                         listView.SetItemChecked(currentIndex->ToInt(), false);
729                 }
730                 _pFileManager->ClearCheckedList();
731         }
732 }
733
734 void
735 SubBaseSelection::ResetFooter(void)
736 {
737         AppResource* pAppResource = null;
738         String selectFiles;
739
740         pAppResource = Application::GetInstance()->GetAppResource();
741         pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles);
742
743         if (_pListView != null)
744         {
745                 ClearSelectedItems(*_pListView);
746                 _pFooter->SetItemEnabled(0,false);
747                 _pFooter->Invalidate(true);
748                 _itemSelectedCount.Clear();
749                 _itemSelectedCount.Append(selectFiles);
750                 _pLabelNumberOfItems->SetText(_itemSelectedCount);
751                 _pLabelNumberOfItems->Invalidate(true);
752         }
753 }
754
755 void
756 SubBaseSelection::OnPlayerAudioFocusChanged (void)
757 {
758         //Empty Implementation.
759 }
760
761 void
762 SubBaseSelection::OnFormBackRequested(Form& source)
763 {
764         String currentPath;
765         String parentPath;
766         result r = E_SUCCESS;
767         SceneManager* pSceneManager = null;
768         pSceneManager = SceneManager::GetInstance();
769         currentPath = FolderNavigationPresentationModel::GetCurrentPath();
770
771         if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
772         {
773                 ResetFooter();
774         }
775
776         if (_pAudioPlayer != null)
777         {
778                 if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING)
779                 {
780                 _pAudioPlayer->Stop();
781                 }
782         }
783         if (currentPath == BasePresentationModel::GetMediaPath() || currentPath == BasePresentationModel::GetSdCardPath())
784         {
785                 FolderNavigationPresentationModel::SetCurrentFilePath(currentPath);
786                 ShowHomeView();
787         }
788         else
789         {
790                 parentPath = FolderNavigationPresentationModel::GetParentPath();
791
792                 FolderNavigationPresentationModel::SetCurrentFilePath(parentPath);
793                 r = pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
794         }
795 }
796
797 void
798 SubBaseSelection::ShowHomeView(void)
799 {
800         SceneManager* pSceneManager = null;
801         String topMostFileSelection(L"ScnTempForm");
802         pSceneManager = SceneManager::GetInstance();
803         if (pSceneManager != null)
804         {
805                 IList* pArgs = new (std::nothrow) ArrayList();
806                 pArgs->Add(new (std::nothrow) Integer(APPCONTROL_STATE_SELECTED));
807                 if (pSceneManager->IsSceneAlive(topMostFileSelection))
808                 {
809                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), pArgs);
810                 }
811                 else
812                 {
813                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE), pArgs);
814                 }
815         }
816 }
817
818 ContentListItem*
819 SubBaseSelection::CreateExportListViewItem(int listItemIndex, int listItemWidth)
820 {
821         AppLogDebug("ENTER");
822
823         Font font;
824
825         String filename;
826         String folderIconPath;
827         String imageIconPath;
828         String fontName;
829         String searchedText;
830         String fileExtension;
831         String creationDate;
832         String searchedString;
833         String selectAll;
834         String fullFilePath;
835         String cacheImagePath;
836
837         HashMap* pCacheList = null;
838         Bitmap* pFetchedCacheImage = null;
839         Bitmap* pThumbnailImage = null;
840
841         DateTime dateCreated;
842         Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);
843         Dimension textDimension(listItemWidth - W_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);
844
845         DirectoryEntry* pFileDetails = null;
846
847         ContentListItem* pCustomItem = null;
848         ContentType contentType = CONTENT_TYPE_UNKNOWN;
849
850         //AppRegistry* pAppRegistry = null;
851         //pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
852
853         TryCatch(_pFilenames != null, , "MfMyFilesApp::Filename list if empty!");
854         TryCatch(_pFilenames->GetCount() != 0, , "MfMyFilesApp::Filename count is Zero!");
855
856         pCustomItem = new (std::nothrow) ContentListItem(listItemWidth, H_ITEM_LISTVIEW);
857         TryCatch(pCustomItem != null, , "MfMyFilesApp::Failed to allocate Memory to pCustomItem");
858
859         //Get the Directory Entry for the element at index from the Filenames list.
860
861         pFileDetails = static_cast< DirectoryEntry* >(_pFilenames->GetAt(listItemIndex));
862         TryCatch(pFileDetails != null, , "MfMyFilesApp::Failed to fetch FileDetails from __pFileNames!");
863
864         pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
865
866         //Set the filename of the element at index index
867         filename = pFileDetails->GetFileName();
868         fullFilePath = pFileDetails->GetFullFilePath();
869
870         //If the registry key value is set for show extension append the extension of the filename else do not.
871
872                 if (!pFileDetails->GetFileExtension().IsEmpty())
873                 {
874                         filename = filename + "." + pFileDetails->GetFileExtension();
875                 }
876
877
878         if (pFileDetails->IsDirectory())
879         {
880                 pCustomItem->SetThumbnail(_pFolderBitmap);
881         }
882         else
883         {
884                 pCustomItem->SetDescColor(Color::GetColor(COLOR_ID_GREY));
885
886                 contentType = ContentManagerUtil::CheckContentType(fullFilePath);
887
888                 if (pFileDetails->GetBitmap() == null && pFileDetails->IsDummy())
889                 {
890                         if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))
891                         {
892                                 if (pFileDetails != null)
893                                 {
894                                         cacheImagePath = pFileDetails->GetFullFilePath();
895                                         AppLogDebug("cache path is %S",cacheImagePath.GetPointer());
896                                 }
897
898                                 if ((pCacheList->GetValue(cacheImagePath)) != null)
899                                 {
900                                         pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
901                                 }
902                         }
903
904                         if (pFetchedCacheImage != null)
905                         {
906                                 AppLogDebug("image taken from cachemanager");
907                                 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
908                                 pCustomItem->SetThumbnail(pThumbnailImage);
909                         }
910                         else
911                         {
912                                 pFileDetails->SetDummy(true);
913                                 pCustomItem->SetThumbnail(_pDummyImage);
914                                 AppLogDebug("call to thumbnail manager");
915                         }
916                 }
917                 else
918                 {
919                         AppLogDebug("BITMAP FOUND : NOT NEED TO DO GETTHUMBNAIL");
920                         pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
921                 }
922         }
923
924         pCustomItem->SetTitle(filename, searchedText);
925
926         pCustomItem->Make();
927
928         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
929
930         return pCustomItem;
931
932 CATCH:
933         if (pCustomItem != null)
934         {
935                 delete pCustomItem;
936                 pCustomItem = null;
937         }
938         return null;
939 }
940
941 void
942 SubBaseSelection::OnTelephonyCallStatusChangedN (CallStatus     callStatus, CallInfo * pCallInfo)
943 {
944         AppLogDebug("SubBaseSelection::OnTelephonyCallStatusChangedN");
945         _pListView->UpdateList();
946 }