2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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
8 // http://floralicense.org/license/
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.
18 * @file: MfCreateFolderForm.cpp
19 * @brief:This file contains implementation of CreateFolderForm class, which implements the Create Folder and rename file/folder functionality
20 * and contains methods that handle the same. Also contains the ResultValues enum
23 #include "MfCreateFolderForm.h"
24 #include "MfDirectoryEntry.h"
25 #include "MfSceneRegister.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Base::Utility;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Io;
34 using namespace Tizen::Locales;
35 using namespace Tizen::System;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
39 using namespace Tizen::Text;
41 CreateFolderForm::CreateFolderForm(void)
42 : __pFileManager(null)
45 , __pHeaderCancel(null)
47 , __pEditFieldFolderName(null)
49 , _pFileProgressingPopup(null)
53 __isCurrentDirectioryToBeRenamed = false;
56 CreateFolderForm::~CreateFolderForm(void)
59 if (__pHeaderCancel != null)
61 delete __pHeaderCancel;
64 if (__pHeaderSave != null)
69 if (_pFileProgressingPopup != null)
71 delete _pFileProgressingPopup;
75 CreateFolderForm::CreateFolderForm(const CreateFolderForm& createFolderForm)
81 CreateFolderForm::operator =(const CreateFolderForm& createFolderForm)
85 if (this != &createFolderForm)
87 __pEditFieldFolderName = createFolderForm.__pEditFieldFolderName;
88 __pHeader = createFolderForm.__pHeader;
89 __pHeaderSave = createFolderForm.__pHeaderSave;
90 __pHeaderCancel = createFolderForm.__pHeaderCancel;
91 __pFileManager = createFolderForm.__pFileManager;
92 __rootPath = createFolderForm.__rootPath;
98 CreateFolderForm::Initialize(void)
100 AppLogDebug("Entry");
101 //Construct the xml from the Application Resource.
102 Form::Construct(L"IDL_CREATE_FOLDER");
107 CreateFolderForm::OnInitializing(void)
109 //Set some of the default properties of the
110 AppLogDebug("Entry");
112 result r = E_SUCCESS;
115 String btnCancelText;
118 //Bitmap* pBackButtonNormal = null;
119 //Bitmap* pBackButtonPressed = null;
121 Color editFieldBackground(0x18, 0x1C, 0x1F, 0xFF);
123 AppResource* pAppResource = null;
124 pAppResource = UiApp::GetInstance()->GetAppResource();
126 if (pAppResource != null)
128 pAppResource->GetString(L"IDS_COM_OPT_SAVE", btnSaveText);
129 pAppResource->GetString(L"IDS_COM_POP_CANCEL", btnCancelText);
130 pAppResource->GetString(L"IDS_COM_BODY_DONE", btnDoneText);
131 //pBackButtonNormal = pAppResource->GetBitmapN(IDB_BACK_BUTTON_NORMAL,BITMAP_PIXEL_FORMAT_ARGB8888);
132 //pBackButtonPressed = pAppResource->GetBitmapN(IDB_BACK_BUTTON_PRESSED,BITMAP_PIXEL_FORMAT_ARGB8888);
135 SetFormBackEventListener(this);
136 AddTouchEventListener(*this);
137 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
139 __previousFormPath = FolderNavigationPresentationModel::GetCurrentPath();
140 __previousFormTab = FolderNavigationPresentationModel::GetStorageType();
141 __previousSceneId = SceneManager::GetInstance()->GetCurrentSceneId();
143 __pFooter = GetFooter();
144 if (__pFooter != null)
146 __pFooter->SetBackButtonEnabled(true);
147 __pFooter->SetBackButton();
149 __pFooterItemSave = new (std::nothrow) FooterItem();
150 __pFooterItemSave->Construct(IDA_BUTTON_SAVE);
151 __pFooterItemSave->SetText(btnSaveText);
153 __pFooter->AddItem(*__pFooterItemSave);
154 __pFooter->AddActionEventListener(*this);
155 __pFooter->Invalidate(true);
159 __pHeader = GetHeader();
160 if (__pHeader != null)
162 __pHeader->SetStyle(HEADER_STYLE_BUTTON);
164 __pHeaderSave = new (std::nothrow) HeaderItem();
165 __pHeaderSave->Construct(IDA_BUTTON_SAVE);
166 __pHeaderSave->SetText(btnSaveText);
168 __pHeaderCancel = new (std::nothrow) ButtonItem();
169 __pHeaderCancel->Construct(BUTTON_ITEM_STYLE_ICON, IDA_BUTTON_CANCEL);
171 if (pBackButtonNormal != null)
173 __pHeaderCancel->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBackButtonNormal);
176 if (pBackButtonPressed != null)
178 __pHeaderCancel->SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBackButtonPressed);
181 __pHeader->AddItem(*__pHeaderSave);
182 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pHeaderCancel);
183 __pHeader->AddActionEventListener(*this);
187 //Get the EditFieldControl from the form and set a few properties, set the overlay command buttons
188 //Show the keypad on form initializing.
189 //Set the action and text event listeners to it.
190 __pEditFieldFolderName = static_cast< EditField* >(GetControl(L"IDC_EDITFIELD_FOLDER_NAME", true));
191 if (__pEditFieldFolderName != null)
193 __pEditFieldFolderName->SetKeypadEnabled(true);
194 __pEditFieldFolderName->SetOverlayKeypadCommandButtonVisible(false);
195 __pEditFieldFolderName->AddKeypadEventListener(*this);
196 __pEditFieldFolderName->ShowKeypad();
197 __pEditFieldFolderName->AddTextEventListener(*this);
198 __pEditFieldFolderName->AddActionEventListener(*this);
200 //Create New instance of the Filemanager
201 __pFileManager = FolderEntryEditorPresentationModel::GetInstance();
202 TryCatch(__pFileManager != null, , "Failed to allocate file manager");
207 if (__pHeaderSave != null)
209 delete __pHeaderSave;
210 __pHeaderSave = null;
213 if (__pHeaderCancel != null)
215 delete __pHeaderCancel;
216 __pHeaderCancel = null;
224 CreateFolderForm::OnTerminating(void)
226 AppLogDebug("Entry");
227 result r = E_SUCCESS;
229 __pFooter = GetFooter();
231 if (__pFooter != null)
233 __pFooter->RemoveAllItems();
234 __pFooter->RemoveAllButtons();
241 CreateFolderForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
243 AppLogDebug("Entry");
244 //Navigates to the previous folder.
249 CreateFolderForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
251 AppLogDebug("Entry");
253 result r = E_SUCCESS;
257 MessageBox messageBox;
258 ResultValues resultValidity = RESULT_VALUES_SUCCESS;
262 case IDA_BUTTON_SAVE:
264 if (__pEditFieldFolderName != null)
269 if (__launchSource.ToInt() == SELECT_CREATE_FOLDER)
271 if (__pEditFieldFolderName != null)
273 folderName.Append(__pEditFieldFolderName->GetText());
275 AppLogDebug("folder value is %ls",folderName.GetPointer());
276 __rootPath = FolderNavigationPresentationModel::GetCurrentPath();
278 filePath.Append(__rootPath);
281 __fileName.Append(__rootPath);
282 __fileName.Append(folderName);
285 if (folderName.CompareTo(".") != 0 && folderName.CompareTo("..") != 0 && folderName.CompareTo("/") != 0)
287 if (File::IsFileExist(__fileName))
289 resultValidity = RESULT_VALUES_FILE_EXISTS;
293 //if (__pEditFieldFolderName->GetText().Trim() == "")
296 resultValidity = RESULT_VALUES_NULL;
299 if (resultValidity == RESULT_VALUES_SUCCESS)
301 r = __pFileManager->CreateFolder(filePath, folderName);
304 MessageBox errorMessage;
306 //String invalidCharacterString;
307 AppResource::GetInstance()->GetString(L"IDS_CREATE_FOLDER_FAILED", msgString);
308 errorMessage.Construct(L"", msgString, MSGBOX_STYLE_NONE, 1000);
310 FolderNavigationPresentationModel::SetCurrentFilePath(filePath);
315 String messageString;
318 if (resultValidity == RESULT_VALUES_FILE_EXISTS)
320 //messageString = "Name already exists!\nRetry?";
321 AppResource::GetInstance()->GetString(L"IDS_MF_POP_SAME_NAME_ALREADY_IN_USE", messageString);
323 else if (resultValidity == RESULT_VALUES_NULL)
326 //messageString = "Name can't be empty!\nRetry?";
327 AppResource::GetInstance()->GetString(L"IDS_NAME_CANT_EMPTY", messageString);
330 messageBox.Construct(L"", messageString, MSGBOX_STYLE_YESNO, 0);
332 // Call ShowAndWait - draw, show itself and process events
334 messageBox.ShowAndWait(modalResult);
338 case MSGBOX_RESULT_YES:
340 if (__pEditFieldFolderName != null)
342 __pEditFieldFolderName->ShowKeypad();
347 case MSGBOX_RESULT_NO:
361 __updatedFilePath.Clear();
364 if (__pEditFieldFolderName != null)
366 __fileName = __pEditFieldFolderName->GetText();
369 String OriginalName = __pDirectory->GetFileName();
371 if (OriginalName.CompareTo(__fileName) == 0)
377 String newRenameValue;
378 ResultValues resultValidity = RESULT_VALUES_SUCCESS;
383 StringTokenizer tokenizer(__filePath, delim);
384 int fwdSlashCount = 1;
386 tokenCount = tokenizer.GetTokenCount();
388 while (tokenizer.HasMoreTokens() && fwdSlashCount < tokenCount)
391 tokenizer.GetNextToken(token);
392 __updatedFilePath.Append("/");
393 __updatedFilePath.Append(token);
396 if (__pEditFieldFolderName != null)
398 __updatedFilePath.Append("/");
399 //updatedFilePath.Append(__pEditFieldFolderName->GetText());
400 __updatedFilePath.Append(__fileName);
402 if (entryIsDirectory == 0)
404 __updatedFilePath.Append(".");
405 __updatedFilePath.Append(__fileExtension);
408 if (__fileName.CompareTo(".") != 0 && __fileName.CompareTo("..") != 0 && __fileName.CompareTo("/") != 0)
410 if (!__fileName.Equals(__pDirectory->GetFileName()) && (File::IsFileExist(__updatedFilePath)))
412 resultValidity = RESULT_VALUES_FILE_EXISTS;
417 if (__fileName == "")
419 resultValidity = RESULT_VALUES_NULL;
423 if (resultValidity == RESULT_VALUES_SUCCESS)
426 filePath.Append(__filePath);
428 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
429 __pFileManager->SetFileManagingListener(this);
430 r = __pFileManager->RenameFolderEntry(filePath, __updatedFilePath);
434 String messageString;
437 if (resultValidity == RESULT_VALUES_FILE_EXISTS)
439 AppResource::GetInstance()->GetString(L"IDS_MF_POP_SAME_NAME_ALREADY_IN_USE", messageString);
441 else if (resultValidity == RESULT_VALUES_NULL)
443 AppResource::GetInstance()->GetString(L"IDS_NAME_CANT_EMPTY", messageString);
446 messageBox.Construct(L"", messageString, MSGBOX_STYLE_YESNO, 0);
448 // Call ShowAndWait - draw, show itself and process events
450 messageBox.ShowAndWait(modalResult);
454 case MSGBOX_RESULT_YES:
456 __pEditFieldFolderName->ShowKeypad();
460 case MSGBOX_RESULT_NO:
468 //Empty Implementation.
479 case IDA_BUTTON_CANCEL:
481 //Closes the view and navigates to the previous form.
486 case IDA_KEYPAD_BUTTON_DONE:
489 if (__pEditFieldFolderName != null)
491 __pEditFieldFolderName->HideKeypad();
496 case IDA_KEYPAD_BUTTON_CANCEL:
499 if (__pEditFieldFolderName != null)
501 __pEditFieldFolderName->HideKeypad();
508 //Empty Implementation.
515 CreateFolderForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
516 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
518 AppLogDebug("Entry");
519 Integer* pSourceForm = null;
520 String renameHeaderText;
521 String createFolderText;
526 result r = E_SUCCESS;
527 Label* pFolderName = null;
528 Panel* pFolderPanel = null;
529 AppResource* pAppResource = null;
531 if (__pEditFieldFolderName != null)
533 __pEditFieldFolderName->ShowKeypad();
536 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
538 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
541 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
543 __rootPath = FolderNavigationPresentationModel::GetCurrentPath();
547 pSourceForm = static_cast< Integer* >(pArgs->GetAt(0));
548 __launchSource = *pSourceForm;
550 pAppResource = Application::GetInstance()->GetAppResource();
552 if (__launchSource.ToInt() == SELECT_RENAME)
554 pFolderName = static_cast< Label* >(GetControl("IDC_LABEL_FOLDER_NAME", true));
555 pFolderPanel = static_cast< Panel* >(GetControl("IDC_PANEL_EDIT_FIELD", true));
557 if (__pEditFieldFolderName != null)
559 if (pFolderName != null)
561 pFolderName->SetShowState(false);
564 if (pFolderPanel != null)
566 pFolderPanel->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, H_RENAME_PANEL));
567 __pEditFieldFolderName->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, H_RENAME_EDITFIELD));
571 if (pAppResource != null)
573 pAppResource->GetString(L"IDS_MF_BODY_RENAME_ABB", renameHeaderText);
574 pAppResource->GetString(L"IDS_COM_BODY_DONE", footerText);
577 __pDirectory = static_cast< DirectoryEntry* >(pArgs->GetAt(1));
578 if (__pDirectory != null)
580 __filePath.Append(__pDirectory->GetFullFilePath());
581 if (__pDirectory->IsDirectory())
583 if (__filePath == __rootPath)
584 __isCurrentDirectioryToBeRenamed = true;
586 if (__pEditFieldFolderName != null)
588 __pEditFieldFolderName->SetText(__pDirectory->GetFileName());
589 r = utf8.GetByteCount(__pDirectory->GetFileName(), byteCount);
590 AppLogDebug("bytecount is %d",byteCount);
591 __textLength = byteCount;
593 entryIsDirectory = 1;
597 __fileExtension = File::GetFileExtension(__filePath);
598 if (__pEditFieldFolderName != null)
600 __pEditFieldFolderName->SetText(__pDirectory->GetFileName());
601 r = utf8.GetByteCount(__pDirectory->GetFileName(), byteCount);
602 AppLogDebug("bytecount is %d",byteCount);
603 __textLength = byteCount;
605 entryIsDirectory = 0;
608 __pHeader = GetHeader();
609 __pHeader->SetTitleText(renameHeaderText);
610 __pHeader->Invalidate(true);
612 __pFooter = GetFooter();
613 if (__pFooter != null)
615 __pFooterItemSave->SetText(footerText);
616 __pFooter->Invalidate(true);
622 pFolderName = static_cast< Label* >(GetControl("IDC_LABEL_FOLDER_NAME", true));
623 pFolderPanel = static_cast< Panel* >(GetControl("IDC_PANEL_EDIT_FIELD", true));
625 if (__pEditFieldFolderName != null)
627 if (pFolderName != null)
629 pFolderName->SetShowState(true);
632 if (pFolderPanel != null)
634 pFolderPanel->SetBounds(Rectangle(X_DEFAULT, Y_DEFAULT, GetClientAreaBounds().width, H_RENAME_PANEL));
635 __pEditFieldFolderName->SetBounds(Rectangle(X_DEFAULT, Y_CREATE_FOLDER_EDITFIELD, GetClientAreaBounds().width, H_CREATE_FOLDER_EDITFIELD));
639 if (pAppResource != null)
641 pAppResource->GetString(L"IDS_COM_BODY_CREATE_FOLDER", createFolderText);
642 pAppResource->GetString(L"IDS_COM_OPT_SAVE", footerText);
645 __pHeader = GetHeader();
646 __pHeader->SetTitleText(createFolderText);
647 __pHeader->Invalidate(true);
649 __pFooter = GetFooter();
650 if (__pFooter != null)
652 __pFooterItemSave->SetText(footerText);
653 __pFooter->Invalidate(true);
656 if (__pEditFieldFolderName != null)
658 GenerateFolderName(newName);
659 __pEditFieldFolderName->SetText(newName);
660 r = utf8.GetByteCount(newName, byteCount);
661 //__textLength = newName.GetLength();
662 __textLength = byteCount;
667 if (pSourceForm != null)
672 pArgs->RemoveAll(false);
677 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
681 CreateFolderForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
682 const Tizen::Ui::Scenes::SceneId& nextSceneId)
684 DeviceManager::RemoveAllDeviceEventListeners();
688 CreateFolderForm::OnTextValueChanged(const Tizen::Ui::Control& source)
691 //wchar_t characterToCompare;
693 String specialCharacters(L"/");
694 String byteCountForInput;
695 //int specialCharCount = 0;
702 MessageBox messageBox;
706 FooterItemStatus currentStatus = FOOTER_ITEM_STATUS_NORMAL;
708 result r = E_SUCCESS;
710 if (__pEditFieldFolderName != null)
712 byteCountForInput = __pEditFieldFolderName->GetText();
713 r = utf8.GetByteCount(byteCountForInput, byteCount);
714 AppLogDebug("result is %s",GetErrorMessage(r));
715 AppLogDebug("Bye count is %d",byteCount);
718 if (__pEditFieldFolderName != null)
720 currentText = __pEditFieldFolderName->GetText();
721 textToCheck = currentText.GetLength() - __textLength;
722 if (currentText.IsEmpty())
724 if (__pFooter != null)
726 __pFooter->SetItemEnabled(0, false);
727 __pFooter->Invalidate(true);
732 if (__pFooter != null)
734 __pFooter->GetItemStatus(0, currentStatus);
736 if (currentStatus == FOOTER_ITEM_STATUS_DISABLED)
738 __pFooter->SetItemEnabled(0,true);
739 __pFooter->Invalidate(true);
745 inputLength = byteCount;
746 if (__fileExtension.GetLength() >0)
748 inputLength = inputLength + __fileExtension.GetLength() +1;
752 if (currentText.StartsWith(".", 0))
754 String invalidCharacterString;
756 AppResource::GetInstance()->GetString(L"IDS_COM_POP_INVALID_CHARACTERS", invalidCharacterString);
757 messageBox.Construct(L"", invalidCharacterString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
758 messageBox.ShowAndWait(modalResult);
760 validString = __pEditFieldFolderName->GetText();
762 if (validString.GetLength() > 1)
764 validString.Remove(0,1);
765 __pEditFieldFolderName->SetText(validString);
769 __pEditFieldFolderName->SetText("");
770 if (__pFooter != null)
772 __pFooter->SetItemEnabled(0, false);
773 __pFooter->Invalidate(true);
776 __pEditFieldFolderName->ShowKeypad();
782 if (__fileExtension.GetLength() == 0 )//folder case
784 tempLength = ID_FOLDER_NAME_LENGTH_MAX;
788 tempLength = ID_FILE_NAME_LENGTH_MAX;
791 textToCheck = __pEditFieldFolderName->GetText().GetLength() - __textLength;
792 r = currentText.SubString(__pEditFieldFolderName->GetCursorPosition() - textToCheck,currentInput);
793 for(int i = 0 ; i < currentInput.GetLength() ; i++)
795 if(specialCharacters.Contains(currentInput[i]))
797 String invalidCharacterString;
798 AppResource::GetInstance()->GetString(L"IDS_COM_POP_INVALID_CHARACTERS", invalidCharacterString);
799 messageBox.Construct(L"", invalidCharacterString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
800 messageBox.ShowAndWait(modalResult);
801 currentText.Remove(__pEditFieldFolderName->GetCursorPosition()-textToCheck,textToCheck);
802 __pEditFieldFolderName->SetText(currentText);
803 __pEditFieldFolderName->SetFocus();
808 inputLength = byteCount;
809 AppLogDebug("input length and temp legth is %d %d",inputLength,tempLength);
810 if (inputLength >= tempLength)
812 String maxCharacterString;
813 String currentInputCharacter;
814 int checkByteCount = 0;
815 int lengthOfFinalString = 0;
816 int currentCharacter = 0;
817 AppResource::GetInstance()->GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED", maxCharacterString);
818 messageBox.Construct(L"", maxCharacterString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
819 messageBox.ShowAndWait(modalResult);
820 currentText = __pEditFieldFolderName->GetText();
822 for (currentCharacter=0;checkByteCount < tempLength;currentCharacter++)
824 currentInputCharacter.Clear();
825 currentInputCharacter = currentText[currentCharacter];
826 r = utf8.GetByteCount(currentInputCharacter, byteCount);
831 AppLogDebug("result of byte count is %s",GetErrorMessage(r));
832 checkByteCount = checkByteCount + byteCount;
833 lengthOfFinalString++;
836 r = __pEditFieldFolderName->GetText().SubString(0,lengthOfFinalString,currentInput);
837 AppLogDebug("current input is %S",currentInput.GetPointer());
838 r = __pEditFieldFolderName->SetText(currentInput);
839 __pEditFieldFolderName->ShowKeypad();
843 r = utf8.GetByteCount(__pEditFieldFolderName->GetText(), byteCount);
844 __textLength = byteCount;
849 CreateFolderForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
851 if (__pFooter != null)
853 __pFooter->SetItemEnabled(0, false);
854 __pFooter->Invalidate(true);
859 CreateFolderForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
861 Rectangle editFieldBounds(GetClientAreaBounds().x, 0, GetClientAreaBounds().width, H_RENAME_EDITFIELD);
863 switch (orientationStatus)
865 case ORIENTATION_STATUS_PORTRAIT:
867 if (__pEditFieldFolderName != null)
869 __pEditFieldFolderName->SetBounds(editFieldBounds);
874 case ORIENTATION_STATUS_LANDSCAPE:
876 if (__pEditFieldFolderName != null)
878 __pEditFieldFolderName->SetBounds(editFieldBounds);
885 //Empty Implementation.
894 CreateFolderForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
896 //Empty Implementation.
897 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
902 CreateFolderForm::OnKeypadOpened(Tizen::Ui::Control& source)
904 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
907 CreateFolderForm::OnKeypadClosed(Tizen::Ui::Control& source)
909 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
912 CreateFolderForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
914 //Empty Implementation.
918 CreateFolderForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
920 //Empty Implementation
924 CreateFolderForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
926 //Empty Implementation
930 CreateFolderForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
932 //Empty Implementation
936 CreateFolderForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
938 //Empty Implementation
942 CreateFolderForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
944 //Empty Implementation
948 CreateFolderForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
950 if (!(source.Equals(*__pEditFieldFolderName)))
952 __pEditFieldFolderName->HideKeypad();
957 CreateFolderForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
959 bool setMediaPath = false;
960 bool searchHistoryStatus = false;
961 MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
962 String unmounted = sdCardStatusUnmounted;
963 String removed = usbDeviceStatusRemoved;
966 SceneManager* pSceneManager = null;
967 IListT< SceneId >* pSceneList = null;
970 pSceneManager = SceneManager::GetInstance();
972 if (state == unmounted || state == removed)
974 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
975 if (state == unmounted)
977 if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
979 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
980 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
985 if (state == removed)
987 if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
989 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
990 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
997 if (pSceneManager != null)
999 pSceneList = pSceneManager->GetSceneHistoryN();
1002 if (pSceneList != null)
1004 itemCount = pSceneList->GetCount() - 1;
1005 pSceneList->GetAt(itemCount, searchScene);
1006 while (searchScene != IDSCN_SEARCH_FORM && itemCount >= 0)
1009 pSceneList->GetAt(itemCount, searchScene);
1013 if (searchScene == IDSCN_SEARCH_FORM)
1015 AppLogDebug("Search scene present");
1016 searchHistoryStatus = true;
1020 AppLogDebug("Search scene not present");
1021 searchHistoryStatus = false;
1026 pSceneList->RemoveAll();
1031 if (searchHistoryStatus == true)
1033 if (pSceneManager != null)
1035 pSceneManager->DestroyScene(IDSCN_SEARCH_FORM);
1036 pSceneManager->ClearSceneHistory();
1040 if (pSceneManager != null)
1042 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null); }
1048 CreateFolderForm::TransitionScene(void)
1050 SceneManager* pSceneManager = SceneManager::GetInstance();
1051 if (__previousFormPath.CompareTo("") != 0)
1053 FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
1054 FolderNavigationPresentationModel::SetStorageType(__previousFormTab);
1056 pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
1060 CreateFolderForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1063 ComponentType currentDeviceType;
1068 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
1074 currentDeviceType = COMPONENT_TYPE_USB;
1084 OnDeviceChange(currentDeviceType, state);
1088 CreateFolderForm::GenerateFolderName(String& newName)
1090 String newFolderName;
1091 AppResource::GetInstance()->GetString(L"IDS_COM_POP_FOLDER", newFolderName);
1092 AppLogDebug("Entry");
1094 int currentNameCount = 0;
1095 bool checkFileAvailability = false;
1096 String directoryName = FolderNavigationPresentationModel::GetCurrentPath();
1098 directoryName.Append(newFolderName);
1100 checkFileAvailability = File::IsFileExist(directoryName);
1102 while (checkFileAvailability)
1105 newFolderName.Clear();
1106 AppResource::GetInstance()->GetString(L"IDS_COM_POP_FOLDER", newFolderName);
1107 newFolderName.Append("_");
1108 newFolderName.Append(currentNameCount);
1109 directoryName.Clear();
1110 directoryName = FolderNavigationPresentationModel::GetCurrentPath();
1111 directoryName.Append(newFolderName);
1112 checkFileAvailability = File::IsFileExist(directoryName);
1115 newName = newFolderName;
1120 CreateFolderForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,
1121 const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1123 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1127 CreateFolderForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId,
1128 const Tizen::Ui::Scenes::SceneId &nextSceneId)
1130 //Empty Implementation.
1134 CreateFolderForm::CreateFileProgressingPopup(void)
1136 AppLogDebug("Entry");
1137 result r = E_SUCCESS;
1138 _pFileProgressingPopup = new (std::nothrow) Popup();
1139 _pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
1140 if (_pFileProgressingPopup != null)
1142 _pFileProgressingPopup->SetTitleText(L"FileProcessing");
1144 _pFileProgressingCancelButton = static_cast< Button* >(_pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1145 if (_pFileProgressingCancelButton != null)
1147 _pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
1148 _pFileProgressingCancelButton->AddActionEventListener(*this);
1149 _pFileProgressingCancelButton->SetShowState(false);
1152 _pFileProgressingProgress = static_cast< Progress* >(_pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
1153 if (_pFileProgressingProgress != null)
1155 _pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
1156 _pFileProgressingProgress->SetValue(0);
1157 _pFileProgressingProgress->SetShowState(false);
1160 _pFileProgressingHeaderLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
1161 if (_pFileProgressingHeaderLabel != null)
1163 _pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
1164 _pFileProgressingHeaderLabel->SetShowState(true);
1167 _pFileProgressingLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
1168 if (_pFileProgressingLabel != null)
1170 _pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
1171 _pFileProgressingLabel->SetShowState(true);
1174 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1179 CreateFolderForm::HideFileProgressingPopup(void)
1181 if (_pFileProgressingPopup != null && _pFileProgressingPopup->IsVisible())
1183 _pFileProgressingPopup->SetShowState(false);
1185 delete _pFileProgressingPopup;
1186 _pFileProgressingPopup = null;
1191 CreateFolderForm::ShowFileProgressingPopup(void)
1193 String renamingLabelText;
1194 String copyingLabelText;
1196 AppResource* pAppResource = null;
1197 pAppResource = Application::GetInstance()->GetAppResource();
1199 pAppResource->GetString("IDS_MF_POP_RENAMING", renamingLabelText);
1201 renamingLabelText.Append(L"...");
1202 CreateFileProgressingPopup();
1204 if (_pFileProgressingPopup != null)
1206 if (_pFileProgressingHeaderLabel != null)
1208 _pFileProgressingHeaderLabel->SetBounds(X_DEFAULT,Y_DEFAULT,_pFileProgressingPopup->GetBounds().width - 40, _pFileProgressingPopup->GetBounds().height);
1209 _pFileProgressingHeaderLabel->SetTextConfig(40, LABEL_TEXT_STYLE_BOLD);
1210 _pFileProgressingHeaderLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1211 _pFileProgressingHeaderLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1212 _pFileProgressingHeaderLabel->SetText(renamingLabelText);
1213 _pFileProgressingHeaderLabel->Invalidate(true);
1216 _pFileProgressingPopup->SetShowState(true);
1217 _pFileProgressingPopup->Show();
1222 CreateFolderForm::OnFileManagingStart(void)
1224 ShowFileProgressingPopup();
1228 CreateFolderForm::OnFileManagingStop(FileManagingResult fileProcessingResult)
1234 CreateFolderForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
1236 AppLogDebug("ENTER");
1238 int fileProcessingResult = 0;
1239 SceneManager* pSceneManager = null;
1240 HashMap* pCacheList = null;
1241 String oldCachePath;
1242 bool cacheKeyStatus = false;
1243 pSceneManager = SceneManager::GetInstance();
1244 Integer* pfileProcessingResult = null;
1245 TryCatch(pArgs != null, , "Argument list received is invalid");
1247 pfileProcessingResult = (Integer*) pArgs->GetAt(0);
1248 if (pfileProcessingResult != null)
1250 fileProcessingResult = pfileProcessingResult->ToInt();
1251 delete pfileProcessingResult;
1253 switch (fileProcessingResult)
1255 case FILE_MANAGING_RENAME_SUCCESS:
1257 AppLogDebug("FILE_MANAGING_RENAME_SUCCESS");
1258 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1259 HideFileProgressingPopup();
1261 pSceneManager = SceneManager::GetInstance();
1263 if (pCacheList != null)
1265 oldCachePath = __pDirectory->GetFullFilePath();
1266 cacheKeyStatus = pCacheList->ContainsKey(oldCachePath);
1270 CacheManager::GetInstance()->RenameCacheEntry(oldCachePath,__updatedFilePath);
1273 __pEditFieldFolderName->HideKeypad();
1275 if (pSceneManager != null)
1277 String fileName = __pEditFieldFolderName->GetText();
1279 if(__pDirectory != null)
1281 __pDirectory->SetFileName(fileName);
1284 if (entryIsDirectory == 1)
1286 __updatedFilePath.Append(L"/");
1288 if(__pDirectory != null)
1290 __pDirectory->SetFullFilePath(__updatedFilePath);
1293 if (__isCurrentDirectioryToBeRenamed == true)
1294 FolderNavigationPresentationModel::SetCurrentFilePath(__updatedFilePath);
1296 //pSceneManager->GoBackward(BackwardSceneTransition(), null);
1301 case FILE_MANAGING_RENAME_FAILED:
1303 AppLogDebug("FILE_MANAGING_RENAME_FAILED");
1304 HideFileProgressingPopup();
1305 AppResource* pAppResource = null;
1306 MessageBox messageBox;
1307 String renameFailed;
1309 pAppResource = UiApp::GetInstance()->GetAppResource();
1310 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
1312 pAppResource->GetString(L"IDS_RENAME_FAILED", renameFailed);
1313 messageBox.Construct(L"",renameFailed, MSGBOX_STYLE_NONE, 1000);
1314 int modalResult = 0;
1315 messageBox.ShowAndWait(modalResult);
1317 __pEditFieldFolderName->HideKeypad();
1319 if (pSceneManager != null)
1321 //pSceneManager->GoBackward(BackwardSceneTransition(), null);
1336 pArgs->RemoveAll(false);
1341 AppLogDebug("EXIT");