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 StSecurityForm.cpp
19 * @brief This is the implementation file for SecurityForm class.
22 #include "StResourceManager.h"
23 #include "StSecurityForm.h"
24 #include "StSettingScenesList.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Ui::Controls;
31 using namespace Tizen::Ui::Scenes;
33 static const int ID_GROUP_SECURITY_SCREEN_SECURITY = 0;
34 static const int ID_GROUP_SECURITY_SCREEN_SECURITY_ITEM_COUNT = 2;
35 static const int ID_ITEM_SECURITY_SCREEN_LOCK_TYPE = 0;
36 static const int ID_ITEM_SECURITY_SCREEN_LOCK_SCREEN_OPTION = 1;
38 static const int ID_GROUP_SECURITY_PHONE_SECURITY = 1;
39 static const int ID_GROUP_SECURITY_PHONE_SECURITY_ITEM_COUNT = 1;
40 static const int ID_ITEM_SECURITY_PHONE_SECURITY = 0;
42 static const int ID_GROUP_SECURITY_SIM = 2;
43 static const int ID_GROUP_SECURITY_SIM_ITEM_COUNT = 1;
44 static const int ID_ITEM_SECURITY_SIM_LOCK = 0;
46 static const int ID_GROUP_SECURITY_PIN = 3;
47 static const int ID_GROUP_SECURITY_PIN_ITEM_COUNT = 3;
48 static const int ID_ITEM_SECURITY_PIN_LOCK = 0;
49 static const int ID_ITEM_SECURITY_CHANGE_PIN_1 = 1;
50 static const int ID_ITEM_SECURITY_CHANGE_PIN_2 = 2;
52 static const int ID_GROUP_SECURITY_DEVICE = 4;
53 static const int ID_GROUP_SECURITY_DEVICE_ITEM_COUNT = 1;
54 static const int ID_ITEM_SECURITY_DEVICE_ENCRYPTION = 0;
56 static const int ID_GROUP_SECURITY_PASSWORD_HELP_TEXT = 5;
58 static const int ID_GROUP_COUNT = 6;
59 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_SECURITY_PIN_ITEM_COUNT;
61 SecurityForm::SecurityForm(void)
65 SecurityForm::~SecurityForm(void)
70 SecurityForm::CreateFooter(void)
72 Footer* pFooter = GetFooter();
75 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
76 pFooter->SetBackButton();
77 pFooter->AddActionEventListener(*this);
79 SetFormBackEventListener(this);
83 SecurityForm::OnInitializing(void)
85 CreateHeader(ResourceManager::GetString(L"IDS_ST_HEADER_SECURITY"));
95 SecurityForm::OnTerminating(void)
99 SetFormBackEventListener(null);
104 SecurityForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
106 __pTableView->UpdateTableView();
110 SecurityForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
115 SecurityForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
117 SceneManager* pSceneManager = SceneManager::GetInstance();
118 AppAssert(pSceneManager);
120 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
124 SecurityForm::GetGroupCount(void)
126 AppLogDebug("ENTER");
127 return ID_GROUP_COUNT;
131 SecurityForm::GetItemCount(int groupIndex)
137 case ID_GROUP_SECURITY_SCREEN_SECURITY:
139 itemCount = ID_GROUP_SECURITY_SCREEN_SECURITY_ITEM_COUNT;
143 case ID_GROUP_SECURITY_PHONE_SECURITY:
145 itemCount = ID_GROUP_SECURITY_PHONE_SECURITY_ITEM_COUNT;
149 case ID_GROUP_SECURITY_SIM:
151 itemCount = ID_GROUP_SECURITY_SIM_ITEM_COUNT;
155 case ID_GROUP_SECURITY_PIN:
157 itemCount = ID_GROUP_SECURITY_PIN_ITEM_COUNT;
161 case ID_GROUP_SECURITY_DEVICE:
163 itemCount = ID_GROUP_SECURITY_DEVICE_ITEM_COUNT;
171 AppLogDebug("GetItemCount %d", itemCount);
176 SecurityForm::CreateGroupItem(int groupIndex, int itemWidth)
178 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
179 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
180 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
181 Color colorText = COLOR_HELP_TEXT_TYPE_01;
182 Rectangle itemMainRectangle;
184 Label* pLabel = null;
186 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
190 case ID_GROUP_SECURITY_SCREEN_SECURITY:
192 style = LABEL_TEXT_STYLE_BOLD;
193 colorText = COLOR_GROUP_TITLE_TEXT;
194 yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
195 itemHeight = H_GROUP_INDEX_DEFAULT;
196 groupText = ResourceManager::GetString(L"IDS_ST_HEADER_SCREEN_SECURITY");
200 case ID_GROUP_SECURITY_PHONE_SECURITY:
202 style = LABEL_TEXT_STYLE_BOLD;
203 colorText = COLOR_GROUP_TITLE_TEXT;
204 yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
205 itemHeight = H_GROUP_INDEX_DEFAULT;
206 groupText = ResourceManager::GetString(L"IDS_ST_BODY_PHONE_SECURITY");
210 case ID_GROUP_SECURITY_SIM:
212 yItemOffset = Y_GROUP_INDEX_DEFAULT;
213 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
218 case ID_GROUP_SECURITY_PIN:
220 yItemOffset = Y_GROUP_INDEX_DEFAULT;
221 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
226 case ID_GROUP_SECURITY_DEVICE:
228 yItemOffset = Y_GROUP_INDEX_DEFAULT;
229 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
234 case ID_GROUP_SECURITY_PASSWORD_HELP_TEXT:
236 style = LABEL_TEXT_STYLE_NORMAL;
237 colorText = COLOR_HELP_TEXT_TYPE_01;
238 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
239 itemHeight = ((H_GROUP_INDEX_HELP_TEXT * LINE_COUNT_2) + H_GROUP_INDEX_NO_TITLE_TEXT_GAP);
240 groupText = ResourceManager::GetString(L"IDS_SECURITY_DEVICE_ENCRYPTION_HELP");
246 yItemOffset = Y_GROUP_INDEX_DEFAULT;
247 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
253 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
254 itemMainRectangle.y = yItemOffset;
255 itemMainRectangle.width = itemWidth;
256 itemMainRectangle.height = itemHeight;
258 RelativeLayout relativeLayout;
259 relativeLayout.Construct();
261 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
262 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
264 pLabel = new (std::nothrow) Label();
265 pLabel->Construct(itemMainRectangle, groupText);
266 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
267 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
268 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
269 pLabel->SetTextColor(colorText);
271 pItem->AddControl(pLabel);
272 relativeLayout.SetMargin(*pLabel, itemMainRectangle.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);
275 pItem->SetEnabled(false);
281 SecurityForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
283 Rectangle itemMainRectangle;
284 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
285 Label* pLabel = null;
287 int fontSize = GetFontSize();
289 TableViewItem* pItem = new (std::nothrow) TableViewItem();
293 case ID_GROUP_SECURITY_SCREEN_SECURITY:
297 case ID_ITEM_SECURITY_SCREEN_LOCK_TYPE:
299 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SCREEN_LOCK_TYPE");
303 case ID_ITEM_SECURITY_SCREEN_LOCK_SCREEN_OPTION:
305 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN_OPTIONS");
315 case ID_GROUP_SECURITY_PHONE_SECURITY:
317 itemMainText = ResourceManager::GetString(L"IDS_ST_MBODY_FIND_MY_MOBILE");
321 case ID_GROUP_SECURITY_SIM:
323 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SIM_LOCK");
324 if (itemIndex == ID_ITEM_SECURITY_PIN_LOCK)
326 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
331 case ID_GROUP_SECURITY_PIN:
335 case ID_ITEM_SECURITY_PIN_LOCK:
337 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
338 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_PIN_LOCK");
342 case ID_ITEM_SECURITY_CHANGE_PIN_1:
344 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_CHANGE_PIN1");
348 case ID_ITEM_SECURITY_CHANGE_PIN_2:
350 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_CHANGE_PIN2");
360 case ID_GROUP_SECURITY_DEVICE:
362 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DEVICE_ENCRYPTED");
370 ItemTypeOneLine(itemMainRectangle);
372 RelativeLayout relativeLayout;
373 relativeLayout.Construct();
375 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
376 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
378 pLabel = new (std::nothrow) Label();
379 pLabel->Construct(itemMainRectangle, itemMainText);
380 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
381 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
382 pLabel->SetTextColor(COLOR_MAIN_TEXT);
384 pItem->AddControl(pLabel);
386 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
387 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
388 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
394 SecurityForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
396 AppLogDebug("ENTER");
405 SecurityForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
407 AppLogDebug("ENTER");
416 SecurityForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
418 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
422 case ID_GROUP_SECURITY_SCREEN_SECURITY:
424 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
426 if (itemIndex == ID_GROUP_SECURITY_SCREEN_SECURITY)
430 if (itemIndex == ID_ITEM_SECURITY_SCREEN_LOCK_SCREEN_OPTION)
437 case ID_GROUP_SECURITY_PHONE_SECURITY:
439 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
441 if (itemIndex == ID_ITEM_SECURITY_PHONE_SECURITY)
443 // TODO: make scene or call appControl. Find my mobile ?
449 case ID_GROUP_SECURITY_SIM:
451 if (itemIndex == ID_ITEM_SECURITY_SIM_LOCK)
453 // TODO: make scene or call appControl. SIM Lock.
459 case ID_GROUP_SECURITY_PIN:
461 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
463 if (itemIndex == ID_ITEM_SECURITY_PIN_LOCK)
468 if (itemIndex == ID_ITEM_SECURITY_CHANGE_PIN_1)
470 // TODO: change pin 1 ?
473 if (itemIndex == ID_ITEM_SECURITY_CHANGE_PIN_2)
475 // TODO: change pin 2 ?
481 case ID_GROUP_SECURITY_DEVICE:
483 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
485 if (itemIndex == ID_ITEM_SECURITY_DEVICE_ENCRYPTION)
487 // TODO: Device encryption ?
499 SecurityForm::GetDefaultGroupItemHeight(void)
501 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
505 SecurityForm::GetDefaultItemHeight(void)
507 return H_GROUP_ITEM_DEFAULT;
511 SecurityForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
516 SecurityForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
521 SecurityForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
526 SecurityForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)