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