3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 #include <FShellLiveboxProviderInfo.h>
20 #include <FShellLiveboxManager.h>
21 #include <FShellLiveboxSizeInfo.h>
23 #include "LiveboxViewerMainForm.h"
24 #include "LiveboxViewerFormFactory.h"
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::App;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Ui;
31 using namespace Tizen::Ui::Controls;
32 using namespace Tizen::Ui::Scenes;
33 using namespace Tizen::Shell;
35 const int LIST_ITEM_HEIGHT = 112;
36 const int LIST_ITEM_MARGIN_LEFT = 26;
37 const int LIST_ITEM_MARGIN_TOP = 32;
38 const int LIST_ITEM_TEXT_HEIGHT = 44;
40 LiveboxViewerMainForm::LiveboxViewerMainForm(void)
42 , __pLiveboxProviderList(null)
44 __pLiveboxProviderList = LiveboxManager::GetInstance()->GetLiveboxProviderInfoListN();
45 TryReturnVoid(__pLiveboxProviderList, "GetLiveboxListN returns null!!" );
47 AppLog("All livebox count (%d)", __pLiveboxProviderList->GetCount() );
50 LiveboxViewerMainForm::~LiveboxViewerMainForm(void)
55 LiveboxViewerMainForm::Initialize(void)
57 Construct(L"IDF_FORM");
63 LiveboxViewerMainForm::OnInitializing(void)
67 // Setup back event listener
68 SetFormBackEventListener(this);
70 if (!__pLiveboxProviderList)
72 AppLog("GetLiveboxListN returns null!!");
76 for(int i = 0; i < __pLiveboxProviderList->GetCount(); i++)
78 LiveboxProviderInfo* pLiveboxProviderInfo = dynamic_cast<LiveboxProviderInfo*>(__pLiveboxProviderList->GetAt(i) );
80 IList* pSizeList = pLiveboxProviderInfo->GetSizeInfoListN();
81 if(pSizeList == null) continue;
82 AppLog("%ls, support (%d) sizes", pLiveboxProviderInfo->GetDisplayName().GetPointer(), pSizeList->GetCount() );
84 for(int j = 0; j < pSizeList->GetCount(); j ++)
86 LiveboxSizeInfo* pSizeInfo = dynamic_cast<LiveboxSizeInfo*>(pSizeList->GetAt(j) );
87 AppLog("(%d, %d)", pSizeInfo->GetSize().width, pSizeInfo->GetSize().height);
89 pSizeList->RemoveAll(true);
94 // Add your initialization code here
95 __pList = new (std::nothrow) ListView();
96 __pList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), true, false);
97 __pList->SetItemProvider(*this);
98 __pList->AddListViewItemEventListener(*this);
105 LiveboxViewerMainForm::OnTerminating(void)
107 result r = E_SUCCESS;
110 // Add your termination code here
111 if (__pLiveboxProviderList)
113 __pLiveboxProviderList->RemoveAll(true);
114 delete __pLiveboxProviderList;
121 LiveboxViewerMainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
123 SceneManager* pSceneManager = SceneManager::GetInstance();
124 AppAssert(pSceneManager);
134 LiveboxViewerMainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
136 UiApp* pApp = UiApp::GetInstance();
142 LiveboxViewerMainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
143 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
146 // Add your scene activate code here
147 AppLog("OnSceneActivatedN");
151 LiveboxViewerMainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
152 const Tizen::Ui::Scenes::SceneId& nextSceneId)
155 // Add your scene deactivate code here
156 AppLog("OnSceneDeactivated");
160 LiveboxViewerMainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
162 SceneManager* pSceneManager = SceneManager::GetInstance();
163 AppAssert(pSceneManager);
165 if(status == LIST_ITEM_STATUS_SELECTED)
167 ArrayList* pList = new (std::nothrow) ArrayList;
171 LiveboxProviderInfo* pProviderInfo = dynamic_cast<LiveboxProviderInfo*>(__pLiveboxProviderList->GetAt(index));
172 AppAssert(pProviderInfo);
174 AppLog("Display name (%ls)", pProviderInfo->GetDisplayName().GetPointer());
175 AppLog("AppId (%ls)", pProviderInfo->GetAppId().GetPointer());
176 AppLog("Name (%ls)", pProviderInfo->GetName().GetPointer());
178 pList->Add(*(new (std::nothrow) String( pProviderInfo->GetDisplayName())));
179 pList->Add(*(new (std::nothrow) String( pProviderInfo->GetAppId()) ));
180 pList->Add(*(new (std::nothrow) String( pProviderInfo->GetName()) ));
182 pSceneManager->GoForward(ForwardSceneTransition(VIEW_SCENE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
187 LiveboxViewerMainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView &listView, int index, Tizen::Ui::Controls::SweepDirection direction)
192 LiveboxViewerMainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
197 LiveboxViewerMainForm::OnItemReordered(Tizen::Ui::Controls::ListView &view, int oldIndex, int newIndex)
202 LiveboxViewerMainForm::GetItemCount(void)
204 return __pLiveboxProviderList->GetCount();
207 Tizen::Ui::Controls::ListItemBase*
208 LiveboxViewerMainForm::CreateItem (int index, int itemWidth)
210 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
212 CustomItem* pItem = new (std::nothrow) CustomItem();
213 pItem->Construct(Tizen::Graphics::Dimension(itemWidth, LIST_ITEM_HEIGHT), style);
215 Rectangle itemRect(LIST_ITEM_MARGIN_LEFT, LIST_ITEM_MARGIN_TOP, GetClientAreaBounds().width - (LIST_ITEM_MARGIN_LEFT * 2), LIST_ITEM_TEXT_HEIGHT);
217 LiveboxProviderInfo* pProviderInfo = dynamic_cast<LiveboxProviderInfo*>(__pLiveboxProviderList->GetAt(index));
220 String itemTitle(pProviderInfo->GetDisplayName());
222 AppLog("Item title (%ls)", itemTitle.GetPointer());
224 pItem->AddElement(itemRect, ID_FORMAT_STRING, itemTitle, true);
231 LiveboxViewerMainForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)