2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file StSoundsForm.cpp
19 * @brief This is the implementation file for SoundsForm class.
22 #include "StResourceManager.h"
23 #include "StSoundsForm.h"
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;
35 static const int IDA_HEADER_VOLUME = 100;
36 static const int IDA_HEADER_RINGTONE = 101;
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;
43 static const int ID_GROUP_VOLUME = 1;
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;
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;
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;
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;
65 static const int ID_GROUP_SCREEN_LOCK_SOUND = 2;
66 static const int ID_GROUP_SCREEN_LOCK_SOUND_ITEM_COUNT = 1;
68 static const int ID_VOLUME_PAGE_GROUP_COUNT = 2;
69 static const int ID_RINGTONE_PAGE_GROUP_COUNT = 3;
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;
76 static const int ID_GROUP2_INDEX1 = 0;
77 static const int ID_GROUP2_INDEX2 = 1;
78 static const int ID_GROUP2_INDEX3 = 2;
80 static const int ID_SOUND_VOLUME_PAGE = 1;
81 static const int ID_SOUND_RINGTONE_PAGE = 2;
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;
87 static const int STRING_SIZE_LIMIT = 20;
89 static const int SOUND_FORM_FIRST_CONTROL = 0;
91 SoundsForm::SoundsForm(void)
92 : __currentTableViewList(ID_SOUND_VOLUME_PAGE)
94 , __notificationVolume(0)
100 SoundsForm::~SoundsForm(void)
105 SoundsForm::CreateHeader(void)
107 Header* pHeader = GetHeader();
109 pHeader->SetStyle(HEADER_STYLE_TAB);
111 HeaderItem headerItemVolume;
112 headerItemVolume.Construct(IDA_HEADER_VOLUME);
113 headerItemVolume.SetText(ResourceManager::GetString(L"IDS_ST_BODY_VOLUME"));
115 pHeader->AddItem(headerItemVolume);
116 pHeader->AddActionEventListener(*this);
120 SoundsForm::CreateFooter(void)
122 Footer* pFooter = GetFooter();
125 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
126 pFooter->AddActionEventListener(*this);
128 SetFormBackEventListener(this);
132 SoundsForm::OnInitializing(void)
134 BaseForm::CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_SOUNDS"));
136 SettingInfo::AddSettingEventListener(*this);
137 #if 0 // Not supported by platform
138 result r = E_SUCCESS;
140 AddFocusEventListener(*this);
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);
146 SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, 15);
147 SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, 0);
149 __pSoundPlay = new (std::nothrow) Player();
150 r = __pSoundPlay->Construct(*this);
153 AppLogDebug("Construct fail(%s)", GetErrorMessage(r));
160 SoundsForm::OnTerminating(void)
162 #if 0 // Not supported by platform
163 if (__pSoundPlay != null)
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))
170 __pSoundPlay->Stop();
171 __pSoundPlay->Close();
176 SettingInfo::RemoveSettingEventListener(*this);
177 SetFormBackEventListener(null);
182 SoundsForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
184 bool itemStatus = false;
186 __pTableView->UpdateTableView();
188 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
190 if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, itemStatus) == E_SUCCESS)
192 if (itemStatus == false)
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);
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);
210 SoundsForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
215 SoundsForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
217 #if 0 // Not supported by platform
220 SceneManager* pSceneManager = SceneManager::GetInstance();
221 AppAssert(pSceneManager);
223 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
227 SoundsForm::GetGroupCount(void)
229 AppLogDebug("ENTER");
230 return ((__currentTableViewList == ID_SOUND_VOLUME_PAGE) ? (ID_VOLUME_PAGE_GROUP_COUNT) : (ID_RINGTONE_PAGE_GROUP_COUNT));
234 SoundsForm::GetItemCount(int groupIndex)
236 AppLogDebug("ENTER");
244 itemCount = ID_GROUP_MAIN_ITEM_COUNT;
250 itemCount = ID_GROUP_VOLUME_ITEM_COUNT;
256 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
258 itemCount = ID_GROUP_VIBRATION_ITEM_COUNT;
262 itemCount = ID_GROUP_SCREEN_LOCK_SOUND_ITEM_COUNT;
275 SoundsForm::CreateGroupItem(int groupIndex, int itemWidth)
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;
283 Label* pLabel = null;
285 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
291 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
293 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
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");
303 yItemOffset = H_GROUP_INDEX_TITLE_TEXT;
309 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
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");
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");
323 yItemOffset = H_GROUP_INDEX_TITLE_TEXT;
329 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
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");
338 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
340 yItemOffset = H_GROUP_INDEX_TITLE_TEXT;
346 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
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);
355 yItemOffset = H_GROUP_INDEX_TITLE_TEXT;
356 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
365 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
366 itemMainRectangle.y = yItemOffset;
367 itemMainRectangle.width = itemWidth;
368 itemMainRectangle.height = itemHeight;
370 RelativeLayout relativeLayout;
371 relativeLayout.Construct();
373 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
374 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
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);
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);
393 SoundsForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
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;
403 Slider* pSlider = null;
405 int fontSize = GetFontSize();
407 TableViewItem* pItem = new (std::nothrow) TableViewItem();
409 ItemTypeOneLine(itemMainRectangle);
411 itemSliderRectangle.x = 0;
412 itemSliderRectangle.y = Y_GROUP_ITEM_DEFAULT_LABEL;
413 itemSliderRectangle.width = itemWidth;
414 itemSliderRectangle.height = H_GROUP_ITEM_DEFAULT_SLIDER;
416 if (groupIndex == ID_GROUP1)
418 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
420 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
423 RelativeLayout relativeLayout;
424 relativeLayout.Construct();
426 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
427 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
429 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
433 case ID_ITEM_MAIN_VOLUME:
435 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SOUNDS");
437 if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, slientMode) == E_SUCCESS)
439 if (slientMode == false)
441 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
446 AppLogDebug("Construct fail(%s)", GetErrorMessage(GetLastResult()));
448 GroupItemEnable(itemIndex, slientMode);
452 case ID_ITEM_MAIN_VIBRATION:
454 bool vibratorStatus = false;
455 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_CALLALERTTYPE_VIBRATION");
457 if (SettingInfo::GetValue(SETTING_INFO_KEY_VIBRATOR, vibratorStatus) == E_SUCCESS)
459 __pTableView->SetItemChecked(groupIndex, itemIndex, vibratorStatus);
463 AppLogDebug("Construct fail(%s)", GetErrorMessage(GetLastResult()));
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);
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);
487 case ID_ITEM_INCOMMING_CALL_RINGTONE:
489 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_INCOMING_CALL_RINGTONE");
493 case ID_ITEM_INCOMMING_CALL_VIBRATION:
495 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_INCOMING_CALL_VIBRATION");
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);
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);
516 if (groupIndex == ID_GROUP2)
518 RelativeLayout relativeLayout;
519 relativeLayout.Construct();
521 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
523 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT_SLIDER), style);
527 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
530 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
532 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
534 result r = E_SUCCESS;
536 String sliderItemName;
537 sliderItemName.Format(STRING_SIZE_LIMIT, L"volumeItem_%d", itemIndex);
539 pSlider = new (std::nothrow) Slider();
541 pSlider->Construct(itemSliderRectangle, BACKGROUND_STYLE_NONE, true, GROUP_ITEM_SLIDER_MIN_VALUE, GROUP_ITEM_SLIDER_MAX_VALUE);
543 if (itemIndex == ID_ITEM_VOLUME_SYSTEM)
545 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_SYSTEM"));
546 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, volume);
548 else if (itemIndex == ID_ITEM_VOLUME_MEDIA)
550 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_MEDIA"));
551 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, volume);
553 else if (itemIndex == ID_ITEM_VOLUME_NOTIFICATION)
555 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_NOTIFICATION"));
556 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_NOTIFICATION_VOLUME, volume);
561 AppLogDebug("Get volume fail... - %s", GetErrorMessage(r));
562 pSlider->SetValue(GROUP_ITEM_SLIDER_DEFAULT_VALUE);
566 pSlider->SetValue(volume);
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));
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);
582 delete pBitmapSoundMin;
583 delete pBitmapSoundMax;
585 pItem->AddControl(pSlider);
586 pItem->SetIndividualSelectionEnabled(pSlider, true);
588 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
589 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
595 case ID_ITEM_NOTIFICATION_MESSAGE_ALERT:
597 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MESSAGE_ALERT");
601 case ID_ITEM_NOTIFICATION_MESSAGE_ALERT_REPETITION:
603 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MSG_ALERT_REPETITION");
607 case ID_ITEM_NOTIFICATION_EMAIL_ALERT:
609 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_EMAIL_ALERT");
613 case ID_ITEM_NOTIFICATION_EMAIL_ALERT_REPETITION:
615 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_EMAIL_ALERT_REPETITION");
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);
629 pItem->AddControl(pLabel);
633 if (groupIndex == ID_GROUP3)
635 RelativeLayout relativeLayout;
636 relativeLayout.Construct();
638 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
640 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM_DEFAULT_SLIDER), style);
644 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
645 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
648 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
650 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
654 case ID_ITEM_VIBRATION_NOTIFICATION:
656 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_NOTIFICATION");
660 case ID_ITEM_VIBRATION_HAPTIC_FEEDBACK:
662 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SOUNDFEEDBACK_HAPTIC_FEEDBACK");
670 String sliderItemName;
671 sliderItemName.Format(STRING_SIZE_LIMIT, L"vibrationItem_%d", itemIndex);
673 pSlider = new (std::nothrow) Slider();
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);
679 pBitmapSoundMin = ResourceManager::GetBitmapN(IDB_VIBRATION_MIN);
680 pBitmapSoundMax = ResourceManager::GetBitmapN(IDB_VIBRATION_MAX);
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);
688 delete pBitmapSoundMin;
689 delete pBitmapSoundMax;
691 pItem->AddControl(pSlider);
692 pItem->SetIndividualSelectionEnabled(pSlider, true);
694 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
695 relativeLayout.SetRelation(*pSlider, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
697 __pTableView->SetItemEnabled(groupIndex, itemIndex, false);
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);
708 pItem->AddControl(pLabel);
714 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
715 pLabel->SetTextColor(COLOR_MAIN_TEXT);
722 SoundsForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
724 AppLogDebug("ENTER");
733 SoundsForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
735 AppLogDebug("ENTER");
744 SoundsForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
746 #if 0 // Not supported by platform
749 AppLogDebug("Group(%d) index(%d)", groupIndex, itemIndex);
750 bool itemSelectStatus = tableView.IsItemChecked(groupIndex, itemIndex);
752 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
760 case ID_ITEM_MAIN_VOLUME:
762 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
764 itemSelectStatus = !itemSelectStatus;
767 if (SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, !itemSelectStatus) == E_SUCCESS)
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();
777 AppLogDebug("GetValue ID_GROUP_USE_PACKET_DATA [%s]", GetErrorMessage(GetLastResult()));
784 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
786 itemSelectStatus = ((itemSelectStatus == true) ? (false) : (true));
789 if (SettingInfo::SetValue(SETTING_INFO_KEY_VIBRATOR, itemSelectStatus) == E_SUCCESS)
791 AppLogDebug("Construct fail(%s)", GetErrorMessage(GetLastResult()));
793 tableView.SetItemChecked(groupIndex, itemIndex, itemSelectStatus);
797 AppLogDebug("Construct fail(%s)", GetErrorMessage(GetLastResult()));
813 case ID_GROUP_INCOMMING_CALL:
815 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
817 if (itemIndex == ID_ITEM_INCOMMING_CALL_RINGTONE)
821 if (itemIndex == ID_ITEM_INCOMMING_CALL_VIBRATION)
828 case ID_GROUP_NOTIFICATION:
830 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
832 if (itemIndex == ID_ITEM_NOTIFICATION_MESSAGE_ALERT)
836 if (itemIndex == ID_ITEM_NOTIFICATION_MESSAGE_ALERT_REPETITION)
840 if (itemIndex == ID_ITEM_NOTIFICATION_EMAIL_ALERT)
844 if (itemIndex == ID_ITEM_NOTIFICATION_EMAIL_ALERT_REPETITION)
851 case ID_GROUP_SCREEN_LOCK_SOUND:
853 // TODO: change Lock Sound Value.
865 SoundsForm::OnActionPerformed(const Control& source, int actionId)
869 case IDA_HEADER_VOLUME:
871 AppLogDebug("IDA_HEADER_VOLUME Page Selected");
872 __currentTableViewList = ID_SOUND_VOLUME_PAGE;
876 case IDA_HEADER_RINGTONE:
878 AppLogDebug("IDA_HEADER_RINGTONE Page Selected");
879 __currentTableViewList = ID_SOUND_RINGTONE_PAGE;
886 __pTableView->UpdateTableView();
890 SoundsForm::OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment)
892 String sourceName(source.GetName());
893 result r = E_SUCCESS;
895 if (sourceName == L"volumeItem_0")
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);
903 else if (sourceName == L"volumeItem_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);
912 else if (sourceName == L"volumeItem_2")
915 r = SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, adjustment);
916 #else // Not supported by platform
917 __systemVolume = adjustment;
921 else if (sourceName == L"volumeItem_3")
924 else if (sourceName == L"vibrationItem_0")
926 // TODO: Notification Vibration Control.
928 else if (sourceName == L"vibrationItem_1")
930 // TODO: Haptic feedback Vibration Control.
935 AppLogDebug("Set volume fail... - %s", GetErrorMessage(r));
938 AppLogDebug("control by name[%ls]", sourceName.GetPointer());
942 SoundsForm::GroupItemEnable(int itemIndex, bool enableStatus)
949 if (enableStatus == true)
951 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
953 if (itemIndex == ID_ITEM_MAIN_VOLUME)
955 itemCount = __pTableView->GetItemCountAt(ID_GROUP_VOLUME);
956 for (count = 0; count < itemCount; count++)
958 localGroup = ID_GROUP_VOLUME;
961 __pTableView->SetItemEnabled(localGroup, localItem, true);
966 itemCount = __pTableView->GetItemCountAt(ID_GROUP_VIBRATION);
967 for (count = 0; count < itemCount; count++)
969 localGroup = ID_GROUP_VIBRATION;
972 __pTableView->SetItemEnabled(localGroup, localItem, true);
979 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
981 if (itemIndex == ID_ITEM_MAIN_VOLUME)
983 itemCount = __pTableView->GetItemCountAt(ID_GROUP_VOLUME);
984 for (count = 0; count < itemCount; count++)
986 localGroup = ID_GROUP_VOLUME;
989 __pTableView->SetItemEnabled(localGroup, localItem, false);
994 itemCount = __pTableView->GetItemCountAt(ID_GROUP_VIBRATION);
995 for (count = 0; count < itemCount; count++)
997 localGroup = ID_GROUP_VIBRATION;
1000 __pTableView->SetItemEnabled(localGroup, localItem, false);
1008 SoundsForm::GetDefaultGroupItemHeight(void)
1010 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1014 SoundsForm::GetDefaultItemHeight(void)
1016 return H_GROUP_ITEM_DEFAULT;
1020 SoundsForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1025 SoundsForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
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;
1037 ItemTypeOneLine(itemMainRectangle);
1039 if (groupIndex == ID_GROUP1)
1041 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
1043 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
1046 RelativeLayout relativeLayout;
1047 relativeLayout.Construct();
1049 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1051 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
1055 case ID_ITEM_MAIN_VOLUME:
1057 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SOUNDS");
1059 if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, slientMode) == E_SUCCESS)
1061 AppLog("slientMode = %d", slientMode);
1062 if (slientMode == false)
1064 __pTableView->SetItemChecked(groupIndex, itemIndex, true);
1068 __pTableView->SetItemChecked(groupIndex, itemIndex, false);
1070 Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
1071 pLabel->Invalidate(false);
1075 AppLogDebug("GetValue fail(%s)", GetErrorMessage(GetLastResult()));
1077 GroupItemEnable(itemIndex, slientMode);
1081 case ID_ITEM_MAIN_VIBRATION:
1083 bool vibratorStatus = false;
1084 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_CALLALERTTYPE_VIBRATION");
1086 if (SettingInfo::GetValue(SETTING_INFO_KEY_VIBRATOR, vibratorStatus) == E_SUCCESS)
1088 __pTableView->SetItemChecked(groupIndex, itemIndex, vibratorStatus);
1092 AppLogDebug("GetValue fail(%s)", GetErrorMessage(GetLastResult()));
1100 pItem->Invalidate(false);
1105 else if (groupIndex == ID_GROUP2)
1107 AppLogDebug("ENTER");
1108 RelativeLayout relativeLayout;
1109 relativeLayout.Construct();
1111 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
1113 if (__currentTableViewList == ID_SOUND_VOLUME_PAGE)
1115 AppLogDebug("ENTER");
1116 result r = E_SUCCESS;
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)
1123 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_SYSTEM"));
1124 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, volume);
1126 else if (itemIndex == ID_ITEM_VOLUME_MEDIA)
1128 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_MEDIA"));
1129 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, volume);
1131 else if (itemIndex == ID_ITEM_VOLUME_NOTIFICATION)
1133 pSlider->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_NOTIFICATION"));
1134 r = SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_NOTIFICATION_VOLUME, volume);
1139 AppLogDebug("Get volume fail... - %s", GetErrorMessage(r));
1140 pSlider->SetValue(GROUP_ITEM_SLIDER_DEFAULT_VALUE);
1144 pSlider->SetValue(volume);
1147 pBitmapSoundMin = ResourceManager::GetBitmapN(IDB_SOUND_MIN);
1148 pBitmapSoundMax = ResourceManager::GetBitmapN(IDB_SOUND_MAX);
1150 pSlider->SetIcon(ICON_POSITION_LEFT, *pBitmapSoundMin);
1151 pSlider->SetIcon(ICON_POSITION_RIGHT, *pBitmapSoundMax);
1152 pSlider->SetName(sliderItemName);
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);
1167 SoundsForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1172 SoundsForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1177 SoundsForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1179 if (requestId == REFRESH_REQUEST_EVENT)
1183 __pTableView->UpdateTableView();
1184 bool itemStatus = false;
1186 if (SettingInfo::GetValue(SETTING_INFO_KEY_VIBRATOR, itemStatus) == E_SUCCESS)
1188 __pTableView->SetItemChecked(ID_GROUP1, ID_ITEM_MAIN_VIBRATION, itemStatus);
1190 if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, itemStatus) == E_SUCCESS)
1192 if (itemStatus == true)
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);
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);
1210 pArgs->RemoveAll(true);
1217 SoundsForm::OnFocusGained(const Tizen::Ui::Control& source)
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);
1224 SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME, 15);
1225 SettingInfo::SetValue(SETTING_INFO_KEY_SOUND_SYSTEM_VOLUME, 0);
1230 SoundsForm::OnFocusLost(const Tizen::Ui::Control& source)
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);
1239 SoundsForm::PlaySound(int type)
1241 #if 0 // Not supported by platform
1245 if (type == ID_ITEM_VOLUME_NOTIFICATION)
1247 filePath = L"/opt/share/settings/Alerts/General notification_sdk.wav";
1248 adjustment = __notificationVolume;
1250 else if (type == ID_ITEM_VOLUME_MEDIA)
1252 filePath = L"/opt/share/settings/Ringtones/ringtone_sdk.mp3";
1253 adjustment = __mediaVolume;
1257 filePath = L"/opt/share/svi/sound/touch/touch.wav";
1258 adjustment = __systemVolume;
1261 result r= E_SUCCESS;
1262 if (__pSoundPlay == null)
1266 PlayerState estate = __pSoundPlay->GetState();
1267 if ((estate == PLAYER_STATE_PAUSED)
1268 || (estate == PLAYER_STATE_PLAYING) || (estate == PLAYER_STATE_ENDOFCLIP))
1270 if (__pSoundPlay != null)
1272 delete __pSoundPlay;
1273 __pSoundPlay = null;
1275 __pSoundPlay = new (std::nothrow) Player();
1276 __pSoundPlay->Construct(*this);
1279 r = __pSoundPlay->OpenFile(filePath, false);
1282 AppLog("%s", GetErrorMessage(r));
1286 int volume = adjustment * 100.0 / 15.0;
1289 __pSoundPlay->SetVolume(volume);
1290 __pSoundPlay->Play();
1292 __pSoundPlay->Close();
1297 SoundsForm::OnSettingChanged(String& key)
1299 AppLogDebug("ENTER");
1300 AppLogDebug("SETTING KEY: %S", key.GetPointer());
1301 if (key.CompareTo(SETTING_INFO_KEY_SOUND_MEDIA_VOLUME) == 0)
1303 __pTableView->RefreshItem(ID_GROUP2, ID_GROUP2_INDEX2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1305 else if (key.CompareTo(SETTING_INFO_KEY_SOUND_SILENTMODE) == 0)
1308 if (SettingInfo::GetValue(SETTING_INFO_KEY_SOUND_SILENTMODE, silentMode) != E_SUCCESS)
1310 AppLogDebug("GetValue Failed");
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);
1318 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));