Fixed prevent issues
[apps/osp/Gallery.git] / src / GlAlbumNameEditorForm.cpp
index d0c97cb..4c76280 100644 (file)
@@ -46,10 +46,7 @@ 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)
@@ -83,7 +80,7 @@ result
 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;
@@ -101,9 +98,6 @@ AlbumNameEditorForm::OnInitializing(void)
 
        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"));
@@ -115,14 +109,10 @@ AlbumNameEditorForm::OnInitializing(void)
        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;
@@ -240,7 +230,11 @@ AlbumNameEditorForm::OnTextValueChanged(const Control& source)
                                }
                                AppLogDebug("result of byte count is %s",GetErrorMessage(r));
                                checkByteCount = checkByteCount + byteCount;
-                               lengthOfFinalString++;
+
+                               if( checkByteCount < tempLength)
+                               {
+                                       lengthOfFinalString++;
+                               }
                        }
 
                        r = __pNameEditField->GetText().SubString(0, lengthOfFinalString, currentInput);
@@ -441,6 +435,8 @@ AlbumNameEditorForm::OnActionPerformed(const Control& source, int actionId)
        {
        case IDA_BUTTON_CREATE_NAME_SAVE:
        {
+               __pNameEditField->SetEnabled(false);
+
                if (__albumNameEditorMode == ALBUM_NAME_EDITOR_MODE_CREATE)
                {
                        OnCreateAlbum();
@@ -492,6 +488,7 @@ AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
        __pPresentationModel = AlbumListPresentationModel::GetInstance();
        __previousSceneId = previousSceneId;
 
+       __pNameEditField->SetEnabled(true);
        __pPresentationModel->AddContentEventListener(this);
 
        if (pArgs != null)
@@ -541,6 +538,7 @@ AlbumNameEditorForm::OnSceneActivatedN(const SceneId& previousSceneId,
                        }
                        delete pEnum;
                        delete pArgs;
+                       pArgs = NULL ;
                }
        }