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;
52 static const Rectangle RECT_DETAILS_CONTORL_LABEL (20, 0, 200, 48);
54 static const int W_PLAY_BUTTON = 160;
55 static const int H_PLAY_BUTTON = 160;
57 static const int GAP_W_POPUP_ITEM = 5;
58 static const int W_DELETE_POPUP = 600;
59 static const int H_DELETE_POPUP = 300;
60 static const int H_DELETE_LABEL = 180;
61 static const int Y_DELETE_BUTTON = 180;
62 static const int H_DELETE_BUTTON = 80;
64 static const Dimension DUMMY_IMAGE_DIMENSION (720, 1280);
65 static const Rectangle DUMMY_IMAGE_RECTANGLE (0, 0, 720, 1280);
67 static const int PAGE_NO_CONTENT_SEARCH = 1;
68 static const int COUNT_PER_PAGE_CONTENT_SEARCH = 10;
70 static const int FORMAT_BUFFER_SIZE = 256;
72 static const long long SINGLE_GIGA_BYTE = (1024 * 1024 * 1024);
73 static const long long SINGLE_MEGA_BYTE = (1024 * 1024);
74 static const long long SINGLE_KILO_BYTE = 1024;
76 static const int Y_RENAME_BUTTON = 100;
77 static const int H_RENAME_BUTTON = 64;
78 static const int W_RENAME_BUTTON = 64;
80 static const int GAP_W_END_OF_LABEL = 60;
81 static const int X_DETAIL_FILEINFO_LABEL = 20;
82 static const int H_DETAIL_FILEINFO_LABEL = 50;
83 static const int H_DETAIL_MAIN_TEXT = 48;
84 static const int H_DETAIL_SUB_TEXT = 42;
85 static const int GAP_H_DETAIL_TEXT = 26;
86 static const int H_DETAIL_FILEINFO_VALUE_LABEL = 56;
88 static const int X_MORE = 55;
90 static const int DETAIL_SUB_FONT_SIZE = 32;
91 static const int DETAIL_MAIN_FONT_SIZE = 36;
92 static const int DETAIL_COUNT_MAX = 9;
94 ImageViewerForm::ImageViewerForm(void)
95 : __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
98 , __pScrollPanel(null)
99 , __pDetail_Label(null)
100 , __pLabelMessage(null)
101 , __pPlayButton(null)
102 , __pRenameButton(null)
103 , __pDetailFooterItem(null)
106 , __pContextMenuMore(null)
107 , __pContextMenuCopy(null)
108 , __pContextMenuSetAs(null)
109 , __pContextMenuShare(null)
110 , __pDeletePopup(null)
113 , __startSlide(false)
115 , __pPresentationModel(null)
117 AppLogDebug("ENTER");
118 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
121 ImageViewerForm::~ImageViewerForm(void)
123 AppLogDebug("ENTER");
124 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
128 ImageViewerForm::Initialize()
130 AppLogDebug("ENTER");
131 __pPresentationModel = ImageViewerPresentationModel::GetInstance();
133 if (__pPresentationModel->GetFileCount() > 0)
135 if (__pPresentationModel->GetType() == APPCONTROL_DATA_SLIDE_SHOW)
141 __pPresentationModel->AddFileUpdateListener(this);
143 __pSettingPresentationModel = SettingPresentationModel::GetInstance();
145 int startIndex = __pPresentationModel->GetStartIndex();
146 String filePath = __pPresentationModel->GetFilePathAt(startIndex);
148 if (filePath.StartsWith(WEB_URL_HTTP, 0) == true)
150 __initializeDisplayModeCurrent = APPCONTROL_MODE_WEB_LINK;
152 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_MESSAGE)
154 __initializeDisplayModeCurrent = APPCONTROL_MODE_MESSAGE;
156 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_EMAIL)
158 __initializeDisplayModeCurrent = APPCONTROL_MODE_EMAIL;
162 __initializeDisplayModeCurrent = APPCONTROL_MODE_NORMAL;
165 result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
167 if (filePath == EMPTY_SPACE)
169 MessageBox messageBox;
170 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE,
173 messageBox.ShowAndWait(modalResult);
175 UiApp* pApp = UiApp::GetInstance();
179 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
185 ImageViewerForm::OnInitializing(void)
187 AppLogDebug("ENTER");
188 SetFormBackEventListener(this);
189 __pPresentationModel->AddListener(this);
192 InitializeDisplay(__initializeDisplayModeCurrent);
193 InitializePanelDetail();
196 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
197 || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
198 || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
200 int index = __pPresentationModel->GetStartIndex();
201 __pGallery->UpdateGallery();
202 __pGallery->SetCurrentItemIndex(index);
205 String filePath = __pPresentationModel->GetFilePathAt(index);
206 __pPresentationModel->RequestImage(filePath);
208 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
215 __pTimer = new (std::nothrow) Timer();
216 __pTimer->Construct(*this);
219 result r = SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
220 AddOrientationEventListener(*this);
221 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
227 ImageViewerForm::OnInitialized(void)
229 AppLogDebug("ENTER");
230 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
236 ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
238 AppLogDebug("ENTER");
239 if (__detail == false)
241 ShowPanelDetail(true);
245 ShowPanelDetail(false);
248 Rectangle clientRect = GetClientAreaBounds();
249 Rectangle rect = GetBounds();
251 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
252 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
253 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
256 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
260 ImageViewerForm::InitializeDisplay(AppControlMode status)
262 AppLogDebug("ENTER");
264 String strItemIdxText;
266 __pHeader = GetHeader();
267 __pHeader->AddActionEventListener(*this);
269 __pFooter = GetFooter();
270 __pFooter->AddActionEventListener(*this);
271 __pFooter->RemoveAllItems();
273 GetHeaderString(0, strItemText, strItemIdxText);
274 Rectangle rect = GetClientAreaBounds();
275 __pHeader->SetTitleText(strItemText);
276 __pHeader->SetDescriptionText(strItemIdxText);
278 if (status == APPCONTROL_MODE_NORMAL)
280 __pPlayButton = new (std::nothrow) Button();
281 if (__pPlayButton != null)
283 Rectangle clientRect = GetClientAreaBounds();
285 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
286 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
287 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
288 AddControl(*__pPlayButton);
290 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
291 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
292 delete pNormalBackgroundBitmap;
294 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
295 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
296 delete pPressedBackgroundBitmap;
298 __pPlayButton->AddActionEventListener(*this);
299 __pPlayButton->SetShowState(false);
302 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
303 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
304 __pFooter->SetBackButton();
306 FooterItem footerItem1;
307 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
308 Bitmap* pFooterItemShareNomal =
309 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
310 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
312 FooterItem footerItem2;
313 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DELETE);
314 Bitmap* pFooterItemDeleteNomal =
315 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
316 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
318 __pFooter->AddItem(footerItem1);
319 __pFooter->AddItem(footerItem2);
321 delete pFooterItemShareNomal;
322 delete pFooterItemDeleteNomal;
324 ButtonItem buttonItemMore;
325 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
326 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
327 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
328 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
329 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
330 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
332 else if (status == APPCONTROL_MODE_WEB_LINK)
334 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
335 __pFooter->SetBackButton();
337 FooterItem footerItem1;
338 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
339 Bitmap* pFooterItemShareNomal =
340 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
341 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
343 FooterItem footerItem2;
344 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DOWNLOAD);
345 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
346 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
348 __pFooter->AddItem(footerItem1);
349 __pFooter->AddItem(footerItem2);
351 delete pFooterItemShareNomal;
352 delete pFooterItemDownlordNomal;
354 ButtonItem buttonItemMore;
355 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
356 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
357 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
358 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
359 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
360 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
362 __pFooter->AddItem(footerItem1);
363 __pFooter->AddItem(footerItem2);
365 else if (status == APPCONTROL_MODE_CROP)
367 FooterItem footerItem1;
368 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SAVE);
369 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
370 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
372 FooterItem footerItem2;
373 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_BACK);
374 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
375 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
377 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
378 __pFooter->AddItem(footerItem1);
379 __pFooter->AddItem(footerItem2);
384 else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
386 __pPlayButton = new (std::nothrow) Button();
387 if (__pPlayButton != null)
389 Rectangle clientRect = GetClientAreaBounds();
391 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
392 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
393 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
394 AddControl(*__pPlayButton);
396 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
397 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
398 delete pNormalBackgroundBitmap;
400 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
401 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
402 delete pPressedBackgroundBitmap;
404 __pPlayButton->AddActionEventListener(*this);
405 __pPlayButton->SetShowState(false);
408 __pFooter->SetBackButton();
411 String filePath = __pPresentationModel->GetFilePathAt(0);
412 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
413 if (contentType == CONTENT_TYPE_VIDEO)
415 __pPlayButton->SetShowState(true);
417 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
421 ImageViewerForm::GetHeaderString(int index, String &fileName, String &page)
423 AppLogDebug("ENTER");
424 int allCount = __pPresentationModel->GetFileCount();
425 String pStr = __pPresentationModel->GetFilePathAt(index);
426 fileName = __pPresentationModel->GetFileName(pStr);
427 page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
428 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
432 ImageViewerForm::DeleteImageFile()
434 AppLogDebug("ENTER");
435 int currentIndex = __pGallery->GetCurrentItemIndex();
437 String strItemText(EMPTY_SPACE);
438 String strItemIdxText(EMPTY_SPACE);
439 int countPath = __pPresentationModel->GetFileCount();
440 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
441 result r = E_SUCCESS;
442 if (filePath.GetLength() == 0)
444 UiApp* pApp = UiApp::GetInstance();
446 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
451 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
452 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
454 ContentId contentId = __pPresentationModel->GetFileContentId(filePath);
455 ContentManager contentManager;
456 contentManager.Construct();
457 r = contentManager.DeleteContent(contentId);
460 r = File::Remove(filePath);
463 MessageBox messageBox;
464 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
465 MSGBOX_STYLE_NONE, 3000);
467 messageBox.ShowAndWait(modalResult);
468 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
476 r = File::Remove(filePath);
479 __pPresentationModel->DeleteFilePathAt(currentIndex);
482 UiApp* pApp = UiApp::GetInstance();
484 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
488 else if ((countPath - 1) == currentIndex)
490 __pGallery->SetCurrentItemIndex(--currentIndex);
493 __pGallery->UpdateGallery();
494 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
495 __pPresentationModel->RequestImage(filePath);
497 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
498 __pHeader->SetTitleText(strItemText);
499 __pHeader->SetDescriptionText(strItemIdxText);
501 if (__visible == true)
503 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
505 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
507 __pPlayButton->SetShowState(false);
511 __pPlayButton->SetShowState(true);
515 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
521 ImageViewerForm::CallVideoPlayer(void)
523 AppLogDebug("ENTER");
524 int index = __pGallery->GetCurrentItemIndex();
525 String filePath = __pPresentationModel->GetFilePathAt(index);
527 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
528 pDataList->Construct();
529 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE),
530 new (std::nothrow) String(APPCONTROL_DATA_VIDEO));
531 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), new (std::nothrow) String(filePath));
533 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER,
534 APPCONTROL_OPERATION_ID_PLAY, pDataList, this);
535 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
539 ImageViewerForm::CreateGallery(void)
541 AppLogDebug("ENTER");
542 Rectangle clientRect = GetClientAreaBounds();
543 Rectangle rect = GetBounds();
545 __pGallery = new (std::nothrow) Gallery();
546 __pGallery->Construct(Rectangle(0, -clientRect.y, rect.width, rect.height));
547 __pGallery->SetName(L"GalleryControl");
548 __pGallery->SetItemProvider(*this);
549 __pGallery->AddGalleryEventListener(*this);
550 AddControl(*__pGallery);
551 __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
553 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
557 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
558 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
560 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
561 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
563 case SLIDE_SHOW_TRANSITION_EFFECT_SLIDE:
567 __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
569 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
573 ImageViewerForm::InitializePanelDetail()
575 AppLogDebug("ENTER");
576 __pScrollPanel = new (std::nothrow) ScrollPanel();
578 String arrayId[DETAIL_COUNT_MAX] =
580 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
581 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
582 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
585 if (__pScrollPanel == null)
587 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
589 return E_INVALID_STATE;
592 Rectangle clientRect = GetClientAreaBounds();
593 result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height));
596 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
598 return E_INVALID_STATE;
601 __pDetail_Label = new (std::nothrow) Label();
602 __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
603 __pScrollPanel->AddControl(*__pDetail_Label);
604 __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
605 __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
606 __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
607 __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
609 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
611 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
612 __pDetail_FileInfo_Label[i]->Construct(
613 Rectangle(X_DETAIL_FILEINFO_LABEL,
614 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
615 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
616 __pScrollPanel->AddControl(*__pDetail_FileInfo_Label[i]);
618 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
619 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
620 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
621 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
623 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
625 if (i == DETAIL_COUNT_MAX - 1)
627 __pDetail_FileInfo_Value_Label[i]->Construct(
628 Rectangle(X_DETAIL_FILEINFO_LABEL,
629 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
630 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
634 __pDetail_FileInfo_Value_Label[i]->Construct(
635 Rectangle(X_DETAIL_FILEINFO_LABEL,
636 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
637 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
640 __pScrollPanel->AddControl(*__pDetail_FileInfo_Value_Label[i]);
642 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
643 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
644 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
645 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
648 __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
649 __pScrollPanel->SetShowState(false);
651 AddControl(*__pScrollPanel);
652 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
658 ImageViewerForm::InitializePopup(void)
660 AppLogDebug("ENTER");
661 if (__pDeletePopup == null)
663 __pDeletePopup = new (std::nothrow) Popup();
664 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
666 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
668 Label* pLabel = new (std::nothrow) Label();
669 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
670 ResourceManager::GetString(L"IDS_COM_BODY_DELETE") + L"?");
672 Button* pDeleteButton = new (std::nothrow) Button();
673 pDeleteButton->Construct(
674 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
675 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
676 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
677 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
678 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
679 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
680 pDeleteButton->AddActionEventListener(*this);
682 Button* pCancelButton = new (std::nothrow) Button();
683 pCancelButton->Construct(
684 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
685 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
686 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
687 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
688 pCancelButton->AddActionEventListener(*this);
690 __pDeletePopup->AddControl(*pLabel);
691 __pDeletePopup->AddControl(*pDeleteButton);
692 __pDeletePopup->AddControl(*pCancelButton);
696 __pDeletePopup->SetShowState(true);
697 __pDeletePopup->Show();
699 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
705 ImageViewerForm::InitializeContextMenuMore(void)
707 AppLogDebug("ENTER");
708 int currentIndex = __pGallery->GetCurrentItemIndex();
709 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
711 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
713 if (__pContextMenuMore != null)
715 delete __pContextMenuMore;
716 __pContextMenuMore = null;
719 __pContextMenuMore = new (std::nothrow) ContextMenu();
721 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
722 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
724 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
726 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
727 ACTION_ID_CONTEXTMENU_SET_AS);
728 __pContextMenuMore->AddItem("Crop", ACTION_ID_FOOTER_BUTTON_CROP);
731 if (__pGallery->GetItemCount() > 1)
733 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
734 ACTION_ID_FOOTER_BUTTON_SLIDE);
736 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
737 ACTION_ID_FOOTER_BUTTON_DETAILS);
738 __pContextMenuMore->SetShowState(false);
739 __pContextMenuMore->AddActionEventListener(*this);
740 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
746 ImageViewerForm::InitializeContextMenuSetAs(void)
748 AppLogDebug("ENTER");
750 if (__pContextMenuSetAs != null)
752 delete __pContextMenuSetAs;
753 __pContextMenuSetAs = null;
756 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
757 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
758 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
760 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
761 ACTION_ID_CONTEXTMENU_HOME);
762 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
763 ACTION_ID_CONTEXTMENU_LOCK);
764 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
765 ACTION_ID_CONTEXTMENU_CALLER);
766 __pContextMenuSetAs->AddActionEventListener(*this);
767 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
773 ImageViewerForm::InitializeContextMenuShare(void)
775 AppLogDebug("ENTER");
776 if (__pContextMenuShare != null)
778 delete __pContextMenuShare;
779 __pContextMenuShare = null;
781 __pContextMenuShare = new (std::nothrow) ContextMenu();
782 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
783 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
784 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
786 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
787 ACTION_ID_CONTEXTMENU_MESSAGE);
788 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
789 __pContextMenuShare->AddActionEventListener(*this);
790 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
796 ImageViewerForm::GetFileSize(String filePath)
798 AppLogDebug("ENTER");
802 result r = File::GetAttributes(filePath, attr);
805 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
809 size = attr.GetFileSize();
810 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
816 ImageViewerForm::SetDetailInfo(void)
818 AppLogDebug("ENTER");
820 Rectangle clientRect = GetClientAreaBounds();
821 __pScrollPanel->SetBounds(0, 0, clientRect.width, clientRect.height);
823 int currentIndex = __pGallery->GetCurrentItemIndex();
824 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
826 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
828 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
830 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
831 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
834 result r = File::GetAttributes(strFilePath, attr);
837 long long nSize = attr.GetFileSize();
838 DateTime dateTime = attr.GetDateTime();
839 strResult[2] = dateTime.ToString();
841 if (nSize > SINGLE_GIGA_BYTE)
843 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
844 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
846 else if (nSize > SINGLE_MEGA_BYTE)
848 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
849 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
851 else if (nSize > SINGLE_KILO_BYTE)
853 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
854 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
858 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
859 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
864 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
865 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
868 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
869 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
870 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
871 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
872 strResult[8] = strFilePath;
873 String fileName = File::GetFileName(strFilePath);
874 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
876 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
878 strResult[0] = __downLordFileName;
880 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
882 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
884 if (pImgMeta != null)
886 ImageContentInfo imageContentInfo;
887 r = imageContentInfo.Construct(&strFilePath);
890 strResult[1] = imageContentInfo.GetMediaFormat();
891 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
892 pImgMeta->GetHeight());
894 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
896 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
899 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
901 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
902 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
908 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
910 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
911 if (pVideoMeta != null)
913 VideoContentInfo videoContentInfo;
914 r = videoContentInfo.Construct(&strFilePath);
917 strResult[1] = videoContentInfo.GetMediaFormat();
918 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
919 pVideoMeta->GetHeight());
920 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
922 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
928 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
930 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
931 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
934 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
936 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
940 if (__pRenameButton == null)
942 __pRenameButton = new (std::nothrow) Button();
943 Rectangle rect = GetBounds();
944 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
945 __pRenameButton->SetActionId(ACTION_ID_PANEL_HEADER_DETAILS_RENAME);
947 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
948 Bitmap* pIconBackground =
949 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
950 Bitmap* pIconPressed =
951 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
953 if (pIcon != null && pIconPressed != null && pIconBackground != null)
955 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
956 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
957 Point iconPosition(0, 0);
958 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
959 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
963 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
964 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
968 delete pIconBackground;
970 __pScrollPanel->AddControl(*__pRenameButton);
971 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
972 __pRenameButton->AddActionEventListener(*this);
976 Rectangle rect = GetBounds();
977 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
979 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
985 ImageViewerForm::ShowPanelDetail(bool showStatus)
987 AppLogDebug("ENTER");
991 __pScrollPanel->SetShowState(true);
996 __pScrollPanel->SetShowState(false);
999 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1005 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1007 AppLogDebug("ENTER");
1008 FooterItem footerItem;
1009 footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
1010 Bitmap* pfooterItem = null;
1014 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1015 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1019 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1020 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1023 pFooter->SetItemAt(position, footerItem);
1024 pFooter->Invalidate(true);
1027 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1033 ImageViewerForm::DownloadFile(void)
1035 AppLogDebug("ENTER");
1036 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1037 if (File::IsFileExist(DestPath) == false)
1039 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1043 ContentId contentId;
1044 ContentManager contentManager;
1045 contentManager.Construct();
1047 ImageContentInfo imageContentInfo;
1048 imageContentInfo.Construct(null);
1050 imageContentInfo.SetKeyword(L"platform, tizen");
1051 String sourcePath = DestPath;
1052 String destPath = Environment::GetMediaPath();
1053 destPath.Append(FOLDER_PATH_DOWNLOADS);
1054 destPath.Append(__downLordFileName);
1056 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1057 ImageViewerForm::OnFormBackRequested(*this);
1058 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1062 ImageViewerForm::GetItemCount(void)
1064 AppLogDebug("ENTER");
1065 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1067 return __pPresentationModel->GetFileCount();
1071 ImageViewerForm::CreateItem(int index)
1073 AppLogDebug("ENTER : index(%d)", index);
1074 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1076 String filePath = __pPresentationModel->GetFilePathAt(index);
1077 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1078 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1079 if (pBitmap == null)
1081 pBitmap = GetQuickThumbnailN(filePath);
1083 if (pBitmap == null)
1085 pBitmap = new (std::nothrow) Bitmap();
1086 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1089 pGallery->Construct(*pBitmap, filePath);
1091 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1097 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1099 AppLogDebug("ENTER index(%d)", index);
1100 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1101 pImageInfo->ClearBitmap();
1103 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1109 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1111 AppLogDebug("ENTER index(%d)", index);
1113 String filePath = __pPresentationModel->GetFilePathAt(index);
1114 AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1115 __pPresentationModel->RequestImage(filePath);
1118 String strItemIdxText;
1119 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
1120 __pHeader->SetTitleText(strItemText);
1121 __pHeader->SetDescriptionText(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_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
1160 if (contentType == CONTENT_TYPE_VIDEO)
1162 __pPlayButton->SetShowState(true);
1165 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
1168 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1169 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1172 Rectangle clientRect = GetClientAreaBounds();
1173 Rectangle rect = GetBounds();
1174 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1176 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1180 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1182 AppLogDebug("ENTER");
1183 PowerManager::KeepScreenOnState(true, false);
1184 if (__visible == true)
1186 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
1188 int index = __pGallery->GetCurrentItemIndex();
1189 String filePath = __pPresentationModel->GetFilePathAt(index);
1190 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1192 if (contentType == CONTENT_TYPE_VIDEO)
1194 __pPlayButton->SetShowState(false);
1200 Rectangle clientRect = GetClientAreaBounds();
1201 Rectangle rect = GetBounds();
1202 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1204 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1208 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1210 AppLogDebug("ENTER");
1211 PowerManager::KeepScreenOnState(false, true);
1212 int index = __pGallery->GetCurrentItemIndex();
1214 if (__visible == false)
1216 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
1218 String filePath = __pPresentationModel->GetFilePathAt(index);
1219 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1220 if (contentType == CONTENT_TYPE_VIDEO)
1222 __pPlayButton->SetShowState(true);
1225 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1226 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1232 String strItemIdxText;
1233 GetHeaderString(index, strItemText, strItemIdxText);
1234 __pHeader->SetTitleText(strItemText);
1235 __pHeader->SetDescriptionText(strItemIdxText);
1237 Rectangle clientRect = GetClientAreaBounds();
1238 Rectangle rect = GetBounds();
1239 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1242 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1246 ImageViewerForm::OnUpdateContentList(void)
1251 ImageViewerForm::OnTerminating(void)
1253 AppLogDebug("ENTER");
1255 if (__pTimer != null)
1262 __pPresentationModel->ClearImageRequests();
1263 __pPresentationModel->RemoveListener(*this);
1264 __pPresentationModel->RemoveFileUpdateListener(*this);
1266 if (__pContextMenuCopy != null)
1268 delete __pContextMenuCopy;
1269 __pContextMenuCopy = null;
1272 if (__pContextMenuSetAs != null)
1274 delete __pContextMenuSetAs;
1275 __pContextMenuSetAs = null;
1278 if (__pDeletePopup != null)
1280 delete __pDeletePopup;
1281 __pDeletePopup = null;
1284 if (__pContextMenuShare != null)
1286 delete __pContextMenuShare;
1287 __pContextMenuShare = null;
1290 if (__pContextMenuMore != null)
1292 delete __pContextMenuMore;
1293 __pContextMenuMore = null;
1296 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1302 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1304 AppLogDebug("ENTER actionId(%d)", actionId);
1305 SceneManager* pSceneManager = SceneManager::GetInstance();
1310 case ACTION_ID_FOOTER_MORE:
1312 InitializeContextMenuMore();
1314 __pContextMenuMore->SetShowState(true);
1315 __pContextMenuMore->Show();
1318 case ACTION_ID_CONTEXTMENU_SET_AS:
1319 InitializeContextMenuSetAs();
1321 __pContextMenuSetAs->SetShowState(true);
1322 __pContextMenuSetAs->Show();
1324 case ACTION_ID_FOOTER_BUTTON_SHARE:
1325 InitializeContextMenuShare();
1327 __pContextMenuShare->SetShowState(true);
1328 __pContextMenuShare->Show();
1330 case ACTION_ID_FOOTER_BUTTON_DELETE:
1331 __pDeletePopup->SetShowState(true);
1332 __pDeletePopup->Show();
1334 case ACTION_ID_FOOTER_BUTTON_SLIDE:
1336 int repeatValue = 0;
1338 if (__pPresentationModel->GetFileCount() > 1)
1340 __pGallery->UpdateGallery();
1341 if (__detail == false)
1343 ShowPanelDetail(false);
1346 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1347 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1349 if (repeatValue == 0)
1351 __pGallery->StartSlideShow(false);
1355 __pGallery->StartSlideShow(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_DETAILS:
1371 ShowPanelDetail(__detail);
1374 case ACTION_ID_FOOTER_BUTTON_BACK:
1375 ImageViewerForm::OnFormBackRequested(*this);
1377 case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1380 case ACTION_ID_FOOTER_BUTTON_SAVE:
1382 case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1384 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1385 pSelectedIndex->Construct();
1386 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1387 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1390 case ACTION_ID_CONTEXTMENU_HOME:
1392 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1393 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1394 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1395 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1396 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1399 case ACTION_ID_CONTEXTMENU_LOCK:
1401 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1402 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1403 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1404 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1405 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1408 case ACTION_ID_CONTEXTMENU_CALLER:
1410 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1411 pDataList->Construct();
1412 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1413 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1414 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_RETURN_TYPE),
1415 new (std::nothrow) String(APPCONTROL_DATA_CONTACT_ID));
1417 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1418 APPCONTROL_OPERATION_ID_PICK, pDataList, this);
1421 case ACTION_ID_CONTEXTMENU_EMAIL:
1423 OnRequestEmailAction();
1426 case ACTION_ID_CONTEXTMENU_MESSAGE:
1428 OnRequestMessagesAction();
1431 case ACTION_ID_CONTEXTMENU_COPY:
1433 int currentIndex = __pGallery->GetCurrentItemIndex();
1434 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1437 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1438 Clipboard* pClipboard = Clipboard::GetInstance();
1439 pClipboard->CopyItem(item);
1442 case ACTION_ID_DELETE_POPUP_DEL:
1444 __pDeletePopup->SetShowState(false);
1445 __pDeletePopup->Show();
1448 if (__detail == false)
1450 ShowPanelDetail(false);
1454 case ACTION_ID_DELETE_POPUP_CANCEL:
1456 __pDeletePopup->SetShowState(false);
1457 __pDeletePopup->Show();
1460 case ACTION_ID_CONTORL_BUTTON_PLAY:
1466 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1470 ImageViewerForm::OnFormBackRequested(Form& source)
1472 AppLogDebug("ENTER");
1473 if (__detail == false)
1475 ShowPanelDetail(false);
1479 UiApp* pApp = UiApp::GetInstance();
1482 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1486 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1487 const SceneId& currentSceneId, IList* pArgs)
1489 AppLogDebug("ENTER");
1491 Rectangle clientRect = GetClientAreaBounds();
1492 Rectangle rect = GetBounds();
1494 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1495 __pScrollPanel->SetBounds(Rectangle(0, 0, clientRect.width, clientRect.height));
1496 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1498 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1501 String strItemText(EMPTY_SPACE);
1502 String strItemIdxText(EMPTY_SPACE);
1503 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
1504 __pHeader->SetTitleText(strItemText);
1505 __pHeader->SetDescriptionText(strItemIdxText);
1509 if (__pGallery->GetCurrentItemIndex() < 0)
1511 SetFooterItemState(false);
1515 SetFooterItemState(true);
1518 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1522 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1523 const SceneId& nextSceneId)
1525 AppLogDebug("ENTER");
1526 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1530 ImageViewerForm::OnImageDecodedN(const int index)
1532 AppLogDebug("ENTER");
1533 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1535 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1539 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1540 const String& operationId, AppCtrlResult appControlResult,
1541 const IMap* pExtraData)
1543 AppLogDebug("ENTER");
1545 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1546 && operationId == APPCONTROL_OPERATION_ID_PICK
1547 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1549 const String* pReturnType =
1550 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_RETURN_TYPE)));
1551 if (pReturnType != null && pReturnType->CompareTo(APPCONTROL_DATA_CONTACT_ID) == 0)
1553 const String* pContactId =
1554 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_VALUE)));
1555 SceneManager* pSceneManager = SceneManager::GetInstance();
1556 long long lresult = 0;
1557 if (pContactId != null && pContactId->GetLength() > 0)
1559 LongLong::Parse(*pContactId, lresult);
1561 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1562 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1563 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1564 pList->Add(new (std::nothrow) LongLong(lresult));
1565 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1566 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1570 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1571 pImageViewerApp->SetFrameEnabled(true);
1572 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1576 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1578 AppLogDebug("ENTER");
1579 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1583 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1585 AppLogDebug("ENTER");
1586 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1590 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1592 AppLogDebug("ENTER");
1593 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1597 ImageViewerForm::OnOtherControlSelected(const Control& source)
1599 AppLogDebug("ENTER");
1600 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1604 ImageViewerForm::InitShowGallery(void)
1606 AppLogDebug("ENTER");
1607 if (__pGallery != null && __pGallery->IsVisible() == false)
1609 Canvas* pCanvas = GetCanvasN();
1610 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1612 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1618 __pGallery->SetShowState(true);
1621 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1625 ImageViewerForm::OnTimerExpired(Timer &timer)
1627 int repeatValue = 0;
1628 AppLogDebug("ENTER");
1629 if (__pPresentationModel->GetFileCount() > 1)
1631 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1632 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1634 if (repeatValue == 0)
1636 __pGallery->StartSlideShow(false);
1640 __pGallery->StartSlideShow(true);
1643 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1647 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1649 AppLogDebug("ENTER");
1650 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1654 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1655 const String& errorMessage)
1657 AppLogDebug("ENTER");
1658 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1662 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1663 result transferResult, const String& errorCode, const String& errorMessage)
1665 AppLogDebug("ENTER");
1666 AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1667 AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1668 AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1669 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1673 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1674 const String& errorCode, const String& errorMessage)
1676 AppLogDebug("ENTER");
1677 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1681 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1682 const String& errorMessage)
1684 AppLogDebug("ENTER");
1685 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1689 ImageViewerForm::RequestDecodeUrl(void)
1691 AppLogDebug("ENTER");
1693 String filePath = __pPresentationModel->GetFilePathAt(0);
1695 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1697 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1702 __downLordFileName = __pPresentationModel->GetFileName(filePath);
1704 Image* pImage = new (std::nothrow) Image();
1705 pImage->Construct();
1708 uri.SetUri(filePath);
1710 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1713 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1717 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1718 result r, const String errorCode, const String errorMessage)
1720 AppLogDebug("ENTER");
1721 Image* pImage = new (std::nothrow) Image();
1722 pImage->Construct();
1724 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1725 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1729 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1730 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1732 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1734 __pPresentationModel->RequestImage(destPath);
1738 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1742 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1746 ImageViewerForm::OnRequestEmailAction(void)
1748 AppLogDebug("ENTER");
1749 int currentIndex = __pGallery->GetCurrentItemIndex();
1751 if (__pPresentationModel->GetFileCount() <= 0)
1753 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1757 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1759 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1761 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE || mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1763 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1764 pDataList->Construct();
1765 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS),
1766 new (std::nothrow) String(filePath));
1768 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL,
1769 APPCONTROL_OPERATION_ID_COMPOSE, pDataList, this);
1771 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1775 ImageViewerForm::OnRequestMessagesAction(void)
1777 AppLogDebug("ENTER");
1778 int currentIndex = __pGallery->GetCurrentItemIndex();
1780 if (__pPresentationModel->GetFileCount() <= 0)
1782 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1786 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1788 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1790 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE || mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1792 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1793 pDataList->Construct();
1794 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE),new (std::nothrow) String(APPCONTROL_DATA_MMS));
1795 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS),new (std::nothrow) String(filePath));
1797 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES,
1798 APPCONTROL_OPERATION_ID_COMPOSE, pDataList, this);
1800 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1804 ImageViewerForm::SetFooterItemState(bool isEnable)
1806 AppLogDebug("ENTER");
1807 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
1809 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1810 __pFooter->SetItemEnabled(0, isEnable);
1811 __pFooter->SetItemEnabled(1, isEnable);
1813 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1815 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1816 __pFooter->SetItemEnabled(0, isEnable);
1817 __pFooter->SetItemEnabled(1, isEnable);
1819 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
1821 __pFooter->SetItemEnabled(0, isEnable);
1823 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1827 ImageViewerForm::GetQuickThumbnailN(String& filePath)
1829 AppLogDebug("ENTER");
1830 Bitmap* pBitmap = null;
1832 if (filePath.GetLength() > 4)
1836 ContentSearch contentSearch;
1837 ContentSearchResult* pResultItem = null;
1838 IList* pContentInfoList = null;
1840 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1841 result r = contentSearch.Construct(contentType);
1842 AppLogDebug("r(%s)", GetErrorMessage(r));
1845 pBitmap = new (std::nothrow) Bitmap();
1846 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1857 queryString = CONTENT_QUERY_PREFIX_FILENAME;
1858 queryString.Append(L"'");
1859 queryString.Append(__pPresentationModel->GetFileName(filePath));
1860 queryString.Append(L"'");
1862 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
1863 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
1865 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
1867 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
1868 while (pEnum->MoveNext() == E_SUCCESS)
1870 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
1871 if (pResultItem == null)
1876 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
1878 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
1884 if (pContentInfoList != null)
1886 delete pContentInfoList;
1889 if (pBitmap != null)
1891 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1893 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1895 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
1896 result r = imageBuffer->Construct(filePath);
1899 if ( imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP ||
1900 imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM )
1902 Dimension srcDim( imageBuffer->GetHeight(),imageBuffer->GetWidth());
1903 pBitmap->Scale(srcDim);
1907 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
1908 pBitmap->Scale(srcDim);
1914 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1916 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
1918 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
1920 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
1921 pBitmap->Scale(srcDim);
1929 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
1930 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
1931 pBitmap = new (std::nothrow) Bitmap();
1932 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
1935 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1939 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
1941 AppLogDebug(" ENTER");
1942 bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF );
1943 bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
1945 int currentIndex = __pGallery->GetCurrentItemIndex();
1946 int countPath = __pPresentationModel->GetFileCount();
1948 if (countPath == 0 && eventDelete)
1950 UiApp* pApp = UiApp::GetInstance();
1952 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1955 AppLogDebug(" countPath is %d", countPath);
1956 AppLogDebug(" currentIndex is %d", currentIndex);
1958 if (countPath == currentIndex && eventDelete)
1960 __pGallery->SetCurrentItemIndex(--currentIndex);
1962 else if ( eventMove )
1964 currentIndex = index;
1965 __pGallery->SetCurrentItemIndex(currentIndex);
1968 String strItemText(EMPTY_SPACE);
1969 String strItemIdxText(EMPTY_SPACE);
1971 __pGallery->UpdateGallery();
1972 AppLogDebug(" UpdateGallery is %d", currentIndex);
1973 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1974 __pPresentationModel->RequestImage(filePath);
1976 GetHeaderString(currentIndex, strItemText, strItemIdxText);
1977 __pHeader->SetTitleText(strItemText);
1978 __pHeader->SetDescriptionText(strItemIdxText);
1980 if (__visible == true)
1982 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1984 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1986 __pPlayButton->SetShowState(false);
1990 __pPlayButton->SetShowState(true);
1993 if ( __detail == false)
1995 __pScrollPanel->SetShowState(false);
2001 AppLogDebug("EXIT");