#include <FApp.h>
#include <FIo.h>
#include <FSystem.h>
+#include <FText.h>
#include "IvCommonUtil.h"
#include "IvImageNameEditorForm.h"
#include "IvImageViewerPresentationModel.h"
using namespace Tizen::Media;
using namespace Tizen::Io;
using namespace Tizen::System;
+using namespace Tizen::Text;
-static const int FILE_MAX_LENGTH = 255;
ImageNameEditorForm::ImageNameEditorForm(void)
: __currentIndex(0)
, __modalMsgBoxResult(0)
+ , __textLength(0)
, __pNameEditField(null)
, __pMessageBox(null)
, __pPresentationModel(null)
String inputString;
__nameEditFieldText = __pNameEditField->GetText();
+
switch (actionId)
{
case IDA_BUTTON_EDITFIELD_SAVE:
inputString = __nameEditFieldText;
+ inputString.Trim();
- if (__nameEditFieldPreText == __nameEditFieldText)
+ if (__nameEditFieldPreText == inputString)
{
String msg = ResourceManager::GetString(L"IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE");
CreateMessage(msg);
{
String fileName = File::GetFileName(filePath);
String fileExtension = File::GetFileExtension(filePath);
- String tempFileName = __nameEditFieldText + FILE_EXT_SEPARATOR + fileExtension;
+ String tempFileName = inputString + FILE_EXT_SEPARATOR + fileExtension;
filePath.Replace(fileName, tempFileName);
if (File::IsFileExist(filePath) == true)
void
ImageNameEditorForm::OnTextValueChanged (const Control &source)
{
- AppLogDebug("ENTER");
+ String currentInput;
+ String currentText;
+ String specialCharacters(L"/");
+ String byteCountForInput;
+ int byteCount = 0;
+ int inputLength = 0;
+ int tempLength = 220;
+ int textToCheck = 0;
+ MessageBox messageBox;
+ Utf8Encoding utf8;
- String filePath = __pPresentationModel->GetFilePathAt(__currentIndex);
- String inputString = __pNameEditField->GetText();
- if (inputString.Contains(DIRECTORY_SEPARATOR) == true)
- {
- String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
- CreateMessage(msg);
-
- __pNameEditField->SetText(__nameEditFieldTempText);
- __pNameEditField->SetFocus();
-
- return;
- }
+ FooterItemStatus currentStatus = FOOTER_ITEM_STATUS_NORMAL;
- String ext = File::GetFileExtension(filePath);
+ result r = E_SUCCESS;
- ByteBuffer* buffer = StringUtil::StringToUtf8N(inputString);
- int remaining = 0;
- if (buffer != null)
+ if (__pNameEditField != null)
{
- remaining = buffer->GetRemaining();
+ byteCountForInput = __pNameEditField->GetText();
+ r = utf8.GetByteCount(byteCountForInput, byteCount);
+ AppLogDebug("result is %s",GetErrorMessage(r));
+ AppLogDebug("Bye count is %d",byteCount);
}
- int maximumLength = FILE_MAX_LENGTH - ext.GetLength() - 1;
- if (remaining >= maximumLength)
+ if (__pNameEditField != null)
{
- String msg = ResourceManager::GetString(L"IDS_COM_POP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED");
- CreateMessage(msg);
+ currentText = __pNameEditField->GetText();
+ textToCheck = currentText.GetLength() - __textLength;
+ if (currentText.IsEmpty())
+ {
+ 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);
+ }
- AppLogDebug("EXIT1(%s)", GetErrorMessage(GetLastResult()));
- return;
- }
- __nameEditFieldTempText = inputString;
+ }
+ }
- inputString.Trim();
- FooterItemStatus itemStatus;
- GetFooter()->GetItemStatus(0, itemStatus);
- if (inputString.GetLength() == 0)
- {
- if (itemStatus != FOOTER_ITEM_STATUS_DISABLED)
+ if (currentText.StartsWith(".", 0))
+ {
+ String invalidCharacterString;
+ String validString;
+ String msg = ResourceManager::GetString(L"IDS_COM_POP_INVALID_CHARACTERS");
+ CreateMessage(msg);
+ validString = __pNameEditField->GetText();
+
+ 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;
+ 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);
+ return;
+
- AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
void
AppLogDebug("ENTER");
if (previousSceneId == IDSCN_IMAGE_VIEWER)
{
+ int byteCount = 0;
+ Utf8Encoding utf8;
+
if (pArgs != null)
{
IEnumerator* pEnum = pArgs->GetEnumeratorN();
__nameEditFieldPreText = __nameEditFieldText;
__pNameEditField->SetText(__nameEditFieldText);
+ utf8.GetByteCount(__nameEditFieldText, byteCount);
+ __textLength = byteCount;
__nameEditFieldTempText = __nameEditFieldText;
__pNameEditField->ShowKeypad();