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