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