Fixed issue 47790
[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                         if (currentInput == L"")
212                         {
213                                 if (GetFooter() != null)
214                                 {
215                                         GetFooter()->SetItemEnabled(0, false);
216                                         GetFooter()->Invalidate(true);
217                                 }
218                         }
219                 }
220
221                 byteCountForInput = __pNameEditField->GetText();
222                 r = utf8.GetByteCount(byteCountForInput, inputLength);
223
224                 if (inputLength  >= tempLength)
225                 {
226                         String maxCharacterString;
227                         String currentInputCharacter;
228                         int checkByteCount = 0;
229                         int lengthOfFinalString = 0;
230                         int currentCharacter = 0;
231
232                         String msg = ResourceManager::GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED");
233                         CreateMessage(msg);
234                         currentText = __pNameEditField->GetText();
235
236                         for (currentCharacter=0; checkByteCount < tempLength; ++currentCharacter)
237                         {
238                                 currentInputCharacter.Clear();
239                                 currentInputCharacter = currentText[currentCharacter];
240                                 r = utf8.GetByteCount(currentInputCharacter, byteCount);
241                                 if (r != E_SUCCESS)
242                                 {
243                                         break;
244                                 }
245                                 AppLogDebug("result of byte count is %s",GetErrorMessage(r));
246                                 checkByteCount = checkByteCount + byteCount;
247
248                                 if (checkByteCount < tempLength)
249                                 {
250                                         ++lengthOfFinalString;
251                                 }
252                         }
253
254                         r = __pNameEditField->GetText().SubString(0, lengthOfFinalString, currentInput);
255                         AppLogDebug("current input is %S", currentInput.GetPointer());
256                         r = __pNameEditField->SetText(currentInput);
257                         __pNameEditField->ShowKeypad();
258                         return;
259                 }
260
261                 r = utf8.GetByteCount(__pNameEditField->GetText(), byteCount);
262                 __textLength = byteCount;
263         }
264
265         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
266 }
267
268 void
269 AlbumNameEditorForm::OnTextValueChangeCanceled(const Control& source)
270 {
271         AppLogDebug("ENTER");
272         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
273 }
274
275 result
276 AlbumNameEditorForm::OnTerminating(void)
277 {
278         AppLogDebug("ENTER");
279         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
280
281         return E_SUCCESS;
282 }
283
284 void AlbumNameEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
285 {
286         Invalidate(true);
287 }
288
289 void AlbumNameEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
290 {
291         _overlayMsg = false;
292         if (res != COMPLETE_SUCCESS)
293         {
294                 __pNameEditField->SetText(__nameEditFieldPreText);
295                 __pNameEditField->HideKeypad();
296                 __pNameEditField->Draw();
297                 SceneManager* pSceneManager = SceneManager::GetInstance();
298                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
299         }
300 }
301
302 void
303 AlbumNameEditorForm::OnRenameAlbum(String& strOri)
304 {
305         AppLogDebug("Rename Album");
306         String path;
307         int index = 0;
308         strOri.Reverse();
309         strOri.IndexOf(DIRECTORY_SEPARATOR, 0, index);
310         strOri.Reverse();
311         strOri.SubString(0, (strOri.GetLength() - index), path);
312         path.Append(__nameEditFieldText);
313
314         //Rename
315         result r = __pPresentationModel->RenameAlbum(strOri, path, this);
316
317         if (IsFailed(r))
318         {
319                 AppLogDebug("Unable to rename Album %s", GetErrorMessage(r));
320                 if (__pMessageBox == null)
321                 {
322                         __pMessageBox = new (std::nothrow) MessageBox();
323                         if (r == E_FILE_ALREADY_EXIST)
324                         {
325                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_BODY_UNABLE_TO_RENAME_ALBUM_NAME_ALREADY_IN_USE_ABB"),
326                                                           MSGBOX_STYLE_NONE, 3000);
327
328                         }
329                         else
330                         {
331                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_POP_UNABLE_TO_RENAME"),
332                                                           MSGBOX_STYLE_NONE, 3000);
333                         }
334                         int modalResult = 0;
335                         _overlayMsg = true;
336                         __pMessageBox->ShowAndWait(modalResult);
337                         _overlayMsg = false;
338                         delete __pMessageBox;
339                         __pMessageBox = null;
340                         __pNameEditField->SetEnabled(true);
341                         __pNameEditField->ShowKeypad();
342                 }
343         }
344         else
345         {
346                 //Add a popup here
347                 Rectangle clientRect = Form::GetBounds();
348                 Rectangle rect(0, 0, clientRect.width, clientRect.height);
349                 __pProgressAnim = new (std::nothrow) ProgressAnimation;
350                 __pProgressAnim->Construct(rect);
351                 AddControl(__pProgressAnim);
352                 __pProgressAnim->SetShowState(true);
353                 GetFooter()->SetEnabled(false);
354                 __pProgressAnim->AnimationStart();
355                 __pProgressAnim->Draw();
356                 _overlayMsg = true;
357         }
358 }
359
360 void
361 AlbumNameEditorForm::OnCreateAlbum(void)
362 {
363         String path;
364         __pNameEditField->HideKeypad();
365         __pNameEditField->RequestRedraw();
366         path.Append(Tizen::System::Environment::GetMediaPath());
367         path.Append(__nameEditFieldText);
368
369         if (__previousSceneId != IDSCN_ALL_LIST_EDITOR && __previousSceneId != IDSCN_ALL_LIST_SELECTION)
370         {
371                 Directory::Create(path, true);
372         }
373
374         __nameEditFieldPreText = __nameEditFieldText;
375
376         if (path.IsEmpty())
377         {
378                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
379                 delete __pMoveIndexList;
380                 __pMoveIndexList = null;
381                 return;
382         }
383
384         if (__pMoveIndexList == null || __pMoveIndexList->GetCount() <= 0)
385         {
386                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
387                 delete __pMoveIndexList;
388                 __pMoveIndexList = null;
389                 return;
390         }
391
392         delete __pFileMove;
393         GetMoveFileIndexList(path, __pMoveIndexList, __pFilePresentationModel);
394         __pFileMove = new (std::nothrow) FileMoveTimer(path, __pMoveIndexList, __pFilePresentationModel, this);
395         if (__fileActionMode == FILE_ACTION_COPY)
396         {
397                 AppLogDebug("Rash: Setting to Copy in AlbumNameEditor");
398                 __pFileMove->SetCopy();
399         }
400         else
401         {
402                 __pFileMove->ClearCopy();
403         }
404         result r = __pFileMove->StartTimer();
405
406         if (IsFailed(r))
407         {
408                 delete __pFileMove;
409                 __pFileMove = null;
410                 __pNameEditField->SetText(__nameEditFieldPreText);
411                 __pNameEditField->HideKeypad();
412                 __pNameEditField->Draw();
413                 AppLogDebug("MoveToContentFileList content failed (%s)", GetErrorMessage(r));
414                 SceneManager* pSceneManager = SceneManager::GetInstance();
415                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
416         }
417         else
418         {
419                 AppLogDebug("MoveToContentFileList content in progress");
420                 _overlayMsg = true;
421                 __fileActionMode = FILE_ACTION_MOVE;
422         }
423 }
424
425 void AlbumNameEditorForm::OnAlbumRenameComplete(void)
426 {
427         //Hide popup here..
428         __pProgressAnim->AnimationStop();
429         __pProgressAnim->SetShowState(false);
430         RemoveControl(__pProgressAnim);
431         _overlayMsg = false;
432         GetFooter()->SetEnabled(true);
433         SceneManager* pSceneManager = SceneManager::GetInstance();
434         pSceneManager->GoBackward((BackwardSceneTransition(IDSCN_ALBUM_LIST)));
435 }
436
437 void
438 AlbumNameEditorForm::OnActionPerformed(const Control& source, int actionId)
439 {
440         AppLogDebug("ENTER");
441         String path;
442         __nameEditFieldText = __pNameEditField->GetText();
443
444         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
445         {
446                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
447                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
448                 path = pAlbumInfo->GetDirectory(0);
449         }
450
451         switch (actionId)
452         {
453         case IDA_BUTTON_CREATE_NAME_SAVE:
454         {
455                 __pNameEditField->SetEnabled(false);
456                 GetFooter()->SetItemEnabled(0, false);
457
458                 if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
459                 {
460                         OnCreateAlbum();
461                 }
462                 else if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_RENAME)
463                 {
464                         String albumName = __pNameEditField->GetText();
465                         if (__originalText.Equals(albumName, true))
466                         {
467                                 SceneManager* pSceneManager = SceneManager::GetInstance();
468                                 pSceneManager->GoBackward(BackwardSceneTransition());
469                         }
470                         else
471                         {
472                                 OnRenameAlbum(path);
473                         }
474                 }
475                 break;
476         }
477
478         default:
479                 break;
480         }
481         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
482 }
483
484 void
485 AlbumNameEditorForm::OnFormBackRequested(Form& source)
486 {
487         AppLogDebug("ENTER");
488         if (__pProgressAnim != null)
489         {
490                 if (__pProgressAnim->GetShowState())
491                 {
492                         return;
493                 }
494         }
495
496         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
497         {
498                 SceneManager* pSceneManager = SceneManager::GetInstance();
499                 pSceneManager->GoForward(ForwardSceneTransition(__callerSceneId));
500         }
501         else
502         {
503                 SceneManager* pSceneManager = SceneManager::GetInstance();
504                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST_EDITOR));
505         }
506         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
507 }
508
509 void
510 AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
511                 const SceneId& currentSceneId, IList* pArgs)
512 {
513         AppLogDebug("ENTER");
514         __pPresentationModel = AlbumListPresentationModel::GetInstance();
515         __previousSceneId = previousSceneId;
516
517         __pNameEditField->SetEnabled(true);
518         __pPresentationModel->AddContentEventListener(this);
519
520         if (pArgs != null)
521         {
522                 Integer* pAlbumTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
523                 if (pAlbumTypePtr->ToInt() == ALBUM_CREATE)
524                 {
525                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_CREATE");
526                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_CREATE;
527                 }
528                 else if (pAlbumTypePtr->ToInt() == ALBUM_RENAME)
529                 {
530                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_RENAME");
531                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_RENAME;
532                 }
533                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
534         }
535
536         if (pArgs != null)
537         {
538                 Integer* operationTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
539                 if (operationTypePtr->ToInt() == FILE_ACTION_MOVE)
540                 {
541                         AppLogDebug("Rash: FILE_MOVE_ACTION");
542                         __fileActionMode = FILE_ACTION_MOVE;
543                 }
544                 else if (operationTypePtr->ToInt() == FILE_ACTION_COPY)
545                 {
546                         AppLogDebug("Rash: FILE_COPY_ACTION");
547                         __fileActionMode = FILE_ACTION_COPY;
548                 }
549                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
550         }
551
552         if (previousSceneId == IDSCN_ALBUM_LIST_EDITOR)
553         {
554                 if (pArgs != null)
555                 {
556                         IEnumerator* pEnum = pArgs->GetEnumeratorN();
557                         if (pEnum->MoveNext() == E_SUCCESS)
558                         {
559                                 Integer *index = static_cast<Integer*>(pEnum->GetCurrent());
560                                 if (index != null)
561                                 {
562                                         __folderIndex = index->ToInt();
563                                 }
564                         }
565                         delete pEnum;
566                         delete pArgs;
567                         pArgs = NULL;
568                 }
569         }
570
571         if (previousSceneId == IDSCN_ALL_LIST_EDITOR
572                         || previousSceneId == IDSCN_IMAGE_LIST_EDITOR
573                         || previousSceneId == IDSCN_VIDEO_LIST_EDITOR
574                         || previousSceneId == IDSCN_ALL_LIST_SELECTION)
575         {
576                 if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
577                 {
578                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_EDITOR");
579                 }
580                 else if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
581                 {
582                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_SELECTION");
583                 }
584
585                 __callerSceneId = previousSceneId;
586         }
587         else
588         {
589                 __callerSceneId = EMPTY_SPACE;
590         }
591
592         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
593         {
594                 __nameEditFieldText = EMPTY_SPACE;
595                 __nameEditFieldPreText = EMPTY_SPACE;
596                 __pNameEditField->SetText(__nameEditFieldText);
597                 __nameEditFieldTempText = __nameEditFieldText;
598                 __pNameEditField->ShowKeypad();
599                 __pNameEditField->SetFocus();
600
601                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"));
602                 GetFooter()->SetItemEnabled(0, false);
603                 GetFooter()->Invalidate(true);
604         }
605         else
606         {
607                 int byteCount = 0;
608                 Utf8Encoding utf8;
609                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
610                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
611
612                 String strName = pAlbumInfo->GetAlbumName();
613                 __nameEditFieldText = strName;
614                 __nameEditFieldPreText = strName;
615                 __pNameEditField->SetText(__nameEditFieldText);
616                 __nameEditFieldTempText = __nameEditFieldText;
617                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_RENAME"));
618                 __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
619                 __pNameEditField->ShowKeypad();
620                 __pNameEditField->SetFocus();
621                 __originalText = __pNameEditField->GetText();
622                 utf8.GetByteCount(__nameEditFieldText, byteCount);
623                 __textLength = byteCount;
624                 GetFooter()->SetItemEnabled(0, true);
625                 GetFooter()->Invalidate(true);
626         }
627
628         if (pArgs != NULL)
629         {
630                 __pMoveIndexList = pArgs;
631         }
632
633         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
634 }
635
636 void
637 AlbumNameEditorForm::OnSceneDeactivated(const SceneId& currentSceneId,
638                 const SceneId& nextSceneId)
639 {
640         AppLogDebug("ENTER");
641         __pPresentationModel->RemoveContentEventListener(*this);
642         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
643 }
644
645 void
646 AlbumNameEditorForm::OnContentUpdated(void)
647 {
648         AppLogDebug("ENTER");
649
650         if (__mountState == false)
651         {
652                 SceneManager* pSceneManager = SceneManager::GetInstance();
653                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
654                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
655         }
656         else
657         {
658                 __mountState = false;
659         }
660 }
661
662 void
663 AlbumNameEditorForm::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
664 {
665         AppLogDebug("ENTER");
666
667         if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
668         {
669                 if (__pFileMove && __pFileMove->IsStarted())
670                 {
671                         __pFileMove->Cancel();
672                         delete __pFileMove;
673                         __pFileMove = null;
674                 }
675                 __mountState = false;
676                 SceneManager* pSceneManager = SceneManager::GetInstance();
677                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
678                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
679         }
680         else
681         {
682                 __mountState = true;
683         }
684         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
685 }
686
687 void
688 AlbumNameEditorForm::CreateMessage(String& str)
689 {
690         if (__pMessageBox == null)
691         {
692                 __pMessageBox = new(std::nothrow) MessageBox;
693
694                 if (__pMessageBox != null)
695                 {
696                         __pMessageBox->Construct(L"", str, MSGBOX_STYLE_OK, 3000);
697                         __pMessageBox->ShowAndWait(__modalMsgBoxResult);
698
699                         delete __pMessageBox;
700                         __pMessageBox = null;
701                         __modalMsgBoxResult = 0;
702                 }
703         }
704 }
705
706 void
707 AlbumNameEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
708 {
709         if (__pProgressAnim != null)
710         {
711                 __pProgressAnim->ChangeOrientation(Form::GetBounds());
712                 __pProgressAnim->Invalidate(true);
713         }
714 }