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