Applied latest source code
[apps/native/preloaded/Settings.git] / src / StPrivacyForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                StPrivacyForm.cpp
19  * @brief               This is the implementation file for PrivacyForm class.
20  */
21
22 #include <FSecurity.h>
23 #include "StPrivacyForm.h"
24 #include "StResourceManager.h"
25 #include "StSettingScenesList.h"
26 #include "StTypes.h"
27
28 using namespace Tizen::App::Package;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Base::Utility;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Security;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Scenes;
37
38 static const int ID_GROUP_COUNT = 1;
39
40 PrivacyForm::PrivacyForm(void)
41         : __pPrivacyManager(null)
42         , __privacyPackageList(null)
43         , __pLabelArrayList(null)
44 {
45 }
46
47 PrivacyForm::~PrivacyForm(void)
48 {
49         if (__pLabelArrayList != null)
50         {
51                 __pLabelArrayList->RemoveAll(false);
52                 delete __pLabelArrayList;
53         }
54 }
55
56 void
57 PrivacyForm::CreateFooter(void)
58 {
59         Footer* pFooter = GetFooter();
60         AppAssert(pFooter);
61
62         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
63         pFooter->AddActionEventListener(*this);
64
65         SetFormBackEventListener(this);
66 }
67
68 result
69 PrivacyForm::OnInitializing(void)
70 {
71         AppLogDebug("Enter");
72         __pLabelArrayList = new (std::nothrow) ArrayList();
73         __pLabelArrayList->Construct();
74
75         result r = InitPrivacyAppPackageList();
76         if (IsFailed(r))
77         {
78                 AppLogDebug("InitPrivacyAppPackageList");
79                 return E_FAILURE;
80         }
81
82         CreateHeader(ResourceManager::GetString(L"IDS_COM_BODY_PRIVACY"));
83         UpdateTableViewAndNoContent();
84
85         return r;
86 }
87
88 result
89 PrivacyForm::OnTerminating(void)
90 {
91         __pPrivacyManager = null;
92
93         if (__privacyPackageList != null)
94         {
95                 __privacyPackageList->RemoveAll(true);
96                 delete __privacyPackageList;
97                 __privacyPackageList = null;
98         }
99
100         int controlCount = GetControlCount();
101         for (int i = 0; i < controlCount; i++)
102         {
103                 RemoveControl(GetControl(0));
104         }
105         __pTableView = null;
106
107         SetFormBackEventListener(null);
108         return E_SUCCESS;
109 }
110
111 void
112 PrivacyForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
113 {
114         AppLogDebug("Enter");
115
116         if (pArgs != null)
117         {
118                 delete pArgs;
119         }
120
121         result r = InitPrivacyAppPackageList();
122         if (IsFailed(r))
123         {
124                 AppLogDebug("InitPrivacyAppPackageList");
125                 return;
126         }
127
128         if(previousSceneId == IDSCN_PRIVACY_DETAIL)
129         {
130                 if (__pLabelArrayList != null)
131                 {
132                         __pLabelArrayList->RemoveAll(false);
133                 }
134                 UpdateTableViewAndNoContent();
135         }
136         AppLogDebug("EXIT");
137 }
138
139 result
140 PrivacyForm::InitPrivacyAppPackageList(void)
141 {
142         __pPrivacyManager = PrivacyManager::GetInstance();
143         if (__pPrivacyManager == null)
144         {
145                 AppLogDebug("pPrivacyManager is null");
146                 return E_FAILURE;
147         }
148
149         __privacyPackageList = static_cast<ArrayList*>(__pPrivacyManager->GetPrivacyAppPackageListN());
150
151         if (__privacyPackageList == null)
152         {
153                 AppLogDebug("__privacyPackageList is null");
154                 return E_FAILURE;
155         }
156         return E_SUCCESS;
157 }
158
159 Tizen::Base::String
160 PrivacyForm::GetDisplayPackageName(int itemIndex)
161 {
162         String result;
163         String itemMainText;
164
165         if (__privacyPackageList == null)
166         {
167                 return result;
168         }
169
170         String packageId = *static_cast<String*>(__privacyPackageList->GetAt(itemIndex));
171         if (packageId.IsEmpty() == true)
172         {
173                 AppLogDebug("packageId is empty");
174                 return result;
175         }
176
177         PackageManager* pPackageManager = PackageManager::GetInstance();
178         if (pPackageManager == null)
179         {
180                 AppLogDebug("pPackageManager is null");
181         }
182         else
183         {
184                 PackageInfo* pPackageInfo = pPackageManager->GetPackageInfoN(packageId);
185                 if (pPackageInfo == null)
186                 {
187                         AppLogDebug("pPackageInfo is null. GetDisplayName fail");
188                         return result;
189                 }
190                 itemMainText = pPackageInfo->GetDisplayName();
191                 delete pPackageInfo;
192                 return itemMainText;
193         }
194         return result;
195 }
196
197 Tizen::Base::String
198 PrivacyForm::GetUsedPrivacyService(int itemIndex)
199 {
200         String result;
201
202         if (__privacyPackageList == null)
203         {
204                 return result;
205         }
206
207         ArrayList* pPrivacyServiceList = static_cast<ArrayList*>(__privacyPackageList->GetAt(itemIndex));
208         if (pPrivacyServiceList == null)
209         {
210                 AppLogDebug("pPrivacyServiceList is null");
211                 return result;
212         }
213
214         String packageId = *static_cast<String*>(__privacyPackageList->GetAt(itemIndex));
215
216         ArrayList* privacyListInfo = static_cast<ArrayList*>(__pPrivacyManager->GetPrivacyInfoListN(packageId));
217         if (privacyListInfo == null)
218         {
219                 AppLogDebug("privacyListInfo null");
220                 return result;
221         }
222
223         int serviceCount = privacyListInfo->GetCount();
224         for (int index = 0; index < serviceCount; index++)
225         {
226                 PrivacyInfo* pPrivacyService = static_cast<PrivacyInfo*>(privacyListInfo->GetAt(index));
227                 String key = pPrivacyService->GetDisplayName();
228
229                 if (key.IsEmpty() == false)
230                 {
231                         result.Append(key);
232
233                         if (index != (serviceCount - 1))
234                         {
235                                 result.Append(L", ");
236                         }
237                 }
238         }
239         return result;
240 }
241
242 void
243 PrivacyForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
244 {
245 }
246
247 void
248 PrivacyForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
249 {
250         SceneManager* pSceneManager = SceneManager::GetInstance();
251         AppAssert(pSceneManager);
252
253         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
254 }
255
256 int
257 PrivacyForm::GetGroupCount(void)
258 {
259         AppLogDebug("ENTER");
260         return ID_GROUP_COUNT;
261 }
262
263 int
264 PrivacyForm::GetItemCount(int groupIndex)
265 {
266         int itemCount = 0;
267
268         itemCount = GetPackageListCount();
269         AppLogDebug("GetItemCount %d", itemCount);
270
271         return itemCount;
272 }
273
274 TableViewGroupItem*
275 PrivacyForm::CreateGroupItem(int groupIndex, int itemWidth)
276 {
277         AppLogDebug("ENTER");
278
279         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
280         int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
281         LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
282         Rectangle itemMainRectangle;
283         String groupText;
284         Label* pLabel = null;
285         int fontSize = GetFontSize();
286
287         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
288
289         yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
290         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
291
292         itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
293         itemMainRectangle.y = yItemOffset;
294         itemMainRectangle.width = itemWidth;
295         itemMainRectangle.height = itemHeight;
296
297         RelativeLayout relativeLayout;
298         relativeLayout.Construct();
299
300         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
301         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
302
303         pLabel = new (std::nothrow) Label();
304         pLabel->Construct(itemMainRectangle, groupText);
305         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
306         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
307         pLabel->SetTextConfig(fontSize, style);
308         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
309
310         pItem->AddControl(pLabel);
311         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
312         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
313         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
314         pItem->SetEnabled(false);
315
316         return pItem;
317 }
318
319 TableViewItem*
320 PrivacyForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
321 {
322         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
323
324         Rectangle itemMainRectangle;
325         Rectangle itemSubRectangle;
326         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
327         String itemMainText;
328         String itemSubText;
329         String fontReturnValue;
330         Label* pLabel = null;
331
332         int fontSize = GetFontSize();
333         int itemHeight = H_GROUP_ITEM_DEFAULT;
334         Rectangle detailArrow;
335
336         itemMainText = GetDisplayPackageName(itemIndex);
337         itemSubText = GetUsedPrivacyService(itemIndex);
338
339         ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
340         itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
341
342         RelativeLayout relativeLayout;
343         relativeLayout.Construct();
344
345         TableViewItem* pItem = new (std::nothrow) TableViewItem();
346
347         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
348         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
349
350         pLabel = new (std::nothrow) Label();
351         itemMainRectangle.width = itemMainRectangle.width + TWO_LINE_ITEM_WIDTH_GAP;
352         pLabel->Construct(itemMainRectangle, itemMainText);
353         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
354         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
355         pLabel->SetTextColor(COLOR_MAIN_TEXT);
356         pLabel->AddTouchEventListener(*this);
357
358         String labelName = L"LABEL_MAIN_";
359         labelName.Append(itemIndex);
360         pLabel->SetName(labelName);
361         pItem->AddControl(pLabel);
362         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
363         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
364
365         String itemName = L"ITEM_";
366         itemName.Append(itemIndex);
367         pItem->SetName(itemName);
368         pItem->AddFocusEventListener(*this);
369
370         labelName.Clear();
371         labelName = L"LABEL_SUB_";
372         labelName.Append(itemIndex);
373         Label* pSecondLabel = new (std::nothrow) Label();
374         pSecondLabel->Construct(itemSubRectangle, itemSubText);
375         pSecondLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
376         pSecondLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
377         pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
378         pSecondLabel->SetTextColor(COLOR_SUB_TEXT);
379         pSecondLabel->AddTouchEventListener(*this);
380         pSecondLabel->SetName(labelName);
381         __pLabelArrayList->Add(pSecondLabel);
382         pItem->AddControl(pSecondLabel);
383         relativeLayout.SetMargin(*pSecondLabel, itemSubRectangle.x, 0, 0, 0);
384         relativeLayout.SetRelation(*pSecondLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
385         relativeLayout.SetRelation(*pSecondLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
386
387         pItem->AddKeyEventListener(*this);
388         AppLog("Exit group[%d] index[%d]", groupIndex, itemIndex);
389         return pItem;
390 }
391
392 bool
393 PrivacyForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
394 {
395         AppLogDebug("ENTER");
396
397         delete pItem;
398         pItem = null;
399
400         return true;
401 }
402
403 bool
404 PrivacyForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
405 {
406         AppLogDebug("ENTER");
407
408         delete pItem;
409         pItem = null;
410
411         return true;
412 }
413
414 void
415 PrivacyForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
416 {
417         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
418
419         SceneManager* pSceneManager = SceneManager::GetInstance();
420         AppAssert(pSceneManager);
421
422         ArrayList* pPrivacyServiceData = new (std::nothrow) ArrayList(SingleObjectDeleter);
423         pPrivacyServiceData->Construct();
424
425         Label* firstLineLabel = static_cast<Label*>(pItem->GetControl(0));
426         Label* secondLineLabel = static_cast<Label*>(pItem->GetControl(1));
427
428         String packageId = *static_cast<String*>(__privacyPackageList->GetAt(itemIndex));
429         pPrivacyServiceData->Add(new (std::nothrow) String(packageId));
430
431         if (firstLineLabel)
432         {
433                 pPrivacyServiceData->Add(new (std::nothrow) String(firstLineLabel->GetText()));
434         }
435
436         if (secondLineLabel)
437         {
438                 pPrivacyServiceData->Add(new (std::nothrow) String(secondLineLabel->GetText()));
439         }
440
441         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_PRIVACY_DETAIL, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pPrivacyServiceData);
442 }
443
444 int
445 PrivacyForm::GetDefaultGroupItemHeight(void)
446 {
447         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
448 }
449
450 int
451 PrivacyForm::GetDefaultItemHeight(void)
452 {
453         return H_GROUP_ITEM_DEFAULT;
454 }
455
456 void
457 PrivacyForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
458 {
459         AppLogDebug("ENTER");
460
461         LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
462         Rectangle itemMainRectangle = pItem->GetBounds();
463         int fontSize = GetFontSize();
464         Rectangle pLabelBounds;
465
466         itemMainRectangle.width = GetClientAreaBounds().width;
467         pItem->SetBounds(itemMainRectangle);
468         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
469
470         Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
471         pLabelBounds = pLabel->GetBounds();
472         pLabelBounds.width =  GetClientAreaBounds().width;
473         pLabel->SetBounds(pLabelBounds);
474         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
475         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
476         pLabel->SetTextConfig(fontSize, style);
477         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
478
479         pLabel->Invalidate(false);
480         pItem->Invalidate(false);
481         pItem->SetEnabled(false);
482 }
483
484 void
485 PrivacyForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
486 {
487         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
488
489         Rectangle itemMainRectangle;
490         Rectangle itemSubRectangle;
491         String itemMainText;
492         String itemSubText;
493         Rectangle itemRectangle = pItem->GetBounds();
494
495         int fontSize = GetFontSize();
496         int itemHeight = H_GROUP_ITEM_DEFAULT;
497         Rectangle detailArrow;
498
499         itemMainText = GetDisplayPackageName(itemIndex);
500         itemSubText = GetUsedPrivacyService(itemIndex);
501
502         ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
503         itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
504
505         itemRectangle.width = GetClientAreaBounds().width;
506         itemRectangle.height = itemHeight;
507         pItem->SetBounds(itemRectangle);
508         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
509
510         Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
511         itemMainRectangle = pLabel->GetBounds();
512         itemMainRectangle.width = GetClientAreaBounds().width;
513         pLabel->SetBounds(itemMainRectangle);
514         pLabel->SetText(itemMainText);
515         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
516         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
517         pLabel->SetTextColor(COLOR_MAIN_TEXT);
518         pLabel->Invalidate(false);
519
520         pLabel = static_cast<Label*>(pItem->GetControl(1));
521         itemSubRectangle = pLabel->GetBounds();
522         itemSubRectangle.width = GetClientAreaBounds().width;
523         pLabel->SetBounds(itemSubRectangle);
524         pLabel->SetText(itemSubText);
525         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
526         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
527         pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
528         pLabel->SetTextColor(COLOR_SUB_TEXT);
529         pLabel->Invalidate(false);
530
531         pItem->Invalidate(false);
532 }
533
534 void
535 PrivacyForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
536 {
537 }
538
539 void
540 PrivacyForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
541 {
542 }
543
544 int
545 PrivacyForm::GetPackageListCount(void)
546 {
547         if (__privacyPackageList == null)
548         {
549                 AppLogDebug("__privacyPackageList is null");
550                 return 0;
551         }
552
553         return __privacyPackageList->GetCount();
554 }
555
556 void
557 PrivacyForm::UpdateTableViewAndNoContent(void)
558 {
559         bool createTableView = false;
560         if (__pTableView != null)
561         {
562                 if (GetPackageListCount() != 0)
563                 {
564                         __pTableView->UpdateTableView();
565                         return;
566                 }
567         }
568         else
569         {
570                 if (GetPackageListCount() != 0)
571                 {
572                         createTableView = true;
573                 }
574         }
575
576         if (__pTableView != null)
577         {
578                 int tableViewControlCount = __pTableView->GetControlCount();
579                 for (int i = 0; i < tableViewControlCount; i++)
580                 {
581                         __pTableView->RemoveControl(__pTableView->GetControl(i));
582                 }
583                 __pTableView = null;
584         }
585
586         RemoveAllControls();
587         RequestRedraw();
588
589         if (createTableView)
590         {
591                 CreateTableView();
592                 __pTableView->UpdateTableView();
593         }
594         else
595         {
596                 Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
597                 if (pLabel == null)
598                 {
599                         Rectangle clientRect = GetClientAreaBounds();
600                         Bitmap* pBitmp = ResourceManager::GetBitmapN(IDB_NO_CONTENTS);
601
602                         int bitmapWidth = pBitmp->GetWidth();
603                         int bitmapHeight = pBitmp->GetHeight();
604                         String labelText = ResourceManager::GetString(L"IDS_ST_BODY_NO_CONTENT");
605                         Color textColor = COLOR_HELP_TEXT_TYPE_03_NORMAL;
606                         int noContentTextHeight = GetHeightForStringArea(labelText, bitmapWidth, 32);
607
608                         int xPos = (clientRect.width / LINE_COUNT_2) - (bitmapWidth / DIVIDE_BY_TWO);
609                         int yPos = (clientRect.height / LINE_COUNT_2) - ((bitmapHeight + noContentTextHeight) / DIVIDE_BY_TWO);
610
611                         Label* pLabel = new (std::nothrow) Label();
612                         pLabel->Construct(Rectangle(xPos, yPos, bitmapWidth, bitmapHeight), L"");
613                         pLabel->SetName(NO_CONTENTS);
614                         pLabel->SetBackgroundBitmap(*pBitmp);
615
616                         yPos = yPos + bitmapHeight;
617
618                         Label* pLabelNoContents = new (std::nothrow) Label();
619                         pLabelNoContents->Construct(Rectangle(0, yPos, clientRect.width, noContentTextHeight), L"");
620                         pLabelNoContents->SetName(NO_CONTENTS_TEXT);
621                         pLabelNoContents->SetTextColor(textColor);
622                         pLabelNoContents->SetText(labelText);
623
624                         AddControl(pLabel);
625                         AddControl(pLabelNoContents);
626                 }
627         }
628 }
629
630 void
631 PrivacyForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
632 {
633         AppLog("Enter");
634         Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
635         if (pLabel != null)
636         {
637                 Rectangle clientRect = GetClientAreaBounds();
638                 Rectangle labelBound = pLabel->GetBounds();
639
640                 int xPos = (clientRect.width / LINE_COUNT_2) - (labelBound.width / LINE_COUNT_2);
641                 int yPos = (clientRect.height / LINE_COUNT_2) -(labelBound.height / LINE_COUNT_2);
642
643                 pLabel->SetBounds(Rectangle(xPos, yPos, labelBound.width, labelBound.height));
644                 yPos = yPos + pLabel->GetBounds().height;
645                 Label* pTextLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS_TEXT, false));
646                 if (pTextLabel != null)
647                 {
648                         pTextLabel->SetBounds(Rectangle(0, yPos, clientRect.width, pTextLabel->GetBounds().height));
649                 }
650                 return;
651         }
652         if(__pTableView)
653         __pTableView->RefreshAllItems();
654         Invalidate(true);
655 }
656
657 void
658 PrivacyForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
659 {
660         AppLog("Enter %ls", source.GetName().GetPointer());
661         SetLabelColor(source.GetName(), COLOR_SUB_TEXT);
662 }
663
664 void
665 PrivacyForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
666 {
667         AppLog("Enter %ls", source.GetName().GetPointer());
668         SetLabelColor(source.GetName(), Color::GetColor(COLOR_ID_WHITE).GetRGB32());
669 }
670
671 void
672 PrivacyForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
673 {
674         AppLog("Enter %ls", source.GetName().GetPointer());
675         SetLabelColor(source.GetName(), COLOR_SUB_TEXT);
676 }
677
678 void
679 PrivacyForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
680 {
681         AppLog("Enter %ls", source.GetName().GetPointer());
682         SetLabelColor(source.GetName(), COLOR_SUB_TEXT);
683 }
684
685 void
686 PrivacyForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
687 {
688         AppLog("Enter %ls", source.GetName().GetPointer());
689         if(keyCode == KEY_ENTER)
690         {
691                 SetLabelColor(source.GetName(), Color::GetColor(COLOR_ID_WHITE).GetRGB32());
692         }
693 }
694
695 void
696 PrivacyForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
697 {
698         AppLog("Enter %ls", source.GetName().GetPointer());
699         if(keyCode == KEY_ENTER)
700         {
701                 SetLabelColor(source.GetName(), COLOR_SUB_TEXT);
702         }
703 }
704
705 void
706 PrivacyForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
707 {
708 }
709
710 void
711 PrivacyForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
712 {
713         AppLog("Enter");
714         if (requestId == REFRESH_REQUEST_EVENT)
715         {
716                 AppLog("Refresh");
717                 InitPrivacyAppPackageList();
718                 if (__pLabelArrayList != null)
719                 {
720                         __pLabelArrayList->RemoveAll(false);
721                 }
722                 UpdateTableViewAndNoContent();
723         }
724 }
725
726 void
727 PrivacyForm::OnFocusLost(const Tizen::Ui::Control& source)
728 {
729         AppLog("Enter %ls", source.GetName().GetPointer());
730         SetLabelColor(source.GetName(), COLOR_SUB_TEXT);
731 }
732
733 void
734 PrivacyForm::OnFocusGained(const Tizen::Ui::Control& source)
735 {
736         AppLog("Enter");
737 }
738
739 void
740 PrivacyForm::SetLabelColor(Tizen::Base::String sourceName, const unsigned int color)
741 {
742         AppLog("ENTER");
743         int index = 0;
744         String source = sourceName;
745         String temp_number;
746         source.Reverse();
747         source.IndexOf(L"_", 0, index);
748         source.SubString(0, index, temp_number);
749         Integer::Parse(temp_number, index);
750         Label* pLabel = null;
751
752         pLabel = static_cast <Label*> (__pLabelArrayList->GetAt(index));
753         if (pLabel != null)
754         {
755                 AppLog("Enter setting %ls", pLabel->GetName().GetPointer());
756                 pLabel->SetTextColor(color);
757                 pLabel->Invalidate(false);
758         }
759         AppLog("EXIT");
760 }