Fixed the jira issue.(N_SE-36843)
[apps/osp/Contacts.git] / src / CtContactDetailsForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
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        CtContactDetailsForm.cpp
19  * @brief       This is the implementation file for the ContactDetailsForm class.
20  */
21
22 #include <FApp.h>
23 #include <FBase.h>
24 #include <FMedia.h>
25 #include <FSocial.h>
26 #include "CtContactDetailsForm.h"
27 #include "CtContactPresentationModel.h"
28 #include "CtContactValueListItemProvider.h"
29 #include "CtContactsApp.h"
30 #include "CtResourceManager.h"
31 #include "CtSceneRegister.h"
32 #include "CtTypes.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Base::Utility;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Media;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43 using namespace Tizen::Social;
44
45 static const int IDA_FOOTER_EDIT = 10;
46 static const int IDA_FOOTER_DELETE = 11;
47 static const int IDA_FOOTER_MORE = 12;
48 static const int IDA_FOOTER_ADD = 13;
49 static const int IDA_VOICE_CALL = 20;
50 static const int IDA_MESSAGE = 21;
51 static const int IDA_VIDEO_CALL = 22;
52 static const int IDA_CONTEXTMENU_SHARE_EMAIL = 30;
53 static const int IDA_CONTEXTMENU_SHARE_MESSAGE = 31;
54 static const int IDA_BUTTON_RINGTONE_CLEAR = 40;
55 static const int IDA_BUTTON_SHARE_NAME_CARD = 50;
56 static const int IDA_POPUP_CLOSE = 60;
57 static const int IDA_INVALID_FILE_POPUP_CLOSE = 61;
58 static const int IDA_MORE_DEFAULT_NUMBER = 70;
59
60 static const wchar_t* IDB_DETAILS_FAVORITE_ON = L"00_icon_favorite_on.png";
61 static const wchar_t* IDB_DETAILS_FAVORITE_OFF = L"00_icon_favorite_off.png";
62 static const wchar_t* IDB_DETAILS_RESET_NORMAL = L"00_button_refresh.png";
63 static const wchar_t* IDB_DETAILS_RESET_PRESSED = L"00_button_refresh_press.png";
64 static const wchar_t* IDB_CIRCLE_BUTTON_NORMAL = L"C02_circle_button.png";
65 static const wchar_t* IDB_CIRCLE_BUTTON_PRESSED = L"C02_circle_button_press.png";
66 static const wchar_t* IDB_CALL_NORMAL = L"C02_circle_icon_call.png";
67 static const wchar_t* IDB_CALL_PRESSED = L"C02_circle_icon_call_press.png";
68 static const wchar_t* IDB_SMS_NORMAL = L"C02_circle_icon_sms.png";
69 static const wchar_t* IDB_SMS_PRESSED = L"C02_circle_icon_sms_press.png";
70 static const wchar_t* IDB_VIDEO_CALL_NORMAL = L"C02_circle_icon_vt-call.png";
71 static const wchar_t* IDB_VIDEO_CALL_PRESSED = L"C02_circle_icon_vt-call_press.png";
72 static const wchar_t* IDB_MORE_NORMAL = L"00_icon_more.png";
73 static const wchar_t* IDB_MORE_PRESSED = L"00_icon_more_press.png";
74
75 static const wchar_t* FAVORITE_LABEL = L"FavoriteLabel";
76
77 static const int Y_THUMBNAIL = 34;
78 static const int H_THUMBNAIL = 360;
79 static const int X_MAIN_INFO = 26;
80 static const int H_NAME = 70;
81 static const int H_SUB_INFO = 40;
82 static const int H_SUB_INFO_DIVIDER = 6;
83 static const int H_DEFAULT_NUMBER = 50;
84 static const int H_QUICK_BUTTON_DIVIDER = 42;
85 #if __SUPPORT_VIDEO_CALL
86 static const int W_QUICK_BUTTON_GAP = 115;
87 static const int X_QUICK_BUTTON = 38;
88 #else
89 static const int W_QUICK_BUTTON_GAP = 148;
90 static const int X_QUICK_BUTTON = 148;
91 #endif
92 static const int H_QUICK_BUTTON = 138;
93 static const int Y_FAVORITE = 10;
94 static const int H_FAVORITE = 45;
95 static const int W_FAVORITE_GAP = 26;
96 static const int W_GROUP_STYLE_MARGIN = 16;
97 static const int W_TEXT_MARGIN = 26;
98 static const int W_TYPE = 160;
99 static const int H_ITEM = 112;
100 static const int H_ITEM_DOUBLE_LINE = 140;
101 static const int H_ADDITIONAL_ITEM = 54;
102 static const int Y_ITEM_TITLE = 22;
103 static const int H_ITEM_TITLE = 42;
104 static const int H_ITEM_VALUE = 54;
105 static const int H_ICON = 74;
106 static const int Y_BUTTON = 20;
107 static const int H_BUTTON = 72;
108 static const int H_BUTTON_CONTAINER = 132;
109 static const int W_BUTTON_GAP = 18;
110
111 static const int W_POPUP = 688;
112 static const int H_POPUP = 532;
113 static const int H_INVALID_FILE_POPUP = 200;
114 static const int H_POPUP_LIST_VIEW = 338;
115 static const int Y_POPUP_BUTTON = 358;
116 static const int H_POPUP_BUTTON = 74;
117 static const int W_POPUP_BUTTON = 394;
118 static const int Y_POPUP_TEXT_LABEL = 12;
119 static const int H_POPUP_TEXT_LABEL = 90;
120 static const int X_MORE = 55;
121
122 static const int SUB_INDEX_MASK = 0xF000;
123
124 static const unsigned int COLOR_TABLE_BG = Color32<248, 246, 239>::Value;
125 static const unsigned int COLOR_ITEM_TITLE = Color32<128, 128, 128>::Value;
126 static const unsigned int COLOR_ITEM_VALUE = Color32<0, 0, 0>::Value;
127 static const unsigned int COLOR_ITEM_TYPE = Color32<128, 128, 128>::Value;
128 static const unsigned int COLOR_OTHER_NUMBER = Color32<0, 0, 0>::Value;
129 static const unsigned int COLOR_NAME = Color32<59, 115, 182>::Value;
130 static const unsigned int COLOR_GROUP_STYLE = Color32<240, 237, 232>::Value;
131 static const unsigned int COLOR_POPUP_TEXT = Color32<0, 0, 0>::Value;
132
133 static const int FONT_SIZE_NAME = 56;
134 static const int FONT_SIZE_SUB_INFO = 32;
135 static const int FONT_SIZE_MAIN_TEXT = 44;
136 static const int FONT_SIZE_SUB_TEXT = 32;
137 static const int FONT_SIZE_POPUP_TEXT = 38;
138
139 static const wchar_t* INPUT_KEY_CALL_TYPE = L"http://tizen.org/appcontrol/data/call/type";
140 static const wchar_t* INPUT_KEY_MESSAGE_TYPE = L"http://tizen.org/appcontrol/data/message/type";
141 static const wchar_t* INPUT_KEY_MESSAGE_TO = L"http://tizen.org/appcontrol/data/to";
142 static const wchar_t* INPUT_KEY_SELECTION_MODE = L"http://tizen.org/appcontrol/data/selection_mode";
143 static const wchar_t* INPUT_DATA_SELECTION_MODE_SINGLE = L"single";
144 static const wchar_t* INPUT_MIME_TYPE_AUDIO = L"audio/*";
145 static const wchar_t* INPUT_URI_TEL = L"tel:";
146 static const wchar_t* INPUT_TYPE_VIDEO = L"video";
147 static const wchar_t* INPUT_TYPE_VOICE = L"voice";
148 static const wchar_t* INPUT_TYPE_SMS = L"sms";
149 static const wchar_t* INPUT_TYPE_MMS = L"mms";
150 static const wchar_t* OUTPUT_KEY_SELECTED = L"http://tizen.org/appcontrol/data/selected";
151 static const wchar_t* KEY_VIEW_TYPE = L"viewType";
152 static const wchar_t* KEY_VIEW_TYPE_VCF = L"path";
153 static const wchar_t* KEY_VIEW_TYPE_CONTACT_ID = L"contactId";
154 static const wchar_t* VALUE_VIEW_TYPE_VCF = L"vcf";
155 static const wchar_t* VALUE_VIEW_TYPE_CONTACT = L"contact";
156
157 ContactDetailsForm::ContactDetailsForm(void)
158 : __pAppControl(null)
159 , __pTableView(null)
160 , __pContextMenuCall(null)
161 , __pContextMenuShare(null)
162 , __pContextMenuMore(null)
163 , __pDefaultSelectorPopup(null)
164 , __pInvalidFilePopup(null)
165 , __pItemList(null)
166 , __pPresentationModel(null)
167 , __scrolledDistance(0)
168 {
169 }
170
171 ContactDetailsForm::~ContactDetailsForm(void)
172 {
173 }
174
175 void
176 ContactDetailsForm::Initialize(void)
177 {
178         Construct(L"IDL_CONTACT_DETAILS_FORM");
179 }
180
181 result
182 ContactDetailsForm::OnInitializing(void)
183 {
184         Footer* pFooter = GetFooter();
185         pFooter->AddActionEventListener(*this);
186         SetFormBackEventListener(this);
187
188         __pTableView = new (std::nothrow) TableView();
189         __pTableView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
190         __pTableView->SetItemProvider(this);
191         __pTableView->AddTableViewItemEventListener(*this);
192         __pTableView->SetBackgroundColor(COLOR_TABLE_BG);
193         __pTableView->AddTouchEventListener(*this);
194         __pTableView->AddScrollEventListener(*this);
195         AddControl(*__pTableView);
196
197         __pContextMenuCall = new (std::nothrow) ContextMenu();
198         __pContextMenuCall->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
199         __pContextMenuCall->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_CALL"), IDA_VOICE_CALL);
200         __pContextMenuCall->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"), IDA_MESSAGE);
201 #if     __SUPPORT_VIDEO_CALL
202         __pContextMenuCall->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_VIDEO_CALL"), IDA_VIDEO_CALL);
203 #endif
204         __pContextMenuCall->AddActionEventListener(*this);
205
206         __pContextMenuShare = new (std::nothrow) ContextMenu();
207         __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
208         __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), IDA_CONTEXTMENU_SHARE_EMAIL);
209         __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"), IDA_CONTEXTMENU_SHARE_MESSAGE);
210         __pContextMenuShare->AddActionEventListener(*this);
211
212         __pContextMenuMore = new (std::nothrow) ContextMenu();
213         __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST);
214         __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_MARK_AS_DEFAULT_NUMBER"), IDA_MORE_DEFAULT_NUMBER);
215         __pContextMenuMore->AddActionEventListener(*this);
216
217         __pItemList = new (std::nothrow) ArrayListT<int>();
218         __pItemList->Construct();
219
220         __pPresentationModel = new (std::nothrow) ContactPresentationModel();
221         __pPresentationModel->Construct();
222         __pPresentationModel->AddContactChangeListener(*this);
223
224         return E_SUCCESS;
225 }
226
227 result
228 ContactDetailsForm::OnTerminating(void)
229 {
230         delete __pAppControl;
231         delete __pContextMenuCall;
232         delete __pContextMenuShare;
233         delete __pContextMenuMore;
234
235         if (__pItemList != null)
236         {
237                 __pItemList->RemoveAll();
238                 delete __pItemList;
239         }
240
241         if (__pPresentationModel != null)
242         {
243                 __pPresentationModel->RemoveContactChangeListener(*this);
244                 delete __pPresentationModel;
245         }
246
247         delete __pDefaultSelectorPopup;
248         delete __pInvalidFilePopup;
249
250         return E_SUCCESS;
251 }
252
253 void
254 ContactDetailsForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
255 {
256         AppLog("ContactDetailsForm::OnActionPerformed(), actionId %d", actionId);
257
258         result r = E_SUCCESS;
259         SceneManager* pSceneManager = SceneManager::GetInstance();
260
261         switch (actionId)
262         {
263         case IDA_FOOTER_EDIT:
264                 {
265                         ArrayList* pList = new (std::nothrow) ArrayList();
266                         pList->Construct();
267                         pList->Add(*(new (std::nothrow) Integer(__pPresentationModel->GetContactId())));
268                         r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
269                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go forward", GetErrorMessage(r));
270                 }
271                 break;
272         case IDA_FOOTER_DELETE:
273                 {
274                         int modalResult = 0;
275                         MessageBox deleteMessageBox;
276                         deleteMessageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"), MSGBOX_STYLE_YESNO);
277                         deleteMessageBox.ShowAndWait(modalResult);
278
279                         if (modalResult == MSGBOX_RESULT_YES)
280                         {
281                                 r = __pPresentationModel->RemoveContact();
282                                 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to remove contact", GetErrorMessage(r));
283                         }
284                 }
285                 break;
286         case IDA_FOOTER_MORE:
287                 {
288                         __pContextMenuMore->SetShowState(true);
289                         __pContextMenuMore->Show();
290                 }
291                 break;
292         case IDA_FOOTER_ADD:
293                 {
294                         ArrayList* pList = new (std::nothrow) ArrayList();
295                         pList->Construct();
296                         pList->Add(*(new (std::nothrow) Integer(INVALID_RECORD_ID)));
297                         pList->Add(*(new (std::nothrow) String(__pPresentationModel->GetVcfPath())));
298                         r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
299                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go forward", GetErrorMessage(r));
300                 }
301                 break;
302         case IDA_MORE_DEFAULT_NUMBER:
303                 {
304                         ShowDefaultSelectorPopup();
305                 }
306                 break;
307         case IDA_BUTTON_RINGTONE_CLEAR:
308                 {
309                         __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, String());
310                         __pPresentationModel->UpdateContact();
311                         __pTableView->RefreshItem(__pItemList->GetCount() - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
312                 }
313                 break;
314         case IDA_VOICE_CALL:
315                 {
316                         r = LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, INPUT_TYPE_VOICE, source.GetName());
317                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
318                 }
319                 break;
320         case IDA_MESSAGE:
321                 {
322                         r = LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, INPUT_TYPE_SMS, source.GetName());
323                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
324                 }
325                 break;
326         case IDA_VIDEO_CALL:
327                 {
328                         r = LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, INPUT_TYPE_VIDEO, source.GetName());
329                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
330                 }
331                 break;
332         case IDA_CONTEXTMENU_SHARE_EMAIL:
333                 {
334                         r = LaunchAppControl(PROVIDER_ID_EMAIL, OPERATION_ID_COMPOSE);
335                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
336                 }
337                 break;
338         case IDA_CONTEXTMENU_SHARE_MESSAGE:
339                 {
340                         r = LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, INPUT_TYPE_MMS);
341                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
342                 }
343                 break;
344         case IDA_BUTTON_SHARE_NAME_CARD:
345                 {
346                         Point itemPoint;
347                         itemPoint.x = GetClientAreaBounds().width / 2;
348                         itemPoint.y = 0;
349
350                         TableViewItem* pParent = static_cast<TableViewItem*>(source.GetParent());
351                         if (pParent != null)
352                         {
353                                 itemPoint.y = GetClientAreaBounds().y + pParent->GetY() + source.GetY() - __scrolledDistance;
354                         }
355
356                         __pContextMenuShare->SetAnchorPosition(itemPoint);
357                         __pContextMenuShare->SetShowState(true);
358                         __pContextMenuShare->Show();
359                 }
360                 break;
361         case IDA_POPUP_CLOSE:
362                 {
363                         HideDefaultSelectorPopup();
364                 }
365                 break;
366         case IDA_INVALID_FILE_POPUP_CLOSE:
367                 {
368                         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
369
370                         result r = AppControlProviderManager::GetInstance()->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, null);
371                         AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
372
373                         UiApp::GetInstance()->Terminate();
374                 }
375                 break;
376         default:
377                 break;
378         }
379 }
380
381 void
382 ContactDetailsForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
383 {
384         if (__appControlViewType.IsEmpty() == false)
385         {
386                 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
387                 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
388
389                 result r = pAppManager->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_CANCELED, null);
390                 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
391
392                 UiApp::GetInstance()->Terminate();
393         }
394         else
395         {
396                 SceneManager* pSceneManager = SceneManager::GetInstance();
397
398                 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
399                 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
400         }
401 }
402
403 void
404 ContactDetailsForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, IList* pArgs)
405 {
406         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
407         TryReturnVoid(pContactsApp != null, "Unable to cast UiApp to ContactsApp");
408
409         pContactsApp->AddContactsAppChangeEventListener(*this);
410
411         if (previousSceneId == IDSCN_GROUP_SELECTOR || previousSceneId == IDSCN_GROUP_EDITOR)
412         {
413                 if (pArgs == null)
414                 {
415                         return;
416                 }
417
418                 Integer* pArgument = null;
419                 __pPresentationModel->RemoveContactFromAllCategories();
420                 IEnumerator* pEnum = pArgs->GetEnumeratorN();
421                 while (pEnum->MoveNext() == E_SUCCESS)
422                 {
423                         pArgument = static_cast<Integer*>(pEnum->GetCurrent());
424                         if (pArgument != null)
425                         {
426                                 __pPresentationModel->AddContactToCategory(pArgument->ToInt());
427                         }
428                 }
429                 delete pEnum;
430
431                 __pTableView->RefreshItem(__pItemList->GetCount() - 2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
432         }
433         else if (previousSceneId == IDSCN_CONTACT_EDITOR && __appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
434         {
435                 InitializeDetailItemList();
436                 __pTableView->UpdateTableView();
437         }
438         else
439         {
440                 if (pArgs == null)
441                 {
442                         return;
443                 }
444
445                 if (pContactsApp->GetOperationId() == OPERATION_ID_VIEW)
446                 {
447                         __pPresentationModel->RemoveContactChangeListener(*this);
448
449                         result r = InitializeAppControl(pArgs);
450
451                         if (IsFailed(r))
452                         {
453                                 pArgs->RemoveAll(true);
454                                 delete pArgs;
455                                 AppLogDebug("Unable to initialize appcontrol");
456
457                                 ShowInvalidFilePopup();
458
459                                 return;
460                         }
461
462                         InitializeDetailItemList();
463                 }
464                 else
465                 {
466                         Integer* pContactId = static_cast<Integer*>(pArgs->GetAt(0));
467                         if (pContactId != null)
468                         {
469                                 __pPresentationModel->SetContactId(pContactId->ToInt());
470                                 InitializeDetailItemList();
471                         }
472                 }
473                 __pTableView->UpdateTableView();
474         }
475
476         if (pArgs != null)
477         {
478                 pArgs->RemoveAll(true);
479                 delete pArgs;
480         }
481 }
482
483 result
484 ContactDetailsForm::InitializeAppControl(Tizen::Base::Collection::IList* pArgs)
485 {
486         if (pArgs == null)
487         {
488                 return E_FAILURE;
489         }
490
491         result r = E_SUCCESS;
492
493         String* pArgStringType = null;
494         String* pArgStringValue = null;
495         String keyViewType;
496         String keyValue;
497         String valueViewType;
498         String value;
499
500         pArgStringType = static_cast<String*>(pArgs->GetAt(0));
501         pArgStringValue = static_cast<String*>(pArgs->GetAt(1));
502
503         TryReturn(pArgStringType != null && pArgStringValue != null, E_FAILURE, "[E_FAILURE] Unable to initialize appcontrol");
504
505         ParseAppControlArgument(*pArgStringType, keyViewType, valueViewType);
506         ParseAppControlArgument(*pArgStringValue, keyValue, value);
507
508         if (keyViewType.Equals(KEY_VIEW_TYPE, false))
509         {
510                 if (valueViewType.Equals(VALUE_VIEW_TYPE_CONTACT, false))
511                 {
512                         if (keyValue.Equals(KEY_VIEW_TYPE_CONTACT_ID, false))
513                         {
514                                 RecordId contactId;
515                                 Integer::Parse(value, contactId);
516                                 r = __pPresentationModel->SetContactId(contactId);
517                                 __appControlViewType = valueViewType;
518
519                                 Footer* pFooter = GetFooter();
520                                 pFooter->RemoveAllItems();
521
522                                 FooterItem footerItemEdit;
523                                 footerItemEdit.Construct(IDA_FOOTER_EDIT);
524                                 footerItemEdit.SetText(ResourceManager::GetString(L"IDS_COM_SK_EDIT"));
525                                 pFooter->AddItem(footerItemEdit);
526
527                                 FooterItem footerItemDelete;
528                                 footerItemDelete.Construct(IDA_FOOTER_DELETE);
529                                 footerItemDelete.SetText(ResourceManager::GetString(L"IDS_COM_SK_DELETE"));
530                                 pFooter->AddItem(footerItemDelete);
531
532                                 __pPresentationModel->AddContactChangeListener(*this);
533                         }
534                         else
535                         {
536                                 AppLogDebug("Invalid KEY(contactId) of AppControl[VIEW]. [%ls] has been input", keyValue.GetPointer());
537                                 r = E_FAILURE;
538                         }
539                 }
540                 else if (valueViewType.Equals(VALUE_VIEW_TYPE_VCF, false))
541                 {
542                         if (keyValue.Equals(KEY_VIEW_TYPE_VCF, false))
543                         {
544                                 r = __pPresentationModel->SetVcfPath(value);
545
546                                 __appControlViewType = valueViewType;
547                                 Footer* pFooter = GetFooter();
548                                 pFooter->RemoveAllItems();
549                                 pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
550
551                                 FooterItem footerItemAdd;
552                                 footerItemAdd.Construct(IDA_FOOTER_ADD);
553                                 footerItemAdd.SetText(ResourceManager::GetString(L"IDS_COM_OPT_ADD_TO_CONTACTS"));
554                                 pFooter->AddItem(footerItemAdd);
555                         }
556                         else
557                         {
558                                 AppLogDebug("Invalid KEY(path) of AppControl[VIEW]. [%ls] has been input", keyValue.GetPointer());
559                                 r = E_FAILURE;
560                         }
561                 }
562                 else
563                 {
564                         AppLogDebug("viewType of AppControl[VIEW] should be either vcf or contact. [%ls] has been inpue", keyValue.GetPointer());
565                         r = E_FAILURE;
566                 }
567         }
568         else
569         {
570                 AppLogDebug("Invalid KEY(viewType) of AppControl[VIEW]. [%ls] has been input", keyViewType.GetPointer());
571                 r = E_FAILURE;
572         }
573
574         return r;
575 }
576
577 void
578 ContactDetailsForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
579 {
580         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
581         pContactsApp->RemoveContactsAppChangeEventListener(*this);
582
583         delete __pAppControl;
584         __pAppControl = null;
585 }
586
587 void
588 ContactDetailsForm::InitializeDetailItemList(void)
589 {
590         if (__pItemList->GetCount() > 0)
591         {
592                 __pItemList->RemoveAll();
593         }
594
595         // Default area
596         __pItemList->Add(DETAIL_PROPERTY_MAIN_INFO);
597
598         // Other Phone Numbers
599         Footer* pFooter = GetFooter();
600         pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
601         int otherNumberCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
602         if (otherNumberCount > 1)
603         {
604                 ButtonItem footerItemMore;
605                 footerItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
606                 footerItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, ResourceManager::GetBitmapN(IDB_MORE_NORMAL));
607                 footerItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, ResourceManager::GetBitmapN(IDB_MORE_PRESSED));
608
609                 if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
610                 {
611                         pFooter->SetButton(BUTTON_POSITION_LEFT, footerItemMore);
612                 }
613
614                 for (int subIndex = 0; subIndex < otherNumberCount; subIndex++)
615                 {
616                         if (__pPresentationModel->GetDefaultNumberIndex() != subIndex)
617                         {
618                                 __pItemList->Add(DETAIL_PROPERTY_PHONE_NUMBER + subIndex);
619                         }
620                 }
621         }
622
623         if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL) > 0)
624         {
625                 __pItemList->Add(DETAIL_PROPERTY_EMAIL);
626         }
627
628         if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_ADDRESS) > 0)
629         {
630                 __pItemList->Add(DETAIL_PROPERTY_ADDRESS);
631         }
632
633         if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS) > 0)
634         {
635                 __pItemList->Add(DETAIL_PROPERTY_IM_ADDRESS);
636         }
637
638         if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL) > 0)
639         {
640                 __pItemList->Add(DETAIL_PROPERTY_URL);
641         }
642
643         if (__pPresentationModel->GetValue(DETAIL_PROPERTY_BIRTHDAY).IsEmpty() == false)
644         {
645                 __pItemList->Add(DETAIL_PROPERTY_BIRTHDAY);
646         }
647
648         if (__pPresentationModel->GetValue(DETAIL_PROPERTY_NOTE).IsEmpty() == false)
649         {
650                 __pItemList->Add(DETAIL_PROPERTY_NOTE);
651         }
652
653         __pItemList->Add(DETAIL_PROPERTY_GROUP);
654         __pItemList->Add(DETAIL_PROPERTY_RINGTONE);
655 }
656
657 int
658 ContactDetailsForm::GetItemCount(void)
659 {
660         return __pItemList->GetCount();
661 }
662
663 Tizen::Ui::Controls::TableViewItem*
664 ContactDetailsForm::CreateItem(int itemIndex, int itemWidth)
665 {
666         TableViewItem* pItem = new (std::nothrow) TableViewItem();
667
668         int contentItemIndex = -1;
669         int itemSubIndex = -1;
670         __pItemList->GetAt(itemIndex, contentItemIndex);
671
672         switch (contentItemIndex & SUB_INDEX_MASK)
673         {
674         case DETAIL_PROPERTY_PHONE_NUMBER:
675                 {
676                         itemSubIndex = contentItemIndex - DETAIL_PROPERTY_PHONE_NUMBER;
677                         contentItemIndex = DETAIL_PROPERTY_PHONE_NUMBER;
678                 }
679                 break;
680         case DETAIL_PROPERTY_EMAIL:
681                 {
682                         contentItemIndex = DETAIL_PROPERTY_EMAIL;
683                 }
684                 break;
685         case DETAIL_PROPERTY_IM_ADDRESS:
686                 {
687                         contentItemIndex = DETAIL_PROPERTY_IM_ADDRESS;
688                 }
689                 break;
690         case DETAIL_PROPERTY_ADDRESS:
691                 {
692                         contentItemIndex = DETAIL_PROPERTY_ADDRESS;
693                 }
694                 break;
695         case DETAIL_PROPERTY_URL:
696                 {
697                         contentItemIndex = DETAIL_PROPERTY_URL;
698                 }
699                 break;
700         default:
701                 break;
702         }
703
704         switch (contentItemIndex)
705         {
706         case DETAIL_PROPERTY_MAIN_INFO:
707                 {
708                         AddMainInfo(itemWidth, pItem);
709                 }
710                 break;
711         case DETAIL_PROPERTY_PHONE_NUMBER: // fall through
712         case DETAIL_PROPERTY_EMAIL: // fall through
713         case DETAIL_PROPERTY_ADDRESS: // fall through
714         case DETAIL_PROPERTY_URL: // fall through
715         case DETAIL_PROPERTY_BIRTHDAY: // fall through
716         case DETAIL_PROPERTY_NOTE:
717         case DETAIL_PROPERTY_IM_ADDRESS:
718                 {
719                         AddProperty(itemWidth, pItem, contentItemIndex, itemSubIndex);
720                 }
721                 break;
722         case DETAIL_PROPERTY_GROUP:
723                 {
724                         AddGroup(itemWidth, pItem);
725                 }
726                 break;
727         case DETAIL_PROPERTY_RINGTONE:
728                 {
729                         AddRingTone(itemWidth, pItem);
730                 }
731                 break;
732         default:
733                 {
734                         delete pItem;
735                         pItem = null;
736                 }
737                 break;
738         }
739
740         return pItem;
741 }
742
743 bool
744 ContactDetailsForm::DeleteItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
745 {
746         delete pItem;
747         return true;
748 }
749
750 void
751 ContactDetailsForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
752 {
753         int contentItemIndex = -1;
754         __pItemList->GetAt(itemIndex, contentItemIndex);
755
756         String value;
757
758         if (contentItemIndex == DETAIL_PROPERTY_GROUP)
759         {
760                 value =  __pPresentationModel->GetValue(DETAIL_PROPERTY_GROUP);
761
762                 if (value.IsEmpty())
763                 {
764                         value = ResourceManager::GetString(L"IDS_PB_BODY_NOT_ASSIGNED");
765                 }
766         }
767         else if (contentItemIndex == DETAIL_PROPERTY_RINGTONE)
768         {
769                 String path =  __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
770                 int index = 0;
771                 path.LastIndexOf(L"/", path.GetLength() - 1, index);
772
773                 if (index != 0)
774                 {
775                         path.SubString(index + 1, value);
776                 }
777         }
778
779         Label* pValueLabel = static_cast<Label*>(pItem->GetControl(2));
780         if (pValueLabel == null)
781         {
782                 return;
783         }
784
785         pValueLabel->SetText(value);
786         pValueLabel->Invalidate(false);
787 }
788
789 int
790 ContactDetailsForm::GetDefaultItemHeight(void)
791 {
792         return H_ITEM;
793 }
794
795 void
796 ContactDetailsForm::AddMainInfo(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
797 {
798         int itemHeight = Y_THUMBNAIL;
799
800         Label* pThumbnailLabel = null;
801
802         String thumbnailPath = __pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL);
803         Bitmap* pThumbnail = null;
804         ImageBuffer thumbnailImageBuffer;
805         result r = thumbnailImageBuffer.Construct(thumbnailPath);
806         if (r == E_SUCCESS)
807         {
808                 pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);
809         }
810         if (pThumbnail != null)
811         {
812                 pThumbnail->SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
813                 pThumbnail->Scale(Dimension(H_THUMBNAIL, H_THUMBNAIL));
814                 pThumbnailLabel = new (std::nothrow) Label();
815                 pThumbnailLabel->Construct(Rectangle((itemWidth - H_THUMBNAIL) / 2, Y_THUMBNAIL, H_THUMBNAIL, H_THUMBNAIL), L"");
816                 pThumbnailLabel->SetBackgroundBitmap(*pThumbnail);
817                 delete pThumbnail;
818
819                 itemHeight += (H_THUMBNAIL + Y_THUMBNAIL);
820         }
821
822         String firstName = __pPresentationModel->GetValue(DETAIL_PROPERTY_FIRST_NAME);
823         String middleName = __pPresentationModel->GetValue(DETAIL_PROPERTY_MIDDLE_NAME);
824         String lastName = __pPresentationModel->GetValue(DETAIL_PROPERTY_LAST_NAME);
825         String nickName = __pPresentationModel->GetValue(DETAIL_PROPERTY_NICK_NAME);
826         String suffix = __pPresentationModel->GetValue(DETAIL_PROPERTY_NAME_SUFFIX);
827         String jobTitle = __pPresentationModel->GetValue(DETAIL_PROPERTY_JOB_TITLE);
828         String company = __pPresentationModel->GetValue(DETAIL_PROPERTY_COMPANY);
829         String department = __pPresentationModel->GetValue(DETAIL_PROPERTY_DEPARTMENT);
830
831         String name;
832         if (firstName.IsEmpty() == false)
833         {
834                 name = firstName + CHARACTER_SPACE;
835         }
836         if (middleName.IsEmpty() == false)
837         {
838                 name += (middleName + CHARACTER_SPACE);
839         }
840         if (lastName.IsEmpty() == false)
841         {
842                 name += lastName;
843         }
844
845         if (name.IsEmpty())
846         {
847                 if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER))
848                 {
849                         name.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER));
850                 }
851                 else
852                 {
853                         name.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_EMAIL, 0));
854                 }
855         }
856
857         String suffixNickName;
858         if (suffix.IsEmpty() == false)
859         {
860                 suffixNickName = suffix + CHARACTER_SPACE;
861         }
862         if (nickName.IsEmpty() == false)
863         {
864                 suffixNickName += nickName;
865         }
866
867         String companyInfo;
868         if (jobTitle.IsEmpty() == false)
869         {
870                 companyInfo = jobTitle + CHARACTER_SPACE;
871         }
872         if (company.IsEmpty() == false)
873         {
874                 companyInfo += company + CHARACTER_SPACE;
875         }
876         if (department.IsEmpty() == false)
877         {
878                 companyInfo += department;
879         }
880
881         Label* pNameLabel = null;
882         Label* pFavoriteLabel = null;
883         if (name.IsEmpty() == false)
884         {
885                 pNameLabel = new (std::nothrow) Label();
886                 pNameLabel->Construct(Rectangle(X_MAIN_INFO, itemHeight, itemWidth - (X_MAIN_INFO + H_FAVORITE + W_FAVORITE_GAP * 2), H_NAME), name);
887                 pNameLabel->SetTextConfig(FONT_SIZE_NAME, LABEL_TEXT_STYLE_BOLD);
888                 pNameLabel->SetTextColor(COLOR_NAME);
889                 pNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
890                 pNameLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
891
892                 if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
893                 {
894                         pFavoriteLabel = new (std::nothrow) Label();
895                         pFavoriteLabel->Construct(Rectangle(itemWidth - (H_FAVORITE + W_FAVORITE_GAP * 2), itemHeight + Y_FAVORITE, H_FAVORITE, H_FAVORITE), L"");
896                         pFavoriteLabel->SetName(FAVORITE_LABEL);
897                         pFavoriteLabel->AddTouchEventListener(*this);
898
899                         Bitmap* pBitmap = null;
900                         if (__pPresentationModel->IsFavorite())
901                         {
902                                 pBitmap = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_ON);
903                         }
904                         else
905                         {
906                                 pBitmap = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_OFF);
907                         }
908
909                         if (pBitmap != null)
910                         {
911                                 pFavoriteLabel->SetBackgroundBitmap(*pBitmap);
912                                 delete pBitmap;
913                         }
914                 }
915
916                 itemHeight += H_NAME;
917         }
918
919         Label* pSuffixNickNameLabel = null;
920         if (suffixNickName.IsEmpty() == false)
921         {
922                 pSuffixNickNameLabel = new (std::nothrow) Label();
923                 pSuffixNickNameLabel->Construct(Rectangle(X_MAIN_INFO, itemHeight, itemWidth - X_MAIN_INFO, H_SUB_INFO), suffixNickName);
924                 pSuffixNickNameLabel->SetTextConfig(FONT_SIZE_SUB_INFO, LABEL_TEXT_STYLE_NORMAL);
925                 pSuffixNickNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
926                 pSuffixNickNameLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
927                 itemHeight += (H_SUB_INFO + H_SUB_INFO_DIVIDER);
928         }
929
930         Label* pCompanyInfoLabel = null;
931         if (companyInfo.IsEmpty() == false)
932         {
933                 pCompanyInfoLabel = new (std::nothrow) Label();
934                 pCompanyInfoLabel->Construct(Rectangle(X_MAIN_INFO, itemHeight, itemWidth - X_MAIN_INFO, H_SUB_INFO), companyInfo);
935                 pCompanyInfoLabel->SetTextConfig(FONT_SIZE_SUB_INFO, LABEL_TEXT_STYLE_NORMAL);
936                 pCompanyInfoLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
937                 pCompanyInfoLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
938                 itemHeight += (H_SUB_INFO + H_SUB_INFO_DIVIDER);
939         }
940
941         Label* pDefaultNumberLabel = null;
942         Button* pCallButton = null;
943         Button* pMessageButton = null;
944 #if __SUPPORT_VIDEO_CALL
945         Button* pVideoCallButton = null;
946 #endif
947
948         String defaultPhoneNumber = __pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER);
949         if (defaultPhoneNumber.IsEmpty() == false)
950         {
951                 pDefaultNumberLabel = new (std::nothrow) Label();
952                 pDefaultNumberLabel->Construct(Rectangle(X_MAIN_INFO, itemHeight, itemWidth - X_MAIN_INFO, H_DEFAULT_NUMBER), defaultPhoneNumber);
953                 pDefaultNumberLabel->SetTextConfig(FONT_SIZE_MAIN_TEXT, LABEL_TEXT_STYLE_BOLD);
954                 pDefaultNumberLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
955                 pDefaultNumberLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
956                 itemHeight += (H_DEFAULT_NUMBER + H_QUICK_BUTTON_DIVIDER);
957
958                 Bitmap* pBgNormal = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON_NORMAL);
959                 Bitmap* pBgPressed = ResourceManager::GetBitmapN(IDB_CIRCLE_BUTTON_PRESSED);
960                 Bitmap* pCallNormal = ResourceManager::GetBitmapN(IDB_CALL_NORMAL);
961                 Bitmap* pCallPressed = ResourceManager::GetBitmapN(IDB_CALL_PRESSED);
962                 Bitmap* pMessageNormal = ResourceManager::GetBitmapN(IDB_SMS_NORMAL);
963                 Bitmap* pMessagePressed = ResourceManager::GetBitmapN(IDB_SMS_PRESSED);
964                 Bitmap* pVideoCallNormal = ResourceManager::GetBitmapN(IDB_VIDEO_CALL_NORMAL);
965                 Bitmap* pVideoCallPressed = ResourceManager::GetBitmapN(IDB_VIDEO_CALL_PRESSED);
966
967                 pCallButton = new (std::nothrow) Button();
968                 pCallButton->Construct(Rectangle(X_QUICK_BUTTON, itemHeight, H_QUICK_BUTTON, H_QUICK_BUTTON));
969                 pCallButton->SetActionId(IDA_VOICE_CALL);
970                 pCallButton->AddActionEventListener(*this);
971                 if (pBgNormal != null)
972                 {
973                         pCallButton->SetNormalBackgroundBitmap(*pBgNormal);
974                 }
975                 if (pBgPressed != null)
976                 {
977                         pCallButton->SetPressedBackgroundBitmap(*pBgPressed);
978                 }
979                 if (pCallNormal != null)
980                 {
981                         pCallButton->SetNormalBitmap(Point(0, 0), *pCallNormal);
982                 }
983                 if (pCallPressed != null)
984                 {
985                         pCallButton->SetPressedBitmap(Point(0, 0), *pCallPressed);
986                 }
987
988                 pMessageButton = new (std::nothrow) Button();
989                 pMessageButton->Construct(Rectangle((X_QUICK_BUTTON + H_QUICK_BUTTON + W_QUICK_BUTTON_GAP), itemHeight, H_QUICK_BUTTON, H_QUICK_BUTTON));
990                 pMessageButton->SetActionId(IDA_MESSAGE);
991                 pMessageButton->AddActionEventListener(*this);
992                 if (pBgNormal != null)
993                 {
994                         pMessageButton->SetNormalBackgroundBitmap(*pBgNormal);
995                 }
996                 if (pBgPressed != null)
997                 {
998                         pMessageButton->SetPressedBackgroundBitmap(*pBgPressed);
999                 }
1000                 if (pMessageNormal != null)
1001                 {
1002                         pMessageButton->SetNormalBitmap(Point(0, 0), *pMessageNormal);
1003                 }
1004                 if (pMessagePressed != null)
1005                 {
1006                         pMessageButton->SetPressedBitmap(Point(0, 0), *pMessagePressed);
1007                 }
1008 #if __SUPPORT_VIDEO_CALL
1009                 pVideoCallButton = new (std::nothrow) Button();
1010                 pVideoCallButton->Construct(Rectangle((X_QUICK_BUTTON + (H_QUICK_BUTTON * 2) + (W_QUICK_BUTTON_GAP * 2)), itemHeight, H_QUICK_BUTTON, H_QUICK_BUTTON));
1011                 pVideoCallButton->SetActionId(IDA_VIDEO_CALL);
1012                 pVideoCallButton->AddActionEventListener(*this);
1013                 if (pBgNormal != null)
1014                 {
1015                         pVideoCallButton->SetNormalBackgroundBitmap(*pBgNormal);
1016                 }
1017                 if (pBgPressed != null)
1018                 {
1019                         pVideoCallButton->SetPressedBackgroundBitmap(*pBgPressed);
1020                 }
1021                 if (pVideoCallNormal != null)
1022                 {
1023                         pVideoCallButton->SetNormalBitmap(Point(0, 0), *pVideoCallNormal);
1024                 }
1025                 if (pVideoCallPressed != null)
1026                 {
1027                         pVideoCallButton->SetPressedBitmap(Point(0, 0), *pVideoCallPressed);
1028                 }
1029 #endif
1030
1031                 delete pBgNormal;
1032                 delete pBgPressed;
1033                 delete pCallNormal;
1034                 delete pCallPressed;
1035                 delete pMessageNormal;
1036                 delete pMessagePressed;
1037                 delete pVideoCallNormal;
1038                 delete pVideoCallPressed;
1039
1040                 itemHeight += (H_QUICK_BUTTON + H_QUICK_BUTTON_DIVIDER);
1041         }
1042         else
1043         {
1044                 itemHeight += H_QUICK_BUTTON_DIVIDER;
1045         }
1046
1047         pItem->Construct(Dimension(itemWidth, itemHeight));
1048         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1049         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1050
1051         if (pThumbnailLabel != null)
1052         {
1053                 pItem->AddControl(*pThumbnailLabel);
1054         }
1055         if (pNameLabel != null)
1056         {
1057                 pItem->AddControl(*pNameLabel);
1058         }
1059         if (pFavoriteLabel != null)
1060         {
1061                 pItem->AddControl(*pFavoriteLabel);
1062         }
1063         if (pSuffixNickNameLabel != null)
1064         {
1065                 pItem->AddControl(*pSuffixNickNameLabel);
1066         }
1067         if (pCompanyInfoLabel != null)
1068         {
1069                 pItem->AddControl(*pCompanyInfoLabel);
1070         }
1071         if (pDefaultNumberLabel != null)
1072         {
1073                 pItem->AddControl(*pDefaultNumberLabel);
1074         }
1075 #if __SUPPORT_VIDEO_CALL
1076         if (pCallButton != null && pMessageButton != null && pVideoCallButton != null)
1077         {
1078                 pItem->AddControl(*pCallButton);
1079                 pItem->AddControl(*pMessageButton);
1080                 pItem->AddControl(*pVideoCallButton);
1081         }
1082 #else
1083         if (pCallButton != null && pMessageButton != null)
1084         {
1085                 pItem->AddControl(*pCallButton);
1086                 pItem->AddControl(*pMessageButton);
1087         }
1088 #endif
1089 }
1090
1091 void
1092 ContactDetailsForm::AddProperty(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, int detailProperty, int itemSubIndex)
1093 {
1094         String title;
1095         String value;
1096         String type;
1097         int lineCount = 1;
1098         int itemHeight = H_ITEM_DOUBLE_LINE;
1099         int valueCount = __pPresentationModel->GetMultiValuesCount(static_cast<DetailProperty>(detailProperty));
1100
1101         if (detailProperty != DETAIL_PROPERTY_PHONE_NUMBER && valueCount > 1)
1102         {
1103                 pItem->Construct(Dimension(itemWidth, H_ITEM_DOUBLE_LINE + (H_ADDITIONAL_ITEM * (valueCount - 1))), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1104                 CreateTitleValueTypeItem(itemWidth, pItem, detailProperty);
1105
1106                 return;
1107         }
1108
1109         switch (detailProperty)
1110         {
1111         case DETAIL_PROPERTY_PHONE_NUMBER:
1112                 {
1113                         type = __pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, itemSubIndex);
1114                         value = __pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, itemSubIndex);
1115
1116                         pItem->Construct(Dimension(itemWidth, H_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1117                         pItem->SetName(value);
1118
1119                         CreateValueTypeItem(itemWidth, pItem, value, type);
1120
1121                         return;
1122                 }
1123                 break;
1124         case DETAIL_PROPERTY_EMAIL:
1125                 {
1126                         title = ResourceManager::GetString(L"IDS_COM_BODY_EMAIL");
1127                         type = __pPresentationModel->GetType(static_cast<DetailProperty>(detailProperty), 0);
1128                         value = __pPresentationModel->GetValue(static_cast<DetailProperty>(detailProperty), 0);
1129                 }
1130                 break;
1131         case DETAIL_PROPERTY_ADDRESS:
1132                 {
1133                         title = ResourceManager::GetString(L"IDS_PB_BODY_ADDRESS");
1134                         type = __pPresentationModel->GetType(static_cast<DetailProperty>(detailProperty), 0);
1135                         value = __pPresentationModel->GetValue(static_cast<DetailProperty>(detailProperty), 0);
1136                 }
1137                 break;
1138         case DETAIL_PROPERTY_IM_ADDRESS:
1139                 {
1140                         title = ResourceManager::GetString(L"IDS_PB_HEADER_INSTANT_MESSENGER_ABB");
1141                         type = __pPresentationModel->GetType(static_cast<DetailProperty>(detailProperty), 0);
1142                         value = __pPresentationModel->GetValue(static_cast<DetailProperty>(detailProperty), 0);
1143                 }
1144                 break;
1145         case DETAIL_PROPERTY_URL:
1146                 {
1147                         title = ResourceManager::GetString(L"IDS_PB_BODY_URL");
1148                         type = __pPresentationModel->GetType(static_cast<DetailProperty>(detailProperty), 0);
1149                         value = __pPresentationModel->GetValue(static_cast<DetailProperty>(detailProperty), 0);
1150                 }
1151                 break;
1152         case DETAIL_PROPERTY_BIRTHDAY:
1153                 {
1154                         title = ResourceManager::GetString(L"IDS_PB_BODY_BIRTHDAY");
1155                         value = __pPresentationModel->GetValue(DETAIL_PROPERTY_BIRTHDAY);
1156                 }
1157                 break;
1158         case DETAIL_PROPERTY_NOTE:
1159                 {
1160                         pItem->Construct(Dimension(itemWidth, itemHeight), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1161                         CreateNoteItem(itemWidth, pItem);
1162
1163                         return;
1164                 }
1165                 break;
1166         default:
1167                 break;
1168         }
1169
1170         pItem->Construct(Dimension(itemWidth, itemHeight), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1171         CreateTitleValueTypeItem(itemWidth, pItem, title, value, type, lineCount);
1172 }
1173
1174 void
1175 ContactDetailsForm::AddGroup(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1176 {
1177         pItem->Construct(Dimension(itemWidth, H_ITEM_DOUBLE_LINE), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1178         pItem->SetName(Integer::ToString(DETAIL_PROPERTY_GROUP));
1179
1180         String title = ResourceManager::GetString(L"IDS_PB_BODY_GROUPS");
1181         String value =  __pPresentationModel->GetValue(DETAIL_PROPERTY_GROUP);
1182
1183         if (value.IsEmpty())
1184         {
1185                 value = ResourceManager::GetString(L"IDS_PB_BODY_NOT_ASSIGNED");
1186         }
1187
1188         AddGroupStylePanel(itemWidth, pItem, GROUP_STYLE_TOP);
1189
1190         CreateTitleValueTypeItem(itemWidth, pItem, title, value);
1191 }
1192
1193 void
1194 ContactDetailsForm::AddRingTone(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1195 {
1196         pItem->Construct(Dimension(itemWidth, H_ITEM_DOUBLE_LINE), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1197         pItem->SetName(Integer::ToString(DETAIL_PROPERTY_RINGTONE));
1198
1199         String title = ResourceManager::GetString(L"IDS_PB_BODY_RINGTONE");
1200         String value = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
1201
1202         int index = 0;
1203         String trimmedPath;
1204         value.LastIndexOf(L"/", value.GetLength() - 1, index);
1205
1206         if (index != 0)
1207         {
1208                 value.SubString(index + 1, trimmedPath);
1209         }
1210
1211         AddGroupStylePanel(itemWidth, pItem, GROUP_STYLE_BOTTOM);
1212
1213         CreateTitleValueTypeItem(itemWidth, pItem, title, trimmedPath);
1214
1215         if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
1216         {
1217                 Button* pClearButton = new (std::nothrow) Button();
1218                 pClearButton->Construct(Rectangle(itemWidth - H_ICON - W_TEXT_MARGIN, (H_ITEM_DOUBLE_LINE - H_ICON) / 2, H_ICON, H_ICON));
1219                 pClearButton->SetActionId(IDA_BUTTON_RINGTONE_CLEAR);
1220                 pClearButton->AddActionEventListener(*this);
1221
1222                 Bitmap* pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_NORMAL);
1223                 if (pReset != null)
1224                 {
1225                         pClearButton->SetNormalBitmap(Point(0, 0), *pReset);
1226                         delete pReset;
1227                 }
1228                 pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_PRESSED);
1229                 if (pReset != null)
1230                 {
1231                         pClearButton->SetPressedBitmap(Point(0, 0), *pReset);
1232                         delete pReset;
1233                 }
1234
1235                 pItem->AddControl(*pClearButton);
1236                 pItem->SetIndividualSelectionEnabled(pClearButton, true);
1237         }
1238 }
1239
1240 void
1241 ContactDetailsForm::AddShareButtons(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1242 {
1243         pItem->Construct(Dimension(itemWidth, H_BUTTON_CONTAINER));
1244
1245         int buttonWidth = itemWidth - W_BUTTON_GAP * 2;
1246
1247         Button* pSendNameButton = new (std::nothrow) Button();
1248         pSendNameButton->Construct(Rectangle(W_BUTTON_GAP, Y_BUTTON, buttonWidth, H_BUTTON), ResourceManager::GetString(L"IDS_PB_HEADER_SEND_NAMECARD"));
1249         pSendNameButton->SetActionId(IDA_BUTTON_SHARE_NAME_CARD);
1250         pSendNameButton->AddActionEventListener(*this);
1251         pItem->AddControl(*pSendNameButton);
1252 }
1253
1254 void
1255 ContactDetailsForm::CreateValueTypeItem(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, const Tizen::Base::String& value, const Tizen::Base::String& type)
1256 {
1257         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1258         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1259
1260         Label* pValueLabel = new (std::nothrow) Label();
1261         pValueLabel->Construct(Rectangle(W_TEXT_MARGIN, 0, itemWidth - W_TEXT_MARGIN * 2 - W_TYPE, H_ITEM), value);
1262         pValueLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1263         pValueLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1264         pValueLabel->SetTextConfig(FONT_SIZE_MAIN_TEXT, LABEL_TEXT_STYLE_NORMAL);
1265         pValueLabel->SetTextColor(COLOR_OTHER_NUMBER);
1266         pItem->AddControl(*pValueLabel);
1267
1268         Label* pTypeLabel = new (std::nothrow) Label();
1269         pTypeLabel->Construct(Rectangle((itemWidth - W_TEXT_MARGIN - W_TYPE), 0, W_TYPE, H_ITEM), type);
1270         pTypeLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1271         pTypeLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1272         pTypeLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1273         pTypeLabel->SetTextColor(COLOR_ITEM_TYPE);
1274         pItem->AddControl(*pTypeLabel);
1275 }
1276
1277 void
1278 ContactDetailsForm::CreateTitleValueTypeItem(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, const Tizen::Base::String& title, const Tizen::Base::String& value, const Tizen::Base::String& type, int lineCount)
1279 {
1280         int valueWidth = itemWidth - (W_TEXT_MARGIN * 2);
1281
1282         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1283         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1284
1285         Label* pTitleLabel = new (std::nothrow) Label();
1286         pTitleLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE, itemWidth - W_TEXT_MARGIN, H_ITEM_TITLE), title);
1287         pTitleLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1288         pTitleLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1289         pTitleLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1290         pTitleLabel->SetTextColor(COLOR_ITEM_TITLE);
1291         pItem->AddControl(*pTitleLabel);
1292
1293         if (type.IsEmpty() == false)
1294         {
1295                 Label* pTypeLabel = new (std::nothrow) Label();
1296                 pTypeLabel->Construct(Rectangle((itemWidth - W_TEXT_MARGIN - W_TYPE), Y_ITEM_TITLE + H_ITEM_TITLE, W_TYPE, H_ITEM_VALUE), type);
1297                 pTypeLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1298                 pTypeLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1299                 pTypeLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1300                 pTypeLabel->SetTextColor(COLOR_ITEM_TYPE);
1301                 pItem->AddControl(*pTypeLabel);
1302
1303                 valueWidth = itemWidth - (W_TEXT_MARGIN * 2) - W_TYPE;
1304         }
1305         else if (title.Equals(ResourceManager::GetString(L"IDS_PB_BODY_RINGTONE"), false))
1306         {
1307                 valueWidth = itemWidth - (W_TEXT_MARGIN * 2) - H_ICON;
1308         }
1309
1310         Label* pValueLabel = new (std::nothrow) Label();
1311         pValueLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE + H_ITEM_TITLE, valueWidth, H_ITEM_VALUE * lineCount), value);
1312         pValueLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1313         pValueLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1314         pValueLabel->SetTextConfig(FONT_SIZE_MAIN_TEXT, LABEL_TEXT_STYLE_NORMAL);
1315         pValueLabel->SetTextColor(COLOR_ITEM_VALUE);
1316         pItem->AddControl(*pValueLabel);
1317 }
1318
1319 void
1320 ContactDetailsForm::CreateTitleValueTypeItem(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, int detailProperty)
1321 {
1322         String title;
1323
1324         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1325         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1326
1327         switch (detailProperty)
1328         {
1329         case DETAIL_PROPERTY_EMAIL:
1330                 {
1331                         title = ResourceManager::GetString(L"IDS_COM_BODY_EMAIL");
1332                 }
1333                 break;
1334         case DETAIL_PROPERTY_ADDRESS:
1335                 {
1336                         title = ResourceManager::GetString(L"IDS_PB_BODY_ADDRESS");
1337                 }
1338                 break;
1339         case DETAIL_PROPERTY_URL:
1340                 {
1341                         title = ResourceManager::GetString(L"IDS_PB_BODY_URL");
1342                 }
1343                 break;
1344         case DETAIL_PROPERTY_IM_ADDRESS:
1345                 {
1346                         title = ResourceManager::GetString(L"IDS_PB_HEADER_INSTANT_MESSENGER_ABB");
1347                 }
1348                 break;
1349         default:
1350                 break;
1351         }
1352
1353         Label* pTitleLabel = new (std::nothrow) Label();
1354         pTitleLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE, itemWidth - W_TEXT_MARGIN, H_ITEM_TITLE), title);
1355         pTitleLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1356         pTitleLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1357         pTitleLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1358         pTitleLabel->SetTextColor(COLOR_ITEM_TITLE);
1359         pItem->AddControl(*pTitleLabel);
1360
1361         for (int i = 0; i < __pPresentationModel->GetMultiValuesCount(static_cast<DetailProperty>(detailProperty)); i++)
1362         {
1363                 String type = __pPresentationModel->GetType(static_cast<DetailProperty>(detailProperty), i);
1364                 String value = __pPresentationModel->GetValue(static_cast<DetailProperty>(detailProperty), i);
1365
1366                 int valueWidth = itemWidth - (W_TEXT_MARGIN * 2);
1367                 if (type.IsEmpty() == false)
1368                 {
1369                         Label* pTypeLabel = new (std::nothrow) Label();
1370                         pTypeLabel->Construct(Rectangle((itemWidth - W_TEXT_MARGIN - W_TYPE), Y_ITEM_TITLE + H_ITEM_TITLE + (H_ADDITIONAL_ITEM * i), W_TYPE, H_ITEM_VALUE), type);
1371                         pTypeLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1372                         pTypeLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1373                         pTypeLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1374                         pTypeLabel->SetTextColor(COLOR_ITEM_TYPE);
1375                         pItem->AddControl(*pTypeLabel);
1376
1377                         valueWidth = itemWidth - (W_TEXT_MARGIN * 2) - W_TYPE;
1378                 }
1379
1380                 Label* pValueLabel = new (std::nothrow) Label();
1381                 pValueLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE + H_ITEM_TITLE + (H_ADDITIONAL_ITEM * i), valueWidth, H_ITEM_VALUE), value);
1382                 pValueLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1383                 pValueLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1384                 pValueLabel->SetTextConfig(FONT_SIZE_MAIN_TEXT, LABEL_TEXT_STYLE_NORMAL);
1385                 pValueLabel->SetTextColor(COLOR_ITEM_VALUE);
1386                 pItem->AddControl(*pValueLabel);
1387         }
1388 }
1389
1390 void
1391 ContactDetailsForm::CreateNoteItem(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1392 {
1393         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1394         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1395
1396         String title = ResourceManager::GetString(L"IDS_PB_BODY_NOTE");
1397         String value = __pPresentationModel->GetValue(DETAIL_PROPERTY_NOTE);
1398
1399         Label* pTitleLabel = new (std::nothrow) Label();
1400         pTitleLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE, itemWidth - W_TEXT_MARGIN, H_ITEM_TITLE), title);
1401         pTitleLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1402         pTitleLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1403         pTitleLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1404         pTitleLabel->SetTextColor(COLOR_ITEM_TITLE);
1405         pItem->AddControl(*pTitleLabel);
1406
1407         Label* pValueLabel = new (std::nothrow) Label();
1408         pValueLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE + H_ITEM_TITLE, itemWidth - (W_TEXT_MARGIN * 2), H_ITEM_VALUE), value);
1409         pValueLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1410         pValueLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
1411         pValueLabel->SetTextConfig(FONT_SIZE_MAIN_TEXT, LABEL_TEXT_STYLE_NORMAL);
1412         pValueLabel->SetTextColor(COLOR_ITEM_VALUE);
1413         pItem->AddControl(*pValueLabel);
1414
1415         Font font;
1416         font.Construct(FONT_STYLE_PLAIN, FONT_SIZE_MAIN_TEXT);
1417
1418         TextElement* pNameElement = new (std::nothrow) TextElement();
1419         pNameElement->Construct(value);
1420         pNameElement->SetFont(font);
1421
1422         EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
1423         pEnrichedText->Construct(Dimension(itemWidth - (W_TEXT_MARGIN * 2) - (pValueLabel->GetLeftMargin() * 2), H_ITEM_VALUE));
1424         pEnrichedText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
1425         pEnrichedText->SetTextAbbreviationEnabled(false);
1426         pEnrichedText->Add(*pNameElement);
1427
1428         pValueLabel->SetSize(pValueLabel->GetWidth(), pEnrichedText->GetTotalLineHeight() + pValueLabel->GetTopMargin());
1429         pItem->SetSize(itemWidth, (Y_ITEM_TITLE * 2) + H_ITEM_TITLE + pEnrichedText->GetTotalLineHeight());
1430
1431         pEnrichedText->RemoveAllTextElements(true);
1432         delete pEnrichedText;
1433 }
1434
1435 void
1436 ContactDetailsForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1437 {
1438         SceneManager* pSceneManager = SceneManager::GetInstance();
1439
1440         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1441         {
1442                 String itemName = pItem->GetName();
1443
1444                 if (itemName.Equals(Integer::ToString(DETAIL_PROPERTY_GROUP), true) == true)
1445                 {
1446                         if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == true)
1447                         {
1448                                 return;
1449                         }
1450
1451                         if (__pPresentationModel->GetCategoryCount() > 0)
1452                         {
1453                                 IList* pCategoryList = __pPresentationModel->GetAssignedCategoryIdListN();
1454
1455                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_SELECTOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pCategoryList);
1456                         }
1457                         else
1458                         {
1459                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
1460                         }
1461                 }
1462                 else if (itemName.Equals(Integer::ToString(DETAIL_PROPERTY_RINGTONE), true) == true)
1463                 {
1464                         if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == true)
1465                         {
1466                                 return;
1467                         }
1468
1469                         result r = LaunchAppControl(PROVIDER_ID_FILEMANAGER, OPERATION_ID_PICK);
1470                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
1471                 }
1472                 else if (itemName.IsEmpty() == false)
1473                 {
1474                         Point itemPoint;
1475                         itemPoint.x = GetClientAreaBounds().width / 2;
1476                         itemPoint.y = GetClientAreaBounds().y + pItem->GetY() + (pItem->GetHeight() / 2) - __scrolledDistance;
1477
1478                         __pContextMenuCall->SetName(itemName);
1479                         __pContextMenuCall->SetAnchorPosition(itemPoint);
1480                         __pContextMenuCall->SetShowState(true);
1481                         __pContextMenuCall->Show();
1482                 }
1483         }
1484 }
1485
1486 void
1487 ContactDetailsForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1488 {
1489 }
1490
1491 void
1492 ContactDetailsForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo)
1493 {
1494 }
1495
1496 void
1497 ContactDetailsForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
1498 {
1499 }
1500
1501 void
1502 ContactDetailsForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1503 {
1504         if (source.GetName().Equals(FAVORITE_LABEL, true))
1505         {
1506                 Label* pLabel = static_cast<Label*>(&const_cast<Control&>(source));
1507                 if (pLabel == null)
1508                 {
1509                         return;
1510                 }
1511
1512                 __pPresentationModel->SetAsFavorite(!__pPresentationModel->IsFavorite());
1513
1514                 Bitmap* pBitmap = null;
1515                 if (__pPresentationModel->IsFavorite())
1516                 {
1517                         pBitmap = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_ON);
1518                 }
1519                 else
1520                 {
1521                         pBitmap = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_OFF);
1522                 }
1523
1524                 if (pBitmap != null)
1525                 {
1526                         pLabel->SetBackgroundBitmap(*pBitmap);
1527                         delete pBitmap;
1528                 }
1529                 pLabel->Invalidate(false);
1530         }
1531 }
1532
1533 void
1534 ContactDetailsForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1535 {
1536 }
1537
1538 void
1539 ContactDetailsForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1540 {
1541 }
1542
1543 void
1544 ContactDetailsForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1545 {
1546 }
1547
1548 void
1549 ContactDetailsForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1550 {
1551 }
1552
1553 void
1554 ContactDetailsForm::OnScrollEndReached (Tizen::Ui::Control &source, Tizen::Ui::Controls::ScrollEndEvent type)
1555 {
1556 }
1557
1558 void
1559 ContactDetailsForm::OnScrollPositionChanged (Tizen::Ui::Control &source, int scrollPos)
1560 {
1561         __scrolledDistance = scrollPos;
1562 }
1563
1564 void
1565 ContactDetailsForm::OnScrollStopped (Tizen::Ui::Control &source)
1566 {
1567 }
1568
1569 void
1570 ContactDetailsForm::OnContactsChanged(void)
1571 {
1572         if (__pPresentationModel->IsContactRemoved())
1573         {
1574                 if (__appControlViewType.IsEmpty() == true)
1575                 {
1576                         SceneManager* pSceneManager = SceneManager::GetInstance();
1577
1578                         result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
1579                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
1580                 }
1581                 else
1582                 {
1583                         UiApp::GetInstance()->Terminate();
1584                 }
1585         }
1586         else
1587         {
1588                 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1589                 TryReturnVoid(pContactsApp != null, "Unable to get ContactsApp instance.");
1590
1591                 if (pContactsApp->GetAppUiState() == APP_UI_STATE_BACKGROUND)
1592                 {
1593                         __pTableView->UpdateTableView();
1594                 }
1595         }
1596
1597         delete __pDefaultSelectorPopup;
1598         __pDefaultSelectorPopup = null;
1599 }
1600
1601 void
1602 ContactDetailsForm::OnCategoriesChanged(void)
1603 {
1604 }
1605
1606 result
1607 ContactDetailsForm::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, const Tizen::Base::String& launchType, const Tizen::Base::String& value)
1608 {
1609         result r = E_SUCCESS;
1610
1611         if (__pAppControl != null)
1612         {
1613                 return E_FAILURE;
1614         }
1615
1616         String uri;
1617         String mimeType;
1618         HashMap extraData;
1619         extraData.Construct();
1620         IAppControlResponseListener* pEvent = null;
1621
1622         if (appId.Equals(String(PROVIDER_ID_PHONE)) && operationId.Equals(String(OPERATION_ID_CALL)))
1623         {
1624                 uri.Append(INPUT_URI_TEL);
1625
1626                 if (value.IsEmpty())
1627                 {
1628                         uri.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER));
1629                 }
1630                 else
1631                 {
1632                         uri.Append(value);
1633                 }
1634
1635                 extraData.Add(new (std::nothrow) String(INPUT_KEY_CALL_TYPE), new (std::nothrow) String(launchType));
1636         }
1637         else if (appId.Equals(String(PROVIDER_ID_MESSAGE)) && operationId.Equals(String(OPERATION_ID_COMPOSE)))
1638         {
1639                 String recipientAddress;
1640
1641                 if (value.IsEmpty())
1642                 {
1643                         recipientAddress.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER));
1644                 }
1645                 else
1646                 {
1647                         recipientAddress.Append(value);
1648                 }
1649                 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TO), new (std::nothrow) String(recipientAddress));
1650                 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TYPE), new (std::nothrow) String(INPUT_TYPE_SMS));
1651         }
1652         else if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
1653         {
1654                 mimeType.Append(INPUT_MIME_TYPE_AUDIO);
1655                 extraData.Add(new (std::nothrow) String(INPUT_KEY_SELECTION_MODE), new (std::nothrow) String(INPUT_DATA_SELECTION_MODE_SINGLE));
1656
1657                 pEvent = this;
1658         }
1659         else if (appId.Equals(String(PROVIDER_ID_EMAIL)) && operationId.Equals(String(OPERATION_ID_COMPOSE)))
1660         {
1661                 ArrayList* pArgList = new (std::nothrow) ArrayList();
1662                 pArgList->Construct();
1663
1664                 pArgList->Add(new (std::nothrow) String(__pPresentationModel->GetValue(DETAIL_PROPERTY_EMAIL, 0)));
1665                 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TO), pArgList);
1666         }
1667
1668         __pAppControl = AppManager::FindAppControlN(appId, operationId);
1669         if (__pAppControl != null)
1670         {
1671                 r = __pAppControl->Start(&uri, &mimeType, &extraData, pEvent);
1672                 TryCatch(r == E_SUCCESS, , "[%s] Unable to launch app control", GetErrorMessage(r));
1673
1674                 if (operationId.Equals(String(OPERATION_ID_PICK)))
1675                 {
1676                         SetEnabled(false);
1677                         Invalidate(true);
1678                 }
1679
1680                 Footer* pFooter = GetFooter();
1681                 pFooter->SetEnabled(false);
1682         }
1683
1684 CATCH:
1685         extraData.RemoveAll(true);
1686
1687         return r;
1688 }
1689
1690 void
1691 ContactDetailsForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1692 {
1693         AppLogDebug("ENTER");
1694
1695         SetEnabled(true);
1696         Invalidate(true);
1697
1698         if (pExtraData == null)
1699         {
1700                 return;
1701         }
1702
1703         if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
1704         {
1705                 if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1706                 {
1707                         const String *pResultString = null;
1708                         const ArrayList* pResultList = dynamic_cast<const ArrayList*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
1709                         if (pResultList != null)
1710                         {
1711                                 pResultString = static_cast<const String*>(pResultList->GetAt(0));
1712                         }
1713                         else
1714                         {
1715                                 pResultString = static_cast<const String*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
1716                         }
1717
1718                         if (pResultString != null && pResultString->IsEmpty() == false)
1719                         {
1720                                 __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, *pResultString);
1721                                 __pPresentationModel->UpdateContact();
1722                                 __pTableView->RefreshItem(__pItemList->GetCount() - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1723                         }
1724                 }
1725         }
1726
1727         AppLogDebug("EXIT");
1728 }
1729
1730 void
1731 ContactDetailsForm::AddGroupStylePanel(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::GroupStyle groupStyle)
1732 {
1733         Panel* pGroupStyle = new (std::nothrow) Panel();
1734         pGroupStyle->Construct(Rectangle(W_GROUP_STYLE_MARGIN, 0, itemWidth - W_GROUP_STYLE_MARGIN * 2, H_ITEM_DOUBLE_LINE), groupStyle);
1735         pGroupStyle->SetBackgroundColor(COLOR_GROUP_STYLE);
1736         pItem->AddControl(*pGroupStyle);
1737 }
1738
1739 result
1740 ContactDetailsForm::ParseAppControlArgument(const Tizen::Base::String& argument, Tizen::Base::String& type, Tizen::Base::String& content)
1741 {
1742         result r = E_SUCCESS;
1743
1744         if (argument.IsEmpty() || argument.Contains(DELIMITER) == false)
1745         {
1746                 return E_FAILURE;
1747         }
1748
1749         StringTokenizer stringToken(argument, DELIMITER);
1750
1751         r = stringToken.GetNextToken(type);
1752         TryReturn(r == E_SUCCESS, r, "[%s] Unable to get type", GetErrorMessage(r));
1753
1754         r = stringToken.GetNextToken(content);
1755         TryReturn(r == E_SUCCESS, r, "[%s] Unable to get content", GetErrorMessage(r));
1756
1757         return r;
1758 }
1759
1760 void
1761 ContactDetailsForm::ShowDefaultSelectorPopup(void)
1762 {
1763         ArrayList* pList = new (std::nothrow) ArrayList();
1764         pList->Construct();
1765
1766         String numberWithType;
1767         int numberCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
1768         for (int index = 0; index < numberCount; index++)
1769         {
1770                 numberWithType = __pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, index) + L"  ";
1771                 numberWithType += __pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, index);
1772
1773                 pList->Add(*(new (std::nothrow) String(numberWithType)));
1774         }
1775         ContactValueListItemProvider* pProvider = new (std::nothrow) ContactValueListItemProvider(pList);
1776
1777         delete __pDefaultSelectorPopup;
1778         __pDefaultSelectorPopup = new (std::nothrow) Popup();
1779         __pDefaultSelectorPopup->Construct(true, Dimension(W_POPUP, H_POPUP));
1780         __pDefaultSelectorPopup->SetTitleText(ResourceManager::GetString(L"IDS_PB_BODY_MARK_AS_DEFAULT_NUMBER"));
1781
1782         Rectangle popupClientBounds = __pDefaultSelectorPopup->GetClientAreaBounds();
1783
1784         ListView* pOtherNumberList = new (std::nothrow) ListView();
1785         pOtherNumberList->Construct(Rectangle(0, 0, popupClientBounds.width, H_POPUP_LIST_VIEW));
1786         pOtherNumberList->AddListViewItemEventListener(*this);
1787         pOtherNumberList->SetItemProvider(*pProvider);
1788
1789         __pDefaultSelectorPopup->AddControl(*pOtherNumberList);
1790
1791         Button* pCloseButton = new (std::nothrow) Button();
1792         pCloseButton->Construct(Rectangle((popupClientBounds.width - W_POPUP_BUTTON) / 2, Y_POPUP_BUTTON,
1793                                                                         W_POPUP_BUTTON, H_POPUP_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CLOSE"));
1794         pCloseButton->SetActionId(IDA_POPUP_CLOSE);
1795         pCloseButton->AddActionEventListener(*this);
1796
1797         __pDefaultSelectorPopup->AddControl(*pCloseButton);
1798         __pDefaultSelectorPopup->SetShowState(true);
1799         __pDefaultSelectorPopup->Show();
1800 }
1801
1802 void
1803 ContactDetailsForm::HideDefaultSelectorPopup(void)
1804 {
1805         __pDefaultSelectorPopup->SetShowState(false);
1806
1807         Invalidate(true);
1808 }
1809
1810 void
1811 ContactDetailsForm::ShowInvalidFilePopup(void)
1812 {
1813         if (__pInvalidFilePopup != null)
1814         {
1815                 delete __pInvalidFilePopup;
1816         }
1817
1818         __pInvalidFilePopup = new (std::nothrow) Popup();
1819         __pInvalidFilePopup->Construct(false, Dimension(W_POPUP, H_INVALID_FILE_POPUP));
1820
1821         Rectangle clientBounds = __pInvalidFilePopup->GetClientAreaBounds();
1822
1823         Label* pLabelText = new (std::nothrow) Label();
1824         pLabelText->Construct(Rectangle(0, Y_POPUP_TEXT_LABEL, clientBounds.width, H_POPUP_TEXT_LABEL), ResourceManager::GetString(L"IDS_RSSR_BODY_INVALID_FORMAT"));
1825         pLabelText->SetTextColor(COLOR_POPUP_TEXT);
1826         pLabelText->SetTextConfig(FONT_SIZE_POPUP_TEXT, LABEL_TEXT_STYLE_BOLD);
1827         pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1828
1829         __pInvalidFilePopup->AddControl(*pLabelText);
1830
1831         Button* pButtonClose = new (std::nothrow) Button();
1832         pButtonClose->Construct(Rectangle((clientBounds.width - W_POPUP_BUTTON) / 2, pLabelText->GetY() + pLabelText->GetHeight(), W_POPUP_BUTTON, H_POPUP_BUTTON));
1833         pButtonClose->SetText(ResourceManager::GetString("IDS_COM_SK_OK"));
1834         pButtonClose->SetActionId(IDA_INVALID_FILE_POPUP_CLOSE);
1835         pButtonClose->AddActionEventListener(*this);
1836
1837         __pInvalidFilePopup->AddControl(*pButtonClose);
1838
1839         __pInvalidFilePopup->Show();
1840 }
1841
1842 void
1843 ContactDetailsForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1844 {
1845         __pPresentationModel->SetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER, L"", index);
1846         __pPresentationModel->AddAddressBook();
1847         InitializeDetailItemList();
1848         __pTableView->UpdateTableView();
1849
1850         HideDefaultSelectorPopup();
1851 }
1852
1853 void
1854 ContactDetailsForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1855 {
1856 }
1857
1858 void
1859 ContactDetailsForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
1860 {
1861 }
1862
1863 void
1864 ContactDetailsForm::OnForeground(void)
1865 {
1866         if (IsEnabled() == false)
1867         {
1868                 SetEnabled(true);
1869                 Invalidate(true);
1870         }
1871
1872         Footer* pFooter = GetFooter();
1873         pFooter->SetEnabled(true);
1874
1875         delete __pAppControl;
1876         __pAppControl = null;
1877 }
1878
1879 void
1880 ContactDetailsForm::OnBackground(void)
1881 {
1882 }