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 MpFolderContentListForm.cpp
19 * @brief This is the implementation file for FolderContentListForm class.
23 #include "MpFolderContentListForm.h"
24 #include "MpFolderListPresentationModel.h"
25 #include "MpMusicPlayerApp.h"
26 #include "MpPlaylistPickerPopup.h"
27 #include "MpSharePopup.h"
28 #include "MpThumbnailInfo.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Content;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Io;
36 using namespace Tizen::Social;
37 using namespace Tizen::System;
38 using namespace Tizen::Ui;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Ui::Scenes;
42 FolderContentListForm::FolderContentListForm(void)
43 : ContentListForm::ContentListForm()
44 , ThumbnailBase::ThumbnailBase()
45 , __pTableViewContextItem(null)
47 , __pCurrentFolderPath(null)
48 , __pPresentationModel(null)
49 , __checkedItemCount(0)
50 , __currentFolderIndex(0)
51 , __activatedStateContextItem(0)
57 FolderContentListForm::~FolderContentListForm(void)
64 FolderContentListForm::Initialize(void)
67 if (IsFailed(Form::Construct(IDL_CONTENT_LIST_FORM)))
69 AppLogDebug("Construct(IDL_CONTENT_LIST_FORM) failed(%s)", GetErrorMessage(GetLastResult()));
78 FolderContentListForm::Construct(void)
81 __pContentListTableView = static_cast<TableView*>(GetControl(IDC_TABLEVIEW_CONTENT_LIST));
82 __pContentListTableView->AddTableViewItemEventListener(*this);
83 __pContentListTableView->SetItemProvider(this);
85 SetContentList(__pContentListTableView);
87 return ContentListForm::Construct();
91 FolderContentListForm::OnInitializing(void)
94 __pTableViewContextItem = CommonUtil::CreateTableViewContextItemN(*this, GetWidth(), FLICK_MENU_STYLE_TYPE_01);
95 __fontSizeValue = CommonUtil::GetFontSizeValue();
96 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
99 return ThumbnailBase::Construct();
103 FolderContentListForm::OnTerminating(void)
105 AppLogDebug("ENTER");
106 ThumbnailBase::Stop();
107 __pPresentationModel = null;
108 delete __pTableViewContextItem;
109 __pTableViewContextItem = null;
111 delete __pCurrentFolderPath;
112 __pCurrentFolderPath = null;
114 return ContentListForm::OnTerminating();
118 FolderContentListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
119 const Tizen::Ui::Scenes::SceneId& currentSceneId,
120 Tizen::Base::Collection::IList* pArgs)
122 AppLogDebug("ENTER");
125 if (previousSceneId.Equals(IDSCN_PLAYLIST_CREATOR, false))
127 SetItemCheckedAll(false);
131 __prevSceneId.Append(*static_cast<String*>(pArgs->GetAt(DATA_ITEM_SCENE_NAME)));
132 __currentFolderIndex = static_cast<Integer*>(pArgs->GetAt(DATA_ITEM_CONTENT_TYPE))->ToInt();
133 __pCurrentFolderPath = new (std::nothrow) String(*(static_cast<String*>(pArgs->GetAt(DATA_ITEM_CONTENT_NAME))));
135 __pPresentationModel = FolderListPresentationModel::GetInstance();
136 __pPresentationModel->UpdateFolderPathList();
137 __pPresentationModel->InitializeContentList(__currentFolderIndex);
139 int position = INIT_VALUE;
140 __pCurrentFolderPath->LastIndexOf(IDS_SEPARATOR_SLASH, __pCurrentFolderPath->GetLength() - 1, position);
141 __pCurrentFolderPath->SubString(position + 1, __headerTitle);
143 String ellipisiPath = CommonUtil::SetHighDepthToEllipsisPath(*__pCurrentFolderPath);
144 Rectangle rect(INIT_VALUE, INIT_VALUE, GetWidth(), 42);
146 Label* pAdditionalInfo = new (std::nothrow) Label();
147 if (!IsFailed(pAdditionalInfo->Construct(rect, ellipisiPath)))
149 pAdditionalInfo->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
150 pAdditionalInfo->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
151 pAdditionalInfo->SetTextConfig(32, LABEL_TEXT_STYLE_BOLD);
152 pAdditionalInfo->SetTextColor(COLOR_ITEM_SUB_TEXT);
154 SetExtraInformaionArea(*pAdditionalInfo);
162 pArgs->RemoveAll(true);
169 FolderContentListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
170 const Tizen::Ui::Scenes::SceneId& nextSceneId)
172 AppLogDebug("ENTER");
173 CancelAllThumbnailRequest();
178 FolderContentListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
180 AppLogDebug("ENTER");
181 SceneManager* pSceneManager = SceneManager::GetInstance();
182 AppAssert(pSceneManager);
186 case IDA_CONTEXT_MENU_ITEM_GO_TO_LIBARY:
188 IEnumeratorT<SceneId>* pIEnum = null;
189 IListT<SceneId>* pSceneIdList = pSceneManager->GetSceneHistoryN();
190 if (pSceneIdList == null)
192 AppLogDebug("EXIT(ScenList is null)");
193 pSceneManager->GoBackward(BackwardSceneTransition());
197 pSceneManager->ClearSceneHistory();
199 pIEnum = pSceneIdList->GetEnumeratorN();
203 while (pIEnum->MoveNext() == E_SUCCESS)
206 pIEnum->GetCurrent(sceneID);
208 if (!__prevSceneId.Equals(sceneID, false))
210 pSceneManager->AddToSceneHistory(sceneID);
214 pSceneManager->DestroyScene(sceneID);
220 pSceneManager->GoBackward(BackwardSceneTransition());
224 case IDA_CONTEXT_MENU_ITEM_SEARCH:
226 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SEARCH, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY));
230 case IDA_CONTEXT_MENU_ITEM_EDIT:
232 ToggleScreenState(SCREEN_STATE_EDITOR);
236 case IDA_FOOTER_BUTTON_MORE:
238 Point anchorPoint(X_POINT_FOOTER_MORE, Y_POINT_PORTRAIT_FOOTER_MORE);
239 if ((GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE) || (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE))
241 anchorPoint.y = Y_POINT_LANDSCAPE_FOOTER_MORE;
243 CreateOptionMenuN(source);
244 SetOptionMenuItem(CONTEXT_MENU_ITEM_STYLE_GO_TO_LIBARY | CONTEXT_MENU_ITEM_STYLE_EDIT, anchorPoint);
248 case IDA_HEADER_BUTTON_SELECTE_ALL:
250 bool isChecked = true;
251 if (__checkedItemCount == __pContentListTableView->GetItemCount())
255 SetItemCheckedAll(isChecked);
259 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
261 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
265 case IDA_FLICK_MENU_ITEM_SHARE:
267 CreateContextMenuN(source);
268 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_EMAIL | CONTEXT_MENU_ITEM_STYLE_MESSAGE);
272 case IDA_FLICK_MENU_ITEM_SET_AS:
274 CreateContextMenuN(source);
275 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_CALL | CONTEXT_MENU_ITEM_STYLE_CALLER);
279 case IDA_FLICK_MENU_ITEM_DELETE:
281 SetCommonPopup(CommonUtil::CreateContentDeletePopup(*this, IDA_COMMON_POPUP_DELETE, IDA_COMMON_POPUP_CANCEL));
283 if (__pContentListTableView->IsContextItemOpened(__activatedStateContextItem))
285 __pContentListTableView->CloseContextItem(__activatedStateContextItem);
290 case IDA_COMMON_POPUP_CANCEL:
296 case IDA_FLICK_MENU_ITEM_ADDTO:
298 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER, PICKER_ARGUMENT_TYPE_ACTIVATED_STATE_CONTEXT_ITEM);
300 if (__pContentListTableView->IsContextItemOpened(__activatedStateContextItem))
302 __pContentListTableView->CloseContextItem(__activatedStateContextItem);
307 case IDA_COMMON_POPUP_DELETE:
309 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(__activatedStateContextItem);
310 if (pContentInfo != null)
312 RemoveContentAt(pContentInfo->contentId);
313 __pPresentationModel->RefreshContentList(__currentFolderIndex);
314 __pContentListTableView->RefreshItem(__activatedStateContextItem, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
320 case IDA_CONTEXT_MENU_ITEM_EMAIL:
322 case IDA_CONTEXT_MENU_ITEM_MESSAGE:
324 result r = E_FAILURE;
325 String providerID = ((actionId == IDA_CONTEXT_MENU_ITEM_EMAIL) ? PROVIDER_ID_EMAIL : PROVIDER_ID_MESSAGE);
326 AppControl* pAppControl = AppManager::FindAppControlN(providerID, OPERATION_ID_COMPOSE);
327 if (pAppControl == null)
329 AppLogDebug("AppManager::FindAppControlN is null");
333 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(__activatedStateContextItem);
334 if (pContentInfo == null)
336 AppLogDebug("PresentationModel->GetContentInfoN is null");
342 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
343 pDataList->Construct();
345 Tizen::Base::Collection::ArrayList* pValueList = new (std::nothrow) ArrayList(SingleObjectDeleter);
346 pValueList->Construct();
347 pValueList->Add((new (std::nothrow) String(pContentInfo->ContentFilePath)));
349 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pValueList);
352 r = pAppControl->Start(null, null, pDataList, this);
355 Frame* pFrame = MusicPlayerApp::GetInstance()->GetFrameAt(0);
357 pFrame->SetEnabled(false);
360 pDataList->RemoveAll(true);
366 if (__pContentListTableView->IsContextItemOpened(__activatedStateContextItem))
368 __pContentListTableView->CloseContextItem(__activatedStateContextItem);
373 case IDA_CONTEXT_MENU_ITEM_CALL:
375 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(__activatedStateContextItem);
376 if (pContentInfo == null)
378 AppLogDebug("PresentationModel->GetContentInfoN is null");
382 if (!IsFailed(SettingInfo::SetValue(CALL_RINGTONE_KEY, pContentInfo->ContentFilePath)))
384 MessageBox messageBox;
385 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_SUCCESS"),
387 COUNT_MESSAGE_BOX_TIMEOUT);
389 messageBox.ShowAndWait(modalResult);
393 if (__pContentListTableView->IsContextItemOpened(__activatedStateContextItem))
395 __pContentListTableView->CloseContextItem(__activatedStateContextItem);
400 case IDA_CONTEXT_MENU_ITEM_CALLER:
402 AppControl* pAppControl = AppManager::FindAppControlN(PROVIDER_ID_CONTACT, OPERATION_ID_SOCIAL_PICK);
403 if (pAppControl == null)
405 AppLogDebug("AppManager::FindAppControlN is null");
409 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
410 pDataList->Construct();
411 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE), new (std::nothrow) String(APPCONTROL_OPTION_SINGLE));
412 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE), new (std::nothrow) String(APPCONTROL_OPTION_PERSON));
413 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE), new (std::nothrow) String(APPCONTROL_OPTION_ITEM_ID));
415 pAppControl->Start(null, null, pDataList, this);
417 pDataList->RemoveAll(true);
422 if (__pContentListTableView->IsContextItemOpened(__activatedStateContextItem))
424 __pContentListTableView->CloseContextItem(__activatedStateContextItem);
429 case IDA_FOOTER_BUTTON_DELETE:
431 RemoveCheckedTableviewItem(true);
435 case IDA_CONTEXT_MENU_ITEM_SHARE_VIA:
437 ToggleScreenState(SCREEN_STATE_SHARE_VIA);
441 case IDA_FOOTER_BUTTON_SHARE:
443 LanucherPicker(PICKER_TYPE_SHARE_PICKER, PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL);
451 TryRemoveContextMenu(actionId);
452 TryRemoveCommonPopup(actionId);
457 FolderContentListForm::GetItemCount(void)
459 AppLogDebug("ENTER");
461 return __pPresentationModel->GetContentCount(__currentFolderIndex);
464 Tizen::Ui::Controls::TableViewItem*
465 FolderContentListForm::CreateItem(const int itemIndex, int itemWidth)
467 AppLogDebug("ENTER");
468 RelativeLayout layout;
471 TableViewAnnexStyle tableViewAnnexStyle = TABLE_VIEW_ANNEX_STYLE_NORMAL;
472 if (GetScreenState() != SCREEN_STATE_NORMAL)
474 tableViewAnnexStyle = TABLE_VIEW_ANNEX_STYLE_MARK;
477 TableViewItem* pItem = new (std::nothrow) TableViewItem();
478 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(itemIndex);
480 result r = pItem->Construct(layout, Dimension(itemWidth, __itemHeight), tableViewAnnexStyle);
481 TryCatch(r == E_SUCCESS, , "pItem->Construct(%s)", GetErrorMessage(r));
482 TryCatch(pContentInfo != null, , "pContentInfo is null", GetErrorMessage(GetLastResult()));
484 r = CreateTableViewItem(*pItem, *pContentInfo);
485 TryCatch(r == E_SUCCESS, , "CreateTableViewItem failed(%s)", GetErrorMessage(r));
487 RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(itemIndex)));
494 AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
507 FolderContentListForm::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
509 if (GetScreenState() == SCREEN_STATE_NORMAL && IsEmptyContentList() == false)
511 CreateOptionMenuN(source);
512 SetOptionMenuItem(CONTEXT_MENU_ITEM_STYLE_SHARE_VIA | CONTEXT_MENU_ITEM_STYLE_EDIT);
517 FolderContentListForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
519 Tizen::Ui::Controls::TableViewItem* pItem,
520 Tizen::Ui::Controls::TableViewItemStatus status)
522 AppLogDebug("ENTER");
523 if (GetScreenState() != SCREEN_STATE_NORMAL)
525 SetItemCheckedStateChanged(status);
530 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
532 SceneManager* pSceneManager = SceneManager::GetInstance();
533 AppAssert(pSceneManager);
535 ArrayList* pSceneArg = MakePlayerSceneParam(itemIndex);
536 if (pSceneArg != null)
538 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_PLAYER), pSceneArg);
545 FolderContentListForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex,
546 Tizen::Ui::Controls::TableViewContextItem* pContextItem,
549 AppLogDebug("ENTER");
552 AppLogDebug("INDEX %d", itemIndex);
553 __activatedStateContextItem = itemIndex;
559 FolderContentListForm::GetDefaultItemHeight(void)
561 AppLogDebug("ENTER");
567 FolderContentListForm::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
569 AppLogDebug("ENTER");
575 FolderContentListForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView,
579 AppLogDebug("ENTER");
583 Tizen::Base::Collection::ArrayList*
584 FolderContentListForm::MakePlayerSceneParam(int startIndex)
586 AppLogDebug("ENTER");
587 ArrayList* pSelectedMusicContent = __pPresentationModel->GetContentPathListN(__currentFolderIndex);
588 if (pSelectedMusicContent == null)
594 ArrayList* pTempList = new (std::nothrow) ArrayList();
595 pTempList->Construct();
596 pTempList->Add(*(new (std::nothrow) String(MUSIC)));
597 pTempList->Add(*(new (std::nothrow) Integer(startIndex)));
598 pTempList->Add(*(pSelectedMusicContent));
605 FolderContentListForm::CreateTableViewItem(Tizen::Ui::Controls::TableViewItem& parent, const ContentInformation& contentInfo)
607 AppLogDebug("ENTER");
608 Panel* pTableViewItem = new (std::nothrow) Panel();
610 if (GetScreenState() != SCREEN_STATE_NORMAL)
612 if (__fontSizeValue.Equals(STRING_FONT_SIZE_GIANT, false))
614 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_EDITOR_ITEM_PANEL_FONT_SIZE_GIANT)))
616 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
620 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_HUGE, false))
622 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_EDITOR_ITEM_PANEL_FONT_SIZE_HUGE)))
624 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
628 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_LARGE, false))
630 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_EDITOR_ITEM_PANEL_FONT_SIZE_LARGE)))
632 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
636 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_SMALL, false))
638 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_EDITOR_ITEM_PANEL_FONT_SIZE_SMALL)))
640 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
646 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_EDITOR_ITEM_PANEL_DEFAULT)))
648 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
655 if (__fontSizeValue.Equals(STRING_FONT_SIZE_GIANT, false))
657 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_ITEM_PANEL_FONT_SIZE_GIANT)))
659 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
663 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_HUGE, false))
665 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_ITEM_PANEL_FONT_SIZE_HUGE)))
667 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
671 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_LARGE, false))
673 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_ITEM_PANEL_FONT_SIZE_LARGE)))
675 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
679 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_SMALL, false))
681 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_ITEM_PANEL_FONT_SIZE_SMALL)))
683 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
689 if (IsFailed(pTableViewItem->Construct(IDL_CONTENT_LIST_FOLDER_ITEM_PANEL_DEFAULT)))
691 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
697 String filePath = contentInfo.ContentFilePath;
698 Bitmap* StorageIconBitmap = null;
701 String tempPath = contentInfo.ContentFilePath;
703 tempPath.LastIndexOf(L"/", tempPath.GetLength() - 1, indexOf);
704 tempPath.SubString(indexOf + 1, fileName);
706 String phonePath = IDS_STORAGE_PHONE_PATH;
707 phonePath.Remove(IDS_STORAGE_PHONE_PATH.GetLength() - 1, 1);
709 String sdCardPath = IDS_STORAGE_SDCARD_PATH;
710 sdCardPath.Remove(IDS_STORAGE_SDCARD_PATH.GetLength() - 1, 1);
712 if (filePath.Contains(phonePath))
714 StorageIconBitmap = ResourceManager::GetBitmapN(IDB_STORAGE_PHONE);
716 else if (filePath.Contains(sdCardPath))
718 StorageIconBitmap = ResourceManager::GetBitmapN(IDB_STORAGE_SDCARD);
722 StorageIconBitmap = ResourceManager::GetBitmapN(IDB_STORAGE_PHONE);
725 Label* pFolderStorageIcon = static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENT_FOLDER_STORAGE_ICON));
726 pFolderStorageIcon->SetBackgroundBitmap(*StorageIconBitmap);
727 delete StorageIconBitmap;
729 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENT_TITLE_NAME))->SetText(fileName);
730 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENT_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
732 parent.AddControl(pTableViewItem);
733 parent.SetIndividualSelectionEnabled(pTableViewItem, true);
735 CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
742 FolderContentListForm::IsEmptyContentList(void)
744 AppLogDebug("ENTER");
745 if (__pPresentationModel->GetContentCount(__currentFolderIndex) != INIT_VALUE)
754 FolderContentListForm::SetHeader(void)
756 AppLogDebug("ENTER");
757 CommonUtil::SetSimpleTitleStyle(*GetHeader(), __headerTitle);
763 FolderContentListForm::OnAppControlCompleteResponseReceived(const AppId& appId,
764 const String& operationId, AppCtrlResult appControlResult,
765 const IMap* pExtraData)
767 AppLogDebug("ENTER");
768 if (pExtraData == null)
773 AppLogDebug("%ls, %ls", appId.GetPointer(), operationId.GetPointer());
774 if (appId.Equals(String(PROVIDER_ID_CONTACT)))
776 if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
780 ArrayList* pArrayListValue = null;
781 String* pResultString = null;
782 if (pExtraData != null)
784 IMapEnumerator* pEnum = pExtraData->GetMapEnumeratorN();
785 while (pEnum->MoveNext() == E_SUCCESS)
787 pKey = static_cast<String*>(pEnum->GetKey());
788 if (pKey->Equals(APPCONTROL_KEY_SOCIAL_ITEM_ID, true))
790 pArrayListValue = static_cast<ArrayList*>(pEnum->GetValue());
791 pResultString = static_cast<String*>(pArrayListValue->GetAt(0));
792 AppLogDebug("extraData : %ls:%ls", pKey->GetPointer(), pResultString->GetPointer());
793 Integer::Parse(*pResultString, contactId);
801 AppLogDebug("pKey is invaild");
807 AppLogDebug("pExtraData is null");
811 AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
812 Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
814 ContentInformation* pCcontentInfo = __pPresentationModel->GetContentInfoN(__activatedStateContextItem);
815 if (pCcontentInfo == null)
822 Contact* pContact = pAddressbook->GetContactN(contactId);
823 pContact->SetValue(CONTACT_PROPERTY_ID_RINGTONE, pCcontentInfo->ContentFilePath);
824 result r = pAddressbook->UpdateContact(*pContact);
828 ShowDelayedMessageBox(ResourceManager::GetString(L"IDS_COM_POP_SUCCESS"));
831 delete pCcontentInfo;
832 pCcontentInfo = null;
845 FolderContentListForm::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
847 AppLogDebug("ENTER");
848 __pThumbnail = pThumbnailInfo->GetBitmapN();
849 Object* pParam = pThumbnailInfo->GetUserParamN();
852 __pContentListTableView->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
856 delete pThumbnailInfo;
861 FolderContentListForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
863 AppLogDebug("ENTER");
864 ContentListForm::OnUserEventReceivedN(requestId, pArgs);
869 FolderContentListForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
871 AppLogDebug("ENTER");
875 AppLogDebug("pItem is null");
881 Label* pThumbnailLabel = static_cast<Label*>(pItem->GetControl(IDC_CONTENT_THUMBNAIL, true));
882 if (__pThumbnail == null || pThumbnailLabel == null)
884 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
889 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
892 pThumbnailLabel->Invalidate(true);
897 FolderContentListForm::GetCheckedItemCount(void)
899 AppLogDebug("ENTER");
901 return __checkedItemCount;
905 FolderContentListForm::UpdateTableView(void)
907 AppLogDebug("ENTER");
908 __pContentListTableView->UpdateTableView();
913 FolderContentListForm::UpdateContentList(void)
915 AppLogDebug("ENTER");
916 __currentFolderIndex = __pPresentationModel->GetFolderIndex(*__pCurrentFolderPath);
918 if (__currentFolderIndex < 0)
920 SceneManager* pSceneManager = SceneManager::GetInstance();
921 AppAssert(pSceneManager);
922 SetScreenState(SCREEN_STATE_NORMAL);
924 if (!pSceneManager->GetCurrentSceneId().Equals(IDSCN_FOLDER_LIST,true))
926 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_DESTROY_OPTION_KEEP));
931 __pPresentationModel->InitializeContentList(__currentFolderIndex);
937 FolderContentListForm::SetItemCheckedAll(bool isChecked)
939 AppLogDebug("ENTER");
940 if (isChecked == true)
942 __checkedItemCount = __pContentListTableView->GetItemCount();
946 __checkedItemCount = INIT_VALUE;
948 CommonUtil::SetItemCheckedAll(isChecked, *__pContentListTableView);
949 if(GetFooter() != null)
951 CommonUtil::SetFooterItemEnabled(*GetFooter(), isChecked);
954 SetCheckedCountBallonTooltip(GetCheckedItemCount());
959 FolderContentListForm::RemoveCheckedTableviewItem(bool itemRemove)
961 AppLogDebug("ENTER");
964 int totalCount = __pContentListTableView->GetItemCount();
965 for (int iCount = 0; iCount < totalCount; iCount++)
967 if (__pContentListTableView->IsItemChecked(iCount) == true)
969 __pContentListTableView->SetItemChecked(iCount, false);
970 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(iCount);
971 RemoveContentAt(pContentInfo->contentId);
978 SetItemCheckedAll(false);
984 FolderContentListForm::SetItemCheckedStateChanged(Tizen::Ui::Controls::TableViewItemStatus status)
986 AppLogDebug("ENTER");
987 if (status == TABLE_VIEW_ITEM_STATUS_UNCHECKED)
989 __checkedItemCount--;
990 if (__checkedItemCount == INIT_VALUE)
992 if (GetFooter() != null)
994 CommonUtil::SetFooterItemEnabled(*GetFooter(), false);
998 else if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
1000 if (__checkedItemCount == INIT_VALUE)
1002 if (GetFooter() != null)
1004 CommonUtil::SetFooterItemEnabled(*GetFooter(), true);
1008 __checkedItemCount++;
1011 SetCheckedCountBallonTooltip(GetCheckedItemCount());
1012 AppLogDebug("EXIT");
1015 Tizen::Base::Collection::IList*
1016 FolderContentListForm::GetPickerArgumentListN(PickerType pickerType, PickerArgumentType argumentType)
1018 AppLogDebug("ENTER");
1019 Tizen::Base::Collection::ArrayList* pContentFilePathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1020 if (IsFailed(pContentFilePathList->Construct()))
1022 AppLogDebug("pContentList->Construct failed(%s)", GetErrorMessage(GetLastResult()));
1023 delete pContentFilePathList;
1027 if (argumentType == PICKER_ARGUMENT_TYPE_ACTIVATED_STATE_CONTEXT_ITEM)
1029 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(__activatedStateContextItem);
1030 if (pContentInfo == null)
1032 delete pContentFilePathList;
1033 AppLogDebug("GetContentInfoN(%d) is null", __activatedStateContextItem);
1037 pContentFilePathList->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
1038 delete pContentInfo;
1040 else if (argumentType == PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL)
1042 int totalCount = __pContentListTableView->GetItemCount();
1043 for (int iCount = 0; iCount < totalCount; iCount++)
1045 if (__pContentListTableView->IsItemChecked(iCount) == true)
1047 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(iCount);
1048 if (pContentInfo == null)
1050 AppLogDebug("GetContentInfoN(%d) is null", iCount);
1051 delete pContentFilePathList;
1055 if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER)
1057 pContentFilePathList->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
1059 else if (pickerType == PICKER_TYPE_SHARE_PICKER)
1061 pContentFilePathList->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
1063 delete pContentInfo;
1067 AppLogDebug("EXIT");
1068 return pContentFilePathList;
1072 FolderContentListForm::OnFontSizeChanged(void)
1074 __fontSizeValue = CommonUtil::GetFontSizeValue();
1075 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
1076 __pContentListTableView->UpdateTableView();