Arrange code
[apps/osp/Gallery.git] / src / GlAlbumNameEditorForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                GlAlbumNameEditorForm.cpp
19  * @brief               This is the implementation file for AlbumNameEditorForm class.
20  */
21
22 #include <FMedia.h>
23 #include <FText.h>
24
25 #include "GlAlbumInfo.h"
26 #include "GlAlbumListPresentationModel.h"
27 #include "GlAlbumNameEditorForm.h"
28 #include "GlFileListPresentationModel.h"
29 #include "GlFileMoveTimer.h"
30 #include "GlProgressAnimation.h"
31 #include "GlResourceManager.h"
32 #include "GlTypes.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Base::Runtime;
38 using namespace Tizen::Base::Utility;
39 using namespace Tizen::Content;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Io;
42 using namespace Tizen::Media;
43 using namespace Tizen::System;
44 using namespace Tizen::Text;
45 using namespace Tizen::Ui;
46 using namespace Tizen::Ui::Controls;
47 using namespace Tizen::Ui::Scenes;
48
49 static const unsigned int COLOR_NAME_EDIT_FIELD = Color32<255, 255, 255>::Value;
50
51 AlbumNameEditorForm::AlbumNameEditorForm(void)
52         : __pNameEditField(null)
53         , __folderIndex(0)
54         , __modalMsgBoxResult(0)
55         , __textLength(0)
56         , __mountState(false)
57         , __albumNameEditorMode(ALBUM_NAME_EDITOR_MODE_RENAME)
58         , __pMessageBox(null)
59         , __pMoveIndexList(null)
60         , __fileActionMode(FILE_ACTION_MOVE)
61         , __pFileMove(null)
62         , __pProgressAnim(null)
63         , __pPresentationModel(null)
64         , __pFilePresentationModel(null)
65 {
66         AppLogDebug("ENTER");
67         _overlayMsg = false;
68         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
69 }
70
71 AlbumNameEditorForm::~AlbumNameEditorForm(void)
72 {
73         AppLogDebug("ENTER");
74         DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
75         delete __pFileMove;
76         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
77 }
78
79 result
80 AlbumNameEditorForm::Initialize(void)
81 {
82         AppLogDebug("ENTER");
83         result r = Construct(L"IDL_FORM_ALBUM_NAME_EDITOR");
84         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
85
86         return r;
87 }
88
89 result
90 AlbumNameEditorForm::OnInitializing(void)
91 {
92         AppLogDebug("ENTER");
93         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
94         __pFilePresentationModel = FileListPresentationModel::GetInstance();
95
96         SetOrientation(ORIENTATION_AUTOMATIC);
97                 AddOrientationEventListener(*this);
98
99         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
100         Header* pHeader = GetHeader();
101
102         pHeader->SetStyle(HEADER_STYLE_TITLE);
103
104         FooterItem itemSave;
105         itemSave.Construct(IDA_BUTTON_CREATE_NAME_SAVE);
106         itemSave.SetText(ResourceManager::GetString(L"IDS_COM_OPT_SAVE"));
107
108         GetFooter()->AddItem(itemSave);
109         GetFooter()->AddActionEventListener(*this);
110         GetFooter()->Invalidate(true);
111
112         SetFormBackEventListener(this);
113         SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
114
115         __pNameEditField = static_cast<EditField*>(GetControl(L"IDC_EDITFIELD_NAME"));
116         __pNameEditField->AddTextEventListener(*this);
117         __pNameEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_NAME_EDIT_FIELD);
118         __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
119         __pNameEditField->AddActionEventListener(*this);
120
121         return E_SUCCESS;
122 }
123
124 void
125 AlbumNameEditorForm::OnTextValueChanged(const Control& source)
126 {
127         String currentInput;
128         String currentText;
129         String specialCharacters(L"/");
130         String byteCountForInput;
131         int byteCount = 0;
132         int inputLength = 0;
133         int tempLength = 255;
134         int textToCheck = 0;
135         MessageBox messageBox;
136         Utf8Encoding utf8;
137
138         FooterItemStatus currentStatus = FOOTER_ITEM_STATUS_NORMAL;
139
140         result r = E_SUCCESS;
141
142         if (__pNameEditField != null)
143         {
144                 byteCountForInput = __pNameEditField->GetText();
145                 r = utf8.GetByteCount(byteCountForInput, byteCount);
146                 AppLogDebug("result is %s",GetErrorMessage(r));
147                 AppLogDebug("Byte count is %d",byteCount);
148         }
149
150         if (__pNameEditField != null)
151         {
152                 currentText = __pNameEditField->GetText();
153                 textToCheck = currentText.GetLength() - __textLength;
154                 if (currentText.IsEmpty())
155                 {
156                         if (GetFooter() != null)
157                         {
158                                 GetFooter()->SetItemEnabled(0, false);
159                                 GetFooter()->Invalidate(true);
160                         }
161                 }
162                 else
163                 {
164                         if (GetFooter() != null)
165                         {
166                                 GetFooter()->GetItemStatus(0, currentStatus);
167
168                                 if (currentStatus == FOOTER_ITEM_STATUS_DISABLED)
169                                 {
170                                         GetFooter()->SetItemEnabled(0,true);
171                                         GetFooter()->Invalidate(true);
172                                 }
173                         }
174                 }
175
176                 if (currentText.StartsWith(".", 0))
177                 {
178                         String invalidCharacterString;
179                         String validString;
180                         String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
181                         CreateMessage(msg);
182                         validString = __pNameEditField->GetText();
183
184                         if (validString.GetLength() > 1)
185                         {
186                                 validString.Remove(0,1);
187                                 __pNameEditField->SetText(validString);
188                         }
189                         else
190                         {
191                                 __pNameEditField->SetText("");
192
193                                 if (GetFooter() != null)
194                                 {
195                                         GetFooter()->SetItemEnabled(0, false);
196                                         GetFooter()->Invalidate(true);
197                                 }
198                         }
199                         __pNameEditField->ShowKeypad();
200                 }
201
202                 currentInput = __pNameEditField->GetText();
203
204                 if (currentInput.Contains(specialCharacters[0]))
205                 {
206                         String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
207                         CreateMessage(msg);
208                         currentInput.Replace("/", "");
209                         __pNameEditField->SetText(currentInput);
210                 }
211
212                 inputLength = byteCount;
213                 if (inputLength  >= tempLength)
214                 {
215                         String maxCharacterString;
216                         String currentInputCharacter;
217                         int checkByteCount = 0;
218                         int lengthOfFinalString = 0;
219                         int currentCharacter = 0;
220
221                         String msg = ResourceManager::GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED");
222                         CreateMessage(msg);
223                         currentText = __pNameEditField->GetText();
224
225                         for (currentCharacter=0; checkByteCount < tempLength; ++currentCharacter)
226                         {
227                                 currentInputCharacter.Clear();
228                                 currentInputCharacter = currentText[currentCharacter];
229                                 r = utf8.GetByteCount(currentInputCharacter, byteCount);
230                                 if (r != E_SUCCESS)
231                                 {
232                                         break;
233                                 }
234                                 AppLogDebug("result of byte count is %s",GetErrorMessage(r));
235                                 checkByteCount = checkByteCount + byteCount;
236
237                                 if (checkByteCount < tempLength)
238                                 {
239                                         ++lengthOfFinalString;
240                                 }
241                         }
242
243                         r = __pNameEditField->GetText().SubString(0, lengthOfFinalString, currentInput);
244                         AppLogDebug("current input is %S", currentInput.GetPointer());
245                         r = __pNameEditField->SetText(currentInput);
246                         __pNameEditField->ShowKeypad();
247                         return;
248                 }
249
250                 r = utf8.GetByteCount(__pNameEditField->GetText(), byteCount);
251                 __textLength = byteCount;
252         }
253
254         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
255 }
256
257 void
258 AlbumNameEditorForm::OnTextValueChangeCanceled(const Control& source)
259 {
260         AppLogDebug("ENTER");
261         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
262 }
263
264 result
265 AlbumNameEditorForm::OnTerminating(void)
266 {
267         AppLogDebug("ENTER");
268         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
269
270         return E_SUCCESS;
271 }
272
273 void AlbumNameEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
274 {
275         Invalidate(true);
276 }
277
278 void AlbumNameEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
279 {
280         _overlayMsg = false;
281         if (res != COMPLETE_SUCCESS)
282         {
283                 __pNameEditField->SetText(__nameEditFieldPreText);
284                 __pNameEditField->HideKeypad();
285                 __pNameEditField->Draw();
286                 SceneManager* pSceneManager = SceneManager::GetInstance();
287                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
288         }
289 }
290
291 void
292 AlbumNameEditorForm::OnRenameAlbum(String& strOri)
293 {
294         AppLogDebug("Rename Album");
295         String path;
296         int index = 0;
297         strOri.Reverse();
298         strOri.IndexOf(DIRECTORY_SEPARATOR, 0, index);
299         strOri.Reverse();
300         strOri.SubString(0, (strOri.GetLength() - index), path);
301         path.Append(__nameEditFieldText);
302
303         //Rename
304         result r = __pPresentationModel->RenameAlbum(strOri, path, this);
305
306         if (IsFailed(r))
307         {
308                 AppLogDebug("Unable to rename Album %s", GetErrorMessage(r));
309                 if (__pMessageBox == null)
310                 {
311                         __pMessageBox = new (std::nothrow) MessageBox();
312                         if (r == E_FILE_ALREADY_EXIST)
313                         {
314                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_BODY_UNABLE_TO_RENAME_ALBUM_NAME_ALREADY_IN_USE_ABB"),
315                                                           MSGBOX_STYLE_NONE, 3000);
316
317                         }
318                         else
319                         {
320                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_POP_UNABLE_TO_RENAME"),
321                                                           MSGBOX_STYLE_NONE, 3000);
322                         }
323                         int modalResult = 0;
324                         _overlayMsg = true;
325                         __pMessageBox->ShowAndWait(modalResult);
326                         _overlayMsg = false;
327                         delete __pMessageBox;
328                         __pMessageBox = null;
329                         __pNameEditField->SetEnabled(true);
330                         __pNameEditField->ShowKeypad();
331                 }
332         }
333         else
334         {
335                 //Add a popup here
336                 Rectangle clientRect = GetClientAreaBounds();
337                 Rectangle rect(0, 0, clientRect.width, clientRect.height);
338                 __pProgressAnim = new (std::nothrow) ProgressAnimation;
339                 __pProgressAnim->Construct(rect);
340                 AddControl(__pProgressAnim);
341                 __pProgressAnim->SetShowState(true);
342                 GetFooter()->SetEnabled(false);
343                 __pProgressAnim->AnimationStart();
344                 __pProgressAnim->Draw();
345                 _overlayMsg = true;
346         }
347 }
348
349 void
350 AlbumNameEditorForm::OnCreateAlbum(void)
351 {
352         String path;
353         __pNameEditField->HideKeypad();
354         __pNameEditField->RequestRedraw();
355         path.Append(Tizen::System::Environment::GetMediaPath());
356         path.Append(__nameEditFieldText);
357
358         if (__previousSceneId != IDSCN_ALL_LIST_EDITOR && __previousSceneId != IDSCN_ALL_LIST_SELECTION)
359         {
360                 Directory::Create(path, true);
361         }
362
363         __nameEditFieldPreText = __nameEditFieldText;
364
365         if (path.IsEmpty())
366         {
367                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
368                 delete __pMoveIndexList;
369                 __pMoveIndexList = null;
370                 return;
371         }
372
373         if (__pMoveIndexList == null || __pMoveIndexList->GetCount() <= 0)
374         {
375                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
376                 delete __pMoveIndexList;
377                 __pMoveIndexList = null;
378                 return;
379         }
380
381         delete __pFileMove;
382         GetMoveFileIndexList(path, __pMoveIndexList, __pFilePresentationModel);
383         __pFileMove = new (std::nothrow) FileMoveTimer(path, __pMoveIndexList, __pFilePresentationModel, this);
384         if (__fileActionMode == FILE_ACTION_COPY)
385         {
386                 AppLogDebug("Rash: Setting to Copy in AlbumNameEditor");
387                 __pFileMove->SetCopy();
388         }
389         else
390         {
391                 __pFileMove->ClearCopy();
392         }
393         result r = __pFileMove->StartTimer();
394
395         if (IsFailed(r))
396         {
397                 delete __pFileMove;
398                 __pFileMove = null;
399                 __pNameEditField->SetText(__nameEditFieldPreText);
400                 __pNameEditField->HideKeypad();
401                 __pNameEditField->Draw();
402                 AppLogDebug("MoveToContentFileList content failed (%s)", GetErrorMessage(r));
403                 SceneManager* pSceneManager = SceneManager::GetInstance();
404                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
405         }
406         else
407         {
408                 AppLogDebug("MoveToContentFileList content in progress");
409                 _overlayMsg = true;
410                 __fileActionMode = FILE_ACTION_MOVE;
411         }
412 }
413
414 void AlbumNameEditorForm::OnAlbumRenameComplete(void)
415 {
416         //Hide popup here..
417         __pProgressAnim->AnimationStop();
418         __pProgressAnim->SetShowState(false);
419         RemoveControl(__pProgressAnim);
420         _overlayMsg = false;
421         GetFooter()->SetEnabled(true);
422         SceneManager* pSceneManager = SceneManager::GetInstance();
423         pSceneManager->GoBackward((BackwardSceneTransition(IDSCN_ALBUM_LIST)));
424 }
425
426 void
427 AlbumNameEditorForm::OnActionPerformed(const Control& source, int actionId)
428 {
429         AppLogDebug("ENTER");
430         String path;
431         __nameEditFieldText = __pNameEditField->GetText();
432
433         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
434         {
435                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
436                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
437                 path = pAlbumInfo->GetDirectory(0);
438         }
439
440         switch (actionId)
441         {
442         case IDA_BUTTON_CREATE_NAME_SAVE:
443         {
444                 __pNameEditField->SetEnabled(false);
445
446                 if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
447                 {
448                         OnCreateAlbum();
449                 }
450                 else if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
451                 {
452                         String albumName = __pNameEditField->GetText();
453                         if (__originalText.Equals(albumName, true))
454                         {
455                                 SceneManager* pSceneManager = SceneManager::GetInstance();
456                                 pSceneManager->GoBackward(BackwardSceneTransition());
457                         }
458                         else
459                         {
460                                 OnRenameAlbum(path);
461                         }
462                 }
463                 break;
464         }
465
466         default:
467                 break;
468         }
469         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
470 }
471
472 void
473 AlbumNameEditorForm::OnFormBackRequested(Form& source)
474 {
475         AppLogDebug("ENTER");
476         if (__pProgressAnim != null)
477         {
478                 if (__pProgressAnim->GetShowState())
479                 {
480                         return;
481                 }
482         }
483
484         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
485         {
486                 SceneManager* pSceneManager = SceneManager::GetInstance();
487                 pSceneManager->GoForward(ForwardSceneTransition(__callerSceneId));
488         }
489         else
490         {
491                 SceneManager* pSceneManager = SceneManager::GetInstance();
492                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST_EDITOR));
493         }
494         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
495 }
496
497 void
498 AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
499                 const SceneId& currentSceneId, IList* pArgs)
500 {
501         AppLogDebug("ENTER");
502         __pPresentationModel = AlbumListPresentationModel::GetInstance();
503         __previousSceneId = previousSceneId;
504
505         __pNameEditField->SetEnabled(true);
506         __pPresentationModel->AddContentEventListener(this);
507
508         if (pArgs != null)
509         {
510                 Integer* pAlbumTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
511                 if (pAlbumTypePtr->ToInt() == ALBUM_CREATE)
512                 {
513                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_CREATE");
514                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_CREATE;
515                 }
516                 else if (pAlbumTypePtr->ToInt() == ALBUM_RENAME)
517                 {
518                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_RENAME");
519                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_RENAME;
520                 }
521                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
522         }
523
524         if (pArgs != null)
525         {
526                 Integer* operationTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
527                 if (operationTypePtr->ToInt() == FILE_ACTION_MOVE)
528                 {
529                         AppLogDebug("Rash: FILE_MOVE_ACTION");
530                         __fileActionMode = FILE_ACTION_MOVE;
531                 }
532                 else if (operationTypePtr->ToInt() == FILE_ACTION_COPY)
533                 {
534                         AppLogDebug("Rash: FILE_COPY_ACTION");
535                         __fileActionMode = FILE_ACTION_COPY;
536                 }
537                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
538         }
539
540         if (previousSceneId == IDSCN_ALBUM_LIST_EDITOR)
541         {
542                 if (pArgs != null)
543                 {
544                         IEnumerator* pEnum = pArgs->GetEnumeratorN();
545                         if (pEnum->MoveNext() == E_SUCCESS)
546                         {
547                                 Integer *index = static_cast<Integer*>(pEnum->GetCurrent());
548                                 if (index != null)
549                                 {
550                                         __folderIndex = index->ToInt();
551                                 }
552                         }
553                         delete pEnum;
554                         delete pArgs;
555                         pArgs = NULL;
556                 }
557         }
558
559         if (previousSceneId == IDSCN_ALL_LIST_EDITOR
560                         || previousSceneId == IDSCN_IMAGE_LIST_EDITOR
561                         || previousSceneId == IDSCN_VIDEO_LIST_EDITOR
562                         || previousSceneId == IDSCN_ALL_LIST_SELECTION)
563         {
564                 if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
565                 {
566                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_EDITOR");
567                 }
568                 else if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
569                 {
570                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_SELECTION");
571                 }
572
573                 __callerSceneId = previousSceneId;
574         }
575         else
576         {
577                 __callerSceneId = EMPTY_SPACE;
578         }
579
580         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
581         {
582                 __nameEditFieldText = EMPTY_SPACE;
583                 __nameEditFieldPreText = EMPTY_SPACE;
584                 __pNameEditField->SetText(__nameEditFieldText);
585                 __nameEditFieldTempText = __nameEditFieldText;
586                 __pNameEditField->ShowKeypad();
587                 __pNameEditField->SetFocus();
588
589                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"));
590                 GetFooter()->SetItemEnabled(0, false);
591                 GetFooter()->Invalidate(true);
592         }
593         else
594         {
595                 int byteCount = 0;
596                 Utf8Encoding utf8;
597                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
598                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
599
600                 String strName = pAlbumInfo->GetAlbumName();
601                 __nameEditFieldText = strName;
602                 __nameEditFieldPreText = strName;
603                 __pNameEditField->SetText(__nameEditFieldText);
604                 __nameEditFieldTempText = __nameEditFieldText;
605                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_RENAME"));
606                 __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
607                 __pNameEditField->ShowKeypad();
608                 __pNameEditField->SetFocus();
609                 __originalText = __pNameEditField->GetText();
610                 utf8.GetByteCount(__nameEditFieldText, byteCount);
611                 __textLength = byteCount;
612                 GetFooter()->SetItemEnabled(0, true);
613                 GetFooter()->Invalidate(true);
614         }
615
616         if (pArgs != NULL)
617         {
618                 __pMoveIndexList = pArgs;
619         }
620
621         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
622 }
623
624 void
625 AlbumNameEditorForm::OnSceneDeactivated(const SceneId& currentSceneId,
626                 const SceneId& nextSceneId)
627 {
628         AppLogDebug("ENTER");
629         __pPresentationModel->RemoveContentEventListener(*this);
630         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
631 }
632
633 void
634 AlbumNameEditorForm::OnContentUpdated(void)
635 {
636         AppLogDebug("ENTER");
637
638         if (__mountState == false)
639         {
640                 SceneManager* pSceneManager = SceneManager::GetInstance();
641                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
642                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
643         }
644         else
645         {
646                 __mountState = false;
647         }
648 }
649
650 void
651 AlbumNameEditorForm::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
652 {
653         AppLogDebug("ENTER");
654
655         if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
656         {
657                 if (__pFileMove && __pFileMove->IsStarted())
658                 {
659                         __pFileMove->Cancel();
660                         delete __pFileMove;
661                         __pFileMove = null;
662                 }
663                 __mountState = false;
664                 SceneManager* pSceneManager = SceneManager::GetInstance();
665                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
666                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
667         }
668         else
669         {
670                 __mountState = true;
671         }
672         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
673 }
674
675 void
676 AlbumNameEditorForm::CreateMessage(String& str)
677 {
678         if (__pMessageBox == null)
679         {
680                 __pMessageBox = new(std::nothrow) MessageBox;
681
682                 if (__pMessageBox != null)
683                 {
684                         __pMessageBox->Construct(L"", str, MSGBOX_STYLE_OK, 3000);
685                         __pMessageBox->ShowAndWait(__modalMsgBoxResult);
686
687                         delete __pMessageBox;
688                         __pMessageBox = null;
689                         __modalMsgBoxResult = 0;
690                 }
691         }
692 }
693
694 void
695 AlbumNameEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
696 {
697         if (__pProgressAnim != NULL)
698         {
699                 __pProgressAnim->ChangeOrientation(GetClientAreaBounds());
700                 __pProgressAnim->Invalidate(true);
701         }
702 }