2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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 PhnSettingsCallForwardWaitBarrForm.cpp
19 * @brief Call setting tone form
22 #include "PhnAppUtility.h"
23 #include "PhnSettingsCallStatusTonesForm.h"
24 #include "PhnSettingsConstants.h"
25 #include "PhnSettingsPresentationModel.h"
26 #include "PhnSceneRegister.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
36 static const wchar_t* IDL_SETTINGS_STATUS_TONES_FORM = L"IDL_SETTINGS_STATUS_TONES_FORM";
38 SettingsCallStatusTonesForm::SettingsCallStatusTonesForm(void)
42 SettingsCallStatusTonesForm::~SettingsCallStatusTonesForm(void)
47 SettingsCallStatusTonesForm::Initialize(void)
49 Construct(IDL_SETTINGS_STATUS_TONES_FORM);
53 SettingsCallStatusTonesForm::OnInitializing(void)
57 __pSettingsPresentor = SettingsPresentationModel::GetInstance();
59 // Setup back event listener
60 SetFormBackEventListener(this);
62 Footer* pFooter = GetFooter();
65 pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, pFooter->GetColor());
66 pFooter->AddActionEventListener(*this);
69 //initialize table view
70 r = InitializeGroupedTableView();
76 SettingsCallStatusTonesForm::OnTerminating(void)
79 __pSettingsPresentor = null;
84 SettingsCallStatusTonesForm::OnActionPerformed(const Control& source, int actionId)
94 SettingsCallStatusTonesForm::OnFormBackRequested(Controls::Form& source)
96 SceneManager* pSceneManager = SceneManager::GetInstance();
97 AppAssert(pSceneManager != null);
98 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MORE_OPTIONS), null);
102 SettingsCallStatusTonesForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
107 SettingsCallStatusTonesForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
112 SettingsCallStatusTonesForm::InitializeGroupedTableView(void)
114 result r = E_FAILURE;
115 GroupedTableView* pStatusTonesTableView = static_cast<GroupedTableView*>(GetControl(IDC_GROUPEDTABLEVIEW));
116 if (pStatusTonesTableView != null)
118 pStatusTonesTableView->SetGroupedLookEnabled(true);
119 pStatusTonesTableView->SetItemProvider(this);
120 r = pStatusTonesTableView->AddGroupedTableViewItemEventListener(*this);
126 SettingsCallStatusTonesForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status)
128 bool activateState = false;
129 if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
131 activateState = true;
135 case GROUP_CALL_CONNECT:// for "CALLCONNECT_CONNECT_TONE" item
137 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
139 if (__pSettingsPresentor->GetCallConnectToneStatus() == true)
141 activateState = false;
145 activateState = true;
148 tableView.SetItemChecked(GROUP_CALL_CONNECT,CALLCONNECT_CONNECT_TONE,activateState);
149 __pSettingsPresentor->SetCallConnectToneStatus(activateState);
153 case GROUP_CALL_REMINDER:// for "CALLREMINDER_MINUTE_REMINDERS" item
155 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
157 if (__pSettingsPresentor->GetMinuteMinderToneStatus() == true)
159 activateState = false;
163 activateState = true;
166 tableView.SetItemChecked(GROUP_CALL_REMINDER,CALLREMINDER_MINUTE_REMINDERS,activateState);
167 __pSettingsPresentor->SetMinuteMinderToneStatus(activateState);
171 case GROUP_CALL_END:// for "CALLEND_END_TONE" item
173 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
175 if (__pSettingsPresentor->GetCallEndToneStatus() == true)
177 activateState = false;
181 activateState = true;
184 tableView.SetItemChecked(GROUP_CALL_END,CALLEND_END_TONE,activateState);
185 __pSettingsPresentor->SetCallEndToneStatus(activateState);
195 SettingsCallStatusTonesForm::GetGroupCount(void)
197 return GROUP_TOTALCOUNT;
201 SettingsCallStatusTonesForm::GetItemCount(int groupIndex)
206 case GROUP_CALL_CONNECT:
208 itemCount = CALLCONNECT_TOTALCOUNT;
212 case GROUP_CALL_REMINDER:
214 itemCount = CALLREMINDER_TOTALCOUNT;
220 itemCount = CALLEND_TOTALCOUNT;
224 case GROUP_CALL_CONNECT_HLPTXT:
225 case GROUP_CALL_REMINDER_HLPTXT:
226 case GROUP_CALL_END_HLPTXT:
239 SettingsCallStatusTonesForm::CreateGroupItem(int groupIndex, int itemWidth)
241 String helpText(L"");
242 int groupHeight = H_LIST_HIDDENGROUP_ITEM;
245 case GROUP_CALL_CONNECT_HLPTXT:
247 helpText.Append(AppUtility::GetResourceString(IDS_SETTING_CONNECTTONE_HLP_STRING));
248 groupHeight = H_LIST_MENU_TWOLINE_HLPTXT_ITEM;
252 case GROUP_CALL_REMINDER_HLPTXT:
254 helpText.Append(AppUtility::GetResourceString(IDS_SETTING_REMINDERS_HLP_STRING));
255 groupHeight = H_LIST_MENU_SINGLELINE_HLPTXT_ITEM;
259 case GROUP_CALL_END_HLPTXT:
261 helpText.Append(AppUtility::GetResourceString(IDS_SETTING_ENDTONE_HLP_STRING));
262 groupHeight = H_LIST_MENU_TWOLINE_HLPTXT_ITEM;
270 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
271 if (helpText.IsEmpty() == true)
273 pItem->Construct(Dimension(itemWidth, groupHeight));
274 pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG);
278 //help text item rectangle
279 Rectangle helpItemRect(X_LIST_MENU_HLPTXT_ITEM, 0, (itemWidth - X_LIST_MENU_HLPTXT_ITEM), groupHeight);
280 pItem->Construct(Dimension(itemWidth, groupHeight));
281 Label* pItemLbl = new (std::nothrow) Label();
282 pItemLbl->Construct(helpItemRect, helpText);
283 pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
284 pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
285 pItemLbl->SetTextConfig(FONT_SIZE_HELP_TXT, LABEL_TEXT_STYLE_NORMAL);
286 pItemLbl->SetTextColor(COLOR_HELP_TXT);
287 pItem->AddControl(*pItemLbl);
288 pItem->SetEnabled(false);
289 pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
290 pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
296 SettingsCallStatusTonesForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
304 SettingsCallStatusTonesForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem)
310 SettingsCallStatusTonesForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
312 GroupedTableView* pStatusTonesTableView = static_cast<GroupedTableView*>(GetControl(IDC_GROUPEDTABLEVIEW));
313 //text item rectangle
314 Rectangle itemRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM);
316 TableViewItem* pItem = new (std::nothrow) TableViewItem();
317 pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING);
319 //Set the item name and status for all menu items
320 String itemName(L"");
321 bool activateState = false;
324 case GROUP_CALL_CONNECT:// for "CALLCONNECT_CONNECT_TONE" item
326 itemName.Append(AppUtility::GetResourceString(IDS_SETTING_CONNECTTONE_STRING));
327 activateState = __pSettingsPresentor->GetCallConnectToneStatus();
331 case GROUP_CALL_REMINDER:// for "CALLREMINDER_MINUTE_REMINDERS" item
333 itemName.Append(AppUtility::GetResourceString(IDS_SETTING_REMINDERS_STRING));
334 activateState = __pSettingsPresentor->GetMinuteMinderToneStatus();
338 case GROUP_CALL_END:// for "CALLEND_END_TONE" item
340 itemName.Append(AppUtility::GetResourceString(IDS_SETTING_ENDTONE_STRING));
341 activateState = __pSettingsPresentor->GetCallEndToneStatus();
350 Label* pItemLbl = new (std::nothrow) Label();
351 pItemLbl->Construct(itemRect, itemName);
352 pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
353 pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
354 pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL);
355 pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT
356 pItem->AddControl(*pItemLbl);
357 pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
360 pStatusTonesTableView->SetItemChecked(groupIndex, itemIndex, activateState);
365 SettingsCallStatusTonesForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
373 SettingsCallStatusTonesForm::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem)
379 SettingsCallStatusTonesForm::GetDefaultGroupItemHeight(void)
381 return H_LIST_HIDDENGROUP_ITEM;
385 SettingsCallStatusTonesForm::GetDefaultItemHeight(void)
387 return H_LIST_NORMAL_MENU_ITEM;