add launch app control for configuration code. show icon and preview
authorjungmin76.park <jungmin76.park@samsung.com>
Mon, 4 Feb 2013 03:51:57 +0000 (12:51 +0900)
committerjungmin76.park <jungmin76.park@samsung.com>
Mon, 4 Feb 2013 04:08:04 +0000 (13:08 +0900)
Change-Id: Ibcb9d12728384e2e28294775dba1d6f74c4d5b36
Signed-off-by: jungmin76.park <jungmin76.park@samsung.com>
project/inc/LiveboxViewerMainForm.h
project/inc/ViewForm.h
project/src/LiveboxViewerMainForm.cpp
project/src/ViewForm.cpp

index cf0b461..25aa762 100644 (file)
 #ifndef _LIVEBOX_VIEWER_MAIN_FORM_H_
 #define _LIVEBOX_VIEWER_MAIN_FORM_H_
 
+#include <FApp.h>
 #include <FBase.h>
 #include <FUi.h>
+#include <FShellLiveboxProviderInfo.h>
 
 class LiveboxViewerMainForm
        : public Tizen::Ui::Controls::Form
@@ -28,6 +30,7 @@ class LiveboxViewerMainForm
        , public Tizen::Ui::Scenes::ISceneEventListener
        , public Tizen::Ui::Controls::IListViewItemEventListener
        , public Tizen::Ui::Controls::IListViewItemProvider
+       , public Tizen::App::IAppControlResponseListener
 {
 public:
        LiveboxViewerMainForm(void);
@@ -54,10 +57,18 @@ private:
        virtual Tizen::Ui::Controls::ListItemBase*  CreateItem (int index, int itemWidth);
        virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
 
+       virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData);
+       void StartConfigurationAppControl(const Tizen::Base::String& appId, const Tizen::Base::String& providerName);
+       void GoLiveboxViewScene(const Tizen::Base::String& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& userInfo);
+
 private:
        static const int ID_FORMAT_STRING = 500;
+       static const int ID_FORMAT_BITMAP = 501;
+
        Tizen::Ui::Controls::ListView* __pList;
        Tizen::Base::Collection::IList* __pLiveboxProviderList;
+       Tizen::Base::Collection::ArrayList* __pLiveboxIconList;
+       Tizen::Shell::LiveboxProviderInfo* __pSelectedProviderInfo;
 }; // LiveboxViewerMainForm
 
 #endif // _LIVEBOX_VIEWER_MAIN_FORM_H_
index 12cfb25..35c566b 100644 (file)
@@ -40,7 +40,7 @@ public:
        virtual result OnTerminating(void);
 
 private:
-       void CreateLiveboxView(const Tizen::Base::String& appId, const Tizen::Base::String& liveboxProviderId);
+       void CreateLiveboxView(const Tizen::Base::String& appId, const Tizen::Base::String& liveboxProviderId, const Tizen::Base::String& userInfo);
        virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
        virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
        virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
index 3198472..0216579 100644 (file)
@@ -16,6 +16,7 @@
 //
 
 #include <FApp.h>
+#include <FMedia.h>
 #include <FShellLiveboxProviderInfo.h>
 #include <FShellLiveboxManager.h>
 #include <FShellLiveboxSizeInfo.h>
@@ -32,6 +33,7 @@ using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Shell;
 
+const int LIST_ITEM_ICON = 72;
 const int LIST_ITEM_HEIGHT = 112;
 const int LIST_ITEM_MARGIN_LEFT = 26;
 const int LIST_ITEM_MARGIN_TOP = 32;
@@ -44,7 +46,18 @@ LiveboxViewerMainForm::LiveboxViewerMainForm(void)
        __pLiveboxProviderList = LiveboxManager::GetInstance()->GetLiveboxProviderInfoListN();
        TryReturnVoid(__pLiveboxProviderList, "GetLiveboxListN returns null!!" );
 
-       AppLog("All livebox count (%d)", __pLiveboxProviderList->GetCount() );
+       __pLiveboxIconList = new ArrayList(SingleObjectDeleter);
+       __pLiveboxIconList->Construct();
+       for( int i = 0; i < __pLiveboxProviderList->GetCount(); i++)
+       {
+               LiveboxProviderInfo* pLiveboxProviderInfo = dynamic_cast<LiveboxProviderInfo*>(__pLiveboxProviderList->GetAt(i) );
+
+               Tizen::Media::Image image;
+               result r = image.Construct();
+               Bitmap* pBmp = image.DecodeN(pLiveboxProviderInfo->GetIconPath(), BITMAP_PIXEL_FORMAT_ARGB8888);
+
+               __pLiveboxIconList->Add(pBmp);
+       }
 }
 
 LiveboxViewerMainForm::~LiveboxViewerMainForm(void)
@@ -114,6 +127,12 @@ LiveboxViewerMainForm::OnTerminating(void)
                delete __pLiveboxProviderList;
        }
 
+       if (__pLiveboxIconList)
+       {
+               __pLiveboxIconList->RemoveAll();
+               delete __pLiveboxIconList;
+       }
+
        return r;
 }
 
@@ -159,28 +178,54 @@ LiveboxViewerMainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& curr
 void
 LiveboxViewerMainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
 {
-       SceneManager* pSceneManager = SceneManager::GetInstance();
-       AppAssert(pSceneManager);
-
        if(status == LIST_ITEM_STATUS_SELECTED)
        {
-               ArrayList* pList = new (std::nothrow) ArrayList;
-               AppAssert(pList);
-               pList->Construct();
+               __pSelectedProviderInfo = dynamic_cast<LiveboxProviderInfo*>(__pLiveboxProviderList->GetAt(index));
+               AppAssert(__pSelectedProviderInfo);
 
-               LiveboxProviderInfo* pProviderInfo = dynamic_cast<LiveboxProviderInfo*>(__pLiveboxProviderList->GetAt(index));
-               AppAssert(pProviderInfo);
+               String configurationAppControlAppId = __pSelectedProviderInfo->GetConfigurationAppControlAppId();
+               if(!configurationAppControlAppId.IsEmpty())
+               {
+                       StartConfigurationAppControl(__pSelectedProviderInfo->GetConfigurationAppControlAppId(), __pSelectedProviderInfo->GetName());
+               }
+               else
+               {
+                       AppLog("%ls", __pSelectedProviderInfo->GetDisplayName().GetPointer());
+                       GoLiveboxViewScene(__pSelectedProviderInfo->GetAppId(), __pSelectedProviderInfo->GetName(), L"");
+               }
+       }
+}
 
-               AppLog("Display name (%ls)", pProviderInfo->GetDisplayName().GetPointer());
-               AppLog("AppId (%ls)", pProviderInfo->GetAppId().GetPointer());
-               AppLog("Name (%ls)", pProviderInfo->GetName().GetPointer());
+void
+LiveboxViewerMainForm::StartConfigurationAppControl(const Tizen::Base::String& appId, const Tizen::Base::String& providerName)
+{
+       AppControl* pAc = AppManager::FindAppControlN( appId, L"http://tizen.org/appcontrol/operation/livebox/configuration");
+       HashMap extra;
+       extra.Construct();
+       String key = L"ProviderName";
+       String value = providerName;
+       extra.Add(&key, &value);
+
+       pAc->Start(null, null, &extra, this);
+       delete pAc;
+}
 
-               pList->Add(*(new (std::nothrow) String( pProviderInfo->GetDisplayName())));
-               pList->Add(*(new (std::nothrow) String( pProviderInfo->GetAppId()) ));
-               pList->Add(*(new (std::nothrow) String( pProviderInfo->GetName()) ));
+void
+LiveboxViewerMainForm::GoLiveboxViewScene(const String& appId, const String& providerName, const String& userInfo)
+{
+       ArrayList* pList = new (std::nothrow) ArrayList;
+       AppAssert(pList);
+       pList->Construct();
 
-               pSceneManager->GoForward(ForwardSceneTransition(VIEW_SCENE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
-       }
+       pList->Add(*(new (std::nothrow) String(appId) ));
+       pList->Add(*(new (std::nothrow) String(providerName) ));
+       pList->Add(*(new (std::nothrow) String(userInfo )) );
+
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       AppAssert(pSceneManager);
+
+       pSceneManager->GoForward(ForwardSceneTransition(VIEW_SCENE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
+       __pSelectedProviderInfo = null;
 }
 
 void
@@ -207,21 +252,21 @@ LiveboxViewerMainForm::GetItemCount(void)
 Tizen::Ui::Controls::ListItemBase*
 LiveboxViewerMainForm::CreateItem (int index, int itemWidth)
 {
-       ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
-       
        CustomItem* pItem = new (std::nothrow) CustomItem();
-       pItem->Construct(Tizen::Graphics::Dimension(itemWidth, LIST_ITEM_HEIGHT), style);
+       pItem->Construct(Tizen::Graphics::Dimension(itemWidth, LIST_ITEM_HEIGHT), LIST_ANNEX_STYLE_NORMAL);
        
-       Rectangle itemRect(LIST_ITEM_MARGIN_LEFT, LIST_ITEM_MARGIN_TOP, GetClientAreaBounds().width - (LIST_ITEM_MARGIN_LEFT * 2), LIST_ITEM_TEXT_HEIGHT);
+       Rectangle iconRect(LIST_ITEM_MARGIN_LEFT, LIST_ITEM_MARGIN_TOP/2, LIST_ITEM_ICON, LIST_ITEM_ICON);
+       int text_x = LIST_ITEM_ICON + LIST_ITEM_MARGIN_LEFT + 20;
+       Rectangle textRect(text_x, LIST_ITEM_MARGIN_TOP, GetClientAreaBounds().width - LIST_ITEM_MARGIN_LEFT - text_x, LIST_ITEM_TEXT_HEIGHT);
        
        LiveboxProviderInfo* pProviderInfo = dynamic_cast<LiveboxProviderInfo*>(__pLiveboxProviderList->GetAt(index));
+
        if (pProviderInfo)
        {
-               String itemTitle(pProviderInfo->GetDisplayName());
-
-               AppLog("Item title (%ls)", itemTitle.GetPointer());
+               Bitmap* pBmp = dynamic_cast<Bitmap*>(__pLiveboxIconList->GetAt(index));
 
-               pItem->AddElement(itemRect, ID_FORMAT_STRING, itemTitle, true);
+               pItem->AddElement(iconRect, ID_FORMAT_BITMAP, *pBmp, null, null);
+               pItem->AddElement(textRect, ID_FORMAT_STRING, pProviderInfo->GetDisplayName()+" ("+pProviderInfo->GetAppId()+")", true);
        }
 
        return pItem;
@@ -233,3 +278,20 @@ LiveboxViewerMainForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *
        delete pItem;
        return true;
 }
+
+
+void
+LiveboxViewerMainForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId, AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
+{
+       String temp;
+       TryReturnVoid(__pSelectedProviderInfo, "__pSelectedProviderInfo should not be null!");
+
+       if(pExtraData)
+       {
+               String userInfokey(L"UserInfo");
+               const String* pUserInfoValue = dynamic_cast<const String*>(pExtraData->GetValue(userInfokey) );
+               AppLog("%ls, %ls, %ls", appId.GetPointer(), operationId.GetPointer(), pUserInfoValue->GetPointer() );
+
+               GoLiveboxViewScene(__pSelectedProviderInfo->GetAppId(), __pSelectedProviderInfo->GetName(), *pUserInfoValue);
+       }
+}
index c35f550..19ecd83 100644 (file)
@@ -16,6 +16,8 @@
 //
 
 #include <unique_ptr.h>
+#include <FApp.h>
+#include <FMedia.h>
 #include <FShellLiveboxView.h>
 #include <FShellLiveboxManager.h>
 #include <FShellLiveboxProviderInfo.h>
@@ -30,6 +32,7 @@ using namespace Tizen::Ui;
 using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Shell;
+using namespace Tizen::Media;
 
 const int CONTEXT_MENU_X = 100;
 const int CONTEXT_MENU_Y = 200;
@@ -86,12 +89,12 @@ ViewForm::OnTerminating(void)
 }
 
 void
-ViewForm::CreateLiveboxView(const Tizen::Base::String& appId, const Tizen::Base::String& providerName)
+ViewForm::CreateLiveboxView(const Tizen::Base::String& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& userInfo)
 {
        unique_ptr<LiveboxView> pLiveboxView(new LiveboxView());
        if (pLiveboxView)
        {
-               result r = pLiveboxView->Construct(appId, providerName, Rectangle(VIEW_X, VIEW_Y, VIEW_WIDTH, VIEW_HEIGHT));
+               result r = pLiveboxView->Construct(appId, providerName, Rectangle(VIEW_X, VIEW_Y, VIEW_WIDTH, VIEW_HEIGHT), userInfo);
                TryReturnVoid(r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
 
                AddControl(*pLiveboxView);
@@ -121,7 +124,21 @@ ViewForm::CreateLiveboxView(const Tizen::Base::String& appId, const Tizen::Base:
                        String size;
                        size.Format(255, L"%dx%d", pSizeInfo->GetSize().width, pSizeInfo->GetSize().height);
 
-                       __pContextMenu->AddItem(size, i);
+                       Image image;
+                       result r = image.Construct();
+//                     Bitmap* pBmp = image.DecodeN(L"/opt/apps/yPpyL2WVNQ/shared/res/screen-density-xhigh/2x2.png", BITMAP_PIXEL_FORMAT_ARGB8888);
+                       Bitmap* pBmp = image.DecodeN(pSizeInfo->GetPreviewImagePath(), BITMAP_PIXEL_FORMAT_ARGB8888);
+
+
+                       if( pBmp)
+                       {
+//                             __pContextMenu->AddItem(size, i, *pBmp );
+                               __pContextMenu->AddItem(size, i, *pBmp );
+                       }
+                       else
+                       {
+                               __pContextMenu->AddItem(size, i);
+                       }
                }
        }
 
@@ -177,19 +194,17 @@ ViewForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, c
 {
        if (pArgs && (pArgs->GetCount() > 0))
        {
-               String* pDisplayName = dynamic_cast<String*>(pArgs->GetAt(0));
-               String* pAppId = dynamic_cast<String*>(pArgs->GetAt(1));
-               String* pLiveboxProviderName = dynamic_cast<String*>(pArgs->GetAt(2));
+               String* pAppId = dynamic_cast<String*>(pArgs->GetAt(0));
+               String* pLiveboxProviderName = dynamic_cast<String*>(pArgs->GetAt(1));
+               String* pUserInfo = dynamic_cast<String*>(pArgs->GetAt(2));
                if (pAppId != null && pLiveboxProviderName != null)
                {
-                       AppLog("%ls", pDisplayName->GetPointer());
                        AppLog("%ls", pAppId->GetPointer());
-                       AppLog("%ls", pLiveboxProviderName->GetPointer());
 
                        Header* pHeader = GetHeader();
-                       pHeader->SetTitleText(*pDisplayName);
+                       pHeader->SetTitleText(*pAppId);
 
-                       CreateLiveboxView(*pAppId, *pLiveboxProviderName);
+                       CreateLiveboxView(*pAppId, *pLiveboxProviderName, *pUserInfo);
                }
                
                pArgs->RemoveAll(true);