2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file StHomeAndLockScreenForm.cpp
19 * @brief This is the implementation file for HomeAndLockScreenForm class.
22 #include "StHomeAndLockScreenForm.h"
23 #include "StResourceManager.h"
24 #include "StSettingScenesList.h"
27 using namespace Tizen::App::Package;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::System;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
36 static const int ID_INDEX_HOME_SCREEN_WALLPAPER = 0;
37 static const int ID_INDEX_LOCK_SCREEN_WALLPAPER = 1;
39 static const int ID_GROUP_SCREEN_TYPE = 0;
40 static const int ID_ITEM_SCREEN_TYPE = 0;
41 static const int ID_GROUP_SCREEN_TYPE_ITEM_COUNT = 1;
43 static const int ID_GROUP_SCREEN_WALLPAPER = 1;
44 static const int ID_ITEM_SCREEN_WALLPAPER = 0;
45 static const int ID_GROUP_SCREEN_WALLPAPER_ITEM_COUNT = 1;
47 static const int ID_GROUP_COUNT = 2;
48 static const int ID_GROUP_MAX_ITEM_COUNT = 1;
50 HomeAndLockScreenForm::HomeAndLockScreenForm(void)
54 HomeAndLockScreenForm::~HomeAndLockScreenForm(void)
59 HomeAndLockScreenForm::CreateFooter(void)
61 Footer* pFooter = GetFooter();
64 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
65 pFooter->SetBackButton();
66 pFooter->AddActionEventListener(*this);
68 SetFormBackEventListener(this);
72 HomeAndLockScreenForm::OnInitializing(void)
78 HomeAndLockScreenForm::OnTerminating(void)
83 SetFormBackEventListener(null);
89 HomeAndLockScreenForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
93 SetWallpaperIndex(*static_cast<String*>(pArgs->GetAt(0)));
95 AppLogDebug("Screen Mode[%d] ( home::0 / Lock::1 )", GetWallpaperIndex());
97 CreateHeader(GetTitleText());
100 AppLogDebug("ENTER");
102 __pTableView->UpdateTableView();
104 else if (previousSceneId.Equals(IDSCN_SCREEN_TYPE, false))
106 __pTableView->RefreshItem(0,0,TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
110 AppLogDebug("pArgs Null");
115 HomeAndLockScreenForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
120 HomeAndLockScreenForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
122 SceneManager* pSceneManager = SceneManager::GetInstance();
123 AppAssert(pSceneManager);
125 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
129 HomeAndLockScreenForm::GetGroupCount(void)
131 AppLogDebug("ENTER");
132 return ID_GROUP_COUNT;
136 HomeAndLockScreenForm::GetItemCount(int groupIndex)
138 int itemCount = ID_GROUP_MAX_ITEM_COUNT;
140 AppLogDebug("GetItemCount %d", itemCount);
146 HomeAndLockScreenForm::CreateGroupItem(int groupIndex, int itemWidth)
148 AppLogDebug("ENTER");
150 int itemHeight = H_GROUP_INDEX_DEFAULT;;
152 Rectangle itemMainRectangle;
154 Label* pLabel = null;
156 groupText = GetGroupText(groupIndex);
158 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
159 itemMainRectangle.y = yItemOffset;
160 itemMainRectangle.width = itemWidth;
161 itemMainRectangle.height = itemHeight;
163 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
165 RelativeLayout relativeLayout;
166 relativeLayout.Construct();
168 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
169 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
171 pLabel = new (std::nothrow) Label();
172 pLabel->Construct(itemMainRectangle, groupText);
173 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
174 pLabel->SetTextVerticalAlignment(ALIGNMENT_BOTTOM);
175 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
176 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
178 pItem->AddControl(pLabel);
179 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
180 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
181 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
182 pItem->SetEnabled(false);
188 HomeAndLockScreenForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
190 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
192 Rectangle itemMainRectangle;
193 Rectangle itemSubRectangle;
194 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
197 String fontReturnValue;
198 Label* pLabel = null;
200 int fontSize = GetFontSize();
202 itemMainText = GetGroupItemText(groupIndex);
204 ItemTypeOneLine(itemMainRectangle);
205 itemHeight = itemMainRectangle.height;
207 if (groupIndex == ID_GROUP_SCREEN_TYPE)
209 itemSubText = GetGroupItemSelectedText();
210 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
211 itemHeight = itemMainRectangle.height + itemSubRectangle.height;
214 TableViewItem* pItem = new (std::nothrow) TableViewItem();
216 RelativeLayout relativeLayout;
217 relativeLayout.Construct();
219 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
220 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
222 pLabel = new (std::nothrow) Label();
223 pLabel->Construct(itemMainRectangle, itemMainText);
224 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
225 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
226 pLabel->SetTextColor(COLOR_MAIN_TEXT);
228 pItem->AddControl(pLabel);
230 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
231 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
233 if (groupIndex == ID_GROUP_SCREEN_TYPE)
235 pLabel = new (std::nothrow) Label();
236 pLabel->Construct(itemSubRectangle, itemSubText);
237 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
238 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
239 pLabel->SetTextColor(COLOR_SUB_TEXT);
241 pItem->AddControl(pLabel);
243 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
244 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
250 HomeAndLockScreenForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
252 AppLogDebug("ENTER");
261 HomeAndLockScreenForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
263 AppLogDebug("ENTER");
272 HomeAndLockScreenForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
274 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
276 SceneManager* pSceneManager = SceneManager::GetInstance();
277 AppAssert(pSceneManager);
279 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
282 AppLogDebug("pArgs is null");
285 result r = pArgs->Construct();
288 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
290 pArgs->Add(*(new (std::nothrow) String(Integer::ToString(GetWallpaperIndex()))));
292 const wchar_t* pSceneName;
293 if (groupIndex == ID_GROUP_SCREEN_WALLPAPER)
295 pSceneName = IDSCN_WALLPAPER_ALBUM_LIST;
299 pSceneName = IDSCN_SCREEN_TYPE;
302 if (pSceneName != null)
304 pSceneManager->GoForward(ForwardSceneTransition(pSceneName, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
309 HomeAndLockScreenForm::GetDefaultGroupItemHeight(void)
311 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
315 HomeAndLockScreenForm::GetDefaultItemHeight(void)
317 return H_GROUP_ITEM_DEFAULT;
321 HomeAndLockScreenForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
326 HomeAndLockScreenForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
330 case ID_GROUP_SCREEN_TYPE:
333 Label* pSecondLabel = static_cast<Label*>(pItem->GetControl(1));
334 itemSubText = GetGroupItemSelectedText();
335 pSecondLabel->SetText(itemSubText);
336 pSecondLabel->Invalidate(false);
347 HomeAndLockScreenForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
352 HomeAndLockScreenForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
357 HomeAndLockScreenForm::SetWallpaperIndex(Tizen::Base::String& whitchOne)
359 Integer::Parse(whitchOne, __wallpaperIndex);
363 HomeAndLockScreenForm::GetWallpaperIndex(void)
365 return __wallpaperIndex;
369 HomeAndLockScreenForm::GetTitleText(void)
373 switch (GetWallpaperIndex())
375 case ID_INDEX_HOME_SCREEN_WALLPAPER:
377 headerText = ResourceManager::GetString(L"IDS_ST_HEADER_HOME_SCREEN");
381 case ID_INDEX_LOCK_SCREEN_WALLPAPER:
383 headerText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN");
392 HomeAndLockScreenForm::GetGroupText(int groupIndex)
398 case ID_GROUP_SCREEN_TYPE:
400 if (GetWallpaperIndex())
402 groupText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN");
406 groupText = ResourceManager::GetString(L"IDS_ST_HEADER_HOME_SCREEN");
411 case ID_GROUP_SCREEN_WALLPAPER:
413 groupText = ResourceManager::GetString(L"IDS_ST_BODY_MAINDISPLAY_WALLPAPER");
422 HomeAndLockScreenForm::GetGroupItemText(int groupIndex)
428 case ID_GROUP_SCREEN_TYPE:
430 if (GetWallpaperIndex())
432 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SCREEN_LOCK_TYPE");
436 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_HOME_SCREEN_TYPE");
441 case ID_GROUP_SCREEN_WALLPAPER:
443 if (GetWallpaperIndex())
445 itemMainText = ResourceManager::GetString(L"IDS_ST_MBODY_LOCK_SCREEN_WALLPAPER_M_NOUN");
449 itemMainText = ResourceManager::GetString(L"IDS_ST_MBODY_HOME_SCREEN_WALLPAPER");
459 HomeAndLockScreenForm::GetGroupItemSelectedText(void)
463 String applicationId;
465 if (GetWallpaperIndex() == 0)
467 screenType = SETTING_INFO_KEY_SCREEN_TYPE_HOME;
471 screenType = SETTING_INFO_KEY_SCREEN_TYPE_LOCK;
474 result r = SettingInfo::GetValue(screenType, applicationId);
475 AppLogDebug("GetValue(%ls, ..) result=[%s]", screenType.GetPointer(), GetErrorMessage(r));
479 AppLog("AppId=[%ls]", applicationId.GetPointer());
481 if (applicationId.Equals(L"org.tizen.menu-screen", false))
484 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DEFAULT_HOME_SCREEN");
486 else if (applicationId.Equals(L"org.tizen.lockscreen", false))
489 itemMainText = ResourceManager::GetString(L"IDS_ST_MBODY_SWIPE");
493 // Downloaded home/lock
494 PackageManager* pMgr = PackageManager::GetInstance();
495 PackageAppInfo* pPackageAppInfo = pMgr->GetPackageAppInfoN(applicationId);
496 itemMainText = pPackageAppInfo->GetAppDisplayName();