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 PhnCallOptionPopup.cpp
19 * @brief Call Options Popup class
25 #include <FGraphics.h>
28 #include "PhnCallOptionPopup.h"
29 #include "PhnAppUtility.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Base::Utility;
34 using namespace Tizen::App;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Social;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
41 const int W_POPUP = 620;
42 const int H_POPUP = 712;
43 const int W_CANCEL_BUTTON = 400;
44 const int H_CANCEL_BUTTON = 72;
45 const int CANCEL_BUTTON_PADDING = 20;
46 const int H_LIST_ITEM = 112;
47 const int W_LIST_ITEM = 112;
48 const int HORIZONTAL_PADDING = 16;
49 const int VERTICAL_PADDING = 110;
50 const int IDA_BUTTON_CANCEL_OPTIONS_POPUP = 502;
51 static const wchar_t* IDL_CALL_OPTION_POPUP = L"IDL_CALL_OPTION_POPUP";
53 CallOptionPopup::CallOptionPopup(IPopupItemSelectListener& listener, CallPresentationModel& callPresenter)
54 : __pContactList(null)
55 , __popupListener(listener)
56 , __callPresenter(callPresenter)
61 CallOptionPopup::~CallOptionPopup(void)
65 __pContactList->RemoveAll();
66 delete __pContactList;
67 __pContactList = null;
72 CallOptionPopup::Initialize(void)
75 r = Construct(IDL_CALL_OPTION_POPUP);
76 TryReturn(r == E_SUCCESS, r, "CallOptionPopup construction failed");
79 int listHeight = H_LIST_ITEM * __pContactList->GetCount();
80 int popupHeight = H_CANCEL_BUTTON + listHeight + CANCEL_BUTTON_PADDING + VERTICAL_PADDING;
81 r = SetSize(Dimension(W_POPUP + HORIZONTAL_PADDING, popupHeight));
82 TryReturn(r == E_SUCCESS, r, "CallOptionPopup::SetSize() failed");
85 Application::GetInstance()->GetAppResource()->GetString(L"IDS_CANCEL", strText);
86 Button* pCancelButton = new (std::nothrow) Button();
87 r = pCancelButton->Construct(Rectangle(VERTICAL_PADDING, listHeight + CANCEL_BUTTON_PADDING , W_CANCEL_BUTTON, H_CANCEL_BUTTON), strText);
88 pCancelButton->SetActionId(IDA_BUTTON_CANCEL_OPTIONS_POPUP);
89 pCancelButton->AddActionEventListener(*this);
90 r = AddControl(*pCancelButton);
91 TryReturn(r == E_SUCCESS, r, "CallOptionPopup::AddControl() failed");
93 ListView* pListView = new (std::nothrow) ListView();
94 pListView->Construct(Rectangle(0, 0, W_POPUP - HORIZONTAL_PADDING, listHeight), true, SCROLL_STYLE_FADE_OUT);
95 pListView->AddListViewItemEventListener(*this);
96 pListView->SetItemProvider(*this);
97 r = AddControl(*pListView);
103 CallOptionPopup::ConstructListData(void)
105 ArrayListT<CallInfo>* pCallList = static_cast<ArrayListT<CallInfo>*>(__callPresenter.GetCallListN());
106 if (pCallList != null)
108 int callCount = pCallList->GetCount();
114 CallInfo phnCallInfo;
115 pCallList->GetAt(0,phnCallInfo);
116 //show contact number
118 contactNo.Append(phnCallInfo.GetContactNumber());
119 String* displayName = phnCallInfo.FetchCallerNameN();
120 if (displayName->IsEmpty() == true)
122 displayName->Append(contactNo);
125 __pContactList = new (std::nothrow) ArrayList();
126 __pContactList->Construct(2);
127 if (phnCallInfo.IsConferenceCall() == false)
129 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION1");
130 String* listItem1 = new (std::nothrow) String();
131 listItem1->Format(100,optionStr.GetPointer(),displayName->GetPointer());//(L"Putting " + *displayName + L" on hold");
132 __pContactList->Add(*listItem1);
134 optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION2");
135 String* listItem2 = new (std::nothrow) String();
136 listItem2->Append(optionStr + *displayName);
137 __pContactList->Add(*listItem2);
141 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION7");
142 String* listItem1 = new (std::nothrow) String();
143 if (phnCallInfo.IsOnHold() == true)
145 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION8");
146 listItem1->Format(100, optionStr.GetPointer(),phnCallInfo.GetCallerListCount());
150 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION7");
151 listItem1->Format(100, optionStr.GetPointer(),phnCallInfo.GetCallerListCount());
153 __pContactList->Add(*listItem1);
154 String* listItem2 = new (std::nothrow) String();
155 if (phnCallInfo.IsOnHold() == true)
157 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION3");
158 listItem2->Format(100, optionStr.GetPointer(),phnCallInfo.GetCallerListCount());
162 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION4");
163 listItem2->Format(100, optionStr.GetPointer(),phnCallInfo.GetCallerListCount());
165 __pContactList->Add(*listItem2);
174 //2calls present. active call and held call
175 CallInfo firstCallInfo;
176 pCallList->GetAt(0,firstCallInfo);
177 CallInfo secondCallInfo;
178 pCallList->GetAt(1,secondCallInfo);
179 __pContactList = new (std::nothrow) ArrayList();
180 __pContactList->Construct(3);
181 //show contact number
183 contactNo.Append(firstCallInfo.GetContactNumber());
184 String* displayName = firstCallInfo.FetchCallerNameN();
185 if (displayName->IsEmpty() == true)
187 displayName->Append(contactNo);
189 String* listItem1 = new (std::nothrow) String();
190 if (firstCallInfo.IsConferenceCall() == true)
192 if (firstCallInfo.IsOnHold() == true)
194 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION3");
195 listItem1->Format(100, optionStr.GetPointer(),firstCallInfo.GetCallerListCount());
199 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION4");
200 listItem1->Format(100, optionStr.GetPointer(),firstCallInfo.GetCallerListCount());
205 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION5");
206 listItem1->Append(optionStr + *displayName );
210 contactNo.Append(secondCallInfo.GetContactNumber());
211 displayName = secondCallInfo.FetchCallerNameN();
212 if (displayName->IsEmpty() == true)
214 displayName->Append(contactNo);
216 String* listItem2 = new (std::nothrow) String();
217 if (secondCallInfo.IsConferenceCall() == true)
220 callCountStr.Append(secondCallInfo.GetCallerListCount());
222 if (secondCallInfo.IsOnHold() == true)
224 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION3");
225 listItem2->Format(100, optionStr.GetPointer(),secondCallInfo.GetCallerListCount());
229 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION4");
230 listItem2->Format(100, optionStr.GetPointer(),secondCallInfo.GetCallerListCount());
235 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION5");
236 listItem2->Append(optionStr + *displayName );
238 if (firstCallInfo.IsOnHold() == true)
240 __pContactList->Add(*listItem2);
241 __pContactList->Add(*listItem1);
245 __pContactList->Add(*listItem1);
246 __pContactList->Add(*listItem2);
248 String optionStr = AppUtility::GetResourceString(L"IDS_CALL_OPTION6");
249 String* listItem3 = new (std::nothrow) String();
250 listItem3->Append(optionStr);
251 __pContactList->Add(*listItem3);
259 pCallList->RemoveAll();
265 CallOptionPopup::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId,
266 Tizen::Ui::Controls::ListItemStatus status)
268 Popup::SetShowState(false);
269 __popupListener.OnItemSelected(elementId);
274 CallOptionPopup::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index,
275 Tizen::Ui::Controls::SweepDirection direction)
281 CallOptionPopup::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId,
282 Tizen::Ui::Controls::ListContextItemStatus state)
288 CallOptionPopup::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId,
289 bool& invokeListViewItemCallback)
295 CallOptionPopup::GetItemCount(void)
297 if (__pContactList != null)
299 return __pContactList->GetCount();
304 Tizen::Ui::Controls::ListItemBase*
305 CallOptionPopup::CreateItem(int index, int itemWidth)
308 String* strText = static_cast<String*>(__pContactList->GetAt(index));
309 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
310 CustomItem* pItem = new CustomItem();
311 pItem->Construct(Dimension(itemWidth, W_LIST_ITEM), style);
312 if (__pContactList->GetCount() == 2)
314 elementId = ID_SECOND_INCOMING_CALL + index;
318 elementId = ID_MULTI_PARTY_CALL + index;
320 pItem->AddElement(Rectangle(HORIZONTAL_PADDING, 0, W_POPUP - HORIZONTAL_PADDING, H_LIST_ITEM), elementId, *strText);
325 CallOptionPopup::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
334 CallOptionPopup::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
338 case IDA_BUTTON_CANCEL_OPTIONS_POPUP:
340 Popup::SetShowState(false);
341 __popupListener.OnItemSelected(IDA_BUTTON_CANCEL_OPTIONS_POPUP);