2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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);
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 (__isDetail == false)
276 ShowPanelDetail(true);
280 ShowPanelDetail(false);
282 if (__pContextMenuMore != null)
284 __pContextMenuMore->SetShowState(false);
287 Rectangle clientRect = GetClientAreaBounds();
288 Rectangle rect = GetBounds();
290 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
291 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
292 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
295 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
299 ImageViewerForm::InitializeDisplay(AppControlMode status)
301 AppLogDebug("ENTER");
303 String strItemIdxText;
305 __pFooter = GetFooter();
306 __pFooter->AddActionEventListener(*this);
307 __pFooter->RemoveAllItems();
309 GetLabelText(0, strItemIdxText);
310 Rectangle rect = GetClientAreaBounds();
313 if (status == APPCONTROL_MODE_NORMAL)
315 __pPlayButton = new (std::nothrow) Button();
316 if (__pPlayButton != null)
318 Rectangle clientRect = GetClientAreaBounds();
320 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
321 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
322 __pPlayButton->SetActionId(IDA_CONTORL_BUTTON_PLAY);
323 AddControl(__pPlayButton);
325 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
326 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
327 delete pNormalBackgroundBitmap;
329 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
330 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
331 delete pPressedBackgroundBitmap;
333 __pPlayButton->AddActionEventListener(*this);
334 __pPlayButton->SetShowState(false);
337 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
338 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
339 __pFooter->SetBackButton();
341 FooterItem footerItem1;
342 footerItem1.Construct(IDA_FOOTER_BUTTON_SHARE);
343 Bitmap* pFooterItemShareNomal =
344 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
345 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
347 FooterItem footerItem2;
348 footerItem2.Construct(IDA_FOOTER_BUTTON_DELETE);
349 Bitmap* pFooterItemDeleteNomal =
350 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
351 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
353 __pFooter->AddItem(footerItem1);
354 __pFooter->AddItem(footerItem2);
356 delete pFooterItemShareNomal;
357 delete pFooterItemDeleteNomal;
359 ButtonItem buttonItemMore;
360 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
361 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
362 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
363 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
364 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
365 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
367 else if (status == APPCONTROL_MODE_WEB_LINK)
369 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
370 __pFooter->SetBackButton();
372 FooterItem footerItem1;
373 footerItem1.Construct(IDA_FOOTER_BUTTON_SHARE);
374 Bitmap* pFooterItemShareNomal =
375 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
376 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
378 FooterItem footerItem2;
379 footerItem2.Construct(IDA_FOOTER_BUTTON_DOWNLOAD);
380 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
381 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
383 __pFooter->AddItem(footerItem1);
384 __pFooter->AddItem(footerItem2);
386 delete pFooterItemShareNomal;
387 delete pFooterItemDownlordNomal;
389 ButtonItem buttonItemMore;
390 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
391 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
392 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
393 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
394 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
395 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
397 __pFooter->AddItem(footerItem1);
398 __pFooter->AddItem(footerItem2);
400 else if (status == APPCONTROL_MODE_CROP)
402 FooterItem footerItem1;
403 footerItem1.Construct(IDA_FOOTER_BUTTON_SAVE);
404 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
405 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
407 FooterItem footerItem2;
408 footerItem2.Construct(IDA_FOOTER_BUTTON_BACK);
409 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
410 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
412 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
413 __pFooter->AddItem(footerItem1);
414 __pFooter->AddItem(footerItem2);
419 else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
421 __pPlayButton = new (std::nothrow) Button();
422 if (__pPlayButton != null)
424 Rectangle clientRect = GetClientAreaBounds();
426 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
427 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
428 __pPlayButton->SetActionId(IDA_CONTORL_BUTTON_PLAY);
429 AddControl(__pPlayButton);
431 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
432 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
433 delete pNormalBackgroundBitmap;
435 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
436 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
437 delete pPressedBackgroundBitmap;
439 __pPlayButton->AddActionEventListener(*this);
440 __pPlayButton->SetShowState(false);
443 __pFooter->SetBackButton();
446 String filePath = __pPresentationModel->GetFilePathAt(0);
447 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
448 if (contentType == CONTENT_TYPE_VIDEO)
450 __pPlayButton->SetShowState(true);
452 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
456 ImageViewerForm::GetLabelText(int index, String &page)
458 AppLogDebug("ENTER");
459 int allCount = __pPresentationModel->GetFileCount();
460 String pStr = __pPresentationModel->GetFilePathAt(index);
461 page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
462 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
466 ImageViewerForm::DeleteImageFile()
468 AppLogDebug("ENTER");
469 int currentIndex = __pGallery->GetCurrentItemIndex();
470 int shuffleValue = 0;
472 String strItemText(EMPTY_SPACE);
473 String strItemIdxText(EMPTY_SPACE);
474 int countPath = __pPresentationModel->GetFileCount();
475 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
477 if (filePath.GetLength() == 0)
479 UiApp* pApp = UiApp::GetInstance();
481 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
486 result r = File::Remove(filePath);
489 MessageBox messageBox;
490 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
491 MSGBOX_STYLE_NONE, 3000);
493 messageBox.ShowAndWait(modalResult);
494 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
499 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
500 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
502 ContentManager::ScanFile(filePath);
505 __pPresentationModel->DeleteFilePathAt(currentIndex);
508 UiApp* pApp = UiApp::GetInstance();
510 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
514 else if ((countPath - 1) == currentIndex)
516 __pGallery->SetCurrentItemIndex(--currentIndex);
519 if (__pPresentationModel->GetFileCount() > 1)
521 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
522 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
524 if(shuffleValue != 0)
526 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
527 if(__pShuffledList != null)
529 delete __pShuffledList;
530 __pShuffledList = null;
532 CreateShuffledList(__pPresentationModel->GetFileCount());
534 __pGallery->UpdateGallery();
535 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
536 __pPresentationModel->RequestImage(filePath);
538 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
540 __pLabel->SetText(strItemIdxText);
542 if (__isVisible == true)
544 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
546 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
548 __pPlayButton->SetShowState(false);
552 __pPlayButton->SetShowState(true);
556 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
562 ImageViewerForm::CallVideoPlayer(void)
564 AppLogDebug("ENTER");
565 int index = __pGallery->GetCurrentItemIndex();
566 String filePath = __pPresentationModel->GetFilePathAt(index);
567 filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
569 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
570 new (std::nothrow) String(filePath), new (std::nothrow) String(APPCONTROL_MIME_VIDEO_ALL), null, this);
571 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
575 ImageViewerForm::CreateGallery(void)
577 AppLogDebug("ENTER");
578 Rectangle clientRect = GetClientAreaBounds();
579 Rectangle rect = GetBounds();
581 __pGallery = static_cast<Gallery*>(GetControl(L"IDC_GALLERY"));
582 AppAssert(__pGallery);
584 __pGallery->SetItemProvider(*this);
585 __pGallery->AddGalleryEventListener(*this);
586 __pGallery->SetBackgroundColor(COLOR_GALLERY_BG);
588 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
592 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
593 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
595 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
596 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
598 case SLIDE_SHOW_TRANSITION_EFFECT_PAGE:
599 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_PAGE);
603 __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
605 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
609 ImageViewerForm::InitializePanelDetail()
611 AppLogDebug("ENTER");
612 __pScrollPanel = new (std::nothrow) ScrollPanel();
614 String arrayId[DETAIL_COUNT_MAX] =
616 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
617 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
618 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
621 if (__pScrollPanel == null)
623 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
625 return E_INVALID_STATE;
628 Rectangle clientRect = GetClientAreaBounds();
629 result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height - __pLabel->GetHeight()));
632 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
634 return E_INVALID_STATE;
637 __pDetail_Label = new (std::nothrow) Label();
638 __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
639 __pScrollPanel->AddControl(__pDetail_Label);
640 __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
641 __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
642 __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
643 __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
645 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
647 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
648 __pDetail_FileInfo_Label[i]->Construct(
649 Rectangle(X_DETAIL_FILEINFO_LABEL,
650 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
651 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
652 __pScrollPanel->AddControl(__pDetail_FileInfo_Label[i]);
654 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
655 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
656 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
657 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
659 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
661 if (i == DETAIL_COUNT_MAX - 1)
663 __pDetail_FileInfo_Value_Label[i]->Construct(
664 Rectangle(X_DETAIL_FILEINFO_LABEL,
665 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
666 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
670 __pDetail_FileInfo_Value_Label[i]->Construct(
671 Rectangle(X_DETAIL_FILEINFO_LABEL,
672 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
673 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
676 __pScrollPanel->AddControl(__pDetail_FileInfo_Value_Label[i]);
678 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
679 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
680 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
681 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
684 __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTROL_PANEL);
685 __pScrollPanel->SetShowState(false);
687 __pRenameButton = new (std::nothrow) Button();
688 Rectangle rect = GetBounds();
689 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
690 __pRenameButton->SetActionId(IDA_PANEL_HEADER_DETAILS_RENAME);
691 __pRenameButton->AddActionEventListener(*this);
693 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
694 Bitmap* pIconBackground =
695 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
696 Bitmap* pIconPressed =
697 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
699 if (pIcon != null && pIconPressed != null && pIconBackground != null)
701 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
702 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
703 Point iconPosition(0, 0);
704 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
705 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
709 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
710 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
714 delete pIconBackground;
716 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
717 __pScrollPanel->AddControl(__pRenameButton);
720 AddControl(__pScrollPanel);
721 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
727 ImageViewerForm::InitializePopup(void)
729 AppLogDebug("ENTER");
730 if (__pDeletePopup == null)
732 __pDeletePopup = new (std::nothrow) Popup();
733 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
735 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
737 Label* pLabel = new (std::nothrow) Label();
738 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
739 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
740 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
741 pLabel->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
743 Button* pDeleteButton = new (std::nothrow) Button();
744 pDeleteButton->Construct(
745 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
746 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
747 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
748 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
749 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
750 pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
751 pDeleteButton->AddActionEventListener(*this);
753 Button* pCancelButton = new (std::nothrow) Button();
754 pCancelButton->Construct(
755 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
756 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
757 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
758 pCancelButton->SetActionId(IDA_DELETE_POPUP_CANCEL);
759 pCancelButton->AddActionEventListener(*this);
761 __pDeletePopup->AddControl(pLabel);
762 __pDeletePopup->AddControl(pDeleteButton);
763 __pDeletePopup->AddControl(pCancelButton);
767 __pDeletePopup->SetShowState(true);
768 __pDeletePopup->Show();
770 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
776 ImageViewerForm::InitializeContextMenuMore(void)
778 AppLogDebug("ENTER");
779 result r = E_SUCCESS;
780 int currentIndex = __pGallery->GetCurrentItemIndex();
781 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
783 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
785 if (__pContextMenuMore != null)
787 delete __pContextMenuMore;
788 __pContextMenuMore = null;
791 __pContextMenuMore = new (std::nothrow) ContextMenu();
793 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().height),
794 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
796 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
798 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
799 IDA_CONTEXTMENU_SET_AS);
802 ImageFormat imageFormat = IMG_FORMAT_NONE;
805 imageFormat = img.GetImageFormat(filePath);
807 if (imageFormat == IMG_FORMAT_JPG || imageFormat == IMG_FORMAT_PNG || imageFormat == IMG_FORMAT_BMP)
809 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), IDA_FOOTER_BUTTON_CROP);
810 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"), IDA_FOOTER_BUTTON_ROTATE_RIGHT);
811 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"), IDA_FOOTER_BUTTON_ROTATE_LEFT);
815 if (__pGallery->GetItemCount() > 1)
817 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
818 IDA_FOOTER_BUTTON_SLIDE);
820 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
821 IDA_FOOTER_BUTTON_DETAILS);
822 __pContextMenuMore->SetShowState(false);
823 __pContextMenuMore->AddActionEventListener(*this);
824 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
830 ImageViewerForm::InitializeContextMenuSetAs(void)
832 AppLogDebug("ENTER");
834 if (__pContextMenuSetAs != null)
836 delete __pContextMenuSetAs;
837 __pContextMenuSetAs = null;
840 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
841 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
842 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
844 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
845 IDA_CONTEXTMENU_HOME);
846 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
847 IDA_CONTEXTMENU_LOCK);
848 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_HOME_AND_LOCK_SCREENS"),
849 IDA_CONTEXTMENU_HOME_AND_LOCK);
850 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
851 IDA_CONTEXTMENU_CALLER);
852 __pContextMenuSetAs->AddActionEventListener(*this);
853 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
859 ImageViewerForm::InitializeContextMenuShare(void)
861 AppLogDebug("ENTER");
862 if (__pContextMenuShare != null)
864 delete __pContextMenuShare;
865 __pContextMenuShare = null;
867 __pContextMenuShare = new (std::nothrow) ContextMenu();
868 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
869 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
870 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
872 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
873 IDA_CONTEXTMENU_MESSAGE);
874 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), IDA_CONTEXTMENU_EMAIL);
875 __pContextMenuShare->AddActionEventListener(*this);
876 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
882 ImageViewerForm::GetFileSize(String filePath) const
884 AppLogDebug("ENTER");
888 result r = File::GetAttributes(filePath, attr);
891 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
895 size = attr.GetFileSize();
896 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
902 ImageViewerForm::SetDetailInfo(void)
904 AppLogDebug("ENTER");
906 Rectangle clientRect = GetClientAreaBounds();
907 __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
908 int currentIndex = __pGallery->GetCurrentItemIndex();
909 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
911 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
913 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
915 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
916 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
919 result r = File::GetAttributes(strFilePath, attr);
922 long long nSize = attr.GetFileSize();
923 DateTime dateTime = attr.GetDateTime();
924 strResult[2] = dateTime.ToString();
926 if (nSize > SINGLE_GIGA_BYTE)
928 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
929 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
931 else if (nSize > SINGLE_MEGA_BYTE)
933 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
934 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
936 else if (nSize > SINGLE_KILO_BYTE)
938 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
939 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
943 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
944 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
949 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
950 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
953 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
954 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
955 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
956 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
957 strResult[8] = strFilePath;
958 String fileName = File::GetFileName(strFilePath);
959 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
961 if (strResult[8].StartsWith(Tizen::System::Environment::GetMediaPath(), 0) == true)
963 strResult[8].Replace(Tizen::System::Environment::GetMediaPath(), MEDIA_ROOT_PHONE, 0);
966 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
968 strResult[0] = __downloadFileName;
970 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
972 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
974 if (pImgMeta != null)
976 ImageContentInfo imageContentInfo;
977 r = imageContentInfo.Construct(&strFilePath);
980 strResult[1] = imageContentInfo.GetMediaFormat();
981 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
982 pImgMeta->GetHeight());
984 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
986 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
989 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
991 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
992 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
998 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1000 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
1001 if (pVideoMeta != null)
1003 VideoContentInfo videoContentInfo;
1004 r = videoContentInfo.Construct(&strFilePath);
1007 strResult[1] = videoContentInfo.GetMediaFormat();
1008 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
1009 pVideoMeta->GetHeight());
1010 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
1012 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
1018 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
1020 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
1022 if (i == DETAIL_COUNT_MAX - 1)
1024 __pDetail_FileInfo_Value_Label[i]->SetBounds(
1025 Rectangle(X_DETAIL_FILEINFO_LABEL,
1026 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
1027 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3));
1031 __pDetail_FileInfo_Value_Label[i]->SetBounds(
1032 Rectangle(X_DETAIL_FILEINFO_LABEL,
1033 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
1034 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL));
1037 __pDetail_FileInfo_Value_Label[i]->Invalidate(true);
1040 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1042 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1046 Rectangle rect = GetBounds();
1047 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
1049 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1055 ImageViewerForm::ShowPanelDetail(bool showStatus)
1057 AppLogDebug("ENTER");
1061 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTROL_PANEL);
1062 __pLabel->Invalidate(true);
1063 __pScrollPanel->SetShowState(true);
1068 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTROL_LABEL);
1069 __pLabel->Invalidate(true);
1070 __pScrollPanel->SetShowState(false);
1073 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1079 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1081 AppLogDebug("ENTER");
1082 FooterItem footerItem;
1083 footerItem.Construct(IDA_FOOTER_BUTTON_DETAILS);
1084 Bitmap* pfooterItem = null;
1088 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1089 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1093 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1094 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1097 pFooter->SetItemAt(position, footerItem);
1098 pFooter->Invalidate(true);
1101 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1107 ImageViewerForm::DownloadFile(void)
1109 AppLogDebug("ENTER");
1110 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1111 if (File::IsFileExist(DestPath) == false)
1113 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1117 ContentId contentId;
1118 ContentManager contentManager;
1119 contentManager.Construct();
1121 ImageContentInfo imageContentInfo;
1122 imageContentInfo.Construct(null);
1124 imageContentInfo.SetKeyword(L"platform, tizen");
1125 String sourcePath = DestPath;
1126 String destPath = Environment::GetMediaPath();
1127 destPath.Append(FOLDER_PATH_DOWNLOADS);
1128 destPath.Append(__downloadFileName);
1130 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1131 ImageViewerForm::OnFormBackRequested(*this);
1132 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1136 ImageViewerForm::GetItemCount(void)
1138 AppLogDebug("ENTER");
1139 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1141 return __pPresentationModel->GetFileCount();
1145 ImageViewerForm::CreateItem(int index)
1147 AppLogDebug("ENTER : index(%d)", index);
1148 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1150 int curIndex = index;
1152 if (__isShuffle == true && __pShuffledList != null)
1154 curIndex = __pShuffledList[index];
1157 String filePath = __pPresentationModel->GetFilePathAt(curIndex);
1158 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1159 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1161 if (pBitmap == null)
1163 pBitmap = GetQuickThumbnailN(filePath);
1165 if (pBitmap == null && __pGallery->IsSlideShowStarted() == true)
1167 pBitmap = __pPresentationModel->GetImage(filePath);
1168 __pPresentationModel->RequestImage(filePath);
1170 else if (pBitmap == null)
1172 pBitmap = new (std::nothrow) Bitmap();
1173 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1176 pGallery->Construct(*pBitmap, filePath);
1178 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1184 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1186 AppLogDebug("ImageViewerForm::DeleteItem ENTER index(%d)", index);
1187 int curIndex = index;
1189 if (__isShuffle == true && __pShuffledList != null)
1191 curIndex = __pShuffledList[index];
1194 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(curIndex);
1195 pImageInfo->ClearBitmap();
1197 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1203 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1205 AppLogDebug("ImageViewerForm::OnGalleryCurrentItemChanged index(%d)", index);
1207 String filePath = __pPresentationModel->GetFilePathAt(index);
1208 __pPresentationModel->RequestImage(filePath);
1210 String strItemIdxText;
1211 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1212 __pLabel->SetText(strItemIdxText);
1214 if (__isVisible == true)
1216 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1217 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1219 __pPlayButton->SetShowState(true);
1223 __pPlayButton->SetShowState(false);
1228 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1232 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1234 AppLogDebug("ENTER");
1236 String filePath = __pPresentationModel->GetFilePathAt(index);
1237 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1239 if (__isVisible == true)
1241 if (contentType == CONTENT_TYPE_VIDEO)
1243 __pPlayButton->SetShowState(false);
1246 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1247 __pLabel->SetShowState(false);
1248 __isVisible = false;
1252 if (contentType == CONTENT_TYPE_VIDEO)
1254 __pPlayButton->SetShowState(true);
1257 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1258 __pLabel->SetShowState(true);
1261 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1262 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1265 Rectangle clientRect = GetClientAreaBounds();
1266 Rectangle rect = GetBounds();
1267 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1269 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1273 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1275 AppLogDebug("ENTER");
1276 PowerManager::KeepScreenOnState(true, false);
1278 int index = __pGallery->GetCurrentItemIndex();
1279 String filePath = __pPresentationModel->GetFilePathAt(index);
1280 __pPresentationModel->RequestImage(filePath);
1282 if (__isVisible == true)
1284 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1285 __pLabel->SetShowState(false);
1287 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1288 if (contentType == CONTENT_TYPE_VIDEO)
1290 __pPlayButton->SetShowState(false);
1293 __isVisible = false;
1296 Rectangle clientRect = GetClientAreaBounds();
1297 Rectangle rect = GetBounds();
1298 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1300 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1304 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1306 AppLogDebug("ImageViewerForm::OnGallerySlideShowStopped");
1310 if (__isShuffle == true)
1312 if (__pShuffelTimer == null)
1314 __pShuffelTimer = new (std::nothrow) Timer();
1315 __pShuffelTimer->Construct(*this);
1317 __pShuffelTimer->Start(1);
1321 index = __pGallery->GetCurrentItemIndex();
1322 SlideShowStopped(index);
1325 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1329 ImageViewerForm::SlideShowStopped(int index)
1331 AppLog("ImageViewerForm::SlideShowStopped");
1332 PowerManager::KeepScreenOnState(false, true);
1334 if (__isVisible == false)
1336 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1337 __pLabel->SetShowState(true);
1338 String filePath = __pPresentationModel->GetFilePathAt(index);
1339 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1340 if (contentType == CONTENT_TYPE_VIDEO)
1342 __pPlayButton->SetShowState(true);
1345 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1346 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1351 String strItemIdxText;
1352 GetLabelText(index, strItemIdxText);
1353 __pLabel->SetText(strItemIdxText);
1356 Rectangle clientRect = GetClientAreaBounds();
1357 Rectangle rect = GetBounds();
1358 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1364 ImageViewerForm::OnUpdateContentList(void)
1369 ImageViewerForm::OnTerminating(void)
1371 AppLogDebug("ENTER");
1373 if (__pTimer != null)
1380 if (__pShuffelTimer)
1382 __pShuffelTimer->Cancel();
1383 delete __pShuffelTimer;
1384 __pShuffelTimer = null;
1387 __pPresentationModel->ClearImageRequests();
1388 __pPresentationModel->RemoveListener(*this);
1389 __pPresentationModel->RemoveFileUpdateListener(*this);
1391 if (__pContextMenuCopy != null)
1393 delete __pContextMenuCopy;
1394 __pContextMenuCopy = null;
1397 if (__pContextMenuSetAs != null)
1399 delete __pContextMenuSetAs;
1400 __pContextMenuSetAs = null;
1403 if (__pDeletePopup != null)
1405 delete __pDeletePopup;
1406 __pDeletePopup = null;
1409 if (__pContextMenuShare != null)
1411 delete __pContextMenuShare;
1412 __pContextMenuShare = null;
1415 if (__pContextMenuMore != null)
1417 delete __pContextMenuMore;
1418 __pContextMenuMore = null;
1421 if (__pShuffledList != null)
1423 free(__pShuffledList);
1424 __pShuffledList = null;
1427 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1433 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1435 AppLogDebug("ENTER actionId(%d)", actionId);
1436 SceneManager* pSceneManager = SceneManager::GetInstance();
1441 case IDA_FOOTER_MORE:
1443 InitializeContextMenuMore();
1445 __pContextMenuMore->SetShowState(true);
1446 __pContextMenuMore->Show();
1450 case IDA_CONTEXTMENU_SET_AS:
1452 InitializeContextMenuSetAs();
1453 __pContextMenuSetAs->SetShowState(true);
1454 __pContextMenuSetAs->Show();
1458 case IDA_FOOTER_BUTTON_SHARE:
1460 InitializeContextMenuShare();
1461 __pContextMenuShare->SetShowState(true);
1462 __pContextMenuShare->Show();
1466 case IDA_FOOTER_BUTTON_DELETE:
1468 __pDeletePopup->SetShowState(true);
1469 __pDeletePopup->Show();
1473 case IDA_FOOTER_BUTTON_SLIDE:
1475 if (__pPopUp != null)
1477 __pPopUp->SetShowState(true);
1483 case IDA_FOOTER_BUTTON_CROP:
1486 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1487 ImageBuffer imagebuffer;
1488 result r = imagebuffer.Construct(filePath);
1493 int imageWidth = imagebuffer.GetWidth();
1494 int imageHeight = imagebuffer.GetHeight();
1495 if (imageWidth <= (H_CROP_RECTANGLE * 5) || imageHeight <= (H_CROP_RECTANGLE * 5))
1497 MessageBox messageBox;
1498 String messageText = ResourceManager::GetString(L"IDS_IMGE_POP_IMAGE_IS_TOO_SMALL");
1499 messageBox.Construct(L"", messageText, MSGBOX_STYLE_OK, 3000);
1500 int modalResult = 0;
1501 messageBox.ShowAndWait(modalResult);
1505 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1506 pList->Add(new (std::nothrow) String(filePath));
1507 pList->Add(new (std::nothrow) String(APPCONTROL_DATA_AUTO));
1508 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1512 case IDA_FOOTER_BUTTON_ROTATE_RIGHT:
1514 int currentIndex = __pGallery->GetCurrentItemIndex();
1515 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1516 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1517 RotateImage(filePath, rotateMode);
1518 __pPresentationModel->RequestImage(filePath);
1519 ContentManager::ScanFile(filePath);
1523 case IDA_FOOTER_BUTTON_ROTATE_LEFT:
1525 int currentIndex = __pGallery->GetCurrentItemIndex();
1526 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1527 RotateMode rotateMode = ROTATE_MODE_LEFT;
1528 RotateImage(filePath, rotateMode);
1529 __pPresentationModel->RequestImage(filePath);
1530 ContentManager::ScanFile(filePath);
1534 case IDA_FOOTER_BUTTON_DETAILS:
1536 ShowPanelDetail(__isDetail);
1540 case IDA_FOOTER_BUTTON_BACK:
1542 ImageViewerForm::OnFormBackRequested(*this);
1546 case IDA_FOOTER_BUTTON_DOWNLOAD:
1552 case IDA_FOOTER_BUTTON_SAVE:
1555 case IDA_PANEL_HEADER_DETAILS_RENAME:
1557 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1558 pSelectedIndex->Construct();
1559 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1560 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1564 case IDA_CONTEXTMENU_HOME:
1566 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1567 ImageBuffer imageBuffer;
1568 result r = imageBuffer.Construct(filePath);
1572 MessageBox messageBox;
1573 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_UNSUPPORTED_FILE_TYPE"), MSGBOX_STYLE_NONE, 3000);
1574 int modalResult = 0;
1575 messageBox.ShowAndWait(modalResult);
1576 UiApp* pApp = UiApp::GetInstance();
1581 if (File::IsFileExist(filePath))
1583 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1584 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1585 pList->Add(new (std::nothrow) String(filePath));
1586 pList->Add(new (std::nothrow) String(cropMode));
1587 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1588 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1592 MessageBox messageBox;
1593 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE, 3000);
1594 int modalResult = 0;
1595 messageBox.ShowAndWait(modalResult);
1596 UiApp* pApp = UiApp::GetInstance();
1603 case IDA_CONTEXTMENU_LOCK:
1605 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1606 ImageBuffer imageBuffer;
1607 result r = imageBuffer.Construct(filePath);
1611 MessageBox messageBox;
1612 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_UNSUPPORTED_FILE_TYPE"), MSGBOX_STYLE_NONE, 3000);
1613 int modalResult = 0;
1614 messageBox.ShowAndWait(modalResult);
1615 UiApp* pApp = UiApp::GetInstance();
1620 if (File::IsFileExist(filePath))
1622 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1623 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1624 pList->Add(new (std::nothrow) String(filePath));
1625 pList->Add(new (std::nothrow) String(cropMode));
1626 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1627 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1632 MessageBox messageBox;
1633 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE, 3000);
1634 int modalResult = 0;
1635 messageBox.ShowAndWait(modalResult);
1636 UiApp* pApp = UiApp::GetInstance();
1643 case IDA_CONTEXTMENU_CALLER:
1646 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1647 ImageBuffer imagebuffer;
1648 result r = imagebuffer.Construct(filePath);
1651 MessageBox messageBox;
1652 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_UNSUPPORTED_FILE_TYPE"), MSGBOX_STYLE_NONE, 3000);
1653 int modalResult = 0;
1654 messageBox.ShowAndWait(modalResult);
1655 UiApp* pApp = UiApp::GetInstance();
1659 int imageWidth = imagebuffer.GetWidth();
1660 int imageHeight = imagebuffer.GetHeight();
1661 if (imageWidth <= (H_CROP_RECTANGLE * 5) || imageHeight <= (H_CROP_RECTANGLE * 5))
1663 MessageBox messageBox;
1664 String messageText = ResourceManager::GetString(L"IDS_IMGE_POP_IMAGE_IS_TOO_SMALL");
1665 messageBox.Construct(L"", messageText, MSGBOX_STYLE_OK, 3000);
1666 int modalResult = 0;
1667 messageBox.ShowAndWait(modalResult);
1670 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1671 pDataList->Construct();
1672 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1673 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1674 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1675 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1676 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1677 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1679 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1680 APPCONTROL_OPERATION_ID_SOCIAL_PICK, null, null, pDataList, this);
1684 case IDA_CONTEXTMENU_HOME_AND_LOCK:
1686 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1687 ImageBuffer imageBuffer;
1688 result r = imageBuffer.Construct(filePath);
1692 MessageBox messageBox;
1693 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_UNSUPPORTED_FILE_TYPE"), MSGBOX_STYLE_NONE, 3000);
1694 int modalResult = 0;
1695 messageBox.ShowAndWait(modalResult);
1696 UiApp* pApp = UiApp::GetInstance();
1701 if (File::IsFileExist(filePath))
1703 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1704 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1705 pList->Add(new (std::nothrow) String(filePath));
1706 pList->Add(new (std::nothrow) String(cropMode));
1707 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1708 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1712 MessageBox messageBox;
1713 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE, 3000);
1714 int modalResult = 0;
1715 messageBox.ShowAndWait(modalResult);
1716 UiApp* pApp = UiApp::GetInstance();
1723 case IDA_CONTEXTMENU_EMAIL:
1725 OnRequestEmailAction();
1729 case IDA_CONTEXTMENU_MESSAGE:
1731 OnRequestMessagesAction();
1735 case IDA_CONTEXTMENU_COPY:
1737 int currentIndex = __pGallery->GetCurrentItemIndex();
1738 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1741 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1742 Clipboard* pClipboard = Clipboard::GetInstance();
1743 pClipboard->CopyItem(item);
1747 case IDA_DELETE_POPUP_DEL:
1749 __pDeletePopup->SetShowState(false);
1750 __pDeletePopup->Show();
1753 if (__isDetail == false)
1755 ShowPanelDetail(false);
1760 case IDA_DELETE_POPUP_CANCEL:
1762 __pDeletePopup->SetShowState(false);
1763 __pDeletePopup->Show();
1767 case IDA_CONTORL_BUTTON_PLAY:
1776 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1780 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1782 result r = E_SUCCESS;
1783 ImageBuffer rotateBuffer;
1784 ImageBuffer* pRotatedBuffer = null;
1785 ImageFormat imageFormat;
1787 r = img.Construct();
1791 imageFormat = img.GetImageFormat(filePath);
1794 r = rotateBuffer.Construct(filePath);
1797 if (rotateMode == ROTATE_MODE_RIGHT)
1799 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
1803 pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
1807 if (pRotatedBuffer != null)
1809 r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
1810 delete pRotatedBuffer;
1816 ImageViewerForm::OnFormBackRequested(Form& source)
1818 AppLogDebug("ENTER");
1819 if (__isDetail == false)
1821 ShowPanelDetail(false);
1825 UiApp* pApp = UiApp::GetInstance();
1828 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1832 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1833 const SceneId& currentSceneId, IList* pArgs)
1835 AppLogDebug("ENTER");
1837 Rectangle clientRect = GetClientAreaBounds();
1838 Rectangle rect = GetBounds();
1840 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1841 __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight()));
1842 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1844 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1847 String strItemIdxText(EMPTY_SPACE);
1848 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1849 __pLabel->SetText(strItemIdxText);
1853 if (previousSceneId == IDSCN_IMAGE_CROP && pArgs != null)
1856 filePath = *(static_cast<String*>(pArgs->GetAt(0)));
1858 int count = __pPresentationModel->GetFileCount();
1859 __pPresentationModel->AddImageCache(filePath);
1860 __pGallery->UpdateGallery();
1861 __pGallery->SetCurrentItemIndex(count);
1862 __pPresentationModel->RequestImage(filePath);
1863 ShowPanelDetail(false);
1866 if (__pGallery->GetCurrentItemIndex() < 0)
1868 SetFooterItemState(false);
1872 SetFooterItemState(true);
1875 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1879 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1880 const SceneId& nextSceneId)
1882 AppLogDebug("ENTER");
1883 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1887 ImageViewerForm::OnImageDecodedN(const int index)
1889 AppLogDebug("ENTER");
1890 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1892 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1896 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1897 const String& operationId, AppCtrlResult appControlResult,
1898 const IMap* pExtraData)
1900 AppLogDebug("ENTER");
1902 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1903 && operationId == APPCONTROL_OPERATION_ID_SOCIAL_PICK
1904 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1906 const ArrayList* pResultList =
1907 static_cast<const ArrayList*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1908 const String* pContactId = null;
1910 if (pResultList != null)
1912 pContactId = static_cast<const String*>(pResultList->GetAt(0));
1915 long long lresult = 0;
1916 if (pContactId != null && pContactId->GetLength() > 0)
1918 LongLong::Parse(*pContactId, lresult);
1919 String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1920 String cropMode = APPCONTROL_DATA_FIT_TO_SCREEN;
1921 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1922 pList->Add(new (std::nothrow) String(filePath));
1923 pList->Add(new (std::nothrow) String(cropMode));
1924 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1925 pList->Add(new (std::nothrow) LongLong(lresult));
1926 SceneManager* pSceneManager = SceneManager::GetInstance();
1927 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1931 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1932 pImageViewerApp->SetFrameEnabled(true);
1933 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1937 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1939 AppLogDebug("ENTER");
1940 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1944 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1946 AppLogDebug("ENTER");
1947 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1951 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1953 AppLogDebug("ENTER");
1954 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1958 ImageViewerForm::OnOtherControlSelected(const Control& source)
1960 AppLogDebug("ENTER");
1961 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1965 ImageViewerForm::InitShowGallery(void)
1967 AppLogDebug("ENTER");
1968 if (__pGallery != null && __pGallery->IsVisible() == false)
1970 Canvas* pCanvas = GetCanvasN();
1971 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1973 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1979 __pGallery->SetShowState(true);
1982 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1986 ImageViewerForm::OnTimerExpired(Timer &timer)
1988 AppLog("ImageViewerForm::OnTimerExpired");
1990 if (timer.Equals(*__pShuffelTimer) == true)
1992 AppLog("OnTimerExpired __pShuffelTimer");
1993 int curItemIndex = __pGallery->GetCurrentItemIndex();
1994 int index = __pShuffledList[curItemIndex];
1996 __isShuffle = false;
1998 __pGallery->UpdateGallery();
2000 AppLog("ImageViewerForm::OnGallerySlideShowStopped index = %d, shuffelIndex = %d", curItemIndex, index);
2002 __pGallery->SetCurrentItemIndex(index);
2005 SlideShowStopped(index);
2009 int repeatValue = 0;
2010 int shuffleValue = 0;
2012 if (__pPresentationModel->GetFileCount() > 1)
2014 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2015 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2017 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2018 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
2020 if (shuffleValue != 0)
2022 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
2023 CreateShuffledList(__pPresentationModel->GetFileCount());
2028 __shuffelStartIndex = 0;
2029 __isShuffle = false;
2032 if ( repeatValue == 0)
2034 __pGallery->StartSlideShow(false);
2038 __pGallery->StartSlideShow(true);
2041 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2045 ImageViewerForm::CreateShuffledList(int count)
2047 AppLogDebug("ENTER");
2051 if (__pShuffledList == null)
2053 __pShuffledList = new (std::nothrow) int[count];
2054 for(int i = 0; i < count; ++i)
2056 __pShuffledList[i] = i;
2059 origIndex = __shuffelStartIndex;
2061 for(int i = count - 1; i > 0; --i)
2063 int randomNum = Math::Rand() % (i+1);
2064 int shuffleIndex = __pShuffledList[randomNum];
2065 __pShuffledList[randomNum] = __pShuffledList[i];
2066 __pShuffledList[i] = shuffleIndex;
2068 if(shuffleIndex == origIndex)
2074 if(origIndex != __pShuffledList[__shuffelStartIndex])
2076 int tempIndex = __pShuffledList[__shuffelStartIndex];
2077 __pShuffledList[__shuffelStartIndex] = origIndex;
2078 __pShuffledList[curPos] = tempIndex;
2081 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2085 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
2087 AppLogDebug("ENTER");
2088 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2092 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
2093 const String& errorMessage)
2095 AppLogDebug("ENTER");
2096 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2100 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
2101 result transferResult, const String& errorCode, const String& errorMessage)
2103 AppLogDebug("ENTER");
2104 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2108 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
2109 const String& errorCode, const String& errorMessage)
2111 AppLogDebug("ENTER");
2112 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2116 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
2117 const String& errorMessage)
2119 AppLogDebug("ENTER");
2120 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2124 ImageViewerForm::RequestDecodeUrl(void)
2126 AppLogDebug("ENTER");
2128 String filePath = __pPresentationModel->GetFilePathAt(0);
2130 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
2132 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2137 __downloadFileName = __pPresentationModel->GetFileName(filePath);
2139 Image* pImage = new (std::nothrow) Image();
2140 pImage->Construct();
2143 uri.SetUri(filePath);
2145 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
2148 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2152 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
2153 result r, const String errorCode, const String errorMessage)
2155 AppLogDebug("ENTER");
2156 Image* pImage = new (std::nothrow) Image();
2157 pImage->Construct();
2159 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
2160 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
2164 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
2165 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
2167 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
2169 __pPresentationModel->RequestImage(destPath);
2173 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
2177 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2181 ImageViewerForm::OnRequestEmailAction(void)
2183 AppLogDebug("ENTER");
2184 int currentIndex = __pGallery->GetCurrentItemIndex();
2186 if (__pPresentationModel->GetFileCount() <= 0)
2188 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2192 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2194 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2195 pDataList->Construct();
2197 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2198 pList->Add(new (std::nothrow) String(filePath));
2200 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
2202 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
2203 new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, this);
2204 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2208 ImageViewerForm::OnRequestMessagesAction(void)
2210 AppLogDebug("ENTER");
2211 int currentIndex = __pGallery->GetCurrentItemIndex();
2213 if (__pPresentationModel->GetFileCount() <= 0)
2215 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
2219 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2221 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2222 pDataList->Construct();
2223 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2224 pList->Add(new (std::nothrow) String(filePath));
2225 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
2226 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
2228 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES, APPCONTROL_OPERATION_ID_COMPOSE, null,
2229 null, pDataList, this);
2230 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2234 ImageViewerForm::SetFooterItemState(bool isEnable)
2236 AppLogDebug("ENTER");
2237 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
2239 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2240 __pFooter->SetItemEnabled(0, isEnable);
2241 __pFooter->SetItemEnabled(1, isEnable);
2243 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
2245 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
2246 __pFooter->SetItemEnabled(0, isEnable);
2247 __pFooter->SetItemEnabled(1, isEnable);
2249 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
2251 __pFooter->SetItemEnabled(0, isEnable);
2253 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2257 ImageViewerForm::GetQuickThumbnailN(String& filePath) const
2259 AppLogDebug("ENTER");
2260 Bitmap* pBitmap = null;
2262 if (filePath.GetLength() > 4)
2266 ContentSearch contentSearch;
2267 ContentSearchResult* pResultItem = null;
2268 IList* pContentInfoList = null;
2270 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
2271 result r = contentSearch.Construct(contentType);
2272 AppLogDebug("r(%s)", GetErrorMessage(r));
2275 pBitmap = new (std::nothrow) Bitmap();
2276 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
2287 queryString = CONTENT_QUERY_PREFIX_FILENAME;
2288 queryString.Append(L"'");
2289 queryString.Append(__pPresentationModel->GetFileName(filePath));
2290 queryString.Append(L"'");
2292 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
2293 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
2295 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
2297 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
2298 while (pEnum->MoveNext() == E_SUCCESS)
2300 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
2301 if (pResultItem == null)
2306 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
2308 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
2314 if (pContentInfoList != null)
2316 delete pContentInfoList;
2319 if (pBitmap != null)
2321 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2323 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2325 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
2326 result r = imageBuffer->Construct(filePath);
2329 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
2330 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
2332 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
2333 pBitmap->Scale(srcDim);
2337 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
2338 pBitmap->Scale(srcDim);
2344 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
2346 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
2348 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
2350 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
2351 pBitmap->Scale(srcDim);
2359 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
2360 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_BLACK), DUMMY_IMAGE_RECTANGLE);
2361 pBitmap = new (std::nothrow) Bitmap();
2362 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2365 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2369 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2371 AppLogDebug(" ENTER");
2373 int currentIndex = __pGallery->GetCurrentItemIndex();
2374 int fileCount = __pPresentationModel->GetFileCount();
2376 if (fileCount == 0 && eventId == IV_FILE_DELETE)
2378 UiApp* pApp = UiApp::GetInstance();
2380 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2383 if (fileCount <= currentIndex && eventId == IV_FILE_DELETE)
2385 currentIndex = fileCount - 1;
2387 else if (eventId == IV_FILE_CREATE)
2389 currentIndex = index;
2392 String strItemIdxText(EMPTY_SPACE);
2393 __pGallery->SetCurrentItemIndex(currentIndex);
2394 __pGallery->UpdateGallery();
2395 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2396 __pPresentationModel->RequestImage(filePath);
2398 GetLabelText(currentIndex,strItemIdxText);
2399 __pLabel->SetText(strItemIdxText);
2401 if (__isVisible == true)
2403 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2405 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2407 __pPlayButton->SetShowState(false);
2411 __pPlayButton->SetShowState(true);
2414 if (__isDetail == false)
2416 __pScrollPanel->SetShowState(false);
2421 AppLogDebug("EXIT");
2425 ImageViewerForm::OnSlideSettingPopUpItemSelected(int index)
2427 if ( __pPopUp != NULL)
2429 __pPopUp->SetShowState(false);
2434 int repeatValue = 0;
2436 int transitioneffect = 0;
2438 if (__pPresentationModel->GetFileCount() > 1)
2441 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2442 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, interval);
2444 interval = interval * 1000;
2445 __pGallery->SetSlideShowViewDuration(interval);
2446 __pGallery->UpdateGallery();
2448 if (__isDetail == false)
2450 ShowPanelDetail(false);
2453 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2454 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2456 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2457 ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
2459 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2460 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, transitioneffect);
2462 if (transitioneffect == 1)
2464 __pGallery->SetSlideShowAnimation(GALLERY_ANIMATION_DISSOLVE);
2466 else if (transitioneffect == 2)
2468 __pGallery->SetSlideShowAnimation(GALLERY_ANIMATION_ZOOM);
2472 __pGallery->SetSlideShowAnimation(GALLERY_ANIMATION_PAGE);
2475 if (shuffleValue != 0)
2477 __shuffelStartIndex = __pGallery->GetCurrentItemIndex();
2478 CreateShuffledList(__pPresentationModel->GetFileCount());
2483 __shuffelStartIndex = 0;
2484 __isShuffle = false;
2487 if (repeatValue == 0)
2489 __pGallery->StartSlideShow(false);
2493 __pGallery->StartSlideShow(true);
2497 else if (index == 1)
2499 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY,
2500 APPCONTROL_OPERATION_ID_CONFIGURE, null, null, null, this);