Initialize Tizen 2.3
[apps/osp/Call.git] / src / CallIncomingCallForm.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    CallIncomingCallForm.cpp
19  * @brief       Incoming Call form implementation
20  */
21 #include <FBaseColIList.h>
22 #include "CallIncomingCallForm.h"
23 #include "CallAppUtility.h"
24 #include "CallSettingsManager.h"
25 #include "CallPresentationModel.h"
26 #include "CallSceneRegister.h"
27 #include "CallTypes.h"
28 #include "CallApp.h"
29
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Animations;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38
39 //Constants
40 const int W_DIAL_BITMAP = 100;
41 const int H_DIAL_BITMAP = 100;
42 const int W_CREATE_BITMAP = 56;
43 const int H_CREATE_BITMAP = 56;
44 const int X_CREATE_BITMAP = 8;
45 const int Y_CREATE_BITMAP = 8;
46 const int W_MESSAGE_BG_BITMAP = 720;
47 const int H_MESSAGE_BG_BITMAP = 110;
48 const int W_ARROW_BITMAP = 28;
49 const int H_ARROW_BITMAP = 36;
50 const int W_MESSAGE_BITMAP = 50;
51 const int H_MESSAGE_BITMAP = 50;
52 const int X_MESSAGE_BITMAP = 185;
53 const int Y_MESSAGE_BITMAP = 50;
54 const int MESSAGE_TEXT_X_MARGIN = 20;
55 const int MESSAGE_TEXT_Y_MARGIN = 10;
56 const int SEND_TEXT_X_MARGIN = 78;
57 const int SEND_TEXT_Y_MARGIN = 20;
58 const int SEND_BUTTON_ROUND_DIMENSION = 5;
59 const int W_DIAL_LABEL = 188;
60 const int H_DIAL_LABEL = 188;
61 const int DIAL_ICON_X_OFFSET = 44;
62 const int DIAL_ICON_Y_OFFSET = 44;
63 const int REJECT_LABEL_X_OFFSET = 492;
64 const int X_CALL_PANEL = 20;
65 const int Y_CALL_PANEL = 110;
66 const int H_CALL_PANEL = 188;
67 const int Y_ARROW_LABEL = 79;
68 const int W_ARROW_LABEL = 20;
69 const int H_ARROW_LABEL = 32;
70 const int VALID_TOUCH_X_OFFSET = 158;
71 const int VALID_TOUCH_Y_OFFSET = 158;
72 const int X_ARROW_LABEL_STARTPOS = 206; // 188 circle wodth , 18 GUI spec
73 const int X_ARROW_REJECT_LABEL_STARTPOS = 454; // 700 width of panel - 20 offset - 188 circle width - 18 GUI spec - 20 width of image
74 const int ARROW_LABEL_X_MARGIN = 48; //20 width of arrow and 28 GUI spec
75 const int ACCEPT_LABEL_RELATIVE_POS = -384; //relative pos of accept labels right to reject labels left
76 const int MAX_LIST_HEIGHT = 448;//678;
77 const int H_REJECT_VIEW_FOOTER = 98;
78 const int X_LIST_TEXT_ITEM = 16;
79 const int W_LIST_TEXT_ITEM = 452;
80 const int H_LIST_TEXT_ITEM = 111;
81 const int X_SEND_TEXT_ITEM = 484;
82 const int Y_SEND_TEXT_ITEM = 20;
83 const int W_SEND_TEXT_ITEM = 220;
84 const int W_SEND_BUTTON_MARGIN = 14;
85 const int H_SEND_TEXT_ITEM = 72;
86 const int X_PHOTO_LBL = 166;
87 const int Y_PHOTO_LBL = 232;
88 const int W_PHOTO_LBL = 388;
89 const int H_PHOTO_LBL = 388;
90 const int W_PHOTO_LABEL = 720;
91 const int H_PHOTO_LABEL = 720;
92 const int COUNT_ARROW_ELEMENTS = 3;
93
94 const unsigned int COLOR_SEND_BUTTON_PRESSED = Color32<130, 142, 150>::Value;
95 const unsigned int COLOR_SEND_BUTTON_NORMAL = Color32<64, 156, 211>::Value;
96 const unsigned int COLOR_SWIPE_PANEL = Color32<0, 0, 0, 255>::Value;
97 const unsigned int COLOR_LIST_TEXT_NORMAL = Color32<0, 0, 0>::Value;
98 const unsigned int COLOR_LIST_TEXT_PRESSED = Color32<249, 249, 249>::Value;
99
100 const int FONT_SIZE_MSG_TXT = 44;
101
102 static const wchar_t* IDL_INCOMING_CALL_FORM = L"IDL_INCOMING_CALL_FORM";
103 static const wchar_t* IDB_REJECT_MESSAGE_BG = L"C01-1_Reject_message_bg.png";
104 static const wchar_t* IDB_REJECT_MESSAGE_UP_ARROW = L"C01-1_Reject_message_arrow_01.png";
105 static const wchar_t* IDB_REJECT_MESSAGE_DOWN_ARROW = L"C01-1_Reject_message_arrow_02.png";
106 static const wchar_t* IDB_REJECT_MESSAGE_ICON = L"C01-1_icon_Reject_with_Message.png";
107 static const wchar_t* IDB_ACCEPT_CIRCLE_ICON = L"C01-1_accept_left.png";
108 static const wchar_t* IDB_REJECT_CIRCLE_ICON = L"C01-1_reject_right.png";
109 static const wchar_t* IDB_CALL_ACCEPT_ICON = L"C01-1_accept_left_dial_answer.png";
110 static const wchar_t* IDB_CALL_REJECT_ICON = L"C01-1_reject_right_dial_decline.png";
111 static const wchar_t* IDB_ACCEPT_ARROW_ICON = L"C01-1_arrow_g.png";
112 static const wchar_t* IDB_REJECT_ARROW_ICON = L"C01-1_arrow_r.png";
113 static const wchar_t* IDB_CALL_BG = L"C01-1_calling_BG_01.png";
114 static const wchar_t* IDC_REJECT_MESSAGE_BUTTON = L"IDC_REJECT_MESSAGE_BUTTON";
115 static const wchar_t* IDC_REJECT_PANEL = L"IDC_REJECT_PANEL";
116 static const wchar_t* IDC_REJECT_MESSAGE_CANCEL_BUTTON = L"IDC_REJECT_MESSAGE_CANCEL_BUTTON";
117 static const wchar_t* IDC_MSG_TABLEVIEW = L"IDC_MSG_TABLEVIEW";
118 static const wchar_t* IDC_CALLER_LABEL = L"IDC_CALLER_LABEL";
119 static const wchar_t* IDC_NUMBER_LABEL = L"IDC_NUMBER_LABEL";
120 static const wchar_t* IDC_BIG_PHOTO_LABEL = L"IDC_BIG_PHOTO_LABEL";
121 static const wchar_t* IDC_CALLHANDEL_PANEL = L"IDC_CALLHANDEL_PANEL";
122 static const wchar_t* IDC_ACCEPT_LABEL = L"IDC_ACCEPT_LABEL";
123 static const wchar_t* IDC_REJECT_LEBEL = L"IDC_REJECT_LEBEL";
124 static const wchar_t* IDC_ACCEPT_ARROW = L"IDC_ACCEPT_ARROW_";
125 static const wchar_t* IDC_REJECT_ARROW = L"IDC_REJECT_ARROW_";
126 const wchar_t* IDS_REJECT_MESSAGE_BTN = L"IDS_REJECT_MESSAGE_BTN";
127 const wchar_t* IDS_LIST_SEND_BUTTON = L"IDS_LIST_SEND_BUTTON";
128 const wchar_t* IDS_NO_MESSAGE_STR = L"IDS_NO_MESSAGE_STR";
129
130 const wchar_t* IDI_FORM_VISUAL_ELE_NAME = L"FormVisEle";
131 const wchar_t* IDI_PANEL_VISUAL_ELE_NAME = L"PanelVisEle";
132 const wchar_t* IDI_ACCEPT_VISUAL_ELE_NAME = L"AcceptVisEle";
133 const wchar_t* IDI_REJECT_VISUAL_ELE_NAME = L"RejectVisEle";
134 const wchar_t* IDI_ACCEPT_ARROW_VISUAL_ELE_NAME = L"AcceptArrowVisEle";
135 const wchar_t* IDI_REJECT_ARROW_VISUAL_ELE_NAME = L"RejectArrowVisEle";
136 const wchar_t* IDI_REJECT_FINAL_VISUAL_ELE_NAME = L"RejectFinalVisEle";
137 const wchar_t* IDI_ACCEPT_FINAL_VISUAL_ELE_NAME = L"AcceptFinalVisEle";
138
139 IncomingCallForm::IncomingCallForm(void)
140         : BaseForm(FORMTYPE_INCOMINGCALL)
141 {
142         __pActiveContactNo = null;
143         __pRejectMessageList = null;
144         __incomingCallHandle = -1;
145         __isAnswerCallStarted = false;
146         __isRejectCallStarted = false;
147         __pAcceptArrowLabelsList = null;
148         __pRejectArrowLabelsList = null;
149         __pRejectCircle = null;
150         __pAcceptCircle = null;
151         __pAcceptDial = null;
152         __pRejectDial = null;
153         __pAcceptArrow = null;
154         __pRejectArrow = null;
155         __pAcceptLabel = null;
156         __pRejectLabel = null;
157         __pAcceptArrowLabel = null;
158         __pRejectArrowLabel = null;
159         __pCallHandlePanel = null;
160         __pAcceptVisElem = null;
161         __pRejectVisElem = null;
162         __pRejectFinalVisElem = null;
163         __pAcceptFinalVisElem = null;
164         __pAcceptArrowVisElem = null;
165         __pRejectArrowVisElem = null;
166         __pCallPresentor = null;
167         __pOptionPopup = null;
168         __pSmallPhotoLabel = null;
169 }
170
171 IncomingCallForm::~IncomingCallForm(void)
172 {
173 }
174
175 void
176 IncomingCallForm::Initialize(void)
177 {
178         Construct(IDL_INCOMING_CALL_FORM);
179 }
180
181 result
182 IncomingCallForm::OnInitializing(void)
183 {
184         result r = E_SUCCESS;
185         Canvas* pCanvas = null;
186
187         InitializeFooter();
188
189
190         VisualElement* pFormVisElem = new (std::nothrow) VisualElement();
191         r = pFormVisElem->Construct();
192         pFormVisElem->SetBounds(FloatRectangle(GetBounds().x, GetBounds().y, GetBounds().width, GetBounds().height));
193         pFormVisElem->SetShowState(true);
194         pFormVisElem->SetOpacity(1.0f);
195         pFormVisElem->SetName(IDI_FORM_VISUAL_ELE_NAME);
196         GetVisualElement()->AttachChild(*pFormVisElem);
197         pCanvas = pFormVisElem->GetCanvasN();
198         if(pCanvas != null)
199         {
200                 pCanvas->Clear();
201                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
202                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
203                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(GetBounds().x, GetBounds().y, GetBounds().width, GetBounds().height));
204                 delete pCanvas;
205                 pCanvas = null;
206         }
207         HideRejectPanel();
208
209
210         InitializeTableView();
211
212         __pAcceptCircle = AppUtility::GetBitmapFromResourcesN(IDB_ACCEPT_CIRCLE_ICON, W_DIAL_LABEL, H_DIAL_LABEL);
213         __pRejectCircle = AppUtility::GetBitmapFromResourcesN(IDB_REJECT_CIRCLE_ICON, W_DIAL_LABEL, H_DIAL_LABEL);
214         __pAcceptDial = AppUtility::GetBitmapFromResourcesN(IDB_CALL_ACCEPT_ICON, W_DIAL_BITMAP, H_DIAL_BITMAP);
215         __pRejectDial = AppUtility::GetBitmapFromResourcesN(IDB_CALL_REJECT_ICON, W_DIAL_BITMAP, H_DIAL_BITMAP);
216         __pAcceptArrow = AppUtility::GetBitmapFromResourcesN(IDB_ACCEPT_ARROW_ICON, W_ARROW_LABEL, H_ARROW_LABEL);
217         __pRejectArrow = AppUtility::GetBitmapFromResourcesN(IDB_REJECT_ARROW_ICON, W_ARROW_LABEL, H_ARROW_LABEL);
218
219
220         if(__pRejectDial == null)
221         {
222                 AppLogDebug("Null");
223         }
224         //Panel for showing accept and reject call buttons.
225         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL, true));
226          int yPos = pPhotoLbl->GetX()+pPhotoLbl->GetHeight()+ Y_CALL_PANEL;
227
228         __pCallHandlePanel = static_cast<Panel*>(GetControl(IDC_CALLHANDEL_PANEL, true));
229         __pCallHandlePanel->AddTouchEventListener(*this);
230         __pCallHandlePanel->SetBackgroundColor(COLOR_SWIPE_PANEL);
231         VisualElement* pCallPanelVisElem = new (std::nothrow) VisualElement();
232         r = pCallPanelVisElem->Construct();
233         pCallPanelVisElem->SetBounds(FloatRectangle(__pCallHandlePanel->GetBoundsF()));
234         pCallPanelVisElem->SetShowState(true);
235         pCallPanelVisElem->SetOpacity(1.0f);
236         pCallPanelVisElem->SetName(IDI_PANEL_VISUAL_ELE_NAME);
237         __pCallHandlePanel->GetVisualElement()->AttachChild(*pCallPanelVisElem);
238         pCanvas = pCallPanelVisElem->GetCanvasN();
239         if(pCanvas != null)
240         {
241                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
242                 pCanvas->Clear();
243                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
244                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
245                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(X_CALL_PANEL, yPos, GetClientAreaBounds().width, H_CALL_PANEL));
246                 delete pCanvas;
247                 pCanvas = null;
248         }
249         //Lock Label for animation
250         __pAcceptLabel = static_cast<Label*>(GetControl(IDC_ACCEPT_LABEL, true));
251         __pAcceptLabel->SetBackgroundColor(COLOR_SWIPE_PANEL);
252         __pAcceptLabel->AddTouchEventListener(*this);
253         //left dial icon
254         __pAcceptVisElem = new (std::nothrow) VisualElement();
255         r = __pAcceptVisElem->Construct();
256         __pAcceptVisElem->SetBounds(FloatRectangle(0, 0, __pAcceptLabel->GetWidth(), __pAcceptLabel->GetHeight()));
257         __pAcceptVisElem->SetShowState(true);
258         __pAcceptVisElem->SetOpacity(1.0f);
259         __pAcceptVisElem->SetName(IDI_ACCEPT_VISUAL_ELE_NAME);
260         __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
261         pCanvas = __pAcceptVisElem->GetCanvasN();
262         if(pCanvas != null)
263         {
264                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
265                 pCanvas->Clear();
266                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
267                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
268                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
269                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pAcceptCircle);
270                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial);
271                 delete pCanvas;
272                 pCanvas = null;
273         }
274         //UnLock Label for animation
275         __pRejectLabel = static_cast<Label*>(GetControl(IDC_REJECT_LEBEL, true));
276         __pRejectLabel->AddTouchEventListener(*this);
277         __pRejectLabel->SetBackgroundColor(COLOR_SWIPE_PANEL);
278         SetControlAlwaysAtBottom(*__pCallHandlePanel, true);
279
280         //Right reject icon
281         __pRejectVisElem = new (std::nothrow) VisualElement();
282         r = __pRejectVisElem->Construct();
283         __pRejectVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
284         __pRejectVisElem->SetShowState(true);
285         __pRejectVisElem->SetOpacity(1.00f);
286         __pRejectVisElem->SetName(IDI_REJECT_VISUAL_ELE_NAME);
287         __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
288         pCanvas = __pRejectVisElem->GetCanvasN();
289         if(pCanvas != null)
290         {
291                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
292                 pCanvas->Clear();
293                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
294                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
295                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
296                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle);
297                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial);
298                 delete pCanvas;
299                 pCanvas = null;
300         }
301
302         //! Constructs an array list to store the unlock labels
303         __pAcceptArrowLabelsList = new (std::nothrow) ArrayList();
304         r = __pAcceptArrowLabelsList->Construct();
305
306         //! Constructs the Unlock Labels with the bitmap as background, adds the touch event Listener and adds them to the panel.
307         int x = X_ARROW_LABEL_STARTPOS;
308         for (int index = 0; index < COUNT_ARROW_ELEMENTS; index++)
309         {
310                 String LabelName(IDC_ACCEPT_ARROW);
311                 LabelName.Append(index+1);
312                 __pAcceptArrowLabel = static_cast<Label*>(GetControl(LabelName, true));
313                 __pAcceptArrowLabel->AddTouchEventListener(*this);
314                 __pAcceptArrowLabelsList->Add(*__pAcceptArrowLabel);
315                 __pAcceptArrowVisElem = new (std::nothrow) VisualElement();
316                 r = __pAcceptArrowVisElem->Construct();
317                 __pAcceptArrowVisElem->SetBounds(FloatRectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
318                 __pAcceptArrowVisElem->SetShowState(true);
319                 __pAcceptArrowVisElem->SetOpacity(0.0f);
320                 String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
321                 VisualEleName.Append(index);
322                 __pAcceptArrowVisElem->SetName(VisualEleName);
323                 __pAcceptArrowLabel->GetVisualElement()->AttachChild(*__pAcceptArrowVisElem);
324                 pCanvas = __pAcceptArrowVisElem->GetCanvasN();
325                 if(pCanvas != null)
326                 {
327                         pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
328                         pCanvas->Clear();
329                         pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
330                         pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
331                         pCanvas->DrawRectangle(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
332                         pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
333                         pCanvas->DrawBitmap(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL), *__pAcceptArrow);
334                         delete pCanvas;
335                         pCanvas = null;
336                 }
337                 x += ARROW_LABEL_X_MARGIN;
338         }
339         //! Constructs an array list to store the unlock labels
340         __pRejectArrowLabelsList = new (std::nothrow) ArrayList();
341         r = __pRejectArrowLabelsList->Construct();
342
343         x = X_ARROW_REJECT_LABEL_STARTPOS;
344         for (int index = 0; index < COUNT_ARROW_ELEMENTS; index++)
345         {
346                 String LabelName(IDC_REJECT_ARROW);
347                 LabelName.Append(index+1);
348                 __pRejectArrowLabel = static_cast<Label*>(GetControl(LabelName, true));
349                 __pRejectArrowLabel->AddTouchEventListener(*this);
350                 __pRejectArrowLabelsList->Add(*__pRejectArrowLabel);
351                 __pRejectArrowVisElem = new (std::nothrow) VisualElement();
352                 r = __pRejectArrowVisElem->Construct();
353                 __pRejectArrowVisElem->SetBounds(FloatRectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
354                 __pRejectArrowVisElem->SetShowState(true);
355                 __pRejectArrowVisElem->SetOpacity(0.0f);
356                 String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
357                 VisualEleName.Append(index);
358                 __pRejectArrowVisElem->SetName(VisualEleName);
359                 __pRejectArrowLabel->GetVisualElement()->AttachChild(*__pRejectArrowVisElem);
360                 pCanvas = __pRejectArrowVisElem->GetCanvasN();
361                 if(pCanvas != null)
362                 {
363                         pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
364                         pCanvas->Clear();
365                         pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
366                         pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
367                         pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
368                         pCanvas->DrawBitmap(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL), *__pRejectArrow);
369                         delete pCanvas;
370                         pCanvas = null;
371                 }
372                 x -= ARROW_LABEL_X_MARGIN;
373         }
374
375
376         return r;
377 }
378
379 void
380 IncomingCallForm::InitializeFooter(void)
381 {
382         Footer* pFooter = GetFooter();
383         FooterItem footerItemCreate;
384
385         SetFormBackEventListener(this);
386         if(pFooter != null)
387         {
388                 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
389                 pFooter->AddActionEventListener(*this);
390
391                 footerItemCreate.Construct(IDA_CREATE_REJECT_CALL_MESSAGE);
392                 footerItemCreate.SetText(AppUtility::GetResourceString(IDS_REJECT_MESSAGE_CREATE));
393                 pFooter->AddItem(footerItemCreate);
394                 pFooter->SetShowState(false);
395         }
396 }
397
398 void
399 IncomingCallForm::ShowRejectMessageFooter(void)
400 {
401         Footer* pFooter = GetFooter();
402         if(pFooter != null)
403         {
404                 AppLogDebug("SetShowState");
405                 pFooter->SetShowState(true);
406
407         }
408 }
409
410 void
411 IncomingCallForm::HideRejectMessageFooter(void)
412 {
413         Footer* pFooter = GetFooter();
414         if(pFooter != null)
415         {
416                 pFooter->SetShowState(false);
417         }
418 }
419
420 result
421 IncomingCallForm::OnTerminating(void)
422 {
423         result r = E_SUCCESS;
424
425         if (__pRejectMessageList != null)
426         {
427                 delete __pRejectMessageList;
428                 __pRejectMessageList = null;
429         }
430         if (__pActiveContactNo != null)
431         {
432                 delete __pActiveContactNo;
433                 __pActiveContactNo = null;
434         }
435         __incomingCallHandle = -1;
436         __pCallPresentor = null;
437
438         /* Deleting fails in A4RC* SDK. Remove if not necessary
439         if (__pAcceptVisElem != null)
440         {
441                 __pAcceptVisElem->Destroy();
442                 __pAcceptVisElem = null;
443         }
444
445         if (__pRejectVisElem != null)
446         {
447                 __pRejectVisElem->Destroy();
448                 __pRejectVisElem = null;
449         }
450
451         if (__pRejectFinalVisElem != null)
452         {
453                 __pRejectFinalVisElem->Destroy();
454                 __pRejectFinalVisElem = null;
455         }
456
457         if (__pAcceptFinalVisElem != null)
458         {
459                 __pAcceptFinalVisElem->Destroy();
460                 __pAcceptFinalVisElem = null;
461         }
462
463         for (int i = 0; i < 7; i++)
464         {
465                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
466                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement();
467                 if (__pRejectArrowVisElem != null)
468                 {
469                         __pRejectArrowVisElem->Destroy();
470                         __pRejectArrowVisElem = null;
471                 }
472
473                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
474                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement();
475                 if (__pAcceptArrowVisElem != null)
476                 {
477                         __pAcceptArrowVisElem->Destroy();
478                         __pAcceptArrowVisElem = null;
479                 }
480         }
481
482         if (__pAcceptArrowVisElem != null)
483         {
484                 __pAcceptArrowVisElem = null;
485         }
486
487         if (__pRejectArrowVisElem != null)
488         {
489                 __pRejectArrowVisElem = null;
490         }
491 */
492         if (__pAcceptArrowLabelsList != null)
493         {
494                 __pAcceptArrowLabelsList->RemoveAll(false);
495                 delete __pAcceptArrowLabelsList;
496                 __pAcceptArrowLabelsList = null;
497         }
498
499         if (__pRejectArrowLabelsList != null)
500         {
501                 __pRejectArrowLabelsList->RemoveAll(false);
502                 delete __pRejectArrowLabelsList;
503                 __pRejectArrowLabelsList = null;
504         }
505
506         if (__pRejectCircle != null)
507         {
508                 delete __pRejectCircle;
509                 __pRejectCircle = null;
510         }
511
512         if (__pAcceptCircle != null)
513         {
514                 delete __pAcceptCircle;
515                 __pAcceptCircle = null;
516         }
517
518         if (__pAcceptDial != null)
519         {
520                 delete __pAcceptDial;
521                 __pAcceptDial = null;
522         }
523
524         if (__pRejectDial != null)
525         {
526                 delete __pRejectDial;
527                 __pRejectDial = null;
528         }
529
530         if (__pAcceptArrow != null)
531         {
532                 delete __pAcceptArrow;
533                 __pAcceptArrow = null;
534         }
535
536         if (__pRejectArrow != null)
537         {
538                 delete __pRejectArrow;
539                 __pRejectArrow = null;
540         }
541         __pCallHandlePanel->RemoveTouchEventListener(*this);
542         __pAcceptLabel->RemoveTouchEventListener(*this);
543         __pRejectLabel->RemoveTouchEventListener(*this);
544         __pAcceptArrowLabel->RemoveTouchEventListener(*this);
545         __pRejectArrowLabel->RemoveTouchEventListener(*this);
546         __pAcceptLabel = null;
547         __pRejectLabel = null;
548         __pAcceptArrowLabel = null;
549         __pRejectArrowLabel = null;
550         __pCallHandlePanel = null;
551         return r;
552 }
553
554 void
555 IncomingCallForm::ShowRejectMessagePanel(void)
556         {
557                 Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
558                 if (pKeysPanel)
559                 {
560                         pKeysPanel->SetShowState(true);
561                         SetRejectMessagePanelBounds();
562
563                         Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
564                         pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
565                         pButtonReject->AddActionEventListener(*this);
566                         pButtonReject->SetEnabled(true);
567                         //pButtonReject->SetFocus();
568                         FloatRectangle originalrect = pButtonReject->GetBoundsF();
569                         FloatRectangle allignedrect = CoordinateSystem::AlignToDevice(pButtonReject->GetBoundsF());
570                         pButtonReject->SetBounds(allignedrect);
571                         pButtonReject->Invalidate(true);
572
573                         ShowRejectMessageFooter();
574
575
576                         //pKeysPanel->SetFocus();
577                         pKeysPanel->Draw();
578                 }
579                 Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
580                 if (pButtonRejectMessage)
581                 {
582                         pButtonRejectMessage->SetShowState(false);
583                         pButtonRejectMessage->Invalidate(true);
584                         pButtonRejectMessage->Draw();
585                 }
586         }
587 void
588 IncomingCallForm::HideRejectMessagePanel(void)
589 {
590         HideRejectPanel();
591         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
592         if (pButtonRejectMessage)
593         {
594                 pButtonRejectMessage->SetShowState(true);
595                 FloatRectangle originalrect = pButtonRejectMessage->GetBoundsF();
596                 FloatRectangle allignedrect = CoordinateSystem::AlignToDevice(pButtonRejectMessage->GetBoundsF());
597                 pButtonRejectMessage->SetBounds(allignedrect);
598                 pButtonRejectMessage->Invalidate(true);
599                 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetLandscapeLayoutN());
600                 if (pRelativeLayout != null)
601                 {
602                         pRelativeLayout->SetRelation(*pButtonRejectMessage,*this,RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
603                         pRelativeLayout->Update();
604                         delete pRelativeLayout;
605                 }
606         }
607 }
608
609 void
610 IncomingCallForm::SetRejectMessagePanelBounds(void)
611 {
612         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
613         if(pKeysPanel)
614         {
615                 TableView* pMessageList = static_cast<TableView*>(pKeysPanel->GetControl(IDC_MSG_TABLEVIEW));
616                 Rectangle tmpRect = pMessageList->GetBounds();
617                 SetControlAlwaysOnTop(*pKeysPanel,true);
618                 //Set Height to Reject Message Panel
619                 int listHeight = H_LIST_NORMAL_MENU_ITEM; //If no messages
620                 if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
621                 {
622                         listHeight = H_LIST_NORMAL_MENU_ITEM * (__pRejectMessageList->GetCount()); //multiply by number of items
623                 }
624                 if (listHeight > MAX_LIST_HEIGHT)
625                 {
626                         listHeight = MAX_LIST_HEIGHT;
627                 }
628
629                 pMessageList->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, listHeight);
630                 pMessageList->RefreshAllItems();
631                 tmpRect = pKeysPanel->GetBounds();
632                 pKeysPanel->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, H_MESSAGE_BG_BITMAP /*+ H_REJECT_VIEW_FOOTER*/ + listHeight);
633         }
634 }
635
636 void
637 IncomingCallForm::OnActionPerformed(const Control& source, int actionId)
638 {
639         switch (actionId)
640         {
641         case IDA_SHOW_REJECT_CALL_MESSAGE_PANEL: // applicable in all form states
642         {
643                 ShowRejectMessagePanel();
644         }
645         break;
646
647         case IDA_CREATE_REJECT_CALL_MESSAGE:
648         {
649                 if(__pCallPresentor->IsAppControlRunning() == false)
650                 {
651                         __pCallPresentor->RejectCall(__incomingCallHandle, true,*__pActiveContactNo);
652                         /*ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
653                         if(pCallList != null && pCallList->GetCount() > 0)
654                         {
655                                 __pCallPresentor->HandleCallConnected(*pCallList);
656                         }
657                         pCallList = null;*/
658                 }
659         }
660         break;
661
662         case IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL:
663         {
664                 HideRejectMessagePanel();
665         }
666         break;
667
668         case IDA_SEND_REJECT_MSG1:
669         case IDA_SEND_REJECT_MSG2:
670         case IDA_SEND_REJECT_MSG3:
671         case IDA_SEND_REJECT_MSG4:
672         case IDA_SEND_REJECT_MSG5:
673         case IDA_SEND_REJECT_MSG6:
674         {
675                 __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo);
676                 String textToBeSent;
677                 //calculate msgIndex
678                 int msgIndex = IDA_SEND_REJECT_MSG1;
679                 msgIndex = actionId - msgIndex;
680                 __pRejectMessageList->GetAt(msgIndex, textToBeSent);
681                 __pCallPresentor->SendMessage(textToBeSent,*__pActiveContactNo);
682         }
683         break;
684
685         default:
686                 break;
687         }
688 }
689
690 void
691 IncomingCallForm::OnSceneActivatedN(const SceneId& previousSceneId,     const SceneId& currentSceneId, IList* pArgs)
692 {
693         AppLogDebug("Enter");
694         AddOrientationEventListener(*this);
695         //Get Reject list from Settings Manager
696         IMapT<int,String>* pMsgMap = SettingsManager::GetInstance()->GetRejectMessageListN();
697         if(pMsgMap != null)
698         {
699                 if (__pRejectMessageList != null)
700                 {
701                         delete __pRejectMessageList;
702                         __pRejectMessageList = null;
703                 }
704                 __pRejectMessageList = pMsgMap->GetValuesN();
705                 delete pMsgMap;
706                 pMsgMap = null;
707         }
708         //No reject messages
709         else
710         {
711                 if (__pRejectMessageList != null)
712                 {
713                         delete __pRejectMessageList;
714                         __pRejectMessageList = null;
715                 }
716         }
717         //listen to Foreground events
718         CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
719         pPhoneApp->AddAppStateChangeListener(*this);
720         if(__pCallPresentor == null)
721         {
722                 __pCallPresentor = CallPresentationModel::GetInstance();
723         }
724         __pCallPresentor->SetTelEventListener(this);
725         //Abort any AppControl Request running already to show incoming call screen
726         if (__pCallPresentor->IsAppControlRunning() == true)
727         {
728                 __pCallPresentor->AbortAppControlRequest();
729         }
730
731         HideRejectPanel();
732
733         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null)
734         {
735                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
736         }
737         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null)
738         {
739                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
740         }
741
742         __pAcceptVisElem->SetOpacity(1.0f);
743         __pRejectVisElem->SetOpacity(1.00f);
744         for (int i = 0; i < COUNT_ARROW_ELEMENTS; i++)
745         {
746                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
747                 String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
748                 RejectVisualEleName.Append(i);
749                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true);
750                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
751                 String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
752                 AcceptVisualEleName.Append(i);
753                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true);
754                 switch(i)
755                 {
756                         case 0:
757                                 __pAcceptArrowVisElem->SetOpacity(0.6f);
758                                 __pRejectArrowVisElem->SetOpacity(0.6f);
759                         break;
760                         case 1:
761                                 __pAcceptArrowVisElem->SetOpacity(0.8f);
762                                 __pRejectArrowVisElem->SetOpacity(0.8f);
763                         break;
764                         case 2:
765                                 __pAcceptArrowVisElem->SetOpacity(1.0f);
766                                 __pRejectArrowVisElem->SetOpacity(1.0f);
767                         break;
768                 }
769
770         }
771
772
773         if (pArgs != null)
774         {
775                 //get Call Info
776                 AppCallInfo* pIncomingCall = static_cast<AppCallInfo*>(pArgs->GetAt(0));
777                 if (pIncomingCall != null)
778                 {
779                         //start alert with contact's custom ringtone
780                         __pCallPresentor->StartAlert(*pIncomingCall);
781                         //show contact number
782                         String contactNo;
783                         contactNo.Append(pIncomingCall->GetContactNumber());
784                         if (__pActiveContactNo)
785                         {
786                                 delete __pActiveContactNo;
787                                 __pActiveContactNo = null;
788                         }
789                         __incomingCallHandle = pIncomingCall->GetCallHandle()->ToLong();
790                         __pActiveContactNo = new (std::nothrow) String();
791
792                         if(contactNo.IsEmpty())
793                         {
794                                 AppLogDebug("Number empty");
795                                 contactNo.Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
796                                 AppLogDebug("%ls",contactNo.GetPointer());
797                         }
798                         __pActiveContactNo->Append(contactNo);
799                         //Show person details
800                         ShowPersonDetails(*__pActiveContactNo, IDC_NUMBER_LABEL, IDC_CALLER_LABEL, pIncomingCall);
801                         //Check if incoming call is hidden call, then do not show "Reject with Message" button
802                         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
803                         if (pButtonRejectMessage)
804                         {
805                                 //for hidden call, contact number is not present
806                                 bool showRejectMsgButton = (pIncomingCall->GetContactNumber().IsEmpty() == false);
807                                 pButtonRejectMessage->SetShowState(showRejectMsgButton);
808                                 pButtonRejectMessage->Invalidate(true);
809                         }
810                 }
811                 pArgs->RemoveAll();
812                 delete pArgs;
813                 pArgs = null;
814         }
815         CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
816         pCallApp->SetTopMostWindow(true);
817         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
818         if (pButtonRejectMessage)
819         {
820                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
821                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, false);
822                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
823                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, true);
824                 pButtonRejectMessage->SetActionId(IDA_SHOW_REJECT_CALL_MESSAGE_PANEL);
825                 pButtonRejectMessage->AddActionEventListener(*this);
826         }
827
828         //This called here to handle the case when incoming call comes when
829         // add call is in foreground.
830         //Uncommenting for N_SE-50029
831         __pCallPresentor->OnAppForeground();
832
833 }
834
835 void
836 IncomingCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
837 {
838         RemoveOrientationEventListener(*this);
839         if (__pSmallPhotoLabel != null)
840         {
841                 RemoveControl(*__pSmallPhotoLabel);
842                 __pSmallPhotoLabel = null;
843         }
844         for (int i = 0; i < COUNT_ARROW_ELEMENTS; i++)
845         {
846                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
847                 String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
848                 RejectVisualEleName.Append(i);
849                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true);
850                 __pRejectArrowVisElem->SetOpacity(0.0f);
851                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
852                 String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
853                 AcceptVisualEleName.Append(i);
854                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true);
855                 __pAcceptArrowVisElem->SetOpacity(0.0f);
856         }
857         if(__pAcceptLabel != null)
858         {
859                 if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME,true) != null)
860                 {
861                         AppLogDebug("__pAcceptLabel Detatach child");
862                         __pAcceptLabel->GetVisualElement()->DetachChild(*__pAcceptFinalVisElem);
863                 }
864         }
865         if(__pRejectLabel != null)
866         {
867                 if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_FINAL_VISUAL_ELE_NAME,true) != null)
868                 {
869                         AppLogDebug("__pRejectLabel Detatach child");
870                         __pRejectLabel->GetVisualElement()->DetachChild(*__pRejectFinalVisElem);
871                 }
872
873         }
874         CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
875         pCallApp->RemoveAppStateChangeListener(*this);
876 }
877
878 result
879 IncomingCallForm::OnDraw(void)
880 {
881         Bitmap* pBackgroundWp = null;
882         // get a Canvas instance
883         Canvas* pCanvas = GetCanvasN();
884
885         pBackgroundWp = AppResource::GetInstance()->GetBitmapN(IDB_CALL_BG);
886
887         if (pCanvas)
888         {
889
890                 if (pBackgroundWp)
891                 {
892                         pCanvas->DrawBitmap(pCanvas->GetBounds(), *pBackgroundWp);
893                 }
894         }
895
896         delete pBackgroundWp;
897         pBackgroundWp = null;
898
899         delete pCanvas;
900         pCanvas = null;
901
902         return E_SUCCESS;
903 }
904
905 void
906 IncomingCallForm::HideRejectPanel(void)
907 {
908         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
909         if (pKeysPanel)
910         {
911                 pKeysPanel->SetShowState(false);
912                 Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
913                 pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
914                 pButtonReject->AddActionEventListener(*this);
915                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
916                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, false);
917                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
918                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, true);
919
920                 HideRejectMessageFooter();
921                 pKeysPanel->Invalidate(true);
922         }
923 }
924
925 void
926 IncomingCallForm::InitializeTableView(void)
927 {
928         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
929         TableView* pMessageList = static_cast<TableView*>(pKeysPanel->GetControl(IDC_MSG_TABLEVIEW));
930         pMessageList->SetItemProvider(this);
931         pMessageList->AddTableViewItemEventListener(*this);
932 }
933
934 ///////////////////////////////////////////////////////////////////////////////
935 /////                   Table View Functionality supporting functions                    /////
936 //////////////////////////////////////////////////////////////////////////////
937 int
938 IncomingCallForm::GetItemCount(void)
939 {
940         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
941         {
942                 return (__pRejectMessageList->GetCount());
943         }
944         return 1;
945 }
946
947 TableViewItem*
948 IncomingCallForm::CreateItem(int itemIndex, int itemWidth)
949 {
950         //create a new item
951         TableViewItem* pItem = new (std::nothrow) TableViewItem();
952         pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL);
953
954         //Message text item rectangle
955         //Rectangle itemRect(X_LIST_TEXT_ITEM, 0, W_LIST_TEXT_ITEM, H_LIST_NORMAL_MENU_ITEM);
956         Rectangle itemRect(X_LIST_TEXT_ITEM, 0, itemWidth - W_SEND_BUTTON_MARGIN - W_SEND_TEXT_ITEM, H_LIST_NORMAL_MENU_ITEM);
957
958         //Message
959         String itemName(L"");
960         bool isShowSendButton = true;
961         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
962         {
963                 __pRejectMessageList->GetAt(itemIndex, itemName);
964         }
965         else
966         {
967                 itemName.Append(AppUtility::GetResourceString(IDS_NO_MESSAGE_STR));
968                 isShowSendButton = false;
969         }
970
971         Label* pMsgLbl = new (std::nothrow) Label();
972         pMsgLbl->Construct(itemRect, itemName);
973         pMsgLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
974         pMsgLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
975         pMsgLbl->SetTextConfig(FONT_SIZE_MSG_TXT, LABEL_TEXT_STYLE_NORMAL);
976         pMsgLbl->SetTextColor(COLOR_LIST_TEXT_NORMAL);
977         pItem->AddControl(pMsgLbl);
978
979         //Send Button
980         if(isShowSendButton == true)
981         {
982                 String sendText = AppUtility::GetResourceString(IDS_LIST_SEND_BUTTON);
983                 Button* pSendButton = new (std::nothrow) Button();
984                 pSendButton->Construct(Rectangle(GetClientAreaBounds().width - W_SEND_BUTTON_MARGIN -W_SEND_TEXT_ITEM, Y_SEND_TEXT_ITEM, W_SEND_TEXT_ITEM, H_SEND_TEXT_ITEM), sendText);
985                 //set action id and listener
986                 int actionId = IDA_SEND_REJECT_MSG1;
987                 switch(itemIndex)
988                 {
989                 case 0:
990                         actionId = IDA_SEND_REJECT_MSG1;
991                         break;
992                 case 1:
993                         actionId = IDA_SEND_REJECT_MSG2;
994                         break;
995                 case 2:
996                         actionId = IDA_SEND_REJECT_MSG3;
997                         break;
998                 case 3:
999                         actionId = IDA_SEND_REJECT_MSG4;
1000                         break;
1001                 case 4:
1002                         actionId = IDA_SEND_REJECT_MSG5;
1003                         break;
1004                 case 5:
1005                         actionId = IDA_SEND_REJECT_MSG6;
1006                         break;
1007                 }
1008                 pSendButton->SetActionId(actionId);
1009                 pSendButton->AddActionEventListener(*this);
1010                 pItem->AddControl(*pSendButton);
1011                 pItem->SetIndividualSelectionEnabled(pSendButton, true);
1012         }
1013         else
1014         {
1015                 pItem->SetEnabled(false);
1016         }
1017
1018         return pItem;
1019 }
1020
1021 void
1022 IncomingCallForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1023 {
1024         Rectangle itemRect(X_LIST_TEXT_ITEM, 0, pItem->GetWidth()- W_SEND_BUTTON_MARGIN - W_SEND_TEXT_ITEM, H_LIST_NORMAL_MENU_ITEM);
1025         Label* pItemLbl = static_cast<Label*>(pItem->GetControl(0));
1026         if(pItemLbl != null)
1027         {
1028                 pItemLbl->SetBounds(itemRect);
1029         }
1030         Button* pSendButton = static_cast<Button*>(pItem->GetControl(1));
1031         if(pSendButton != null)
1032         {
1033                 pSendButton->SetBounds(Rectangle(GetClientAreaBounds().width - W_SEND_BUTTON_MARGIN -W_SEND_TEXT_ITEM, Y_SEND_TEXT_ITEM, W_SEND_TEXT_ITEM, H_SEND_TEXT_ITEM));
1034         }
1035         pItem->Invalidate(true);
1036 }
1037
1038 bool
1039 IncomingCallForm::DeleteItem(int itemIndex, TableViewItem* pItem)
1040 {
1041         delete pItem;
1042         pItem = null;
1043         return true;
1044 }
1045
1046 int
1047 IncomingCallForm::GetDefaultItemHeight(void)
1048 {
1049         return H_LIST_NORMAL_MENU_ITEM;
1050 }
1051
1052 void
1053 IncomingCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, AppCallInfo* pCallInfo)
1054 {
1055         //call individual methods to show contact number, caller name & photo
1056         SetTextToLabel(phoneNumber, contactLblName);
1057
1058         //fetch contact details based on phone number
1059         String* pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber);
1060         Bitmap* pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber);
1061         ShowCallerPhoto(pPhotoBitmap);
1062
1063         //free resources
1064         if (pDisplayName)
1065         {
1066                 SetTextToLabel(*pDisplayName, nameLblName);
1067                 delete pDisplayName;
1068                 pDisplayName = null;
1069         }
1070
1071         if (pPhotoBitmap)
1072         {
1073                 delete pPhotoBitmap;
1074                 pPhotoBitmap = null;
1075         }
1076 }
1077
1078 void
1079 IncomingCallForm::SetTextToLabel(const String& textToBeSet, const String& lblName)
1080 {
1081         Label* pContactLbl = static_cast<Label*>(GetControl(lblName));
1082         //passing an empty string to SetText fails in label,
1083         //if previously valid text has been set
1084         if (textToBeSet.IsEmpty() == true && pContactLbl->GetText().IsEmpty() == false)
1085         {
1086                 String stringToBeSet(L"");
1087                 pContactLbl->SetText(stringToBeSet);
1088         }
1089
1090         else
1091         {
1092                 pContactLbl->SetText(textToBeSet);
1093         }
1094 }
1095
1096 void
1097 IncomingCallForm::ShowCallerPhoto(const Bitmap* pPhotoId)
1098 {
1099         bool showSmallPhoto = false;
1100         //show photo - for Big Photo Id, Animated Call Image
1101         if (pPhotoId == null)
1102         {
1103                 pPhotoId = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1104         }
1105         else
1106         {
1107                 //Check the size of photo
1108                 // Now checking the condition with && but actually it should be ||
1109                 //But for now keeping it as && because _pContact->GetThubNail() returns image width as
1110                 // height 270 and width = 480 . So all images set thru gallery is show as small image
1111                 if(pPhotoId->GetHeight() <= H_SMALL_PHOTO
1112                                 && pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1113                 {
1114                         showSmallPhoto = true;
1115                 }
1116         }
1117
1118         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL));
1119         if(showSmallPhoto == true)
1120         {
1121                 ShowThumbnailImage(pPhotoId);
1122         }
1123         else
1124         {
1125                 if (pPhotoLbl != null && pPhotoId != null)
1126                 {
1127                         Canvas* pCanvas = new (std::nothrow) Canvas;
1128                         Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1129                         pCanvas->Construct(canvasRect);
1130                         //draw the contact bitmap
1131                         pCanvas->DrawBitmap(canvasRect,*pPhotoId);
1132                         Bitmap* pNewPhotoId = new Bitmap();
1133                         pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1134                         delete pCanvas;
1135
1136                         pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1137                         pPhotoLbl->Invalidate(true);
1138                         delete pNewPhotoId;
1139                 }
1140         }
1141 }
1142
1143 void
1144 IncomingCallForm::ShowThumbnailImage(const Bitmap* pPhotoId)
1145 {
1146         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL));
1147
1148         if (pPhotoLbl != null && pPhotoId != null)
1149         {
1150                 Canvas* pCanvas = new (std::nothrow) Canvas;
1151                 Bitmap* pBackground = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_BACKGROUND,W_CALL_THUMBNAIL,H_CALL_THUMBNAIL);
1152                 Bitmap* pShadow = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_SHADOW,W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW);
1153                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1154                 pCanvas->Construct(canvasRect);
1155                 //draw the back ground
1156                 pCanvas->DrawBitmap(canvasRect,*pBackground);
1157                 //draw shadow (to be enabled after correct shadow image is provided )
1158                 //pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_CALL_THUMBNAIL_SHADOW/2),
1159                         //      (pPhotoLbl->GetBounds().height/2)-(H_CALL_THUMBNAIL_SHADOW/2),W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW),*pShadow);
1160                 //draw the contact bitmap
1161                 pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_SMALL_PHOTO/2),
1162                                 (pPhotoLbl->GetBounds().height/2)-(H_SMALL_PHOTO/2),W_SMALL_PHOTO,H_SMALL_PHOTO),*pPhotoId);
1163                 Bitmap* pNewPhotoId = new Bitmap();
1164                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1165                 delete pCanvas;
1166
1167                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1168                 pPhotoLbl->Invalidate(true);
1169                 delete pNewPhotoId;
1170                 delete pBackground;
1171                 delete pShadow;
1172         }
1173
1174 }
1175
1176 void
1177 IncomingCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
1178 {
1179         //Draw Small Photo and show on small photo label
1180         __pSmallPhotoLabel  = new (std::nothrow) Label();//static_cast<Label*>(GetControl(IDC_SMALL_PHOTO_LABEL));
1181         __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L"");
1182         __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
1183         __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
1184         // Add a Label to the Form
1185         AddControl(*__pSmallPhotoLabel);
1186         __pSmallPhotoLabel->Invalidate(true);
1187 }
1188
1189 void
1190 IncomingCallForm::ShowTimerInfo(const String& timerLblName, const String& textToBeDisplayed)
1191 {
1192         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
1193         if (pTimerLbl != null)
1194         {
1195                 pTimerLbl->SetText(textToBeDisplayed);
1196         }
1197 }
1198
1199 void
1200 IncomingCallForm::SetBitmapToRejectMessageButton(const String& btnName, const String& bgBitmap
1201                                                                                                 , const String& arrowBitmap, const String& messageIconBitmap, bool isButtonInPanel, bool setButtonPressBitmap)
1202 {
1203
1204         Button* pButton = null;
1205         if (isButtonInPanel == false)
1206         {
1207                 pButton = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1208         }
1209         else
1210         {
1211                 Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
1212                 pButton = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
1213         }
1214         Bitmap* pHoldBmp = null;
1215         Canvas* pCanvas = null;
1216         pCanvas = new (std::nothrow) Canvas();
1217         pCanvas->Construct(Rectangle(0,0,pButton->GetBounds().width,pButton->GetBounds().height));
1218         //set bitmap to button
1219         pHoldBmp = AppUtility::GetBitmapFromResourcesN(bgBitmap);
1220         if (pHoldBmp)
1221         {
1222                 //scale bitmap to predefined size
1223                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1224                 pHoldBmp->Scale(Dimension(pButton->GetBounds().width, H_MESSAGE_BG_BITMAP));
1225                 pCanvas->DrawBitmap(Rectangle(Point(0, 0), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1226         }
1227         delete pHoldBmp;
1228         pHoldBmp = null;
1229         pHoldBmp = AppUtility::GetBitmapFromResourcesN(arrowBitmap);
1230         if (pHoldBmp)
1231         {
1232                 //scale bitmap to predefined size
1233                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1234                 pHoldBmp->Scale(Dimension(W_ARROW_BITMAP, H_ARROW_BITMAP));
1235                 pCanvas->DrawBitmap(Rectangle(Point((pButton->GetBounds().width / 2 - 17/*Width of arrow / 2*/), 0), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1236         }
1237         delete pHoldBmp;
1238         pHoldBmp = null;
1239
1240
1241
1242         //set button name
1243         String holdBtnName = AppUtility::GetResourceString(btnName);
1244         FloatDimension textDimension;
1245         if (!holdBtnName.IsEmpty())
1246         {
1247                 Font font;
1248                 font.Construct(FONT_STYLE_PLAIN, pButton->GetTextSize());
1249                 font.GetTextExtent(holdBtnName, holdBtnName.GetLength(), textDimension);
1250                 textDimension.height = textDimension.height + font.GetDescender();
1251                 TextElement* pTextElement = new (std::nothrow) TextElement();
1252                 pTextElement->Construct(holdBtnName);
1253                 Color textColor(249, 249, 249);
1254                 if (setButtonPressBitmap)
1255                 {
1256                         textColor.SetAlpha(255);
1257                 }
1258                 else
1259                 {
1260                         textColor.SetAlpha(127);
1261                 }
1262
1263                 pTextElement->SetTextColor(textColor);
1264                 pTextElement->SetFont(font);
1265
1266                 EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
1267                 pEnrichedText->Construct(textDimension);
1268                 pEnrichedText->Add(*pTextElement);
1269                 //Point textPos((X_MESSAGE_BITMAP + pHoldBmp->GetWidth() + MESSAGE_TEXT_X_MARGIN), Y_MESSAGE_BITMAP + MESSAGE_TEXT_Y_MARGIN);
1270                 Point textPos((pButton->GetWidth()/2)-(textDimension.width/2) + MESSAGE_TEXT_X_MARGIN,Y_MESSAGE_BITMAP + MESSAGE_TEXT_Y_MARGIN);
1271                 pCanvas->DrawText(textPos, *pEnrichedText);
1272                 // Cleans up
1273                 pEnrichedText->RemoveAll(true);
1274                 delete pEnrichedText;
1275         }
1276
1277
1278         pHoldBmp = AppUtility::GetBitmapFromResourcesN(messageIconBitmap);
1279         if (pHoldBmp)
1280         {
1281                 //scale bitmap to predefined size
1282                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1283                 pHoldBmp->Scale(Dimension(W_MESSAGE_BITMAP, H_MESSAGE_BITMAP));
1284                 //pCanvas->DrawBitmap(Rectangle(Point(X_MESSAGE_BITMAP, Y_MESSAGE_BITMAP), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1285                 pCanvas->DrawBitmap(Rectangle(Point((pButton->GetWidth()/2)-(textDimension.width/2) -pHoldBmp->GetWidth(), Y_MESSAGE_BITMAP), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1286         }
1287
1288         //set background bitmpa to button
1289         Bitmap* pActualBgBmp = new (std::nothrow) Bitmap();
1290         pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds());
1291         if (setButtonPressBitmap)
1292         {
1293                 pButton->SetPressedBackgroundBitmap(*pActualBgBmp);
1294         }
1295         else
1296         {
1297                 pButton->SetNormalBackgroundBitmap(*pActualBgBmp);
1298         }
1299         delete pActualBgBmp;
1300         delete pHoldBmp;
1301         delete pCanvas;
1302 }
1303
1304 /*!In OnTouchPressed, It creates the three visual elements and starts the animation of opacity and rotation variation
1305   */
1306 void
1307 IncomingCallForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1308 {
1309         //__pCallPresentor->StopAlert();
1310         if (currentPosition.x < VALID_TOUCH_X_OFFSET && currentPosition.y < VALID_TOUCH_Y_OFFSET)
1311         {
1312                 Rectangle rect = source.GetBounds();
1313                 if (source.Equals(*__pAcceptLabel))
1314                 {
1315                         __isAnswerCallStarted = true;
1316                         __isRejectCallStarted = false;
1317                 }
1318                 else if (source.Equals(*__pRejectLabel))
1319                 {
1320                         __isAnswerCallStarted = false;
1321                         __isRejectCallStarted = true;
1322                 }
1323                 else
1324                 {
1325                         // touch event between the 2 labels. So Do nothing
1326                         return;
1327                 }
1328
1329         }
1330 }
1331
1332 // On Touch released, the animation and the visual elements disappear
1333 void
1334 IncomingCallForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1335 {
1336         AppLogDebug("%d",currentPosition.x);
1337         if (__isAnswerCallStarted == true)
1338         {
1339                 if (currentPosition.x > __pRejectLabel->GetBounds().x)
1340                 {
1341                         //Right reject icon
1342                         if(__pRejectFinalVisElem == null)
1343                         {
1344                                 __pRejectFinalVisElem = new (std::nothrow) VisualElement();
1345                                 __pRejectFinalVisElem->Construct();
1346                                 __pRejectFinalVisElem->SetName(IDI_REJECT_FINAL_VISUAL_ELE_NAME);
1347                         }
1348                         __pRejectFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1349                         __pRejectFinalVisElem->SetShowState(true);
1350                         __pRejectFinalVisElem->SetOpacity(1.00f);
1351                         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_FINAL_VISUAL_ELE_NAME,true) == null)
1352                         {
1353                                 AppLogDebug("AttachChild __pRejectFinalVisElem");
1354                                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectFinalVisElem);
1355                         }
1356                         Canvas* pCanvas = __pRejectFinalVisElem->GetCanvasN();
1357                         if(pCanvas != null)
1358                         {
1359                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1360                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1361                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, W_DIAL_LABEL), *__pAcceptCircle);
1362                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial);
1363                                 delete pCanvas;
1364                         }
1365
1366                         __pAcceptVisElem->SetOpacity(0.0f);
1367                         //fetch already active call list
1368                         ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
1369                         if (pCallList != null && pCallList->GetCount() > 0)
1370                         {
1371                                 //then atleast 1 active call exist.
1372                                 AppCallInfo phnCallInfo;
1373                                 pCallList->GetAt(0,phnCallInfo);
1374                                 //Check if only 1 call exist and it is on Hold
1375                                 if(pCallList->GetCount() == 1 && phnCallInfo.IsOnHold())
1376                                 {
1377                                         //directly accept call
1378                                         __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1379                                 }
1380                                 else
1381                                 {
1382                                         //Either 1 call exist and not "on Hold".
1383                                         //Or 2 calls exist.
1384                                         if(__pOptionPopup != null)
1385                                         {
1386                                                 delete __pOptionPopup;
1387                                                 __pOptionPopup = null;
1388                                         }
1389                                         __pOptionPopup = new (std::nothrow) CallOptionPopup(*this,*(__pCallPresentor));
1390                                         __pOptionPopup->Initialize();
1391                                         __pOptionPopup->SetShowState(true);
1392                                         __pOptionPopup->Draw();
1393                                         __pOptionPopup->Show();
1394                                 }
1395                                 pCallList->RemoveAll();
1396                         }
1397                         else
1398                         {
1399                                 //no active call - Accept the  incoming call
1400                                 __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1401                         }
1402                         delete pCallList;
1403                         pCallList = null;
1404                 }
1405                 else
1406                 {
1407                         __pAcceptVisElem->SetOpacity(1.0f);
1408                         __pRejectVisElem->SetOpacity(1.00f);
1409
1410                 }
1411         }
1412         else if (__isRejectCallStarted == true)
1413         {
1414                 if (currentPosition.x < ((__pAcceptLabel->GetBounds().x + __pAcceptLabel->GetWidth())- __pRejectLabel->GetBounds().x))
1415                 {
1416                         //left dial icon
1417                         if(__pAcceptFinalVisElem == null)
1418                         {
1419                                 __pAcceptFinalVisElem = new (std::nothrow) VisualElement();
1420                                 __pAcceptFinalVisElem->Construct();
1421                                 __pAcceptFinalVisElem->SetName(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME);
1422                         }
1423                         __pAcceptFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1424                         __pAcceptFinalVisElem->SetOpacity(1.0f);
1425
1426
1427                         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME,true) == null)
1428                         {
1429                                 AppLogDebug("AttachChild __pAcceptFinalVisElem");
1430                                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptFinalVisElem);
1431                         }
1432                         Canvas* pCanvas = __pAcceptFinalVisElem->GetCanvasN();
1433                         if(pCanvas != null)
1434                         {
1435                                 AppLogDebug("__pAcceptFinalVisElem drawing");
1436                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1437                                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
1438                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1439                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle);
1440                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial);
1441                                 delete pCanvas;
1442                         }
1443                         __pRejectVisElem->SetOpacity(0.0f);
1444                         //Reject the call
1445                         __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo);
1446                 }
1447                 else
1448                 {
1449                         __pAcceptVisElem->SetOpacity(1.0f);
1450                         __pRejectVisElem->SetOpacity(1.00f);
1451
1452                 }
1453         }
1454         __isAnswerCallStarted = false;
1455         __isRejectCallStarted = false;
1456 }
1457
1458 void
1459 IncomingCallForm::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1460 {
1461         if (__isAnswerCallStarted == true)
1462         {
1463                 if (currentPosition.x > 170 && currentPosition.x < 578)
1464                 {
1465                         if (currentPosition.x > REJECT_LABEL_X_OFFSET)
1466                         {
1467                                 __pRejectVisElem->SetOpacity(0.60f);
1468                                 __pAcceptVisElem->SetOpacity(0.60f);
1469                         }
1470                         else
1471                         {
1472                                 __pRejectVisElem->SetOpacity(1.0f);
1473                                 __pAcceptVisElem->SetOpacity(1.0f);
1474                         }
1475
1476                 }
1477         }
1478         if (__isRejectCallStarted == true)
1479         {
1480                 if (currentPosition.x < 0 && currentPosition.x > -522)
1481                 {
1482                         if (currentPosition.x < ACCEPT_LABEL_RELATIVE_POS)
1483                         {
1484                                 __pRejectVisElem->SetOpacity(0.60f);
1485                                 __pAcceptVisElem->SetOpacity(0.60f);
1486                         }
1487                         else
1488                         {
1489                                 __pRejectVisElem->SetOpacity(1.0f);
1490                                 __pAcceptVisElem->SetOpacity(1.0f);
1491                         }
1492                 }
1493         }
1494 }
1495
1496 void
1497 IncomingCallForm::OnItemSelected(int itemIndex)
1498 {
1499         ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1500         pArgs->Construct();
1501
1502         //display name, mobile number
1503         Integer* argIndex = new (std::nothrow) Integer(itemIndex);
1504         pArgs->Add(argIndex);
1505         SendUserEvent(REQUEST_ITEM_SELECTED,pArgs);
1506 }
1507
1508 void
1509 IncomingCallForm::HandleMultipleCallSelection(int itemIndex)
1510 {
1511         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null)
1512         {
1513                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
1514         }
1515         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null)
1516         {
1517                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
1518         }
1519
1520         __pAcceptVisElem->SetOpacity(1.0f);
1521         __pRejectVisElem->SetOpacity(1.00f);
1522
1523         if (__pRejectFinalVisElem != null)
1524         {
1525                 __pRejectFinalVisElem->Destroy();
1526                 __pRejectFinalVisElem = null;
1527         }
1528         if (__pAcceptFinalVisElem != null)
1529         {
1530                 __pAcceptFinalVisElem->Destroy();
1531                 __pAcceptFinalVisElem = null;
1532         }
1533
1534         if (__pOptionPopup)
1535         {
1536                 delete __pOptionPopup;
1537                 __pOptionPopup = null;
1538         }
1539         //accept call
1540         if(itemIndex != IDA_BUTTON_CANCEL_OPTIONS_POPUP)
1541         {
1542                 __pCallPresentor->AcceptIncomingCall(CallAnsweringOptions(itemIndex),__incomingCallHandle);
1543         }
1544 }
1545
1546 void
1547 IncomingCallForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1548 {
1549         switch(requestId)
1550         {
1551                 case REQUEST_ITEM_SELECTED:
1552                 {
1553                         if(pArgs != null)
1554                         {
1555                                 Integer *index = static_cast<Integer*>(pArgs->GetAt(0));
1556                                 if(index != null)
1557                                 {
1558                                         HandleMultipleCallSelection(index->ToInt());
1559                                 }
1560                         }
1561                 }
1562                 break;
1563         }
1564 }
1565
1566 void
1567 IncomingCallForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1568 {
1569         AppLogDebug("Enter");
1570         HideRejectPanel();
1571         //SetFocus();
1572         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1573         if (pButtonRejectMessage)
1574         {
1575                 pButtonRejectMessage->SetShowState(true);
1576                 pButtonRejectMessage->Invalidate(true);
1577                 pButtonRejectMessage->Draw();
1578         }
1579         RequestRedraw(true);
1580
1581 }
1582
1583 void
1584 IncomingCallForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1585 {
1586
1587         Layout* pLayout = GetLayoutN();
1588         if (pLayout != null)
1589         {
1590                 pLayout->Update();
1591         }
1592
1593         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
1594         if(pKeysPanel->GetShowState() == true)
1595         {
1596                 //HideRejectMessagePanel();
1597                 //ShowRejectMessagePanel();
1598                 SetRejectMessagePanelBounds();
1599         }
1600
1601         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1602         if (pButtonRejectMessage != null)
1603         {
1604                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1605                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, false);
1606                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1607                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, true);
1608                 pButtonRejectMessage->Invalidate(true);
1609         }
1610
1611         Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
1612         if (pButtonReject != null)
1613         {
1614                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1615                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, false);
1616                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1617                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, true);
1618                 FloatRectangle allignedrect = CoordinateSystem::AlignToDevice(pButtonReject->GetBoundsF());
1619                 pButtonReject->SetBounds(allignedrect);
1620                 pButtonReject->Invalidate(true);
1621
1622         }
1623 }
1624
1625 void
1626 IncomingCallForm::OnForeground(void)
1627 {
1628         AppLogDebug("Enter");
1629         //This is done so that when in IncomingCallForm and calloptionpopup is shown , now if
1630         // focus goes away from popup by pressing cancel key from the host keyboard the focus shouldnt get lost
1631         // but should focus the Reject message button immediately.
1632 //      Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1633 //Commented for bug N_SE-52277
1634         //pButtonRejectMessage->SetFocus();
1635         //pButtonRejectMessage->Invalidate(true);
1636         __pCallPresentor->OnAppForeground();
1637 }
1638
1639 void
1640 IncomingCallForm::OnScreenOff(void)
1641 {
1642         __pCallPresentor->StopAlert();
1643 }
1644
1645 void
1646 IncomingCallForm::CallDisconnected(void)
1647 {
1648
1649         //check if no call option popup is shown, then remain on incoming call screen.
1650         //As user has neither accepted nor rejected incoming call.
1651         if ((__pOptionPopup == null) || (__pOptionPopup->GetShowState() == false))
1652         {
1653                 //Resume the alert when there is an incoming call and the already active call is disconnected
1654                 //Here we start playing the ringtone again
1655                 AppCallInfo* pIncomingCall = __pCallPresentor->GetIncomingCallHandle();
1656                 if(pIncomingCall != null)
1657                 {
1658                         __pCallPresentor->ResumeAlert(*pIncomingCall);
1659                 }
1660                 return;
1661         }
1662
1663         //fetch already active call list and show updated option popup
1664         ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
1665         if (pCallList != null && pCallList->GetCount() > 0)
1666         {
1667                 //then atleast 1 active call exist.
1668                 AppCallInfo phnCallInfo;
1669                 pCallList->GetAt(0,phnCallInfo);
1670                 //Check if only 1 call exist and it is on Hold
1671                 if(pCallList->GetCount() == 1 && phnCallInfo.IsOnHold())
1672                 {
1673                         //directly accept call
1674                         __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1675                 }
1676                 else
1677                 {
1678                         //Either 1 call exist and not "on Hold".
1679                         //Or 2 calls exist.
1680                         if(__pOptionPopup != null)
1681                         {
1682                                 delete __pOptionPopup;
1683                                 __pOptionPopup = null;
1684                         }
1685                         __pOptionPopup = new (std::nothrow) CallOptionPopup(*this,*(__pCallPresentor));
1686                         __pOptionPopup->Initialize();
1687                         __pOptionPopup->SetShowState(true);
1688                         __pOptionPopup->Draw();
1689                         __pOptionPopup->Show();
1690                         AppCallInfo* pIncomingCall = __pCallPresentor->GetIncomingCallHandle();
1691                         if(pIncomingCall != null)
1692                         {
1693                                 //Resume the alert when there is an incoming call and the already active call is disconnected
1694                                 //Here we start playing the ringtone again
1695                                 __pCallPresentor->ResumeAlert(*pIncomingCall);
1696                         }
1697                 }
1698                 pCallList->RemoveAll();
1699         }
1700         else
1701         {
1702                 //no active call - Accept the  incoming call
1703                 __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1704         }
1705         delete pCallList;
1706         pCallList = null;
1707 }