Fixed issue 43926
[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                         else
318                         {
319                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_POP_UNABLE_TO_RENAME"),
320                                                           MSGBOX_STYLE_NONE, 3000);
321                         }
322                         int modalResult = 0;
323                         _overlayMsg = true;
324                         __pMessageBox->ShowAndWait(modalResult);
325                         _overlayMsg = false;
326                         delete __pMessageBox;
327                         __pMessageBox = null;
328                 }
329         }
330         else
331         {
332                 //Add a popup here
333                 Rectangle clientRect = GetClientAreaBounds();
334                 Rectangle rect(0, 0, clientRect.width, clientRect.height);
335                 __pProgressAnim = new (std::nothrow) ProgressAnimation;
336                 __pProgressAnim->Construct(rect);
337                 AddControl(__pProgressAnim);
338                 __pProgressAnim->SetShowState(true);
339                 GetFooter()->SetEnabled(false);
340                 __pProgressAnim->AnimationStart();
341                 __pProgressAnim->Draw();
342                 _overlayMsg = true;
343         }
344 }
345
346 void
347 AlbumNameEditorForm::OnCreateAlbum(void)
348 {
349         String path;
350         __pNameEditField->HideKeypad();
351         __pNameEditField->RequestRedraw();
352         path.Append(Tizen::System::Environment::GetMediaPath());
353         path.Append(__nameEditFieldText);
354
355         if (__previousSceneId != IDSCN_ALL_LIST_EDITOR && __previousSceneId != IDSCN_ALL_LIST_SELECTION)
356         {
357                 Directory::Create(path, true);
358         }
359
360         __nameEditFieldPreText = __nameEditFieldText;
361
362         if (path.IsEmpty())
363         {
364                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
365                 delete __pMoveIndexList;
366                 __pMoveIndexList = null;
367                 return ;
368         }
369
370         if (__pMoveIndexList == null || __pMoveIndexList->GetCount() <= 0)
371         {
372                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
373                 delete __pMoveIndexList;
374                 __pMoveIndexList = null;
375                 return ;
376         }
377
378         delete __pFileMove;
379         GetMoveFileIndexList(path, __pMoveIndexList, __pFilePresentationModel);
380         __pFileMove = new (std::nothrow) FileMoveTimer(path, __pMoveIndexList, __pFilePresentationModel, this);
381         if (__fileActionMode == FILE_ACTION_COPY)
382         {
383                 AppLogDebug("Rash: Setting to Copy in AlbumNameEditor");
384                 __pFileMove->SetCopy();
385         }
386         else
387         {
388                 __pFileMove->ClearCopy();
389         }
390         result r = __pFileMove->StartTimer();
391
392         if (IsFailed(r))
393         {
394                 delete __pFileMove;
395                 __pFileMove = null;
396                 __pNameEditField->SetText(__nameEditFieldPreText);
397                 __pNameEditField->HideKeypad();
398                 __pNameEditField->Draw();
399                 AppLogDebug("MoveToContentFileList content failed (%s)", GetErrorMessage(r));
400                 SceneManager* pSceneManager = SceneManager::GetInstance();
401                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
402         }
403         else
404         {
405                 AppLogDebug("MoveToContentFileList content in progress");
406                 _overlayMsg = true;
407                 __fileActionMode = FILE_ACTION_MOVE;
408         }
409 }
410
411 void AlbumNameEditorForm::OnAlbumRenameComplete(void)
412 {
413         //Hide popup here..
414         __pProgressAnim->AnimationStop();
415         __pProgressAnim->SetShowState(false);
416         RemoveControl(__pProgressAnim);
417         _overlayMsg = false;
418         GetFooter()->SetEnabled(true);
419         SceneManager* pSceneManager = SceneManager::GetInstance();
420         pSceneManager->GoBackward((BackwardSceneTransition(IDSCN_ALBUM_LIST)));
421 }
422
423 void
424 AlbumNameEditorForm::OnActionPerformed(const Control& source, int actionId)
425 {
426         AppLogDebug("ENTER");
427         String path;
428         __nameEditFieldText = __pNameEditField->GetText();
429
430         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
431         {
432                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
433                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
434                 path = pAlbumInfo->GetDirectory(0);
435         }
436
437         switch (actionId)
438         {
439         case IDA_BUTTON_CREATE_NAME_SAVE:
440         {
441                 __pNameEditField->SetEnabled(false);
442
443                 if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
444                 {
445                         OnCreateAlbum();
446                 }
447                 else if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
448                 {
449                         String albumName = __pNameEditField->GetText();
450                         if (__originalText.Equals(albumName , true))
451                         {
452                                 SceneManager* pSceneManager = SceneManager::GetInstance();
453                                 pSceneManager->GoBackward(BackwardSceneTransition());
454                         }
455                         else
456                         {
457                                 OnRenameAlbum(path);
458                         }
459                 }
460                 break;
461         }
462
463         default:
464                 break;
465         }
466         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
467 }
468
469 void
470 AlbumNameEditorForm::OnFormBackRequested(Form& source)
471 {
472         AppLogDebug("ENTER");
473         if (__pProgressAnim != null)
474         {
475                 if (__pProgressAnim->GetShowState())
476                 {
477                         return;
478                 }
479         }
480
481         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
482         {
483                 SceneManager* pSceneManager = SceneManager::GetInstance();
484                 pSceneManager->GoForward(ForwardSceneTransition(__callerSceneId));
485         }
486         else
487         {
488                 SceneManager* pSceneManager = SceneManager::GetInstance();
489                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST_EDITOR));
490         }
491         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
492 }
493
494 void
495 AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
496                 const SceneId& currentSceneId, IList* pArgs)
497 {
498         AppLogDebug("ENTER");
499         __pPresentationModel = AlbumListPresentationModel::GetInstance();
500         __previousSceneId = previousSceneId;
501
502         __pNameEditField->SetEnabled(true);
503         __pPresentationModel->AddContentEventListener(this);
504
505         if (pArgs != null)
506         {
507                 Integer* pAlbumTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
508                 if (pAlbumTypePtr->ToInt() == ALBUM_CREATE)
509                 {
510                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_CREATE");
511                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_CREATE;
512                 }
513                 else if (pAlbumTypePtr->ToInt() == ALBUM_RENAME)
514                 {
515                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_RENAME");
516                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_RENAME;
517                 }
518                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
519         }
520
521         if (pArgs != null)
522         {
523                 Integer* operationTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
524                 if (operationTypePtr->ToInt() == FILE_ACTION_MOVE)
525                 {
526                         AppLogDebug("Rash: FILE_MOVE_ACTION");
527                         __fileActionMode = FILE_ACTION_MOVE;
528                 }
529                 else if (operationTypePtr->ToInt() == FILE_ACTION_COPY)
530                 {
531                         AppLogDebug("Rash: FILE_COPY_ACTION");
532                         __fileActionMode = FILE_ACTION_COPY;
533                 }
534                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
535         }
536
537         if (previousSceneId == IDSCN_ALBUM_LIST_EDITOR)
538         {
539                 if (pArgs != null)
540                 {
541                         IEnumerator* pEnum = pArgs->GetEnumeratorN();
542                         if (pEnum->MoveNext() == E_SUCCESS)
543                         {
544                                 Integer *index = static_cast<Integer*>(pEnum->GetCurrent());
545                                 if (index != null)
546                                 {
547                                         __folderIndex = index->ToInt();
548                                 }
549                         }
550                         delete pEnum;
551                         delete pArgs;
552                         pArgs = NULL ;
553                 }
554         }
555
556         if (previousSceneId == IDSCN_ALL_LIST_EDITOR
557                         || previousSceneId == IDSCN_IMAGE_LIST_EDITOR
558                         || previousSceneId == IDSCN_VIDEO_LIST_EDITOR
559                         || previousSceneId == IDSCN_ALL_LIST_SELECTION)
560         {
561                 if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
562                 {
563                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_EDITOR");
564                 }
565                 else if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
566                 {
567                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_SELECTION");
568                 }
569
570                 __callerSceneId = previousSceneId;
571         }
572         else
573         {
574                 __callerSceneId = EMPTY_SPACE;
575         }
576
577         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
578         {
579                 __nameEditFieldText = EMPTY_SPACE;
580                 __nameEditFieldPreText = EMPTY_SPACE;
581                 __pNameEditField->SetText(__nameEditFieldText);
582                 __nameEditFieldTempText = __nameEditFieldText;
583                 __pNameEditField->ShowKeypad();
584                 __pNameEditField->SetFocus();
585
586                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"));
587                 GetFooter()->SetItemEnabled(0, false);
588                 GetFooter()->Invalidate(true);
589         }
590         else
591         {
592                 int byteCount = 0;
593                 Utf8Encoding utf8;
594                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
595                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
596
597                 String strName = pAlbumInfo->GetAlbumName();
598                 __nameEditFieldText = strName;
599                 __nameEditFieldPreText = strName;
600                 __pNameEditField->SetText(__nameEditFieldText);
601                 __nameEditFieldTempText = __nameEditFieldText;
602                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_RENAME"));
603                 __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
604                 __pNameEditField->ShowKeypad();
605                 __pNameEditField->SetFocus();
606                 __originalText = __pNameEditField->GetText();
607                 utf8.GetByteCount(__nameEditFieldText, byteCount);
608                 __textLength = byteCount;
609                 GetFooter()->SetItemEnabled(0, true);
610                 GetFooter()->Invalidate(true);
611         }
612
613         if (pArgs != NULL)
614         {
615                 __pMoveIndexList = pArgs;
616         }
617
618         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
619 }
620
621 void
622 AlbumNameEditorForm::OnSceneDeactivated(const SceneId& currentSceneId,
623                 const SceneId& nextSceneId)
624 {
625         AppLogDebug("ENTER");
626         __pPresentationModel->RemoveContentEventListener(*this);
627         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
628 }
629
630 void
631 AlbumNameEditorForm::OnContentUpdated(void)
632 {
633         AppLogDebug("ENTER");
634
635         if ( __mountState == false )
636         {
637                 SceneManager* pSceneManager = SceneManager::GetInstance();
638                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
639                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
640         }
641         else
642         {
643                 __mountState = false;
644         }
645 }
646
647 void
648 AlbumNameEditorForm::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
649 {
650         AppLogDebug("ENTER");
651
652         if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
653         {
654                 if ( __pFileMove && __pFileMove->IsStarted() )
655                 {
656                         __pFileMove->Cancel();
657                         delete __pFileMove;
658                         __pFileMove = null;
659                 }
660                 __mountState = false;
661                 SceneManager* pSceneManager = SceneManager::GetInstance();
662                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
663                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
664         }
665         else
666         {
667                 __mountState = true;
668         }
669         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
670 }
671
672 void
673 AlbumNameEditorForm::CreateMessage(String& str)
674 {
675         if (__pMessageBox == null)
676         {
677                 __pMessageBox = new(std::nothrow) MessageBox;
678
679                 if (__pMessageBox != null)
680                 {
681                         __pMessageBox->Construct(L"", str, MSGBOX_STYLE_OK, 3000);
682                         __pMessageBox->ShowAndWait(__modalMsgBoxResult);
683
684                         delete __pMessageBox;
685                         __pMessageBox = null;
686                         __modalMsgBoxResult = 0;
687                 }
688         }
689 }
690
691 void
692 AlbumNameEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
693 {
694         if ( __pProgressAnim != NULL)
695         {
696                 __pProgressAnim->ChangeOrientation(GetClientAreaBounds());
697                 __pProgressAnim->Invalidate(true);
698         }
699 }