2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file IvImageViewerForm.cpp
19 * @brief This is the implementation file for ImageViewerForm class.
23 #include "IvCommonUtil.h"
24 #include "IvImageInfo.h"
25 #include "IvImageViewerApp.h"
26 #include "IvImageViewerForm.h"
27 #include "IvImageViewerPresentationModel.h"
28 #include "IvResourceManager.h"
29 #include "IvSettingPresentationModel.h"
30 #include "IvSlideShowPopUp.h"
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Base::Utility;
38 using namespace Tizen::Content;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Io;
41 using namespace Tizen::Media;
42 using namespace Tizen::System;
43 using namespace Tizen::Ui;
44 using namespace Tizen::Ui::Controls;
45 using namespace Tizen::Ui::Scenes;
47 static const unsigned int COLOR_HEADER_CONTORL_PANEL = Color32<0, 0, 0, 100>::Value;
48 static const unsigned int COLOR_HEADER_BUTTON1 = Color32<0, 0, 0, 100>::Value;
49 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
50 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
51 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
52 static const unsigned int COLOR_GALLERY_BG = Color32<31,31,31>::Value;
54 static const Rectangle RECT_DETAILS_CONTORL_LABEL (20, 0, 200, 48);
56 static const int W_PLAY_BUTTON = 160;
57 static const int H_PLAY_BUTTON = 160;
59 static const int GAP_W_POPUP_ITEM = 5;
60 static const int W_DELETE_POPUP = 600;
61 static const int H_DELETE_POPUP = 300;
62 static const int H_DELETE_LABEL = 180;
63 static const int Y_DELETE_BUTTON = 180;
64 static const int H_DELETE_BUTTON = 80;
66 static const Dimension DUMMY_IMAGE_DIMENSION (720, 1280);
67 static const Rectangle DUMMY_IMAGE_RECTANGLE (0, 0, 720, 1280);
69 static const int PAGE_NO_CONTENT_SEARCH = 1;
70 static const int COUNT_PER_PAGE_CONTENT_SEARCH = 10;
72 static const int FORMAT_BUFFER_SIZE = 256;
74 static const long long SINGLE_GIGA_BYTE = (1024 * 1024 * 1024);
75 static const long long SINGLE_MEGA_BYTE = (1024 * 1024);
76 static const long long SINGLE_KILO_BYTE = 1024;
78 static const int Y_RENAME_BUTTON = 100;
79 static const int H_RENAME_BUTTON = 64;
80 static const int W_RENAME_BUTTON = 64;
82 static const int GAP_W_END_OF_LABEL = 60;
83 static const int X_DETAIL_FILEINFO_LABEL = 20;
84 static const int H_DETAIL_FILEINFO_LABEL = 50;
85 static const int H_DETAIL_MAIN_TEXT = 48;
86 static const int H_DETAIL_SUB_TEXT = 42;
87 static const int GAP_H_DETAIL_TEXT = 26;
88 static const int H_DETAIL_FILEINFO_VALUE_LABEL = 56;
90 static const int X_MORE = 55;
92 static const int DETAIL_SUB_FONT_SIZE = 32;
93 static const int DETAIL_MAIN_FONT_SIZE = 36;
94 static const int DETAIL_COUNT_MAX = 9;
96 ImageViewerForm::ImageViewerForm(void)
97 : __shuffelStartIndex(0)
98 , __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
101 , __pScrollPanel(null)
102 , __pDetail_Label(null)
103 , __pLabelMessage(null)
104 , __pPlayButton(null)
105 , __pRenameButton(null)
106 , __pDetailFooterItem(null)
109 , __pShuffelTimer(null)
110 , __pContextMenuMore(null)
111 , __pContextMenuCopy(null)
112 , __pContextMenuSetAs(null)
113 , __pContextMenuShare(null)
114 , __pDeletePopup(null)
117 , __startSlide(false)
120 , __pShuffledList(null)
121 , __pPresentationModel(null)
123 AppLogDebug("ENTER");
124 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
127 ImageViewerForm::~ImageViewerForm(void)
129 AppLogDebug("ENTER");
130 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
134 ImageViewerForm::Initialize()
136 AppLogDebug("ENTER");
138 result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
140 __pPresentationModel = ImageViewerPresentationModel::GetInstance();
142 if (__pPresentationModel->GetFileCount() > 0)
144 if (__pPresentationModel->GetType() == APPCONTROL_DATA_SLIDE_SHOW)
150 __pPresentationModel->AddFileUpdateListener(this);
152 __pSettingPresentationModel = SettingPresentationModel::GetInstance();
154 int startIndex = __pPresentationModel->GetStartIndex();
155 String filePath = __pPresentationModel->GetFilePathAt(startIndex);
157 if (filePath.StartsWith(WEB_URL_HTTP, 0) == true)
159 __initializeDisplayModeCurrent = APPCONTROL_MODE_WEB_LINK;
161 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_MESSAGE)
163 __initializeDisplayModeCurrent = APPCONTROL_MODE_MESSAGE;
165 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_EMAIL)
167 __initializeDisplayModeCurrent = APPCONTROL_MODE_EMAIL;
171 __initializeDisplayModeCurrent = APPCONTROL_MODE_NORMAL;
174 if (filePath == EMPTY_SPACE)
176 MessageBox messageBox;
177 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE,
180 messageBox.ShowAndWait(modalResult);
182 UiApp* pApp = UiApp::GetInstance();
186 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
192 ImageViewerForm::OnInitializing(void)
194 AppLogDebug("ENTER");
195 result r = E_SUCCESS;
196 SetFormBackEventListener(this);
197 __pPresentationModel->AddListener(this);
199 __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL_INFO"));
205 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
206 SetControlAlwaysOnTop(*__pLabel,true);
207 int allCount = __pPresentationModel->GetFileCount();
210 displayText.Append(index);
211 displayText.Append("/");
212 displayText.Append(allCount);
214 __pLabel->SetText(displayText);
217 InitializeDisplay(__initializeDisplayModeCurrent);
218 InitializePanelDetail();
221 __pPopUp = new (std::nothrow) SlideShowPopUp();
223 if (__pPopUp != null)
225 __pPopUp->Initialize();
226 __pPopUp->SetEventListner(this);
227 AddControl(*__pPopUp);
231 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
232 || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
233 || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
235 int index = __pPresentationModel->GetStartIndex();
236 __pGallery->UpdateGallery();
237 __pGallery->SetCurrentItemIndex(index);
240 String filePath = __pPresentationModel->GetFilePathAt(index);
241 __pPresentationModel->RequestImage(filePath);
243 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
250 __pTimer = new (std::nothrow) Timer();
251 __pTimer->Construct(*this);
255 AddOrientationEventListener(*this);
256 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
262 ImageViewerForm::OnInitialized(void)
264 AppLogDebug("ENTER");
265 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
271 ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
273 AppLogDebug("ENTER");
274 if (__detail == false)
276 ShowPanelDetail(true);
280 ShowPanelDetail(false);
283 Rectangle clientRect = GetClientAreaBounds();
284 Rectangle rect = GetBounds();
286 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
287 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
288 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
291 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
295 ImageViewerForm::InitializeDisplay(AppControlMode status)
297 AppLogDebug("ENTER");
299 String strItemIdxText;
301 __pFooter = GetFooter();
302 __pFooter->AddActionEventListener(*this);
303 __pFooter->RemoveAllItems();
305 GetLabelText(0, strItemIdxText);
306 Rectangle rect = GetClientAreaBounds();
309 if (status == APPCONTROL_MODE_NORMAL)
311 __pPlayButton = new (std::nothrow) Button();
312 if (__pPlayButton != null)
314 Rectangle clientRect = GetClientAreaBounds();
316 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
317 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
318 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
319 AddControl(*__pPlayButton);
321 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
322 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
323 delete pNormalBackgroundBitmap;
325 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
326 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
327 delete pPressedBackgroundBitmap;
329 __pPlayButton->AddActionEventListener(*this);
330 __pPlayButton->SetShowState(false);
333 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
334 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
335 __pFooter->SetBackButton();
337 FooterItem footerItem1;
338 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
339 Bitmap* pFooterItemShareNomal =
340 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
341 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
343 FooterItem footerItem2;
344 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DELETE);
345 Bitmap* pFooterItemDeleteNomal =
346 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
347 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
349 __pFooter->AddItem(footerItem1);
350 __pFooter->AddItem(footerItem2);
352 delete pFooterItemShareNomal;
353 delete pFooterItemDeleteNomal;
355 ButtonItem buttonItemMore;
356 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
357 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
358 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
359 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
360 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
361 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
363 else if (status == APPCONTROL_MODE_WEB_LINK)
365 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
366 __pFooter->SetBackButton();
368 FooterItem footerItem1;
369 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
370 Bitmap* pFooterItemShareNomal =
371 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
372 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
374 FooterItem footerItem2;
375 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DOWNLOAD);
376 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
377 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
379 __pFooter->AddItem(footerItem1);
380 __pFooter->AddItem(footerItem2);
382 delete pFooterItemShareNomal;
383 delete pFooterItemDownlordNomal;
385 ButtonItem buttonItemMore;
386 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
387 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
388 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
389 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
390 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
391 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
393 __pFooter->AddItem(footerItem1);
394 __pFooter->AddItem(footerItem2);
396 else if (status == APPCONTROL_MODE_CROP)
398 FooterItem footerItem1;
399 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SAVE);
400 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
401 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
403 FooterItem footerItem2;
404 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_BACK);
405 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
406 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
408 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
409 __pFooter->AddItem(footerItem1);
410 __pFooter->AddItem(footerItem2);
415 else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
417 __pPlayButton = new (std::nothrow) Button();
418 if (__pPlayButton != null)
420 Rectangle clientRect = GetClientAreaBounds();
422 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
423 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
424 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
425 AddControl(*__pPlayButton);
427 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
428 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
429 delete pNormalBackgroundBitmap;
431 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
432 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
433 delete pPressedBackgroundBitmap;
435 __pPlayButton->AddActionEventListener(*this);
436 __pPlayButton->SetShowState(false);
439 __pFooter->SetBackButton();
442 String filePath = __pPresentationModel->GetFilePathAt(0);
443 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
444 if (contentType == CONTENT_TYPE_VIDEO)
446 __pPlayButton->SetShowState(true);
448 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
452 ImageViewerForm::GetLabelText(int index, String &page)
454 AppLogDebug("ENTER");
455 int allCount = __pPresentationModel->GetFileCount();
456 String pStr = __pPresentationModel->GetFilePathAt(index);
457 page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
458 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
462 ImageViewerForm::DeleteImageFile()
464 AppLogDebug("ENTER");
465 int currentIndex = __pGallery->GetCurrentItemIndex();
467 String strItemText(EMPTY_SPACE);
468 String strItemIdxText(EMPTY_SPACE);
469 int countPath = __pPresentationModel->GetFileCount();
470 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
472 if (filePath.GetLength() == 0)
474 UiApp* pApp = UiApp::GetInstance();
476 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
481 result r = File::Remove(filePath);
484 MessageBox messageBox;
485 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
486 MSGBOX_STYLE_NONE, 3000);
488 messageBox.ShowAndWait(modalResult);
489 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
494 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
495 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
497 ContentManager::ScanFile(filePath);
500 __pPresentationModel->DeleteFilePathAt(currentIndex);
503 UiApp* pApp = UiApp::GetInstance();
505 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
509 else if ((countPath - 1) == currentIndex)
511 __pGallery->SetCurrentItemIndex(--currentIndex);
514 __pGallery->UpdateGallery();
515 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
516 __pPresentationModel->RequestImage(filePath);
518 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
520 __pLabel->SetText(strItemIdxText);
522 if (__visible == true)
524 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
526 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
528 __pPlayButton->SetShowState(false);
532 __pPlayButton->SetShowState(true);
536 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
542 ImageViewerForm::CallVideoPlayer(void)
544 AppLogDebug("ENTER");
545 int index = __pGallery->GetCurrentItemIndex();
546 String filePath = __pPresentationModel->GetFilePathAt(index);
547 filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
549 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
550 new (std::nothrow) String(filePath), new (std::nothrow) String(APPCONTROL_MIME_VIDEO_ALL), null, this);
551 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
555 ImageViewerForm::CreateGallery(void)
557 AppLogDebug("ENTER");
558 Rectangle clientRect = GetClientAreaBounds();
559 Rectangle rect = GetBounds();
561 __pGallery = new (std::nothrow) Gallery();
562 __pGallery->Construct(Rectangle(0, clientRect.y, rect.width, rect.height));
563 __pGallery->SetName(L"GalleryControl");
564 __pGallery->SetItemProvider(*this);
565 __pGallery->AddGalleryEventListener(*this);
566 __pGallery->SetBackgroundColor(COLOR_GALLERY_BG);
567 AddControl(*__pGallery);
568 __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
570 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
574 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
575 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
577 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
578 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
580 case SLIDE_SHOW_TRANSITION_EFFECT_SLIDE:
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_CONTORL_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(ACTION_ID_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_BODY_DELETE") + L"?");
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(ACTION_ID_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(ACTION_ID_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 ACTION_ID_CONTEXTMENU_SET_AS);
778 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), ACTION_ID_FOOTER_BUTTON_CROP);
779 //__pContextMenuMore->AddItem("Rotate Left", ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT);
780 //__pContextMenuMore->AddItem("Rotate Right", ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT);
783 if (__pGallery->GetItemCount() > 1)
785 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
786 ACTION_ID_FOOTER_BUTTON_SLIDE);
788 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
789 ACTION_ID_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 ACTION_ID_CONTEXTMENU_HOME);
814 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
815 ACTION_ID_CONTEXTMENU_LOCK);
816 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_POP_SET_WALLPAPER_FOR_HOME_SCREEN_AND_LOCK_SCREEN"),
817 ACTION_ID_CONTEXTMENU_HOME_AND_LOCK);
818 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
819 ACTION_ID_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 ACTION_ID_CONTEXTMENU_MESSAGE);
842 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
843 __pContextMenuShare->AddActionEventListener(*this);
844 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
850 ImageViewerForm::GetFileSize(String filePath)
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());
877 int currentIndex = __pGallery->GetCurrentItemIndex();
878 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
880 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
882 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
884 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
885 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
888 result r = File::GetAttributes(strFilePath, attr);
891 long long nSize = attr.GetFileSize();
892 DateTime dateTime = attr.GetDateTime();
893 strResult[2] = dateTime.ToString();
895 if (nSize > SINGLE_GIGA_BYTE)
897 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
898 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
900 else if (nSize > SINGLE_MEGA_BYTE)
902 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
903 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
905 else if (nSize > SINGLE_KILO_BYTE)
907 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
908 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
912 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
913 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
918 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
919 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
922 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
923 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
924 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
925 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
926 strResult[8] = strFilePath;
927 String fileName = File::GetFileName(strFilePath);
928 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
930 if (strResult[8].StartsWith(Tizen::System::Environment::GetMediaPath(), 0) == true)
932 strResult[8].Replace(Tizen::System::Environment::GetMediaPath(), MEDIA_ROOT_PHONE, 0);
935 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
937 strResult[0] = __downLordFileName;
939 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
941 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
943 if (pImgMeta != null)
945 ImageContentInfo imageContentInfo;
946 r = imageContentInfo.Construct(&strFilePath);
949 strResult[1] = imageContentInfo.GetMediaFormat();
950 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
951 pImgMeta->GetHeight());
953 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
955 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
958 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
960 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
961 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
967 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
969 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
970 if (pVideoMeta != null)
972 VideoContentInfo videoContentInfo;
973 r = videoContentInfo.Construct(&strFilePath);
976 strResult[1] = videoContentInfo.GetMediaFormat();
977 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
978 pVideoMeta->GetHeight());
979 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
981 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
987 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
989 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
990 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
993 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
995 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
999 Rectangle rect = GetBounds();
1000 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
1002 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1008 ImageViewerForm::ShowPanelDetail(bool showStatus)
1010 AppLogDebug("ENTER");
1014 __pScrollPanel->SetShowState(true);
1019 __pScrollPanel->SetShowState(false);
1022 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1028 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1030 AppLogDebug("ENTER");
1031 FooterItem footerItem;
1032 footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
1033 Bitmap* pfooterItem = null;
1037 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1038 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1042 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1043 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1046 pFooter->SetItemAt(position, footerItem);
1047 pFooter->Invalidate(true);
1050 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1056 ImageViewerForm::DownloadFile(void)
1058 AppLogDebug("ENTER");
1059 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1060 if (File::IsFileExist(DestPath) == false)
1062 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1066 ContentId contentId;
1067 ContentManager contentManager;
1068 contentManager.Construct();
1070 ImageContentInfo imageContentInfo;
1071 imageContentInfo.Construct(null);
1073 imageContentInfo.SetKeyword(L"platform, tizen");
1074 String sourcePath = DestPath;
1075 String destPath = Environment::GetMediaPath();
1076 destPath.Append(FOLDER_PATH_DOWNLOADS);
1077 destPath.Append(__downLordFileName);
1079 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1080 ImageViewerForm::OnFormBackRequested(*this);
1081 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1085 ImageViewerForm::GetItemCount(void)
1087 AppLogDebug("ENTER");
1088 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1090 return __pPresentationModel->GetFileCount();
1094 ImageViewerForm::CreateItem(int index)
1096 AppLogDebug("ENTER : index(%d)", index);
1097 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1099 int curIndex = index;
1101 if(__shuffle == true && __pShuffledList != null)
1103 curIndex = __pShuffledList[index];
1106 String filePath = __pPresentationModel->GetFilePathAt(curIndex);
1107 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1108 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1110 if (pBitmap == null)
1112 pBitmap = GetQuickThumbnailN(filePath);
1114 if (pBitmap == null)
1116 pBitmap = new (std::nothrow) Bitmap();
1117 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1120 pGallery->Construct(*pBitmap, filePath);
1122 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1128 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1130 AppLogDebug("ImageViewerForm::DeleteItem ENTER index(%d)", index);
1131 int curIndex = index;
1133 if(__shuffle == true && __pShuffledList != null)
1135 curIndex = __pShuffledList[index];
1139 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1140 pImageInfo->ClearBitmap();
1142 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1148 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1150 AppLogDebug("ImageViewerForm::OnGalleryCurrentItemChanged index(%d)", index);
1152 String filePath = __pPresentationModel->GetFilePathAt(index);
1153 AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1154 __pPresentationModel->RequestImage(filePath);
1156 String strItemIdxText;
1157 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1158 __pLabel->SetText(strItemIdxText);
1160 if (__visible == true)
1162 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1163 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1165 __pPlayButton->SetShowState(true);
1169 __pPlayButton->SetShowState(false);
1174 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1178 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1180 AppLogDebug("ENTER");
1182 String filePath = __pPresentationModel->GetFilePathAt(index);
1183 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1185 if (__visible == true)
1187 if (contentType == CONTENT_TYPE_VIDEO)
1189 __pPlayButton->SetShowState(false);
1192 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1193 __pLabel->SetShowState(false);
1198 if (contentType == CONTENT_TYPE_VIDEO)
1200 __pPlayButton->SetShowState(true);
1203 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1204 __pLabel->SetShowState(true);
1207 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1208 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1211 Rectangle clientRect = GetClientAreaBounds();
1212 Rectangle rect = GetBounds();
1213 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1215 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1219 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1221 AppLogDebug("ENTER");
1222 PowerManager::KeepScreenOnState(true, false);
1223 if (__visible == true)
1225 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1226 __pLabel->SetShowState(false);
1228 int index = __pGallery->GetCurrentItemIndex();
1229 String filePath = __pPresentationModel->GetFilePathAt(index);
1230 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1232 if (contentType == CONTENT_TYPE_VIDEO)
1234 __pPlayButton->SetShowState(false);
1240 Rectangle clientRect = GetClientAreaBounds();
1241 Rectangle rect = GetBounds();
1242 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1244 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1248 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1250 AppLogDebug("ImageViewerForm::OnGallerySlideShowStopped");
1254 if(__shuffle == true)
1257 if(__pShuffelTimer == null)
1259 __pShuffelTimer = new (std::nothrow) Timer();
1260 __pShuffelTimer->Construct(*this);
1262 __pShuffelTimer->Start(1);
1266 index = __pGallery->GetCurrentItemIndex();
1267 SlideShowStopped(index);
1271 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1275 ImageViewerForm::SlideShowStopped(int index)
1277 AppLog("ImageViewerForm::SlideShowStopped");
1278 PowerManager::KeepScreenOnState(false, true);
1280 if (__visible == false)
1282 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1283 __pLabel->SetShowState(true);
1284 String filePath = __pPresentationModel->GetFilePathAt(index);
1285 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1286 if (contentType == CONTENT_TYPE_VIDEO)
1288 __pPlayButton->SetShowState(true);
1291 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1292 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1297 String strItemIdxText;
1298 GetLabelText(index, strItemIdxText);
1299 __pLabel->SetText(strItemIdxText);
1302 Rectangle clientRect = GetClientAreaBounds();
1303 Rectangle rect = GetBounds();
1304 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1310 ImageViewerForm::OnUpdateContentList(void)
1315 ImageViewerForm::OnTerminating(void)
1317 AppLogDebug("ENTER");
1319 if (__pTimer != null)
1328 __pShuffelTimer->Cancel();
1329 delete __pShuffelTimer;
1330 __pShuffelTimer = null;
1333 __pPresentationModel->ClearImageRequests();
1334 __pPresentationModel->RemoveListener(*this);
1335 __pPresentationModel->RemoveFileUpdateListener(*this);
1337 if (__pContextMenuCopy != null)
1339 delete __pContextMenuCopy;
1340 __pContextMenuCopy = null;
1343 if (__pContextMenuSetAs != null)
1345 delete __pContextMenuSetAs;
1346 __pContextMenuSetAs = null;
1349 if (__pDeletePopup != null)
1351 delete __pDeletePopup;
1352 __pDeletePopup = null;
1355 if (__pContextMenuShare != null)
1357 delete __pContextMenuShare;
1358 __pContextMenuShare = null;
1361 if (__pContextMenuMore != null)
1363 delete __pContextMenuMore;
1364 __pContextMenuMore = null;
1367 if(__pShuffledList != null)
1369 free(__pShuffledList);
1370 __pShuffledList = null;
1373 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1379 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1381 AppLogDebug("ENTER actionId(%d)", actionId);
1382 SceneManager* pSceneManager = SceneManager::GetInstance();
1387 case ACTION_ID_FOOTER_MORE:
1389 InitializeContextMenuMore();
1391 __pContextMenuMore->SetShowState(true);
1392 __pContextMenuMore->Show();
1395 case ACTION_ID_CONTEXTMENU_SET_AS:
1396 InitializeContextMenuSetAs();
1398 __pContextMenuSetAs->SetShowState(true);
1399 __pContextMenuSetAs->Show();
1401 case ACTION_ID_FOOTER_BUTTON_SHARE:
1402 InitializeContextMenuShare();
1404 __pContextMenuShare->SetShowState(true);
1405 __pContextMenuShare->Show();
1407 case ACTION_ID_FOOTER_BUTTON_DELETE:
1408 __pDeletePopup->SetShowState(true);
1409 __pDeletePopup->Show();
1411 case ACTION_ID_FOOTER_BUTTON_SLIDE:
1413 if (__pPopUp != null)
1415 __pPopUp->SetShowState(true);
1421 case ACTION_ID_FOOTER_BUTTON_CROP:
1424 String cropMode = L"auto";
1425 //String cropMode = L"auto";
1426 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1427 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1428 pList->Add(new (std::nothrow) String(filePath));
1429 pList->Add(new (std::nothrow) String(cropMode));
1430 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1433 case ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT:
1435 int currentIndex = __pGallery->GetCurrentItemIndex();
1436 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1437 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1438 __pPresentationModel->SetImageRotateStatus(true);
1439 RotateImage(filePath, rotateMode);
1440 AppLog("Manish After Rotate");
1441 //__pPresentationModel->SetImageCacheAt(currentIndex, filePath);
1442 ImageInfo* pImageInfo = null;
1443 pImageInfo->Construct(filePath, null);
1444 pImageInfo->ClearBitmap();
1445 __pGallery->RefreshGallery(currentIndex, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1446 __pPresentationModel->RequestImage(filePath);
1447 ContentManager::ScanFile(filePath);
1450 case ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT:
1452 int currentIndex = __pGallery->GetCurrentItemIndex();
1453 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1454 RotateMode rotateMode = ROTATE_MODE_LEFT;
1455 __pPresentationModel->SetImageRotateStatus(true);
1456 RotateImage(filePath, rotateMode);
1457 __pPresentationModel->RequestImage(filePath);
1458 ContentManager::ScanFile(filePath);
1461 case ACTION_ID_FOOTER_BUTTON_DETAILS:
1463 ShowPanelDetail(__detail);
1466 case ACTION_ID_FOOTER_BUTTON_BACK:
1467 ImageViewerForm::OnFormBackRequested(*this);
1469 case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1472 case ACTION_ID_FOOTER_BUTTON_SAVE:
1474 case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1476 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1477 pSelectedIndex->Construct();
1478 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1479 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1482 case ACTION_ID_CONTEXTMENU_HOME:
1484 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1485 String cropMode = "fit-to-screen";
1486 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1487 pList->Add(new (std::nothrow) String(filePath));
1488 pList->Add(new (std::nothrow) String(cropMode));
1489 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1490 //__pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1491 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1494 case ACTION_ID_CONTEXTMENU_LOCK:
1496 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1497 String cropMode = "fit-to-screen";
1498 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1499 pList->Add(new (std::nothrow) String(filePath));
1500 pList->Add(new (std::nothrow) String(cropMode));
1501 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1502 //__pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1503 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1506 case ACTION_ID_CONTEXTMENU_CALLER:
1508 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1509 pDataList->Construct();
1510 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1511 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1512 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1513 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1514 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1515 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1517 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1518 APPCONTROL_OPERATION_ID_SOCIAL_PICK, null, null, pDataList, this);
1522 case ACTION_ID_CONTEXTMENU_HOME_AND_LOCK:
1524 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1525 String cropMode = "fit-to-screen";
1526 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1527 pList->Add(new (std::nothrow) String(filePath));
1528 pList->Add(new (std::nothrow) String(cropMode));
1529 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1530 //__pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1531 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1535 case ACTION_ID_CONTEXTMENU_EMAIL:
1537 OnRequestEmailAction();
1540 case ACTION_ID_CONTEXTMENU_MESSAGE:
1542 OnRequestMessagesAction();
1545 case ACTION_ID_CONTEXTMENU_COPY:
1547 int currentIndex = __pGallery->GetCurrentItemIndex();
1548 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1551 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1552 Clipboard* pClipboard = Clipboard::GetInstance();
1553 pClipboard->CopyItem(item);
1556 case ACTION_ID_DELETE_POPUP_DEL:
1558 __pDeletePopup->SetShowState(false);
1559 __pDeletePopup->Show();
1562 if (__detail == false)
1564 ShowPanelDetail(false);
1568 case ACTION_ID_DELETE_POPUP_CANCEL:
1570 __pDeletePopup->SetShowState(false);
1571 __pDeletePopup->Show();
1574 case ACTION_ID_CONTORL_BUTTON_PLAY:
1580 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1584 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1586 result r = E_SUCCESS;
1587 ImageBuffer rotateBuffer;
1588 ImageBuffer* pRotatedBuffer = null;
1589 ImageFormat imageFormat;
1591 r = img.Construct();
1594 imageFormat = img.GetImageFormat(filePath);
1596 r = rotateBuffer.Construct(filePath);
1598 //ImageBuffer::GetImageInfo(filePath, imageFormat, width, height);
1601 if (rotateMode == ROTATE_MODE_RIGHT)
1603 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1607 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1611 if (pRotatedBuffer != null)
1613 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1614 delete pRotatedBuffer;
1620 ImageViewerForm::OnFormBackRequested(Form& source)
1622 AppLogDebug("ENTER");
1623 if (__detail == false)
1625 ShowPanelDetail(false);
1629 UiApp* pApp = UiApp::GetInstance();
1632 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1636 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1637 const SceneId& currentSceneId, IList* pArgs)
1639 AppLogDebug("ENTER");
1641 Rectangle clientRect = GetClientAreaBounds();
1642 Rectangle rect = GetBounds();
1644 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1645 __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight()));
1646 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1648 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1651 String strItemIdxText(EMPTY_SPACE);
1652 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1653 __pLabel->SetText(strItemIdxText);
1657 if (previousSceneId == IDSCN_IMAGE_CROP && pArgs != null)
1659 AppLog("Manish hello");
1661 filePath = *(static_cast<String*>(pArgs->GetAt(0)));
1663 AppLog("Manish %ls", filePath.GetPointer());
1664 int count = __pPresentationModel->GetFileCount();
1665 __pPresentationModel->AddImageCache(filePath);
1666 __pGallery->UpdateGallery();
1667 __pGallery->SetCurrentItemIndex(count);
1668 __pPresentationModel->RequestImage(filePath);
1671 if (__pGallery->GetCurrentItemIndex() < 0)
1673 SetFooterItemState(false);
1677 SetFooterItemState(true);
1680 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1684 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1685 const SceneId& nextSceneId)
1687 AppLogDebug("ENTER");
1688 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1692 ImageViewerForm::OnImageDecodedN(const int index)
1694 AppLogDebug("ENTER");
1695 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1697 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1701 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1702 const String& operationId, AppCtrlResult appControlResult,
1703 const IMap* pExtraData)
1705 AppLogDebug("ENTER");
1707 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1708 && operationId == APPCONTROL_OPERATION_ID_SOCIAL_PICK
1709 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1711 const ArrayList* pResultList =
1712 static_cast<const ArrayList*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1713 const String* pContactId = null;
1715 if (pResultList != null)
1717 pContactId = static_cast<const String*>(pResultList->GetAt(0));
1720 long long lresult = 0;
1721 if (pContactId != null && pContactId->GetLength() > 0)
1723 LongLong::Parse(*pContactId, lresult);
1724 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1725 String cropMode = "fit-to-screen";
1726 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1727 pList->Add(new (std::nothrow) String(filePath));
1728 pList->Add(new (std::nothrow) String(cropMode));
1729 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1730 pList->Add(new (std::nothrow) LongLong(lresult));
1731 SceneManager* pSceneManager = SceneManager::GetInstance();
1732 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1733 /*ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1734 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1735 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1736 pList->Add(new (std::nothrow) LongLong(lresult));
1737 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1739 SceneManager* pSceneManager = SceneManager::GetInstance();
1740 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);*/
1744 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1745 pImageViewerApp->SetFrameEnabled(true);
1746 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1750 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1752 AppLogDebug("ENTER");
1753 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1757 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1759 AppLogDebug("ENTER");
1760 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1764 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1766 AppLogDebug("ENTER");
1767 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1771 ImageViewerForm::OnOtherControlSelected(const Control& source)
1773 AppLogDebug("ENTER");
1774 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1778 ImageViewerForm::InitShowGallery(void)
1780 AppLogDebug("ENTER");
1781 if (__pGallery != null && __pGallery->IsVisible() == false)
1783 Canvas* pCanvas = GetCanvasN();
1784 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1786 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1792 __pGallery->SetShowState(true);
1795 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1799 ImageViewerForm::OnTimerExpired(Timer &timer)
1801 AppLog("ImageViewerForm::OnTimerExpired");
1803 if(timer.Equals(*__pShuffelTimer) == true)
1805 AppLog("OnTimerExpired __pShuffelTimer");
1806 int curItemIndex = __pGallery->GetCurrentItemIndex();
1807 int index = __pShuffledList[curItemIndex];
1811 __pGallery->UpdateGallery();
1813 AppLog("ImageViewerForm::OnGallerySlideShowStopped index = %d, shuffelIndex = %d", curItemIndex, index);
1815 __pGallery->SetCurrentItemIndex(index);
1818 SlideShowStopped(index);
1822 int repeatValue = 0;
1823 int shuffleValue = 0;
1825 if (__pPresentationModel->GetFileCount() > 1)
1827 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1828 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1830 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1831 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
1834 if(shuffleValue != 0)
1836 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
1837 CreateShuffledList(__pPresentationModel->GetFileCount());
1842 __shuffelStartIndex = 0;
1846 if( repeatValue == 0)
1848 __pGallery->StartSlideShow(false);
1852 __pGallery->StartSlideShow(true);
1855 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1859 ImageViewerForm::CreateShuffledList(int count)
1861 AppLogDebug("ImageViewerForm::CreateShuffledList ENTER");
1862 if(__pShuffledList == null)
1864 __pShuffledList = new (std::nothrow) int[count];
1865 for(int i = 0; i < count; i++)
1867 __pShuffledList[i] = i;
1870 for(int i = count - 1; i > 1; i--)
1872 int randomNum = Math::Rand() % (i+1);
1873 int t = __pShuffledList[randomNum];
1874 __pShuffledList[randomNum] = __pShuffledList[i];
1875 __pShuffledList[i] = t;
1878 for(int i = 0; i < count; i++)
1880 AppLogDebug("ShuffeldList i = %d & Val = %d", i, __pShuffledList[i]);
1883 AppLogDebug("ImageViewerForm::CreateShuffledList EXIT");
1887 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1889 AppLogDebug("ENTER");
1890 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1894 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1895 const String& errorMessage)
1897 AppLogDebug("ENTER");
1898 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1902 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1903 result transferResult, const String& errorCode, const String& errorMessage)
1905 AppLogDebug("ENTER");
1906 AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1907 AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1908 AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1909 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1913 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1914 const String& errorCode, const String& errorMessage)
1916 AppLogDebug("ENTER");
1917 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1921 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1922 const String& errorMessage)
1924 AppLogDebug("ENTER");
1925 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1929 ImageViewerForm::RequestDecodeUrl(void)
1931 AppLogDebug("ENTER");
1933 String filePath = __pPresentationModel->GetFilePathAt(0);
1935 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1937 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1942 __downLordFileName = __pPresentationModel->GetFileName(filePath);
1944 Image* pImage = new (std::nothrow) Image();
1945 pImage->Construct();
1948 uri.SetUri(filePath);
1950 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1953 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1957 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1958 result r, const String errorCode, const String errorMessage)
1960 AppLogDebug("ENTER");
1961 Image* pImage = new (std::nothrow) Image();
1962 pImage->Construct();
1964 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1965 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1969 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1970 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1972 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1974 __pPresentationModel->RequestImage(destPath);
1978 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1982 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1986 ImageViewerForm::OnRequestEmailAction(void)
1988 AppLogDebug("ENTER");
1989 int currentIndex = __pGallery->GetCurrentItemIndex();
1991 if (__pPresentationModel->GetFileCount() <= 0)
1993 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1997 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1999 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2000 pDataList->Construct();
2002 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2003 pList->Add(new (std::nothrow) String(filePath));
2005 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
2007 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
2008 new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, this);
2009 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2013 ImageViewerForm::OnRequestMessagesAction(void)
2015 AppLogDebug("ENTER");
2016 int currentIndex = __pGallery->GetCurrentItemIndex();
2018 if (__pPresentationModel->GetFileCount() <= 0)
2020 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2024 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2026 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2027 pDataList->Construct();
2028 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2029 pList->Add(new (std::nothrow) String(filePath));
2030 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
2031 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
2033 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES, APPCONTROL_OPERATION_ID_COMPOSE, null,
2034 null, pDataList, this);
2035 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2039 ImageViewerForm::SetFooterItemState(bool isEnable)
2041 AppLogDebug("ENTER");
2042 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
2044 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2045 __pFooter->SetItemEnabled(0, isEnable);
2046 __pFooter->SetItemEnabled(1, isEnable);
2048 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
2050 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2051 __pFooter->SetItemEnabled(0, isEnable);
2052 __pFooter->SetItemEnabled(1, isEnable);
2054 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
2056 __pFooter->SetItemEnabled(0, isEnable);
2058 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2062 ImageViewerForm::GetQuickThumbnailN(String& filePath)
2064 AppLogDebug("ENTER");
2065 Bitmap* pBitmap = null;
2067 if (filePath.GetLength() > 4)
2071 ContentSearch contentSearch;
2072 ContentSearchResult* pResultItem = null;
2073 IList* pContentInfoList = null;
2075 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
2076 result r = contentSearch.Construct(contentType);
2077 AppLogDebug("r(%s)", GetErrorMessage(r));
2080 pBitmap = new (std::nothrow) Bitmap();
2081 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
2092 queryString = CONTENT_QUERY_PREFIX_FILENAME;
2093 queryString.Append(L"'");
2094 queryString.Append(__pPresentationModel->GetFileName(filePath));
2095 queryString.Append(L"'");
2097 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
2098 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
2100 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
2102 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
2103 while (pEnum->MoveNext() == E_SUCCESS)
2105 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
2106 if (pResultItem == null)
2111 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
2113 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
2119 if (pContentInfoList != null)
2121 delete pContentInfoList;
2124 if (pBitmap != null)
2126 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2128 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2130 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
2131 result r = imageBuffer->Construct(filePath);
2134 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
2135 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
2137 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
2138 pBitmap->Scale(srcDim);
2142 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
2143 pBitmap->Scale(srcDim);
2149 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
2151 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
2153 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
2155 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
2156 pBitmap->Scale(srcDim);
2164 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
2165 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
2166 pBitmap = new (std::nothrow) Bitmap();
2167 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2170 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2174 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2176 AppLogDebug(" ENTER");
2178 int currentIndex = __pGallery->GetCurrentItemIndex();
2179 int fileCount = __pPresentationModel->GetFileCount();
2181 if (fileCount == 0 && eventId == IV_FILE_DELETE)
2183 UiApp* pApp = UiApp::GetInstance();
2185 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2188 if (fileCount <= currentIndex && eventId == IV_FILE_DELETE)
2190 currentIndex = fileCount - 1;
2192 else if (eventId == IV_FILE_CREATE)
2194 currentIndex = index;
2198 String strItemIdxText(EMPTY_SPACE);
2199 __pGallery->SetCurrentItemIndex(currentIndex);
2200 __pGallery->UpdateGallery();
2201 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2202 __pPresentationModel->RequestImage(filePath);
2204 GetLabelText(currentIndex,strItemIdxText);
2205 __pLabel->SetText(strItemIdxText);
2207 if (__visible == true)
2209 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2211 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2213 __pPlayButton->SetShowState(false);
2217 __pPlayButton->SetShowState(true);
2220 if (__detail == false)
2222 __pScrollPanel->SetShowState(false);
2227 AppLogDebug("EXIT");
2231 ImageViewerForm::OnSlideSettingPopUpItemSelected(int index)
2233 if ( __pPopUp != NULL)
2235 __pPopUp->SetShowState(false);
2238 if (index == 0) // start slide show
2240 int repeatValue = 0;
2242 if (__pPresentationModel->GetFileCount() > 1)
2246 __pGallery->UpdateGallery();
2248 if (__detail == false)
2250 ShowPanelDetail(false);
2253 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2254 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2256 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2257 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
2259 if (shuffleValue != 0)
2261 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
2262 CreateShuffledList(__pPresentationModel->GetFileCount());
2267 __shuffelStartIndex = 0;
2271 if (repeatValue == 0)
2273 __pGallery->StartSlideShow(false);
2277 __pGallery->StartSlideShow(true);
2281 else if (index == 1) // launch settings
2283 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY,
2284 APPCONTROL_OPERATION_ID_CONFIGURE, null, null, null, this);