*/
#include <FMedia.h>
+#include <FText.h>
+
#include "GlAlbumInfo.h"
#include "GlAlbumListPresentationModel.h"
#include "GlAlbumNameEditorForm.h"
using namespace Tizen::Io;
using namespace Tizen::Media;
using namespace Tizen::System;
+using namespace Tizen::Text;
using namespace Tizen::Ui;
using namespace Tizen::Ui::Controls;
using namespace Tizen::Ui::Scenes;
-static const Rectangle RECT_NAME_EDIT_FIELD (0, 0, 720, 100);
static const unsigned int COLOR_NAME_EDIT_FIELD = Color32<255, 255, 255>::Value;
-static const int ALBUM_MAX_LENGTH = 255;
AlbumNameEditorForm::AlbumNameEditorForm(void)
: __pNameEditField(null)
, __folderIndex(0)
+ , __modalMsgBoxResult(0)
+ , __textLength(0)
, __mountState(false)
, __albumNameEditorMode(ALBUM_NAME_EDITOR_MODE_RENAME)
, __pMessageBox(null)
AlbumNameEditorForm::Initialize(void)
{
AppLogDebug("ENTER");
- result r = Construct(FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR);
+ result r = Construct(L"IDL_FORM_ALBUM_NAME_EDITOR");
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
return r;
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
__pFilePresentationModel = FileListPresentationModel::GetInstance();
+ SetOrientation(ORIENTATION_AUTOMATIC);
+ AddOrientationEventListener(*this);
+
DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
Header* pHeader = GetHeader();
pHeader->SetStyle(HEADER_STYLE_TITLE);
- GetFooter()->SetBackButtonEnabled(true);
- GetFooter()->SetBackButton();
-
FooterItem itemSave;
itemSave.Construct(IDA_BUTTON_CREATE_NAME_SAVE);
itemSave.SetText(ResourceManager::GetString(L"IDS_COM_OPT_SAVE"));
SetFormBackEventListener(this);
SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
- __pNameEditField = new (std::nothrow) EditField();
- __pNameEditField->Construct(RECT_NAME_EDIT_FIELD, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY,
- EDIT_FIELD_TITLE_STYLE_NONE, true, ALBUM_MAX_LENGTH);
+ __pNameEditField = static_cast<EditField*>(GetControl(L"IDC_EDITFIELD_NAME"));
__pNameEditField->AddTextEventListener(*this);
__pNameEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_NAME_EDIT_FIELD);
__pNameEditField->SetOverlayKeypadCommandButtonVisible(false);
-
- AddControl(__pNameEditField);
__pNameEditField->AddActionEventListener(*this);
return E_SUCCESS;
void
AlbumNameEditorForm::OnTextValueChanged(const Control& source)
{
- AppLogDebug("ENTER");
- String inputString = __pNameEditField->GetText();
-
- if (inputString.Contains(DIRECTORY_SEPARATOR) == true)
- {
- if (__pMessageBox == null)
- {
- __pMessageBox = new (std::nothrow) MessageBox();
- __pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS"),
- MSGBOX_STYLE_NONE, 3000);
- int modalResult = 0;
- _overlayMsg = true;
- __pMessageBox->ShowAndWait(modalResult);
- _overlayMsg = false;
- delete __pMessageBox;
- __pMessageBox = null;
- }
+ String currentInput;
+ String currentText;
+ String specialCharacters(L"/");
+ String byteCountForInput;
+ int byteCount = 0;
+ int inputLength = 0;
+ int tempLength = 255;
+ int textToCheck = 0;
+ MessageBox messageBox;
+ Utf8Encoding utf8;
- __pNameEditField->SetText(__nameEditFieldTempText);
- __pNameEditField->SetFocus();
+ FooterItemStatus currentStatus = FOOTER_ITEM_STATUS_NORMAL;
- return;
- }
+ result r = E_SUCCESS;
- ByteBuffer* pBuffer = StringUtil::StringToUtf8N(inputString);
- int remaining = 0;
- if (pBuffer != null)
+ if (__pNameEditField != null)
{
- remaining = pBuffer->GetRemaining();
+ byteCountForInput = __pNameEditField->GetText();
+ r = utf8.GetByteCount(byteCountForInput, byteCount);
+ AppLogDebug("result is %s",GetErrorMessage(r));
+ AppLogDebug("Byte count is %d",byteCount);
}
- if (remaining >= ALBUM_MAX_LENGTH)
+ if (__pNameEditField != null)
{
- if (__pMessageBox == null)
+ currentText = __pNameEditField->GetText();
+ textToCheck = currentText.GetLength() - __textLength;
+ if (currentText.IsEmpty())
{
- __pMessageBox = new (std::nothrow) MessageBox();
- __pMessageBox->Construct(L"",
- ResourceManager::GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED"),
- MSGBOX_STYLE_NONE, 3000);
- int modalResult = 0;
- __pMessageBox->ShowAndWait(modalResult);
- delete __pMessageBox;
- __pMessageBox = null;
+ if (GetFooter() != null)
+ {
+ GetFooter()->SetItemEnabled(0, false);
+ GetFooter()->Invalidate(true);
+ }
}
+ else
+ {
+ if (GetFooter() != null)
+ {
+ GetFooter()->GetItemStatus(0, currentStatus);
- __pNameEditField->SetText(__nameEditFieldTempText);
- __pNameEditField->SetFocus();
+ if (currentStatus == FOOTER_ITEM_STATUS_DISABLED)
+ {
+ GetFooter()->SetItemEnabled(0,true);
+ GetFooter()->Invalidate(true);
+ }
+ }
+ }
- return;
- }
- __nameEditFieldTempText = inputString;
+ if (currentText.StartsWith(".", 0))
+ {
+ String invalidCharacterString;
+ String validString;
+ String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
+ CreateMessage(msg);
+ validString = __pNameEditField->GetText();
- FooterItemStatus itemStatus;
- GetFooter()->GetItemStatus(0, itemStatus);
- if (inputString.GetLength() == 0)
- {
- if (itemStatus != FOOTER_ITEM_STATUS_DISABLED)
+ if (validString.GetLength() > 1)
+ {
+ validString.Remove(0,1);
+ __pNameEditField->SetText(validString);
+ }
+ else
+ {
+ __pNameEditField->SetText("");
+
+ if (GetFooter() != null)
+ {
+ GetFooter()->SetItemEnabled(0, false);
+ GetFooter()->Invalidate(true);
+ }
+ }
+ __pNameEditField->ShowKeypad();
+ }
+
+ currentInput = __pNameEditField->GetText();
+
+ if (currentInput.Contains(specialCharacters[0]))
{
- GetFooter()->SetItemEnabled(0, false);
+ String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
+ CreateMessage(msg);
+ currentInput.Replace("/", "");
+ __pNameEditField->SetText(currentInput);
}
- }
- else
- {
- if (itemStatus == FOOTER_ITEM_STATUS_DISABLED)
+
+ inputLength = byteCount;
+ if (inputLength >= tempLength)
{
- GetFooter()->SetItemEnabled(0, true);
+ String maxCharacterString;
+ String currentInputCharacter;
+ int checkByteCount = 0;
+ int lengthOfFinalString = 0;
+ int currentCharacter = 0;
+
+ String msg = ResourceManager::GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED");
+ CreateMessage(msg);
+ currentText = __pNameEditField->GetText();
+
+ for (currentCharacter=0; checkByteCount < tempLength; currentCharacter++)
+ {
+ currentInputCharacter.Clear();
+ currentInputCharacter = currentText[currentCharacter];
+ r = utf8.GetByteCount(currentInputCharacter, byteCount);
+ if (r != E_SUCCESS)
+ {
+ break;
+ }
+ AppLogDebug("result of byte count is %s",GetErrorMessage(r));
+ checkByteCount = checkByteCount + byteCount;
+
+ if( checkByteCount < tempLength)
+ {
+ lengthOfFinalString++;
+ }
+ }
+
+ r = __pNameEditField->GetText().SubString(0, lengthOfFinalString, currentInput);
+ AppLogDebug("current input is %S", currentInput.GetPointer());
+ r = __pNameEditField->SetText(currentInput);
+ __pNameEditField->ShowKeypad();
+ return;
}
+
+ r = utf8.GetByteCount(__pNameEditField->GetText(), byteCount);
+ __textLength = byteCount;
}
- GetFooter()->Invalidate(true);
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
{
__pMessageBox->Construct(L"", ResourceManager::GetString(L"IDS_MEDIABR_BODY_UNABLE_TO_RENAME_ALBUM_NAME_ALREADY_IN_USE_ABB"),
MSGBOX_STYLE_NONE, 3000);
+
}
else
{
_overlayMsg = false;
delete __pMessageBox;
__pMessageBox = null;
+ __pNameEditField->SetEnabled(true);
+ __pNameEditField->ShowKeypad();
}
}
else
{
//Add a popup here
- Rectangle clientRect= GetClientAreaBounds();
+ Rectangle clientRect = GetClientAreaBounds();
Rectangle rect(0, 0, clientRect.width, clientRect.height);
__pProgressAnim = new (std::nothrow) ProgressAnimation;
__pProgressAnim->Construct(rect);
{
case IDA_BUTTON_CREATE_NAME_SAVE:
{
+ __pNameEditField->SetEnabled(false);
+
if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
{
OnCreateAlbum();
AlbumNameEditorForm::OnFormBackRequested(Form& source)
{
AppLogDebug("ENTER");
+ if (__pProgressAnim != null)
+ {
+ if (__pProgressAnim->GetShowState())
+ {
+ return;
+ }
+ }
+
if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
{
SceneManager* pSceneManager = SceneManager::GetInstance();
__pPresentationModel = AlbumListPresentationModel::GetInstance();
__previousSceneId = previousSceneId;
+ __pNameEditField->SetEnabled(true);
__pPresentationModel->AddContentEventListener(this);
if (pArgs != null)
}
delete pEnum;
delete pArgs;
+ pArgs = NULL ;
}
}
}
else
{
-
+ int byteCount = 0;
+ Utf8Encoding utf8;
IList* pAlbumInfoList = __pPresentationModel->GetAlbumInfoList();
AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pAlbumInfoList->GetAt(__folderIndex));
__pNameEditField->ShowKeypad();
__pNameEditField->SetFocus();
__originalText = __pNameEditField->GetText();
+ utf8.GetByteCount(__nameEditFieldText, byteCount);
+ __textLength = byteCount;
+ GetFooter()->SetItemEnabled(0, true);
+ GetFooter()->Invalidate(true);
}
if (pArgs != NULL)
if (deviceType == DEVICE_TYPE_STORAGE_CARD && state == DEVICE_STORAGE_CARD_UNMOUNTED)
{
+ if ( __pFileMove && __pFileMove->IsStarted() )
+ {
+ __pFileMove->Cancel();
+ delete __pFileMove;
+ __pFileMove = null;
+ }
__mountState = false;
SceneManager* pSceneManager = SceneManager::GetInstance();
pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
}
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
+
+void
+AlbumNameEditorForm::CreateMessage(String& str)
+{
+ if (__pMessageBox == null)
+ {
+ __pMessageBox = new(std::nothrow) MessageBox;
+
+ if (__pMessageBox != null)
+ {
+ __pMessageBox->Construct(L"", str, MSGBOX_STYLE_OK, 3000);
+ __pMessageBox->ShowAndWait(__modalMsgBoxResult);
+
+ delete __pMessageBox;
+ __pMessageBox = null;
+ __modalMsgBoxResult = 0;
+ }
+ }
+}
+
+void
+AlbumNameEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
+{
+ if ( __pProgressAnim != NULL)
+ {
+ __pProgressAnim->ChangeOrientation(GetClientAreaBounds());
+ __pProgressAnim->Invalidate(true);
+ }
+}