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"));
721 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
722 pLabel->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
724 Button* pDeleteButton = new (std::nothrow) Button();
725 pDeleteButton->Construct(
726 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
727 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
728 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
729 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
730 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
731 pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
732 pDeleteButton->AddActionEventListener(*this);
734 Button* pCancelButton = new (std::nothrow) Button();
735 pCancelButton->Construct(
736 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
737 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
738 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
739 pCancelButton->SetActionId(IDA_DELETE_POPUP_CANCEL);
740 pCancelButton->AddActionEventListener(*this);
742 __pDeletePopup->AddControl(*pLabel);
743 __pDeletePopup->AddControl(*pDeleteButton);
744 __pDeletePopup->AddControl(*pCancelButton);
748 __pDeletePopup->SetShowState(true);
749 __pDeletePopup->Show();
751 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
757 ImageViewerForm::InitializeContextMenuMore(void)
759 AppLogDebug("ENTER");
760 int currentIndex = __pGallery->GetCurrentItemIndex();
761 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
763 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
765 if (__pContextMenuMore != null)
767 delete __pContextMenuMore;
768 __pContextMenuMore = null;
771 __pContextMenuMore = new (std::nothrow) ContextMenu();
773 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().height),
774 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
776 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
778 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
779 IDA_CONTEXTMENU_SET_AS);
780 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), IDA_FOOTER_BUTTON_CROP);
781 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"), IDA_FOOTER_BUTTON_ROTATE_RIGHT);
782 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"), IDA_FOOTER_BUTTON_ROTATE_LEFT);
785 if (__pGallery->GetItemCount() > 1)
787 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
788 IDA_FOOTER_BUTTON_SLIDE);
790 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
791 IDA_FOOTER_BUTTON_DETAILS);
792 __pContextMenuMore->SetShowState(false);
793 __pContextMenuMore->AddActionEventListener(*this);
794 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
800 ImageViewerForm::InitializeContextMenuSetAs(void)
802 AppLogDebug("ENTER");
804 if (__pContextMenuSetAs != null)
806 delete __pContextMenuSetAs;
807 __pContextMenuSetAs = null;
810 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
811 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
812 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
814 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
815 IDA_CONTEXTMENU_HOME);
816 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
817 IDA_CONTEXTMENU_LOCK);
818 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_HOME_AND_LOCK_SCREENS"),
819 IDA_CONTEXTMENU_HOME_AND_LOCK);
820 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
821 IDA_CONTEXTMENU_CALLER);
822 __pContextMenuSetAs->AddActionEventListener(*this);
823 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
829 ImageViewerForm::InitializeContextMenuShare(void)
831 AppLogDebug("ENTER");
832 if (__pContextMenuShare != null)
834 delete __pContextMenuShare;
835 __pContextMenuShare = null;
837 __pContextMenuShare = new (std::nothrow) ContextMenu();
838 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
839 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
840 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
842 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
843 IDA_CONTEXTMENU_MESSAGE);
844 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), IDA_CONTEXTMENU_EMAIL);
845 __pContextMenuShare->AddActionEventListener(*this);
846 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
852 ImageViewerForm::GetFileSize(String filePath) const
854 AppLogDebug("ENTER");
858 result r = File::GetAttributes(filePath, attr);
861 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
865 size = attr.GetFileSize();
866 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
872 ImageViewerForm::SetDetailInfo(void)
874 AppLogDebug("ENTER");
876 Rectangle clientRect = GetClientAreaBounds();
877 __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
878 int currentIndex = __pGallery->GetCurrentItemIndex();
879 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
881 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
883 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
885 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
886 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
889 result r = File::GetAttributes(strFilePath, attr);
892 long long nSize = attr.GetFileSize();
893 DateTime dateTime = attr.GetDateTime();
894 strResult[2] = dateTime.ToString();
896 if (nSize > SINGLE_GIGA_BYTE)
898 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
899 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
901 else if (nSize > SINGLE_MEGA_BYTE)
903 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
904 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
906 else if (nSize > SINGLE_KILO_BYTE)
908 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
909 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
913 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
914 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
919 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
920 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
923 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
924 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
925 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
926 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
927 strResult[8] = strFilePath;
928 String fileName = File::GetFileName(strFilePath);
929 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
931 if (strResult[8].StartsWith(Tizen::System::Environment::GetMediaPath(), 0) == true)
933 strResult[8].Replace(Tizen::System::Environment::GetMediaPath(), MEDIA_ROOT_PHONE, 0);
936 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
938 strResult[0] = __downloadFileName;
940 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
942 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
944 if (pImgMeta != null)
946 ImageContentInfo imageContentInfo;
947 r = imageContentInfo.Construct(&strFilePath);
950 strResult[1] = imageContentInfo.GetMediaFormat();
951 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
952 pImgMeta->GetHeight());
954 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
956 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
959 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
961 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
962 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
968 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
970 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
971 if (pVideoMeta != null)
973 VideoContentInfo videoContentInfo;
974 r = videoContentInfo.Construct(&strFilePath);
977 strResult[1] = videoContentInfo.GetMediaFormat();
978 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
979 pVideoMeta->GetHeight());
980 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
982 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
988 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
990 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
992 if (i == DETAIL_COUNT_MAX - 1)
994 __pDetail_FileInfo_Value_Label[i]->SetBounds(
995 Rectangle(X_DETAIL_FILEINFO_LABEL,
996 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
997 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3));
1001 __pDetail_FileInfo_Value_Label[i]->SetBounds(
1002 Rectangle(X_DETAIL_FILEINFO_LABEL,
1003 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
1004 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL));
1007 __pDetail_FileInfo_Value_Label[i]->Invalidate(true);
1010 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1012 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1016 Rectangle rect = GetBounds();
1017 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
1019 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1025 ImageViewerForm::ShowPanelDetail(bool showStatus)
1027 AppLogDebug("ENTER");
1031 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTROL_PANEL);
1032 __pLabel->Invalidate(true);
1033 __pScrollPanel->SetShowState(true);
1038 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTROL_LABEL);
1039 __pLabel->Invalidate(true);
1040 __pScrollPanel->SetShowState(false);
1043 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1049 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1051 AppLogDebug("ENTER");
1052 FooterItem footerItem;
1053 footerItem.Construct(IDA_FOOTER_BUTTON_DETAILS);
1054 Bitmap* pfooterItem = null;
1058 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1059 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1063 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1064 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1067 pFooter->SetItemAt(position, footerItem);
1068 pFooter->Invalidate(true);
1071 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1077 ImageViewerForm::DownloadFile(void)
1079 AppLogDebug("ENTER");
1080 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1081 if (File::IsFileExist(DestPath) == false)
1083 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1087 ContentId contentId;
1088 ContentManager contentManager;
1089 contentManager.Construct();
1091 ImageContentInfo imageContentInfo;
1092 imageContentInfo.Construct(null);
1094 imageContentInfo.SetKeyword(L"platform, tizen");
1095 String sourcePath = DestPath;
1096 String destPath = Environment::GetMediaPath();
1097 destPath.Append(FOLDER_PATH_DOWNLOADS);
1098 destPath.Append(__downloadFileName);
1100 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1101 ImageViewerForm::OnFormBackRequested(*this);
1102 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1106 ImageViewerForm::GetItemCount(void)
1108 AppLogDebug("ENTER");
1109 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1111 return __pPresentationModel->GetFileCount();
1115 ImageViewerForm::CreateItem(int index)
1117 AppLogDebug("ENTER : index(%d)", index);
1118 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1120 int curIndex = index;
1122 if (__isShuffle == true && __pShuffledList != null)
1124 curIndex = __pShuffledList[index];
1127 String filePath = __pPresentationModel->GetFilePathAt(curIndex);
1128 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1129 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1131 if (pBitmap == null)
1133 pBitmap = GetQuickThumbnailN(filePath);
1135 if (pBitmap == null && __pGallery->IsSlideShowStarted() == true)
1137 pBitmap = __pPresentationModel->GetImage(filePath);
1138 __pPresentationModel->RequestImage(filePath);
1140 else if (pBitmap == null)
1142 pBitmap = new (std::nothrow) Bitmap();
1143 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1146 pGallery->Construct(*pBitmap, filePath);
1148 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1154 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1156 AppLogDebug("ImageViewerForm::DeleteItem ENTER index(%d)", index);
1157 int curIndex = index;
1159 if (__isShuffle == true && __pShuffledList != null)
1161 curIndex = __pShuffledList[index];
1164 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1165 pImageInfo->ClearBitmap();
1167 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1173 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1175 AppLogDebug("ImageViewerForm::OnGalleryCurrentItemChanged index(%d)", index);
1177 String filePath = __pPresentationModel->GetFilePathAt(index);
1178 __pPresentationModel->RequestImage(filePath);
1180 String strItemIdxText;
1181 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1182 __pLabel->SetText(strItemIdxText);
1184 if (__isVisible == true)
1186 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1187 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1189 __pPlayButton->SetShowState(true);
1193 __pPlayButton->SetShowState(false);
1198 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1202 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1204 AppLogDebug("ENTER");
1206 String filePath = __pPresentationModel->GetFilePathAt(index);
1207 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1209 if (__isVisible == true)
1211 if (contentType == CONTENT_TYPE_VIDEO)
1213 __pPlayButton->SetShowState(false);
1216 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1217 __pLabel->SetShowState(false);
1218 __isVisible = false;
1222 if (contentType == CONTENT_TYPE_VIDEO)
1224 __pPlayButton->SetShowState(true);
1227 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1228 __pLabel->SetShowState(true);
1231 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1232 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
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::OnGallerySlideShowStarted(Gallery& gallery)
1245 AppLogDebug("ENTER");
1246 PowerManager::KeepScreenOnState(true, false);
1248 int index = __pGallery->GetCurrentItemIndex();
1249 String filePath = __pPresentationModel->GetFilePathAt(index);
1250 __pPresentationModel->RequestImage(filePath);
1252 if (__isVisible == true)
1254 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1255 __pLabel->SetShowState(false);
1257 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1258 if (contentType == CONTENT_TYPE_VIDEO)
1260 __pPlayButton->SetShowState(false);
1263 __isVisible = false;
1266 Rectangle clientRect = GetClientAreaBounds();
1267 Rectangle rect = GetBounds();
1268 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1270 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1274 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1276 AppLogDebug("ImageViewerForm::OnGallerySlideShowStopped");
1280 if (__isShuffle == true)
1282 if (__pShuffelTimer == null)
1284 __pShuffelTimer = new (std::nothrow) Timer();
1285 __pShuffelTimer->Construct(*this);
1287 __pShuffelTimer->Start(1);
1291 index = __pGallery->GetCurrentItemIndex();
1292 SlideShowStopped(index);
1295 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1299 ImageViewerForm::SlideShowStopped(int index)
1301 AppLog("ImageViewerForm::SlideShowStopped");
1302 PowerManager::KeepScreenOnState(false, true);
1304 if (__isVisible == false)
1306 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1307 __pLabel->SetShowState(true);
1308 String filePath = __pPresentationModel->GetFilePathAt(index);
1309 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1310 if (contentType == CONTENT_TYPE_VIDEO)
1312 __pPlayButton->SetShowState(true);
1315 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1316 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1321 String strItemIdxText;
1322 GetLabelText(index, strItemIdxText);
1323 __pLabel->SetText(strItemIdxText);
1326 Rectangle clientRect = GetClientAreaBounds();
1327 Rectangle rect = GetBounds();
1328 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1334 ImageViewerForm::OnUpdateContentList(void)
1339 ImageViewerForm::OnTerminating(void)
1341 AppLogDebug("ENTER");
1343 if (__pTimer != null)
1350 if (__pShuffelTimer)
1352 __pShuffelTimer->Cancel();
1353 delete __pShuffelTimer;
1354 __pShuffelTimer = null;
1357 __pPresentationModel->ClearImageRequests();
1358 __pPresentationModel->RemoveListener(*this);
1359 __pPresentationModel->RemoveFileUpdateListener(*this);
1361 if (__pContextMenuCopy != null)
1363 delete __pContextMenuCopy;
1364 __pContextMenuCopy = null;
1367 if (__pContextMenuSetAs != null)
1369 delete __pContextMenuSetAs;
1370 __pContextMenuSetAs = null;
1373 if (__pDeletePopup != null)
1375 delete __pDeletePopup;
1376 __pDeletePopup = null;
1379 if (__pContextMenuShare != null)
1381 delete __pContextMenuShare;
1382 __pContextMenuShare = null;
1385 if (__pContextMenuMore != null)
1387 delete __pContextMenuMore;
1388 __pContextMenuMore = null;
1391 if (__pShuffledList != null)
1393 free(__pShuffledList);
1394 __pShuffledList = null;
1397 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1403 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1405 AppLogDebug("ENTER actionId(%d)", actionId);
1406 SceneManager* pSceneManager = SceneManager::GetInstance();
1411 case IDA_FOOTER_MORE:
1413 InitializeContextMenuMore();
1415 __pContextMenuMore->SetShowState(true);
1416 __pContextMenuMore->Show();
1420 case IDA_CONTEXTMENU_SET_AS:
1422 InitializeContextMenuSetAs();
1423 __pContextMenuSetAs->SetShowState(true);
1424 __pContextMenuSetAs->Show();
1428 case IDA_FOOTER_BUTTON_SHARE:
1430 InitializeContextMenuShare();
1431 __pContextMenuShare->SetShowState(true);
1432 __pContextMenuShare->Show();
1436 case IDA_FOOTER_BUTTON_DELETE:
1438 __pDeletePopup->SetShowState(true);
1439 __pDeletePopup->Show();
1443 case IDA_FOOTER_BUTTON_SLIDE:
1445 if (__pPopUp != null)
1447 __pPopUp->SetShowState(true);
1453 case IDA_FOOTER_BUTTON_CROP:
1456 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1457 ImageBuffer imagebuffer;
1458 result r = imagebuffer.Construct(filePath);
1463 int imageWidth = imagebuffer.GetWidth();
1464 int imageHeight = imagebuffer.GetHeight();
1465 if (imageWidth <= (H_CROP_RECTANGLE * 3) || imageHeight <= (H_CROP_RECTANGLE * 3))
1467 MessageBox messageBox;
1468 String messageText = ResourceManager::GetString(L"IDS_IMGE_POP_IMAGE_IS_TOO_SMALL");
1469 messageBox.Construct(L"", messageText, MSGBOX_STYLE_OK, 3000);
1470 int modalResult = 0;
1471 messageBox.ShowAndWait(modalResult);
1475 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1476 pList->Add(new (std::nothrow) String(filePath));
1477 pList->Add(new (std::nothrow) String(APPCONTROL_DATA_AUTO));
1478 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1482 case IDA_FOOTER_BUTTON_ROTATE_RIGHT:
1484 int currentIndex = __pGallery->GetCurrentItemIndex();
1485 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1486 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1487 RotateImage(filePath, rotateMode);
1488 __pPresentationModel->RequestImage(filePath);
1489 ContentManager::ScanFile(filePath);
1493 case IDA_FOOTER_BUTTON_ROTATE_LEFT:
1495 int currentIndex = __pGallery->GetCurrentItemIndex();
1496 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1497 RotateMode rotateMode = ROTATE_MODE_LEFT;
1498 RotateImage(filePath, rotateMode);
1499 __pPresentationModel->RequestImage(filePath);
1500 ContentManager::ScanFile(filePath);
1504 case IDA_FOOTER_BUTTON_DETAILS:
1506 ShowPanelDetail(__isDetail);
1510 case IDA_FOOTER_BUTTON_BACK:
1512 ImageViewerForm::OnFormBackRequested(*this);
1516 case IDA_FOOTER_BUTTON_DOWNLOAD:
1522 case IDA_FOOTER_BUTTON_SAVE:
1525 case IDA_PANEL_HEADER_DETAILS_RENAME:
1527 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1528 pSelectedIndex->Construct();
1529 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1530 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1534 case IDA_CONTEXTMENU_HOME:
1536 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1537 if (File::IsFileExist(filePath))
1539 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1540 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1541 pList->Add(new (std::nothrow) String(filePath));
1542 pList->Add(new (std::nothrow) String(cropMode));
1543 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1544 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1548 MessageBox messageBox;
1549 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE, 3000);
1550 int modalResult = 0;
1551 messageBox.ShowAndWait(modalResult);
1552 UiApp* pApp = UiApp::GetInstance();
1559 case IDA_CONTEXTMENU_LOCK:
1561 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1562 if (File::IsFileExist(filePath))
1564 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1565 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1566 pList->Add(new (std::nothrow) String(filePath));
1567 pList->Add(new (std::nothrow) String(cropMode));
1568 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1569 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1574 MessageBox messageBox;
1575 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE, 3000);
1576 int modalResult = 0;
1577 messageBox.ShowAndWait(modalResult);
1578 UiApp* pApp = UiApp::GetInstance();
1585 case IDA_CONTEXTMENU_CALLER:
1587 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1588 pDataList->Construct();
1589 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1590 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1591 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1592 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1593 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1594 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1596 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1597 APPCONTROL_OPERATION_ID_SOCIAL_PICK, null, null, pDataList, this);
1601 case IDA_CONTEXTMENU_HOME_AND_LOCK:
1603 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1604 if (File::IsFileExist(filePath))
1606 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1607 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1608 pList->Add(new (std::nothrow) String(filePath));
1609 pList->Add(new (std::nothrow) String(cropMode));
1610 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1611 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1615 MessageBox messageBox;
1616 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE, 3000);
1617 int modalResult = 0;
1618 messageBox.ShowAndWait(modalResult);
1619 UiApp* pApp = UiApp::GetInstance();
1626 case IDA_CONTEXTMENU_EMAIL:
1628 OnRequestEmailAction();
1632 case IDA_CONTEXTMENU_MESSAGE:
1634 OnRequestMessagesAction();
1638 case IDA_CONTEXTMENU_COPY:
1640 int currentIndex = __pGallery->GetCurrentItemIndex();
1641 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1644 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1645 Clipboard* pClipboard = Clipboard::GetInstance();
1646 pClipboard->CopyItem(item);
1650 case IDA_DELETE_POPUP_DEL:
1652 __pDeletePopup->SetShowState(false);
1653 __pDeletePopup->Show();
1656 if (__isDetail == false)
1658 ShowPanelDetail(false);
1663 case IDA_DELETE_POPUP_CANCEL:
1665 __pDeletePopup->SetShowState(false);
1666 __pDeletePopup->Show();
1670 case IDA_CONTORL_BUTTON_PLAY:
1679 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1683 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1685 result r = E_SUCCESS;
1686 ImageBuffer rotateBuffer;
1687 ImageBuffer* pRotatedBuffer = null;
1688 ImageFormat imageFormat;
1690 r = img.Construct();
1694 imageFormat = img.GetImageFormat(filePath);
1697 r = rotateBuffer.Construct(filePath);
1700 if (rotateMode == ROTATE_MODE_RIGHT)
1702 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1706 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1710 if (pRotatedBuffer != null)
1712 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1713 delete pRotatedBuffer;
1719 ImageViewerForm::OnFormBackRequested(Form& source)
1721 AppLogDebug("ENTER");
1722 if (__isDetail == false)
1724 ShowPanelDetail(false);
1728 UiApp* pApp = UiApp::GetInstance();
1731 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1735 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1736 const SceneId& currentSceneId, IList* pArgs)
1738 AppLogDebug("ENTER");
1740 Rectangle clientRect = GetClientAreaBounds();
1741 Rectangle rect = GetBounds();
1743 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1744 __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight()));
1745 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1747 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1750 String strItemIdxText(EMPTY_SPACE);
1751 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1752 __pLabel->SetText(strItemIdxText);
1756 if (previousSceneId == IDSCN_IMAGE_CROP && pArgs != null)
1759 filePath = *(static_cast<String*>(pArgs->GetAt(0)));
1761 int count = __pPresentationModel->GetFileCount();
1762 __pPresentationModel->AddImageCache(filePath);
1763 __pGallery->UpdateGallery();
1764 __pGallery->SetCurrentItemIndex(count);
1765 __pPresentationModel->RequestImage(filePath);
1766 ShowPanelDetail(false);
1769 if (__pGallery->GetCurrentItemIndex() < 0)
1771 SetFooterItemState(false);
1775 SetFooterItemState(true);
1778 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1782 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1783 const SceneId& nextSceneId)
1785 AppLogDebug("ENTER");
1786 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1790 ImageViewerForm::OnImageDecodedN(const int index)
1792 AppLogDebug("ENTER");
1793 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1795 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1799 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1800 const String& operationId, AppCtrlResult appControlResult,
1801 const IMap* pExtraData)
1803 AppLogDebug("ENTER");
1805 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1806 && operationId == APPCONTROL_OPERATION_ID_SOCIAL_PICK
1807 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1809 const ArrayList* pResultList =
1810 static_cast<const ArrayList*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1811 const String* pContactId = null;
1813 if (pResultList != null)
1815 pContactId = static_cast<const String*>(pResultList->GetAt(0));
1818 long long lresult = 0;
1819 if (pContactId != null && pContactId->GetLength() > 0)
1821 LongLong::Parse(*pContactId, lresult);
1822 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1823 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1824 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1825 pList->Add(new (std::nothrow) String(filePath));
1826 pList->Add(new (std::nothrow) String(cropMode));
1827 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1828 pList->Add(new (std::nothrow) LongLong(lresult));
1829 SceneManager* pSceneManager = SceneManager::GetInstance();
1830 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1834 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1835 pImageViewerApp->SetFrameEnabled(true);
1836 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1840 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1842 AppLogDebug("ENTER");
1843 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1847 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1849 AppLogDebug("ENTER");
1850 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1854 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1856 AppLogDebug("ENTER");
1857 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1861 ImageViewerForm::OnOtherControlSelected(const Control& source)
1863 AppLogDebug("ENTER");
1864 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1868 ImageViewerForm::InitShowGallery(void)
1870 AppLogDebug("ENTER");
1871 if (__pGallery != null && __pGallery->IsVisible() == false)
1873 Canvas* pCanvas = GetCanvasN();
1874 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1876 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1882 __pGallery->SetShowState(true);
1885 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1889 ImageViewerForm::OnTimerExpired(Timer &timer)
1891 AppLog("ImageViewerForm::OnTimerExpired");
1893 if (timer.Equals(*__pShuffelTimer) == true)
1895 AppLog("OnTimerExpired __pShuffelTimer");
1896 int curItemIndex = __pGallery->GetCurrentItemIndex();
1897 int index = __pShuffledList[curItemIndex];
1899 __isShuffle = false;
1901 __pGallery->UpdateGallery();
1903 AppLog("ImageViewerForm::OnGallerySlideShowStopped index = %d, shuffelIndex = %d", curItemIndex, index);
1905 __pGallery->SetCurrentItemIndex(index);
1908 SlideShowStopped(index);
1912 int repeatValue = 0;
1913 int shuffleValue = 0;
1915 if (__pPresentationModel->GetFileCount() > 1)
1917 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1918 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1920 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1921 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
1923 if (shuffleValue != 0)
1925 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
1926 CreateShuffledList(__pPresentationModel->GetFileCount());
1931 __shuffelStartIndex = 0;
1932 __isShuffle = false;
1935 if ( repeatValue == 0)
1937 __pGallery->StartSlideShow(false);
1941 __pGallery->StartSlideShow(true);
1944 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1948 ImageViewerForm::CreateShuffledList(int count)
1950 AppLogDebug("ENTER");
1951 if (__pShuffledList == null)
1953 __pShuffledList = new (std::nothrow) int[count];
1954 for(int i = 0; i < count; ++i)
1956 __pShuffledList[i] = i;
1959 for(int i = count - 1; i > 1; --i)
1961 int randomNum = Math::Rand() % (i+1);
1962 int t = __pShuffledList[randomNum];
1963 __pShuffledList[randomNum] = __pShuffledList[i];
1964 __pShuffledList[i] = t;
1966 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1970 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1972 AppLogDebug("ENTER");
1973 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1977 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1978 const String& errorMessage)
1980 AppLogDebug("ENTER");
1981 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1985 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1986 result transferResult, const String& errorCode, const String& errorMessage)
1988 AppLogDebug("ENTER");
1989 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1993 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1994 const String& errorCode, const String& errorMessage)
1996 AppLogDebug("ENTER");
1997 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2001 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
2002 const String& errorMessage)
2004 AppLogDebug("ENTER");
2005 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2009 ImageViewerForm::RequestDecodeUrl(void)
2011 AppLogDebug("ENTER");
2013 String filePath = __pPresentationModel->GetFilePathAt(0);
2015 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
2017 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2022 __downloadFileName = __pPresentationModel->GetFileName(filePath);
2024 Image* pImage = new (std::nothrow) Image();
2025 pImage->Construct();
2028 uri.SetUri(filePath);
2030 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
2033 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2037 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
2038 result r, const String errorCode, const String errorMessage)
2040 AppLogDebug("ENTER");
2041 Image* pImage = new (std::nothrow) Image();
2042 pImage->Construct();
2044 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
2045 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
2049 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
2050 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
2052 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
2054 __pPresentationModel->RequestImage(destPath);
2058 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
2062 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2066 ImageViewerForm::OnRequestEmailAction(void)
2068 AppLogDebug("ENTER");
2069 int currentIndex = __pGallery->GetCurrentItemIndex();
2071 if (__pPresentationModel->GetFileCount() <= 0)
2073 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2077 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2079 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2080 pDataList->Construct();
2082 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2083 pList->Add(new (std::nothrow) String(filePath));
2085 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
2087 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
2088 new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, this);
2089 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2093 ImageViewerForm::OnRequestMessagesAction(void)
2095 AppLogDebug("ENTER");
2096 int currentIndex = __pGallery->GetCurrentItemIndex();
2098 if (__pPresentationModel->GetFileCount() <= 0)
2100 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2104 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2106 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2107 pDataList->Construct();
2108 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2109 pList->Add(new (std::nothrow) String(filePath));
2110 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
2111 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
2113 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES, APPCONTROL_OPERATION_ID_COMPOSE, null,
2114 null, pDataList, this);
2115 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2119 ImageViewerForm::SetFooterItemState(bool isEnable)
2121 AppLogDebug("ENTER");
2122 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
2124 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2125 __pFooter->SetItemEnabled(0, isEnable);
2126 __pFooter->SetItemEnabled(1, isEnable);
2128 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
2130 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2131 __pFooter->SetItemEnabled(0, isEnable);
2132 __pFooter->SetItemEnabled(1, isEnable);
2134 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
2136 __pFooter->SetItemEnabled(0, isEnable);
2138 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2142 ImageViewerForm::GetQuickThumbnailN(String& filePath) const
2144 AppLogDebug("ENTER");
2145 Bitmap* pBitmap = null;
2147 if (filePath.GetLength() > 4)
2151 ContentSearch contentSearch;
2152 ContentSearchResult* pResultItem = null;
2153 IList* pContentInfoList = null;
2155 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
2156 result r = contentSearch.Construct(contentType);
2157 AppLogDebug("r(%s)", GetErrorMessage(r));
2160 pBitmap = new (std::nothrow) Bitmap();
2161 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
2172 queryString = CONTENT_QUERY_PREFIX_FILENAME;
2173 queryString.Append(L"'");
2174 queryString.Append(__pPresentationModel->GetFileName(filePath));
2175 queryString.Append(L"'");
2177 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
2178 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
2180 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
2182 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
2183 while (pEnum->MoveNext() == E_SUCCESS)
2185 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
2186 if (pResultItem == null)
2191 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
2193 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
2199 if (pContentInfoList != null)
2201 delete pContentInfoList;
2204 if (pBitmap != null)
2206 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2208 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2210 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
2211 result r = imageBuffer->Construct(filePath);
2214 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
2215 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
2217 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
2218 pBitmap->Scale(srcDim);
2222 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
2223 pBitmap->Scale(srcDim);
2229 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
2231 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
2233 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
2235 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
2236 pBitmap->Scale(srcDim);
2244 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
2245 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_BLACK), DUMMY_IMAGE_RECTANGLE);
2246 pBitmap = new (std::nothrow) Bitmap();
2247 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2250 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2254 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2256 AppLogDebug(" ENTER");
2258 int currentIndex = __pGallery->GetCurrentItemIndex();
2259 int fileCount = __pPresentationModel->GetFileCount();
2261 if (fileCount == 0 && eventId == IV_FILE_DELETE)
2263 UiApp* pApp = UiApp::GetInstance();
2265 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2268 if (fileCount <= currentIndex && eventId == IV_FILE_DELETE)
2270 currentIndex = fileCount - 1;
2272 else if (eventId == IV_FILE_CREATE)
2274 currentIndex = index;
2277 String strItemIdxText(EMPTY_SPACE);
2278 __pGallery->SetCurrentItemIndex(currentIndex);
2279 __pGallery->UpdateGallery();
2280 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2281 __pPresentationModel->RequestImage(filePath);
2283 GetLabelText(currentIndex,strItemIdxText);
2284 __pLabel->SetText(strItemIdxText);
2286 if (__isVisible == true)
2288 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2290 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2292 __pPlayButton->SetShowState(false);
2296 __pPlayButton->SetShowState(true);
2299 if (__isDetail == false)
2301 __pScrollPanel->SetShowState(false);
2306 AppLogDebug("EXIT");
2310 ImageViewerForm::OnSlideSettingPopUpItemSelected(int index)
2312 if ( __pPopUp != NULL)
2314 __pPopUp->SetShowState(false);
2319 int repeatValue = 0;
2321 int transitioneffect = 0;
2323 if (__pPresentationModel->GetFileCount() > 1)
2326 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2327 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, interval);
2329 interval = interval * 1000;
2330 __pGallery->SetSlideShowViewDuration(interval);
2331 __pGallery->UpdateGallery();
2333 if (__isDetail == false)
2335 ShowPanelDetail(false);
2338 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2339 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2341 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2342 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
2344 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2345 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, transitioneffect);
2347 if (transitioneffect == 1)
2349 __pGallery->SetSlideShowAnimation(GALLERY_ANIMATION_DISSOLVE);
2351 else if (transitioneffect == 2)
2353 __pGallery->SetSlideShowAnimation(GALLERY_ANIMATION_ZOOM);
2357 __pGallery->SetSlideShowAnimation(GALLERY_ANIMATION_PAGE);
2360 if (shuffleValue != 0)
2362 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
2363 CreateShuffledList(__pPresentationModel->GetFileCount());
2368 __shuffelStartIndex = 0;
2369 __isShuffle = false;
2372 if (repeatValue == 0)
2374 __pGallery->StartSlideShow(false);
2378 __pGallery->StartSlideShow(true);
2382 else if (index == 1)
2384 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY,
2385 APPCONTROL_OPERATION_ID_CONFIGURE, null, null, null, this);