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);
442 if (filePath.GetLength() == 0)
444 UiApp* pApp = UiApp::GetInstance();
446 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
451 result r = File::Remove(filePath);
454 MessageBox messageBox;
455 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
456 MSGBOX_STYLE_NONE, 3000);
458 messageBox.ShowAndWait(modalResult);
459 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
464 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
465 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
467 ContentManager::ScanFile(filePath);
470 __pPresentationModel->DeleteFilePathAt(currentIndex);
473 UiApp* pApp = UiApp::GetInstance();
475 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
479 else if ((countPath - 1) == currentIndex)
481 __pGallery->SetCurrentItemIndex(--currentIndex);
484 __pGallery->UpdateGallery();
485 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
486 __pPresentationModel->RequestImage(filePath);
488 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
489 __pHeader->SetTitleText(strItemText);
490 __pHeader->SetDescriptionText(strItemIdxText);
492 if (__visible == true)
494 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
496 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
498 __pPlayButton->SetShowState(false);
502 __pPlayButton->SetShowState(true);
506 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
512 ImageViewerForm::CallVideoPlayer(void)
514 AppLogDebug("ENTER");
515 int index = __pGallery->GetCurrentItemIndex();
516 String filePath = __pPresentationModel->GetFilePathAt(index);
517 filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
519 AppLogDebug("ENTER(%ls)", filePath.GetPointer());
521 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
522 &filePath, null, this);
523 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
527 ImageViewerForm::CreateGallery(void)
529 AppLogDebug("ENTER");
530 Rectangle clientRect = GetClientAreaBounds();
531 Rectangle rect = GetBounds();
533 __pGallery = new (std::nothrow) Gallery();
534 __pGallery->Construct(Rectangle(0, -clientRect.y, rect.width, rect.height));
535 __pGallery->SetName(L"GalleryControl");
536 __pGallery->SetItemProvider(*this);
537 __pGallery->AddGalleryEventListener(*this);
538 AddControl(*__pGallery);
539 __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
541 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
545 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
546 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
548 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
549 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
551 case SLIDE_SHOW_TRANSITION_EFFECT_SLIDE:
555 __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
557 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
561 ImageViewerForm::InitializePanelDetail()
563 AppLogDebug("ENTER");
564 __pScrollPanel = new (std::nothrow) ScrollPanel();
566 String arrayId[DETAIL_COUNT_MAX] =
568 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
569 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
570 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
573 if (__pScrollPanel == null)
575 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
577 return E_INVALID_STATE;
580 Rectangle clientRect = GetClientAreaBounds();
581 result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height));
584 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
586 return E_INVALID_STATE;
589 __pDetail_Label = new (std::nothrow) Label();
590 __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
591 __pScrollPanel->AddControl(*__pDetail_Label);
592 __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
593 __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
594 __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
595 __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
597 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
599 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
600 __pDetail_FileInfo_Label[i]->Construct(
601 Rectangle(X_DETAIL_FILEINFO_LABEL,
602 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
603 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
604 __pScrollPanel->AddControl(*__pDetail_FileInfo_Label[i]);
606 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
607 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
608 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
609 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
611 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
613 if (i == DETAIL_COUNT_MAX - 1)
615 __pDetail_FileInfo_Value_Label[i]->Construct(
616 Rectangle(X_DETAIL_FILEINFO_LABEL,
617 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
618 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
622 __pDetail_FileInfo_Value_Label[i]->Construct(
623 Rectangle(X_DETAIL_FILEINFO_LABEL,
624 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
625 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
628 __pScrollPanel->AddControl(*__pDetail_FileInfo_Value_Label[i]);
630 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
631 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
632 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
633 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
636 __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
637 __pScrollPanel->SetShowState(false);
639 __pRenameButton = new (std::nothrow) Button();
640 Rectangle rect = GetBounds();
641 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
642 __pRenameButton->SetActionId(ACTION_ID_PANEL_HEADER_DETAILS_RENAME);
643 __pRenameButton->AddActionEventListener(*this);
645 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
646 Bitmap* pIconBackground =
647 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
648 Bitmap* pIconPressed =
649 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
651 if (pIcon != null && pIconPressed != null && pIconBackground != null)
653 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
654 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
655 Point iconPosition(0, 0);
656 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
657 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
661 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
662 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
666 delete pIconBackground;
668 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
669 __pScrollPanel->AddControl(*__pRenameButton);
672 AddControl(*__pScrollPanel);
673 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
679 ImageViewerForm::InitializePopup(void)
681 AppLogDebug("ENTER");
682 if (__pDeletePopup == null)
684 __pDeletePopup = new (std::nothrow) Popup();
685 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
687 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
689 Label* pLabel = new (std::nothrow) Label();
690 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
691 ResourceManager::GetString(L"IDS_COM_BODY_DELETE") + L"?");
693 Button* pDeleteButton = new (std::nothrow) Button();
694 pDeleteButton->Construct(
695 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
696 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
697 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
698 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
699 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
700 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
701 pDeleteButton->AddActionEventListener(*this);
703 Button* pCancelButton = new (std::nothrow) Button();
704 pCancelButton->Construct(
705 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
706 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
707 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
708 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
709 pCancelButton->AddActionEventListener(*this);
711 __pDeletePopup->AddControl(*pLabel);
712 __pDeletePopup->AddControl(*pDeleteButton);
713 __pDeletePopup->AddControl(*pCancelButton);
717 __pDeletePopup->SetShowState(true);
718 __pDeletePopup->Show();
720 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
726 ImageViewerForm::InitializeContextMenuMore(void)
728 AppLogDebug("ENTER");
729 int currentIndex = __pGallery->GetCurrentItemIndex();
730 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
732 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
734 if (__pContextMenuMore != null)
736 delete __pContextMenuMore;
737 __pContextMenuMore = null;
740 __pContextMenuMore = new (std::nothrow) ContextMenu();
742 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
743 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
745 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
747 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
748 ACTION_ID_CONTEXTMENU_SET_AS);
749 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), ACTION_ID_FOOTER_BUTTON_CROP);
752 if (__pGallery->GetItemCount() > 1)
754 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
755 ACTION_ID_FOOTER_BUTTON_SLIDE);
757 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
758 ACTION_ID_FOOTER_BUTTON_DETAILS);
759 __pContextMenuMore->SetShowState(false);
760 __pContextMenuMore->AddActionEventListener(*this);
761 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
767 ImageViewerForm::InitializeContextMenuSetAs(void)
769 AppLogDebug("ENTER");
771 if (__pContextMenuSetAs != null)
773 delete __pContextMenuSetAs;
774 __pContextMenuSetAs = null;
777 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
778 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
779 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
781 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
782 ACTION_ID_CONTEXTMENU_HOME);
783 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
784 ACTION_ID_CONTEXTMENU_LOCK);
785 __pContextMenuSetAs->AddItem(L"Home and lock screens", ACTION_ID_CONTEXTMENU_HOME_AND_LOCK);
786 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
787 ACTION_ID_CONTEXTMENU_CALLER);
788 __pContextMenuSetAs->AddActionEventListener(*this);
789 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
795 ImageViewerForm::InitializeContextMenuShare(void)
797 AppLogDebug("ENTER");
798 if (__pContextMenuShare != null)
800 delete __pContextMenuShare;
801 __pContextMenuShare = null;
803 __pContextMenuShare = new (std::nothrow) ContextMenu();
804 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
805 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
806 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
808 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
809 ACTION_ID_CONTEXTMENU_MESSAGE);
810 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
811 __pContextMenuShare->AddActionEventListener(*this);
812 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
818 ImageViewerForm::GetFileSize(String filePath)
820 AppLogDebug("ENTER");
824 result r = File::GetAttributes(filePath, attr);
827 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
831 size = attr.GetFileSize();
832 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
838 ImageViewerForm::SetDetailInfo(void)
840 AppLogDebug("ENTER");
842 Rectangle clientRect = GetClientAreaBounds();
843 __pScrollPanel->SetBounds(0, 0, clientRect.width, clientRect.height);
845 int currentIndex = __pGallery->GetCurrentItemIndex();
846 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
848 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
850 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
852 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
853 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
856 result r = File::GetAttributes(strFilePath, attr);
859 long long nSize = attr.GetFileSize();
860 DateTime dateTime = attr.GetDateTime();
861 strResult[2] = dateTime.ToString();
863 if (nSize > SINGLE_GIGA_BYTE)
865 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
866 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
868 else if (nSize > SINGLE_MEGA_BYTE)
870 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
871 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
873 else if (nSize > SINGLE_KILO_BYTE)
875 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
876 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
880 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
881 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
886 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
887 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
890 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
891 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
892 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
893 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
894 strResult[8] = strFilePath;
895 String fileName = File::GetFileName(strFilePath);
896 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
898 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
900 strResult[0] = __downLordFileName;
902 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
904 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
906 if (pImgMeta != null)
908 ImageContentInfo imageContentInfo;
909 r = imageContentInfo.Construct(&strFilePath);
912 strResult[1] = imageContentInfo.GetMediaFormat();
913 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
914 pImgMeta->GetHeight());
916 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
918 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
921 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
923 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
924 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
930 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
932 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
933 if (pVideoMeta != null)
935 VideoContentInfo videoContentInfo;
936 r = videoContentInfo.Construct(&strFilePath);
939 strResult[1] = videoContentInfo.GetMediaFormat();
940 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
941 pVideoMeta->GetHeight());
942 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
944 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
950 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
952 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
953 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
956 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
958 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
962 Rectangle rect = GetBounds();
963 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
965 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
971 ImageViewerForm::ShowPanelDetail(bool showStatus)
973 AppLogDebug("ENTER");
977 __pScrollPanel->SetShowState(true);
982 __pScrollPanel->SetShowState(false);
985 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
991 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
993 AppLogDebug("ENTER");
994 FooterItem footerItem;
995 footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
996 Bitmap* pfooterItem = null;
1000 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1001 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1005 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1006 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1009 pFooter->SetItemAt(position, footerItem);
1010 pFooter->Invalidate(true);
1013 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1019 ImageViewerForm::DownloadFile(void)
1021 AppLogDebug("ENTER");
1022 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1023 if (File::IsFileExist(DestPath) == false)
1025 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1029 ContentId contentId;
1030 ContentManager contentManager;
1031 contentManager.Construct();
1033 ImageContentInfo imageContentInfo;
1034 imageContentInfo.Construct(null);
1036 imageContentInfo.SetKeyword(L"platform, tizen");
1037 String sourcePath = DestPath;
1038 String destPath = Environment::GetMediaPath();
1039 destPath.Append(FOLDER_PATH_DOWNLOADS);
1040 destPath.Append(__downLordFileName);
1042 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1043 ImageViewerForm::OnFormBackRequested(*this);
1044 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1048 ImageViewerForm::GetItemCount(void)
1050 AppLogDebug("ENTER");
1051 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1053 return __pPresentationModel->GetFileCount();
1057 ImageViewerForm::CreateItem(int index)
1059 AppLogDebug("ENTER : index(%d)", index);
1060 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1062 String filePath = __pPresentationModel->GetFilePathAt(index);
1063 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1064 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1065 if (pBitmap == null)
1067 pBitmap = GetQuickThumbnailN(filePath);
1069 if (pBitmap == null)
1071 pBitmap = new (std::nothrow) Bitmap();
1072 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1075 pGallery->Construct(*pBitmap, filePath);
1077 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1083 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1085 AppLogDebug("ENTER index(%d)", index);
1086 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1087 pImageInfo->ClearBitmap();
1089 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1095 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1097 AppLogDebug("ENTER index(%d)", index);
1099 String filePath = __pPresentationModel->GetFilePathAt(index);
1100 AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1101 __pPresentationModel->RequestImage(filePath);
1104 String strItemIdxText;
1105 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
1106 __pHeader->SetTitleText(strItemText);
1107 __pHeader->SetDescriptionText(strItemIdxText);
1109 if (__visible == true)
1111 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1112 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1114 __pPlayButton->SetShowState(true);
1118 __pPlayButton->SetShowState(false);
1123 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1127 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1129 AppLogDebug("ENTER");
1131 String filePath = __pPresentationModel->GetFilePathAt(index);
1132 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1134 if (__visible == true)
1136 if (contentType == CONTENT_TYPE_VIDEO)
1138 __pPlayButton->SetShowState(false);
1141 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
1146 if (contentType == CONTENT_TYPE_VIDEO)
1148 __pPlayButton->SetShowState(true);
1151 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
1154 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1155 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1158 Rectangle clientRect = GetClientAreaBounds();
1159 Rectangle rect = GetBounds();
1160 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1162 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1166 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1168 AppLogDebug("ENTER");
1169 PowerManager::KeepScreenOnState(true, false);
1170 if (__visible == true)
1172 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
1174 int index = __pGallery->GetCurrentItemIndex();
1175 String filePath = __pPresentationModel->GetFilePathAt(index);
1176 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1178 if (contentType == CONTENT_TYPE_VIDEO)
1180 __pPlayButton->SetShowState(false);
1186 Rectangle clientRect = GetClientAreaBounds();
1187 Rectangle rect = GetBounds();
1188 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1190 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1194 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1196 AppLogDebug("ENTER");
1197 PowerManager::KeepScreenOnState(false, true);
1198 int index = __pGallery->GetCurrentItemIndex();
1200 if (__visible == false)
1202 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
1204 String filePath = __pPresentationModel->GetFilePathAt(index);
1205 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1206 if (contentType == CONTENT_TYPE_VIDEO)
1208 __pPlayButton->SetShowState(true);
1211 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1212 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1218 String strItemIdxText;
1219 GetHeaderString(index, strItemText, strItemIdxText);
1220 __pHeader->SetTitleText(strItemText);
1221 __pHeader->SetDescriptionText(strItemIdxText);
1223 Rectangle clientRect = GetClientAreaBounds();
1224 Rectangle rect = GetBounds();
1225 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1228 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1232 ImageViewerForm::OnUpdateContentList(void)
1237 ImageViewerForm::OnTerminating(void)
1239 AppLogDebug("ENTER");
1241 if (__pTimer != null)
1248 __pPresentationModel->ClearImageRequests();
1249 __pPresentationModel->RemoveListener(*this);
1250 __pPresentationModel->RemoveFileUpdateListener(*this);
1252 if (__pContextMenuCopy != null)
1254 delete __pContextMenuCopy;
1255 __pContextMenuCopy = null;
1258 if (__pContextMenuSetAs != null)
1260 delete __pContextMenuSetAs;
1261 __pContextMenuSetAs = null;
1264 if (__pDeletePopup != null)
1266 delete __pDeletePopup;
1267 __pDeletePopup = null;
1270 if (__pContextMenuShare != null)
1272 delete __pContextMenuShare;
1273 __pContextMenuShare = null;
1276 if (__pContextMenuMore != null)
1278 delete __pContextMenuMore;
1279 __pContextMenuMore = null;
1282 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1288 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1290 AppLogDebug("ENTER actionId(%d)", actionId);
1291 SceneManager* pSceneManager = SceneManager::GetInstance();
1296 case ACTION_ID_FOOTER_MORE:
1298 InitializeContextMenuMore();
1300 __pContextMenuMore->SetShowState(true);
1301 __pContextMenuMore->Show();
1304 case ACTION_ID_CONTEXTMENU_SET_AS:
1305 InitializeContextMenuSetAs();
1307 __pContextMenuSetAs->SetShowState(true);
1308 __pContextMenuSetAs->Show();
1310 case ACTION_ID_FOOTER_BUTTON_SHARE:
1311 InitializeContextMenuShare();
1313 __pContextMenuShare->SetShowState(true);
1314 __pContextMenuShare->Show();
1316 case ACTION_ID_FOOTER_BUTTON_DELETE:
1317 __pDeletePopup->SetShowState(true);
1318 __pDeletePopup->Show();
1320 case ACTION_ID_FOOTER_BUTTON_SLIDE:
1322 int repeatValue = 0;
1324 if (__pPresentationModel->GetFileCount() > 1)
1326 __pGallery->UpdateGallery();
1327 if (__detail == false)
1329 ShowPanelDetail(false);
1332 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1333 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1335 if (repeatValue == 0)
1337 __pGallery->StartSlideShow(false);
1341 __pGallery->StartSlideShow(true);
1346 case ACTION_ID_FOOTER_BUTTON_CROP:
1349 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1350 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1351 pList->Add(new (std::nothrow) String(filePath));
1352 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1355 case ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT:
1357 int currentIndex = __pGallery->GetCurrentItemIndex();
1358 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1359 RotateMode rotateMode = ROTATE_MODE_RIGHT;
1360 __pPresentationModel->SetImageRotateStatus(true);
1361 RotateImage(filePath, rotateMode);
1362 __pPresentationModel->RequestImage(filePath);
1364 ContentManager contentManager;
1365 contentManager.Construct();
1366 contentManager.ScanFile(filePath);
1369 case ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT:
1371 int currentIndex = __pGallery->GetCurrentItemIndex();
1372 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1373 RotateMode rotateMode = ROTATE_MODE_LEFT;
1374 __pPresentationModel->SetImageRotateStatus(true);
1375 RotateImage(filePath, rotateMode);
1376 __pPresentationModel->RequestImage(filePath);
1378 ContentManager contentManager;
1379 contentManager.Construct();
1380 contentManager.ScanFile(filePath);
1383 case ACTION_ID_FOOTER_BUTTON_DETAILS:
1385 ShowPanelDetail(__detail);
1388 case ACTION_ID_FOOTER_BUTTON_BACK:
1389 ImageViewerForm::OnFormBackRequested(*this);
1391 case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1394 case ACTION_ID_FOOTER_BUTTON_SAVE:
1396 case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1398 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1399 pSelectedIndex->Construct();
1400 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1401 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1404 case ACTION_ID_CONTEXTMENU_HOME:
1406 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1407 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1408 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1409 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1410 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1413 case ACTION_ID_CONTEXTMENU_LOCK:
1415 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1416 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1417 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1418 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1419 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1422 case ACTION_ID_CONTEXTMENU_CALLER:
1424 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1425 pDataList->Construct();
1426 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1427 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1428 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1429 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1430 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1431 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1433 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1434 APPCONTROL_OPERATION_ID_PICK, null, pDataList, this);
1438 case ACTION_ID_CONTEXTMENU_HOME_AND_LOCK:
1440 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1441 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1442 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
1443 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1444 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1449 case ACTION_ID_CONTEXTMENU_EMAIL:
1451 OnRequestEmailAction();
1454 case ACTION_ID_CONTEXTMENU_MESSAGE:
1456 OnRequestMessagesAction();
1459 case ACTION_ID_CONTEXTMENU_COPY:
1461 int currentIndex = __pGallery->GetCurrentItemIndex();
1462 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1465 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1466 Clipboard* pClipboard = Clipboard::GetInstance();
1467 pClipboard->CopyItem(item);
1470 case ACTION_ID_DELETE_POPUP_DEL:
1472 __pDeletePopup->SetShowState(false);
1473 __pDeletePopup->Show();
1476 if (__detail == false)
1478 ShowPanelDetail(false);
1482 case ACTION_ID_DELETE_POPUP_CANCEL:
1484 __pDeletePopup->SetShowState(false);
1485 __pDeletePopup->Show();
1488 case ACTION_ID_CONTORL_BUTTON_PLAY:
1494 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1498 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
1500 result r = E_SUCCESS;
1501 ImageBuffer* pRotatedBuffer = null;
1502 ImageBuffer* pRotatedBuffer1 = null;
1503 ImageFormat imageFormat;
1506 pRotatedBuffer = new (std::nothrow) ImageBuffer();
1507 r = pRotatedBuffer->Construct(filePath);
1508 pRotatedBuffer->GetImageInfo(filePath, imageFormat, width, height);
1511 if (rotateMode == ROTATE_MODE_RIGHT)
1513 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_90);
1517 pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_270);
1520 TryCatch(pRotatedBuffer1 != null, r = GetLastResult(), "RotateN failed:%s", GetErrorMessage(GetLastResult()));
1521 pRotatedBuffer1->EncodeToFile(filePath, imageFormat, true, 100);
1522 delete pRotatedBuffer1;
1523 delete pRotatedBuffer;
1527 if (pRotatedBuffer != null) //this buffer is no longer used
1529 delete pRotatedBuffer;
1531 if (pRotatedBuffer1 != null) //this buffer is no longer used
1533 delete pRotatedBuffer1;
1539 ImageViewerForm::OnFormBackRequested(Form& source)
1541 AppLogDebug("ENTER");
1542 if (__detail == false)
1544 ShowPanelDetail(false);
1548 UiApp* pApp = UiApp::GetInstance();
1551 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1555 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1556 const SceneId& currentSceneId, IList* pArgs)
1558 AppLogDebug("ENTER");
1560 Rectangle clientRect = GetClientAreaBounds();
1561 Rectangle rect = GetBounds();
1563 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1564 __pScrollPanel->SetBounds(Rectangle(0, 0, clientRect.width, clientRect.height));
1565 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1567 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1570 String strItemText(EMPTY_SPACE);
1571 String strItemIdxText(EMPTY_SPACE);
1572 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
1573 __pHeader->SetTitleText(strItemText);
1574 __pHeader->SetDescriptionText(strItemIdxText);
1578 if (__pGallery->GetCurrentItemIndex() < 0)
1580 SetFooterItemState(false);
1584 SetFooterItemState(true);
1587 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1591 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1592 const SceneId& nextSceneId)
1594 AppLogDebug("ENTER");
1595 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1599 ImageViewerForm::OnImageDecodedN(const int index)
1601 AppLogDebug("ENTER");
1602 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1604 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1608 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1609 const String& operationId, AppCtrlResult appControlResult,
1610 const IMap* pExtraData)
1612 AppLogDebug("ENTER");
1614 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1615 && operationId == APPCONTROL_OPERATION_ID_PICK
1616 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1618 const String* pContactId =
1619 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1620 SceneManager* pSceneManager = SceneManager::GetInstance();
1621 long long lresult = 0;
1622 if (pContactId != null && pContactId->GetLength() > 0)
1624 LongLong::Parse(*pContactId, lresult);
1626 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1627 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1628 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1629 pList->Add(new (std::nothrow) LongLong(lresult));
1630 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1631 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1634 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1635 pImageViewerApp->SetFrameEnabled(true);
1636 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1640 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1642 AppLogDebug("ENTER");
1643 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1647 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1649 AppLogDebug("ENTER");
1650 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1654 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1656 AppLogDebug("ENTER");
1657 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1661 ImageViewerForm::OnOtherControlSelected(const Control& source)
1663 AppLogDebug("ENTER");
1664 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1668 ImageViewerForm::InitShowGallery(void)
1670 AppLogDebug("ENTER");
1671 if (__pGallery != null && __pGallery->IsVisible() == false)
1673 Canvas* pCanvas = GetCanvasN();
1674 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1676 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1682 __pGallery->SetShowState(true);
1685 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1689 ImageViewerForm::OnTimerExpired(Timer &timer)
1691 int repeatValue = 0;
1692 AppLogDebug("ENTER");
1693 if (__pPresentationModel->GetFileCount() > 1)
1695 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1696 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1698 if (repeatValue == 0)
1700 __pGallery->StartSlideShow(false);
1704 __pGallery->StartSlideShow(true);
1707 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1711 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1713 AppLogDebug("ENTER");
1714 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1718 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1719 const String& errorMessage)
1721 AppLogDebug("ENTER");
1722 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1726 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1727 result transferResult, const String& errorCode, const String& errorMessage)
1729 AppLogDebug("ENTER");
1730 AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1731 AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1732 AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1733 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1737 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1738 const String& errorCode, const String& errorMessage)
1740 AppLogDebug("ENTER");
1741 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1745 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1746 const String& errorMessage)
1748 AppLogDebug("ENTER");
1749 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1753 ImageViewerForm::RequestDecodeUrl(void)
1755 AppLogDebug("ENTER");
1757 String filePath = __pPresentationModel->GetFilePathAt(0);
1759 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1761 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1766 __downLordFileName = __pPresentationModel->GetFileName(filePath);
1768 Image* pImage = new (std::nothrow) Image();
1769 pImage->Construct();
1772 uri.SetUri(filePath);
1774 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1777 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1781 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1782 result r, const String errorCode, const String errorMessage)
1784 AppLogDebug("ENTER");
1785 Image* pImage = new (std::nothrow) Image();
1786 pImage->Construct();
1788 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1789 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1793 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1794 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1796 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1798 __pPresentationModel->RequestImage(destPath);
1802 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1806 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1810 ImageViewerForm::OnRequestEmailAction(void)
1812 AppLogDebug("ENTER");
1813 int currentIndex = __pGallery->GetCurrentItemIndex();
1815 if (__pPresentationModel->GetFileCount() <= 0)
1817 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1821 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1823 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1824 pDataList->Construct();
1826 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1827 pList->Add(new (std::nothrow) String(filePath));
1829 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1831 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
1832 null, pDataList, this);
1833 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1837 ImageViewerForm::OnRequestMessagesAction(void)
1839 AppLogDebug("ENTER");
1840 int currentIndex = __pGallery->GetCurrentItemIndex();
1842 if (__pPresentationModel->GetFileCount() <= 0)
1844 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1848 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1850 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1851 pDataList->Construct();
1852 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE),
1853 new (std::nothrow) String(APPCONTROL_DATA_MMS));
1855 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1856 pList->Add(new (std::nothrow) String(filePath));
1858 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1860 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES,
1861 APPCONTROL_OPERATION_ID_COMPOSE, null, pDataList, this);
1862 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1866 ImageViewerForm::SetFooterItemState(bool isEnable)
1868 AppLogDebug("ENTER");
1869 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
1871 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1872 __pFooter->SetItemEnabled(0, isEnable);
1873 __pFooter->SetItemEnabled(1, isEnable);
1875 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1877 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1878 __pFooter->SetItemEnabled(0, isEnable);
1879 __pFooter->SetItemEnabled(1, isEnable);
1881 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
1883 __pFooter->SetItemEnabled(0, isEnable);
1885 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1889 ImageViewerForm::GetQuickThumbnailN(String& filePath)
1891 AppLogDebug("ENTER");
1892 Bitmap* pBitmap = null;
1894 if (filePath.GetLength() > 4)
1898 ContentSearch contentSearch;
1899 ContentSearchResult* pResultItem = null;
1900 IList* pContentInfoList = null;
1902 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1903 result r = contentSearch.Construct(contentType);
1904 AppLogDebug("r(%s)", GetErrorMessage(r));
1907 pBitmap = new (std::nothrow) Bitmap();
1908 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1919 queryString = CONTENT_QUERY_PREFIX_FILENAME;
1920 queryString.Append(L"'");
1921 queryString.Append(__pPresentationModel->GetFileName(filePath));
1922 queryString.Append(L"'");
1924 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
1925 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
1927 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
1929 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
1930 while (pEnum->MoveNext() == E_SUCCESS)
1932 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
1933 if (pResultItem == null)
1938 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
1940 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
1946 if (pContentInfoList != null)
1948 delete pContentInfoList;
1951 if (pBitmap != null)
1953 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1955 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1957 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
1958 result r = imageBuffer->Construct(filePath);
1961 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
1962 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
1964 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
1965 pBitmap->Scale(srcDim);
1969 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
1970 pBitmap->Scale(srcDim);
1976 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1978 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
1980 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
1982 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
1983 pBitmap->Scale(srcDim);
1991 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
1992 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
1993 pBitmap = new (std::nothrow) Bitmap();
1994 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
1997 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
2001 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
2003 AppLogDebug(" ENTER");
2004 bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF);
2005 bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
2007 int currentIndex = __pGallery->GetCurrentItemIndex();
2008 int countPath = __pPresentationModel->GetFileCount();
2010 if (countPath == 0 && eventDelete)
2012 UiApp* pApp = UiApp::GetInstance();
2014 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
2016 AppLogDebug(" countPath is %d", countPath);
2017 AppLogDebug(" currentIndex is %d", currentIndex);
2019 if (countPath == currentIndex && eventDelete)
2021 __pGallery->SetCurrentItemIndex(--currentIndex);
2025 currentIndex = index;
2026 __pGallery->SetCurrentItemIndex(currentIndex);
2029 String strItemText(EMPTY_SPACE);
2030 String strItemIdxText(EMPTY_SPACE);
2032 __pGallery->UpdateGallery();
2033 AppLogDebug(" UpdateGallery is %d", currentIndex);
2034 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
2035 __pPresentationModel->RequestImage(filePath);
2037 GetHeaderString(currentIndex, strItemText, strItemIdxText);
2038 __pHeader->SetTitleText(strItemText);
2039 __pHeader->SetDescriptionText(strItemIdxText);
2041 if (__visible == true)
2043 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
2045 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
2047 __pPlayButton->SetShowState(false);
2051 __pPlayButton->SetShowState(true);
2054 if (__detail == false)
2056 __pScrollPanel->SetShowState(false);
2061 AppLogDebug("EXIT");