2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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 StMoreConnectivityForm.cpp
19 * @brief This is the implementation file for MoreConnectivityForm class.
22 #include "StBluetoothForm.h"
23 #include "StMoreConnectivityForm.h"
24 #include "StResourceManager.h"
25 #include "StSettingScenesList.h"
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_GROUP_CONNECTIVITY = 0;
37 #ifdef DISPLAY_SETTING_MENU_FOR_R0
38 static const int ID_GROUP_CONNECTIVITY_ITEM_COUNT = 1;
40 static const int ID_GROUP_CONNECTIVITY_ITEM_COUNT = 2;
42 static const int ID_ITEM_CONNECTIVITY_BLUETOOTH = 0;
43 static const int ID_ITEM_CONNECTIVITY_WIFI_DIRECT = 1;
45 static const int ID_GROUP_COUNT = 1;
46 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_CONNECTIVITY_ITEM_COUNT;
48 static const int BLUETOOTH_ON_OFF_OPTION = 2;
49 static const int BLUETOOTH_OFF_OPTION = 0;
50 static const int BLUETOOTH_ON_OPTION = 1;
52 MoreConnectivityForm::MoreConnectivityForm(void)
56 MoreConnectivityForm::~MoreConnectivityForm(void)
61 MoreConnectivityForm::CreateFooter(void)
63 Footer* pFooter = GetFooter();
66 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
67 pFooter->SetBackButton();
68 pFooter->AddActionEventListener(*this);
70 SetFormBackEventListener(this);
74 MoreConnectivityForm::OnInitializing(void)
76 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_MORE_CONNECTIVITY_SETTINGS"));
85 MoreConnectivityForm::OnTerminating(void)
89 SetFormBackEventListener(null);
94 MoreConnectivityForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
96 if (__pTableView != null)
98 __pTableView->UpdateTableView();
103 MoreConnectivityForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
108 MoreConnectivityForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
110 SceneManager* pSceneManager = SceneManager::GetInstance();
111 AppAssert(pSceneManager);
113 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
117 MoreConnectivityForm::GetGroupCount(void)
119 AppLogDebug("ENTER");
120 return ID_GROUP_COUNT;
124 MoreConnectivityForm::GetItemCount(int groupIndex)
126 int itemCount = ID_GROUP_MAX_ITEM_COUNT;
128 AppLogDebug("GetItemCount %d", itemCount);
134 MoreConnectivityForm::CreateGroupItem(int groupIndex, int itemWidth)
136 AppLogDebug("ENTER");
138 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
139 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
140 Rectangle itemRectangle;
142 Label* pLabel = null;
144 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
146 itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
147 itemRectangle.y = Y_GROUP_ITEM_DEFAULT_LABEL;
148 itemRectangle.width = itemWidth;
149 itemRectangle.height = itemHeight;
151 RelativeLayout relativeLayout;
152 relativeLayout.Construct();
154 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
155 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
157 pLabel = new (std::nothrow) Label();
158 pLabel->Construct(itemRectangle, groupText);
159 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
160 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
161 pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
163 pItem->AddControl(*pLabel);
164 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
165 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
166 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
167 pItem->SetEnabled(false);
173 MoreConnectivityForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
175 AppLogDebug("ENTER");
177 bool checkSecondText = false;
178 int itmeHeight = H_GROUP_ITEM_DEFAULT_LABEL;
179 int btEnableStatus = BLUETOOTH_OFF_OPTION;
180 Rectangle itemLabelRect;
181 Rectangle itemIconRect;
182 Rectangle itemIconLabelRect;
183 Rectangle itemSecondLineTextRect;
184 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
185 Bitmap* pBitmap = null;
187 String secondLineText;
188 bool EnableStatus = false;
189 Label* pLabel = null;
190 int fontSize = GetFontSize();
192 TableViewItem* pItem = new (std::nothrow) TableViewItem();
194 if (itemIndex == ID_ITEM_CONNECTIVITY_BLUETOOTH)
196 checkSecondText = true;
197 ItemTypeIconAndTwoLine(itemIconRect, itemIconLabelRect, itemSecondLineTextRect, fontSize);
198 itmeHeight = (itemIconLabelRect.height + itemSecondLineTextRect.height);
200 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_BLUETOOTH, EnableStatus) == E_SUCCESS)
202 AppLogDebug("systeminfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
204 if (EnableStatus == true)
206 btEnableStatus = BluetoothPresentationModel::GetInstance()->IsBluetoothActivated();
207 secondLineText = ResourceManager::GetString(L"IDS_ST_BODY_ON");
211 secondLineText = ResourceManager::GetString(L"IDS_ST_BODY_OFF");
214 itemText = ResourceManager::GetString(L"IDS_ST_BODY_BLUETOOTH");
218 itemText = ResourceManager::GetString(L"IDS_ST_HEADER_WI_FI_DIRECT");
219 ItemTypeIconAndOneLine(itemIconRect, itemIconLabelRect);
222 RelativeLayout relativeLayout;
223 relativeLayout.Construct();
225 pItem->Construct(relativeLayout, Dimension(itemWidth, itmeHeight), style);
226 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
228 pBitmap = ResourceManager::GetBitmapN(IDB_BLUETOOTH);
232 pLabel = new (std::nothrow) Label();
233 pLabel->Construct(itemLabelRect, itemText);
234 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
236 pItem->AddControl(*pLabel);
237 relativeLayout.SetMargin(*pLabel, itemLabelRect.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
238 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
239 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
243 pLabel = new (std::nothrow) Label();
244 pLabel->Construct(itemIconRect, L"");
245 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
246 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
247 pLabel->SetBackgroundBitmap(*pBitmap);
249 pItem->AddControl(*pLabel);
251 pLabel = new (std::nothrow) Label();
252 pLabel->Construct(itemIconLabelRect, itemText);
253 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
254 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
255 pLabel->SetTextColor(COLOR_MAIN_TEXT);
257 pItem->AddControl(*pLabel);
258 relativeLayout.SetMargin(*pLabel, itemIconLabelRect.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
259 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
260 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
262 if (checkSecondText == true)
264 pLabel = new (std::nothrow) Label();
265 pLabel->Construct(itemSecondLineTextRect, secondLineText);
266 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
267 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
268 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
269 pLabel->SetTextColor(COLOR_SUB_TEXT);
271 pItem->AddControl(*pLabel);
272 relativeLayout.SetMargin(*pLabel, itemSecondLineTextRect.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
273 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
274 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
282 MoreConnectivityForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
284 AppLogDebug("ENTER");
293 MoreConnectivityForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
295 AppLogDebug("ENTER");
304 MoreConnectivityForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
306 bool EnableStatus = false;
307 SceneManager* pSceneManager = SceneManager::GetInstance();
308 AppAssert(pSceneManager);
310 AppLogDebug("Group[ %d ] Index [ %d ]", groupIndex, itemIndex);
314 case ID_ITEM_CONNECTIVITY_BLUETOOTH:
316 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_BLUETOOTH, EnableStatus) != E_SUCCESS)
318 AppLogDebug("systeminfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
321 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_BLUETOOTH, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
325 case ID_ITEM_CONNECTIVITY_WIFI_DIRECT:
327 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WIFI_DIRECT, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
337 MoreConnectivityForm::GetDefaultGroupItemHeight(void)
339 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
343 MoreConnectivityForm::GetDefaultItemHeight(void)
345 return H_GROUP_ITEM_DEFAULT;
349 MoreConnectivityForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
354 MoreConnectivityForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
359 MoreConnectivityForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
364 MoreConnectivityForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)