2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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 IvImageViewerForm.cpp
19 * @brief This is the implementation file for ImageViewerForm class.
23 #include "IvCommonUtil.h"
24 #include "IvImageInfo.h"
25 #include "IvImageViewerApp.h"
26 #include "IvImageViewerForm.h"
27 #include "IvImageViewerPresentationModel.h"
28 #include "IvResourceManager.h"
29 #include "IvSettingPresentationModel.h"
30 #include "IvSlideShowPopUp.h"
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Base::Utility;
38 using namespace Tizen::Content;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Io;
41 using namespace Tizen::Media;
42 using namespace Tizen::System;
43 using namespace Tizen::Ui;
44 using namespace Tizen::Ui::Controls;
45 using namespace Tizen::Ui::Scenes;
47 static const unsigned int COLOR_HEADER_CONTORL_PANEL = Color32<0, 0, 0, 100>::Value;
48 static const unsigned int COLOR_HEADER_BUTTON1 = Color32<0, 0, 0, 100>::Value;
49 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
50 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
51 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
52 static const unsigned int COLOR_GALLERY_BG = Color32<31,31,31>::Value;
54 static const Rectangle RECT_DETAILS_CONTORL_LABEL (20, 0, 200, 48);
56 static const int W_PLAY_BUTTON = 160;
57 static const int H_PLAY_BUTTON = 160;
59 static const int GAP_W_POPUP_ITEM = 5;
60 static const int W_DELETE_POPUP = 600;
61 static const int H_DELETE_POPUP = 300;
62 static const int H_DELETE_LABEL = 180;
63 static const int Y_DELETE_BUTTON = 180;
64 static const int H_DELETE_BUTTON = 80;
66 static const Dimension DUMMY_IMAGE_DIMENSION (720, 1280);
67 static const Rectangle DUMMY_IMAGE_RECTANGLE (0, 0, 720, 1280);
69 static const int PAGE_NO_CONTENT_SEARCH = 1;
70 static const int COUNT_PER_PAGE_CONTENT_SEARCH = 10;
72 static const int FORMAT_BUFFER_SIZE = 256;
74 static const long long SINGLE_GIGA_BYTE = (1024 * 1024 * 1024);
75 static const long long SINGLE_MEGA_BYTE = (1024 * 1024);
76 static const long long SINGLE_KILO_BYTE = 1024;
78 static const int Y_RENAME_BUTTON = 100;
79 static const int H_RENAME_BUTTON = 64;
80 static const int W_RENAME_BUTTON = 64;
82 static const int GAP_W_END_OF_LABEL = 60;
83 static const int X_DETAIL_FILEINFO_LABEL = 20;
84 static const int H_DETAIL_FILEINFO_LABEL = 50;
85 static const int H_DETAIL_MAIN_TEXT = 48;
86 static const int H_DETAIL_SUB_TEXT = 42;
87 static const int GAP_H_DETAIL_TEXT = 26;
88 static const int H_DETAIL_FILEINFO_VALUE_LABEL = 56;
90 static const int X_MORE = 55;
92 static const int DETAIL_SUB_FONT_SIZE = 32;
93 static const int DETAIL_MAIN_FONT_SIZE = 36;
94 static const int DETAIL_COUNT_MAX = 9;
96 ImageViewerForm::ImageViewerForm(void)
97 : __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
100 , __pScrollPanel(null)
101 , __pDetail_Label(null)
102 , __pLabelMessage(null)
103 , __pPlayButton(null)
104 , __pRenameButton(null)
105 , __pDetailFooterItem(null)
108 , __pContextMenuMore(null)
109 , __pContextMenuCopy(null)
110 , __pContextMenuSetAs(null)
111 , __pContextMenuShare(null)
112 , __pDeletePopup(null)
115 , __startSlide(false)
117 , __pPresentationModel(null)
119 AppLogDebug("ENTER");
120 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
123 ImageViewerForm::~ImageViewerForm(void)
125 AppLogDebug("ENTER");
126 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
130 ImageViewerForm::Initialize()
132 AppLogDebug("ENTER");
134 result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
136 __pPresentationModel = ImageViewerPresentationModel::GetInstance();
138 if (__pPresentationModel->GetFileCount() > 0)
140 if (__pPresentationModel->GetType() == APPCONTROL_DATA_SLIDE_SHOW)
146 __pPresentationModel->AddFileUpdateListener(this);
148 __pSettingPresentationModel = SettingPresentationModel::GetInstance();
150 int startIndex = __pPresentationModel->GetStartIndex();
151 String filePath = __pPresentationModel->GetFilePathAt(startIndex);
153 if (filePath.StartsWith(WEB_URL_HTTP, 0) == true)
155 __initializeDisplayModeCurrent = APPCONTROL_MODE_WEB_LINK;
157 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_MESSAGE)
159 __initializeDisplayModeCurrent = APPCONTROL_MODE_MESSAGE;
161 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_EMAIL)
163 __initializeDisplayModeCurrent = APPCONTROL_MODE_EMAIL;
167 __initializeDisplayModeCurrent = APPCONTROL_MODE_NORMAL;
170 if (filePath == EMPTY_SPACE)
172 MessageBox messageBox;
173 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE,
176 messageBox.ShowAndWait(modalResult);
178 UiApp* pApp = UiApp::GetInstance();
182 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
188 ImageViewerForm::OnInitializing(void)
190 AppLogDebug("ENTER");
191 result r = E_SUCCESS;
192 SetFormBackEventListener(this);
193 __pPresentationModel->AddListener(this);
195 __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL_INFO"));
201 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
202 SetControlAlwaysOnTop(*__pLabel,true);
203 int allCount = __pPresentationModel->GetFileCount();
206 displayText.Append(index);
207 displayText.Append("/");
208 displayText.Append(allCount);
210 __pLabel->SetText(displayText);
213 InitializeDisplay(__initializeDisplayModeCurrent);
214 InitializePanelDetail();
217 __pPopUp = new (std::nothrow) SlideShowPopUp();
219 if (__pPopUp != null)
221 __pPopUp->Initialize();
222 __pPopUp->SetEventListner(this);
223 AddControl(*__pPopUp);
227 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
228 || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
229 || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
231 int index = __pPresentationModel->GetStartIndex();
232 __pGallery->UpdateGallery();
233 __pGallery->SetCurrentItemIndex(index);
236 String filePath = __pPresentationModel->GetFilePathAt(index);
237 __pPresentationModel->RequestImage(filePath);
239 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
246 __pTimer = new (std::nothrow) Timer();
247 __pTimer->Construct(*this);
251 AddOrientationEventListener(*this);
252 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
258 ImageViewerForm::OnInitialized(void)
260 AppLogDebug("ENTER");
261 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
267 ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
269 AppLogDebug("ENTER");
270 if (__detail == false)
272 ShowPanelDetail(true);
276 ShowPanelDetail(false);
279 Rectangle clientRect = GetClientAreaBounds();
280 Rectangle rect = GetBounds();
282 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
283 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
284 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
287 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
291 ImageViewerForm::InitializeDisplay(AppControlMode status)
293 AppLogDebug("ENTER");
295 String strItemIdxText;
297 __pFooter = GetFooter();
298 __pFooter->AddActionEventListener(*this);
299 __pFooter->RemoveAllItems();
301 GetLabelText(0, strItemIdxText);
302 Rectangle rect = GetClientAreaBounds();
305 if (status == APPCONTROL_MODE_NORMAL)
307 __pPlayButton = new (std::nothrow) Button();
308 if (__pPlayButton != null)
310 Rectangle clientRect = GetClientAreaBounds();
312 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
313 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
314 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
315 AddControl(*__pPlayButton);
317 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
318 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
319 delete pNormalBackgroundBitmap;
321 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
322 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
323 delete pPressedBackgroundBitmap;
325 __pPlayButton->AddActionEventListener(*this);
326 __pPlayButton->SetShowState(false);
329 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
330 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
331 __pFooter->SetBackButton();
333 FooterItem footerItem1;
334 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
335 Bitmap* pFooterItemShareNomal =
336 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
337 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
339 FooterItem footerItem2;
340 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DELETE);
341 Bitmap* pFooterItemDeleteNomal =
342 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
343 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
345 __pFooter->AddItem(footerItem1);
346 __pFooter->AddItem(footerItem2);
348 delete pFooterItemShareNomal;
349 delete pFooterItemDeleteNomal;
351 ButtonItem buttonItemMore;
352 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
353 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
354 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
355 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
356 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
357 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
359 else if (status == APPCONTROL_MODE_WEB_LINK)
361 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
362 __pFooter->SetBackButton();
364 FooterItem footerItem1;
365 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
366 Bitmap* pFooterItemShareNomal =
367 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
368 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
370 FooterItem footerItem2;
371 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DOWNLOAD);
372 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
373 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
375 __pFooter->AddItem(footerItem1);
376 __pFooter->AddItem(footerItem2);
378 delete pFooterItemShareNomal;
379 delete pFooterItemDownlordNomal;
381 ButtonItem buttonItemMore;
382 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
383 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
384 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
385 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
386 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
387 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
389 __pFooter->AddItem(footerItem1);
390 __pFooter->AddItem(footerItem2);
392 else if (status == APPCONTROL_MODE_CROP)
394 FooterItem footerItem1;
395 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SAVE);
396 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
397 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
399 FooterItem footerItem2;
400 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_BACK);
401 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
402 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
404 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
405 __pFooter->AddItem(footerItem1);
406 __pFooter->AddItem(footerItem2);
411 else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
413 __pPlayButton = new (std::nothrow) Button();
414 if (__pPlayButton != null)
416 Rectangle clientRect = GetClientAreaBounds();
418 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
419 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
420 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
421 AddControl(*__pPlayButton);
423 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
424 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
425 delete pNormalBackgroundBitmap;
427 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
428 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
429 delete pPressedBackgroundBitmap;
431 __pPlayButton->AddActionEventListener(*this);
432 __pPlayButton->SetShowState(false);
435 __pFooter->SetBackButton();
438 String filePath = __pPresentationModel->GetFilePathAt(0);
439 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
440 if (contentType == CONTENT_TYPE_VIDEO)
442 __pPlayButton->SetShowState(true);
444 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
448 ImageViewerForm::GetLabelText(int index, String &page)
450 AppLogDebug("ENTER");
451 int allCount = __pPresentationModel->GetFileCount();
452 String pStr = __pPresentationModel->GetFilePathAt(index);
453 page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
454 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
458 ImageViewerForm::DeleteImageFile()
460 AppLogDebug("ENTER");
461 int currentIndex = __pGallery->GetCurrentItemIndex();
463 String strItemText(EMPTY_SPACE);
464 String strItemIdxText(EMPTY_SPACE);
465 int countPath = __pPresentationModel->GetFileCount();
466 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
468 if (filePath.GetLength() == 0)
470 UiApp* pApp = UiApp::GetInstance();
472 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
477 result r = File::Remove(filePath);
480 MessageBox messageBox;
481 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
482 MSGBOX_STYLE_NONE, 3000);
484 messageBox.ShowAndWait(modalResult);
485 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
490 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
491 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
493 ContentManager::ScanFile(filePath);
496 __pPresentationModel->DeleteFilePathAt(currentIndex);
499 UiApp* pApp = UiApp::GetInstance();
501 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
505 else if ((countPath - 1) == currentIndex)
507 __pGallery->SetCurrentItemIndex(--currentIndex);
510 __pGallery->UpdateGallery();
511 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
512 __pPresentationModel->RequestImage(filePath);
514 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
516 if (__visible == true)
518 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
520 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
522 __pPlayButton->SetShowState(false);
526 __pPlayButton->SetShowState(true);
530 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
536 ImageViewerForm::CallVideoPlayer(void)
538 AppLogDebug("ENTER");
539 int index = __pGallery->GetCurrentItemIndex();
540 String filePath = __pPresentationModel->GetFilePathAt(index);
541 filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
543 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
544 new (std::nothrow) String(filePath), new (std::nothrow) String(APPCONTROL_MIME_VIDEO_ALL), null, this);
545 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
549 ImageViewerForm::CreateGallery(void)
551 AppLogDebug("ENTER");
552 Rectangle clientRect = GetClientAreaBounds();
553 Rectangle rect = GetBounds();
555 __pGallery = new (std::nothrow) Gallery();
556 __pGallery->Construct(Rectangle(0, clientRect.y, rect.width, rect.height));
557 __pGallery->SetName(L"GalleryControl");
558 __pGallery->SetItemProvider(*this);
559 __pGallery->AddGalleryEventListener(*this);
560 __pGallery->SetBackgroundColor(COLOR_GALLERY_BG);
561 AddControl(*__pGallery);
562 __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
564 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
568 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
569 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
571 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
572 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
574 case SLIDE_SHOW_TRANSITION_EFFECT_SLIDE:
578 __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
580 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
584 ImageViewerForm::InitializePanelDetail()
586 AppLogDebug("ENTER");
587 __pScrollPanel = new (std::nothrow) ScrollPanel();
589 String arrayId[DETAIL_COUNT_MAX] =
591 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
592 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
593 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
596 if (__pScrollPanel == null)
598 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
600 return E_INVALID_STATE;
603 Rectangle clientRect = GetClientAreaBounds();
604 result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height - __pLabel->GetHeight()));
607 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
609 return E_INVALID_STATE;
612 __pDetail_Label = new (std::nothrow) Label();
613 __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
614 __pScrollPanel->AddControl(*__pDetail_Label);
615 __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
616 __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
617 __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
618 __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
620 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
622 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
623 __pDetail_FileInfo_Label[i]->Construct(
624 Rectangle(X_DETAIL_FILEINFO_LABEL,
625 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
626 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
627 __pScrollPanel->AddControl(*__pDetail_FileInfo_Label[i]);
629 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
630 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
631 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
632 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
634 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
636 if (i == DETAIL_COUNT_MAX - 1)
638 __pDetail_FileInfo_Value_Label[i]->Construct(
639 Rectangle(X_DETAIL_FILEINFO_LABEL,
640 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
641 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
645 __pDetail_FileInfo_Value_Label[i]->Construct(
646 Rectangle(X_DETAIL_FILEINFO_LABEL,
647 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
648 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
651 __pScrollPanel->AddControl(*__pDetail_FileInfo_Value_Label[i]);
653 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
654 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
655 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
656 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
659 __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
660 __pScrollPanel->SetShowState(false);
662 __pRenameButton = new (std::nothrow) Button();
663 Rectangle rect = GetBounds();
664 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
665 __pRenameButton->SetActionId(ACTION_ID_PANEL_HEADER_DETAILS_RENAME);
666 __pRenameButton->AddActionEventListener(*this);
668 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
669 Bitmap* pIconBackground =
670 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
671 Bitmap* pIconPressed =
672 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
674 if (pIcon != null && pIconPressed != null && pIconBackground != null)
676 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
677 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
678 Point iconPosition(0, 0);
679 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
680 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
684 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
685 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
689 delete pIconBackground;
691 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
692 __pScrollPanel->AddControl(*__pRenameButton);
695 AddControl(*__pScrollPanel);
696 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
702 ImageViewerForm::InitializePopup(void)
704 AppLogDebug("ENTER");
705 if (__pDeletePopup == null)
707 __pDeletePopup = new (std::nothrow) Popup();
708 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
710 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
712 Label* pLabel = new (std::nothrow) Label();
713 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
714 ResourceManager::GetString(L"IDS_COM_BODY_DELETE") + L"?");
716 Button* pDeleteButton = new (std::nothrow) Button();
717 pDeleteButton->Construct(
718 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
719 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
720 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
721 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
722 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
723 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
724 pDeleteButton->AddActionEventListener(*this);
726 Button* pCancelButton = new (std::nothrow) Button();
727 pCancelButton->Construct(
728 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
729 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
730 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
731 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
732 pCancelButton->AddActionEventListener(*this);
734 __pDeletePopup->AddControl(*pLabel);
735 __pDeletePopup->AddControl(*pDeleteButton);
736 __pDeletePopup->AddControl(*pCancelButton);
740 __pDeletePopup->SetShowState(true);
741 __pDeletePopup->Show();
743 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
749 ImageViewerForm::InitializeContextMenuMore(void)
751 AppLogDebug("ENTER");
752 int currentIndex = __pGallery->GetCurrentItemIndex();
753 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
755 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
757 if (__pContextMenuMore != null)
759 delete __pContextMenuMore;
760 __pContextMenuMore = null;
763 __pContextMenuMore = new (std::nothrow) ContextMenu();
765 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
766 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
768 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
770 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
771 ACTION_ID_CONTEXTMENU_SET_AS);
772 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), ACTION_ID_FOOTER_BUTTON_CROP);
775 if (__pGallery->GetItemCount() > 1)
777 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
778 ACTION_ID_FOOTER_BUTTON_SLIDE);
780 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
781 ACTION_ID_FOOTER_BUTTON_DETAILS);
782 __pContextMenuMore->SetShowState(false);
783 __pContextMenuMore->AddActionEventListener(*this);
784 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
790 ImageViewerForm::InitializeContextMenuSetAs(void)
792 AppLogDebug("ENTER");
794 if (__pContextMenuSetAs != null)
796 delete __pContextMenuSetAs;
797 __pContextMenuSetAs = null;
800 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
801 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
802 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
804 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
805 ACTION_ID_CONTEXTMENU_HOME);
806 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
807 ACTION_ID_CONTEXTMENU_LOCK);
808 __pContextMenuSetAs->AddItem(L"Home and lock screens", ACTION_ID_CONTEXTMENU_HOME_AND_LOCK);
809 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
810 ACTION_ID_CONTEXTMENU_CALLER);
811 __pContextMenuSetAs->AddActionEventListener(*this);
812 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
818 ImageViewerForm::InitializeContextMenuShare(void)
820 AppLogDebug("ENTER");
821 if (__pContextMenuShare != null)
823 delete __pContextMenuShare;
824 __pContextMenuShare = null;
826 __pContextMenuShare = new (std::nothrow) ContextMenu();
827 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
828 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
829 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
831 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
832 ACTION_ID_CONTEXTMENU_MESSAGE);
833 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
834 __pContextMenuShare->AddActionEventListener(*this);
835 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
841 ImageViewerForm::GetFileSize(String filePath)
843 AppLogDebug("ENTER");
847 result r = File::GetAttributes(filePath, attr);
850 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
854 size = attr.GetFileSize();
855 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
861 ImageViewerForm::SetDetailInfo(void)
863 AppLogDebug("ENTER");
865 Rectangle clientRect = GetClientAreaBounds();
866 __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
868 int currentIndex = __pGallery->GetCurrentItemIndex();
869 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
871 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
873 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
875 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
876 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
879 result r = File::GetAttributes(strFilePath, attr);
882 long long nSize = attr.GetFileSize();
883 DateTime dateTime = attr.GetDateTime();
884 strResult[2] = dateTime.ToString();
886 if (nSize > SINGLE_GIGA_BYTE)
888 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
889 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
891 else if (nSize > SINGLE_MEGA_BYTE)
893 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
894 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
896 else if (nSize > SINGLE_KILO_BYTE)
898 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
899 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
903 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
904 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
909 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
910 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
913 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
914 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
915 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
916 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
917 strResult[8] = strFilePath;
918 String fileName = File::GetFileName(strFilePath);
919 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
921 if (strResult[8].StartsWith(Tizen::System::Environment::GetMediaPath(), 0) == true)
923 strResult[8].Replace(Tizen::System::Environment::GetMediaPath(), MEDIA_ROOT_PHONE, 0);
926 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
928 strResult[0] = __downLordFileName;
930 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
932 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
934 if (pImgMeta != null)
936 ImageContentInfo imageContentInfo;
937 r = imageContentInfo.Construct(&strFilePath);
940 strResult[1] = imageContentInfo.GetMediaFormat();
941 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
942 pImgMeta->GetHeight());
944 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
946 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
949 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
951 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
952 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
958 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
960 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
961 if (pVideoMeta != null)
963 VideoContentInfo videoContentInfo;
964 r = videoContentInfo.Construct(&strFilePath);
967 strResult[1] = videoContentInfo.GetMediaFormat();
968 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
969 pVideoMeta->GetHeight());
970 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
972 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
978 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
980 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
981 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
984 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
986 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
990 Rectangle rect = GetBounds();
991 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
993 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
999 ImageViewerForm::ShowPanelDetail(bool showStatus)
1001 AppLogDebug("ENTER");
1005 __pScrollPanel->SetShowState(true);
1010 __pScrollPanel->SetShowState(false);
1013 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1019 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1021 AppLogDebug("ENTER");
1022 FooterItem footerItem;
1023 footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
1024 Bitmap* pfooterItem = null;
1028 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1029 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1033 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1034 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1037 pFooter->SetItemAt(position, footerItem);
1038 pFooter->Invalidate(true);
1041 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1047 ImageViewerForm::DownloadFile(void)
1049 AppLogDebug("ENTER");
1050 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1051 if (File::IsFileExist(DestPath) == false)
1053 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1057 ContentId contentId;
1058 ContentManager contentManager;
1059 contentManager.Construct();
1061 ImageContentInfo imageContentInfo;
1062 imageContentInfo.Construct(null);
1064 imageContentInfo.SetKeyword(L"platform, tizen");
1065 String sourcePath = DestPath;
1066 String destPath = Environment::GetMediaPath();
1067 destPath.Append(FOLDER_PATH_DOWNLOADS);
1068 destPath.Append(__downLordFileName);
1070 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1071 ImageViewerForm::OnFormBackRequested(*this);
1072 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1076 ImageViewerForm::GetItemCount(void)
1078 AppLogDebug("ENTER");
1079 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1081 return __pPresentationModel->GetFileCount();
1085 ImageViewerForm::CreateItem(int index)
1087 AppLogDebug("ENTER : index(%d)", index);
1088 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1090 String filePath = __pPresentationModel->GetFilePathAt(index);
1091 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1092 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1093 if (pBitmap == null)
1095 pBitmap = GetQuickThumbnailN(filePath);
1097 if (pBitmap == null)
1099 pBitmap = new (std::nothrow) Bitmap();
1100 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1103 pGallery->Construct(*pBitmap, filePath);
1105 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1111 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1113 AppLogDebug("ENTER index(%d)", index);
1114 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1115 pImageInfo->ClearBitmap();
1117 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1123 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1125 AppLogDebug("ENTER index(%d)", index);
1127 String filePath = __pPresentationModel->GetFilePathAt(index);
1128 AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1129 __pPresentationModel->RequestImage(filePath);
1131 String strItemIdxText;
1132 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1133 __pLabel->SetText(strItemIdxText);
1135 if (__visible == true)
1137 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1138 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1140 __pPlayButton->SetShowState(true);
1144 __pPlayButton->SetShowState(false);
1149 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1153 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1155 AppLogDebug("ENTER");
1157 String filePath = __pPresentationModel->GetFilePathAt(index);
1158 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1160 if (__visible == true)
1162 if (contentType == CONTENT_TYPE_VIDEO)
1164 __pPlayButton->SetShowState(false);
1167 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1168 __pLabel->SetShowState(false);
1173 if (contentType == CONTENT_TYPE_VIDEO)
1175 __pPlayButton->SetShowState(true);
1178 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1179 __pLabel->SetShowState(true);
1182 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1183 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1186 Rectangle clientRect = GetClientAreaBounds();
1187 Rectangle rect = GetBounds();
1188 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1190 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1194 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1196 AppLogDebug("ENTER");
1197 PowerManager::KeepScreenOnState(true, false);
1198 if (__visible == true)
1200 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1201 __pLabel->SetShowState(false);
1203 int index = __pGallery->GetCurrentItemIndex();
1204 String filePath = __pPresentationModel->GetFilePathAt(index);
1205 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1207 if (contentType == CONTENT_TYPE_VIDEO)
1209 __pPlayButton->SetShowState(false);
1215 Rectangle clientRect = GetClientAreaBounds();
1216 Rectangle rect = GetBounds();
1217 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1219 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1223 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1225 AppLogDebug("ENTER");
1226 PowerManager::KeepScreenOnState(false, true);
1227 int index = __pGallery->GetCurrentItemIndex();
1229 if (__visible == false)
1231 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1232 __pLabel->SetShowState(true);
1233 String filePath = __pPresentationModel->GetFilePathAt(index);
1234 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1235 if (contentType == CONTENT_TYPE_VIDEO)
1237 __pPlayButton->SetShowState(true);
1240 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1241 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1246 String strItemIdxText;
1247 GetLabelText(index, strItemIdxText);
1248 __pLabel->SetText(strItemIdxText);
1251 Rectangle clientRect = GetClientAreaBounds();
1252 Rectangle rect = GetBounds();
1253 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1256 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1260 ImageViewerForm::OnUpdateContentList(void)
1265 ImageViewerForm::OnTerminating(void)
1267 AppLogDebug("ENTER");
1269 if (__pTimer != null)
1276 __pPresentationModel->ClearImageRequests();
1277 __pPresentationModel->RemoveListener(*this);
1278 __pPresentationModel->RemoveFileUpdateListener(*this);
1280 if (__pContextMenuCopy != null)
1282 delete __pContextMenuCopy;
1283 __pContextMenuCopy = null;
1286 if (__pContextMenuSetAs != null)
1288 delete __pContextMenuSetAs;
1289 __pContextMenuSetAs = null;
1292 if (__pDeletePopup != null)
1294 delete __pDeletePopup;
1295 __pDeletePopup = null;
1298 if (__pContextMenuShare != null)
1300 delete __pContextMenuShare;
1301 __pContextMenuShare = null;
1304 if (__pContextMenuMore != null)
1306 delete __pContextMenuMore;
1307 __pContextMenuMore = null;
1310 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1316 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1318 AppLogDebug("ENTER actionId(%d)", actionId);
1319 SceneManager* pSceneManager = SceneManager::GetInstance();
1324 case ACTION_ID_FOOTER_MORE:
1326 InitializeContextMenuMore();
1328 __pContextMenuMore->SetShowState(true);
1329 __pContextMenuMore->Show();
1332 case ACTION_ID_CONTEXTMENU_SET_AS:
1333 InitializeContextMenuSetAs();
1335 __pContextMenuSetAs->SetShowState(true);
1336 __pContextMenuSetAs->Show();
1338 case ACTION_ID_FOOTER_BUTTON_SHARE:
1339 InitializeContextMenuShare();
1341 __pContextMenuShare->SetShowState(true);
1342 __pContextMenuShare->Show();
1344 case ACTION_ID_FOOTER_BUTTON_DELETE:
1345 __pDeletePopup->SetShowState(true);
1346 __pDeletePopup->Show();
1348 case ACTION_ID_FOOTER_BUTTON_SLIDE:
1350 if (__pPopUp != null)
1352 __pPopUp->SetShowState(true);
1358 case ACTION_ID_FOOTER_BUTTON_CROP:
1361 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1362 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1363 pList->Add(new (std::nothrow) String(filePath));
1364 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1367 case ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT:
1369 int currentIndex = __pGallery->GetCurrentItemIndex();
1370 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1371 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1372 __pPresentationModel->SetImageRotateStatus(true);
1373 RotateImage(filePath, rotateMode);
1374 __pPresentationModel->RequestImage(filePath);
1376 ContentManager contentManager;
1377 contentManager.Construct();
1378 contentManager.ScanFile(filePath);
1381 case ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT:
1383 int currentIndex = __pGallery->GetCurrentItemIndex();
1384 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1385 RotateMode rotateMode = ROTATE_MODE_LEFT;
1386 __pPresentationModel->SetImageRotateStatus(true);
1387 RotateImage(filePath, rotateMode);
1388 __pPresentationModel->RequestImage(filePath);
1390 ContentManager contentManager;
1391 contentManager.Construct();
1392 contentManager.ScanFile(filePath);
1395 case ACTION_ID_FOOTER_BUTTON_DETAILS:
1397 ShowPanelDetail(__detail);
1400 case ACTION_ID_FOOTER_BUTTON_BACK:
1401 ImageViewerForm::OnFormBackRequested(*this);
1403 case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1406 case ACTION_ID_FOOTER_BUTTON_SAVE:
1408 case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1410 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1411 pSelectedIndex->Construct();
1412 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1413 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1416 case ACTION_ID_CONTEXTMENU_HOME:
1418 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1419 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1420 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1421 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1422 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1425 case ACTION_ID_CONTEXTMENU_LOCK:
1427 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1428 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1429 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1430 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1431 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1434 case ACTION_ID_CONTEXTMENU_CALLER:
1436 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1437 pDataList->Construct();
1438 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1439 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1440 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1441 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1442 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1443 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1445 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1446 APPCONTROL_OPERATION_ID_PICK, null, null, pDataList, this);
1450 case ACTION_ID_CONTEXTMENU_HOME_AND_LOCK:
1452 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1453 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1454 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1455 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1456 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1461 case ACTION_ID_CONTEXTMENU_EMAIL:
1463 OnRequestEmailAction();
1466 case ACTION_ID_CONTEXTMENU_MESSAGE:
1468 OnRequestMessagesAction();
1471 case ACTION_ID_CONTEXTMENU_COPY:
1473 int currentIndex = __pGallery->GetCurrentItemIndex();
1474 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1477 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1478 Clipboard* pClipboard = Clipboard::GetInstance();
1479 pClipboard->CopyItem(item);
1482 case ACTION_ID_DELETE_POPUP_DEL:
1484 __pDeletePopup->SetShowState(false);
1485 __pDeletePopup->Show();
1488 if (__detail == false)
1490 ShowPanelDetail(false);
1494 case ACTION_ID_DELETE_POPUP_CANCEL:
1496 __pDeletePopup->SetShowState(false);
1497 __pDeletePopup->Show();
1500 case ACTION_ID_CONTORL_BUTTON_PLAY:
1506 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1510 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1512 result r = E_SUCCESS;
1513 ImageBuffer* pRotatedBuffer = null;
1514 ImageBuffer* pRotatedBuffer1 = null;
1515 ImageFormat imageFormat;
1518 pRotatedBuffer = new (std::nothrow) ImageBuffer();
1519 r = pRotatedBuffer->Construct(filePath);
1520 pRotatedBuffer->GetImageInfo(filePath, imageFormat, width, height);
1523 if (rotateMode == ROTATE_MODE_RIGHT)
1525 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_90);
1529 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_270);
1532 TryCatch(pRotatedBuffer1 != null, r = GetLastResult(), "RotateN failed:%s", GetErrorMessage(GetLastResult()));
1533 pRotatedBuffer1->EncodeToFile(filePath, imageFormat, true, 100);
1534 delete pRotatedBuffer1;
1535 delete pRotatedBuffer;
1539 if (pRotatedBuffer != null) //this buffer is no longer used
1541 delete pRotatedBuffer;
1543 if (pRotatedBuffer1 != null) //this buffer is no longer used
1545 delete pRotatedBuffer1;
1551 ImageViewerForm::OnFormBackRequested(Form& source)
1553 AppLogDebug("ENTER");
1554 if (__detail == false)
1556 ShowPanelDetail(false);
1560 UiApp* pApp = UiApp::GetInstance();
1563 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1567 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1568 const SceneId& currentSceneId, IList* pArgs)
1570 AppLogDebug("ENTER");
1572 Rectangle clientRect = GetClientAreaBounds();
1573 Rectangle rect = GetBounds();
1575 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1576 __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight()));
1577 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1579 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1582 String strItemIdxText(EMPTY_SPACE);
1583 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1584 __pLabel->SetText(strItemIdxText);
1588 if (__pGallery->GetCurrentItemIndex() < 0)
1590 SetFooterItemState(false);
1594 SetFooterItemState(true);
1597 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1601 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1602 const SceneId& nextSceneId)
1604 AppLogDebug("ENTER");
1605 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1609 ImageViewerForm::OnImageDecodedN(const int index)
1611 AppLogDebug("ENTER");
1612 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1614 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1618 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1619 const String& operationId, AppCtrlResult appControlResult,
1620 const IMap* pExtraData)
1622 AppLogDebug("ENTER");
1624 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1625 && operationId == APPCONTROL_OPERATION_ID_PICK
1626 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1628 const String* pContactId =
1629 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1630 SceneManager* pSceneManager = SceneManager::GetInstance();
1631 long long lresult = 0;
1632 if (pContactId != null && pContactId->GetLength() > 0)
1634 LongLong::Parse(*pContactId, lresult);
1636 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1637 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1638 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1639 pList->Add(new (std::nothrow) LongLong(lresult));
1640 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1641 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1644 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1645 pImageViewerApp->SetFrameEnabled(true);
1646 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1650 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1652 AppLogDebug("ENTER");
1653 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1657 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1659 AppLogDebug("ENTER");
1660 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1664 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1666 AppLogDebug("ENTER");
1667 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1671 ImageViewerForm::OnOtherControlSelected(const Control& source)
1673 AppLogDebug("ENTER");
1674 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1678 ImageViewerForm::InitShowGallery(void)
1680 AppLogDebug("ENTER");
1681 if (__pGallery != null && __pGallery->IsVisible() == false)
1683 Canvas* pCanvas = GetCanvasN();
1684 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1686 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1692 __pGallery->SetShowState(true);
1695 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1699 ImageViewerForm::OnTimerExpired(Timer &timer)
1701 int repeatValue = 0;
1702 AppLogDebug("ENTER");
1703 if (__pPresentationModel->GetFileCount() > 1)
1705 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1706 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1708 if (repeatValue == 0)
1710 __pGallery->StartSlideShow(false);
1714 __pGallery->StartSlideShow(true);
1717 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1721 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1723 AppLogDebug("ENTER");
1724 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1728 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1729 const String& errorMessage)
1731 AppLogDebug("ENTER");
1732 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1736 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1737 result transferResult, const String& errorCode, const String& errorMessage)
1739 AppLogDebug("ENTER");
1740 AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1741 AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1742 AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1743 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1747 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1748 const String& errorCode, const String& errorMessage)
1750 AppLogDebug("ENTER");
1751 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1755 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1756 const String& errorMessage)
1758 AppLogDebug("ENTER");
1759 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1763 ImageViewerForm::RequestDecodeUrl(void)
1765 AppLogDebug("ENTER");
1767 String filePath = __pPresentationModel->GetFilePathAt(0);
1769 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1771 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1776 __downLordFileName = __pPresentationModel->GetFileName(filePath);
1778 Image* pImage = new (std::nothrow) Image();
1779 pImage->Construct();
1782 uri.SetUri(filePath);
1784 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1787 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1791 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1792 result r, const String errorCode, const String errorMessage)
1794 AppLogDebug("ENTER");
1795 Image* pImage = new (std::nothrow) Image();
1796 pImage->Construct();
1798 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1799 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1803 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1804 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1806 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1808 __pPresentationModel->RequestImage(destPath);
1812 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1816 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1820 ImageViewerForm::OnRequestEmailAction(void)
1822 AppLogDebug("ENTER");
1823 int currentIndex = __pGallery->GetCurrentItemIndex();
1825 if (__pPresentationModel->GetFileCount() <= 0)
1827 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1831 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1833 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1834 pDataList->Construct();
1836 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1837 pList->Add(new (std::nothrow) String(filePath));
1839 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1841 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
1842 new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, this);
1843 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1847 ImageViewerForm::OnRequestMessagesAction(void)
1849 AppLogDebug("ENTER");
1850 int currentIndex = __pGallery->GetCurrentItemIndex();
1852 if (__pPresentationModel->GetFileCount() <= 0)
1854 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1858 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1860 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1861 pDataList->Construct();
1862 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1863 pList->Add(new (std::nothrow) String(filePath));
1864 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1866 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES, APPCONTROL_OPERATION_ID_COMPOSE,
1867 new (std::nothrow) String(APPCONTROL_URI_MMS_TO), null, pDataList, this);
1868 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1872 ImageViewerForm::SetFooterItemState(bool isEnable)
1874 AppLogDebug("ENTER");
1875 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
1877 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1878 __pFooter->SetItemEnabled(0, isEnable);
1879 __pFooter->SetItemEnabled(1, isEnable);
1881 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1883 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1884 __pFooter->SetItemEnabled(0, isEnable);
1885 __pFooter->SetItemEnabled(1, isEnable);
1887 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
1889 __pFooter->SetItemEnabled(0, isEnable);
1891 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1895 ImageViewerForm::GetQuickThumbnailN(String& filePath)
1897 AppLogDebug("ENTER");
1898 Bitmap* pBitmap = null;
1900 if (filePath.GetLength() > 4)
1904 ContentSearch contentSearch;
1905 ContentSearchResult* pResultItem = null;
1906 IList* pContentInfoList = null;
1908 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1909 result r = contentSearch.Construct(contentType);
1910 AppLogDebug("r(%s)", GetErrorMessage(r));
1913 pBitmap = new (std::nothrow) Bitmap();
1914 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1925 queryString = CONTENT_QUERY_PREFIX_FILENAME;
1926 queryString.Append(L"'");
1927 queryString.Append(__pPresentationModel->GetFileName(filePath));
1928 queryString.Append(L"'");
1930 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
1931 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
1933 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
1935 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
1936 while (pEnum->MoveNext() == E_SUCCESS)
1938 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
1939 if (pResultItem == null)
1944 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
1946 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
1952 if (pContentInfoList != null)
1954 delete pContentInfoList;
1957 if (pBitmap != null)
1959 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1961 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1963 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
1964 result r = imageBuffer->Construct(filePath);
1967 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
1968 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
1970 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
1971 pBitmap->Scale(srcDim);
1975 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
1976 pBitmap->Scale(srcDim);
1982 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1984 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
1986 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
1988 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
1989 pBitmap->Scale(srcDim);
1997 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
1998 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
1999 pBitmap = new (std::nothrow) Bitmap();
2000 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2003 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2007 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2009 AppLogDebug(" ENTER");
2010 bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF);
2011 bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
2013 int currentIndex = __pGallery->GetCurrentItemIndex();
2014 int countPath = __pPresentationModel->GetFileCount();
2016 if (countPath == 0 && eventDelete)
2018 UiApp* pApp = UiApp::GetInstance();
2020 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2022 AppLogDebug(" countPath is %d", countPath);
2023 AppLogDebug(" currentIndex is %d", currentIndex);
2025 if (countPath == currentIndex && eventDelete)
2027 __pGallery->SetCurrentItemIndex(--currentIndex);
2031 currentIndex = index;
2032 __pGallery->SetCurrentItemIndex(currentIndex);
2035 String strItemIdxText(EMPTY_SPACE);
2037 __pGallery->UpdateGallery();
2038 AppLogDebug(" UpdateGallery is %d", currentIndex);
2039 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2040 __pPresentationModel->RequestImage(filePath);
2042 GetLabelText(currentIndex,strItemIdxText);
2043 __pLabel->SetText(strItemIdxText);
2045 if (__visible == true)
2047 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2049 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2051 __pPlayButton->SetShowState(false);
2055 __pPlayButton->SetShowState(true);
2058 if (__detail == false)
2060 __pScrollPanel->SetShowState(false);
2065 AppLogDebug("EXIT");
2069 ImageViewerForm::OnSlideSettingPopUpItemSelected(int index)
2071 if ( __pPopUp != NULL)
2073 __pPopUp->SetShowState(false);
2076 if (index == 0) // start slide show
2078 int repeatValue = 0;
2080 if (__pPresentationModel->GetFileCount() > 1)
2082 __pGallery->UpdateGallery();
2084 if (__detail == false)
2086 ShowPanelDetail(false);
2089 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2090 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2092 if (repeatValue == 0)
2094 __pGallery->StartSlideShow(false);
2098 __pGallery->StartSlideShow(true);
2102 else if (index == 1) // launch settings
2104 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY,
2105 APPCONTROL_OPERATION_ID_CONFIGURE, null, null, null, this);