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 __pRenameButton = new (std::nothrow) Button();
652 Rectangle rect = GetBounds();
653 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
654 __pRenameButton->SetActionId(ACTION_ID_PANEL_HEADER_DETAILS_RENAME);
655 __pRenameButton->AddActionEventListener(*this);
657 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
658 Bitmap* pIconBackground =
659 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
660 Bitmap* pIconPressed =
661 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
663 if (pIcon != null && pIconPressed != null && pIconBackground != null)
665 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
666 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
667 Point iconPosition(0, 0);
668 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
669 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
673 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
674 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
678 delete pIconBackground;
680 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
681 __pScrollPanel->AddControl(*__pRenameButton);
684 AddControl(*__pScrollPanel);
685 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
691 ImageViewerForm::InitializePopup(void)
693 AppLogDebug("ENTER");
694 if (__pDeletePopup == null)
696 __pDeletePopup = new (std::nothrow) Popup();
697 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
699 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
701 Label* pLabel = new (std::nothrow) Label();
702 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
703 ResourceManager::GetString(L"IDS_COM_BODY_DELETE") + L"?");
705 Button* pDeleteButton = new (std::nothrow) Button();
706 pDeleteButton->Construct(
707 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
708 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
709 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
710 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
711 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
712 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
713 pDeleteButton->AddActionEventListener(*this);
715 Button* pCancelButton = new (std::nothrow) Button();
716 pCancelButton->Construct(
717 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
718 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
719 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
720 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
721 pCancelButton->AddActionEventListener(*this);
723 __pDeletePopup->AddControl(*pLabel);
724 __pDeletePopup->AddControl(*pDeleteButton);
725 __pDeletePopup->AddControl(*pCancelButton);
729 __pDeletePopup->SetShowState(true);
730 __pDeletePopup->Show();
732 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
738 ImageViewerForm::InitializeContextMenuMore(void)
740 AppLogDebug("ENTER");
741 int currentIndex = __pGallery->GetCurrentItemIndex();
742 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
744 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
746 if (__pContextMenuMore != null)
748 delete __pContextMenuMore;
749 __pContextMenuMore = null;
752 __pContextMenuMore = new (std::nothrow) ContextMenu();
754 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
755 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
757 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
759 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
760 ACTION_ID_CONTEXTMENU_SET_AS);
761 __pContextMenuMore->AddItem("Crop", ACTION_ID_FOOTER_BUTTON_CROP);
764 if (__pGallery->GetItemCount() > 1)
766 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
767 ACTION_ID_FOOTER_BUTTON_SLIDE);
769 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
770 ACTION_ID_FOOTER_BUTTON_DETAILS);
771 __pContextMenuMore->SetShowState(false);
772 __pContextMenuMore->AddActionEventListener(*this);
773 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
779 ImageViewerForm::InitializeContextMenuSetAs(void)
781 AppLogDebug("ENTER");
783 if (__pContextMenuSetAs != null)
785 delete __pContextMenuSetAs;
786 __pContextMenuSetAs = null;
789 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
790 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
791 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
793 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
794 ACTION_ID_CONTEXTMENU_HOME);
795 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
796 ACTION_ID_CONTEXTMENU_LOCK);
797 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
798 ACTION_ID_CONTEXTMENU_CALLER);
799 __pContextMenuSetAs->AddActionEventListener(*this);
800 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
806 ImageViewerForm::InitializeContextMenuShare(void)
808 AppLogDebug("ENTER");
809 if (__pContextMenuShare != null)
811 delete __pContextMenuShare;
812 __pContextMenuShare = null;
814 __pContextMenuShare = new (std::nothrow) ContextMenu();
815 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
816 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
817 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
819 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
820 ACTION_ID_CONTEXTMENU_MESSAGE);
821 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
822 __pContextMenuShare->AddActionEventListener(*this);
823 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
829 ImageViewerForm::GetFileSize(String filePath)
831 AppLogDebug("ENTER");
835 result r = File::GetAttributes(filePath, attr);
838 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
842 size = attr.GetFileSize();
843 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
849 ImageViewerForm::SetDetailInfo(void)
851 AppLogDebug("ENTER");
853 Rectangle clientRect = GetClientAreaBounds();
854 __pScrollPanel->SetBounds(0, 0, clientRect.width, clientRect.height);
856 int currentIndex = __pGallery->GetCurrentItemIndex();
857 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
859 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
861 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
863 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
864 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
867 result r = File::GetAttributes(strFilePath, attr);
870 long long nSize = attr.GetFileSize();
871 DateTime dateTime = attr.GetDateTime();
872 strResult[2] = dateTime.ToString();
874 if (nSize > SINGLE_GIGA_BYTE)
876 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
877 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
879 else if (nSize > SINGLE_MEGA_BYTE)
881 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
882 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
884 else if (nSize > SINGLE_KILO_BYTE)
886 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
887 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
891 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
892 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
897 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
898 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
901 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
902 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
903 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
904 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
905 strResult[8] = strFilePath;
906 String fileName = File::GetFileName(strFilePath);
907 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
909 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
911 strResult[0] = __downLordFileName;
913 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
915 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
917 if (pImgMeta != null)
919 ImageContentInfo imageContentInfo;
920 r = imageContentInfo.Construct(&strFilePath);
923 strResult[1] = imageContentInfo.GetMediaFormat();
924 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
925 pImgMeta->GetHeight());
927 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
929 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
932 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
934 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
935 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
941 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
943 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
944 if (pVideoMeta != null)
946 VideoContentInfo videoContentInfo;
947 r = videoContentInfo.Construct(&strFilePath);
950 strResult[1] = videoContentInfo.GetMediaFormat();
951 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
952 pVideoMeta->GetHeight());
953 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
955 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
961 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
963 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
964 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
967 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
969 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
973 Rectangle rect = GetBounds();
974 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
976 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
982 ImageViewerForm::ShowPanelDetail(bool showStatus)
984 AppLogDebug("ENTER");
988 __pScrollPanel->SetShowState(true);
993 __pScrollPanel->SetShowState(false);
996 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1002 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
1004 AppLogDebug("ENTER");
1005 FooterItem footerItem;
1006 footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
1007 Bitmap* pfooterItem = null;
1011 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1012 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1016 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1017 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1020 pFooter->SetItemAt(position, footerItem);
1021 pFooter->Invalidate(true);
1024 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1030 ImageViewerForm::DownloadFile(void)
1032 AppLogDebug("ENTER");
1033 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1034 if (File::IsFileExist(DestPath) == false)
1036 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1040 ContentId contentId;
1041 ContentManager contentManager;
1042 contentManager.Construct();
1044 ImageContentInfo imageContentInfo;
1045 imageContentInfo.Construct(null);
1047 imageContentInfo.SetKeyword(L"platform, tizen");
1048 String sourcePath = DestPath;
1049 String destPath = Environment::GetMediaPath();
1050 destPath.Append(FOLDER_PATH_DOWNLOADS);
1051 destPath.Append(__downLordFileName);
1053 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1054 ImageViewerForm::OnFormBackRequested(*this);
1055 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1059 ImageViewerForm::GetItemCount(void)
1061 AppLogDebug("ENTER");
1062 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1064 return __pPresentationModel->GetFileCount();
1068 ImageViewerForm::CreateItem(int index)
1070 AppLogDebug("ENTER : index(%d)", index);
1071 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1073 String filePath = __pPresentationModel->GetFilePathAt(index);
1074 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1075 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1076 if (pBitmap == null)
1078 pBitmap = GetQuickThumbnailN(filePath);
1080 if (pBitmap == null)
1082 pBitmap = new (std::nothrow) Bitmap();
1083 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1086 pGallery->Construct(*pBitmap, filePath);
1088 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1094 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1096 AppLogDebug("ENTER index(%d)", index);
1097 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1098 pImageInfo->ClearBitmap();
1100 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1106 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1108 AppLogDebug("ENTER index(%d)", index);
1110 String filePath = __pPresentationModel->GetFilePathAt(index);
1111 AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1112 __pPresentationModel->RequestImage(filePath);
1115 String strItemIdxText;
1116 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
1117 __pHeader->SetTitleText(strItemText);
1118 __pHeader->SetDescriptionText(strItemIdxText);
1120 if (__visible == true)
1122 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1123 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1125 __pPlayButton->SetShowState(true);
1129 __pPlayButton->SetShowState(false);
1134 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1138 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1140 AppLogDebug("ENTER");
1142 String filePath = __pPresentationModel->GetFilePathAt(index);
1143 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1145 if (__visible == true)
1147 if (contentType == CONTENT_TYPE_VIDEO)
1149 __pPlayButton->SetShowState(false);
1152 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
1157 if (contentType == CONTENT_TYPE_VIDEO)
1159 __pPlayButton->SetShowState(true);
1162 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
1165 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1166 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1169 Rectangle clientRect = GetClientAreaBounds();
1170 Rectangle rect = GetBounds();
1171 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1173 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1177 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1179 AppLogDebug("ENTER");
1180 PowerManager::KeepScreenOnState(true, false);
1181 if (__visible == true)
1183 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
1185 int index = __pGallery->GetCurrentItemIndex();
1186 String filePath = __pPresentationModel->GetFilePathAt(index);
1187 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1189 if (contentType == CONTENT_TYPE_VIDEO)
1191 __pPlayButton->SetShowState(false);
1197 Rectangle clientRect = GetClientAreaBounds();
1198 Rectangle rect = GetBounds();
1199 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1201 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1205 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1207 AppLogDebug("ENTER");
1208 PowerManager::KeepScreenOnState(false, true);
1209 int index = __pGallery->GetCurrentItemIndex();
1211 if (__visible == false)
1213 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
1215 String filePath = __pPresentationModel->GetFilePathAt(index);
1216 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1217 if (contentType == CONTENT_TYPE_VIDEO)
1219 __pPlayButton->SetShowState(true);
1222 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1223 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1229 String strItemIdxText;
1230 GetHeaderString(index, strItemText, strItemIdxText);
1231 __pHeader->SetTitleText(strItemText);
1232 __pHeader->SetDescriptionText(strItemIdxText);
1234 Rectangle clientRect = GetClientAreaBounds();
1235 Rectangle rect = GetBounds();
1236 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1239 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1243 ImageViewerForm::OnUpdateContentList(void)
1248 ImageViewerForm::OnTerminating(void)
1250 AppLogDebug("ENTER");
1252 if (__pTimer != null)
1259 __pPresentationModel->ClearImageRequests();
1260 __pPresentationModel->RemoveListener(*this);
1261 __pPresentationModel->RemoveFileUpdateListener(*this);
1263 if (__pContextMenuCopy != null)
1265 delete __pContextMenuCopy;
1266 __pContextMenuCopy = null;
1269 if (__pContextMenuSetAs != null)
1271 delete __pContextMenuSetAs;
1272 __pContextMenuSetAs = null;
1275 if (__pDeletePopup != null)
1277 delete __pDeletePopup;
1278 __pDeletePopup = null;
1281 if (__pContextMenuShare != null)
1283 delete __pContextMenuShare;
1284 __pContextMenuShare = null;
1287 if (__pContextMenuMore != null)
1289 delete __pContextMenuMore;
1290 __pContextMenuMore = null;
1293 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1299 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1301 AppLogDebug("ENTER actionId(%d)", actionId);
1302 SceneManager* pSceneManager = SceneManager::GetInstance();
1307 case ACTION_ID_FOOTER_MORE:
1309 InitializeContextMenuMore();
1311 __pContextMenuMore->SetShowState(true);
1312 __pContextMenuMore->Show();
1315 case ACTION_ID_CONTEXTMENU_SET_AS:
1316 InitializeContextMenuSetAs();
1318 __pContextMenuSetAs->SetShowState(true);
1319 __pContextMenuSetAs->Show();
1321 case ACTION_ID_FOOTER_BUTTON_SHARE:
1322 InitializeContextMenuShare();
1324 __pContextMenuShare->SetShowState(true);
1325 __pContextMenuShare->Show();
1327 case ACTION_ID_FOOTER_BUTTON_DELETE:
1328 __pDeletePopup->SetShowState(true);
1329 __pDeletePopup->Show();
1331 case ACTION_ID_FOOTER_BUTTON_SLIDE:
1333 int repeatValue = 0;
1335 if (__pPresentationModel->GetFileCount() > 1)
1337 __pGallery->UpdateGallery();
1338 if (__detail == false)
1340 ShowPanelDetail(false);
1343 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1344 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1346 if (repeatValue == 0)
1348 __pGallery->StartSlideShow(false);
1352 __pGallery->StartSlideShow(true);
1357 case ACTION_ID_FOOTER_BUTTON_CROP:
1360 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1361 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1362 pList->Add(new (std::nothrow) String(filePath));
1363 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1366 case ACTION_ID_FOOTER_BUTTON_DETAILS:
1368 ShowPanelDetail(__detail);
1371 case ACTION_ID_FOOTER_BUTTON_BACK:
1372 ImageViewerForm::OnFormBackRequested(*this);
1374 case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1377 case ACTION_ID_FOOTER_BUTTON_SAVE:
1379 case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1381 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1382 pSelectedIndex->Construct();
1383 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1384 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1387 case ACTION_ID_CONTEXTMENU_HOME:
1389 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1390 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1391 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1392 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1393 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1396 case ACTION_ID_CONTEXTMENU_LOCK:
1398 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1399 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1400 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1401 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1402 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1405 case ACTION_ID_CONTEXTMENU_CALLER:
1407 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1408 pDataList->Construct();
1409 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1410 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1411 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_RETURN_TYPE),
1412 new (std::nothrow) String(APPCONTROL_DATA_CONTACT_ID));
1414 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1415 APPCONTROL_OPERATION_ID_PICK, pDataList, this);
1418 case ACTION_ID_CONTEXTMENU_EMAIL:
1420 OnRequestEmailAction();
1423 case ACTION_ID_CONTEXTMENU_MESSAGE:
1425 OnRequestMessagesAction();
1428 case ACTION_ID_CONTEXTMENU_COPY:
1430 int currentIndex = __pGallery->GetCurrentItemIndex();
1431 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1434 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1435 Clipboard* pClipboard = Clipboard::GetInstance();
1436 pClipboard->CopyItem(item);
1439 case ACTION_ID_DELETE_POPUP_DEL:
1441 __pDeletePopup->SetShowState(false);
1442 __pDeletePopup->Show();
1445 if (__detail == false)
1447 ShowPanelDetail(false);
1451 case ACTION_ID_DELETE_POPUP_CANCEL:
1453 __pDeletePopup->SetShowState(false);
1454 __pDeletePopup->Show();
1457 case ACTION_ID_CONTORL_BUTTON_PLAY:
1463 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1467 ImageViewerForm::OnFormBackRequested(Form& source)
1469 AppLogDebug("ENTER");
1470 if (__detail == false)
1472 ShowPanelDetail(false);
1476 UiApp* pApp = UiApp::GetInstance();
1479 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1483 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1484 const SceneId& currentSceneId, IList* pArgs)
1486 AppLogDebug("ENTER");
1488 Rectangle clientRect = GetClientAreaBounds();
1489 Rectangle rect = GetBounds();
1491 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1492 __pScrollPanel->SetBounds(Rectangle(0, 0, clientRect.width, clientRect.height));
1493 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1495 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1498 String strItemText(EMPTY_SPACE);
1499 String strItemIdxText(EMPTY_SPACE);
1500 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
1501 __pHeader->SetTitleText(strItemText);
1502 __pHeader->SetDescriptionText(strItemIdxText);
1506 if (__pGallery->GetCurrentItemIndex() < 0)
1508 SetFooterItemState(false);
1512 SetFooterItemState(true);
1515 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1519 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1520 const SceneId& nextSceneId)
1522 AppLogDebug("ENTER");
1523 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1527 ImageViewerForm::OnImageDecodedN(const int index)
1529 AppLogDebug("ENTER");
1530 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1532 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1536 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1537 const String& operationId, AppCtrlResult appControlResult,
1538 const IMap* pExtraData)
1540 AppLogDebug("ENTER");
1542 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1543 && operationId == APPCONTROL_OPERATION_ID_PICK
1544 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1546 const String* pReturnType =
1547 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_RETURN_TYPE)));
1548 if (pReturnType != null && pReturnType->CompareTo(APPCONTROL_DATA_CONTACT_ID) == 0)
1550 const String* pContactId =
1551 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_VALUE)));
1552 SceneManager* pSceneManager = SceneManager::GetInstance();
1553 long long lresult = 0;
1554 if (pContactId != null && pContactId->GetLength() > 0)
1556 LongLong::Parse(*pContactId, lresult);
1558 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1559 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1560 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1561 pList->Add(new (std::nothrow) LongLong(lresult));
1562 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1563 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1567 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1568 pImageViewerApp->SetFrameEnabled(true);
1569 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1573 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1575 AppLogDebug("ENTER");
1576 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1580 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1582 AppLogDebug("ENTER");
1583 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1587 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1589 AppLogDebug("ENTER");
1590 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1594 ImageViewerForm::OnOtherControlSelected(const Control& source)
1596 AppLogDebug("ENTER");
1597 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1601 ImageViewerForm::InitShowGallery(void)
1603 AppLogDebug("ENTER");
1604 if (__pGallery != null && __pGallery->IsVisible() == false)
1606 Canvas* pCanvas = GetCanvasN();
1607 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1609 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1615 __pGallery->SetShowState(true);
1618 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1622 ImageViewerForm::OnTimerExpired(Timer &timer)
1624 int repeatValue = 0;
1625 AppLogDebug("ENTER");
1626 if (__pPresentationModel->GetFileCount() > 1)
1628 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1629 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1631 if (repeatValue == 0)
1633 __pGallery->StartSlideShow(false);
1637 __pGallery->StartSlideShow(true);
1640 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1644 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1646 AppLogDebug("ENTER");
1647 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1651 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1652 const String& errorMessage)
1654 AppLogDebug("ENTER");
1655 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1659 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1660 result transferResult, const String& errorCode, const String& errorMessage)
1662 AppLogDebug("ENTER");
1663 AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1664 AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1665 AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1666 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1670 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1671 const String& errorCode, const String& errorMessage)
1673 AppLogDebug("ENTER");
1674 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1678 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1679 const String& errorMessage)
1681 AppLogDebug("ENTER");
1682 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1686 ImageViewerForm::RequestDecodeUrl(void)
1688 AppLogDebug("ENTER");
1690 String filePath = __pPresentationModel->GetFilePathAt(0);
1692 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1694 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1699 __downLordFileName = __pPresentationModel->GetFileName(filePath);
1701 Image* pImage = new (std::nothrow) Image();
1702 pImage->Construct();
1705 uri.SetUri(filePath);
1707 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1710 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1714 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1715 result r, const String errorCode, const String errorMessage)
1717 AppLogDebug("ENTER");
1718 Image* pImage = new (std::nothrow) Image();
1719 pImage->Construct();
1721 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1722 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1726 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1727 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1729 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1731 __pPresentationModel->RequestImage(destPath);
1735 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1739 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1743 ImageViewerForm::OnRequestEmailAction(void)
1745 AppLogDebug("ENTER");
1746 int currentIndex = __pGallery->GetCurrentItemIndex();
1748 if (__pPresentationModel->GetFileCount() <= 0)
1750 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1754 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1756 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1758 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE || mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1760 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1761 pDataList->Construct();
1762 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS),
1763 new (std::nothrow) String(filePath));
1765 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL,
1766 APPCONTROL_OPERATION_ID_COMPOSE, pDataList, this);
1768 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1772 ImageViewerForm::OnRequestMessagesAction(void)
1774 AppLogDebug("ENTER");
1775 int currentIndex = __pGallery->GetCurrentItemIndex();
1777 if (__pPresentationModel->GetFileCount() <= 0)
1779 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1783 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1785 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1787 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE || mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1789 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1790 pDataList->Construct();
1791 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE),new (std::nothrow) String(APPCONTROL_DATA_MMS));
1792 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS),new (std::nothrow) String(filePath));
1794 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES,
1795 APPCONTROL_OPERATION_ID_COMPOSE, pDataList, this);
1797 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1801 ImageViewerForm::SetFooterItemState(bool isEnable)
1803 AppLogDebug("ENTER");
1804 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
1806 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1807 __pFooter->SetItemEnabled(0, isEnable);
1808 __pFooter->SetItemEnabled(1, isEnable);
1810 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1812 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1813 __pFooter->SetItemEnabled(0, isEnable);
1814 __pFooter->SetItemEnabled(1, isEnable);
1816 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
1818 __pFooter->SetItemEnabled(0, isEnable);
1820 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1824 ImageViewerForm::GetQuickThumbnailN(String& filePath)
1826 AppLogDebug("ENTER");
1827 Bitmap* pBitmap = null;
1829 if (filePath.GetLength() > 4)
1833 ContentSearch contentSearch;
1834 ContentSearchResult* pResultItem = null;
1835 IList* pContentInfoList = null;
1837 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1838 result r = contentSearch.Construct(contentType);
1839 AppLogDebug("r(%s)", GetErrorMessage(r));
1842 pBitmap = new (std::nothrow) Bitmap();
1843 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1854 queryString = CONTENT_QUERY_PREFIX_FILENAME;
1855 queryString.Append(L"'");
1856 queryString.Append(__pPresentationModel->GetFileName(filePath));
1857 queryString.Append(L"'");
1859 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
1860 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
1862 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
1864 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
1865 while (pEnum->MoveNext() == E_SUCCESS)
1867 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
1868 if (pResultItem == null)
1873 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
1875 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
1881 if (pContentInfoList != null)
1883 delete pContentInfoList;
1886 if (pBitmap != null)
1888 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1890 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1892 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
1893 result r = imageBuffer->Construct(filePath);
1896 if ( imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP ||
1897 imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM )
1899 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
1900 pBitmap->Scale(srcDim);
1904 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
1905 pBitmap->Scale(srcDim);
1911 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1913 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
1915 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
1917 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
1918 pBitmap->Scale(srcDim);
1926 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
1927 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
1928 pBitmap = new (std::nothrow) Bitmap();
1929 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
1932 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1936 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
1938 AppLogDebug(" ENTER");
1939 bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF );
1940 bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
1942 int currentIndex = __pGallery->GetCurrentItemIndex();
1943 int countPath = __pPresentationModel->GetFileCount();
1945 if (countPath == 0 && eventDelete)
1947 UiApp* pApp = UiApp::GetInstance();
1949 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1952 AppLogDebug(" countPath is %d", countPath);
1953 AppLogDebug(" currentIndex is %d", currentIndex);
1955 if (countPath == currentIndex && eventDelete)
1957 __pGallery->SetCurrentItemIndex(--currentIndex);
1959 else if ( eventMove )
1961 currentIndex = index;
1962 __pGallery->SetCurrentItemIndex(currentIndex);
1965 String strItemText(EMPTY_SPACE);
1966 String strItemIdxText(EMPTY_SPACE);
1968 __pGallery->UpdateGallery();
1969 AppLogDebug(" UpdateGallery is %d", currentIndex);
1970 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1971 __pPresentationModel->RequestImage(filePath);
1973 GetHeaderString(currentIndex, strItemText, strItemIdxText);
1974 __pHeader->SetTitleText(strItemText);
1975 __pHeader->SetDescriptionText(strItemIdxText);
1977 if (__visible == true)
1979 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1981 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1983 __pPlayButton->SetShowState(false);
1987 __pPlayButton->SetShowState(true);
1990 if ( __detail == false)
1992 __pScrollPanel->SetShowState(false);
1998 AppLogDebug("EXIT");