Applied latest source code
[apps/native/preloaded/Settings.git] / src / StSoundsForm.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                StSoundsForm.cpp
19  * @brief               This is the implementation file for SoundsForm class.
20  */
21
22 #include "StResourceManager.h"
23 #include "StSoundsForm.h"
24 #include "StTypes.h"
25
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Media;
30 using namespace Tizen::System;
31 using namespace Tizen::Ui;
32 using namespace Tizen::Ui::Controls;
33 using namespace Tizen::Ui::Scenes;
34
35 static const int IDA_HEADER_VOLUME = 100;
36 static const int IDA_HEADER_RINGTONE = 101;
37
38 static const int ID_GROUP_MAIN = 0;
39 static const int ID_GROUP_MAIN_ITEM_COUNT = 1;
40 static const int ID_ITEM_MAIN_VOLUME = 0;
41 static const int ID_ITEM_MAIN_VIBRATION = 1;
42
43 static const int ID_GROUP_VOLUME = 1;
44
45 static const int ID_GROUP_VOLUME_ITEM_COUNT = 3;
46 static const int ID_ITEM_VOLUME_NOTIFICATION = 0;
47 static const int ID_ITEM_VOLUME_MEDIA = 1;
48 static const int ID_ITEM_VOLUME_SYSTEM = 2;
49
50 static const int ID_GROUP_VIBRATION = 2;
51 static const int ID_GROUP_VIBRATION_ITEM_COUNT = 2;
52 static const int ID_ITEM_VIBRATION_NOTIFICATION = 0;
53 static const int ID_ITEM_VIBRATION_HAPTIC_FEEDBACK = 1;
54
55 static const int ID_GROUP_INCOMMING_CALL = 0;
56 static const int ID_ITEM_INCOMMING_CALL_RINGTONE = 0;
57 static const int ID_ITEM_INCOMMING_CALL_VIBRATION = 1;
58
59 static const int ID_GROUP_NOTIFICATION = 1;
60 static const int ID_ITEM_NOTIFICATION_MESSAGE_ALERT = 0;
61 static const int ID_ITEM_NOTIFICATION_MESSAGE_ALERT_REPETITION = 1;
62 static const int ID_ITEM_NOTIFICATION_EMAIL_ALERT = 2;
63 static const int ID_ITEM_NOTIFICATION_EMAIL_ALERT_REPETITION = 3;
64
65 static const int ID_GROUP_SCREEN_LOCK_SOUND = 2;
66 static const int ID_GROUP_SCREEN_LOCK_SOUND_ITEM_COUNT = 1;
67
68 static const int ID_VOLUME_PAGE_GROUP_COUNT = 2;
69 static const int ID_RINGTONE_PAGE_GROUP_COUNT = 3;
70
71 static const int ID_GROUP1 = 0;
72 static const int ID_GROUP2 = 1;
73 static const int ID_GROUP3 = 2;
74 static const int ID_GROUP4 = 3;
75
76 static const int ID_GROUP2_INDEX1 = 0;
77 static const int ID_GROUP2_INDEX2 = 1;
78 static const int ID_GROUP2_INDEX3 = 2;
79
80 static const int ID_SOUND_VOLUME_PAGE = 1;
81 static const int ID_SOUND_RINGTONE_PAGE = 2;
82
83 static const int GROUP_ITEM_SLIDER_MIN_VALUE = 0;
84 static const int GROUP_ITEM_SLIDER_MAX_VALUE = 15;
85 static const int GROUP_ITEM_SLIDER_DEFAULT_VALUE = 5;
86
87 static const int STRING_SIZE_LIMIT = 20;
88
89 static const int SOUND_FORM_FIRST_CONTROL = 0;
90
91 SoundsForm::SoundsForm(void)
92         : __currentTableViewList(ID_SOUND_VOLUME_PAGE)
93         , __pSoundPlay(null)
94         , __notificationVolume(0)
95         , __mediaVolume(0)
96         , __systemVolume(0)
97 {
98 }
99
100 SoundsForm::~SoundsForm(void)
101 {
102 }
103
104 void
105 SoundsForm::CreateHeader(void)
106 {
107         Header* pHeader = GetHeader();
108
109         pHeader->SetStyle(HEADER_STYLE_TAB);
110
111         HeaderItem headerItemVolume;
112         headerItemVolume.Construct(IDA_HEADER_VOLUME);
113         headerItemVolume.SetText(ResourceManager::GetString(L"IDS_ST_BODY_VOLUME"));
114
115         pHeader->AddItem(headerItemVolume);
116         pHeader->AddActionEventListener(*this);
117 }
118
119 void
120 SoundsForm::CreateFooter(void)
121 {
122         Footer* pFooter = GetFooter();
123         AppAssert(pFooter);
124
125         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
126         pFooter->AddActionEventListener(*this);
127
128         SetFormBackEventListener(this);
129 }
130
131 result
132 SoundsForm::OnInitializing(void)
133 {
134         BaseForm::CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_SOUNDS"));
135         CreateTableView();
136         SettingInfo::AddSettingEventListener(*this);
137 #if 0 // Not supported by platform
138         result r = E_SUCCESS;
139
140         AddFocusEventListener(*this);
141
142         SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_NOTIFICATION_VOLUME, __notificationVolume);
143         SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, __mediaVolume);
144         SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, __systemVolume);
145
146         SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, 15);
147         SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, 0);
148
149         __pSoundPlay = new (std::nothrow) Player();
150         r = __pSoundPlay->Construct(*this);
151         if (IsFailed(r))
152         {
153                 AppLogDebug("Construct fail(%s)", GetErrorMessage(r));
154         }
155 #endif
156         return E_SUCCESS;
157 }
158
159 result
160 SoundsForm::OnTerminating(void)
161 {
162 #if 0 // Not supported by platform
163         if (__pSoundPlay != null)
164         {
165                 PlayerState estate = __pSoundPlay->GetState();
166                 if ((estate == PLAYER_STATE_OPENED) || (estate == PLAYER_STATE_PAUSED)
167                         || (estate == PLAYER_STATE_PLAYING)
168                         || (estate == PLAYER_STATE_ENDOFCLIP) || (estate == PLAYER_STATE_STOPPED))
169                 {
170                         __pSoundPlay->Stop();
171                         __pSoundPlay->Close();
172                 }
173                 delete __pSoundPlay;
174         }
175 #endif
176         SettingInfo::RemoveSettingEventListener(*this);
177         SetFormBackEventListener(null);
178         return E_SUCCESS;
179 }
180
181 void
182 SoundsForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
183 {
184         bool itemStatus = false;
185
186         __pTableView->UpdateTableView();
187
188         if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
189         {
190                 if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, itemStatus) == E_SUCCESS)
191                 {
192                         if (itemStatus == false)
193                         {
194                                 __pTableView->SetItemChecked(ID_GROUP1, ID_ITEM_MAIN_VOLUME, true);
195                                 __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX1, true);
196                                 __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX2, true);
197                                 __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX3, true);
198                         }
199                         else
200                         {
201                                 __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX1, false);
202                                 __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX2, false);
203                                 __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX3, false);
204                         }
205                 }
206         }
207 }
208
209 void
210 SoundsForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
211 {
212 }
213
214 void
215 SoundsForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
216 {
217 #if 0 // Not supported by platform
218         PlaySound();
219 #endif
220         SceneManager* pSceneManager = SceneManager::GetInstance();
221         AppAssert(pSceneManager);
222
223         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
224 }
225
226 int
227 SoundsForm::GetGroupCount(void)
228 {
229         AppLogDebug("ENTER");
230         return ((__currentTableViewList == ID_SOUND_VOLUME_PAGE) ? (ID_VOLUME_PAGE_GROUP_COUNT) : (ID_RINGTONE_PAGE_GROUP_COUNT));
231 }
232
233 int
234 SoundsForm::GetItemCount(int groupIndex)
235 {
236         AppLogDebug("ENTER");
237
238         int itemCount = 0;
239
240         switch (groupIndex)
241         {
242         case ID_GROUP1:
243                 {
244                         itemCount = ID_GROUP_MAIN_ITEM_COUNT;
245                 }
246                 break;
247
248         case ID_GROUP2:
249                 {
250                         itemCount = ID_GROUP_VOLUME_ITEM_COUNT;
251                 }
252                 break;
253
254         case ID_GROUP3:
255                 {
256                         if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
257                         {
258                                 itemCount = ID_GROUP_VIBRATION_ITEM_COUNT;
259                         }
260                         else
261                         {
262                                 itemCount = ID_GROUP_SCREEN_LOCK_SOUND_ITEM_COUNT;
263                         }
264                 }
265                 break;
266
267         default:
268                 break;
269         }
270
271         return itemCount;
272 }
273
274 TableViewGroupItem*
275 SoundsForm::CreateGroupItem(int groupIndex, int itemWidth)
276 {
277         int itemHeight = H_GROUP_INDEX_DEFAULT;
278         int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
279         Color colorText = COLOR_HELP_TEXT_TYPE_01;
280         LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
281         Rectangle itemMainRectangle;
282         String groupText;
283         Label* pLabel = null;
284
285         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
286
287         switch (groupIndex)
288         {
289         case ID_GROUP1:
290                 {
291                         if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
292                         {
293                                 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
294                                 groupText = L"";
295                         }
296                         else
297                         {
298                                 style = LABEL_TEXT_STYLE_BOLD;
299                                 colorText = COLOR_GROUP_TITLE_TEXT;
300                                 itemHeight = H_GROUP_INDEX_DEFAULT;
301                                 groupText = ResourceManager::GetString(L"IDS_ST_BODY_INCOMMING_CALL");
302                         }
303                         yItemOffset = H_GROUP_INDEX_TITLE_TEXT;
304                 }
305                 break;
306
307         case ID_GROUP2:
308                 {
309                         if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
310                         {
311                                 style = LABEL_TEXT_STYLE_BOLD;
312                                 colorText = COLOR_GROUP_TITLE_TEXT;
313                                 itemHeight = H_GROUP_INDEX_DEFAULT;
314                                 groupText = ResourceManager::GetString(L"IDS_ST_BODY_VOLUME");
315                         }
316                         else
317                         {
318                                 style = LABEL_TEXT_STYLE_BOLD;
319                                 colorText = COLOR_GROUP_TITLE_TEXT;
320                                 itemHeight = H_GROUP_INDEX_DEFAULT;
321                                 groupText = ResourceManager::GetString(L"IDS_ST_BODY_NOTIFICATION");
322                         }
323                         yItemOffset = H_GROUP_INDEX_TITLE_TEXT;
324                 }
325                 break;
326
327         case ID_GROUP3:
328                 {
329                         if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
330                         {
331                                 style = LABEL_TEXT_STYLE_BOLD;
332                                 colorText = COLOR_GROUP_TITLE_TEXT;
333                                 itemHeight = H_GROUP_INDEX_DEFAULT;
334                                 groupText = ResourceManager::GetString(L"IDS_ST_BODY_CALLALERTTYPE_VIBRATION");
335                         }
336                         else
337                         {
338                                 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
339                         }
340                         yItemOffset = H_GROUP_INDEX_TITLE_TEXT;
341                 }
342                 break;
343
344         case ID_GROUP4:
345                 {
346                         if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
347                         {
348                                 style = LABEL_TEXT_STYLE_NORMAL;
349                                 colorText = COLOR_HELP_TEXT_TYPE_01;
350                                 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
351                                 itemHeight = ((H_GROUP_INDEX_HELP_TEXT * LINE_COUNT_5) + H_GROUP_INDEX_NO_TITLE_TEXT_GAP);
352                         }
353                         else
354                         {
355                                 yItemOffset = H_GROUP_INDEX_TITLE_TEXT;
356                                 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
357                         }
358                 }
359                 break;
360
361         default:
362                 break;
363         }
364
365         itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
366         itemMainRectangle.y = yItemOffset;
367         itemMainRectangle.width = itemWidth;
368         itemMainRectangle.height = itemHeight;
369
370         RelativeLayout relativeLayout;
371         relativeLayout.Construct();
372
373         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
374         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
375
376         pLabel = new (std::nothrow) Label();
377         pLabel->Construct(itemMainRectangle, groupText);
378         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
379         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
380         pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
381         pLabel->SetTextColor(colorText);
382
383         pItem->AddControl(pLabel);
384         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
385         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
386         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
387         pItem->SetEnabled(false);
388
389         return pItem;
390 }
391
392 TableViewItem*
393 SoundsForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
394 {
395         bool slientMode = false;
396         Rectangle itemMainRectangle;
397         Rectangle itemSliderRectangle;
398         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
399         Bitmap* pBitmapSoundMin = null;
400         Bitmap* pBitmapSoundMax = null;
401         Label* pLabel = null;
402
403         Slider* pSlider = null;
404         String itemMainText;
405         int fontSize = GetFontSize();
406
407         TableViewItem* pItem = new (std::nothrow) TableViewItem();
408
409         ItemTypeOneLine(itemMainRectangle);
410
411         itemSliderRectangle.x = 0;
412         itemSliderRectangle.y = Y_GROUP_ITEM_DEFAULT_LABEL;
413         itemSliderRectangle.width = itemWidth;
414         itemSliderRectangle.height = H_GROUP_ITEM_DEFAULT_SLIDER;
415
416         if (groupIndex == ID_GROUP1)
417         {
418                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
419                 {
420                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
421                 }
422
423                 RelativeLayout relativeLayout;
424                 relativeLayout.Construct();
425
426                 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
427                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
428         
429                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
430                 {
431                         switch (itemIndex)
432                         {
433                         case ID_ITEM_MAIN_VOLUME:
434                                 {
435                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SOUNDS");
436
437                                         if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, slientMode) == E_SUCCESS)
438                                         {
439                                                 if (slientMode == false)
440                                                 {
441                                                         __pTableView->SetItemChecked(groupIndex, itemIndex, true);
442                                                 }
443                                         }
444                                         else
445                                         {
446                                                 AppLogDebug("Construct fail(%s)", GetErrorMessage(GetLastResult()));
447                                         }
448                                         GroupItemEnable(itemIndex, slientMode);
449                                 }
450                                 break;
451
452                         case ID_ITEM_MAIN_VIBRATION:
453                                 {
454                                         bool vibratorStatus = false;
455                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_CALLALERTTYPE_VIBRATION");
456
457                                         if (SettingInfo::GetValue(SETTING_INFO_KEY_VIBRATOR, vibratorStatus) == E_SUCCESS)
458                                         {
459                                                 __pTableView->SetItemChecked(groupIndex, itemIndex, vibratorStatus);
460                                         }
461                                         else
462                                         {
463                                                 AppLogDebug("Construct fail(%s)", GetErrorMessage(GetLastResult()));
464                                         }
465                                 }
466                                 break;
467
468                         default:
469                                 break;
470                         }
471
472                         pLabel = new (std::nothrow) Label();
473                         pLabel->Construct(itemMainRectangle, itemMainText);
474                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
475                         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
476                         pLabel->SetTextColor(COLOR_MAIN_TEXT);
477
478                         pItem->AddControl(pLabel);
479                         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
480                         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
481                         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
482                 }
483                 else
484                 {
485                         switch (itemIndex)
486                         {
487                         case ID_ITEM_INCOMMING_CALL_RINGTONE:
488                                 {
489                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_INCOMING_CALL_RINGTONE");
490                                 }
491                                 break;
492
493                         case ID_ITEM_INCOMMING_CALL_VIBRATION:
494                                 {
495                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_INCOMING_CALL_VIBRATION");
496                                 }
497                                 break;
498
499                         default:
500                                 break;
501                         }
502
503                         pLabel = new (std::nothrow) Label();
504                         pLabel->Construct(itemMainRectangle, itemMainText);
505                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
506                         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
507                         pLabel->SetTextColor(COLOR_MAIN_TEXT);
508
509                         pItem->AddControl(pLabel);
510                         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
511                         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
512                         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
513                 }
514         }
515
516         if (groupIndex == ID_GROUP2)
517         {
518                 RelativeLayout relativeLayout;
519                 relativeLayout.Construct();
520
521                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
522                 {
523                         pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT_SLIDER), style);
524                 }
525                 else
526                 {
527                         pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
528                 }
529
530                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
531
532                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
533                 {
534                         result r = E_SUCCESS;
535                         int volume = 0;
536                         String sliderItemName;
537                         sliderItemName.Format(STRING_SIZE_LIMIT, L"volumeItem_%d", itemIndex);
538
539                         pSlider = new (std::nothrow) Slider();
540
541                         pSlider->Construct(itemSliderRectangle, BACKGROUND_STYLE_NONE, true, GROUP_ITEM_SLIDER_MIN_VALUE, GROUP_ITEM_SLIDER_MAX_VALUE);
542
543                         if (itemIndex == ID_ITEM_VOLUME_SYSTEM)
544                         {
545                                 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_SYSTEM"));
546                                 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, volume);
547                         }
548                         else if (itemIndex == ID_ITEM_VOLUME_MEDIA)
549                         {
550                                 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_MEDIA"));
551                                 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, volume);
552                         }
553                         else if (itemIndex == ID_ITEM_VOLUME_NOTIFICATION)
554                         {
555                                 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_NOTIFICATION"));
556                                 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_NOTIFICATION_VOLUME, volume);
557                         }
558
559                         if (IsFailed(r))
560                         {
561                                 AppLogDebug("Get volume fail... - %s", GetErrorMessage(r));
562                                 pSlider->SetValue(GROUP_ITEM_SLIDER_DEFAULT_VALUE);
563                         }
564                         else
565                         {
566                                 pSlider->SetValue(volume);
567                         }
568
569                         pBitmapSoundMin = ResourceManager::GetBitmapN(IDB_SOUND_MIN);
570                         pBitmapSoundMin->SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
571                         pBitmapSoundMin->Scale(Dimension(72,72));
572                         pBitmapSoundMax = ResourceManager::GetBitmapN(IDB_SOUND_MAX);
573                         pBitmapSoundMax->SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
574                         pBitmapSoundMax->Scale(Dimension(72,72));
575
576                         pSlider->SetIcon(ICON_POSITION_LEFT, *pBitmapSoundMin);
577                         pSlider->SetIcon(ICON_POSITION_RIGHT, *pBitmapSoundMax);
578                         pSlider->AddAdjustmentEventListener(*this);
579                         pSlider->AddSliderEventListener(*this);
580                         pSlider->SetName(sliderItemName);
581
582                         delete pBitmapSoundMin;
583                         delete pBitmapSoundMax;
584
585                         pItem->AddControl(pSlider);
586                         pItem->SetIndividualSelectionEnabled(pSlider, true);
587
588                         relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
589                         relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
590                 }
591                 else
592                 {
593                         switch (itemIndex)
594                         {
595                         case ID_ITEM_NOTIFICATION_MESSAGE_ALERT:
596                                 {
597                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MESSAGE_ALERT");
598                                 }
599                                 break;
600
601                         case ID_ITEM_NOTIFICATION_MESSAGE_ALERT_REPETITION:
602                                 {
603                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MSG_ALERT_REPETITION");
604                                 }
605                                 break;
606
607                         case ID_ITEM_NOTIFICATION_EMAIL_ALERT:
608                                 {
609                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_EMAIL_ALERT");
610                                 }
611                                 break;
612
613                         case ID_ITEM_NOTIFICATION_EMAIL_ALERT_REPETITION:
614                                 {
615                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_EMAIL_ALERT_REPETITION");
616                                 }
617                                 break;
618
619                         default:
620                                 break;
621                         }
622
623                         pLabel = new (std::nothrow) Label();
624                         pLabel->Construct(itemMainRectangle, itemMainText);
625                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
626                         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
627                         pLabel->SetTextColor(COLOR_MAIN_TEXT);
628
629                         pItem->AddControl(pLabel);
630                 }
631         }
632
633         if (groupIndex == ID_GROUP3)
634         {
635                 RelativeLayout relativeLayout;
636                 relativeLayout.Construct();
637
638                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
639                 {
640                         pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM_DEFAULT_SLIDER), style);
641                 }
642                 else
643                 {
644                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
645                         pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
646                 }
647
648                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
649
650                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
651                 {
652                         switch (itemIndex)
653                         {
654                         case ID_ITEM_VIBRATION_NOTIFICATION:
655                                 {
656                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_NOTIFICATION");
657                                 }
658                                 break;
659
660                         case ID_ITEM_VIBRATION_HAPTIC_FEEDBACK:
661                                 {
662                                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SOUNDFEEDBACK_HAPTIC_FEEDBACK");
663                                 }
664                                 break;
665
666                         default:
667                                 break;
668                         }
669
670                         String sliderItemName;
671                         sliderItemName.Format(STRING_SIZE_LIMIT, L"vibrationItem_%d", itemIndex);
672
673                         pSlider = new (std::nothrow) Slider();
674
675                         pSlider->Construct(itemSliderRectangle, BACKGROUND_STYLE_NONE, true, GROUP_ITEM_SLIDER_MIN_VALUE, GROUP_ITEM_SLIDER_MAX_VALUE);
676                         pSlider->SetTitleText(itemMainText);
677                         pSlider->SetValue(GROUP_ITEM_SLIDER_DEFAULT_VALUE);
678
679                         pBitmapSoundMin = ResourceManager::GetBitmapN(IDB_VIBRATION_MIN);
680                         pBitmapSoundMax = ResourceManager::GetBitmapN(IDB_VIBRATION_MAX);
681
682                         pSlider->SetIcon(ICON_POSITION_LEFT, *pBitmapSoundMin);
683                         pSlider->SetIcon(ICON_POSITION_RIGHT, *pBitmapSoundMax);
684                         pSlider->AddAdjustmentEventListener(*this);
685                         pSlider->AddSliderEventListener(*this);
686                         pSlider->SetName(sliderItemName);
687
688                         delete pBitmapSoundMin;
689                         delete pBitmapSoundMax;
690
691                         pItem->AddControl(pSlider);
692                         pItem->SetIndividualSelectionEnabled(pSlider, true);
693
694                         relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
695                         relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
696
697                         __pTableView->SetItemEnabled(groupIndex, itemIndex, false);
698                 }
699                 else
700                 {
701                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SCREEN_LOCK_SOUND");
702                         pLabel = new (std::nothrow) Label();
703                         pLabel->Construct(itemMainRectangle, itemMainText);
704                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
705                         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
706                         pLabel->SetTextColor(COLOR_MAIN_TEXT);
707
708                         pItem->AddControl(pLabel);
709                 }
710         }
711
712         if (pLabel != null)
713         {
714                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
715                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
716         }
717
718         return pItem;
719 }
720
721 bool
722 SoundsForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
723 {
724         AppLogDebug("ENTER");
725
726         delete pItem;
727         pItem = null;
728
729         return true;
730 }
731
732 bool
733 SoundsForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
734 {
735         AppLogDebug("ENTER");
736
737         delete pItem;
738         pItem = null;
739
740         return true;
741 }
742
743 void
744 SoundsForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
745 {
746         #if 0 // Not supported by platform
747         PlaySound();
748         #endif
749         AppLogDebug("Group(%d) index(%d)", groupIndex, itemIndex);
750         bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
751
752         if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
753         {
754                 switch (groupIndex)
755                 {
756                 case ID_GROUP_MAIN:
757                         {
758                                 switch (itemIndex)
759                                 {
760                                 case ID_ITEM_MAIN_VOLUME:
761                                         {
762                                                 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
763                                                 {
764                                                         itemSelectStatus = !itemSelectStatus;
765                                                 }
766
767                                                 if (SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, !itemSelectStatus) == E_SUCCESS)
768                                                 {
769                                                         tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
770                                                         tableView.SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX1, itemSelectStatus);
771                                                         tableView.SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX2, itemSelectStatus);
772                                                         tableView.SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX3, itemSelectStatus);
773                                                         __pTableView->RefreshAllItems();
774                                                 }
775                                                 else
776                                                 {
777                                                         AppLogDebug("GetValue ID_GROUP_USE_PACKET_DATA [%s]", GetErrorMessage(GetLastResult()));
778                                                 }
779                                         }
780                                         break;
781
782                                 default:
783                                         {
784                                                 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
785                                                 {
786                                                         itemSelectStatus = ((itemSelectStatus == true) ? (false) : (true));
787                                                 }
788
789                                                 if (SettingInfo::SetValue(SETTING_INFO_KEY_VIBRATOR, itemSelectStatus) == E_SUCCESS)
790                                                 {
791                                                         AppLogDebug("Construct fail(%s)", GetErrorMessage(GetLastResult()));
792
793                                                         tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
794                                                 }
795                                                 else
796                                                 {
797                                                         AppLogDebug("Construct fail(%s)", GetErrorMessage(GetLastResult()));
798                                                 }
799                                         }
800                                         break;
801                                 }
802                         }
803                         break;
804
805                 default:
806                         break;
807                 }
808         }
809         else
810         {
811                 switch (groupIndex)
812                 {
813                 case ID_GROUP_INCOMMING_CALL:
814                         {
815                                 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
816
817                                 if (itemIndex == ID_ITEM_INCOMMING_CALL_RINGTONE)
818                                 {
819                                         // Empty statement
820                                 }
821                                 if (itemIndex == ID_ITEM_INCOMMING_CALL_VIBRATION)
822                                 {
823                                         // Empty statement
824                                 }
825                         }
826                         break;
827
828                 case ID_GROUP_NOTIFICATION:
829                         {
830                                 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
831
832                                 if (itemIndex == ID_ITEM_NOTIFICATION_MESSAGE_ALERT)
833                                 {
834                                         // Empty statement
835                                 }
836                                 if (itemIndex == ID_ITEM_NOTIFICATION_MESSAGE_ALERT_REPETITION)
837                                 {
838                                         // Empty statement
839                                 }
840                                 if (itemIndex == ID_ITEM_NOTIFICATION_EMAIL_ALERT)
841                                 {
842                                         // Empty statement
843                                 }
844                                 if (itemIndex == ID_ITEM_NOTIFICATION_EMAIL_ALERT_REPETITION)
845                                 {
846                                         // Empty statement
847                                 }
848                         }
849                         break;
850
851                 case ID_GROUP_SCREEN_LOCK_SOUND:
852                         {
853                                 // TODO: change Lock Sound Value.
854                                 // Empty statement
855                         }
856                         break;
857
858                 default:
859                         break;
860                 }
861         }
862 }
863
864 void
865 SoundsForm::OnActionPerformed(const Control& source, int actionId)
866 {
867         switch (actionId)
868         {
869         case IDA_HEADER_VOLUME:
870                 {
871                         AppLogDebug("IDA_HEADER_VOLUME Page Selected");
872                         __currentTableViewList = ID_SOUND_VOLUME_PAGE;
873                 }
874                 break;
875
876         case IDA_HEADER_RINGTONE:
877                 {
878                         AppLogDebug("IDA_HEADER_RINGTONE Page Selected");
879                         __currentTableViewList = ID_SOUND_RINGTONE_PAGE;
880                 }
881                 break;
882
883         default:
884                 break;
885         }
886         __pTableView->UpdateTableView();
887 }
888
889 void
890 SoundsForm::OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment)
891 {
892         String sourceName(source.GetName());
893         result r = E_SUCCESS;
894
895         if (sourceName == L"volumeItem_0")
896         {
897                 r = SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_NOTIFICATION_VOLUME, adjustment);
898                 #if 0 // Not supported by platform
899                 __notificationVolume = adjustment;
900                 PlaySound(ID_ITEM_VOLUME_NOTIFICATION);
901                 #endif
902         }
903         else if (sourceName == L"volumeItem_1")
904         {
905                 #if 1
906                 r = SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, adjustment);
907                 #else // Not supported by platform
908                 __mediaVolume = adjustment;
909                 PlaySound(ID_ITEM_VOLUME_MEDIA);
910                 #endif
911         }
912         else if (sourceName == L"volumeItem_2")
913         {
914                 #if 1
915                 r = SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, adjustment);
916                 #else // Not supported by platform
917                 __systemVolume = adjustment;
918                 PlaySound();
919                 #endif
920         }
921         else if (sourceName == L"volumeItem_3")
922         {
923         }
924         else if (sourceName == L"vibrationItem_0")
925         {
926                 // TODO: Notification Vibration Control.
927         }
928         else if (sourceName == L"vibrationItem_1")
929         {
930                 // TODO: Haptic feedback Vibration Control.
931         }
932
933         if (IsFailed(r))
934         {
935                 AppLogDebug("Set volume fail... - %s", GetErrorMessage(r));
936         }
937
938         AppLogDebug("control by name[%ls]", sourceName.GetPointer());
939 }
940
941 void 
942 SoundsForm::GroupItemEnable(int itemIndex, bool enableStatus)
943 {
944         int itemCount = 0;
945         int count = 0;
946         int localGroup = 0;
947         int localItem = 0;
948
949         if (enableStatus == true)
950         {
951                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
952                 {
953                         if (itemIndex == ID_ITEM_MAIN_VOLUME)
954                         {
955                                 itemCount = __pTableView->GetItemCountAt(ID_GROUP_VOLUME);
956                                 for (count = 0; count < itemCount; count++)
957                                 {
958                                         localGroup = ID_GROUP_VOLUME;
959                                         localItem = count;
960
961                                         __pTableView->SetItemEnabled(localGroup, localItem, true);
962                                 }
963                         }
964                         else
965                         {
966                                 itemCount = __pTableView->GetItemCountAt(ID_GROUP_VIBRATION);
967                                 for (count = 0; count < itemCount; count++)
968                                 {
969                                         localGroup = ID_GROUP_VIBRATION;
970                                         localItem = count;
971
972                                         __pTableView->SetItemEnabled(localGroup, localItem, true);
973                                 }
974                         }
975                 }
976         }
977         else
978         {
979                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
980                 {
981                         if (itemIndex == ID_ITEM_MAIN_VOLUME)
982                         {
983                                 itemCount = __pTableView->GetItemCountAt(ID_GROUP_VOLUME);
984                                 for (count = 0; count < itemCount; count++)
985                                 {
986                                         localGroup = ID_GROUP_VOLUME;
987                                         localItem = count;
988
989                                         __pTableView->SetItemEnabled(localGroup, localItem, false);
990                                 }
991                         }
992                         else
993                         {
994                                 itemCount = __pTableView->GetItemCountAt(ID_GROUP_VIBRATION);
995                                 for (count = 0; count < itemCount; count++)
996                                 {
997                                         localGroup = ID_GROUP_VIBRATION;
998                                         localItem = count;
999
1000                                         __pTableView->SetItemEnabled(localGroup, localItem, false);
1001                                 }
1002                         }
1003                 }
1004         }
1005 }
1006
1007 int
1008 SoundsForm::GetDefaultGroupItemHeight(void)
1009 {
1010         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1011 }
1012
1013 int
1014 SoundsForm::GetDefaultItemHeight(void)
1015 {
1016         return H_GROUP_ITEM_DEFAULT;
1017 }
1018
1019 void
1020 SoundsForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1021 {
1022 }
1023
1024 void
1025 SoundsForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1026 {
1027         AppLogDebug("ENTER %d %d", groupIndex, itemIndex);
1028         bool slientMode = false;
1029         Rectangle itemMainRectangle;
1030         Rectangle itemSliderRectangle;
1031         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
1032         Bitmap* pBitmapSoundMin = null;
1033         Bitmap* pBitmapSoundMax = null;
1034         String itemMainText;
1035
1036
1037         ItemTypeOneLine(itemMainRectangle);
1038
1039         if (groupIndex == ID_GROUP1)
1040         {
1041                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
1042                 {
1043                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
1044                 }
1045
1046                 RelativeLayout relativeLayout;
1047                 relativeLayout.Construct();
1048
1049                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1050
1051                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
1052                 {
1053                         switch (itemIndex)
1054                         {
1055                         case ID_ITEM_MAIN_VOLUME:
1056                         {
1057                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SOUNDS");
1058
1059                                 if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, slientMode) == E_SUCCESS)
1060                                 {
1061                                         AppLog("slientMode = %d", slientMode);
1062                                         if (slientMode == false)
1063                                         {
1064                                                 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1065                                         }
1066                                         else
1067                                         {
1068                                                 __pTableView->SetItemChecked(groupIndex, itemIndex, false);
1069                                         }
1070                                         Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
1071                                         pLabel->Invalidate(false);
1072                                 }
1073                                 else
1074                                 {
1075                                         AppLogDebug("GetValue fail(%s)", GetErrorMessage(GetLastResult()));
1076                                 }
1077                                 GroupItemEnable(itemIndex, slientMode);
1078                         }
1079                         break;
1080
1081                         case ID_ITEM_MAIN_VIBRATION:
1082                         {
1083                                 bool vibratorStatus = false;
1084                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_CALLALERTTYPE_VIBRATION");
1085
1086                                 if (SettingInfo::GetValue(SETTING_INFO_KEY_VIBRATOR, vibratorStatus) == E_SUCCESS)
1087                                 {
1088                                         __pTableView->SetItemChecked(groupIndex, itemIndex, vibratorStatus);
1089                                 }
1090                                 else
1091                                 {
1092                                         AppLogDebug("GetValue fail(%s)", GetErrorMessage(GetLastResult()));
1093                                 }
1094                         }
1095                         break;
1096
1097                         default:
1098                                 break;
1099                         }
1100                         pItem->Invalidate(false);
1101
1102                 }
1103         }
1104
1105         else if (groupIndex == ID_GROUP2)
1106         {
1107                 AppLogDebug("ENTER");
1108                 RelativeLayout relativeLayout;
1109                 relativeLayout.Construct();
1110
1111                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1112
1113                 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
1114                 {
1115                         AppLogDebug("ENTER");
1116                         result r = E_SUCCESS;
1117                         int volume = 0;
1118                         String sliderItemName;
1119                         sliderItemName.Format(STRING_SIZE_LIMIT, L"volumeItem_%d", itemIndex);
1120                         Slider* pSlider = static_cast<Slider*>(pItem->GetControl(SOUND_FORM_FIRST_CONTROL));
1121                         if (itemIndex == ID_ITEM_VOLUME_SYSTEM)
1122                         {
1123                                 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_SYSTEM"));
1124                                 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, volume);
1125                         }
1126                         else if (itemIndex == ID_ITEM_VOLUME_MEDIA)
1127                         {
1128                                 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_MEDIA"));
1129                                 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, volume);
1130                         }
1131                         else if (itemIndex == ID_ITEM_VOLUME_NOTIFICATION)
1132                         {
1133                                 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_NOTIFICATION"));
1134                                 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_NOTIFICATION_VOLUME, volume);
1135                         }
1136
1137                         if (IsFailed(r))
1138                         {
1139                                 AppLogDebug("Get volume fail... - %s", GetErrorMessage(r));
1140                                 pSlider->SetValue(GROUP_ITEM_SLIDER_DEFAULT_VALUE);
1141                         }
1142                         else
1143                         {
1144                                 pSlider->SetValue(volume);
1145                         }
1146
1147                         pBitmapSoundMin = ResourceManager::GetBitmapN(IDB_SOUND_MIN);
1148                         pBitmapSoundMax = ResourceManager::GetBitmapN(IDB_SOUND_MAX);
1149
1150                         pSlider->SetIcon(ICON_POSITION_LEFT, *pBitmapSoundMin);
1151                         pSlider->SetIcon(ICON_POSITION_RIGHT, *pBitmapSoundMax);
1152                         pSlider->SetName(sliderItemName);
1153
1154                         delete pBitmapSoundMin;
1155                         delete pBitmapSoundMax;
1156                         pSlider->Invalidate(false);
1157                         pItem->SetIndividualSelectionEnabled(pSlider, true);
1158                         pItem->Invalidate(false);
1159                         relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
1160                         relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
1161                 }
1162         }
1163         Invalidate(true);
1164 }
1165
1166 void
1167 SoundsForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1168 {
1169 }
1170
1171 void
1172 SoundsForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1173 {
1174 }
1175
1176 void
1177 SoundsForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1178 {
1179         if (requestId == REFRESH_REQUEST_EVENT)
1180         {
1181                 if (__pTableView)
1182                 {
1183                         __pTableView->UpdateTableView();
1184                         bool itemStatus = false;
1185
1186                         if (SettingInfo::GetValue(SETTING_INFO_KEY_VIBRATOR, itemStatus) == E_SUCCESS)
1187                         {
1188                                 __pTableView->SetItemChecked(ID_GROUP1, ID_ITEM_MAIN_VIBRATION, itemStatus);
1189                         }
1190                         if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, itemStatus) == E_SUCCESS)
1191                         {
1192                                 if (itemStatus == true)
1193                                 {
1194                                         __pTableView->SetItemChecked(ID_GROUP1, ID_ITEM_MAIN_VOLUME, false);
1195                                         __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX1, false);
1196                                         __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX2, false);
1197                                         __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX3, false);
1198                                 }
1199                                 else
1200                                 {
1201                                         __pTableView->SetItemChecked(ID_GROUP1, ID_ITEM_MAIN_VOLUME, true);
1202                                         __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX1, true);
1203                                         __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX2, true);
1204                                         __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX3, true);
1205                                 }
1206                         }
1207                 }
1208                 if (pArgs)
1209                 {
1210                         pArgs->RemoveAll(true);
1211                         delete pArgs;
1212                 }
1213         }
1214 }
1215
1216 void
1217 SoundsForm::OnFocusGained(const Tizen::Ui::Control& source)
1218 {
1219 #if 0 // Not supported by platform
1220         SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_NOTIFICATION_VOLUME, __notificationVolume);
1221         SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, __mediaVolume);
1222         SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, __systemVolume);
1223
1224         SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, 15);
1225         SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, 0);
1226 #endif
1227 }
1228
1229 void
1230 SoundsForm::OnFocusLost(const Tizen::Ui::Control& source)
1231 {
1232 #if 0 // Not supported by platform
1233         SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, __mediaVolume);
1234         SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, __systemVolume);
1235 #endif
1236 }
1237
1238 void
1239 SoundsForm::PlaySound(int type)
1240 {
1241 #if 0 // Not supported by platform
1242         String filePath;
1243         int adjustment;
1244
1245         if (type == ID_ITEM_VOLUME_NOTIFICATION)
1246         {
1247                 filePath = L"/opt/share/settings/Alerts/General notification_sdk.wav";
1248                 adjustment = __notificationVolume;
1249         }
1250         else if (type == ID_ITEM_VOLUME_MEDIA)
1251         {
1252                 filePath = L"/opt/share/settings/Ringtones/ringtone_sdk.mp3";
1253                 adjustment = __mediaVolume;
1254         }
1255         else
1256         {
1257                 filePath = L"/opt/share/svi/sound/touch/touch.wav";
1258                 adjustment = __systemVolume;
1259         }
1260
1261         result r= E_SUCCESS;
1262         if (__pSoundPlay == null)
1263         {
1264                 return;
1265         }
1266         PlayerState estate = __pSoundPlay->GetState();
1267         if ((estate == PLAYER_STATE_PAUSED)
1268                 || (estate == PLAYER_STATE_PLAYING) || (estate == PLAYER_STATE_ENDOFCLIP))
1269         {
1270                 if (__pSoundPlay != null)
1271                 {
1272                         delete __pSoundPlay;
1273                         __pSoundPlay = null;
1274                 }
1275                 __pSoundPlay = new (std::nothrow) Player();
1276                 __pSoundPlay->Construct(*this);
1277         }
1278
1279         r = __pSoundPlay->OpenFile(filePath, false);
1280         if (IsFailed(r))
1281         {
1282                 AppLog("%s", GetErrorMessage(r));
1283                 return;
1284         }
1285
1286         int volume = adjustment * 100.0 / 15.0;
1287         if (volume)
1288         {
1289                 __pSoundPlay->SetVolume(volume);
1290                 __pSoundPlay->Play();
1291         }
1292         __pSoundPlay->Close();
1293 #endif
1294 }
1295
1296 void
1297 SoundsForm::OnSettingChanged(String& key)
1298 {
1299         AppLogDebug("ENTER");
1300         AppLogDebug("SETTING KEY: %S", key.GetPointer());
1301         if (key.CompareTo(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME) == 0)
1302         {
1303                 __pTableView->RefreshItem(ID_GROUP2, ID_GROUP2_INDEX2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1304         }
1305         else if (key.CompareTo(SETTING_INFO_KEY_SOUND_SILENTMODE) == 0)
1306         {
1307                 bool silentMode;
1308                 if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, silentMode) != E_SUCCESS)
1309                 {
1310                         AppLogDebug("GetValue Failed");
1311                 }
1312                 AppLogDebug("Silent Mode: %d", silentMode);
1313                 __pTableView->SetItemChecked(ID_GROUP1, ID_ITEM_MAIN_VOLUME, !silentMode);
1314                 __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX1, !silentMode);
1315                 __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX2, !silentMode);
1316                 __pTableView->SetItemEnabled(ID_GROUP2, ID_GROUP2_INDEX3, !silentMode);
1317         }
1318         AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
1319         Invalidate(true);
1320         return;
1321 }