Applied latest source code
[apps/native/preloaded/Settings.git] / src / StMainMenuForm.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                StMainMenuForm.cpp
19  * @brief               This is the implementation file for MainMenuForm class.
20  */
21
22 #include "StBluetoothPresentationModel.h"
23 #include "StMainMenuForm.h"
24 #include "StNfcPresentationModel.h"
25 #include "StResourceManager.h"
26 #include "StSettingScenesList.h"
27 #include "StTypes.h"
28
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Net::Bluetooth;
34 using namespace Tizen::System;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38
39 static const int W_RESIZE_LABEL_GAP = 110;
40
41 static const int H_GROUP_FONT_SIZE_GIANT = 146;
42 static const int H_GROUP_FONT_SIZE_HUGE = 128;
43 static const int H_GROUP_FONT_SIZE_LARGE = 110;
44 static const int H_GROUP_FONT_SIZE_DEFAULT = 80;
45 static const int H_GROUP_TITLE_TEXT = (H_GROUP_INDEX_TITLE_TEXT / 4);
46 static const int MAIN_RELATIVE_LAYOUT_RIGHT_MARGIN = 60;
47
48 static const wchar_t* APPCONTROL_OPERATION_ID_CONFIGURE = L"http://tizen.org/appcontrol/operation/configure";
49 static const wchar_t* APPCONTROL_PROVIDER_ID_PHONE = L"tizen.phone";
50 static const wchar_t* APPCONTROL_PROVIDER_ID_ACCOUNT = L"ZsnYtAdjl2.Account";
51
52 static const int ID_GROUP_CONNECTIVITY = 0;
53 static const int ID_ITEM_CONNECTIVITY_WIFI = 0;
54 static const int ID_ITEM_CONNECTIVITY_BLUETOOTH = 1;
55 static const int ID_ITEM_CONNECTIVITY_NETWORK = 2;
56 static const int ID_ITEM_CONNECTIVITY_NFC = 3;
57 static const int ID_GROUP_CONNECTIVITY_ITEM_COUNT = 4;
58
59 static const int ID_GROUP_MODE = 1;
60 static const int ID_ITEM_MODE_FLIGHT_MODE = 0;
61 static const int ID_GROUP_MODE_ITEM_COUNT = 1;
62
63 static const int ID_GROUP_PERSONAL = 2;
64 static const int ID_ITEM_PERSONAL_HOME_SCREEN = 0;
65 static const int ID_ITEM_PERSONAL_LOCK_SCREEN = 1;
66 static const int ID_ITEM_PERSONAL_ACCOUNTS = 2;
67 static const int ID_ITEM_PERSONAL_PRIVACY = 3;
68 static const int ID_GROUP_PERSONAL_ITEM_COUNT = 4;
69
70 static const int ID_GROUP_DEVICE = 3;
71 static const int ID_ITEM_DEVICE_DISPLAY = 0;
72 static const int ID_ITEM_DEVICE_SOUND = 1;
73 static const int ID_ITEM_DEVICE_LOCATION = 2;
74 static const int ID_ITEM_DEVICE_CALL_SETTING = 3;
75 static const int ID_ITEM_DEVICE_ACCESSIBILITY = 4;
76 static const int ID_ITEM_DEVICE_DATE_TIME = 5;
77 static const int ID_ITEM_DEVICE_LANGUAGE_KEYBOARD = 6;
78 static const int ID_GROUP_DEVICE_ITEM_COUNT = 7;
79
80 static const int ID_GROUP_SYSTEM = 4;
81 static const int ID_ITEM_SYSTEM_MANAGE_APPLICATION = 0;
82 static const int ID_ITEM_SYSTEM_DOWNLOADED_APPLICATION = 1;
83 static const int ID_ITEM_SYSTEM_STORAGE = 2;
84 static const int ID_ITEM_SYSTEM_DEVELOPER_OPTION = 3;
85 static const int ID_ITEM_SYSTEM_ABOUT_PHONE = 4;
86 static const int ID_GROUP_SYSTEM_ITEM_COUNT = 5;
87
88 static const int ID_GROUP_APPSETTING = 5;
89 static const int ID_GROUP_NO_APPSETTING = 4;
90 static const int ID_MAIN_MENU_DEFAULT_COUNT = 1;
91 static const int EMULATOR_DEFAULT_COUNT = 1;
92
93 void
94 IFlightModeSetValueAsyncResultListener::OnResultReceivedForSetValueAsync(const Tizen::Base::String& key, result r)
95 {
96         AppLogDebug("key(%ls) r(%s)", key.GetPointer(), GetErrorMessage(r));
97
98         if (IsFailed(r))
99         {
100                 MainMenuForm* pMainMenuForm = dynamic_cast<MainMenuForm*>(SceneManager::GetInstance()->GetCurrentScene()->GetForm());
101                 if (pMainMenuForm)
102                 {
103                         bool flightModeEnableStatus = false;
104                         if (SettingInfo::GetValue(SETTING_INFO_KEY_NETWORK_FLIGHTMODE, flightModeEnableStatus) == E_SUCCESS)
105                         {
106                                 pMainMenuForm->__pTableView->SetItemChecked(ID_GROUP_MODE, ID_ITEM_MODE_FLIGHT_MODE, flightModeEnableStatus);
107                                 pMainMenuForm->__pTableView->RefreshItem(ID_GROUP_MODE, ID_ITEM_MODE_FLIGHT_MODE, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
108                         }
109                 }
110         }
111 }
112
113 MainMenuForm::MainMenuForm(void)
114         : __currentTableViewList(0)
115         , __isNfcSupported(false)
116         , __isRunningAppControl(false)
117         , __pFlightModeSetValueAsyncResultListener(null)
118 {
119 }
120
121 MainMenuForm::~MainMenuForm(void)
122 {
123 }
124
125 void
126 MainMenuForm::CreateFooter(void)
127 {
128         Footer* pFooter = GetFooter();
129         AppAssert(pFooter);
130
131         pFooter->AddActionEventListener(*this);
132 }
133
134 result
135 MainMenuForm::OnInitializing(void)
136 {
137         AppLogDebug("ENTER");
138
139         CreateHeader(ResourceManager::GetString(L"IDS_COM_BODY_SETTINGS"));
140         CreateTableView();
141         __isEmulator = IsEmulator();
142
143         __isNfcSupported = IsNfcSupported();
144         AddFocusEventListener(*this);
145         return E_SUCCESS;
146 }
147
148 result
149 MainMenuForm::OnTerminating(void)
150 {
151         __pTableView = null;
152         RemoveFocusEventListener(*this);
153         SetFormBackEventListener(null);
154         return E_SUCCESS;
155 }
156
157 void
158 MainMenuForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
159 {
160         Header* pHeader = GetHeader();
161         pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_SETTINGS"));
162
163         __pTableView->UpdateTableView();
164
165         bool flightModeEnableStatus = false;
166         if (SettingInfo::GetValue(SETTING_INFO_KEY_NETWORK_FLIGHTMODE, flightModeEnableStatus) == E_SUCCESS)
167         {
168                 __pTableView->SetItemChecked(ID_GROUP_MODE, ID_ITEM_MODE_FLIGHT_MODE, flightModeEnableStatus);
169         }
170 }
171
172 void
173 MainMenuForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
174 {
175 }
176
177 void
178 MainMenuForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
179 {
180         if (__isRunningAppControl)
181         {
182                 AppLogDebug("busy status");
183                 return;
184         }
185
186         UiApp* pApp = UiApp::GetInstance();
187         AppAssert(pApp);
188         pApp->Terminate();
189 }
190
191 int
192 MainMenuForm::GetGroupCount(void)
193 {
194         int groupItemCount = ID_GROUP_NO_APPSETTING;
195
196         if (__isEmulator == false)
197         {
198                 groupItemCount += ID_MAIN_MENU_DEFAULT_COUNT;
199         }
200
201         return groupItemCount;
202 }
203
204 int
205 MainMenuForm::GetItemCount(int groupIndex)
206 {
207         AppLogDebug("ENTER");
208
209         if ((__isEmulator == true)
210                 && (groupIndex >= ID_GROUP_MODE))
211         {
212                 groupIndex += EMULATOR_DEFAULT_COUNT;
213         }
214
215         int itemCount = 0;
216
217         switch (groupIndex)
218         {
219         case ID_GROUP_CONNECTIVITY:
220                 {
221                         itemCount = ID_GROUP_CONNECTIVITY_ITEM_COUNT;
222                 }
223                 break;
224
225         case ID_GROUP_MODE:
226                 {
227                         itemCount = ID_GROUP_MODE_ITEM_COUNT;
228                 }
229                 break;
230
231         case ID_GROUP_DEVICE:
232                 {
233                         itemCount = ID_GROUP_DEVICE_ITEM_COUNT;
234                 }
235                 break;
236
237         case ID_GROUP_PERSONAL:
238                 {
239                         itemCount = ID_GROUP_PERSONAL_ITEM_COUNT;
240                 }
241                 break;
242
243         case ID_GROUP_SYSTEM:
244                 {
245                         itemCount = ID_GROUP_SYSTEM_ITEM_COUNT;
246                 }
247                 break;
248
249         case ID_GROUP_APPSETTING:
250                 {
251                         itemCount = ID_MAIN_MENU_DEFAULT_COUNT;
252                 }
253                 break;
254
255         default:
256                 break;
257         }
258
259         return itemCount;
260 }
261
262 TableViewGroupItem*
263 MainMenuForm::CreateGroupItem(int groupIndex, int itemWidth)
264 {
265         AppLogDebug("ENTER");
266
267         int itemHeight = H_GROUP_INDEX_DEFAULT;
268         LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
269         Rectangle itemRectangle;
270         String groupText;
271         Label* pLabel = null;
272         int fontSize = GetFontSize();
273
274         if ((__isEmulator == true)
275                 && (groupIndex >= ID_GROUP_MODE))
276         {
277                 groupIndex += EMULATOR_DEFAULT_COUNT;
278         }
279
280         switch (groupIndex)
281         {
282         case ID_GROUP_CONNECTIVITY:
283                 {
284                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_CONNECTIVITY");
285                 }
286                 break;
287
288         case ID_GROUP_MODE:
289                 {
290                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_MODE");
291                 }
292                 break;
293
294         case ID_GROUP_PERSONAL:
295                 {
296                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_PERSONAL");
297                 }
298                 break;
299
300         case ID_GROUP_DEVICE:
301                 {
302                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_DEVICE");
303                 }
304                 break;
305
306         case ID_GROUP_SYSTEM:
307                 {
308                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_SYSTEM");
309                 }
310                 break;
311
312         case ID_GROUP_APPSETTING:
313                 {
314                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_DOWNLOADED_APPLICATIONS");
315                 }
316                 break;
317
318         default:
319                 break;
320         }
321
322         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
323
324         itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
325         itemRectangle.y = H_GROUP_TITLE_TEXT;
326         itemRectangle.width = itemWidth - itemRectangle.x;
327
328         if (fontSize == FONT_MAIN_TEXT_SIZE_GIANT)
329         {
330                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_GIANT;
331         }
332         else if (fontSize == FONT_MAIN_TEXT_SIZE_HUGE)
333         {
334                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_HUGE;
335         }
336         else if (fontSize == FONT_MAIN_TEXT_SIZE_LARGE)
337         {
338                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_LARGE;
339         }
340         else
341         {
342                 itemHeight = itemRectangle.height = H_GROUP_FONT_SIZE_DEFAULT;
343         }
344
345         RelativeLayout relativeLayout;
346         relativeLayout.Construct();
347
348         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
349         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
350
351         pLabel = new (std::nothrow) Label();
352         pLabel->Construct(itemRectangle, groupText);
353         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
354         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
355         pLabel->SetTextConfig(fontSize, style);
356         pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
357
358         pItem->AddControl(pLabel);
359         relativeLayout.SetMargin(*pLabel, itemRectangle.x, 0, 0, 0);
360         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
361         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
362         pItem->SetEnabled(false);
363
364         return pItem;
365 }
366
367 TableViewItem*
368 MainMenuForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
369 {
370         AppLogDebug("group[%d] item[%d]", groupIndex, itemIndex);
371
372         if ((__isEmulator == true)
373                 && (groupIndex >= ID_GROUP_MODE))
374         {
375                 groupIndex += EMULATOR_DEFAULT_COUNT;
376         }
377
378         int fontSize = GetFontSize();
379
380         unsigned int itemHeight = 0;
381         bool isDrawBitmapIcon = true;
382         Rectangle itemIconRectangle;
383         Rectangle itemMainRectangle;
384         Rectangle itemSubRectangle;
385         String itemMainText;
386         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
387         Bitmap* pBitmap = null;
388         Label* pLabel = null;
389
390         ItemTypeIconAndOneLine(itemIconRectangle, itemMainRectangle);
391         itemHeight = itemMainRectangle.height;
392
393         switch (groupIndex)
394         {
395         case ID_GROUP_CONNECTIVITY:
396                 {
397                         switch (itemIndex)
398                         {
399                         case ID_ITEM_CONNECTIVITY_WIFI:
400                                 {
401                                         if (__isEmulator)
402                                         {
403                                                 itemHeight = 0;
404                                         }
405                                         else
406                                         {
407                                                 pBitmap = ResourceManager::GetBitmapN(IDB_WIFI);
408                                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_WI_FI");
409                                         }
410                                 }
411                                 break;
412
413                         case ID_ITEM_CONNECTIVITY_BLUETOOTH:
414                                 {
415                                         if (__isEmulator)
416                                         {
417                                                 itemHeight = 0;
418                                         }
419                                         else
420                                         {
421                                                 ItemTypeIconAndOneLine(itemIconRectangle, itemMainRectangle);
422                                                 itemHeight = itemMainRectangle.height;
423
424                                                 pBitmap = ResourceManager::GetBitmapN(IDB_BLUETOOTH);
425                                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_BLUETOOTH");
426                                         }
427                                 }
428                                 break;
429
430                         case ID_ITEM_CONNECTIVITY_NETWORK:
431                                 {
432                                         pBitmap = ResourceManager::GetBitmapN(IDB_NETWORK);
433                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_NETWORK");
434                                 }
435                                 break;
436
437                         case ID_ITEM_CONNECTIVITY_NFC:
438                                 {
439                                         if (!__isNfcSupported)
440                                         {
441                                                 itemHeight = 0;
442                                         }
443                                         else
444                                         {
445                                                 ItemTypeIconAndOneLine(itemIconRectangle, itemMainRectangle);
446                                                 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
447
448                                                 pBitmap = ResourceManager::GetBitmapN(IDB_NFC);
449                                                 itemMainText = ResourceManager::GetString(L"IDS_NFC_BODY_NFC");
450                                         }
451                                 }
452                                 break;
453
454                         default:
455                                 break;
456                         }
457                 }
458                 break;
459
460         case ID_GROUP_MODE:
461                 {
462                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
463                         itemMainRectangle.width -= W_RESIZE_LABEL_GAP;
464                         pBitmap = ResourceManager::GetBitmapN(IDB_FLIGHT_MODE);
465                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_FLIGHT_MODE");
466                 }
467                 break;
468
469         case ID_GROUP_PERSONAL:
470                 {
471                         switch (itemIndex)
472                         {
473                         case ID_ITEM_PERSONAL_HOME_SCREEN:
474                                 {
475                                         pBitmap = ResourceManager::GetBitmapN(IDB_HOME_SCREEN);
476                                         itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_HOME_SCREEN");
477                                 }
478                                 break;
479
480                         case ID_ITEM_PERSONAL_LOCK_SCREEN:
481                                 {
482                                         pBitmap = ResourceManager::GetBitmapN(IDB_LOCK_SCREEN);
483                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN");
484                                 }
485                                 break;
486
487                         case ID_ITEM_PERSONAL_ACCOUNTS:
488                                 {
489                                         pBitmap = ResourceManager::GetBitmapN(IDB_ACCOUNTS);
490                                         itemMainText = ResourceManager::GetString(L"IDS_COM_BODY_ACCOUNTS");
491                                 }
492                                 break;
493
494                         case ID_ITEM_PERSONAL_PRIVACY:
495                                 {
496                                         pBitmap = ResourceManager::GetBitmapN(IDB_PRIVACY);
497                                         itemMainText = ResourceManager::GetString(L"IDS_COM_BODY_PRIVACY");
498                                 }
499                                 break;
500
501                         default:
502                                 break;
503                         }
504                 }
505                 break;
506
507         case ID_GROUP_DEVICE:
508                 {
509                         switch (itemIndex)
510                         {
511                         case ID_ITEM_DEVICE_DISPLAY:
512                                 {
513                                         pBitmap = ResourceManager::GetBitmapN(IDB_DISPLAY);
514                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DISPLAY");
515                                 }
516                                 break;
517
518                         case ID_ITEM_DEVICE_SOUND:
519                                 {
520                                         pBitmap = ResourceManager::GetBitmapN(IDB_SOUND);
521                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SOUNDS");
522                                 }
523                                 break;
524
525                         case ID_ITEM_DEVICE_LOCATION:
526                                 {
527                                         pBitmap = ResourceManager::GetBitmapN(IDB_LOCATION);
528                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_LOCATIONS");
529                                 }
530                                 break;
531
532                         case ID_ITEM_DEVICE_CALL_SETTING:
533                                 {
534                                         pBitmap = ResourceManager::GetBitmapN(IDB_PHONE);
535                                         itemMainText = ResourceManager::GetString(L"IDS_CST_BODY_CALL_SETTINGS");
536                                 }
537                                 break;
538
539                         case ID_ITEM_DEVICE_ACCESSIBILITY:
540                                 {
541                                         pBitmap = ResourceManager::GetBitmapN(IDB_ACCESSIBILITY);
542                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_ACCESSIBILITY");
543                                 }
544                                 break;
545
546                         case ID_ITEM_DEVICE_DATE_TIME:
547                                 {
548                                         pBitmap = ResourceManager::GetBitmapN(IDB_DATE_AND_TIME);
549                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DATE_AND_TIME");
550                                 }
551                                 break;
552
553                         case ID_ITEM_DEVICE_LANGUAGE_KEYBOARD:
554                                 {
555                                         pBitmap = ResourceManager::GetBitmapN(IDB_LANGUAGE_KEYBOARD);
556                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD");
557                                 }
558                                 break;
559
560                         default:
561                                 break;
562                         }
563                 }
564                 break;
565
566         case ID_GROUP_SYSTEM:
567                 {
568                         switch (itemIndex)
569                         {
570                         case ID_ITEM_SYSTEM_MANAGE_APPLICATION:
571                                 {
572                                         pBitmap = ResourceManager::GetBitmapN(IDB_MANAGE_APPLICATION);
573                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MANAGE_APPLICATIONS");
574                                 }
575                                 break;
576
577                         case ID_ITEM_SYSTEM_DOWNLOADED_APPLICATION:
578                                 {
579                                         pBitmap = ResourceManager::GetBitmapN(IDB_DEFAULT_ICON);
580                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DOWNLOADED_APPLICATIONS");
581                                 }
582                                 break;
583
584                         case ID_ITEM_SYSTEM_STORAGE:
585                                 {
586                                         pBitmap = ResourceManager::GetBitmapN(IDB_STORAGE);
587                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_STORAGE");
588                                 }
589                                 break;
590
591                         case ID_ITEM_SYSTEM_DEVELOPER_OPTION:
592                                 {
593                                         if (__isEmulator)
594                                         {
595                                                 itemHeight = 0;
596                                         }
597                                         else
598                                         {
599                                                 pBitmap = ResourceManager::GetBitmapN(IDB_DEVELOPER_OPTION);
600                                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DEVELOPER_OPTIONS");
601                                         }
602                                 }
603                                 break;
604
605                         case ID_ITEM_SYSTEM_ABOUT_PHONE:
606                                 {
607                                         pBitmap = ResourceManager::GetBitmapN(IDB_ABOUT_PHONE);
608                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_ABOUT_PHONE");
609                                 }
610                                 break;
611
612                         default:
613                                 break;
614                         }
615                 }
616                 break;
617
618         default:
619                 break;
620         }
621
622         TableViewItem* pItem = new (std::nothrow) TableViewItem();
623
624         if (pItem)
625         {
626                 RelativeLayout relativeLayout;
627                 relativeLayout.Construct();
628
629                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
630                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
631
632                 if (isDrawBitmapIcon)
633                 {
634                         pLabel = new (std::nothrow) Label();
635                         pLabel->Construct(itemIconRectangle, L"");
636                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
637                         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
638                         pLabel->SetBackgroundBitmap(*pBitmap);
639
640                         pItem->AddControl(pLabel);
641                 }
642
643                 pLabel = new (std::nothrow) Label();
644                 pLabel->Construct(itemMainRectangle, itemMainText);
645                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
646                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
647                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
648
649                 pItem->AddControl(pLabel);
650                 if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
651                 {
652                         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
653                 }
654                 else
655                 {
656                         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, MAIN_RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
657                 }
658                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
659                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
660
661                 if (itemHeight == 0)
662                 {
663                         pItem->SetShowState(false);
664                         pItem->SetEnabled(false);
665                 }
666         }
667
668         if(pBitmap)
669         {
670                 delete pBitmap;
671         }
672
673         return pItem;
674 }
675
676 bool
677 MainMenuForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
678 {
679         AppLogDebug("ENTER");
680
681         delete pItem;
682         pItem = null;
683
684         return true;
685 }
686
687 bool
688 MainMenuForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
689 {
690         AppLogDebug("ENTER");
691
692         delete pItem;
693         pItem = null;
694
695         return true;
696 }
697
698 void
699 MainMenuForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
700 {
701         if (__isRunningAppControl)
702         {
703                 AppLogDebug("busy status");
704                 return;
705         }
706
707         SceneManager* pSceneManager = SceneManager::GetInstance();
708         AppAssert(pSceneManager);
709
710         if ((__isEmulator == true)
711                 && (groupIndex >= ID_GROUP_MODE))
712         {
713                 groupIndex += EMULATOR_DEFAULT_COUNT;
714         }
715         ArrayList* pArgs = null;
716         const wchar_t* pSceneName = null;
717
718         AppLogDebug("Group(%d) index(%d)", groupIndex, itemIndex);
719
720         switch (groupIndex)
721         {
722         case ID_GROUP_CONNECTIVITY:
723                 {
724                         pSceneName = GroupConnectivitySceneConnect(__currentTableViewList, itemIndex, status);
725
726                         AppControl* pAppControl = null;
727
728                         if (pSceneName == IDSCN_WIFI)
729                         {
730                                 pAppControl = AppManager::GetInstance()->FindAppControlN(L"wifi-efl-ug", L"");
731                         }
732                         else if (pSceneName == IDSCN_BLUETOOTH)
733                         {
734                                 pAppControl = AppManager::GetInstance()->FindAppControlN(L"ug-bluetooth-efl", L"");
735                         }
736
737                         if (pAppControl)
738                         {
739                                 AppLog("pAppControl is not null");
740                                 HashMap* pExtraData = new (std::nothrow) HashMap(SingleObjectDeleter);
741                                 pExtraData->Construct();
742
743                                 pExtraData->Add(new (std::nothrow) String(L"caller"), new (std::nothrow) String(L"osp-setting"));
744
745                                 if (pAppControl->Start(null, null, pExtraData, null) == E_SUCCESS)
746                                 {
747                                         __isRunningAppControl = true;
748                                 }
749
750                                 delete pAppControl;
751                                 delete pExtraData;
752                                 return;
753                         }
754                 }
755                 break;
756
757         case ID_GROUP_MODE:
758                 {
759                         if (itemIndex == ID_ITEM_MODE_FLIGHT_MODE)
760                         {
761                                 bool flightModeStatus = tableView.IsItemChecked(groupIndex, itemIndex);
762                                 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
763                                 {
764                                         flightModeStatus = (!(flightModeStatus));
765                                 }
766
767                                 SetIFlightModeSetValueAsyncResultListener();
768                                 if (SettingInfo::SetValueAsyncForPrivilegedKey(SETTING_INFO_KEY_NETWORK_FLIGHTMODE, flightModeStatus, __pFlightModeSetValueAsyncResultListener) == E_SUCCESS)
769                                 {
770                                         tableView.SetItemChecked(groupIndex, itemIndex, flightModeStatus);
771                                         AppLogDebug("flightmode(%d) GetLastResult(%s)", flightModeStatus, GetErrorMessage(GetLastResult()));
772                                 }
773                                 else
774                                 {
775                                         AppLogDebug("flightmode(%d) GetLastResult(%s)", flightModeStatus, GetErrorMessage(GetLastResult()));
776                                 }
777                         }
778                 }
779                 break;
780
781         case ID_GROUP_PERSONAL:
782                 {
783                         pSceneName = GroupPersonalSceneConnect(__currentTableViewList, itemIndex, status);
784
785                         if ((itemIndex != ID_ITEM_PERSONAL_HOME_SCREEN)
786                                 && (itemIndex != ID_ITEM_PERSONAL_LOCK_SCREEN))
787                         {
788                                 break;
789                         }
790
791                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
792                         if (pArgs == null)
793                         {
794                                 AppLogDebug("pArgs is null");
795                                 break;
796                         }
797
798                         result r = pArgs->Construct();
799                         if (IsFailed(r))
800                         {
801                                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
802                                 break;
803                         }
804
805                         switch (itemIndex)
806                         {
807                         case ID_ITEM_PERSONAL_HOME_SCREEN:
808                                 {
809                                         pArgs->Add(new (std::nothrow) String(Integer::ToString(itemIndex)));
810                                 }
811                                 break;
812
813                         case ID_ITEM_PERSONAL_LOCK_SCREEN:
814                                 {
815                                         pArgs->Add(new (std::nothrow) String(Integer::ToString(itemIndex)));
816                                 }
817                                 break;
818                         }
819                 }
820                 break;
821
822         case ID_GROUP_DEVICE:
823                 {
824                         pSceneName = GroupDeviceSceneConnect(__currentTableViewList, itemIndex, status);
825                 }
826                 break;
827
828         case ID_GROUP_SYSTEM:
829                 {
830                         pSceneName = GroupSystemSceneConnect(__currentTableViewList, itemIndex, status);
831                 }
832                 break;
833
834         default:
835                 break;
836         }
837
838         AppLog("pAppControl is null");
839         if (pSceneName != IDSCN_NULL)
840         {
841                 AppLogDebug("pSceneName[%ls]", pSceneName);
842                 pSceneManager->GoForward(ForwardSceneTransition(pSceneName, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
843         }
844 }
845
846 const wchar_t*
847 MainMenuForm::GroupConnectivitySceneConnect(int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
848 {
849         const wchar_t* pScene = null;
850
851         switch (itemIndex)
852         {
853         case ID_ITEM_CONNECTIVITY_WIFI:
854                 {
855 //                      if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
856                         {
857                                 pScene = IDSCN_WIFI;
858                         }
859                 }
860                 break;
861
862         case ID_ITEM_CONNECTIVITY_BLUETOOTH:
863                 {
864 //                      if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
865                         {
866                                 pScene = IDSCN_BLUETOOTH;
867                         }
868                 }
869                 break;
870
871         case ID_ITEM_CONNECTIVITY_NETWORK:
872                 {
873                         pScene = IDSCN_NETWORK;
874                 }
875                 break;
876
877         case ID_ITEM_CONNECTIVITY_NFC:
878                 {
879                         pScene = IDSCN_NFC;
880                 }
881                 break;
882
883         default:
884                 {
885                         pScene = IDSCN_NULL;
886                 }
887                 break;
888         }
889
890         return pScene;
891 }
892
893 const wchar_t*
894 MainMenuForm::GroupPersonalSceneConnect (int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
895 {
896         const wchar_t* pScene = null;
897
898         switch (itemIndex)
899         {
900         case ID_ITEM_PERSONAL_HOME_SCREEN:
901                 {
902                         pScene = IDSCN_HOME_AND_LOCK_SCREEN; 
903                 }
904                 break;
905
906         case ID_ITEM_PERSONAL_LOCK_SCREEN:
907                 {
908                         pScene = IDSCN_HOME_AND_LOCK_SCREEN;
909                 }
910                 break;
911
912         case ID_ITEM_PERSONAL_ACCOUNTS:
913                 {
914                         pScene = IDSCN_NULL;
915
916                         FindAppControlScene(itemIndex);
917                 }
918                 break;
919
920         case ID_ITEM_PERSONAL_PRIVACY:
921                 {
922                         pScene = IDSCN_PRIVACY;
923                 }
924                 break;
925
926         default:
927                 {
928                         pScene = IDSCN_NULL;
929                 }
930                 break;
931         }
932         return pScene;
933 }
934
935 const wchar_t*
936 MainMenuForm::GroupDeviceSceneConnect(int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
937 {
938         const wchar_t* pScene = null;
939
940         switch (itemIndex)
941         {
942         case ID_ITEM_DEVICE_DISPLAY:
943                 {
944                         pScene = IDSCN_DISPLAY;
945                 }
946                 break;
947
948         case ID_ITEM_DEVICE_SOUND:
949                 {
950                         pScene = IDSCN_SOUNDS;
951                 }
952                 break;
953
954         case ID_ITEM_DEVICE_LOCATION:
955                 {
956                         pScene = IDSCN_LOCATION;
957                 }
958                 break;
959
960         case ID_ITEM_DEVICE_CALL_SETTING:
961                 {
962                         pScene = IDSCN_NULL;
963
964                         FindAppControlScene(itemIndex);
965                 }
966                 break;
967
968         case ID_ITEM_DEVICE_ACCESSIBILITY:
969                 {
970                         pScene = IDSCN_ACCESSIBILITY;
971                 }
972                 break;
973
974         case ID_ITEM_DEVICE_DATE_TIME:
975                 {
976                         pScene = IDSCN_DATE_TIME;
977                 }
978                 break;
979
980         case ID_ITEM_DEVICE_LANGUAGE_KEYBOARD:
981                 {
982                         pScene = IDSCN_LOCALE;
983                 }
984                 break;
985
986         default:
987                 {
988                         pScene = IDSCN_NULL;
989                 }
990                 break;
991         }
992         return pScene;
993 }
994
995 const wchar_t*
996 MainMenuForm::GroupSystemSceneConnect(int viewMode, int itemIndex, Tizen::Ui::Controls::TableViewItemStatus status)
997 {
998         const wchar_t* pScene = null;
999
1000         switch (itemIndex)
1001         {
1002         case ID_ITEM_SYSTEM_MANAGE_APPLICATION:
1003                 {
1004                         pScene = IDSCN_MANAGE_APPLICATION;
1005                 }
1006                 break;
1007
1008         case ID_ITEM_SYSTEM_DOWNLOADED_APPLICATION:
1009                 {
1010                         pScene = IDSCN_DOWNLOADED_APPLICATION;
1011                 }
1012                 break;
1013
1014         case ID_ITEM_SYSTEM_STORAGE:
1015                 {
1016                         pScene = IDSCN_MEMORY_STATUS;
1017                 }
1018                 break;
1019
1020         case ID_ITEM_SYSTEM_DEVELOPER_OPTION:
1021                 {
1022                         pScene = IDSCN_DEVELOPER_OPTION;
1023                 }
1024                 break;
1025
1026         case ID_ITEM_SYSTEM_ABOUT_PHONE:
1027                 {
1028                         pScene = IDSCN_PHONE_INFO;
1029                 }
1030                 break;
1031
1032         default:
1033                 {
1034                         pScene = IDSCN_NULL;
1035                 }
1036                 break;
1037         }
1038         return pScene;
1039 }
1040
1041 bool
1042 MainMenuForm::IsEmulator(void)
1043 {
1044         String modelName;
1045         if (SystemInfo::GetValue(SYSTEM_INFO_KEY_MODELNAME, modelName) != E_SUCCESS)
1046         {
1047                 AppLogDebug("GetValue is error %s", GetErrorMessage(GetLastResult()));
1048                 return false;
1049         }
1050
1051         return modelName.Equals(L"Emulator", false);
1052 }
1053
1054 bool
1055 MainMenuForm::IsNfcSupported(void)
1056 {
1057         bool isNfcSupported = false;
1058         if (SystemInfo::GetValue(SYSTEM_INFO_KEY_NFC, isNfcSupported) != E_SUCCESS)
1059         {
1060                 AppLogDebug("GetValue is error %s", GetErrorMessage(GetLastResult()));
1061                 return false;
1062         }
1063         AppLog("isNfcSupported = %d", isNfcSupported);
1064         return isNfcSupported;
1065 }
1066
1067 void
1068 MainMenuForm::FindAppControlScene(int itemIndex)
1069 {
1070         if (__isRunningAppControl)
1071         {
1072                 AppLogDebug("busy status");
1073                 return;
1074         }
1075
1076         String providerId;
1077         String operationId = APPCONTROL_OPERATION_ID_CONFIGURE;
1078
1079         ArrayList* pDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1080
1081         pDataList->Construct();
1082
1083         switch (itemIndex)
1084         {
1085         case ID_ITEM_PERSONAL_ACCOUNTS:
1086                 {
1087                         providerId = APPCONTROL_PROVIDER_ID_ACCOUNT;
1088                 }
1089                 break;
1090
1091         case ID_ITEM_DEVICE_CALL_SETTING:
1092                 {
1093                         providerId = APPCONTROL_PROVIDER_ID_PHONE;
1094                 }
1095                 break;
1096
1097         default:
1098                 break;
1099         }
1100
1101         if (providerId != L"")
1102         {
1103                 AppControl* pAppControl = AppManager::FindAppControlN(providerId, operationId);
1104
1105                 if (pAppControl)
1106                 {
1107                         if (pAppControl->Start(pDataList, null) == E_SUCCESS)
1108                         {
1109                                 //SetFocus();
1110                                 __isRunningAppControl = true;
1111                         }
1112                         delete pAppControl;
1113                 }
1114         }
1115
1116         delete pDataList;
1117         pDataList = null;
1118 }
1119
1120 int
1121 MainMenuForm::GetDefaultGroupItemHeight(void)
1122 {
1123         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1124 }
1125
1126 int
1127 MainMenuForm::GetDefaultItemHeight(void)
1128 {
1129         return H_GROUP_ITEM_DEFAULT;
1130 }
1131
1132 void
1133 MainMenuForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1134 {
1135 }
1136
1137 void
1138 MainMenuForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1139 {
1140 }
1141
1142 void
1143 MainMenuForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1144 {
1145 }
1146
1147 void
1148 MainMenuForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1149 {
1150 }
1151
1152 void
1153 MainMenuForm::OnResultReceivedForSetValueAsync(const Tizen::Base::String& key, result r)
1154 {
1155         AppLogDebug("ENTER");
1156 }
1157
1158 void
1159 MainMenuForm::SetIFlightModeSetValueAsyncResultListener(void)
1160 {
1161         __pFlightModeSetValueAsyncResultListener = new (std::nothrow) IFlightModeSetValueAsyncResultListener();
1162 }
1163
1164 void
1165 MainMenuForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1166 {
1167         Invalidate(true);
1168 }
1169
1170 void
1171 MainMenuForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1172 {
1173         if (requestId == REFRESH_REQUEST_EVENT)
1174         {
1175                 AppLog("Refresh");
1176                 __isRunningAppControl = false;
1177         }
1178 }
1179
1180 void
1181 MainMenuForm::OnFocusLost(const Tizen::Ui::Control& source)
1182 {
1183         AppLog("Enter");
1184 }
1185
1186 void
1187 MainMenuForm::OnFocusGained(const Tizen::Ui::Control& source)
1188 {
1189         AppLog("Enter");
1190         __isRunningAppControl = false;
1191 }