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 GlAllListPanel.cpp
19 * @brief This is the implementation file for AllListPanel class.
22 #include "GlAlbumInfo.h"
23 #include "GlAllListPanel.h"
24 #include "GlCommonUtil.h"
25 #include "GlFileListForm.h"
26 #include "GlFileListPresentationModel.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Content;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Media;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
39 static const Rectangle RECT_INITIAL (0, 0, 10, 10);
40 static const int W_CLIENT = 720;
41 static const int H_CONTENT_MARGIN = 9;
42 static const int W_CONTENT_MARGIN = 6;
43 static const int W_CONTENT_SPACE = 6;
44 static const int H_CONTENT_SPACE = 6;
46 AllListPanel::AllListPanel(void)
48 , __pContentIconListView(null)
49 , __pPresentationModel(null)
52 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
55 AllListPanel::~AllListPanel(void)
58 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
62 AllListPanel::Refresh(void)
65 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
67 if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_IMAGE)
69 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_IMAGE);
71 else if (__pPresentationModel->GetAppControlMediaType() == APPCONTROL_MEDIA_TYPE_VIDEO)
73 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
77 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
82 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
85 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
88 SceneManager* pSceneManager = SceneManager::GetInstance();
89 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
91 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
95 SceneManager* pSceneManager = SceneManager::GetInstance();
96 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
98 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
99 if (pFileListForm != null)
101 pFileListForm->SetMenuState(true);
105 __pContentIconListView->UpdateList();
106 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
110 AllListPanel::Initialize(void)
112 AppLogDebug("ENTER");
113 result r = Construct(RECT_INITIAL);
114 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
120 AllListPanel::OnInitializing(void)
122 AppLogDebug("ENTER");
123 const Form* pForm = dynamic_cast<Form*>(GetParent());
126 __pPresentationModel = FileListPresentationModel::GetInstance();
127 __pPresentationModel->ClearThumbnailRequests();
128 __pPresentationModel->AddPresentationModelListener(this);
130 Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
131 clientAreaBounds.x = clientAreaBounds.y = 0;
132 SetBounds(clientAreaBounds);
134 __pContentIconListView = new (std::nothrow) IconListView();
135 __pContentIconListView->Construct(Rectangle(0, 0, W_CLIENT, clientAreaBounds.height),
136 DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
137 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
138 if (pBitmapEmpty != null)
140 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
143 __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
144 __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
145 __pContentIconListView->SetMargin(MARGIN_TYPE_RIGHT, W_CONTENT_MARGIN);
146 __pContentIconListView->SetMargin(MARGIN_TYPE_TOP, H_CONTENT_MARGIN);
147 __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
148 __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
149 __pContentIconListView->SetItemProvider(*this);
150 __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
151 __pContentIconListView->AddIconListViewItemEventListener(*this);
152 __pContentIconListView->SetTouchAnimationEnabled(false);
153 result r = AddControl(__pContentIconListView);
154 __pContentIconListView->SetShowState(true);
157 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
163 AllListPanel::OnTerminating(void)
165 AppLogDebug("ENTER");
166 SceneManager* pSceneManager = SceneManager::GetInstance();
167 AppAssert(pSceneManager);
168 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
170 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
171 __pPresentationModel->RemoveContentEventListener(pFileListForm);
173 __pPresentationModel->RemovePresentationModelListener(*this);
174 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
180 AllListPanel::GetItemCount(void)
182 AppLogDebug("ENTER");
183 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
189 AllListPanel::CreateItem(int index)
191 AppLogDebug("ENTER : index(%d)", index);
192 Bitmap* pBitmap=null;
193 String* pItemText=null;
194 result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
197 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
201 IconListViewItem* pIconListviewItem = new (std::nothrow) IconListViewItem();
205 __pPresentationModel->RequestThumbnail(index);
206 pBitmap = CommonUtil::GetEmptyThumbnailN();
209 if (pItemText == null)
211 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
213 else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
216 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
219 if (pItemText != null)
221 pIconListviewItem->Construct(*pBitmap, pItemText);
228 if (pItemText != null)
232 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
234 return pIconListviewItem;
238 AllListPanel::DeleteItem(int index, IconListViewItem* pItem)
240 AppLogDebug("ENTER : index(%d)", index);
242 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
248 AllListPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
250 AppLogDebug("ENTER");
251 result r = E_SUCCESS;
252 if (status == ICON_LIST_VIEW_ITEM_SELECTED)
254 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() <= 0)
256 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
260 ArrayList* pArrayList = new (std::nothrow) ArrayList();
261 pArrayList->Construct();
262 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
264 for (int i = 0; i < loopCount; ++i)
266 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
270 listIndex.Format(10, L"%d", index);
272 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
273 pDataList->Construct();
274 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_IMAGE));
275 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pArrayList);
276 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_INDEX), new (std::nothrow) String(listIndex));
278 r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
279 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
281 if (r == E_MAX_EXCEEDED)
283 MessageBox messageBox;
284 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
285 MSGBOX_STYLE_NONE, 3000);
287 messageBox.ShowAndWait(modalResult);
290 String* pTemp = null;
291 loopCount = pArrayList->GetCount();
292 for (int i = 0; i < loopCount; ++i)
294 pTemp = static_cast<String*>(pArrayList->GetAt(i));
295 AppLog("print temp(%ls)", pTemp->GetPointer());
298 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
302 AllListPanel::OnFileInfoChanged(const ContentType contentType)
304 AppLogDebug("ENTER");
305 if (contentType == CONTENT_TYPE_ALL || contentType == CONTENT_TYPE_IMAGE
306 || contentType == CONTENT_TYPE_VIDEO)
308 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
309 __pContentIconListView->UpdateList();
311 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
315 AllListPanel::OnThumbnailDecoded(const int index)
317 AppLogDebug("ENTER : index(%d)", index);
320 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
322 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
326 AllListPanel::ChangeOrientation(void)
328 AppLogDebug("ENTER");
329 SceneManager* pSceneManager = SceneManager::GetInstance();
330 const Form* pForm = dynamic_cast<Form*>(pSceneManager->GetCurrentScene()->GetForm());
331 TryReturn(pForm != null,, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
333 Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
334 SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
335 __pContentIconListView->SetBounds(0, 0, clientAreaBounds.width, clientAreaBounds.height);
339 AllListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
340 const SceneId& currentSceneId, IList* pArgs)
342 AppLogDebug("ENTER");
345 __pPresentationModel = FileListPresentationModel::GetInstance();
347 if (currentSceneId == IDSCN_ALL_LIST)
349 if (previousSceneId == IDSCN_ALBUM_LIST && pArgs != null)
351 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
352 if (pAlbumInfo == null)
354 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
358 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
359 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
360 if (pDirectoryList != null)
362 delete pDirectoryList;
367 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
368 __pContentIconListView->UpdateList();
372 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
373 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
374 __pContentIconListView->UpdateList();
377 SceneManager* pSceneManager = SceneManager::GetInstance();
378 AppAssert(pSceneManager);
379 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
381 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
382 if (pFileListForm != null)
384 pFileListForm->SetTitleText(__pPresentationModel->GetCurrentAlbumName());
386 if (__itemCount == 0)
388 pFileListForm->SetMenuState(false);
392 pFileListForm->SetMenuState(true);
396 __pPresentationModel->AddContentEventListener(pFileListForm);
398 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
402 AllListPanel::OnSceneDeactivated(const SceneId& currentSceneId,
403 const SceneId& nextSceneId)
405 AppLogDebug("ENTER");
406 SceneManager* pSceneManager = SceneManager::GetInstance();
407 AppAssert(pSceneManager);
408 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
410 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
411 __pPresentationModel->RemoveContentEventListener(pFileListForm);
413 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));