Fixed keypad issue
[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
50 static const Rectangle RECT_NAME_EDIT_FIELD (0, 0, 720, 100);
51 static const unsigned int COLOR_NAME_EDIT_FIELD = Color32<255, 255, 255>::Value;
52 static const int ALBUM_MAX_LENGTH = 255;
53
54 AlbumNameEditorForm::AlbumNameEditorForm(void)
55         : __pNameEditField(null)
56         , __folderIndex(0)
57         , __modalMsgBoxResult(0)
58         , __textLength(0)
59         , __mountState(false)
60         , __albumNameEditorMode(ALBUM_NAME_EDITOR_MODE_RENAME)
61         , __pMessageBox(null)
62         , __pMoveIndexList(null)
63         , __fileActionMode(FILE_ACTION_MOVE)
64         , __pFileMove(null)
65         , __pProgressAnim(null)
66         , __pPresentationModel(null)
67         , __pFilePresentationModel(null)
68 {
69         AppLogDebug("ENTER");
70         _overlayMsg = false;
71         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
72 }
73
74 AlbumNameEditorForm::~AlbumNameEditorForm(void)
75 {
76         AppLogDebug("ENTER");
77         DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
78         delete __pFileMove;
79         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
80 }
81
82 result
83 AlbumNameEditorForm::Initialize(void)
84 {
85         AppLogDebug("ENTER");
86         result r = Construct(FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR);
87         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
88
89         return r;
90 }
91
92 result
93 AlbumNameEditorForm::OnInitializing(void)
94 {
95         AppLogDebug("ENTER");
96         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
97         __pFilePresentationModel = FileListPresentationModel::GetInstance();
98
99         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
100         Header* pHeader = GetHeader();
101
102         pHeader->SetStyle(HEADER_STYLE_TITLE);
103
104         GetFooter()->SetBackButtonEnabled(true);
105         GetFooter()->SetBackButton();
106
107         FooterItem itemSave;
108         itemSave.Construct(IDA_BUTTON_CREATE_NAME_SAVE);
109         itemSave.SetText(ResourceManager::GetString(L"IDS_COM_OPT_SAVE"));
110
111         GetFooter()->AddItem(itemSave);
112         GetFooter()->AddActionEventListener(*this);
113         GetFooter()->Invalidate(true);
114
115         SetFormBackEventListener(this);
116         SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
117
118         __pNameEditField = new (std::nothrow) EditField();
119         __pNameEditField->Construct(RECT_NAME_EDIT_FIELD, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY,
120                         EDIT_FIELD_TITLE_STYLE_NONE, true, ALBUM_MAX_LENGTH);
121         __pNameEditField->AddTextEventListener(*this);
122         __pNameEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_NAME_EDIT_FIELD);
123         __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
124
125         AddControl(__pNameEditField);
126         __pNameEditField->AddActionEventListener(*this);
127
128         return E_SUCCESS;
129 }
130
131 void
132 AlbumNameEditorForm::OnTextValueChanged(const Control& source)
133 {
134         String currentInput;
135         String currentText;
136         String specialCharacters(L"/");
137         String byteCountForInput;
138         int byteCount = 0;
139         int inputLength = 0;
140         int tempLength = 255;
141         int textToCheck = 0;
142         MessageBox messageBox;
143         Utf8Encoding utf8;
144
145         FooterItemStatus currentStatus = FOOTER_ITEM_STATUS_NORMAL;
146
147         result r = E_SUCCESS;
148
149         if (__pNameEditField != null)
150         {
151                 byteCountForInput = __pNameEditField->GetText();
152                 r = utf8.GetByteCount(byteCountForInput, byteCount);
153                 AppLogDebug("result is %s",GetErrorMessage(r));
154                 AppLogDebug("Byte count is %d",byteCount);
155         }
156
157         if (__pNameEditField != null)
158         {
159                 currentText = __pNameEditField->GetText();
160                 textToCheck = currentText.GetLength() - __textLength;
161                 if (currentText.IsEmpty())
162                 {
163                         if (GetFooter() != null)
164                         {
165                                 GetFooter()->SetItemEnabled(0, false);
166                                 GetFooter()->Invalidate(true);
167                         }
168                 }
169                 else
170                 {
171                         if (GetFooter() != null)
172                         {
173                                 GetFooter()->GetItemStatus(0, currentStatus);
174
175                                 if (currentStatus == FOOTER_ITEM_STATUS_DISABLED)
176                                 {
177                                         GetFooter()->SetItemEnabled(0,true);
178                                         GetFooter()->Invalidate(true);
179                                 }
180                         }
181                 }
182
183                 if (currentText.StartsWith(".", 0))
184                 {
185                         String invalidCharacterString;
186                         String validString;
187                         String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
188                         CreateMessage(msg);
189                         validString = __pNameEditField->GetText();
190
191                         if (validString.GetLength() > 1)
192                         {
193                                 validString.Remove(0,1);
194                                 __pNameEditField->SetText(validString);
195                         }
196                         else
197                         {
198                                 __pNameEditField->SetText("");
199
200                                 if (GetFooter() != null)
201                                 {
202                                         GetFooter()->SetItemEnabled(0, false);
203                                         GetFooter()->Invalidate(true);
204                                 }
205                         }
206                         __pNameEditField->ShowKeypad();
207                 }
208
209                 currentInput = __pNameEditField->GetText();
210
211                 if (currentInput.Contains(specialCharacters[0]))
212                 {
213                         String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
214                         CreateMessage(msg);
215                         currentInput.Replace("/", "");
216                         __pNameEditField->SetText(currentInput);
217                 }
218
219                 inputLength = byteCount;
220                 if (inputLength  >= tempLength)
221                 {
222                         String maxCharacterString;
223                         String currentInputCharacter;
224                         int checkByteCount = 0;
225                         int lengthOfFinalString = 0;
226                         int currentCharacter = 0;
227
228                         String msg = ResourceManager::GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED");
229                         CreateMessage(msg);
230                         currentText = __pNameEditField->GetText();
231
232                         for (currentCharacter=0; checkByteCount < tempLength; currentCharacter++)
233                         {
234                                 currentInputCharacter.Clear();
235                                 currentInputCharacter = currentText[currentCharacter];
236                                 r = utf8.GetByteCount(currentInputCharacter, byteCount);
237                                 if (r != E_SUCCESS)
238                                 {
239                                         break;
240                                 }
241                                 AppLogDebug("result of byte count is %s",GetErrorMessage(r));
242                                 checkByteCount = checkByteCount + byteCount;
243                                 lengthOfFinalString++;
244                         }
245
246                         r = __pNameEditField->GetText().SubString(0, lengthOfFinalString, currentInput);
247                         AppLogDebug("current input is %S", currentInput.GetPointer());
248                         r = __pNameEditField->SetText(currentInput);
249                         __pNameEditField->ShowKeypad();
250                         return;
251                 }
252
253                 r = utf8.GetByteCount(__pNameEditField->GetText(), byteCount);
254                 __textLength = byteCount;
255         }
256
257         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
258 }
259
260 void
261 AlbumNameEditorForm::OnTextValueChangeCanceled(const Control& source)
262 {
263         AppLogDebug("ENTER");
264         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
265 }
266
267 result
268 AlbumNameEditorForm::OnTerminating(void)
269 {
270         AppLogDebug("ENTER");
271         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
272
273         return E_SUCCESS;
274 }
275
276 void AlbumNameEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
277 {
278         Invalidate(true);
279 }
280
281 void AlbumNameEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
282 {
283         _overlayMsg = false;
284         if (res != COMPLETE_SUCCESS)
285         {
286                 __pNameEditField->SetText(__nameEditFieldPreText);
287                 __pNameEditField->HideKeypad();
288                 __pNameEditField->Draw();
289                 SceneManager* pSceneManager = SceneManager::GetInstance();
290                 pSceneManager->GoBackward(BackwardSceneTransition(__callerSceneId));
291         }
292 }
293
294 void
295 AlbumNameEditorForm::OnRenameAlbum(String& strOri)
296 {
297         AppLogDebug("Rename Album");
298         String path;
299         int index = 0;
300         strOri.Reverse();
301         strOri.IndexOf(DIRECTORY_SEPARATOR, 0, index);
302         strOri.Reverse();
303         strOri.SubString(0, (strOri.GetLength() - index), path);
304         path.Append(__nameEditFieldText);
305
306         //Rename
307         result r = __pPresentationModel->RenameAlbum(strOri, path, this);
308
309         if (IsFailed(r))
310         {
311                 AppLogDebug("Unable to rename Album %s", GetErrorMessage(r));
312                 if (__pMessageBox == null)
313                 {
314                         __pMessageBox = new (std::nothrow) MessageBox();
315                         if (r == E_FILE_ALREADY_EXIST)
316                         {
317                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_BODY_UNABLE_TO_RENAME_ALBUM_NAME_ALREADY_IN_USE_ABB"),
318                                                           MSGBOX_STYLE_NONE, 3000);
319                         }
320                         else
321                         {
322                                 __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_POP_UNABLE_TO_RENAME"),
323                                                           MSGBOX_STYLE_NONE, 3000);
324                         }
325                         int modalResult = 0;
326                         _overlayMsg = true;
327                         __pMessageBox->ShowAndWait(modalResult);
328                         _overlayMsg = false;
329                         delete __pMessageBox;
330                         __pMessageBox = null;
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 (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
477         {
478                 SceneManager* pSceneManager = SceneManager::GetInstance();
479                 pSceneManager->GoForward(ForwardSceneTransition(__callerSceneId));
480         }
481         else
482         {
483                 SceneManager* pSceneManager = SceneManager::GetInstance();
484                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST_EDITOR));
485         }
486         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
487 }
488
489 void
490 AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
491                 const SceneId& currentSceneId, IList* pArgs)
492 {
493         AppLogDebug("ENTER");
494         __pPresentationModel = AlbumListPresentationModel::GetInstance();
495         __previousSceneId = previousSceneId;
496
497         __pNameEditField->SetEnabled(true);
498         __pPresentationModel->AddContentEventListener(this);
499
500         if (pArgs != null)
501         {
502                 Integer* pAlbumTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
503                 if (pAlbumTypePtr->ToInt() == ALBUM_CREATE)
504                 {
505                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_CREATE");
506                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_CREATE;
507                 }
508                 else if (pAlbumTypePtr->ToInt() == ALBUM_RENAME)
509                 {
510                         AppLogDebug("ALBUM_NAME_EDITOR_MODE_RENAME");
511                         __albumNameEditorMode = ALBUM_NAME_EDITOR_MODE_RENAME;
512                 }
513                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
514         }
515
516         if (pArgs != null)
517         {
518                 Integer* operationTypePtr = static_cast<Integer*>(pArgs->GetAt(ALBUM_FIRST_ELEMENT));
519                 if (operationTypePtr->ToInt() == FILE_ACTION_MOVE)
520                 {
521                         AppLogDebug("Rash: FILE_MOVE_ACTION");
522                         __fileActionMode = FILE_ACTION_MOVE;
523                 }
524                 else if (operationTypePtr->ToInt() == FILE_ACTION_COPY)
525                 {
526                         AppLogDebug("Rash: FILE_COPY_ACTION");
527                         __fileActionMode = FILE_ACTION_COPY;
528                 }
529                 pArgs->RemoveAt(ALBUM_FIRST_ELEMENT, true);
530         }
531
532         if (previousSceneId == IDSCN_ALBUM_LIST_EDITOR)
533         {
534                 if (pArgs != null)
535                 {
536                         IEnumerator* pEnum = pArgs->GetEnumeratorN();
537                         if (pEnum->MoveNext() == E_SUCCESS)
538                         {
539                                 Integer *index = static_cast<Integer*>(pEnum->GetCurrent());
540                                 if (index != null)
541                                 {
542                                         __folderIndex = index->ToInt();
543                                 }
544                         }
545                         delete pEnum;
546                         delete pArgs;
547                 }
548         }
549
550         if (previousSceneId == IDSCN_ALL_LIST_EDITOR
551                         || previousSceneId == IDSCN_IMAGE_LIST_EDITOR
552                         || previousSceneId == IDSCN_VIDEO_LIST_EDITOR
553                         || previousSceneId == IDSCN_ALL_LIST_SELECTION)
554         {
555                 if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
556                 {
557                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_EDITOR");
558                 }
559                 else if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
560                 {
561                         AppLogDebug("[MOVE] previousSceneId = IDSCN_ALL_LIST_SELECTION");
562                 }
563
564                 __callerSceneId = previousSceneId;
565         }
566         else
567         {
568                 __callerSceneId = EMPTY_SPACE;
569         }
570
571         if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
572         {
573                 __nameEditFieldText = EMPTY_SPACE;
574                 __nameEditFieldPreText = EMPTY_SPACE;
575                 __pNameEditField->SetText(__nameEditFieldText);
576                 __nameEditFieldTempText = __nameEditFieldText;
577                 __pNameEditField->ShowKeypad();
578                 __pNameEditField->SetFocus();
579
580                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"));
581                 GetFooter()->SetItemEnabled(0, false);
582                 GetFooter()->Invalidate(true);
583         }
584         else
585         {
586                 int byteCount = 0;
587                 Utf8Encoding utf8;
588                 IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
589                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
590
591                 String strName = pAlbumInfo->GetAlbumName();
592                 __nameEditFieldText = strName;
593                 __nameEditFieldPreText = strName;
594                 __pNameEditField->SetText(__nameEditFieldText);
595                 __nameEditFieldTempText = __nameEditFieldText;
596                 GetHeader()->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_RENAME"));
597                 __pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
598                 __pNameEditField->ShowKeypad();
599                 __pNameEditField->SetFocus();
600                 __originalText = __pNameEditField->GetText();
601                 utf8.GetByteCount(__nameEditFieldText, byteCount);
602                 __textLength = byteCount;
603                 GetFooter()->SetItemEnabled(0, true);
604                 GetFooter()->Invalidate(true);
605         }
606
607         if (pArgs != NULL)
608         {
609                 __pMoveIndexList = pArgs;
610         }
611
612         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
613 }
614
615 void
616 AlbumNameEditorForm::OnSceneDeactivated(const SceneId& currentSceneId,
617                 const SceneId& nextSceneId)
618 {
619         AppLogDebug("ENTER");
620         __pPresentationModel->RemoveContentEventListener(*this);
621         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
622 }
623
624 void
625 AlbumNameEditorForm::OnContentUpdated(void)
626 {
627         AppLogDebug("ENTER");
628
629         if ( __mountState == false )
630         {
631                 SceneManager* pSceneManager = SceneManager::GetInstance();
632                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
633                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
634         }
635         else
636         {
637                 __mountState = false;
638         }
639 }
640
641 void
642 AlbumNameEditorForm::OnDeviceStateChanged(DeviceType deviceType, const Tizen::Base::String& state)
643 {
644         AppLogDebug("ENTER");
645
646         if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
647         {
648                 if ( __pFileMove && __pFileMove->IsStarted() )
649                 {
650                         __pFileMove->Cancel();
651                         delete __pFileMove;
652                         __pFileMove = null;
653                 }
654                 __mountState = false;
655                 SceneManager* pSceneManager = SceneManager::GetInstance();
656                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
657                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
658         }
659         else
660         {
661                 __mountState = true;
662         }
663         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
664 }
665
666 void
667 AlbumNameEditorForm::CreateMessage(String& str)
668 {
669         if (__pMessageBox == null)
670         {
671                 __pMessageBox = new(std::nothrow) MessageBox;
672
673                 if (__pMessageBox != null)
674                 {
675                         __pMessageBox->Construct(L"", str, MSGBOX_STYLE_OK, 3000);
676                         __pMessageBox->ShowAndWait(__modalMsgBoxResult);
677
678                         delete __pMessageBox;
679                         __pMessageBox = null;
680                         __modalMsgBoxResult = 0;
681                 }
682         }
683 }