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 StMoreSystemForm.cpp
19 * @brief This is the implementation file for MoreSystemForm class.
23 #include "StMoreSystemForm.h"
24 #include "StResourceManager.h"
25 #include "StSettingScenesList.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::System;
31 using namespace Tizen::Ui;
32 using namespace Tizen::Ui::Controls;
33 using namespace Tizen::Ui::Scenes;
35 static const int ID_GROUP_SYSTEM = 0;
36 static const int ID_GROUP_SYSTEM_ITEM_COUNT = 8;
37 static const int ID_ITEM_SYSTEM_FONT = 0;
38 static const int ID_ITEM_SYSTEM_AUTO_ROTATE_SCREEN = 1;
39 static const int ID_ITEM_SYSTEM_DATE_AND_TIME = 2;
40 static const int ID_ITEM_SYSTEM_LANGUAGE_AND_REGION = 3;
41 static const int ID_ITEM_SYSTEM_KEYBOARD = 4;
42 static const int ID_ITEM_SYSTEM_MANAGE_APPLICATION = 5;
43 static const int ID_ITEM_SYSTEM_DEVELOPER_OPTIONS = 6;
44 static const int ID_ITEM_SYSTEM_ABOUT_PHONE = 7;
46 static const int ID_GROUP_COUNT = 1;
47 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_SYSTEM_ITEM_COUNT;
49 static const int W_RESIZE_LABEL_GAP = 150;
51 MoreSystemForm::MoreSystemForm(void)
55 MoreSystemForm::~MoreSystemForm(void)
60 MoreSystemForm::CreateFooter(void)
62 Footer* pFooter = GetFooter();
65 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
66 pFooter->SetBackButton();
67 pFooter->AddActionEventListener(*this);
69 SetFormBackEventListener(this);
73 MoreSystemForm::OnInitializing(void)
75 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_MORE_SYSTEM_SETTINGS"));
78 SettingInfo::AddSettingEventListener(*this);
84 MoreSystemForm::OnTerminating(void)
87 SettingInfo::RemoveSettingEventListener(*this);
88 SetFormBackEventListener(null);
93 MoreSystemForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
95 bool autoRotation = false;
97 Header* pHeader = GetHeader();
98 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_MORE_SYSTEM_SETTINGS"));
100 __pTableView->Draw(true);
102 if (SettingInfo::GetValue(SETTING_INFO_KEY_SCREEN_ROTAION_AUTO, autoRotation) == E_SUCCESS)
104 __pTableView->SetItemChecked(ID_GROUP_SYSTEM, ID_ITEM_SYSTEM_AUTO_ROTATE_SCREEN, autoRotation);
109 MoreSystemForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
114 MoreSystemForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
116 SceneManager* pSceneManager = SceneManager::GetInstance();
117 AppAssert(pSceneManager);
119 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
123 MoreSystemForm::GetGroupCount(void)
125 AppLogDebug("ENTER");
126 return ID_GROUP_COUNT;
130 MoreSystemForm::GetItemCount(int groupIndex)
132 int itemCount = ID_GROUP_MAX_ITEM_COUNT;
134 AppLogDebug("GetItemCount %d", itemCount);
140 MoreSystemForm::CreateGroupItem(int groupIndex, int itemWidth)
142 AppLogDebug("GroupIndex [%d]", groupIndex);
144 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
145 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
146 Rectangle itemRectangle;
148 Label* pLabel = null;
150 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
152 itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
153 itemRectangle.y = Y_GROUP_ITEM_DEFAULT_LABEL;
154 itemRectangle.width = itemWidth;
155 itemRectangle.height = itemHeight;
157 RelativeLayout relativeLayout;
158 relativeLayout.Construct();
160 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
161 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
163 pLabel = new (std::nothrow) Label();
164 pLabel->Construct(itemRectangle, groupText);
165 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
166 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
167 pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
169 pItem->AddControl(pLabel);
170 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
171 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
172 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
173 pItem->SetEnabled(false);
179 MoreSystemForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
181 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
183 Rectangle itemRectIcon;
184 Rectangle itemRectLabel;
185 Rectangle itemRectIconAndLabel;
186 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
187 Bitmap* pBitmap = null;
189 Label* pLabel = null;
190 int fontSize = GetFontSize();
192 TableViewItem* pItem = new (std::nothrow) TableViewItem();
194 ItemTypeIconAndOneLine(itemRectIcon, itemRectLabel);
198 case ID_ITEM_SYSTEM_FONT:
200 pBitmap = ResourceManager::GetBitmapN(IDB_FONT);
204 case ID_ITEM_SYSTEM_AUTO_ROTATE_SCREEN:
206 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
207 itemRectLabel.width -= W_RESIZE_LABEL_GAP;
208 pBitmap = ResourceManager::GetBitmapN(IDB_AUTO_ROTATE_SCREEN);
212 case ID_ITEM_SYSTEM_DATE_AND_TIME:
214 pBitmap = ResourceManager::GetBitmapN(IDB_DATE_AND_TIME);
218 case ID_ITEM_SYSTEM_LANGUAGE_AND_REGION:
220 pBitmap = ResourceManager::GetBitmapN(IDB_LANGUAGE_KEYBOARD);
224 case ID_ITEM_SYSTEM_KEYBOARD:
226 pBitmap = ResourceManager::GetBitmapN(IDB_LANGUAGE_KEYBOARD);
227 itemText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
231 case ID_ITEM_SYSTEM_MANAGE_APPLICATION:
233 pBitmap = ResourceManager::GetBitmapN(IDB_MANAGE_APPLICATION);
237 case ID_ITEM_SYSTEM_DEVELOPER_OPTIONS:
239 pBitmap = ResourceManager::GetBitmapN(IDB_DEVELOPER_OPTION);
243 case ID_ITEM_SYSTEM_ABOUT_PHONE:
245 pBitmap = ResourceManager::GetBitmapN(IDB_ABOUT_PHONE);
253 itemText = GetTableViewItemString(groupIndex, itemIndex);
255 RelativeLayout relativeLayout;
256 relativeLayout.Construct();
258 pItem->Construct(relativeLayout, Dimension(itemWidth, itemRectLabel.height), style);
259 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
263 pLabel = new (std::nothrow) Label();
264 pLabel->Construct(itemRectLabel, itemText);
265 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
266 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
267 pLabel->SetTextColor(COLOR_MAIN_TEXT);
269 pItem->AddControl(pLabel);
270 if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
272 relativeLayout.SetMargin(*pLabel, itemRectLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
276 relativeLayout.SetMargin(*pLabel, itemRectLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
278 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
279 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
283 pLabel = new (std::nothrow) Label();
284 pLabel->Construct(itemRectIcon, L"");
285 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
286 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
287 pLabel->SetBackgroundBitmap(*pBitmap);
289 pItem->AddControl(pLabel);
291 pLabel = new (std::nothrow) Label();
292 pLabel->Construct(itemRectLabel, itemText);
293 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
294 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
295 pLabel->SetTextColor(COLOR_MAIN_TEXT);
297 pItem->AddControl(pLabel);
298 if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
300 relativeLayout.SetMargin(*pLabel, itemRectLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
304 relativeLayout.SetMargin(*pLabel, itemRectLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
306 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
307 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
314 MoreSystemForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
316 AppLogDebug("ENTER");
325 MoreSystemForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
327 AppLogDebug("ENTER");
336 MoreSystemForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
338 const wchar_t* pSceneName(L"");
339 SceneManager* pSceneManager = SceneManager::GetInstance();
340 AppAssert(pSceneManager);
342 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
346 case ID_ITEM_SYSTEM_FONT:
348 pSceneName = IDSCN_FONT;
352 case ID_ITEM_SYSTEM_AUTO_ROTATE_SCREEN:
354 bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
356 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
358 itemSelectStatus = !itemSelectStatus;
361 if (SettingInfo::SetValue(SETTING_INFO_KEY_SCREEN_ROTAION_AUTO, itemSelectStatus) == E_SUCCESS)
363 tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
368 case ID_ITEM_SYSTEM_DATE_AND_TIME:
370 pSceneName = IDSCN_DATE_TIME;
374 case ID_ITEM_SYSTEM_LANGUAGE_AND_REGION:
376 pSceneName = IDSCN_LOCALE;
380 case ID_ITEM_SYSTEM_KEYBOARD:
382 pSceneName = IDSCN_KEYBOARD;
386 case ID_ITEM_SYSTEM_MANAGE_APPLICATION:
388 pSceneName = IDSCN_MANAGE_APPLICATION;
392 case ID_ITEM_SYSTEM_DEVELOPER_OPTIONS:
394 pSceneName = IDSCN_DEVELOPER_OPTION;
398 case ID_ITEM_SYSTEM_ABOUT_PHONE:
400 pSceneName = IDSCN_PHONE_INFO;
407 AppLogDebug("Default Case");
412 if (pSceneName != null)
414 pSceneManager->GoForward(ForwardSceneTransition(pSceneName, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
419 MoreSystemForm::GetDefaultGroupItemHeight(void)
421 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
425 MoreSystemForm::GetDefaultItemHeight (void)
427 return H_GROUP_ITEM_DEFAULT;
431 MoreSystemForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
436 MoreSystemForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
439 int fontSize = GetFontSize();
441 Rectangle oneLineRect;
442 Rectangle pItemBounds = pItem->GetBounds();
444 ItemTypeIconAndOneLine(iconRect, oneLineRect);
446 pItemBounds.height = oneLineRect.height;
448 pItem->SetBounds(pItemBounds);
450 Label* pLabel = static_cast<Label*>(pItem->GetControl(1));
451 itemText = GetTableViewItemString(groupIndex, itemIndex);
453 pLabel->SetBounds(oneLineRect);
454 pLabel->SetText(itemText);
455 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
457 pLabel->Invalidate(false);
463 MoreSystemForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
468 MoreSystemForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
473 MoreSystemForm::GetTableViewItemString(int groupIndex, int itemIndex)
479 case ID_ITEM_SYSTEM_FONT:
481 itemText = ResourceManager::GetString(L"IDS_ST_BODY_FONT");
485 case ID_ITEM_SYSTEM_AUTO_ROTATE_SCREEN:
487 itemText = ResourceManager::GetString(L"IDS_ST_HEADER_AUTO_ROTATE_SCREEN_ABB");
491 case ID_ITEM_SYSTEM_DATE_AND_TIME:
493 itemText = ResourceManager::GetString(L"IDS_ST_BODY_DATE_AND_TIME");
497 case ID_ITEM_SYSTEM_LANGUAGE_AND_REGION:
499 itemText = ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_REGION_ABB");
503 case ID_ITEM_SYSTEM_KEYBOARD:
505 itemText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
509 case ID_ITEM_SYSTEM_MANAGE_APPLICATION:
511 itemText = ResourceManager::GetString(L"IDS_ST_BODY_MANAGE_APPLICATIONS");
515 case ID_ITEM_SYSTEM_DEVELOPER_OPTIONS:
517 itemText = ResourceManager::GetString(L"IDS_ST_BODY_DEVELOPER_OPTIONS");
521 case ID_ITEM_SYSTEM_ABOUT_PHONE:
523 itemText = ResourceManager::GetString(L"IDS_ST_BODY_ABOUT_PHONE");
537 MoreSystemForm::RefreshGroupItemAt(int groupIndex)
539 int itemCount = __pTableView->GetItemCountAt(groupIndex);
541 for (int count = 0; count < itemCount; count++)
543 __pTableView->RefreshItem(groupIndex, count, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
548 MoreSystemForm::OnSettingChanged (Tizen::Base::String &key)
550 AppLogDebug("MoreSystemForm::key changed [%ls]", key.GetPointer());
552 if (key.Equals(SETTING_INFO_KEY_FONT_SIZE, false)
553 ||key.Equals(SETTING_INFO_KEY_FONT_TYPE, false)
554 ||key.Equals(SETTING_INFO_KEY_LOCALE_LANGUAGE, false))
556 int groupCount = __pTableView->GetGroupCount();
558 for (int count = 0; count < groupCount; count++)
560 RefreshGroupItemAt(count);