1.Crop AppControl change 2.Coding idiom changes
authorchitta ranjan <chitta.rs@samsung.com>
Fri, 12 Apr 2013 07:23:13 +0000 (16:23 +0900)
committerchitta ranjan <chitta.rs@samsung.com>
Fri, 12 Apr 2013 07:46:07 +0000 (16:46 +0900)
Change-Id: I5a1847f16e16775fecd36fa16c6a06460b71e9db
Signed-off-by: chitta ranjan <chitta.rs@samsung.com>
inc/IvImageViewerApp.h
inc/IvTypes.h
src/IvImageCropForm.cpp
src/IvImageViewerApp.cpp
src/IvImageViewerForm.cpp
src/IvTypes.cpp

index e3ec078..6ce020a 100644 (file)
@@ -57,6 +57,9 @@ public:
 
        void SetFrameEnabled(bool enabled);
 
+       void SendAppControlResult(const Tizen::App::AppCtrlResult appControlResult,
+                       const Tizen::Base::Collection::IMap* pExtraData);
+
 private:
        RequestId __requestId;
        Tizen::Base::String __operationId;
index e74b6e8..09c7b31 100644 (file)
@@ -107,6 +107,7 @@ extern const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_CROP;
 
 extern const wchar_t* APPCONTROL_KEY_TYPE;
 extern const wchar_t* APPCONTROL_KEY_PATH;
+extern const wchar_t* APPCONTROL_KEY_SELECTED;
 extern const wchar_t* APPCONTROL_KEY_INDEX;
 extern const wchar_t* APPCONTROL_KEY_SELECTION_MODE;
 extern const wchar_t* APPCONTROL_KEY_SOCIAL_ITEM_TYPE;
index 2af24dc..f11648a 100644 (file)
@@ -54,6 +54,9 @@ ImageCropForm::ImageCropForm(void)
        , __pRectangleBitmap(null)
        , __pointLocation(OUTSIDE_CROPBOX)
        , __pPresentationModel(null)
+       , __statusValue(-1)
+       , __formHeight(0)
+       , __formWidth(0)
 {
 }
 
@@ -241,8 +244,24 @@ ImageCropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
        switch(actionId)
        {
        case IDA_BUTTON_CANCEL:
-               pSceneManager->GoBackward(BackwardSceneTransition());
-               break;
+       {
+               ImageViewerApp* pApp = dynamic_cast<ImageViewerApp*>(UiApp::GetInstance());
+
+               if (pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_IMAGE_CROP)
+               {
+                       if (pApp != null)
+                       {
+                               pApp->SendAppControlResult(APP_CTRL_RESULT_CANCELED, null);
+                               pApp->Terminate();
+                       }
+               }
+               else
+               {
+                       pSceneManager->GoBackward(BackwardSceneTransition());
+               }
+       }
+       break;
+
        case IDA_BUTTON_SAVE:
        {
                if (__cropMode == APPCONTROL_DATA_AUTO)
@@ -274,14 +293,32 @@ ImageCropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                        }
                        ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
                        pList->Add(new (std::nothrow) String(destFilePath));
-                       pSceneManager->GoBackward(BackwardSceneTransition(), pList);
+                       ImageViewerApp* pApp = dynamic_cast<ImageViewerApp*>(UiApp::GetInstance());
+
+                       if (pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_IMAGE_CROP)
+                       {
+                               HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
+                               pMap->Construct();
+                               pMap->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTED), pList);
+
+                               if (pApp != null)
+                               {
+                                       pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, pMap);
+                                       pApp->Terminate();
+                               }
+                       }
+                       else
+                       {
+                               pSceneManager->GoBackward(BackwardSceneTransition(), pList);
+                       }
                }
-               else if(__cropMode == APPCONTROL_DATA_FIT_TO_SCREEN)
+               else if (__cropMode == APPCONTROL_DATA_FIT_TO_SCREEN)
                {
                        ImageBuffer* pCropBuffer = null;
                        result r = E_SUCCESS;
                        pCropBuffer = __imageBuffer.CropN(((__cropBox.x - __imageBox.x) * __imageWidth) / __imageBox.width, ((__cropBox.y - __imageBox.y) * __imageHeight) / __imageBox.height,
                                        (__cropBox.width * __imageWidth) / __imageBox.width, (__cropBox.height * __imageHeight) / __imageBox.height);
+
                        if (__statusValue == SET_AT_TYPE_HOME_SCREEN_WALLPAPER)
                        {
                                String destPath = App::GetInstance()->GetAppDataPath() + TEMP_FILE_PATH_HOME_SCREEN_WALLPAPER;
@@ -355,9 +392,11 @@ ImageCropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                                delete pContact;
                                delete pAddressbook;
                                delete pCropBuffer;
+
                                ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
                                pList->Add(new (std::nothrow) String(destFilePath));
                                pSceneManager->GoBackward(BackwardSceneTransition(), pList);
+
                                AppLogDebug("EXIT(%s)1", GetErrorMessage(GetLastResult()));
                                return;
                        }
@@ -866,7 +905,7 @@ ImageCropForm::SetValue(void)
                __formHeight = Form::GetBounds().height;
                __formWidth = Form::GetBounds().width;
        }
-       else if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+       else if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
        {
                __formHeight = Form::GetBounds().width;
                __formWidth = Form::GetBounds().height;
index 1b269fc..bae8687 100644 (file)
@@ -247,3 +247,12 @@ ImageViewerApp::SetFrameEnabled(bool enabled)
                pMainFrame->SetEnabled(enabled);
        }
 }
+
+void
+ImageViewerApp::SendAppControlResult(const AppCtrlResult appControlResult, const IMap* pExtraData)
+{
+       AppLogDebug("ENTER");
+       AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
+       pAppManager->SendAppControlResult(__requestId, appControlResult, pExtraData);
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
index 07f9c5c..1ae41b2 100644 (file)
@@ -199,7 +199,7 @@ ImageViewerForm::OnInitializing(void)
 
        __pLabel = dynamic_cast<Label*>(GetControl(L"IDC_LABEL_INFO"));
 
-       if(__pLabel == null)
+       if (__pLabel == null)
        {
                return E_FAILURE;
        }
@@ -1151,7 +1151,7 @@ ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
        AppLogDebug("ImageViewerForm::DeleteItem ENTER index(%d)", index);
        int curIndex = index;
 
-       if(__shuffle == true && __pShuffledList != null)
+       if (__shuffle == true && __pShuffledList != null)
        {
                curIndex = __pShuffledList[index];
        }
@@ -1272,10 +1272,10 @@ ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
 
        int index;
 
-       if(__shuffle == true)
+       if (__shuffle == true)
        {
 
-               if(__pShuffelTimer == null)
+               if (__pShuffelTimer == null)
                {
                        __pShuffelTimer = new (std::nothrow) Timer();
                        __pShuffelTimer->Construct(*this);
@@ -1344,7 +1344,7 @@ ImageViewerForm::OnTerminating(void)
                __pTimer = null;
        }
 
-       if(__pShuffelTimer)
+       if (__pShuffelTimer)
        {
                __pShuffelTimer->Cancel();
                delete __pShuffelTimer;
@@ -1385,7 +1385,7 @@ ImageViewerForm::OnTerminating(void)
                __pContextMenuMore = null;
        }
 
-       if(__pShuffledList != null)
+       if (__pShuffledList != null)
        {
                free(__pShuffledList);
                __pShuffledList = null;
@@ -1690,6 +1690,7 @@ ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
                __pGallery->UpdateGallery();
                __pGallery->SetCurrentItemIndex(count);
                __pPresentationModel->RequestImage(filePath);
+               ShowPanelDetail(__detail);
        }
 
        if (__pGallery->GetCurrentItemIndex() < 0)
@@ -1816,7 +1817,7 @@ ImageViewerForm::OnTimerExpired(Timer &timer)
 {
        AppLog("ImageViewerForm::OnTimerExpired");
 
-       if(timer.Equals(*__pShuffelTimer) == true)
+       if (timer.Equals(*__pShuffelTimer) == true)
        {
                AppLog("OnTimerExpired __pShuffelTimer");
                int curItemIndex = __pGallery->GetCurrentItemIndex();
@@ -1874,7 +1875,7 @@ void
 ImageViewerForm::CreateShuffledList(int count)
 {
        AppLogDebug("ENTER");
-       if(__pShuffledList == null)
+       if (__pShuffledList == null)
        {
                __pShuffledList = new (std::nothrow) int[count];
                for(int i = 0; i < count; ++i)
index b708757..edc5e6e 100644 (file)
@@ -50,6 +50,7 @@ const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_CROP = L"http://tizen.org/appcontro
 
 const wchar_t* APPCONTROL_KEY_TYPE = L"http://tizen.org/appcontrol/data/type";
 const wchar_t* APPCONTROL_KEY_PATH = L"http://tizen.org/appcontrol/data/path";
+const wchar_t* APPCONTROL_KEY_SELECTED = L"http://tizen.org/appcontrol/data/selected";
 const wchar_t* APPCONTROL_KEY_INDEX = L"http://tizen.org/appcontrol/data/index";
 const wchar_t* APPCONTROL_KEY_SELECTION_MODE = L"http://tizen.org/appcontrol/data/selection_mode";
 const wchar_t* APPCONTROL_KEY_SOCIAL_ITEM_TYPE = L"http://tizen.org/appcontrol/data/social/item_type";