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_CONTROL_LABEL = Color32<0, 0, 0, 0>::Value;
48 static const unsigned int COLOR_HEADER_CONTROL_PANEL = Color32<0, 0, 0, 100>::Value;
49 static const unsigned int COLOR_HEADER_BUTTON1 = Color32<0, 0, 0, 100>::Value;
50 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
51 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
52 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
53 static const unsigned int COLOR_GALLERY_BG = Color32<31,31,31>::Value;
55 static const Rectangle RECT_DETAILS_CONTORL_LABEL (20, 0, 200, 48);
57 static const int W_PLAY_BUTTON = 160;
58 static const int H_PLAY_BUTTON = 160;
60 static const int GAP_W_POPUP_ITEM = 5;
61 static const int W_DELETE_POPUP = 600;
62 static const int H_DELETE_POPUP = 300;
63 static const int H_DELETE_LABEL = 180;
64 static const int Y_DELETE_BUTTON = 180;
65 static const int H_DELETE_BUTTON = 80;
67 static const Dimension DUMMY_IMAGE_DIMENSION (720, 1280);
68 static const Rectangle DUMMY_IMAGE_RECTANGLE (0, 0, 720, 1280);
70 static const int PAGE_NO_CONTENT_SEARCH = 1;
71 static const int COUNT_PER_PAGE_CONTENT_SEARCH = 10;
73 static const int FORMAT_BUFFER_SIZE = 256;
75 static const long long SINGLE_GIGA_BYTE = (1024 * 1024 * 1024);
76 static const long long SINGLE_MEGA_BYTE = (1024 * 1024);
77 static const long long SINGLE_KILO_BYTE = 1024;
79 static const int Y_RENAME_BUTTON = 100;
80 static const int H_RENAME_BUTTON = 64;
81 static const int W_RENAME_BUTTON = 64;
83 static const int GAP_W_END_OF_LABEL = 60;
84 static const int X_DETAIL_FILEINFO_LABEL = 20;
85 static const int H_DETAIL_FILEINFO_LABEL = 50;
86 static const int H_DETAIL_MAIN_TEXT = 48;
87 static const int H_DETAIL_SUB_TEXT = 42;
88 static const int GAP_H_DETAIL_TEXT = 26;
89 static const int H_DETAIL_FILEINFO_VALUE_LABEL = 56;
91 static const int X_MORE = 55;
93 static const int DETAIL_SUB_FONT_SIZE = 32;
94 static const int DETAIL_MAIN_FONT_SIZE = 36;
95 static const int DETAIL_COUNT_MAX = 9;
97 ImageViewerForm::ImageViewerForm(void)
98 : __shuffelStartIndex(0)
99 , __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
102 , __pScrollPanel(null)
103 , __pDetail_Label(null)
104 , __pLabelMessage(null)
105 , __pPlayButton(null)
106 , __pRenameButton(null)
107 , __pDetailFooterItem(null)
110 , __pShuffelTimer(null)
111 , __pContextMenuMore(null)
112 , __pContextMenuCopy(null)
113 , __pContextMenuSetAs(null)
114 , __pContextMenuShare(null)
115 , __pDeletePopup(null)
118 , __isStartSlide(false)
121 , __pShuffledList(null)
122 , __pPresentationModel(null)
124 AppLogDebug("ENTER");
125 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
128 ImageViewerForm::~ImageViewerForm(void)
130 AppLogDebug("ENTER");
131 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
135 ImageViewerForm::Initialize()
137 AppLogDebug("ENTER");
139 result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
141 __pPresentationModel = ImageViewerPresentationModel::GetInstance();
143 if (__pPresentationModel->GetFileCount() > 0)
145 if (__pPresentationModel->GetType() == APPCONTROL_DATA_SLIDE_SHOW)
147 __isStartSlide = true;
151 __pPresentationModel->AddFileUpdateListener(this);
153 __pSettingPresentationModel = SettingPresentationModel::GetInstance();
155 int startIndex = __pPresentationModel->GetStartIndex();
156 String filePath = __pPresentationModel->GetFilePathAt(startIndex);
158 if (filePath.StartsWith(WEB_URL_HTTP, 0) == true)
160 __initializeDisplayModeCurrent = APPCONTROL_MODE_WEB_LINK;
162 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_MESSAGE)
164 __initializeDisplayModeCurrent = APPCONTROL_MODE_MESSAGE;
166 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_EMAIL)
168 __initializeDisplayModeCurrent = APPCONTROL_MODE_EMAIL;
172 __initializeDisplayModeCurrent = APPCONTROL_MODE_NORMAL;
175 if (filePath == EMPTY_SPACE)
177 MessageBox messageBox;
178 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE,
181 messageBox.ShowAndWait(modalResult);
183 UiApp* pApp = UiApp::GetInstance();
187 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
193 ImageViewerForm::OnInitializing(void)
195 AppLogDebug("ENTER");
196 result r = E_SUCCESS;
197 SetFormBackEventListener(this);
198 __pPresentationModel->AddListener(this);
200 __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL_INFO"));
202 if (__pLabel == null)
206 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTROL_LABEL);
207 SetControlAlwaysOnTop(*__pLabel,true);
208 int allCount = __pPresentationModel->GetFileCount();
211 displayText.Append(index);
212 displayText.Append("/");
213 displayText.Append(allCount);
215 __pLabel->SetText(displayText);
218 InitializeDisplay(__initializeDisplayModeCurrent);
219 InitializePanelDetail();
222 __pPopUp = new (std::nothrow) SlideShowPopUp();
224 if (__pPopUp != null)
226 __pPopUp->Initialize();
227 __pPopUp->SetEventListner(this);
228 AddControl(*__pPopUp);
232 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
233 || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
234 || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
236 int index = __pPresentationModel->GetStartIndex();
237 __pGallery->UpdateGallery();
238 __pGallery->SetCurrentItemIndex(index);
241 String filePath = __pPresentationModel->GetFilePathAt(index);
242 __pPresentationModel->RequestImage(filePath);
244 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
251 __pTimer = new (std::nothrow) Timer();
252 __pTimer->Construct(*this);
256 AddOrientationEventListener(*this);
257 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
263 ImageViewerForm::OnInitialized(void)
265 AppLogDebug("ENTER");
266 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
272 ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
274 AppLogDebug("ENTER");
275 if (__isDetail == false)
277 ShowPanelDetail(true);
281 ShowPanelDetail(false);
284 Rectangle clientRect = GetClientAreaBounds();
285 Rectangle rect = GetBounds();
287 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
288 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
289 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
292 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
296 ImageViewerForm::InitializeDisplay(AppControlMode status)
298 AppLogDebug("ENTER");
300 String strItemIdxText;
302 __pFooter = GetFooter();
303 __pFooter->AddActionEventListener(*this);
304 __pFooter->RemoveAllItems();
306 GetLabelText(0, strItemIdxText);
307 Rectangle rect = GetClientAreaBounds();
310 if (status == APPCONTROL_MODE_NORMAL)
312 __pPlayButton = new (std::nothrow) Button();
313 if (__pPlayButton != null)
315 Rectangle clientRect = GetClientAreaBounds();
317 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
318 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
319 __pPlayButton->SetActionId(IDA_CONTORL_BUTTON_PLAY);
320 AddControl(*__pPlayButton);
322 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
323 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
324 delete pNormalBackgroundBitmap;
326 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
327 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
328 delete pPressedBackgroundBitmap;
330 __pPlayButton->AddActionEventListener(*this);
331 __pPlayButton->SetShowState(false);
334 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
335 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
336 __pFooter->SetBackButton();
338 FooterItem footerItem1;
339 footerItem1.Construct(IDA_FOOTER_BUTTON_SHARE);
340 Bitmap* pFooterItemShareNomal =
341 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
342 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
344 FooterItem footerItem2;
345 footerItem2.Construct(IDA_FOOTER_BUTTON_DELETE);
346 Bitmap* pFooterItemDeleteNomal =
347 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
348 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
350 __pFooter->AddItem(footerItem1);
351 __pFooter->AddItem(footerItem2);
353 delete pFooterItemShareNomal;
354 delete pFooterItemDeleteNomal;
356 ButtonItem buttonItemMore;
357 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
358 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
359 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
360 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
361 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
362 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
364 else if (status == APPCONTROL_MODE_WEB_LINK)
366 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
367 __pFooter->SetBackButton();
369 FooterItem footerItem1;
370 footerItem1.Construct(IDA_FOOTER_BUTTON_SHARE);
371 Bitmap* pFooterItemShareNomal =
372 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
373 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
375 FooterItem footerItem2;
376 footerItem2.Construct(IDA_FOOTER_BUTTON_DOWNLOAD);
377 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
378 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
380 __pFooter->AddItem(footerItem1);
381 __pFooter->AddItem(footerItem2);
383 delete pFooterItemShareNomal;
384 delete pFooterItemDownlordNomal;
386 ButtonItem buttonItemMore;
387 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
388 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
389 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
390 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
391 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
392 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
394 __pFooter->AddItem(footerItem1);
395 __pFooter->AddItem(footerItem2);
397 else if (status == APPCONTROL_MODE_CROP)
399 FooterItem footerItem1;
400 footerItem1.Construct(IDA_FOOTER_BUTTON_SAVE);
401 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
402 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
404 FooterItem footerItem2;
405 footerItem2.Construct(IDA_FOOTER_BUTTON_BACK);
406 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
407 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
409 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
410 __pFooter->AddItem(footerItem1);
411 __pFooter->AddItem(footerItem2);
416 else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
418 __pPlayButton = new (std::nothrow) Button();
419 if (__pPlayButton != null)
421 Rectangle clientRect = GetClientAreaBounds();
423 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
424 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
425 __pPlayButton->SetActionId(IDA_CONTORL_BUTTON_PLAY);
426 AddControl(*__pPlayButton);
428 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
429 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
430 delete pNormalBackgroundBitmap;
432 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
433 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
434 delete pPressedBackgroundBitmap;
436 __pPlayButton->AddActionEventListener(*this);
437 __pPlayButton->SetShowState(false);
440 __pFooter->SetBackButton();
443 String filePath = __pPresentationModel->GetFilePathAt(0);
444 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
445 if (contentType == CONTENT_TYPE_VIDEO)
447 __pPlayButton->SetShowState(true);
449 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
453 ImageViewerForm::GetLabelText(int index, String &page)
455 AppLogDebug("ENTER");
456 int allCount = __pPresentationModel->GetFileCount();
457 String pStr = __pPresentationModel->GetFilePathAt(index);
458 page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
459 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
463 ImageViewerForm::DeleteImageFile()
465 AppLogDebug("ENTER");
466 int currentIndex = __pGallery->GetCurrentItemIndex();
468 String strItemText(EMPTY_SPACE);
469 String strItemIdxText(EMPTY_SPACE);
470 int countPath = __pPresentationModel->GetFileCount();
471 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
473 if (filePath.GetLength() == 0)
475 UiApp* pApp = UiApp::GetInstance();
477 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
482 result r = File::Remove(filePath);
485 MessageBox messageBox;
486 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
487 MSGBOX_STYLE_NONE, 3000);
489 messageBox.ShowAndWait(modalResult);
490 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
495 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
496 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
498 ContentManager::ScanFile(filePath);
501 __pPresentationModel->DeleteFilePathAt(currentIndex);
504 UiApp* pApp = UiApp::GetInstance();
506 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
510 else if ((countPath - 1) == currentIndex)
512 __pGallery->SetCurrentItemIndex(--currentIndex);
515 __pGallery->UpdateGallery();
516 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
517 __pPresentationModel->RequestImage(filePath);
519 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
521 __pLabel->SetText(strItemIdxText);
523 if (__isVisible == true)
525 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
527 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
529 __pPlayButton->SetShowState(false);
533 __pPlayButton->SetShowState(true);
537 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
543 ImageViewerForm::CallVideoPlayer(void)
545 AppLogDebug("ENTER");
546 int index = __pGallery->GetCurrentItemIndex();
547 String filePath = __pPresentationModel->GetFilePathAt(index);
548 filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
550 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
551 new (std::nothrow) String(filePath), new (std::nothrow) String(APPCONTROL_MIME_VIDEO_ALL), null, this);
552 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
556 ImageViewerForm::CreateGallery(void)
558 AppLogDebug("ENTER");
559 Rectangle clientRect = GetClientAreaBounds();
560 Rectangle rect = GetBounds();
562 __pGallery = static_cast<Gallery*>(GetControl(L"IDC_GALLERY"));
563 AppAssert(__pGallery);
565 __pGallery->SetItemProvider(*this);
566 __pGallery->AddGalleryEventListener(*this);
567 __pGallery->SetBackgroundColor(COLOR_GALLERY_BG);
569 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
573 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
574 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
576 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
577 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
579 case SLIDE_SHOW_TRANSITION_EFFECT_PAGE:
580 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_PAGE);
584 __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
586 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
590 ImageViewerForm::InitializePanelDetail()
592 AppLogDebug("ENTER");
593 __pScrollPanel = new (std::nothrow) ScrollPanel();
595 String arrayId[DETAIL_COUNT_MAX] =
597 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
598 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
599 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
602 if (__pScrollPanel == null)
604 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
606 return E_INVALID_STATE;
609 Rectangle clientRect = GetClientAreaBounds();
610 result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height - __pLabel->GetHeight()));
613 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
615 return E_INVALID_STATE;
618 __pDetail_Label = new (std::nothrow) Label();
619 __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
620 __pScrollPanel->AddControl(*__pDetail_Label);
621 __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
622 __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
623 __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
624 __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
626 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
628 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
629 __pDetail_FileInfo_Label[i]->Construct(
630 Rectangle(X_DETAIL_FILEINFO_LABEL,
631 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
632 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
633 __pScrollPanel->AddControl(*__pDetail_FileInfo_Label[i]);
635 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
636 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
637 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
638 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
640 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
642 if (i == DETAIL_COUNT_MAX - 1)
644 __pDetail_FileInfo_Value_Label[i]->Construct(
645 Rectangle(X_DETAIL_FILEINFO_LABEL,
646 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
647 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
651 __pDetail_FileInfo_Value_Label[i]->Construct(
652 Rectangle(X_DETAIL_FILEINFO_LABEL,
653 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
654 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
657 __pScrollPanel->AddControl(*__pDetail_FileInfo_Value_Label[i]);
659 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
660 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
661 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
662 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
665 __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTROL_PANEL);
666 __pScrollPanel->SetShowState(false);
668 __pRenameButton = new (std::nothrow) Button();
669 Rectangle rect = GetBounds();
670 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
671 __pRenameButton->SetActionId(IDA_PANEL_HEADER_DETAILS_RENAME);
672 __pRenameButton->AddActionEventListener(*this);
674 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
675 Bitmap* pIconBackground =
676 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
677 Bitmap* pIconPressed =
678 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
680 if (pIcon != null && pIconPressed != null && pIconBackground != null)
682 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
683 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
684 Point iconPosition(0, 0);
685 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
686 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
690 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
691 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
695 delete pIconBackground;
697 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
698 __pScrollPanel->AddControl(*__pRenameButton);
701 AddControl(*__pScrollPanel);
702 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
708 ImageViewerForm::InitializePopup(void)
710 AppLogDebug("ENTER");
711 if (__pDeletePopup == null)
713 __pDeletePopup = new (std::nothrow) Popup();
714 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
716 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
718 Label* pLabel = new (std::nothrow) Label();
719 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
720 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
722 Button* pDeleteButton = new (std::nothrow) Button();
723 pDeleteButton->Construct(
724 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
725 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
726 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
727 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
728 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
729 pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
730 pDeleteButton->AddActionEventListener(*this);
732 Button* pCancelButton = new (std::nothrow) Button();
733 pCancelButton->Construct(
734 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
735 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
736 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
737 pCancelButton->SetActionId(IDA_DELETE_POPUP_CANCEL);
738 pCancelButton->AddActionEventListener(*this);
740 __pDeletePopup->AddControl(*pLabel);
741 __pDeletePopup->AddControl(*pDeleteButton);
742 __pDeletePopup->AddControl(*pCancelButton);
746 __pDeletePopup->SetShowState(true);
747 __pDeletePopup->Show();
749 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
755 ImageViewerForm::InitializeContextMenuMore(void)
757 AppLogDebug("ENTER");
758 int currentIndex = __pGallery->GetCurrentItemIndex();
759 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
761 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
763 if (__pContextMenuMore != null)
765 delete __pContextMenuMore;
766 __pContextMenuMore = null;
769 __pContextMenuMore = new (std::nothrow) ContextMenu();
771 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().height),
772 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
774 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
776 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
777 IDA_CONTEXTMENU_SET_AS);
778 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), IDA_FOOTER_BUTTON_CROP);
779 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"), IDA_FOOTER_BUTTON_ROTATE_RIGHT);
780 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"), IDA_FOOTER_BUTTON_ROTATE_LEFT);
783 if (__pGallery->GetItemCount() > 1)
785 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
786 IDA_FOOTER_BUTTON_SLIDE);
788 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
789 IDA_FOOTER_BUTTON_DETAILS);
790 __pContextMenuMore->SetShowState(false);
791 __pContextMenuMore->AddActionEventListener(*this);
792 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
798 ImageViewerForm::InitializeContextMenuSetAs(void)
800 AppLogDebug("ENTER");
802 if (__pContextMenuSetAs != null)
804 delete __pContextMenuSetAs;
805 __pContextMenuSetAs = null;
808 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
809 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
810 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
812 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
813 IDA_CONTEXTMENU_HOME);
814 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
815 IDA_CONTEXTMENU_LOCK);
816 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_HOME_AND_LOCK_SCREENS"),
817 IDA_CONTEXTMENU_HOME_AND_LOCK);
818 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
819 IDA_CONTEXTMENU_CALLER);
820 __pContextMenuSetAs->AddActionEventListener(*this);
821 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
827 ImageViewerForm::InitializeContextMenuShare(void)
829 AppLogDebug("ENTER");
830 if (__pContextMenuShare != null)
832 delete __pContextMenuShare;
833 __pContextMenuShare = null;
835 __pContextMenuShare = new (std::nothrow) ContextMenu();
836 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
837 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
838 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
840 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
841 IDA_CONTEXTMENU_MESSAGE);
842 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), IDA_CONTEXTMENU_EMAIL);
843 __pContextMenuShare->AddActionEventListener(*this);
844 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
850 ImageViewerForm::GetFileSize(String filePath) const
852 AppLogDebug("ENTER");
856 result r = File::GetAttributes(filePath, attr);
859 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
863 size = attr.GetFileSize();
864 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
870 ImageViewerForm::SetDetailInfo(void)
872 AppLogDebug("ENTER");
874 Rectangle clientRect = GetClientAreaBounds();
875 __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
876 int currentIndex = __pGallery->GetCurrentItemIndex();
877 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
879 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
881 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
883 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
884 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
887 result r = File::GetAttributes(strFilePath, attr);
890 long long nSize = attr.GetFileSize();
891 DateTime dateTime = attr.GetDateTime();
892 strResult[2] = dateTime.ToString();
894 if (nSize > SINGLE_GIGA_BYTE)
896 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
897 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
899 else if (nSize > SINGLE_MEGA_BYTE)
901 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
902 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
904 else if (nSize > SINGLE_KILO_BYTE)
906 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
907 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
911 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
912 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
917 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
918 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
921 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
922 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
923 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
924 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
925 strResult[8] = strFilePath;
926 String fileName = File::GetFileName(strFilePath);
927 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
929 if (strResult[8].StartsWith(Tizen::System::Environment::GetMediaPath(), 0) == true)
931 strResult[8].Replace(Tizen::System::Environment::GetMediaPath(), MEDIA_ROOT_PHONE, 0);
934 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
936 strResult[0] = __downloadFileName;
938 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
940 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
942 if (pImgMeta != null)
944 ImageContentInfo imageContentInfo;
945 r = imageContentInfo.Construct(&strFilePath);
948 strResult[1] = imageContentInfo.GetMediaFormat();
949 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
950 pImgMeta->GetHeight());
952 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
954 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
957 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
959 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
960 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
966 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
968 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
969 if (pVideoMeta != null)
971 VideoContentInfo videoContentInfo;
972 r = videoContentInfo.Construct(&strFilePath);
975 strResult[1] = videoContentInfo.GetMediaFormat();
976 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
977 pVideoMeta->GetHeight());
978 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
980 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
986 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
988 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
990 if (i == DETAIL_COUNT_MAX - 1)
992 __pDetail_FileInfo_Value_Label[i]->SetBounds(
993 Rectangle(X_DETAIL_FILEINFO_LABEL,
994 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
995 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3));
999 __pDetail_FileInfo_Value_Label[i]->SetBounds(
1000 Rectangle(X_DETAIL_FILEINFO_LABEL,
1001 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
1002 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL));
1005 __pDetail_FileInfo_Value_Label[i]->Invalidate(true);
1008 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1010 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1014 Rectangle rect = GetBounds();
1015 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
1017 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1023 ImageViewerForm::ShowPanelDetail(bool showStatus)
1025 AppLogDebug("ENTER");
1029 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTROL_PANEL);
1030 __pLabel->Invalidate(true);
1031 __pScrollPanel->SetShowState(true);
1036 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTROL_LABEL);
1037 __pLabel->Invalidate(true);
1038 __pScrollPanel->SetShowState(false);
1041 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1047 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1049 AppLogDebug("ENTER");
1050 FooterItem footerItem;
1051 footerItem.Construct(IDA_FOOTER_BUTTON_DETAILS);
1052 Bitmap* pfooterItem = null;
1056 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1057 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1061 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1062 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1065 pFooter->SetItemAt(position, footerItem);
1066 pFooter->Invalidate(true);
1069 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1075 ImageViewerForm::DownloadFile(void)
1077 AppLogDebug("ENTER");
1078 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1079 if (File::IsFileExist(DestPath) == false)
1081 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1085 ContentId contentId;
1086 ContentManager contentManager;
1087 contentManager.Construct();
1089 ImageContentInfo imageContentInfo;
1090 imageContentInfo.Construct(null);
1092 imageContentInfo.SetKeyword(L"platform, tizen");
1093 String sourcePath = DestPath;
1094 String destPath = Environment::GetMediaPath();
1095 destPath.Append(FOLDER_PATH_DOWNLOADS);
1096 destPath.Append(__downloadFileName);
1098 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1099 ImageViewerForm::OnFormBackRequested(*this);
1100 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1104 ImageViewerForm::GetItemCount(void)
1106 AppLogDebug("ENTER");
1107 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1109 return __pPresentationModel->GetFileCount();
1113 ImageViewerForm::CreateItem(int index)
1115 AppLogDebug("ENTER : index(%d)", index);
1116 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1118 int curIndex = index;
1120 if (__isShuffle == true && __pShuffledList != null)
1122 curIndex = __pShuffledList[index];
1125 String filePath = __pPresentationModel->GetFilePathAt(curIndex);
1126 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1127 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1129 if (pBitmap == null)
1131 pBitmap = GetQuickThumbnailN(filePath);
1133 if (pBitmap == null && __pGallery->IsSlideShowStarted() == true)
1135 pBitmap = __pPresentationModel->GetImage(filePath);
1136 __pPresentationModel->RequestImage(filePath);
1138 else if (pBitmap == null)
1140 pBitmap = new (std::nothrow) Bitmap();
1141 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1144 pGallery->Construct(*pBitmap, filePath);
1146 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1152 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1154 AppLogDebug("ImageViewerForm::DeleteItem ENTER index(%d)", index);
1155 int curIndex = index;
1157 if (__isShuffle == true && __pShuffledList != null)
1159 curIndex = __pShuffledList[index];
1162 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1163 pImageInfo->ClearBitmap();
1165 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1171 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1173 AppLogDebug("ImageViewerForm::OnGalleryCurrentItemChanged index(%d)", index);
1175 String filePath = __pPresentationModel->GetFilePathAt(index);
1176 __pPresentationModel->RequestImage(filePath);
1178 String strItemIdxText;
1179 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1180 __pLabel->SetText(strItemIdxText);
1182 if (__isVisible == true)
1184 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1185 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1187 __pPlayButton->SetShowState(true);
1191 __pPlayButton->SetShowState(false);
1196 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1200 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1202 AppLogDebug("ENTER");
1204 String filePath = __pPresentationModel->GetFilePathAt(index);
1205 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1207 if (__isVisible == true)
1209 if (contentType == CONTENT_TYPE_VIDEO)
1211 __pPlayButton->SetShowState(false);
1214 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1215 __pLabel->SetShowState(false);
1216 __isVisible = false;
1220 if (contentType == CONTENT_TYPE_VIDEO)
1222 __pPlayButton->SetShowState(true);
1225 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1226 __pLabel->SetShowState(true);
1229 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1230 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1233 Rectangle clientRect = GetClientAreaBounds();
1234 Rectangle rect = GetBounds();
1235 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1237 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1241 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1243 AppLogDebug("ENTER");
1244 PowerManager::KeepScreenOnState(true, false);
1246 int index = __pGallery->GetCurrentItemIndex();
1247 String filePath = __pPresentationModel->GetFilePathAt(index);
1248 __pPresentationModel->RequestImage(filePath);
1250 if (__isVisible == true)
1252 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1253 __pLabel->SetShowState(false);
1255 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1256 if (contentType == CONTENT_TYPE_VIDEO)
1258 __pPlayButton->SetShowState(false);
1261 __isVisible = false;
1264 Rectangle clientRect = GetClientAreaBounds();
1265 Rectangle rect = GetBounds();
1266 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1268 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1272 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1274 AppLogDebug("ImageViewerForm::OnGallerySlideShowStopped");
1278 if (__isShuffle == true)
1280 if (__pShuffelTimer == null)
1282 __pShuffelTimer = new (std::nothrow) Timer();
1283 __pShuffelTimer->Construct(*this);
1285 __pShuffelTimer->Start(1);
1289 index = __pGallery->GetCurrentItemIndex();
1290 SlideShowStopped(index);
1293 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1297 ImageViewerForm::SlideShowStopped(int index)
1299 AppLog("ImageViewerForm::SlideShowStopped");
1300 PowerManager::KeepScreenOnState(false, true);
1302 if (__isVisible == false)
1304 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1305 __pLabel->SetShowState(true);
1306 String filePath = __pPresentationModel->GetFilePathAt(index);
1307 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1308 if (contentType == CONTENT_TYPE_VIDEO)
1310 __pPlayButton->SetShowState(true);
1313 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1314 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1319 String strItemIdxText;
1320 GetLabelText(index, strItemIdxText);
1321 __pLabel->SetText(strItemIdxText);
1324 Rectangle clientRect = GetClientAreaBounds();
1325 Rectangle rect = GetBounds();
1326 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1332 ImageViewerForm::OnUpdateContentList(void)
1337 ImageViewerForm::OnTerminating(void)
1339 AppLogDebug("ENTER");
1341 if (__pTimer != null)
1348 if (__pShuffelTimer)
1350 __pShuffelTimer->Cancel();
1351 delete __pShuffelTimer;
1352 __pShuffelTimer = null;
1355 __pPresentationModel->ClearImageRequests();
1356 __pPresentationModel->RemoveListener(*this);
1357 __pPresentationModel->RemoveFileUpdateListener(*this);
1359 if (__pContextMenuCopy != null)
1361 delete __pContextMenuCopy;
1362 __pContextMenuCopy = null;
1365 if (__pContextMenuSetAs != null)
1367 delete __pContextMenuSetAs;
1368 __pContextMenuSetAs = null;
1371 if (__pDeletePopup != null)
1373 delete __pDeletePopup;
1374 __pDeletePopup = null;
1377 if (__pContextMenuShare != null)
1379 delete __pContextMenuShare;
1380 __pContextMenuShare = null;
1383 if (__pContextMenuMore != null)
1385 delete __pContextMenuMore;
1386 __pContextMenuMore = null;
1389 if (__pShuffledList != null)
1391 free(__pShuffledList);
1392 __pShuffledList = null;
1395 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1401 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1403 AppLogDebug("ENTER actionId(%d)", actionId);
1404 SceneManager* pSceneManager = SceneManager::GetInstance();
1409 case IDA_FOOTER_MORE:
1411 InitializeContextMenuMore();
1413 __pContextMenuMore->SetShowState(true);
1414 __pContextMenuMore->Show();
1418 case IDA_CONTEXTMENU_SET_AS:
1420 InitializeContextMenuSetAs();
1421 __pContextMenuSetAs->SetShowState(true);
1422 __pContextMenuSetAs->Show();
1426 case IDA_FOOTER_BUTTON_SHARE:
1428 InitializeContextMenuShare();
1429 __pContextMenuShare->SetShowState(true);
1430 __pContextMenuShare->Show();
1434 case IDA_FOOTER_BUTTON_DELETE:
1436 __pDeletePopup->SetShowState(true);
1437 __pDeletePopup->Show();
1441 case IDA_FOOTER_BUTTON_SLIDE:
1443 if (__pPopUp != null)
1445 __pPopUp->SetShowState(true);
1451 case IDA_FOOTER_BUTTON_CROP:
1454 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1455 ImageBuffer imagebuffer;
1456 result r = imagebuffer.Construct(filePath);
1461 int imageWidth = imagebuffer.GetWidth();
1462 int imageHeight = imagebuffer.GetHeight();
1463 if (imageWidth <= (H_CROP_RECTANGLE * 3) || imageHeight <= (H_CROP_RECTANGLE * 3))
1465 MessageBox messageBox;
1466 String messageText = ResourceManager::GetString(L"IDS_IMGE_POP_IMAGE_IS_TOO_SMALL");
1467 messageBox.Construct(L"", messageText, MSGBOX_STYLE_OK, 3000);
1468 int modalResult = 0;
1469 messageBox.ShowAndWait(modalResult);
1473 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1474 pList->Add(new (std::nothrow) String(filePath));
1475 pList->Add(new (std::nothrow) String(APPCONTROL_DATA_AUTO));
1476 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1480 case IDA_FOOTER_BUTTON_ROTATE_RIGHT:
1482 int currentIndex = __pGallery->GetCurrentItemIndex();
1483 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1484 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1485 RotateImage(filePath, rotateMode);
1486 __pPresentationModel->RequestImage(filePath);
1487 ContentManager::ScanFile(filePath);
1491 case IDA_FOOTER_BUTTON_ROTATE_LEFT:
1493 int currentIndex = __pGallery->GetCurrentItemIndex();
1494 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1495 RotateMode rotateMode = ROTATE_MODE_LEFT;
1496 RotateImage(filePath, rotateMode);
1497 __pPresentationModel->RequestImage(filePath);
1498 ContentManager::ScanFile(filePath);
1502 case IDA_FOOTER_BUTTON_DETAILS:
1504 ShowPanelDetail(__isDetail);
1508 case IDA_FOOTER_BUTTON_BACK:
1510 ImageViewerForm::OnFormBackRequested(*this);
1514 case IDA_FOOTER_BUTTON_DOWNLOAD:
1520 case IDA_FOOTER_BUTTON_SAVE:
1523 case IDA_PANEL_HEADER_DETAILS_RENAME:
1525 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1526 pSelectedIndex->Construct();
1527 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1528 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1532 case IDA_CONTEXTMENU_HOME:
1534 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1535 if (File::IsFileExist(filePath))
1537 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1538 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1539 pList->Add(new (std::nothrow) String(filePath));
1540 pList->Add(new (std::nothrow) String(cropMode));
1541 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1542 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1546 MessageBox messageBox;
1547 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE, 3000);
1548 int modalResult = 0;
1549 messageBox.ShowAndWait(modalResult);
1550 UiApp* pApp = UiApp::GetInstance();
1557 case IDA_CONTEXTMENU_LOCK:
1559 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1560 if (File::IsFileExist(filePath))
1562 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1563 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1564 pList->Add(new (std::nothrow) String(filePath));
1565 pList->Add(new (std::nothrow) String(cropMode));
1566 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1567 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1572 MessageBox messageBox;
1573 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE, 3000);
1574 int modalResult = 0;
1575 messageBox.ShowAndWait(modalResult);
1576 UiApp* pApp = UiApp::GetInstance();
1583 case IDA_CONTEXTMENU_CALLER:
1585 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1586 pDataList->Construct();
1587 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1588 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1589 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1590 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1591 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1592 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1594 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1595 APPCONTROL_OPERATION_ID_SOCIAL_PICK, null, null, pDataList, this);
1599 case IDA_CONTEXTMENU_HOME_AND_LOCK:
1601 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1602 if (File::IsFileExist(filePath))
1604 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1605 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1606 pList->Add(new (std::nothrow) String(filePath));
1607 pList->Add(new (std::nothrow) String(cropMode));
1608 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1609 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1613 MessageBox messageBox;
1614 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE, 3000);
1615 int modalResult = 0;
1616 messageBox.ShowAndWait(modalResult);
1617 UiApp* pApp = UiApp::GetInstance();
1624 case IDA_CONTEXTMENU_EMAIL:
1626 OnRequestEmailAction();
1630 case IDA_CONTEXTMENU_MESSAGE:
1632 OnRequestMessagesAction();
1636 case IDA_CONTEXTMENU_COPY:
1638 int currentIndex = __pGallery->GetCurrentItemIndex();
1639 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1642 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1643 Clipboard* pClipboard = Clipboard::GetInstance();
1644 pClipboard->CopyItem(item);
1648 case IDA_DELETE_POPUP_DEL:
1650 __pDeletePopup->SetShowState(false);
1651 __pDeletePopup->Show();
1654 if (__isDetail == false)
1656 ShowPanelDetail(false);
1661 case IDA_DELETE_POPUP_CANCEL:
1663 __pDeletePopup->SetShowState(false);
1664 __pDeletePopup->Show();
1668 case IDA_CONTORL_BUTTON_PLAY:
1677 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1681 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1683 result r = E_SUCCESS;
1684 ImageBuffer rotateBuffer;
1685 ImageBuffer* pRotatedBuffer = null;
1686 ImageFormat imageFormat;
1688 r = img.Construct();
1692 imageFormat = img.GetImageFormat(filePath);
1695 r = rotateBuffer.Construct(filePath);
1698 if (rotateMode == ROTATE_MODE_RIGHT)
1700 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1704 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1708 if (pRotatedBuffer != null)
1710 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1711 delete pRotatedBuffer;
1717 ImageViewerForm::OnFormBackRequested(Form& source)
1719 AppLogDebug("ENTER");
1720 if (__isDetail == false)
1722 ShowPanelDetail(false);
1726 UiApp* pApp = UiApp::GetInstance();
1729 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1733 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1734 const SceneId& currentSceneId, IList* pArgs)
1736 AppLogDebug("ENTER");
1738 Rectangle clientRect = GetClientAreaBounds();
1739 Rectangle rect = GetBounds();
1741 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1742 __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight()));
1743 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1745 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1748 String strItemIdxText(EMPTY_SPACE);
1749 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1750 __pLabel->SetText(strItemIdxText);
1754 if (previousSceneId == IDSCN_IMAGE_CROP && pArgs != null)
1757 filePath = *(static_cast<String*>(pArgs->GetAt(0)));
1759 int count = __pPresentationModel->GetFileCount();
1760 __pPresentationModel->AddImageCache(filePath);
1761 __pGallery->UpdateGallery();
1762 __pGallery->SetCurrentItemIndex(count);
1763 __pPresentationModel->RequestImage(filePath);
1764 ShowPanelDetail(false);
1767 if (__pGallery->GetCurrentItemIndex() < 0)
1769 SetFooterItemState(false);
1773 SetFooterItemState(true);
1776 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1780 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1781 const SceneId& nextSceneId)
1783 AppLogDebug("ENTER");
1784 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1788 ImageViewerForm::OnImageDecodedN(const int index)
1790 AppLogDebug("ENTER");
1791 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1793 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1797 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1798 const String& operationId, AppCtrlResult appControlResult,
1799 const IMap* pExtraData)
1801 AppLogDebug("ENTER");
1803 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1804 && operationId == APPCONTROL_OPERATION_ID_SOCIAL_PICK
1805 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1807 const ArrayList* pResultList =
1808 static_cast<const ArrayList*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1809 const String* pContactId = null;
1811 if (pResultList != null)
1813 pContactId = static_cast<const String*>(pResultList->GetAt(0));
1816 long long lresult = 0;
1817 if (pContactId != null && pContactId->GetLength() > 0)
1819 LongLong::Parse(*pContactId, lresult);
1820 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1821 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1822 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1823 pList->Add(new (std::nothrow) String(filePath));
1824 pList->Add(new (std::nothrow) String(cropMode));
1825 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1826 pList->Add(new (std::nothrow) LongLong(lresult));
1827 SceneManager* pSceneManager = SceneManager::GetInstance();
1828 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1832 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1833 pImageViewerApp->SetFrameEnabled(true);
1834 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1838 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1840 AppLogDebug("ENTER");
1841 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1845 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1847 AppLogDebug("ENTER");
1848 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1852 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1854 AppLogDebug("ENTER");
1855 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1859 ImageViewerForm::OnOtherControlSelected(const Control& source)
1861 AppLogDebug("ENTER");
1862 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1866 ImageViewerForm::InitShowGallery(void)
1868 AppLogDebug("ENTER");
1869 if (__pGallery != null && __pGallery->IsVisible() == false)
1871 Canvas* pCanvas = GetCanvasN();
1872 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1874 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1880 __pGallery->SetShowState(true);
1883 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1887 ImageViewerForm::OnTimerExpired(Timer &timer)
1889 AppLog("ImageViewerForm::OnTimerExpired");
1891 if (timer.Equals(*__pShuffelTimer) == true)
1893 AppLog("OnTimerExpired __pShuffelTimer");
1894 int curItemIndex = __pGallery->GetCurrentItemIndex();
1895 int index = __pShuffledList[curItemIndex];
1897 __isShuffle = false;
1899 __pGallery->UpdateGallery();
1901 AppLog("ImageViewerForm::OnGallerySlideShowStopped index = %d, shuffelIndex = %d", curItemIndex, index);
1903 __pGallery->SetCurrentItemIndex(index);
1906 SlideShowStopped(index);
1910 int repeatValue = 0;
1911 int shuffleValue = 0;
1913 if (__pPresentationModel->GetFileCount() > 1)
1915 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1916 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1918 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1919 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
1921 if (shuffleValue != 0)
1923 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
1924 CreateShuffledList(__pPresentationModel->GetFileCount());
1929 __shuffelStartIndex = 0;
1930 __isShuffle = false;
1933 if ( repeatValue == 0)
1935 __pGallery->StartSlideShow(false);
1939 __pGallery->StartSlideShow(true);
1942 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1946 ImageViewerForm::CreateShuffledList(int count)
1948 AppLogDebug("ENTER");
1949 if (__pShuffledList == null)
1951 __pShuffledList = new (std::nothrow) int[count];
1952 for(int i = 0; i < count; ++i)
1954 __pShuffledList[i] = i;
1957 for(int i = count - 1; i > 1; --i)
1959 int randomNum = Math::Rand() % (i+1);
1960 int t = __pShuffledList[randomNum];
1961 __pShuffledList[randomNum] = __pShuffledList[i];
1962 __pShuffledList[i] = t;
1964 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1968 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1970 AppLogDebug("ENTER");
1971 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1975 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1976 const String& errorMessage)
1978 AppLogDebug("ENTER");
1979 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1983 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1984 result transferResult, const String& errorCode, const String& errorMessage)
1986 AppLogDebug("ENTER");
1987 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1991 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1992 const String& errorCode, const String& errorMessage)
1994 AppLogDebug("ENTER");
1995 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1999 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
2000 const String& errorMessage)
2002 AppLogDebug("ENTER");
2003 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2007 ImageViewerForm::RequestDecodeUrl(void)
2009 AppLogDebug("ENTER");
2011 String filePath = __pPresentationModel->GetFilePathAt(0);
2013 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
2015 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2020 __downloadFileName = __pPresentationModel->GetFileName(filePath);
2022 Image* pImage = new (std::nothrow) Image();
2023 pImage->Construct();
2026 uri.SetUri(filePath);
2028 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
2031 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2035 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
2036 result r, const String errorCode, const String errorMessage)
2038 AppLogDebug("ENTER");
2039 Image* pImage = new (std::nothrow) Image();
2040 pImage->Construct();
2042 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
2043 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
2047 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
2048 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
2050 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
2052 __pPresentationModel->RequestImage(destPath);
2056 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
2060 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2064 ImageViewerForm::OnRequestEmailAction(void)
2066 AppLogDebug("ENTER");
2067 int currentIndex = __pGallery->GetCurrentItemIndex();
2069 if (__pPresentationModel->GetFileCount() <= 0)
2071 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2075 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2077 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2078 pDataList->Construct();
2080 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2081 pList->Add(new (std::nothrow) String(filePath));
2083 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
2085 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
2086 new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, this);
2087 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2091 ImageViewerForm::OnRequestMessagesAction(void)
2093 AppLogDebug("ENTER");
2094 int currentIndex = __pGallery->GetCurrentItemIndex();
2096 if (__pPresentationModel->GetFileCount() <= 0)
2098 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2102 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2104 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2105 pDataList->Construct();
2106 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2107 pList->Add(new (std::nothrow) String(filePath));
2108 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
2109 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
2111 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES, APPCONTROL_OPERATION_ID_COMPOSE, null,
2112 null, pDataList, this);
2113 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2117 ImageViewerForm::SetFooterItemState(bool isEnable)
2119 AppLogDebug("ENTER");
2120 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
2122 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2123 __pFooter->SetItemEnabled(0, isEnable);
2124 __pFooter->SetItemEnabled(1, isEnable);
2126 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
2128 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2129 __pFooter->SetItemEnabled(0, isEnable);
2130 __pFooter->SetItemEnabled(1, isEnable);
2132 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
2134 __pFooter->SetItemEnabled(0, isEnable);
2136 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2140 ImageViewerForm::GetQuickThumbnailN(String& filePath) const
2142 AppLogDebug("ENTER");
2143 Bitmap* pBitmap = null;
2145 if (filePath.GetLength() > 4)
2149 ContentSearch contentSearch;
2150 ContentSearchResult* pResultItem = null;
2151 IList* pContentInfoList = null;
2153 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
2154 result r = contentSearch.Construct(contentType);
2155 AppLogDebug("r(%s)", GetErrorMessage(r));
2158 pBitmap = new (std::nothrow) Bitmap();
2159 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
2170 queryString = CONTENT_QUERY_PREFIX_FILENAME;
2171 queryString.Append(L"'");
2172 queryString.Append(__pPresentationModel->GetFileName(filePath));
2173 queryString.Append(L"'");
2175 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
2176 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
2178 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
2180 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
2181 while (pEnum->MoveNext() == E_SUCCESS)
2183 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
2184 if (pResultItem == null)
2189 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
2191 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
2197 if (pContentInfoList != null)
2199 delete pContentInfoList;
2202 if (pBitmap != null)
2204 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2206 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2208 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
2209 result r = imageBuffer->Construct(filePath);
2212 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
2213 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
2215 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
2216 pBitmap->Scale(srcDim);
2220 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
2221 pBitmap->Scale(srcDim);
2227 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
2229 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
2231 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
2233 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
2234 pBitmap->Scale(srcDim);
2242 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
2243 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_BLACK), DUMMY_IMAGE_RECTANGLE);
2244 pBitmap = new (std::nothrow) Bitmap();
2245 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2248 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2252 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2254 AppLogDebug(" ENTER");
2256 int currentIndex = __pGallery->GetCurrentItemIndex();
2257 int fileCount = __pPresentationModel->GetFileCount();
2259 if (fileCount == 0 && eventId == IV_FILE_DELETE)
2261 UiApp* pApp = UiApp::GetInstance();
2263 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2266 if (fileCount <= currentIndex && eventId == IV_FILE_DELETE)
2268 currentIndex = fileCount - 1;
2270 else if (eventId == IV_FILE_CREATE)
2272 currentIndex = index;
2275 String strItemIdxText(EMPTY_SPACE);
2276 __pGallery->SetCurrentItemIndex(currentIndex);
2277 __pGallery->UpdateGallery();
2278 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2279 __pPresentationModel->RequestImage(filePath);
2281 GetLabelText(currentIndex,strItemIdxText);
2282 __pLabel->SetText(strItemIdxText);
2284 if (__isVisible == true)
2286 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2288 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2290 __pPlayButton->SetShowState(false);
2294 __pPlayButton->SetShowState(true);
2297 if (__isDetail == false)
2299 __pScrollPanel->SetShowState(false);
2304 AppLogDebug("EXIT");
2308 ImageViewerForm::OnSlideSettingPopUpItemSelected(int index)
2310 if ( __pPopUp != NULL)
2312 __pPopUp->SetShowState(false);
2317 int repeatValue = 0;
2319 int transitioneffect = 0;
2321 if (__pPresentationModel->GetFileCount() > 1)
2324 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2325 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, interval);
2327 interval = interval * 1000;
2328 __pGallery->SetSlideShowViewDuration(interval);
2329 __pGallery->UpdateGallery();
2331 if (__isDetail == false)
2333 ShowPanelDetail(false);
2336 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2337 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2339 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2340 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
2342 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2343 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, transitioneffect);
2345 if (transitioneffect == 1)
2347 __pGallery->SetSlideShowAnimation(GALLERY_ANIMATION_DISSOLVE);
2349 else if (transitioneffect == 2)
2351 __pGallery->SetSlideShowAnimation(GALLERY_ANIMATION_ZOOM);
2355 __pGallery->SetSlideShowAnimation(GALLERY_ANIMATION_PAGE);
2358 if (shuffleValue != 0)
2360 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
2361 CreateShuffledList(__pPresentationModel->GetFileCount());
2366 __shuffelStartIndex = 0;
2367 __isShuffle = false;
2370 if (repeatValue == 0)
2372 __pGallery->StartSlideShow(false);
2376 __pGallery->StartSlideShow(true);
2380 else if (index == 1)
2382 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY,
2383 APPCONTROL_OPERATION_ID_CONFIGURE, null, null, null, this);