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 : __shuffelStartIndex(0)
98 , __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
101 , __pScrollPanel(null)
102 , __pDetail_Label(null)
103 , __pLabelMessage(null)
104 , __pPlayButton(null)
105 , __pRenameButton(null)
106 , __pDetailFooterItem(null)
109 , __pShuffelTimer(null)
110 , __pContextMenuMore(null)
111 , __pContextMenuCopy(null)
112 , __pContextMenuSetAs(null)
113 , __pContextMenuShare(null)
114 , __pDeletePopup(null)
117 , __startSlide(false)
120 , __pShuffledList(null)
121 , __pPresentationModel(null)
123 AppLogDebug("ENTER");
124 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
127 ImageViewerForm::~ImageViewerForm(void)
129 AppLogDebug("ENTER");
130 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
134 ImageViewerForm::Initialize()
136 AppLogDebug("ENTER");
138 result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
140 __pPresentationModel = ImageViewerPresentationModel::GetInstance();
142 if (__pPresentationModel->GetFileCount() > 0)
144 if (__pPresentationModel->GetType() == APPCONTROL_DATA_SLIDE_SHOW)
150 __pPresentationModel->AddFileUpdateListener(this);
152 __pSettingPresentationModel = SettingPresentationModel::GetInstance();
154 int startIndex = __pPresentationModel->GetStartIndex();
155 String filePath = __pPresentationModel->GetFilePathAt(startIndex);
157 if (filePath.StartsWith(WEB_URL_HTTP, 0) == true)
159 __initializeDisplayModeCurrent = APPCONTROL_MODE_WEB_LINK;
161 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_MESSAGE)
163 __initializeDisplayModeCurrent = APPCONTROL_MODE_MESSAGE;
165 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_EMAIL)
167 __initializeDisplayModeCurrent = APPCONTROL_MODE_EMAIL;
171 __initializeDisplayModeCurrent = APPCONTROL_MODE_NORMAL;
174 if (filePath == EMPTY_SPACE)
176 MessageBox messageBox;
177 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE,
180 messageBox.ShowAndWait(modalResult);
182 UiApp* pApp = UiApp::GetInstance();
186 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
192 ImageViewerForm::OnInitializing(void)
194 AppLogDebug("ENTER");
195 result r = E_SUCCESS;
196 SetFormBackEventListener(this);
197 __pPresentationModel->AddListener(this);
199 __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL_INFO"));
205 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
206 SetControlAlwaysOnTop(*__pLabel,true);
207 int allCount = __pPresentationModel->GetFileCount();
210 displayText.Append(index);
211 displayText.Append("/");
212 displayText.Append(allCount);
214 __pLabel->SetText(displayText);
217 InitializeDisplay(__initializeDisplayModeCurrent);
218 InitializePanelDetail();
221 __pPopUp = new (std::nothrow) SlideShowPopUp();
223 if (__pPopUp != null)
225 __pPopUp->Initialize();
226 __pPopUp->SetEventListner(this);
227 AddControl(*__pPopUp);
231 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
232 || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
233 || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
235 int index = __pPresentationModel->GetStartIndex();
236 __pGallery->UpdateGallery();
237 __pGallery->SetCurrentItemIndex(index);
240 String filePath = __pPresentationModel->GetFilePathAt(index);
241 __pPresentationModel->RequestImage(filePath);
243 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
250 __pTimer = new (std::nothrow) Timer();
251 __pTimer->Construct(*this);
255 AddOrientationEventListener(*this);
256 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
262 ImageViewerForm::OnInitialized(void)
264 AppLogDebug("ENTER");
265 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
271 ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
273 AppLogDebug("ENTER");
274 if (__detail == false)
276 ShowPanelDetail(true);
280 ShowPanelDetail(false);
283 Rectangle clientRect = GetClientAreaBounds();
284 Rectangle rect = GetBounds();
286 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
287 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
288 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
291 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
295 ImageViewerForm::InitializeDisplay(AppControlMode status)
297 AppLogDebug("ENTER");
299 String strItemIdxText;
301 __pFooter = GetFooter();
302 __pFooter->AddActionEventListener(*this);
303 __pFooter->RemoveAllItems();
305 GetLabelText(0, strItemIdxText);
306 Rectangle rect = GetClientAreaBounds();
309 if (status == APPCONTROL_MODE_NORMAL)
311 __pPlayButton = new (std::nothrow) Button();
312 if (__pPlayButton != null)
314 Rectangle clientRect = GetClientAreaBounds();
316 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
317 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
318 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
319 AddControl(*__pPlayButton);
321 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
322 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
323 delete pNormalBackgroundBitmap;
325 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
326 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
327 delete pPressedBackgroundBitmap;
329 __pPlayButton->AddActionEventListener(*this);
330 __pPlayButton->SetShowState(false);
333 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
334 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
335 __pFooter->SetBackButton();
337 FooterItem footerItem1;
338 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
339 Bitmap* pFooterItemShareNomal =
340 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
341 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
343 FooterItem footerItem2;
344 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DELETE);
345 Bitmap* pFooterItemDeleteNomal =
346 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
347 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
349 __pFooter->AddItem(footerItem1);
350 __pFooter->AddItem(footerItem2);
352 delete pFooterItemShareNomal;
353 delete pFooterItemDeleteNomal;
355 ButtonItem buttonItemMore;
356 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
357 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
358 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
359 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
360 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
361 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
363 else if (status == APPCONTROL_MODE_WEB_LINK)
365 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
366 __pFooter->SetBackButton();
368 FooterItem footerItem1;
369 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
370 Bitmap* pFooterItemShareNomal =
371 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
372 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
374 FooterItem footerItem2;
375 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DOWNLOAD);
376 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
377 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
379 __pFooter->AddItem(footerItem1);
380 __pFooter->AddItem(footerItem2);
382 delete pFooterItemShareNomal;
383 delete pFooterItemDownlordNomal;
385 ButtonItem buttonItemMore;
386 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
387 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
388 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
389 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
390 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
391 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
393 __pFooter->AddItem(footerItem1);
394 __pFooter->AddItem(footerItem2);
396 else if (status == APPCONTROL_MODE_CROP)
398 FooterItem footerItem1;
399 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SAVE);
400 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
401 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
403 FooterItem footerItem2;
404 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_BACK);
405 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
406 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
408 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
409 __pFooter->AddItem(footerItem1);
410 __pFooter->AddItem(footerItem2);
415 else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
417 __pPlayButton = new (std::nothrow) Button();
418 if (__pPlayButton != null)
420 Rectangle clientRect = GetClientAreaBounds();
422 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
423 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
424 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
425 AddControl(*__pPlayButton);
427 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
428 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
429 delete pNormalBackgroundBitmap;
431 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
432 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
433 delete pPressedBackgroundBitmap;
435 __pPlayButton->AddActionEventListener(*this);
436 __pPlayButton->SetShowState(false);
439 __pFooter->SetBackButton();
442 String filePath = __pPresentationModel->GetFilePathAt(0);
443 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
444 if (contentType == CONTENT_TYPE_VIDEO)
446 __pPlayButton->SetShowState(true);
448 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
452 ImageViewerForm::GetLabelText(int index, String &page)
454 AppLogDebug("ENTER");
455 int allCount = __pPresentationModel->GetFileCount();
456 String pStr = __pPresentationModel->GetFilePathAt(index);
457 page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
458 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
462 ImageViewerForm::DeleteImageFile()
464 AppLogDebug("ENTER");
465 int currentIndex = __pGallery->GetCurrentItemIndex();
467 String strItemText(EMPTY_SPACE);
468 String strItemIdxText(EMPTY_SPACE);
469 int countPath = __pPresentationModel->GetFileCount();
470 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
472 if (filePath.GetLength() == 0)
474 UiApp* pApp = UiApp::GetInstance();
476 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
481 result r = File::Remove(filePath);
484 MessageBox messageBox;
485 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
486 MSGBOX_STYLE_NONE, 3000);
488 messageBox.ShowAndWait(modalResult);
489 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
494 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
495 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
497 ContentManager::ScanFile(filePath);
500 __pPresentationModel->DeleteFilePathAt(currentIndex);
503 UiApp* pApp = UiApp::GetInstance();
505 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
509 else if ((countPath - 1) == currentIndex)
511 __pGallery->SetCurrentItemIndex(--currentIndex);
514 __pGallery->UpdateGallery();
515 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
516 __pPresentationModel->RequestImage(filePath);
518 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
520 if (__visible == true)
522 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
524 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
526 __pPlayButton->SetShowState(false);
530 __pPlayButton->SetShowState(true);
534 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
540 ImageViewerForm::CallVideoPlayer(void)
542 AppLogDebug("ENTER");
543 int index = __pGallery->GetCurrentItemIndex();
544 String filePath = __pPresentationModel->GetFilePathAt(index);
545 filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
547 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
548 new (std::nothrow) String(filePath), new (std::nothrow) String(APPCONTROL_MIME_VIDEO_ALL), null, this);
549 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
553 ImageViewerForm::CreateGallery(void)
555 AppLogDebug("ENTER");
556 Rectangle clientRect = GetClientAreaBounds();
557 Rectangle rect = GetBounds();
559 __pGallery = new (std::nothrow) Gallery();
560 __pGallery->Construct(Rectangle(0, clientRect.y, rect.width, rect.height));
561 __pGallery->SetName(L"GalleryControl");
562 __pGallery->SetItemProvider(*this);
563 __pGallery->AddGalleryEventListener(*this);
564 __pGallery->SetBackgroundColor(COLOR_GALLERY_BG);
565 AddControl(*__pGallery);
566 __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
568 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
572 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
573 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
575 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
576 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
578 case SLIDE_SHOW_TRANSITION_EFFECT_SLIDE:
582 __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
584 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
588 ImageViewerForm::InitializePanelDetail()
590 AppLogDebug("ENTER");
591 __pScrollPanel = new (std::nothrow) ScrollPanel();
593 String arrayId[DETAIL_COUNT_MAX] =
595 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
596 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
597 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
600 if (__pScrollPanel == null)
602 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
604 return E_INVALID_STATE;
607 Rectangle clientRect = GetClientAreaBounds();
608 result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height - __pLabel->GetHeight()));
611 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
613 return E_INVALID_STATE;
616 __pDetail_Label = new (std::nothrow) Label();
617 __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
618 __pScrollPanel->AddControl(*__pDetail_Label);
619 __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
620 __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
621 __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
622 __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
624 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
626 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
627 __pDetail_FileInfo_Label[i]->Construct(
628 Rectangle(X_DETAIL_FILEINFO_LABEL,
629 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
630 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
631 __pScrollPanel->AddControl(*__pDetail_FileInfo_Label[i]);
633 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
634 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
635 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
636 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
638 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
640 if (i == DETAIL_COUNT_MAX - 1)
642 __pDetail_FileInfo_Value_Label[i]->Construct(
643 Rectangle(X_DETAIL_FILEINFO_LABEL,
644 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
645 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
649 __pDetail_FileInfo_Value_Label[i]->Construct(
650 Rectangle(X_DETAIL_FILEINFO_LABEL,
651 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
652 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
655 __pScrollPanel->AddControl(*__pDetail_FileInfo_Value_Label[i]);
657 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
658 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
659 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
660 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
663 __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
664 __pScrollPanel->SetShowState(false);
666 __pRenameButton = new (std::nothrow) Button();
667 Rectangle rect = GetBounds();
668 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
669 __pRenameButton->SetActionId(ACTION_ID_PANEL_HEADER_DETAILS_RENAME);
670 __pRenameButton->AddActionEventListener(*this);
672 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
673 Bitmap* pIconBackground =
674 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
675 Bitmap* pIconPressed =
676 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
678 if (pIcon != null && pIconPressed != null && pIconBackground != null)
680 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
681 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
682 Point iconPosition(0, 0);
683 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
684 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
688 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
689 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
693 delete pIconBackground;
695 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
696 __pScrollPanel->AddControl(*__pRenameButton);
699 AddControl(*__pScrollPanel);
700 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
706 ImageViewerForm::InitializePopup(void)
708 AppLogDebug("ENTER");
709 if (__pDeletePopup == null)
711 __pDeletePopup = new (std::nothrow) Popup();
712 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
714 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
716 Label* pLabel = new (std::nothrow) Label();
717 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
718 ResourceManager::GetString(L"IDS_COM_BODY_DELETE") + L"?");
720 Button* pDeleteButton = new (std::nothrow) Button();
721 pDeleteButton->Construct(
722 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
723 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
724 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
725 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
726 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
727 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
728 pDeleteButton->AddActionEventListener(*this);
730 Button* pCancelButton = new (std::nothrow) Button();
731 pCancelButton->Construct(
732 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
733 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
734 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
735 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
736 pCancelButton->AddActionEventListener(*this);
738 __pDeletePopup->AddControl(*pLabel);
739 __pDeletePopup->AddControl(*pDeleteButton);
740 __pDeletePopup->AddControl(*pCancelButton);
744 __pDeletePopup->SetShowState(true);
745 __pDeletePopup->Show();
747 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
753 ImageViewerForm::InitializeContextMenuMore(void)
755 AppLogDebug("ENTER");
756 int currentIndex = __pGallery->GetCurrentItemIndex();
757 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
759 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
761 if (__pContextMenuMore != null)
763 delete __pContextMenuMore;
764 __pContextMenuMore = null;
767 __pContextMenuMore = new (std::nothrow) ContextMenu();
769 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().height),
770 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
772 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
774 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
775 ACTION_ID_CONTEXTMENU_SET_AS);
776 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), ACTION_ID_FOOTER_BUTTON_CROP);
779 if (__pGallery->GetItemCount() > 1)
781 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
782 ACTION_ID_FOOTER_BUTTON_SLIDE);
784 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
785 ACTION_ID_FOOTER_BUTTON_DETAILS);
786 __pContextMenuMore->SetShowState(false);
787 __pContextMenuMore->AddActionEventListener(*this);
788 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
794 ImageViewerForm::InitializeContextMenuSetAs(void)
796 AppLogDebug("ENTER");
798 if (__pContextMenuSetAs != null)
800 delete __pContextMenuSetAs;
801 __pContextMenuSetAs = null;
804 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
805 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
806 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
808 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
809 ACTION_ID_CONTEXTMENU_HOME);
810 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
811 ACTION_ID_CONTEXTMENU_LOCK);
812 __pContextMenuSetAs->AddItem(L"Home and lock screens", ACTION_ID_CONTEXTMENU_HOME_AND_LOCK);
813 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
814 ACTION_ID_CONTEXTMENU_CALLER);
815 __pContextMenuSetAs->AddActionEventListener(*this);
816 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
822 ImageViewerForm::InitializeContextMenuShare(void)
824 AppLogDebug("ENTER");
825 if (__pContextMenuShare != null)
827 delete __pContextMenuShare;
828 __pContextMenuShare = null;
830 __pContextMenuShare = new (std::nothrow) ContextMenu();
831 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
832 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
833 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
835 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
836 ACTION_ID_CONTEXTMENU_MESSAGE);
837 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
838 __pContextMenuShare->AddActionEventListener(*this);
839 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
845 ImageViewerForm::GetFileSize(String filePath)
847 AppLogDebug("ENTER");
851 result r = File::GetAttributes(filePath, attr);
854 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
858 size = attr.GetFileSize();
859 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
865 ImageViewerForm::SetDetailInfo(void)
867 AppLogDebug("ENTER");
869 Rectangle clientRect = GetClientAreaBounds();
870 __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
872 int currentIndex = __pGallery->GetCurrentItemIndex();
873 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
875 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
877 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
879 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
880 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
883 result r = File::GetAttributes(strFilePath, attr);
886 long long nSize = attr.GetFileSize();
887 DateTime dateTime = attr.GetDateTime();
888 strResult[2] = dateTime.ToString();
890 if (nSize > SINGLE_GIGA_BYTE)
892 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
893 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
895 else if (nSize > SINGLE_MEGA_BYTE)
897 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
898 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
900 else if (nSize > SINGLE_KILO_BYTE)
902 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
903 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
907 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
908 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
913 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
914 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
917 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
918 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
919 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
920 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
921 strResult[8] = strFilePath;
922 String fileName = File::GetFileName(strFilePath);
923 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
925 if (strResult[8].StartsWith(Tizen::System::Environment::GetMediaPath(), 0) == true)
927 strResult[8].Replace(Tizen::System::Environment::GetMediaPath(), MEDIA_ROOT_PHONE, 0);
930 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
932 strResult[0] = __downLordFileName;
934 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
936 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
938 if (pImgMeta != null)
940 ImageContentInfo imageContentInfo;
941 r = imageContentInfo.Construct(&strFilePath);
944 strResult[1] = imageContentInfo.GetMediaFormat();
945 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
946 pImgMeta->GetHeight());
948 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
950 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
953 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
955 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
956 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
962 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
964 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
965 if (pVideoMeta != null)
967 VideoContentInfo videoContentInfo;
968 r = videoContentInfo.Construct(&strFilePath);
971 strResult[1] = videoContentInfo.GetMediaFormat();
972 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
973 pVideoMeta->GetHeight());
974 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
976 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
982 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
984 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
985 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
988 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
990 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
994 Rectangle rect = GetBounds();
995 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
997 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1003 ImageViewerForm::ShowPanelDetail(bool showStatus)
1005 AppLogDebug("ENTER");
1009 __pScrollPanel->SetShowState(true);
1014 __pScrollPanel->SetShowState(false);
1017 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1023 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1025 AppLogDebug("ENTER");
1026 FooterItem footerItem;
1027 footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
1028 Bitmap* pfooterItem = null;
1032 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1033 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1037 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1038 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1041 pFooter->SetItemAt(position, footerItem);
1042 pFooter->Invalidate(true);
1045 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1051 ImageViewerForm::DownloadFile(void)
1053 AppLogDebug("ENTER");
1054 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1055 if (File::IsFileExist(DestPath) == false)
1057 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1061 ContentId contentId;
1062 ContentManager contentManager;
1063 contentManager.Construct();
1065 ImageContentInfo imageContentInfo;
1066 imageContentInfo.Construct(null);
1068 imageContentInfo.SetKeyword(L"platform, tizen");
1069 String sourcePath = DestPath;
1070 String destPath = Environment::GetMediaPath();
1071 destPath.Append(FOLDER_PATH_DOWNLOADS);
1072 destPath.Append(__downLordFileName);
1074 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1075 ImageViewerForm::OnFormBackRequested(*this);
1076 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1080 ImageViewerForm::GetItemCount(void)
1082 AppLogDebug("ENTER");
1083 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1085 return __pPresentationModel->GetFileCount();
1089 ImageViewerForm::CreateItem(int index)
1091 AppLogDebug("ENTER : index(%d)", index);
1092 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1094 int curIndex = index;
1096 if(__shuffle == true && __pShuffledList != null)
1098 curIndex = __pShuffledList[index];
1101 String filePath = __pPresentationModel->GetFilePathAt(curIndex);
1102 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1103 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1105 if (pBitmap == null)
1107 pBitmap = GetQuickThumbnailN(filePath);
1109 if (pBitmap == null)
1111 pBitmap = new (std::nothrow) Bitmap();
1112 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1115 pGallery->Construct(*pBitmap, filePath);
1117 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1123 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1125 AppLogDebug("ImageViewerForm::DeleteItem ENTER index(%d)", index);
1126 int curIndex = index;
1128 if(__shuffle == true && __pShuffledList != null)
1130 curIndex = __pShuffledList[index];
1134 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1135 pImageInfo->ClearBitmap();
1137 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1143 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1145 AppLogDebug("ImageViewerForm::OnGalleryCurrentItemChanged index(%d)", index);
1147 String filePath = __pPresentationModel->GetFilePathAt(index);
1148 AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1149 __pPresentationModel->RequestImage(filePath);
1151 String strItemIdxText;
1152 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1153 __pLabel->SetText(strItemIdxText);
1155 if (__visible == true)
1157 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1158 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1160 __pPlayButton->SetShowState(true);
1164 __pPlayButton->SetShowState(false);
1169 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1173 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1175 AppLogDebug("ENTER");
1177 String filePath = __pPresentationModel->GetFilePathAt(index);
1178 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1180 if (__visible == true)
1182 if (contentType == CONTENT_TYPE_VIDEO)
1184 __pPlayButton->SetShowState(false);
1187 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1188 __pLabel->SetShowState(false);
1193 if (contentType == CONTENT_TYPE_VIDEO)
1195 __pPlayButton->SetShowState(true);
1198 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1199 __pLabel->SetShowState(true);
1202 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1203 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1206 Rectangle clientRect = GetClientAreaBounds();
1207 Rectangle rect = GetBounds();
1208 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1210 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1214 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1216 AppLogDebug("ENTER");
1217 PowerManager::KeepScreenOnState(true, false);
1218 if (__visible == true)
1220 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1221 __pLabel->SetShowState(false);
1223 int index = __pGallery->GetCurrentItemIndex();
1224 String filePath = __pPresentationModel->GetFilePathAt(index);
1225 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1227 if (contentType == CONTENT_TYPE_VIDEO)
1229 __pPlayButton->SetShowState(false);
1235 Rectangle clientRect = GetClientAreaBounds();
1236 Rectangle rect = GetBounds();
1237 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1239 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1243 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1245 AppLogDebug("ImageViewerForm::OnGallerySlideShowStopped");
1249 if(__shuffle == true)
1252 if(__pShuffelTimer == null)
1254 __pShuffelTimer = new (std::nothrow) Timer();
1255 __pShuffelTimer->Construct(*this);
1257 __pShuffelTimer->Start(1);
1261 index = __pGallery->GetCurrentItemIndex();
1262 SlideShowStopped(index);
1266 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1270 ImageViewerForm::SlideShowStopped(int index)
1272 AppLog("ImageViewerForm::SlideShowStopped");
1273 PowerManager::KeepScreenOnState(false, true);
1275 if (__visible == false)
1277 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1278 __pLabel->SetShowState(true);
1279 String filePath = __pPresentationModel->GetFilePathAt(index);
1280 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1281 if (contentType == CONTENT_TYPE_VIDEO)
1283 __pPlayButton->SetShowState(true);
1286 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1287 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1292 String strItemIdxText;
1293 GetLabelText(index, strItemIdxText);
1294 __pLabel->SetText(strItemIdxText);
1297 Rectangle clientRect = GetClientAreaBounds();
1298 Rectangle rect = GetBounds();
1299 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1305 ImageViewerForm::OnUpdateContentList(void)
1310 ImageViewerForm::OnTerminating(void)
1312 AppLogDebug("ENTER");
1314 if (__pTimer != null)
1323 __pShuffelTimer->Cancel();
1324 delete __pShuffelTimer;
1325 __pShuffelTimer = null;
1328 __pPresentationModel->ClearImageRequests();
1329 __pPresentationModel->RemoveListener(*this);
1330 __pPresentationModel->RemoveFileUpdateListener(*this);
1332 if (__pContextMenuCopy != null)
1334 delete __pContextMenuCopy;
1335 __pContextMenuCopy = null;
1338 if (__pContextMenuSetAs != null)
1340 delete __pContextMenuSetAs;
1341 __pContextMenuSetAs = null;
1344 if (__pDeletePopup != null)
1346 delete __pDeletePopup;
1347 __pDeletePopup = null;
1350 if (__pContextMenuShare != null)
1352 delete __pContextMenuShare;
1353 __pContextMenuShare = null;
1356 if (__pContextMenuMore != null)
1358 delete __pContextMenuMore;
1359 __pContextMenuMore = null;
1362 if(__pShuffledList != null)
1364 free(__pShuffledList);
1365 __pShuffledList = null;
1368 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1374 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1376 AppLogDebug("ENTER actionId(%d)", actionId);
1377 SceneManager* pSceneManager = SceneManager::GetInstance();
1382 case ACTION_ID_FOOTER_MORE:
1384 InitializeContextMenuMore();
1386 __pContextMenuMore->SetShowState(true);
1387 __pContextMenuMore->Show();
1390 case ACTION_ID_CONTEXTMENU_SET_AS:
1391 InitializeContextMenuSetAs();
1393 __pContextMenuSetAs->SetShowState(true);
1394 __pContextMenuSetAs->Show();
1396 case ACTION_ID_FOOTER_BUTTON_SHARE:
1397 InitializeContextMenuShare();
1399 __pContextMenuShare->SetShowState(true);
1400 __pContextMenuShare->Show();
1402 case ACTION_ID_FOOTER_BUTTON_DELETE:
1403 __pDeletePopup->SetShowState(true);
1404 __pDeletePopup->Show();
1406 case ACTION_ID_FOOTER_BUTTON_SLIDE:
1408 if (__pPopUp != null)
1410 __pPopUp->SetShowState(true);
1416 case ACTION_ID_FOOTER_BUTTON_CROP:
1419 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1420 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1421 pList->Add(new (std::nothrow) String(filePath));
1422 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1425 case ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT:
1427 int currentIndex = __pGallery->GetCurrentItemIndex();
1428 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1429 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1430 __pPresentationModel->SetImageRotateStatus(true);
1431 RotateImage(filePath, rotateMode);
1432 __pPresentationModel->RequestImage(filePath);
1434 ContentManager contentManager;
1435 contentManager.Construct();
1436 contentManager.ScanFile(filePath);
1439 case ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT:
1441 int currentIndex = __pGallery->GetCurrentItemIndex();
1442 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1443 RotateMode rotateMode = ROTATE_MODE_LEFT;
1444 __pPresentationModel->SetImageRotateStatus(true);
1445 RotateImage(filePath, rotateMode);
1446 __pPresentationModel->RequestImage(filePath);
1448 ContentManager contentManager;
1449 contentManager.Construct();
1450 contentManager.ScanFile(filePath);
1453 case ACTION_ID_FOOTER_BUTTON_DETAILS:
1455 ShowPanelDetail(__detail);
1458 case ACTION_ID_FOOTER_BUTTON_BACK:
1459 ImageViewerForm::OnFormBackRequested(*this);
1461 case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1464 case ACTION_ID_FOOTER_BUTTON_SAVE:
1466 case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1468 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1469 pSelectedIndex->Construct();
1470 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1471 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1474 case ACTION_ID_CONTEXTMENU_HOME:
1476 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1477 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1478 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1479 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1480 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1483 case ACTION_ID_CONTEXTMENU_LOCK:
1485 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1486 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1487 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1488 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1489 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1492 case ACTION_ID_CONTEXTMENU_CALLER:
1494 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1495 pDataList->Construct();
1496 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1497 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1498 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1499 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1500 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1501 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1503 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1504 APPCONTROL_OPERATION_ID_PICK, null, null, pDataList, this);
1508 case ACTION_ID_CONTEXTMENU_HOME_AND_LOCK:
1510 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1511 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1512 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1513 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1514 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1519 case ACTION_ID_CONTEXTMENU_EMAIL:
1521 OnRequestEmailAction();
1524 case ACTION_ID_CONTEXTMENU_MESSAGE:
1526 OnRequestMessagesAction();
1529 case ACTION_ID_CONTEXTMENU_COPY:
1531 int currentIndex = __pGallery->GetCurrentItemIndex();
1532 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1535 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1536 Clipboard* pClipboard = Clipboard::GetInstance();
1537 pClipboard->CopyItem(item);
1540 case ACTION_ID_DELETE_POPUP_DEL:
1542 __pDeletePopup->SetShowState(false);
1543 __pDeletePopup->Show();
1546 if (__detail == false)
1548 ShowPanelDetail(false);
1552 case ACTION_ID_DELETE_POPUP_CANCEL:
1554 __pDeletePopup->SetShowState(false);
1555 __pDeletePopup->Show();
1558 case ACTION_ID_CONTORL_BUTTON_PLAY:
1564 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1568 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1570 result r = E_SUCCESS;
1571 ImageBuffer* pRotatedBuffer = null;
1572 ImageBuffer* pRotatedBuffer1 = null;
1573 ImageFormat imageFormat;
1576 pRotatedBuffer = new (std::nothrow) ImageBuffer();
1577 r = pRotatedBuffer->Construct(filePath);
1578 pRotatedBuffer->GetImageInfo(filePath, imageFormat, width, height);
1581 if (rotateMode == ROTATE_MODE_RIGHT)
1583 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_90);
1587 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_270);
1590 TryCatch(pRotatedBuffer1 != null, r = GetLastResult(), "RotateN failed:%s", GetErrorMessage(GetLastResult()));
1591 pRotatedBuffer1->EncodeToFile(filePath, imageFormat, true, 100);
1592 delete pRotatedBuffer1;
1593 delete pRotatedBuffer;
1597 if (pRotatedBuffer != null) //this buffer is no longer used
1599 delete pRotatedBuffer;
1601 if (pRotatedBuffer1 != null) //this buffer is no longer used
1603 delete pRotatedBuffer1;
1609 ImageViewerForm::OnFormBackRequested(Form& source)
1611 AppLogDebug("ENTER");
1612 if (__detail == false)
1614 ShowPanelDetail(false);
1618 UiApp* pApp = UiApp::GetInstance();
1621 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1625 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1626 const SceneId& currentSceneId, IList* pArgs)
1628 AppLogDebug("ENTER");
1630 Rectangle clientRect = GetClientAreaBounds();
1631 Rectangle rect = GetBounds();
1633 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1634 __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight()));
1635 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1637 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1640 String strItemIdxText(EMPTY_SPACE);
1641 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1642 __pLabel->SetText(strItemIdxText);
1646 if (__pGallery->GetCurrentItemIndex() < 0)
1648 SetFooterItemState(false);
1652 SetFooterItemState(true);
1655 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1659 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1660 const SceneId& nextSceneId)
1662 AppLogDebug("ENTER");
1663 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1667 ImageViewerForm::OnImageDecodedN(const int index)
1669 AppLogDebug("ENTER");
1670 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1672 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1676 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1677 const String& operationId, AppCtrlResult appControlResult,
1678 const IMap* pExtraData)
1680 AppLogDebug("ENTER");
1682 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1683 && operationId == APPCONTROL_OPERATION_ID_PICK
1684 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1686 const String* pContactId =
1687 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1688 SceneManager* pSceneManager = SceneManager::GetInstance();
1689 long long lresult = 0;
1690 if (pContactId != null && pContactId->GetLength() > 0)
1692 LongLong::Parse(*pContactId, lresult);
1694 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1695 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1696 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1697 pList->Add(new (std::nothrow) LongLong(lresult));
1698 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1699 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1702 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1703 pImageViewerApp->SetFrameEnabled(true);
1704 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1708 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1710 AppLogDebug("ENTER");
1711 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1715 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1717 AppLogDebug("ENTER");
1718 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1722 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1724 AppLogDebug("ENTER");
1725 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1729 ImageViewerForm::OnOtherControlSelected(const Control& source)
1731 AppLogDebug("ENTER");
1732 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1736 ImageViewerForm::InitShowGallery(void)
1738 AppLogDebug("ENTER");
1739 if (__pGallery != null && __pGallery->IsVisible() == false)
1741 Canvas* pCanvas = GetCanvasN();
1742 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1744 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1750 __pGallery->SetShowState(true);
1753 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1757 ImageViewerForm::OnTimerExpired(Timer &timer)
1759 AppLog("ImageViewerForm::OnTimerExpired");
1761 if(timer.Equals(*__pShuffelTimer) == true)
1763 AppLog("OnTimerExpired __pShuffelTimer");
1764 int curItemIndex = __pGallery->GetCurrentItemIndex();
1765 int index = __pShuffledList[curItemIndex];
1769 __pGallery->UpdateGallery();
1771 AppLog("ImageViewerForm::OnGallerySlideShowStopped index = %d, shuffelIndex = %d", curItemIndex, index);
1773 __pGallery->SetCurrentItemIndex(index);
1776 SlideShowStopped(index);
1780 int repeatValue = 0;
1781 int shuffleValue = 0;
1783 if (__pPresentationModel->GetFileCount() > 1)
1785 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1786 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1788 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1789 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
1792 if(shuffleValue != 0)
1794 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
1795 CreateShuffledList(__pPresentationModel->GetFileCount());
1800 __shuffelStartIndex = 0;
1804 if( repeatValue == 0)
1806 __pGallery->StartSlideShow(false);
1810 __pGallery->StartSlideShow(true);
1813 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1817 ImageViewerForm::CreateShuffledList(int count)
1819 AppLogDebug("ImageViewerForm::CreateShuffledList ENTER");
1820 if(__pShuffledList == null)
1822 __pShuffledList = new (std::nothrow) int[count];
1823 for(int i = 0; i < count; i++)
1825 __pShuffledList[i] = i;
1828 for(int i = count - 1; i > 1; i--)
1830 int randomNum = Math::Rand() % (i+1);
1831 int t = __pShuffledList[randomNum];
1832 __pShuffledList[randomNum] = __pShuffledList[i];
1833 __pShuffledList[i] = t;
1836 for(int i = 0; i < count; i++)
1838 AppLogDebug("ShuffeldList i = %d & Val = %d", i, __pShuffledList[i]);
1841 AppLogDebug("ImageViewerForm::CreateShuffledList EXIT");
1845 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1847 AppLogDebug("ENTER");
1848 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1852 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1853 const String& errorMessage)
1855 AppLogDebug("ENTER");
1856 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1860 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1861 result transferResult, const String& errorCode, const String& errorMessage)
1863 AppLogDebug("ENTER");
1864 AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1865 AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1866 AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1867 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1871 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1872 const String& errorCode, const String& errorMessage)
1874 AppLogDebug("ENTER");
1875 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1879 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1880 const String& errorMessage)
1882 AppLogDebug("ENTER");
1883 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1887 ImageViewerForm::RequestDecodeUrl(void)
1889 AppLogDebug("ENTER");
1891 String filePath = __pPresentationModel->GetFilePathAt(0);
1893 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1895 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1900 __downLordFileName = __pPresentationModel->GetFileName(filePath);
1902 Image* pImage = new (std::nothrow) Image();
1903 pImage->Construct();
1906 uri.SetUri(filePath);
1908 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1911 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1915 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1916 result r, const String errorCode, const String errorMessage)
1918 AppLogDebug("ENTER");
1919 Image* pImage = new (std::nothrow) Image();
1920 pImage->Construct();
1922 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1923 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1927 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1928 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1930 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1932 __pPresentationModel->RequestImage(destPath);
1936 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1940 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1944 ImageViewerForm::OnRequestEmailAction(void)
1946 AppLogDebug("ENTER");
1947 int currentIndex = __pGallery->GetCurrentItemIndex();
1949 if (__pPresentationModel->GetFileCount() <= 0)
1951 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1955 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1957 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1958 pDataList->Construct();
1960 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1961 pList->Add(new (std::nothrow) String(filePath));
1963 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1965 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
1966 new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, this);
1967 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1971 ImageViewerForm::OnRequestMessagesAction(void)
1973 AppLogDebug("ENTER");
1974 int currentIndex = __pGallery->GetCurrentItemIndex();
1976 if (__pPresentationModel->GetFileCount() <= 0)
1978 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1982 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1984 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1985 pDataList->Construct();
1986 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1987 pList->Add(new (std::nothrow) String(filePath));
1988 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1990 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES, APPCONTROL_OPERATION_ID_COMPOSE,
1991 new (std::nothrow) String(APPCONTROL_URI_MMS_TO), null, pDataList, this);
1992 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1996 ImageViewerForm::SetFooterItemState(bool isEnable)
1998 AppLogDebug("ENTER");
1999 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
2001 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2002 __pFooter->SetItemEnabled(0, isEnable);
2003 __pFooter->SetItemEnabled(1, isEnable);
2005 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
2007 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2008 __pFooter->SetItemEnabled(0, isEnable);
2009 __pFooter->SetItemEnabled(1, isEnable);
2011 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
2013 __pFooter->SetItemEnabled(0, isEnable);
2015 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2019 ImageViewerForm::GetQuickThumbnailN(String& filePath)
2021 AppLogDebug("ENTER");
2022 Bitmap* pBitmap = null;
2024 if (filePath.GetLength() > 4)
2028 ContentSearch contentSearch;
2029 ContentSearchResult* pResultItem = null;
2030 IList* pContentInfoList = null;
2032 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
2033 result r = contentSearch.Construct(contentType);
2034 AppLogDebug("r(%s)", GetErrorMessage(r));
2037 pBitmap = new (std::nothrow) Bitmap();
2038 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
2049 queryString = CONTENT_QUERY_PREFIX_FILENAME;
2050 queryString.Append(L"'");
2051 queryString.Append(__pPresentationModel->GetFileName(filePath));
2052 queryString.Append(L"'");
2054 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
2055 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
2057 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
2059 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
2060 while (pEnum->MoveNext() == E_SUCCESS)
2062 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
2063 if (pResultItem == null)
2068 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
2070 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
2076 if (pContentInfoList != null)
2078 delete pContentInfoList;
2081 if (pBitmap != null)
2083 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2085 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2087 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
2088 result r = imageBuffer->Construct(filePath);
2091 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
2092 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
2094 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
2095 pBitmap->Scale(srcDim);
2099 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
2100 pBitmap->Scale(srcDim);
2106 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
2108 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
2110 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
2112 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
2113 pBitmap->Scale(srcDim);
2121 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
2122 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
2123 pBitmap = new (std::nothrow) Bitmap();
2124 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2127 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2131 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2133 AppLogDebug(" ENTER");
2134 bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF);
2135 bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
2137 int currentIndex = __pGallery->GetCurrentItemIndex();
2138 int countPath = __pPresentationModel->GetFileCount();
2140 if (countPath == 0 && eventDelete)
2142 UiApp* pApp = UiApp::GetInstance();
2144 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2146 AppLogDebug(" countPath is %d", countPath);
2147 AppLogDebug(" currentIndex is %d", currentIndex);
2149 if (countPath == currentIndex && eventDelete)
2151 __pGallery->SetCurrentItemIndex(--currentIndex);
2155 currentIndex = index;
2156 __pGallery->SetCurrentItemIndex(currentIndex);
2159 String strItemIdxText(EMPTY_SPACE);
2161 __pGallery->UpdateGallery();
2162 AppLogDebug(" UpdateGallery is %d", currentIndex);
2163 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2164 __pPresentationModel->RequestImage(filePath);
2166 GetLabelText(currentIndex,strItemIdxText);
2167 __pLabel->SetText(strItemIdxText);
2169 if (__visible == true)
2171 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2173 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2175 __pPlayButton->SetShowState(false);
2179 __pPlayButton->SetShowState(true);
2182 if (__detail == false)
2184 __pScrollPanel->SetShowState(false);
2189 AppLogDebug("EXIT");
2193 ImageViewerForm::OnSlideSettingPopUpItemSelected(int index)
2195 if ( __pPopUp != NULL)
2197 __pPopUp->SetShowState(false);
2200 if (index == 0) // start slide show
2202 int repeatValue = 0;
2204 if (__pPresentationModel->GetFileCount() > 1)
2208 __pGallery->UpdateGallery();
2210 if (__detail == false)
2212 ShowPanelDetail(false);
2215 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2216 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2218 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2219 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
2221 if (shuffleValue != 0)
2223 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
2224 CreateShuffledList(__pPresentationModel->GetFileCount());
2229 __shuffelStartIndex = 0;
2233 if (repeatValue == 0)
2235 __pGallery->StartSlideShow(false);
2239 __pGallery->StartSlideShow(true);
2243 else if (index == 1) // launch settings
2245 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY,
2246 APPCONTROL_OPERATION_ID_CONFIGURE, null, null, null, this);