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 : __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
100 , __pScrollPanel(null)
101 , __pDetail_Label(null)
102 , __pLabelMessage(null)
103 , __pPlayButton(null)
104 , __pRenameButton(null)
105 , __pDetailFooterItem(null)
108 , __pContextMenuMore(null)
109 , __pContextMenuCopy(null)
110 , __pContextMenuSetAs(null)
111 , __pContextMenuShare(null)
112 , __pDeletePopup(null)
115 , __startSlide(false)
117 , __pPresentationModel(null)
119 AppLogDebug("ENTER");
120 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
123 ImageViewerForm::~ImageViewerForm(void)
125 AppLogDebug("ENTER");
126 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
130 ImageViewerForm::Initialize()
132 AppLogDebug("ENTER");
134 result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
136 __pPresentationModel = ImageViewerPresentationModel::GetInstance();
138 if (__pPresentationModel->GetFileCount() > 0)
140 if (__pPresentationModel->GetType() == APPCONTROL_DATA_SLIDE_SHOW)
146 __pPresentationModel->AddFileUpdateListener(this);
148 __pSettingPresentationModel = SettingPresentationModel::GetInstance();
150 int startIndex = __pPresentationModel->GetStartIndex();
151 String filePath = __pPresentationModel->GetFilePathAt(startIndex);
153 if (filePath.StartsWith(WEB_URL_HTTP, 0) == true)
155 __initializeDisplayModeCurrent = APPCONTROL_MODE_WEB_LINK;
157 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_MESSAGE)
159 __initializeDisplayModeCurrent = APPCONTROL_MODE_MESSAGE;
161 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_EMAIL)
163 __initializeDisplayModeCurrent = APPCONTROL_MODE_EMAIL;
167 __initializeDisplayModeCurrent = APPCONTROL_MODE_NORMAL;
170 if (filePath == EMPTY_SPACE)
172 MessageBox messageBox;
173 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE,
176 messageBox.ShowAndWait(modalResult);
178 UiApp* pApp = UiApp::GetInstance();
182 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
188 ImageViewerForm::OnInitializing(void)
190 AppLogDebug("ENTER");
191 result r = E_SUCCESS;
192 SetFormBackEventListener(this);
193 __pPresentationModel->AddListener(this);
195 __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL_INFO"));
201 __pLabel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
202 SetControlAlwaysOnTop(*__pLabel,true);
203 int allCount = __pPresentationModel->GetFileCount();
206 displayText.Append(index);
207 displayText.Append("/");
208 displayText.Append(allCount);
210 __pLabel->SetText(displayText);
213 InitializeDisplay(__initializeDisplayModeCurrent);
214 InitializePanelDetail();
217 __pPopUp = new (std::nothrow) SlideShowPopUp();
219 if (__pPopUp != null)
221 __pPopUp->Initialize();
222 __pPopUp->SetEventListner(this);
223 AddControl(*__pPopUp);
227 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
228 || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
229 || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
231 int index = __pPresentationModel->GetStartIndex();
232 __pGallery->UpdateGallery();
233 __pGallery->SetCurrentItemIndex(index);
236 String filePath = __pPresentationModel->GetFilePathAt(index);
237 __pPresentationModel->RequestImage(filePath);
239 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
246 __pTimer = new (std::nothrow) Timer();
247 __pTimer->Construct(*this);
251 AddOrientationEventListener(*this);
252 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
258 ImageViewerForm::OnInitialized(void)
260 AppLogDebug("ENTER");
261 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
267 ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
269 AppLogDebug("ENTER");
270 if (__detail == false)
272 ShowPanelDetail(true);
276 ShowPanelDetail(false);
279 Rectangle clientRect = GetClientAreaBounds();
280 Rectangle rect = GetBounds();
282 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
283 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
284 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
287 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
291 ImageViewerForm::InitializeDisplay(AppControlMode status)
293 AppLogDebug("ENTER");
295 String strItemIdxText;
297 __pFooter = GetFooter();
298 __pFooter->AddActionEventListener(*this);
299 __pFooter->RemoveAllItems();
301 GetLabelText(0, strItemIdxText);
302 Rectangle rect = GetClientAreaBounds();
305 if (status == APPCONTROL_MODE_NORMAL)
307 __pPlayButton = new (std::nothrow) Button();
308 if (__pPlayButton != null)
310 Rectangle clientRect = GetClientAreaBounds();
312 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
313 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
314 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
315 AddControl(*__pPlayButton);
317 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
318 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
319 delete pNormalBackgroundBitmap;
321 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
322 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
323 delete pPressedBackgroundBitmap;
325 __pPlayButton->AddActionEventListener(*this);
326 __pPlayButton->SetShowState(false);
329 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
330 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
331 __pFooter->SetBackButton();
333 FooterItem footerItem1;
334 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
335 Bitmap* pFooterItemShareNomal =
336 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
337 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
339 FooterItem footerItem2;
340 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DELETE);
341 Bitmap* pFooterItemDeleteNomal =
342 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
343 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
345 __pFooter->AddItem(footerItem1);
346 __pFooter->AddItem(footerItem2);
348 delete pFooterItemShareNomal;
349 delete pFooterItemDeleteNomal;
351 ButtonItem buttonItemMore;
352 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
353 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
354 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
355 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
356 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
357 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
359 else if (status == APPCONTROL_MODE_WEB_LINK)
361 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
362 __pFooter->SetBackButton();
364 FooterItem footerItem1;
365 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
366 Bitmap* pFooterItemShareNomal =
367 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
368 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
370 FooterItem footerItem2;
371 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DOWNLOAD);
372 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
373 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
375 __pFooter->AddItem(footerItem1);
376 __pFooter->AddItem(footerItem2);
378 delete pFooterItemShareNomal;
379 delete pFooterItemDownlordNomal;
381 ButtonItem buttonItemMore;
382 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
383 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
384 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
385 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
386 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
387 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
389 __pFooter->AddItem(footerItem1);
390 __pFooter->AddItem(footerItem2);
392 else if (status == APPCONTROL_MODE_CROP)
394 FooterItem footerItem1;
395 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SAVE);
396 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
397 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
399 FooterItem footerItem2;
400 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_BACK);
401 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
402 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
404 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
405 __pFooter->AddItem(footerItem1);
406 __pFooter->AddItem(footerItem2);
411 else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
413 __pPlayButton = new (std::nothrow) Button();
414 if (__pPlayButton != null)
416 Rectangle clientRect = GetClientAreaBounds();
418 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
419 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
420 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
421 AddControl(*__pPlayButton);
423 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
424 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
425 delete pNormalBackgroundBitmap;
427 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
428 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
429 delete pPressedBackgroundBitmap;
431 __pPlayButton->AddActionEventListener(*this);
432 __pPlayButton->SetShowState(false);
435 __pFooter->SetBackButton();
438 String filePath = __pPresentationModel->GetFilePathAt(0);
439 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
440 if (contentType == CONTENT_TYPE_VIDEO)
442 __pPlayButton->SetShowState(true);
444 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
448 ImageViewerForm::GetLabelText(int index, String &page)
450 AppLogDebug("ENTER");
451 int allCount = __pPresentationModel->GetFileCount();
452 String pStr = __pPresentationModel->GetFilePathAt(index);
453 page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
454 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
458 ImageViewerForm::DeleteImageFile()
460 AppLogDebug("ENTER");
461 int currentIndex = __pGallery->GetCurrentItemIndex();
463 String strItemText(EMPTY_SPACE);
464 String strItemIdxText(EMPTY_SPACE);
465 int countPath = __pPresentationModel->GetFileCount();
466 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
468 if (filePath.GetLength() == 0)
470 UiApp* pApp = UiApp::GetInstance();
472 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
477 result r = File::Remove(filePath);
480 MessageBox messageBox;
481 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
482 MSGBOX_STYLE_NONE, 3000);
484 messageBox.ShowAndWait(modalResult);
485 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
490 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
491 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
493 ContentManager::ScanFile(filePath);
496 __pPresentationModel->DeleteFilePathAt(currentIndex);
499 UiApp* pApp = UiApp::GetInstance();
501 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
505 else if ((countPath - 1) == currentIndex)
507 __pGallery->SetCurrentItemIndex(--currentIndex);
510 __pGallery->UpdateGallery();
511 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
512 __pPresentationModel->RequestImage(filePath);
514 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
516 if (__visible == true)
518 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
520 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
522 __pPlayButton->SetShowState(false);
526 __pPlayButton->SetShowState(true);
530 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
536 ImageViewerForm::CallVideoPlayer(void)
538 AppLogDebug("ENTER");
539 int index = __pGallery->GetCurrentItemIndex();
540 String filePath = __pPresentationModel->GetFilePathAt(index);
541 filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
543 AppLogDebug("ENTER(%ls)", filePath.GetPointer());
545 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
546 &filePath, null, this);
547 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
551 ImageViewerForm::CreateGallery(void)
553 AppLogDebug("ENTER");
554 Rectangle clientRect = GetClientAreaBounds();
555 Rectangle rect = GetBounds();
557 __pGallery = new (std::nothrow) Gallery();
558 __pGallery->Construct(Rectangle(0, clientRect.y, rect.width, rect.height));
559 __pGallery->SetName(L"GalleryControl");
560 __pGallery->SetItemProvider(*this);
561 __pGallery->AddGalleryEventListener(*this);
562 __pGallery->SetBackgroundColor(COLOR_GALLERY_BG);
563 AddControl(*__pGallery);
564 __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
566 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
570 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
571 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
573 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
574 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
576 case SLIDE_SHOW_TRANSITION_EFFECT_SLIDE:
580 __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
582 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
586 ImageViewerForm::InitializePanelDetail()
588 AppLogDebug("ENTER");
589 __pScrollPanel = new (std::nothrow) ScrollPanel();
591 String arrayId[DETAIL_COUNT_MAX] =
593 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
594 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
595 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
598 if (__pScrollPanel == null)
600 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
602 return E_INVALID_STATE;
605 Rectangle clientRect = GetClientAreaBounds();
606 result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height - __pLabel->GetHeight()));
609 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
611 return E_INVALID_STATE;
614 __pDetail_Label = new (std::nothrow) Label();
615 __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
616 __pScrollPanel->AddControl(*__pDetail_Label);
617 __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
618 __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
619 __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
620 __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
622 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
624 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
625 __pDetail_FileInfo_Label[i]->Construct(
626 Rectangle(X_DETAIL_FILEINFO_LABEL,
627 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
628 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
629 __pScrollPanel->AddControl(*__pDetail_FileInfo_Label[i]);
631 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
632 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
633 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
634 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
636 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
638 if (i == DETAIL_COUNT_MAX - 1)
640 __pDetail_FileInfo_Value_Label[i]->Construct(
641 Rectangle(X_DETAIL_FILEINFO_LABEL,
642 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
643 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
647 __pDetail_FileInfo_Value_Label[i]->Construct(
648 Rectangle(X_DETAIL_FILEINFO_LABEL,
649 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
650 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
653 __pScrollPanel->AddControl(*__pDetail_FileInfo_Value_Label[i]);
655 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
656 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
657 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
658 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
661 __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
662 __pScrollPanel->SetShowState(false);
664 __pRenameButton = new (std::nothrow) Button();
665 Rectangle rect = GetBounds();
666 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
667 __pRenameButton->SetActionId(ACTION_ID_PANEL_HEADER_DETAILS_RENAME);
668 __pRenameButton->AddActionEventListener(*this);
670 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
671 Bitmap* pIconBackground =
672 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
673 Bitmap* pIconPressed =
674 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
676 if (pIcon != null && pIconPressed != null && pIconBackground != null)
678 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
679 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
680 Point iconPosition(0, 0);
681 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
682 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
686 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
687 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
691 delete pIconBackground;
693 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
694 __pScrollPanel->AddControl(*__pRenameButton);
697 AddControl(*__pScrollPanel);
698 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
704 ImageViewerForm::InitializePopup(void)
706 AppLogDebug("ENTER");
707 if (__pDeletePopup == null)
709 __pDeletePopup = new (std::nothrow) Popup();
710 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
712 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
714 Label* pLabel = new (std::nothrow) Label();
715 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
716 ResourceManager::GetString(L"IDS_COM_BODY_DELETE") + L"?");
718 Button* pDeleteButton = new (std::nothrow) Button();
719 pDeleteButton->Construct(
720 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
721 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
722 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
723 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
724 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
725 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
726 pDeleteButton->AddActionEventListener(*this);
728 Button* pCancelButton = new (std::nothrow) Button();
729 pCancelButton->Construct(
730 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
731 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
732 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
733 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
734 pCancelButton->AddActionEventListener(*this);
736 __pDeletePopup->AddControl(*pLabel);
737 __pDeletePopup->AddControl(*pDeleteButton);
738 __pDeletePopup->AddControl(*pCancelButton);
742 __pDeletePopup->SetShowState(true);
743 __pDeletePopup->Show();
745 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
751 ImageViewerForm::InitializeContextMenuMore(void)
753 AppLogDebug("ENTER");
754 int currentIndex = __pGallery->GetCurrentItemIndex();
755 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
757 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
759 if (__pContextMenuMore != null)
761 delete __pContextMenuMore;
762 __pContextMenuMore = null;
765 __pContextMenuMore = new (std::nothrow) ContextMenu();
767 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
768 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
770 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
772 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
773 ACTION_ID_CONTEXTMENU_SET_AS);
774 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), ACTION_ID_FOOTER_BUTTON_CROP);
777 if (__pGallery->GetItemCount() > 1)
779 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
780 ACTION_ID_FOOTER_BUTTON_SLIDE);
782 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
783 ACTION_ID_FOOTER_BUTTON_DETAILS);
784 __pContextMenuMore->SetShowState(false);
785 __pContextMenuMore->AddActionEventListener(*this);
786 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
792 ImageViewerForm::InitializeContextMenuSetAs(void)
794 AppLogDebug("ENTER");
796 if (__pContextMenuSetAs != null)
798 delete __pContextMenuSetAs;
799 __pContextMenuSetAs = null;
802 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
803 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
804 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
806 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
807 ACTION_ID_CONTEXTMENU_HOME);
808 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
809 ACTION_ID_CONTEXTMENU_LOCK);
810 __pContextMenuSetAs->AddItem(L"Home and lock screens", ACTION_ID_CONTEXTMENU_HOME_AND_LOCK);
811 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
812 ACTION_ID_CONTEXTMENU_CALLER);
813 __pContextMenuSetAs->AddActionEventListener(*this);
814 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
820 ImageViewerForm::InitializeContextMenuShare(void)
822 AppLogDebug("ENTER");
823 if (__pContextMenuShare != null)
825 delete __pContextMenuShare;
826 __pContextMenuShare = null;
828 __pContextMenuShare = new (std::nothrow) ContextMenu();
829 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
830 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
831 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
833 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
834 ACTION_ID_CONTEXTMENU_MESSAGE);
835 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
836 __pContextMenuShare->AddActionEventListener(*this);
837 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
843 ImageViewerForm::GetFileSize(String filePath)
845 AppLogDebug("ENTER");
849 result r = File::GetAttributes(filePath, attr);
852 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
856 size = attr.GetFileSize();
857 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
863 ImageViewerForm::SetDetailInfo(void)
865 AppLogDebug("ENTER");
867 Rectangle clientRect = GetClientAreaBounds();
868 __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
870 int currentIndex = __pGallery->GetCurrentItemIndex();
871 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
873 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
875 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
877 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
878 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
881 result r = File::GetAttributes(strFilePath, attr);
884 long long nSize = attr.GetFileSize();
885 DateTime dateTime = attr.GetDateTime();
886 strResult[2] = dateTime.ToString();
888 if (nSize > SINGLE_GIGA_BYTE)
890 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
891 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
893 else if (nSize > SINGLE_MEGA_BYTE)
895 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
896 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
898 else if (nSize > SINGLE_KILO_BYTE)
900 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
901 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
905 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
906 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
911 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
912 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
915 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
916 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
917 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
918 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
919 strResult[8] = strFilePath;
920 String fileName = File::GetFileName(strFilePath);
921 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
923 if (strResult[8].StartsWith(Tizen::System::Environment::GetMediaPath(), 0) == true)
925 strResult[8].Replace(Tizen::System::Environment::GetMediaPath(), MEDIA_ROOT_PHONE, 0);
928 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
930 strResult[0] = __downLordFileName;
932 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
934 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
936 if (pImgMeta != null)
938 ImageContentInfo imageContentInfo;
939 r = imageContentInfo.Construct(&strFilePath);
942 strResult[1] = imageContentInfo.GetMediaFormat();
943 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
944 pImgMeta->GetHeight());
946 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
948 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
951 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
953 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
954 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
960 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
962 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
963 if (pVideoMeta != null)
965 VideoContentInfo videoContentInfo;
966 r = videoContentInfo.Construct(&strFilePath);
969 strResult[1] = videoContentInfo.GetMediaFormat();
970 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
971 pVideoMeta->GetHeight());
972 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
974 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
980 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
982 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
983 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
986 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
988 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
992 Rectangle rect = GetBounds();
993 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
995 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1001 ImageViewerForm::ShowPanelDetail(bool showStatus)
1003 AppLogDebug("ENTER");
1007 __pScrollPanel->SetShowState(true);
1012 __pScrollPanel->SetShowState(false);
1015 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1021 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1023 AppLogDebug("ENTER");
1024 FooterItem footerItem;
1025 footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
1026 Bitmap* pfooterItem = null;
1030 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1031 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1035 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1036 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1039 pFooter->SetItemAt(position, footerItem);
1040 pFooter->Invalidate(true);
1043 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1049 ImageViewerForm::DownloadFile(void)
1051 AppLogDebug("ENTER");
1052 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1053 if (File::IsFileExist(DestPath) == false)
1055 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1059 ContentId contentId;
1060 ContentManager contentManager;
1061 contentManager.Construct();
1063 ImageContentInfo imageContentInfo;
1064 imageContentInfo.Construct(null);
1066 imageContentInfo.SetKeyword(L"platform, tizen");
1067 String sourcePath = DestPath;
1068 String destPath = Environment::GetMediaPath();
1069 destPath.Append(FOLDER_PATH_DOWNLOADS);
1070 destPath.Append(__downLordFileName);
1072 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1073 ImageViewerForm::OnFormBackRequested(*this);
1074 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1078 ImageViewerForm::GetItemCount(void)
1080 AppLogDebug("ENTER");
1081 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1083 return __pPresentationModel->GetFileCount();
1087 ImageViewerForm::CreateItem(int index)
1089 AppLogDebug("ENTER : index(%d)", index);
1090 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1092 String filePath = __pPresentationModel->GetFilePathAt(index);
1093 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1094 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1095 if (pBitmap == null)
1097 pBitmap = GetQuickThumbnailN(filePath);
1099 if (pBitmap == null)
1101 pBitmap = new (std::nothrow) Bitmap();
1102 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1105 pGallery->Construct(*pBitmap, filePath);
1107 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1113 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1115 AppLogDebug("ENTER index(%d)", index);
1116 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1117 pImageInfo->ClearBitmap();
1119 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1125 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1127 AppLogDebug("ENTER index(%d)", index);
1129 String filePath = __pPresentationModel->GetFilePathAt(index);
1130 AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1131 __pPresentationModel->RequestImage(filePath);
1133 String strItemIdxText;
1134 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1135 __pLabel->SetText(strItemIdxText);
1137 if (__visible == true)
1139 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1140 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1142 __pPlayButton->SetShowState(true);
1146 __pPlayButton->SetShowState(false);
1151 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1155 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1157 AppLogDebug("ENTER");
1159 String filePath = __pPresentationModel->GetFilePathAt(index);
1160 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1162 if (__visible == true)
1164 if (contentType == CONTENT_TYPE_VIDEO)
1166 __pPlayButton->SetShowState(false);
1169 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1170 __pLabel->SetShowState(false);
1175 if (contentType == CONTENT_TYPE_VIDEO)
1177 __pPlayButton->SetShowState(true);
1180 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1181 __pLabel->SetShowState(true);
1184 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1185 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1188 Rectangle clientRect = GetClientAreaBounds();
1189 Rectangle rect = GetBounds();
1190 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1192 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1196 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1198 AppLogDebug("ENTER");
1199 PowerManager::KeepScreenOnState(true, false);
1200 if (__visible == true)
1202 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1203 __pLabel->SetShowState(false);
1205 int index = __pGallery->GetCurrentItemIndex();
1206 String filePath = __pPresentationModel->GetFilePathAt(index);
1207 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1209 if (contentType == CONTENT_TYPE_VIDEO)
1211 __pPlayButton->SetShowState(false);
1217 Rectangle clientRect = GetClientAreaBounds();
1218 Rectangle rect = GetBounds();
1219 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1221 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1225 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1227 AppLogDebug("ENTER");
1228 PowerManager::KeepScreenOnState(false, true);
1229 int index = __pGallery->GetCurrentItemIndex();
1231 if (__visible == false)
1233 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1234 __pLabel->SetShowState(true);
1235 String filePath = __pPresentationModel->GetFilePathAt(index);
1236 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1237 if (contentType == CONTENT_TYPE_VIDEO)
1239 __pPlayButton->SetShowState(true);
1242 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1243 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1248 String strItemIdxText;
1249 GetLabelText(index, strItemIdxText);
1250 __pLabel->SetText(strItemIdxText);
1253 Rectangle clientRect = GetClientAreaBounds();
1254 Rectangle rect = GetBounds();
1255 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1258 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1262 ImageViewerForm::OnUpdateContentList(void)
1267 ImageViewerForm::OnTerminating(void)
1269 AppLogDebug("ENTER");
1271 if (__pTimer != null)
1278 __pPresentationModel->ClearImageRequests();
1279 __pPresentationModel->RemoveListener(*this);
1280 __pPresentationModel->RemoveFileUpdateListener(*this);
1282 if (__pContextMenuCopy != null)
1284 delete __pContextMenuCopy;
1285 __pContextMenuCopy = null;
1288 if (__pContextMenuSetAs != null)
1290 delete __pContextMenuSetAs;
1291 __pContextMenuSetAs = null;
1294 if (__pDeletePopup != null)
1296 delete __pDeletePopup;
1297 __pDeletePopup = null;
1300 if (__pContextMenuShare != null)
1302 delete __pContextMenuShare;
1303 __pContextMenuShare = null;
1306 if (__pContextMenuMore != null)
1308 delete __pContextMenuMore;
1309 __pContextMenuMore = null;
1312 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1318 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1320 AppLogDebug("ENTER actionId(%d)", actionId);
1321 SceneManager* pSceneManager = SceneManager::GetInstance();
1326 case ACTION_ID_FOOTER_MORE:
1328 InitializeContextMenuMore();
1330 __pContextMenuMore->SetShowState(true);
1331 __pContextMenuMore->Show();
1334 case ACTION_ID_CONTEXTMENU_SET_AS:
1335 InitializeContextMenuSetAs();
1337 __pContextMenuSetAs->SetShowState(true);
1338 __pContextMenuSetAs->Show();
1340 case ACTION_ID_FOOTER_BUTTON_SHARE:
1341 InitializeContextMenuShare();
1343 __pContextMenuShare->SetShowState(true);
1344 __pContextMenuShare->Show();
1346 case ACTION_ID_FOOTER_BUTTON_DELETE:
1347 __pDeletePopup->SetShowState(true);
1348 __pDeletePopup->Show();
1350 case ACTION_ID_FOOTER_BUTTON_SLIDE:
1352 if (__pPopUp != null)
1354 __pPopUp->SetShowState(true);
1360 case ACTION_ID_FOOTER_BUTTON_CROP:
1363 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1364 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1365 pList->Add(new (std::nothrow) String(filePath));
1366 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1369 case ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT:
1371 int currentIndex = __pGallery->GetCurrentItemIndex();
1372 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1373 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1374 __pPresentationModel->SetImageRotateStatus(true);
1375 RotateImage(filePath, rotateMode);
1376 __pPresentationModel->RequestImage(filePath);
1378 ContentManager contentManager;
1379 contentManager.Construct();
1380 contentManager.ScanFile(filePath);
1383 case ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT:
1385 int currentIndex = __pGallery->GetCurrentItemIndex();
1386 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1387 RotateMode rotateMode = ROTATE_MODE_LEFT;
1388 __pPresentationModel->SetImageRotateStatus(true);
1389 RotateImage(filePath, rotateMode);
1390 __pPresentationModel->RequestImage(filePath);
1392 ContentManager contentManager;
1393 contentManager.Construct();
1394 contentManager.ScanFile(filePath);
1397 case ACTION_ID_FOOTER_BUTTON_DETAILS:
1399 ShowPanelDetail(__detail);
1402 case ACTION_ID_FOOTER_BUTTON_BACK:
1403 ImageViewerForm::OnFormBackRequested(*this);
1405 case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1408 case ACTION_ID_FOOTER_BUTTON_SAVE:
1410 case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1412 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1413 pSelectedIndex->Construct();
1414 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1415 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1418 case ACTION_ID_CONTEXTMENU_HOME:
1420 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1421 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1422 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1423 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1424 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1427 case ACTION_ID_CONTEXTMENU_LOCK:
1429 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1430 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1431 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1432 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1433 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1436 case ACTION_ID_CONTEXTMENU_CALLER:
1438 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1439 pDataList->Construct();
1440 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1441 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1442 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1443 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1444 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1445 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1447 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1448 APPCONTROL_OPERATION_ID_PICK, null, pDataList, this);
1452 case ACTION_ID_CONTEXTMENU_HOME_AND_LOCK:
1454 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1455 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1456 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1457 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1458 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1463 case ACTION_ID_CONTEXTMENU_EMAIL:
1465 OnRequestEmailAction();
1468 case ACTION_ID_CONTEXTMENU_MESSAGE:
1470 OnRequestMessagesAction();
1473 case ACTION_ID_CONTEXTMENU_COPY:
1475 int currentIndex = __pGallery->GetCurrentItemIndex();
1476 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1479 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1480 Clipboard* pClipboard = Clipboard::GetInstance();
1481 pClipboard->CopyItem(item);
1484 case ACTION_ID_DELETE_POPUP_DEL:
1486 __pDeletePopup->SetShowState(false);
1487 __pDeletePopup->Show();
1490 if (__detail == false)
1492 ShowPanelDetail(false);
1496 case ACTION_ID_DELETE_POPUP_CANCEL:
1498 __pDeletePopup->SetShowState(false);
1499 __pDeletePopup->Show();
1502 case ACTION_ID_CONTORL_BUTTON_PLAY:
1508 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1512 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1514 result r = E_SUCCESS;
1515 ImageBuffer* pRotatedBuffer = null;
1516 ImageBuffer* pRotatedBuffer1 = null;
1517 ImageFormat imageFormat;
1520 pRotatedBuffer = new (std::nothrow) ImageBuffer();
1521 r = pRotatedBuffer->Construct(filePath);
1522 pRotatedBuffer->GetImageInfo(filePath, imageFormat, width, height);
1525 if (rotateMode == ROTATE_MODE_RIGHT)
1527 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_90);
1531 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_270);
1534 TryCatch(pRotatedBuffer1 != null, r = GetLastResult(), "RotateN failed:%s", GetErrorMessage(GetLastResult()));
1535 pRotatedBuffer1->EncodeToFile(filePath, imageFormat, true, 100);
1536 delete pRotatedBuffer1;
1537 delete pRotatedBuffer;
1541 if (pRotatedBuffer != null) //this buffer is no longer used
1543 delete pRotatedBuffer;
1545 if (pRotatedBuffer1 != null) //this buffer is no longer used
1547 delete pRotatedBuffer1;
1553 ImageViewerForm::OnFormBackRequested(Form& source)
1555 AppLogDebug("ENTER");
1556 if (__detail == false)
1558 ShowPanelDetail(false);
1562 UiApp* pApp = UiApp::GetInstance();
1565 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1569 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1570 const SceneId& currentSceneId, IList* pArgs)
1572 AppLogDebug("ENTER");
1574 Rectangle clientRect = GetClientAreaBounds();
1575 Rectangle rect = GetBounds();
1577 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1578 __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight()));
1579 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1581 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1584 String strItemIdxText(EMPTY_SPACE);
1585 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1586 __pLabel->SetText(strItemIdxText);
1590 if (__pGallery->GetCurrentItemIndex() < 0)
1592 SetFooterItemState(false);
1596 SetFooterItemState(true);
1599 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1603 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1604 const SceneId& nextSceneId)
1606 AppLogDebug("ENTER");
1607 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1611 ImageViewerForm::OnImageDecodedN(const int index)
1613 AppLogDebug("ENTER");
1614 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1616 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1620 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1621 const String& operationId, AppCtrlResult appControlResult,
1622 const IMap* pExtraData)
1624 AppLogDebug("ENTER");
1626 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1627 && operationId == APPCONTROL_OPERATION_ID_PICK
1628 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1630 const String* pContactId =
1631 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1632 SceneManager* pSceneManager = SceneManager::GetInstance();
1633 long long lresult = 0;
1634 if (pContactId != null && pContactId->GetLength() > 0)
1636 LongLong::Parse(*pContactId, lresult);
1638 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1639 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1640 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1641 pList->Add(new (std::nothrow) LongLong(lresult));
1642 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1643 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1646 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1647 pImageViewerApp->SetFrameEnabled(true);
1648 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1652 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1654 AppLogDebug("ENTER");
1655 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1659 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1661 AppLogDebug("ENTER");
1662 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1666 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1668 AppLogDebug("ENTER");
1669 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1673 ImageViewerForm::OnOtherControlSelected(const Control& source)
1675 AppLogDebug("ENTER");
1676 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1680 ImageViewerForm::InitShowGallery(void)
1682 AppLogDebug("ENTER");
1683 if (__pGallery != null && __pGallery->IsVisible() == false)
1685 Canvas* pCanvas = GetCanvasN();
1686 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1688 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1694 __pGallery->SetShowState(true);
1697 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1701 ImageViewerForm::OnTimerExpired(Timer &timer)
1703 int repeatValue = 0;
1704 AppLogDebug("ENTER");
1705 if (__pPresentationModel->GetFileCount() > 1)
1707 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1708 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1710 if (repeatValue == 0)
1712 __pGallery->StartSlideShow(false);
1716 __pGallery->StartSlideShow(true);
1719 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1723 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1725 AppLogDebug("ENTER");
1726 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1730 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1731 const String& errorMessage)
1733 AppLogDebug("ENTER");
1734 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1738 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1739 result transferResult, const String& errorCode, const String& errorMessage)
1741 AppLogDebug("ENTER");
1742 AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1743 AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1744 AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1745 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1749 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1750 const String& errorCode, const String& errorMessage)
1752 AppLogDebug("ENTER");
1753 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1757 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1758 const String& errorMessage)
1760 AppLogDebug("ENTER");
1761 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1765 ImageViewerForm::RequestDecodeUrl(void)
1767 AppLogDebug("ENTER");
1769 String filePath = __pPresentationModel->GetFilePathAt(0);
1771 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1773 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1778 __downLordFileName = __pPresentationModel->GetFileName(filePath);
1780 Image* pImage = new (std::nothrow) Image();
1781 pImage->Construct();
1784 uri.SetUri(filePath);
1786 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1789 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1793 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1794 result r, const String errorCode, const String errorMessage)
1796 AppLogDebug("ENTER");
1797 Image* pImage = new (std::nothrow) Image();
1798 pImage->Construct();
1800 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1801 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1805 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1806 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1808 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1810 __pPresentationModel->RequestImage(destPath);
1814 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1818 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1822 ImageViewerForm::OnRequestEmailAction(void)
1824 AppLogDebug("ENTER");
1825 int currentIndex = __pGallery->GetCurrentItemIndex();
1827 if (__pPresentationModel->GetFileCount() <= 0)
1829 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1833 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1835 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1836 pDataList->Construct();
1838 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1839 pList->Add(new (std::nothrow) String(filePath));
1841 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1843 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
1844 null, pDataList, this);
1845 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1849 ImageViewerForm::OnRequestMessagesAction(void)
1851 AppLogDebug("ENTER");
1852 int currentIndex = __pGallery->GetCurrentItemIndex();
1854 if (__pPresentationModel->GetFileCount() <= 0)
1856 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1860 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1862 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1863 pDataList->Construct();
1864 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE),
1865 new (std::nothrow) String(APPCONTROL_DATA_MMS));
1867 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1868 pList->Add(new (std::nothrow) String(filePath));
1870 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1872 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES,
1873 APPCONTROL_OPERATION_ID_COMPOSE, null, pDataList, this);
1874 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1878 ImageViewerForm::SetFooterItemState(bool isEnable)
1880 AppLogDebug("ENTER");
1881 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
1883 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1884 __pFooter->SetItemEnabled(0, isEnable);
1885 __pFooter->SetItemEnabled(1, isEnable);
1887 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1889 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1890 __pFooter->SetItemEnabled(0, isEnable);
1891 __pFooter->SetItemEnabled(1, isEnable);
1893 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
1895 __pFooter->SetItemEnabled(0, isEnable);
1897 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1901 ImageViewerForm::GetQuickThumbnailN(String& filePath)
1903 AppLogDebug("ENTER");
1904 Bitmap* pBitmap = null;
1906 if (filePath.GetLength() > 4)
1910 ContentSearch contentSearch;
1911 ContentSearchResult* pResultItem = null;
1912 IList* pContentInfoList = null;
1914 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1915 result r = contentSearch.Construct(contentType);
1916 AppLogDebug("r(%s)", GetErrorMessage(r));
1919 pBitmap = new (std::nothrow) Bitmap();
1920 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1931 queryString = CONTENT_QUERY_PREFIX_FILENAME;
1932 queryString.Append(L"'");
1933 queryString.Append(__pPresentationModel->GetFileName(filePath));
1934 queryString.Append(L"'");
1936 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
1937 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
1939 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
1941 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
1942 while (pEnum->MoveNext() == E_SUCCESS)
1944 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
1945 if (pResultItem == null)
1950 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
1952 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
1958 if (pContentInfoList != null)
1960 delete pContentInfoList;
1963 if (pBitmap != null)
1965 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1967 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1969 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
1970 result r = imageBuffer->Construct(filePath);
1973 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
1974 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
1976 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
1977 pBitmap->Scale(srcDim);
1981 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
1982 pBitmap->Scale(srcDim);
1988 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1990 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
1992 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
1994 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
1995 pBitmap->Scale(srcDim);
2003 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
2004 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
2005 pBitmap = new (std::nothrow) Bitmap();
2006 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2009 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2013 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2015 AppLogDebug(" ENTER");
2016 bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF);
2017 bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
2019 int currentIndex = __pGallery->GetCurrentItemIndex();
2020 int countPath = __pPresentationModel->GetFileCount();
2022 if (countPath == 0 && eventDelete)
2024 UiApp* pApp = UiApp::GetInstance();
2026 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2028 AppLogDebug(" countPath is %d", countPath);
2029 AppLogDebug(" currentIndex is %d", currentIndex);
2031 if (countPath == currentIndex && eventDelete)
2033 __pGallery->SetCurrentItemIndex(--currentIndex);
2037 currentIndex = index;
2038 __pGallery->SetCurrentItemIndex(currentIndex);
2041 String strItemIdxText(EMPTY_SPACE);
2043 __pGallery->UpdateGallery();
2044 AppLogDebug(" UpdateGallery is %d", currentIndex);
2045 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2046 __pPresentationModel->RequestImage(filePath);
2048 GetLabelText(currentIndex,strItemIdxText);
2049 __pLabel->SetText(strItemIdxText);
2051 if (__visible == true)
2053 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2055 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2057 __pPlayButton->SetShowState(false);
2061 __pPlayButton->SetShowState(true);
2064 if (__detail == false)
2066 __pScrollPanel->SetShowState(false);
2071 AppLogDebug("EXIT");
2075 ImageViewerForm::OnSlideSettingPopUpItemSelected(int index)
2078 if ( __pPopUp != NULL)
2080 __pPopUp->SetShowState(false);
2083 if (index == 0) // start slide show
2085 int repeatValue = 0;
2087 if (__pPresentationModel->GetFileCount() > 1)
2089 __pGallery->UpdateGallery();
2091 if (__detail == false)
2093 ShowPanelDetail(false);
2096 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
2097 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
2099 if (repeatValue == 0)
2101 __pGallery->StartSlideShow(false);
2105 __pGallery->StartSlideShow(true);
2109 else if (index == 1) // launch settings
2111 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
2112 pDataList->Construct();
2114 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_GALLERY,
2115 APPCONTROL_OPERATION_ID_CONFIGURE, null, null, this);