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