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"
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Base::Runtime;
36 using namespace Tizen::Base::Utility;
37 using namespace Tizen::Content;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Io;
40 using namespace Tizen::Media;
41 using namespace Tizen::System;
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Controls;
44 using namespace Tizen::Ui::Scenes;
46 static const unsigned int COLOR_HEADER_CONTORL_PANEL = Color32<0, 0, 0, 100>::Value;
47 static const unsigned int COLOR_HEADER_BUTTON1 = Color32<0, 0, 0, 100>::Value;
48 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
49 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
50 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
51 static const unsigned int COLOR_GALLERY_BG = Color32<31,31,31>::Value;
53 static const Rectangle RECT_DETAILS_CONTORL_LABEL (20, 0, 200, 48);
55 static const int W_PLAY_BUTTON = 160;
56 static const int H_PLAY_BUTTON = 160;
58 static const int GAP_W_POPUP_ITEM = 5;
59 static const int W_DELETE_POPUP = 600;
60 static const int H_DELETE_POPUP = 300;
61 static const int H_DELETE_LABEL = 180;
62 static const int Y_DELETE_BUTTON = 180;
63 static const int H_DELETE_BUTTON = 80;
65 static const Dimension DUMMY_IMAGE_DIMENSION (720, 1280);
66 static const Rectangle DUMMY_IMAGE_RECTANGLE (0, 0, 720, 1280);
68 static const int PAGE_NO_CONTENT_SEARCH = 1;
69 static const int COUNT_PER_PAGE_CONTENT_SEARCH = 10;
71 static const int FORMAT_BUFFER_SIZE = 256;
73 static const long long SINGLE_GIGA_BYTE = (1024 * 1024 * 1024);
74 static const long long SINGLE_MEGA_BYTE = (1024 * 1024);
75 static const long long SINGLE_KILO_BYTE = 1024;
77 static const int Y_RENAME_BUTTON = 100;
78 static const int H_RENAME_BUTTON = 64;
79 static const int W_RENAME_BUTTON = 64;
81 static const int GAP_W_END_OF_LABEL = 60;
82 static const int X_DETAIL_FILEINFO_LABEL = 20;
83 static const int H_DETAIL_FILEINFO_LABEL = 50;
84 static const int H_DETAIL_MAIN_TEXT = 48;
85 static const int H_DETAIL_SUB_TEXT = 42;
86 static const int GAP_H_DETAIL_TEXT = 26;
87 static const int H_DETAIL_FILEINFO_VALUE_LABEL = 56;
89 static const int X_MORE = 55;
91 static const int DETAIL_SUB_FONT_SIZE = 32;
92 static const int DETAIL_MAIN_FONT_SIZE = 36;
93 static const int DETAIL_COUNT_MAX = 9;
95 ImageViewerForm::ImageViewerForm(void)
96 : __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
99 , __pScrollPanel(null)
100 , __pDetail_Label(null)
101 , __pLabelMessage(null)
102 , __pPlayButton(null)
103 , __pRenameButton(null)
104 , __pDetailFooterItem(null)
107 , __pContextMenuMore(null)
108 , __pContextMenuCopy(null)
109 , __pContextMenuSetAs(null)
110 , __pContextMenuShare(null)
111 , __pDeletePopup(null)
114 , __startSlide(false)
116 , __pPresentationModel(null)
118 AppLogDebug("ENTER");
119 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
122 ImageViewerForm::~ImageViewerForm(void)
124 AppLogDebug("ENTER");
125 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
129 ImageViewerForm::Initialize()
131 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);
204 int allCount = __pPresentationModel->GetFileCount();
207 displayText.Append(index);
208 displayText.Append("/");
209 displayText.Append(allCount);
211 __pLabel->SetText(displayText);
214 InitializeDisplay(__initializeDisplayModeCurrent);
215 InitializePanelDetail();
218 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
219 || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
220 || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
222 int index = __pPresentationModel->GetStartIndex();
223 __pGallery->UpdateGallery();
224 __pGallery->SetCurrentItemIndex(index);
227 String filePath = __pPresentationModel->GetFilePathAt(index);
228 __pPresentationModel->RequestImage(filePath);
230 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
237 __pTimer = new (std::nothrow) Timer();
238 __pTimer->Construct(*this);
242 AddOrientationEventListener(*this);
243 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
249 ImageViewerForm::OnInitialized(void)
251 AppLogDebug("ENTER");
252 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
258 ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
260 AppLogDebug("ENTER");
261 if (__detail == false)
263 ShowPanelDetail(true);
267 ShowPanelDetail(false);
270 Rectangle clientRect = GetClientAreaBounds();
271 Rectangle rect = GetBounds();
273 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
274 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
275 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
278 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
282 ImageViewerForm::InitializeDisplay(AppControlMode status)
284 AppLogDebug("ENTER");
286 String strItemIdxText;
288 __pFooter = GetFooter();
289 __pFooter->AddActionEventListener(*this);
290 __pFooter->RemoveAllItems();
292 GetLabelText(0, strItemIdxText);
293 Rectangle rect = GetClientAreaBounds();
296 if (status == APPCONTROL_MODE_NORMAL)
298 __pPlayButton = new (std::nothrow) Button();
299 if (__pPlayButton != null)
301 Rectangle clientRect = GetClientAreaBounds();
303 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
304 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
305 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
306 AddControl(*__pPlayButton);
308 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
309 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
310 delete pNormalBackgroundBitmap;
312 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
313 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
314 delete pPressedBackgroundBitmap;
316 __pPlayButton->AddActionEventListener(*this);
317 __pPlayButton->SetShowState(false);
320 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
321 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
322 __pFooter->SetBackButton();
324 FooterItem footerItem1;
325 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
326 Bitmap* pFooterItemShareNomal =
327 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
328 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
330 FooterItem footerItem2;
331 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DELETE);
332 Bitmap* pFooterItemDeleteNomal =
333 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
334 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
336 __pFooter->AddItem(footerItem1);
337 __pFooter->AddItem(footerItem2);
339 delete pFooterItemShareNomal;
340 delete pFooterItemDeleteNomal;
342 ButtonItem buttonItemMore;
343 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
344 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
345 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
346 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
347 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
348 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
350 else if (status == APPCONTROL_MODE_WEB_LINK)
352 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
353 __pFooter->SetBackButton();
355 FooterItem footerItem1;
356 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
357 Bitmap* pFooterItemShareNomal =
358 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
359 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
361 FooterItem footerItem2;
362 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DOWNLOAD);
363 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
364 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
366 __pFooter->AddItem(footerItem1);
367 __pFooter->AddItem(footerItem2);
369 delete pFooterItemShareNomal;
370 delete pFooterItemDownlordNomal;
372 ButtonItem buttonItemMore;
373 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
374 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
375 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
376 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
377 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
378 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
380 __pFooter->AddItem(footerItem1);
381 __pFooter->AddItem(footerItem2);
383 else if (status == APPCONTROL_MODE_CROP)
385 FooterItem footerItem1;
386 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SAVE);
387 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
388 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
390 FooterItem footerItem2;
391 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_BACK);
392 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
393 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
395 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
396 __pFooter->AddItem(footerItem1);
397 __pFooter->AddItem(footerItem2);
402 else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
404 __pPlayButton = new (std::nothrow) Button();
405 if (__pPlayButton != null)
407 Rectangle clientRect = GetClientAreaBounds();
409 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
410 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
411 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
412 AddControl(*__pPlayButton);
414 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
415 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
416 delete pNormalBackgroundBitmap;
418 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
419 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
420 delete pPressedBackgroundBitmap;
422 __pPlayButton->AddActionEventListener(*this);
423 __pPlayButton->SetShowState(false);
426 __pFooter->SetBackButton();
429 String filePath = __pPresentationModel->GetFilePathAt(0);
430 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
431 if (contentType == CONTENT_TYPE_VIDEO)
433 __pPlayButton->SetShowState(true);
435 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
439 ImageViewerForm::GetLabelText(int index, String &page)
441 AppLogDebug("ENTER");
442 int allCount = __pPresentationModel->GetFileCount();
443 String pStr = __pPresentationModel->GetFilePathAt(index);
444 page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
445 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
449 ImageViewerForm::DeleteImageFile()
451 AppLogDebug("ENTER");
452 int currentIndex = __pGallery->GetCurrentItemIndex();
454 String strItemText(EMPTY_SPACE);
455 String strItemIdxText(EMPTY_SPACE);
456 int countPath = __pPresentationModel->GetFileCount();
457 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
459 if (filePath.GetLength() == 0)
461 UiApp* pApp = UiApp::GetInstance();
463 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
468 result r = File::Remove(filePath);
471 MessageBox messageBox;
472 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
473 MSGBOX_STYLE_NONE, 3000);
475 messageBox.ShowAndWait(modalResult);
476 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
481 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
482 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
484 ContentManager::ScanFile(filePath);
487 __pPresentationModel->DeleteFilePathAt(currentIndex);
490 UiApp* pApp = UiApp::GetInstance();
492 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
496 else if ((countPath - 1) == currentIndex)
498 __pGallery->SetCurrentItemIndex(--currentIndex);
501 __pGallery->UpdateGallery();
502 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
503 __pPresentationModel->RequestImage(filePath);
505 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
507 if (__visible == true)
509 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
511 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
513 __pPlayButton->SetShowState(false);
517 __pPlayButton->SetShowState(true);
521 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
527 ImageViewerForm::CallVideoPlayer(void)
529 AppLogDebug("ENTER");
530 int index = __pGallery->GetCurrentItemIndex();
531 String filePath = __pPresentationModel->GetFilePathAt(index);
532 filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
534 AppLogDebug("ENTER(%ls)", filePath.GetPointer());
536 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
537 &filePath, null, this);
538 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
542 ImageViewerForm::CreateGallery(void)
544 AppLogDebug("ENTER");
545 Rectangle clientRect = GetClientAreaBounds();
546 Rectangle rect = GetBounds();
548 __pGallery = new (std::nothrow) Gallery();
549 __pGallery->Construct(Rectangle(0, clientRect.y, rect.width, rect.height));
550 __pGallery->SetName(L"GalleryControl");
551 __pGallery->SetItemProvider(*this);
552 __pGallery->AddGalleryEventListener(*this);
553 __pGallery->SetBackgroundColor(COLOR_GALLERY_BG);
554 AddControl(*__pGallery);
555 __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
557 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
561 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
562 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
564 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
565 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
567 case SLIDE_SHOW_TRANSITION_EFFECT_SLIDE:
571 __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
573 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
577 ImageViewerForm::InitializePanelDetail()
579 AppLogDebug("ENTER");
580 __pScrollPanel = new (std::nothrow) ScrollPanel();
582 String arrayId[DETAIL_COUNT_MAX] =
584 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
585 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
586 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
589 if (__pScrollPanel == null)
591 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
593 return E_INVALID_STATE;
596 Rectangle clientRect = GetClientAreaBounds();
597 result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height - __pLabel->GetHeight()));
600 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
602 return E_INVALID_STATE;
605 __pDetail_Label = new (std::nothrow) Label();
606 __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
607 __pScrollPanel->AddControl(*__pDetail_Label);
608 __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
609 __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
610 __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
611 __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
613 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
615 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
616 __pDetail_FileInfo_Label[i]->Construct(
617 Rectangle(X_DETAIL_FILEINFO_LABEL,
618 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
619 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
620 __pScrollPanel->AddControl(*__pDetail_FileInfo_Label[i]);
622 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
623 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
624 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
625 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
627 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
629 if (i == DETAIL_COUNT_MAX - 1)
631 __pDetail_FileInfo_Value_Label[i]->Construct(
632 Rectangle(X_DETAIL_FILEINFO_LABEL,
633 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
634 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
638 __pDetail_FileInfo_Value_Label[i]->Construct(
639 Rectangle(X_DETAIL_FILEINFO_LABEL,
640 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
641 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
644 __pScrollPanel->AddControl(*__pDetail_FileInfo_Value_Label[i]);
646 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
647 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
648 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
649 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
652 __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
653 __pScrollPanel->SetShowState(false);
655 __pRenameButton = new (std::nothrow) Button();
656 Rectangle rect = GetBounds();
657 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
658 __pRenameButton->SetActionId(ACTION_ID_PANEL_HEADER_DETAILS_RENAME);
659 __pRenameButton->AddActionEventListener(*this);
661 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
662 Bitmap* pIconBackground =
663 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
664 Bitmap* pIconPressed =
665 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
667 if (pIcon != null && pIconPressed != null && pIconBackground != null)
669 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
670 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
671 Point iconPosition(0, 0);
672 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
673 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
677 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
678 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
682 delete pIconBackground;
684 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
685 __pScrollPanel->AddControl(*__pRenameButton);
688 AddControl(*__pScrollPanel);
689 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
695 ImageViewerForm::InitializePopup(void)
697 AppLogDebug("ENTER");
698 if (__pDeletePopup == null)
700 __pDeletePopup = new (std::nothrow) Popup();
701 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
703 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
705 Label* pLabel = new (std::nothrow) Label();
706 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
707 ResourceManager::GetString(L"IDS_COM_BODY_DELETE") + L"?");
709 Button* pDeleteButton = new (std::nothrow) Button();
710 pDeleteButton->Construct(
711 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
712 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
713 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
714 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
715 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
716 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
717 pDeleteButton->AddActionEventListener(*this);
719 Button* pCancelButton = new (std::nothrow) Button();
720 pCancelButton->Construct(
721 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
722 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
723 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
724 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
725 pCancelButton->AddActionEventListener(*this);
727 __pDeletePopup->AddControl(*pLabel);
728 __pDeletePopup->AddControl(*pDeleteButton);
729 __pDeletePopup->AddControl(*pCancelButton);
733 __pDeletePopup->SetShowState(true);
734 __pDeletePopup->Show();
736 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
742 ImageViewerForm::InitializeContextMenuMore(void)
744 AppLogDebug("ENTER");
745 int currentIndex = __pGallery->GetCurrentItemIndex();
746 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
748 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
750 if (__pContextMenuMore != null)
752 delete __pContextMenuMore;
753 __pContextMenuMore = null;
756 __pContextMenuMore = new (std::nothrow) ContextMenu();
758 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
759 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
761 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
763 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
764 ACTION_ID_CONTEXTMENU_SET_AS);
765 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), ACTION_ID_FOOTER_BUTTON_CROP);
768 if (__pGallery->GetItemCount() > 1)
770 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
771 ACTION_ID_FOOTER_BUTTON_SLIDE);
773 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
774 ACTION_ID_FOOTER_BUTTON_DETAILS);
775 __pContextMenuMore->SetShowState(false);
776 __pContextMenuMore->AddActionEventListener(*this);
777 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
783 ImageViewerForm::InitializeContextMenuSetAs(void)
785 AppLogDebug("ENTER");
787 if (__pContextMenuSetAs != null)
789 delete __pContextMenuSetAs;
790 __pContextMenuSetAs = null;
793 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
794 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
795 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
797 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
798 ACTION_ID_CONTEXTMENU_HOME);
799 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
800 ACTION_ID_CONTEXTMENU_LOCK);
801 __pContextMenuSetAs->AddItem(L"Home and lock screens", ACTION_ID_CONTEXTMENU_HOME_AND_LOCK);
802 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
803 ACTION_ID_CONTEXTMENU_CALLER);
804 __pContextMenuSetAs->AddActionEventListener(*this);
805 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
811 ImageViewerForm::InitializeContextMenuShare(void)
813 AppLogDebug("ENTER");
814 if (__pContextMenuShare != null)
816 delete __pContextMenuShare;
817 __pContextMenuShare = null;
819 __pContextMenuShare = new (std::nothrow) ContextMenu();
820 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
821 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
822 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
824 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
825 ACTION_ID_CONTEXTMENU_MESSAGE);
826 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
827 __pContextMenuShare->AddActionEventListener(*this);
828 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
834 ImageViewerForm::GetFileSize(String filePath)
836 AppLogDebug("ENTER");
840 result r = File::GetAttributes(filePath, attr);
843 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
847 size = attr.GetFileSize();
848 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
854 ImageViewerForm::SetDetailInfo(void)
856 AppLogDebug("ENTER");
858 Rectangle clientRect = GetClientAreaBounds();
859 __pScrollPanel->SetBounds(0,__pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight());
861 int currentIndex = __pGallery->GetCurrentItemIndex();
862 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
864 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
866 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
868 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
869 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
872 result r = File::GetAttributes(strFilePath, attr);
875 long long nSize = attr.GetFileSize();
876 DateTime dateTime = attr.GetDateTime();
877 strResult[2] = dateTime.ToString();
879 if (nSize > SINGLE_GIGA_BYTE)
881 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
882 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
884 else if (nSize > SINGLE_MEGA_BYTE)
886 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
887 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
889 else if (nSize > SINGLE_KILO_BYTE)
891 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
892 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
896 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
897 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
902 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
903 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
906 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
907 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
908 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
909 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
910 strResult[8] = strFilePath;
911 String fileName = File::GetFileName(strFilePath);
912 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
914 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
916 strResult[0] = __downLordFileName;
918 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
920 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
922 if (pImgMeta != null)
924 ImageContentInfo imageContentInfo;
925 r = imageContentInfo.Construct(&strFilePath);
928 strResult[1] = imageContentInfo.GetMediaFormat();
929 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
930 pImgMeta->GetHeight());
932 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
934 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
937 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
939 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
940 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
946 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
948 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
949 if (pVideoMeta != null)
951 VideoContentInfo videoContentInfo;
952 r = videoContentInfo.Construct(&strFilePath);
955 strResult[1] = videoContentInfo.GetMediaFormat();
956 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
957 pVideoMeta->GetHeight());
958 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
960 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
966 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
968 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
969 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
972 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
974 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
978 Rectangle rect = GetBounds();
979 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
981 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
987 ImageViewerForm::ShowPanelDetail(bool showStatus)
989 AppLogDebug("ENTER");
993 __pScrollPanel->SetShowState(true);
998 __pScrollPanel->SetShowState(false);
1001 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1007 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1009 AppLogDebug("ENTER");
1010 FooterItem footerItem;
1011 footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
1012 Bitmap* pfooterItem = null;
1016 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1017 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1021 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1022 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1025 pFooter->SetItemAt(position, footerItem);
1026 pFooter->Invalidate(true);
1029 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1035 ImageViewerForm::DownloadFile(void)
1037 AppLogDebug("ENTER");
1038 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1039 if (File::IsFileExist(DestPath) == false)
1041 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1045 ContentId contentId;
1046 ContentManager contentManager;
1047 contentManager.Construct();
1049 ImageContentInfo imageContentInfo;
1050 imageContentInfo.Construct(null);
1052 imageContentInfo.SetKeyword(L"platform, tizen");
1053 String sourcePath = DestPath;
1054 String destPath = Environment::GetMediaPath();
1055 destPath.Append(FOLDER_PATH_DOWNLOADS);
1056 destPath.Append(__downLordFileName);
1058 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1059 ImageViewerForm::OnFormBackRequested(*this);
1060 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1064 ImageViewerForm::GetItemCount(void)
1066 AppLogDebug("ENTER");
1067 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1069 return __pPresentationModel->GetFileCount();
1073 ImageViewerForm::CreateItem(int index)
1075 AppLogDebug("ENTER : index(%d)", index);
1076 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1078 String filePath = __pPresentationModel->GetFilePathAt(index);
1079 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1080 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1081 if (pBitmap == null)
1083 pBitmap = GetQuickThumbnailN(filePath);
1085 if (pBitmap == null)
1087 pBitmap = new (std::nothrow) Bitmap();
1088 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1091 pGallery->Construct(*pBitmap, filePath);
1093 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1099 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1101 AppLogDebug("ENTER index(%d)", index);
1102 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1103 pImageInfo->ClearBitmap();
1105 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1111 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1113 AppLogDebug("ENTER index(%d)", index);
1115 String filePath = __pPresentationModel->GetFilePathAt(index);
1116 AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1117 __pPresentationModel->RequestImage(filePath);
1119 String strItemIdxText;
1120 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1121 __pLabel->SetText(strItemIdxText);
1123 if (__visible == true)
1125 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1126 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1128 __pPlayButton->SetShowState(true);
1132 __pPlayButton->SetShowState(false);
1137 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1141 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1143 AppLogDebug("ENTER");
1145 String filePath = __pPresentationModel->GetFilePathAt(index);
1146 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1148 if (__visible == true)
1150 if (contentType == CONTENT_TYPE_VIDEO)
1152 __pPlayButton->SetShowState(false);
1155 SetActionBarsVisible( FORM_ACTION_BAR_FOOTER, false);
1156 __pLabel->SetShowState(false);
1161 if (contentType == CONTENT_TYPE_VIDEO)
1163 __pPlayButton->SetShowState(true);
1166 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1167 __pLabel->SetShowState(true);
1170 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1171 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1174 Rectangle clientRect = GetClientAreaBounds();
1175 Rectangle rect = GetBounds();
1176 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1178 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1182 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1184 AppLogDebug("ENTER");
1185 PowerManager::KeepScreenOnState(true, false);
1186 if (__visible == true)
1188 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1189 __pLabel->SetShowState(false);
1191 int index = __pGallery->GetCurrentItemIndex();
1192 String filePath = __pPresentationModel->GetFilePathAt(index);
1193 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1195 if (contentType == CONTENT_TYPE_VIDEO)
1197 __pPlayButton->SetShowState(false);
1203 Rectangle clientRect = GetClientAreaBounds();
1204 Rectangle rect = GetBounds();
1205 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1207 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1211 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1213 AppLogDebug("ENTER");
1214 PowerManager::KeepScreenOnState(false, true);
1215 int index = __pGallery->GetCurrentItemIndex();
1217 if (__visible == false)
1219 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1220 __pLabel->SetShowState(true);
1221 String filePath = __pPresentationModel->GetFilePathAt(index);
1222 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1223 if (contentType == CONTENT_TYPE_VIDEO)
1225 __pPlayButton->SetShowState(true);
1228 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1229 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1234 String strItemIdxText;
1235 GetLabelText(index, strItemIdxText);
1236 __pLabel->SetText(strItemIdxText);
1239 Rectangle clientRect = GetClientAreaBounds();
1240 Rectangle rect = GetBounds();
1241 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1244 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1248 ImageViewerForm::OnUpdateContentList(void)
1253 ImageViewerForm::OnTerminating(void)
1255 AppLogDebug("ENTER");
1257 if (__pTimer != null)
1264 __pPresentationModel->ClearImageRequests();
1265 __pPresentationModel->RemoveListener(*this);
1266 __pPresentationModel->RemoveFileUpdateListener(*this);
1268 if (__pContextMenuCopy != null)
1270 delete __pContextMenuCopy;
1271 __pContextMenuCopy = null;
1274 if (__pContextMenuSetAs != null)
1276 delete __pContextMenuSetAs;
1277 __pContextMenuSetAs = null;
1280 if (__pDeletePopup != null)
1282 delete __pDeletePopup;
1283 __pDeletePopup = null;
1286 if (__pContextMenuShare != null)
1288 delete __pContextMenuShare;
1289 __pContextMenuShare = null;
1292 if (__pContextMenuMore != null)
1294 delete __pContextMenuMore;
1295 __pContextMenuMore = null;
1298 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1304 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1306 AppLogDebug("ENTER actionId(%d)", actionId);
1307 SceneManager* pSceneManager = SceneManager::GetInstance();
1312 case ACTION_ID_FOOTER_MORE:
1314 InitializeContextMenuMore();
1316 __pContextMenuMore->SetShowState(true);
1317 __pContextMenuMore->Show();
1320 case ACTION_ID_CONTEXTMENU_SET_AS:
1321 InitializeContextMenuSetAs();
1323 __pContextMenuSetAs->SetShowState(true);
1324 __pContextMenuSetAs->Show();
1326 case ACTION_ID_FOOTER_BUTTON_SHARE:
1327 InitializeContextMenuShare();
1329 __pContextMenuShare->SetShowState(true);
1330 __pContextMenuShare->Show();
1332 case ACTION_ID_FOOTER_BUTTON_DELETE:
1333 __pDeletePopup->SetShowState(true);
1334 __pDeletePopup->Show();
1336 case ACTION_ID_FOOTER_BUTTON_SLIDE:
1338 int repeatValue = 0;
1340 if (__pPresentationModel->GetFileCount() > 1)
1342 __pGallery->UpdateGallery();
1343 if (__detail == false)
1345 ShowPanelDetail(false);
1348 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1349 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1351 if (repeatValue == 0)
1353 __pGallery->StartSlideShow(false);
1357 __pGallery->StartSlideShow(true);
1362 case ACTION_ID_FOOTER_BUTTON_CROP:
1365 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1366 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1367 pList->Add(new (std::nothrow) String(filePath));
1368 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1371 case ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT:
1373 int currentIndex = __pGallery->GetCurrentItemIndex();
1374 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1375 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1376 __pPresentationModel->SetImageRotateStatus(true);
1377 RotateImage(filePath, rotateMode);
1378 __pPresentationModel->RequestImage(filePath);
1380 ContentManager contentManager;
1381 contentManager.Construct();
1382 contentManager.ScanFile(filePath);
1385 case ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT:
1387 int currentIndex = __pGallery->GetCurrentItemIndex();
1388 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1389 RotateMode rotateMode = ROTATE_MODE_LEFT;
1390 __pPresentationModel->SetImageRotateStatus(true);
1391 RotateImage(filePath, rotateMode);
1392 __pPresentationModel->RequestImage(filePath);
1394 ContentManager contentManager;
1395 contentManager.Construct();
1396 contentManager.ScanFile(filePath);
1399 case ACTION_ID_FOOTER_BUTTON_DETAILS:
1401 ShowPanelDetail(__detail);
1404 case ACTION_ID_FOOTER_BUTTON_BACK:
1405 ImageViewerForm::OnFormBackRequested(*this);
1407 case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1410 case ACTION_ID_FOOTER_BUTTON_SAVE:
1412 case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1414 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1415 pSelectedIndex->Construct();
1416 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1417 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1420 case ACTION_ID_CONTEXTMENU_HOME:
1422 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1423 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1424 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1425 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1426 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1429 case ACTION_ID_CONTEXTMENU_LOCK:
1431 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1432 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1433 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1434 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1435 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1438 case ACTION_ID_CONTEXTMENU_CALLER:
1440 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1441 pDataList->Construct();
1442 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1443 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1444 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1445 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1446 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1447 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1449 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1450 APPCONTROL_OPERATION_ID_PICK, null, pDataList, this);
1454 case ACTION_ID_CONTEXTMENU_HOME_AND_LOCK:
1456 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1457 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1458 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1459 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1460 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1465 case ACTION_ID_CONTEXTMENU_EMAIL:
1467 OnRequestEmailAction();
1470 case ACTION_ID_CONTEXTMENU_MESSAGE:
1472 OnRequestMessagesAction();
1475 case ACTION_ID_CONTEXTMENU_COPY:
1477 int currentIndex = __pGallery->GetCurrentItemIndex();
1478 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1481 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1482 Clipboard* pClipboard = Clipboard::GetInstance();
1483 pClipboard->CopyItem(item);
1486 case ACTION_ID_DELETE_POPUP_DEL:
1488 __pDeletePopup->SetShowState(false);
1489 __pDeletePopup->Show();
1492 if (__detail == false)
1494 ShowPanelDetail(false);
1498 case ACTION_ID_DELETE_POPUP_CANCEL:
1500 __pDeletePopup->SetShowState(false);
1501 __pDeletePopup->Show();
1504 case ACTION_ID_CONTORL_BUTTON_PLAY:
1510 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1514 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1516 result r = E_SUCCESS;
1517 ImageBuffer* pRotatedBuffer = null;
1518 ImageBuffer* pRotatedBuffer1 = null;
1519 ImageFormat imageFormat;
1522 pRotatedBuffer = new (std::nothrow) ImageBuffer();
1523 r = pRotatedBuffer->Construct(filePath);
1524 pRotatedBuffer->GetImageInfo(filePath, imageFormat, width, height);
1527 if (rotateMode == ROTATE_MODE_RIGHT)
1529 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_90);
1533 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_270);
1536 TryCatch(pRotatedBuffer1 != null, r = GetLastResult(), "RotateN failed:%s", GetErrorMessage(GetLastResult()));
1537 pRotatedBuffer1->EncodeToFile(filePath, imageFormat, true, 100);
1538 delete pRotatedBuffer1;
1539 delete pRotatedBuffer;
1543 if (pRotatedBuffer != null) //this buffer is no longer used
1545 delete pRotatedBuffer;
1547 if (pRotatedBuffer1 != null) //this buffer is no longer used
1549 delete pRotatedBuffer1;
1555 ImageViewerForm::OnFormBackRequested(Form& source)
1557 AppLogDebug("ENTER");
1558 if (__detail == false)
1560 ShowPanelDetail(false);
1564 UiApp* pApp = UiApp::GetInstance();
1567 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1571 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1572 const SceneId& currentSceneId, IList* pArgs)
1574 AppLogDebug("ENTER");
1576 Rectangle clientRect = GetClientAreaBounds();
1577 Rectangle rect = GetBounds();
1579 __pGallery->SetBounds(Rectangle(0, clientRect.y, rect.width, rect.height));
1580 __pScrollPanel->SetBounds(Rectangle(0, __pLabel->GetHeight(), clientRect.width, clientRect.height - __pLabel->GetHeight()));
1581 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1583 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1586 String strItemIdxText(EMPTY_SPACE);
1587 GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
1588 __pLabel->SetText(strItemIdxText);
1592 if (__pGallery->GetCurrentItemIndex() < 0)
1594 SetFooterItemState(false);
1598 SetFooterItemState(true);
1601 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1605 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1606 const SceneId& nextSceneId)
1608 AppLogDebug("ENTER");
1609 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1613 ImageViewerForm::OnImageDecodedN(const int index)
1615 AppLogDebug("ENTER");
1616 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1618 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1622 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1623 const String& operationId, AppCtrlResult appControlResult,
1624 const IMap* pExtraData)
1626 AppLogDebug("ENTER");
1628 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1629 && operationId == APPCONTROL_OPERATION_ID_PICK
1630 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1632 const String* pContactId =
1633 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1634 SceneManager* pSceneManager = SceneManager::GetInstance();
1635 long long lresult = 0;
1636 if (pContactId != null && pContactId->GetLength() > 0)
1638 LongLong::Parse(*pContactId, lresult);
1640 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1641 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1642 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1643 pList->Add(new (std::nothrow) LongLong(lresult));
1644 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1645 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1648 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1649 pImageViewerApp->SetFrameEnabled(true);
1650 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1654 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1656 AppLogDebug("ENTER");
1657 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1661 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1663 AppLogDebug("ENTER");
1664 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1668 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1670 AppLogDebug("ENTER");
1671 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1675 ImageViewerForm::OnOtherControlSelected(const Control& source)
1677 AppLogDebug("ENTER");
1678 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1682 ImageViewerForm::InitShowGallery(void)
1684 AppLogDebug("ENTER");
1685 if (__pGallery != null && __pGallery->IsVisible() == false)
1687 Canvas* pCanvas = GetCanvasN();
1688 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1690 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1696 __pGallery->SetShowState(true);
1699 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1703 ImageViewerForm::OnTimerExpired(Timer &timer)
1705 int repeatValue = 0;
1706 AppLogDebug("ENTER");
1707 if (__pPresentationModel->GetFileCount() > 1)
1709 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1710 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1712 if (repeatValue == 0)
1714 __pGallery->StartSlideShow(false);
1718 __pGallery->StartSlideShow(true);
1721 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1725 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1727 AppLogDebug("ENTER");
1728 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1732 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1733 const String& errorMessage)
1735 AppLogDebug("ENTER");
1736 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1740 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1741 result transferResult, const String& errorCode, const String& errorMessage)
1743 AppLogDebug("ENTER");
1744 AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1745 AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1746 AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1747 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1751 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1752 const String& errorCode, const String& errorMessage)
1754 AppLogDebug("ENTER");
1755 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1759 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1760 const String& errorMessage)
1762 AppLogDebug("ENTER");
1763 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1767 ImageViewerForm::RequestDecodeUrl(void)
1769 AppLogDebug("ENTER");
1771 String filePath = __pPresentationModel->GetFilePathAt(0);
1773 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1775 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1780 __downLordFileName = __pPresentationModel->GetFileName(filePath);
1782 Image* pImage = new (std::nothrow) Image();
1783 pImage->Construct();
1786 uri.SetUri(filePath);
1788 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1791 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1795 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1796 result r, const String errorCode, const String errorMessage)
1798 AppLogDebug("ENTER");
1799 Image* pImage = new (std::nothrow) Image();
1800 pImage->Construct();
1802 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1803 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1807 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1808 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1810 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1812 __pPresentationModel->RequestImage(destPath);
1816 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1820 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1824 ImageViewerForm::OnRequestEmailAction(void)
1826 AppLogDebug("ENTER");
1827 int currentIndex = __pGallery->GetCurrentItemIndex();
1829 if (__pPresentationModel->GetFileCount() <= 0)
1831 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1835 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1837 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1838 pDataList->Construct();
1840 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1841 pList->Add(new (std::nothrow) String(filePath));
1843 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1845 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
1846 null, pDataList, this);
1847 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1851 ImageViewerForm::OnRequestMessagesAction(void)
1853 AppLogDebug("ENTER");
1854 int currentIndex = __pGallery->GetCurrentItemIndex();
1856 if (__pPresentationModel->GetFileCount() <= 0)
1858 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1862 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1864 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1865 pDataList->Construct();
1866 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE),
1867 new (std::nothrow) String(APPCONTROL_DATA_MMS));
1869 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1870 pList->Add(new (std::nothrow) String(filePath));
1872 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1874 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES,
1875 APPCONTROL_OPERATION_ID_COMPOSE, null, pDataList, this);
1876 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1880 ImageViewerForm::SetFooterItemState(bool isEnable)
1882 AppLogDebug("ENTER");
1883 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
1885 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1886 __pFooter->SetItemEnabled(0, isEnable);
1887 __pFooter->SetItemEnabled(1, isEnable);
1889 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1891 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1892 __pFooter->SetItemEnabled(0, isEnable);
1893 __pFooter->SetItemEnabled(1, isEnable);
1895 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
1897 __pFooter->SetItemEnabled(0, isEnable);
1899 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1903 ImageViewerForm::GetQuickThumbnailN(String& filePath)
1905 AppLogDebug("ENTER");
1906 Bitmap* pBitmap = null;
1908 if (filePath.GetLength() > 4)
1912 ContentSearch contentSearch;
1913 ContentSearchResult* pResultItem = null;
1914 IList* pContentInfoList = null;
1916 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1917 result r = contentSearch.Construct(contentType);
1918 AppLogDebug("r(%s)", GetErrorMessage(r));
1921 pBitmap = new (std::nothrow) Bitmap();
1922 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1933 queryString = CONTENT_QUERY_PREFIX_FILENAME;
1934 queryString.Append(L"'");
1935 queryString.Append(__pPresentationModel->GetFileName(filePath));
1936 queryString.Append(L"'");
1938 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
1939 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
1941 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
1943 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
1944 while (pEnum->MoveNext() == E_SUCCESS)
1946 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
1947 if (pResultItem == null)
1952 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
1954 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
1960 if (pContentInfoList != null)
1962 delete pContentInfoList;
1965 if (pBitmap != null)
1967 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1969 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1971 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
1972 result r = imageBuffer->Construct(filePath);
1975 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
1976 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
1978 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
1979 pBitmap->Scale(srcDim);
1983 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
1984 pBitmap->Scale(srcDim);
1990 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1992 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
1994 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
1996 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
1997 pBitmap->Scale(srcDim);
2005 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
2006 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
2007 pBitmap = new (std::nothrow) Bitmap();
2008 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
2011 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2015 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2017 AppLogDebug(" ENTER");
2018 bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF);
2019 bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
2021 int currentIndex = __pGallery->GetCurrentItemIndex();
2022 int countPath = __pPresentationModel->GetFileCount();
2024 if (countPath == 0 && eventDelete)
2026 UiApp* pApp = UiApp::GetInstance();
2028 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2030 AppLogDebug(" countPath is %d", countPath);
2031 AppLogDebug(" currentIndex is %d", currentIndex);
2033 if (countPath == currentIndex && eventDelete)
2035 __pGallery->SetCurrentItemIndex(--currentIndex);
2039 currentIndex = index;
2040 __pGallery->SetCurrentItemIndex(currentIndex);
2043 String strItemIdxText(EMPTY_SPACE);
2045 __pGallery->UpdateGallery();
2046 AppLogDebug(" UpdateGallery is %d", currentIndex);
2047 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2048 __pPresentationModel->RequestImage(filePath);
2050 GetLabelText(currentIndex,strItemIdxText);
2051 __pLabel->SetText(strItemIdxText);
2053 if (__visible == true)
2055 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2057 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2059 __pPlayButton->SetShowState(false);
2063 __pPlayButton->SetShowState(true);
2066 if (__detail == false)
2068 __pScrollPanel->SetShowState(false);
2073 AppLogDebug("EXIT");