Added a feature for invalid format and fixed jira issues (N_SE-33586, 32988, 33598)
[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         result r = E_SUCCESS;
257         SceneManager* pSceneManager = SceneManager::GetInstance();
258
259         switch (actionId)
260         {
261         case IDA_FOOTER_EDIT:
262                 {
263                         ArrayList* pList = new (std::nothrow) ArrayList();
264                         pList->Construct();
265                         pList->Add(*(new (std::nothrow) Integer(__pPresentationModel->GetContactId())));
266                         r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
267                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go forward", GetErrorMessage(r));
268                 }
269                 break;
270         case IDA_FOOTER_DELETE:
271                 {
272                         int modalResult = 0;
273                         MessageBox deleteMessageBox;
274                         deleteMessageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_SK_DELETE") + L"?", MSGBOX_STYLE_YESNO);
275                         deleteMessageBox.ShowAndWait(modalResult);
276
277                         if (modalResult == MSGBOX_RESULT_YES)
278                         {
279                                 r = __pPresentationModel->RemoveContact();
280                                 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to remove contact", GetErrorMessage(r));
281                         }
282                 }
283                 break;
284         case IDA_FOOTER_MORE:
285                 {
286                         __pContextMenuMore->SetShowState(true);
287                         __pContextMenuMore->Show();
288                 }
289                 break;
290         case IDA_FOOTER_ADD:
291                 {
292                         ArrayList* pList = new (std::nothrow) ArrayList();
293                         pList->Construct();
294                         pList->Add(*(new (std::nothrow) Integer(INVALID_RECORD_ID)));
295                         pList->Add(*(new (std::nothrow) String(__pPresentationModel->GetVcfPath())));
296                         r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
297                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go forward", GetErrorMessage(r));
298                 }
299                 break;
300         case IDA_MORE_DEFAULT_NUMBER:
301                 {
302                         ShowDefaultSelectorPopup();
303                 }
304                 break;
305         case IDA_BUTTON_RINGTONE_CLEAR:
306                 {
307                         __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, String());
308                         __pPresentationModel->UpdateContact();
309                 }
310                 break;
311         case IDA_VOICE_CALL:
312                 {
313                         r = LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, INPUT_TYPE_VOICE, source.GetName());
314                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
315                 }
316                 break;
317         case IDA_MESSAGE:
318                 {
319                         r = LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, INPUT_TYPE_SMS, source.GetName());
320                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
321                 }
322                 break;
323         case IDA_VIDEO_CALL:
324                 {
325                         r = LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, INPUT_TYPE_VIDEO, source.GetName());
326                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
327                 }
328                 break;
329         case IDA_CONTEXTMENU_SHARE_EMAIL:
330                 {
331                         r = LaunchAppControl(PROVIDER_ID_EMAIL, OPERATION_ID_COMPOSE);
332                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
333                 }
334                 break;
335         case IDA_CONTEXTMENU_SHARE_MESSAGE:
336                 {
337                         r = LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, INPUT_TYPE_MMS);
338                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
339                 }
340                 break;
341         case IDA_BUTTON_SHARE_NAME_CARD:
342                 {
343                         Point itemPoint;
344                         itemPoint.x = GetClientAreaBounds().width / 2;
345                         itemPoint.y = 0;
346
347                         TableViewItem* pParent = static_cast<TableViewItem*>(source.GetParent());
348                         if (pParent != null)
349                         {
350                                 itemPoint.y = GetClientAreaBounds().y + pParent->GetY() + source.GetY() - __scrolledDistance;
351                         }
352
353                         __pContextMenuShare->SetAnchorPosition(itemPoint);
354                         __pContextMenuShare->SetShowState(true);
355                         __pContextMenuShare->Show();
356                 }
357                 break;
358         case IDA_POPUP_CLOSE:
359                 {
360                         HideDefaultSelectorPopup();
361                 }
362                 break;
363         case IDA_INVALID_FILE_POPUP_CLOSE:
364                 {
365                         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
366
367                         AppControlProviderManager::GetInstance()->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, null);
368                         UiApp::GetInstance()->Terminate();
369                 }
370                 break;
371         default:
372                 break;
373         }
374 }
375
376 void
377 ContactDetailsForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
378 {
379         if (__appControlViewType.IsEmpty() == false)
380         {
381                 UiApp* pApp = UiApp::GetInstance();
382                 pApp->Terminate();
383         }
384         else
385         {
386                 SceneManager* pSceneManager = SceneManager::GetInstance();
387
388                 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
389                 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
390         }
391 }
392
393 void
394 ContactDetailsForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, IList* pArgs)
395 {
396         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
397         TryReturnVoid(pContactsApp != null, "Unable to cast UiApp to ContactsApp");
398
399         pContactsApp->AddContactsAppChangeEventListener(*this);
400
401         if (previousSceneId == IDSCN_GROUP_SELECTOR || previousSceneId == IDSCN_GROUP_EDITOR)
402         {
403                 if (pArgs == null)
404                 {
405                         return;
406                 }
407
408                 Integer* pArgument = null;
409                 __pPresentationModel->RemoveContactFromAllCategories();
410                 IEnumerator* pEnum = pArgs->GetEnumeratorN();
411                 while (pEnum->MoveNext() == E_SUCCESS)
412                 {
413                         pArgument = static_cast<Integer*>(pEnum->GetCurrent());
414                         if (pArgument != null)
415                         {
416                                 __pPresentationModel->AddContactToCategory(pArgument->ToInt());
417                         }
418                 }
419                 delete pEnum;
420
421                 __pTableView->RefreshItem(__pItemList->GetCount() - 2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
422         }
423         else if (previousSceneId == IDSCN_CONTACT_EDITOR && __appControlViewType.IsEmpty())
424         {
425                 InitializeDetailItemList();
426                 __pTableView->UpdateTableView();
427         }
428         else
429         {
430                 if (pArgs == null)
431                 {
432                         return;
433                 }
434
435                 if (pContactsApp->GetOperationId() == OPERATION_ID_VIEW)
436                 {
437                         __pPresentationModel->RemoveContactChangeListener(*this);
438
439                         result r = InitializeAppControl(pArgs);
440
441                         if (IsFailed(r))
442                         {
443                                 pArgs->RemoveAll(true);
444                                 delete pArgs;
445                                 AppLogDebug("Unable to initialize appcontrol");
446
447                                 ShowInvalidFilePopup();
448
449                                 return;
450                         }
451
452                         InitializeDetailItemList();
453                 }
454                 else
455                 {
456                         Integer* pContactId = static_cast<Integer*>(pArgs->GetAt(0));
457                         if (pContactId != null)
458                         {
459                                 __pPresentationModel->SetContactId(pContactId->ToInt());
460                                 InitializeDetailItemList();
461                         }
462                 }
463                 __pTableView->UpdateTableView();
464         }
465
466         if (pArgs != null)
467         {
468                 pArgs->RemoveAll(true);
469                 delete pArgs;
470         }
471 }
472
473 result
474 ContactDetailsForm::InitializeAppControl(Tizen::Base::Collection::IList* pArgs)
475 {
476         if (pArgs == null)
477         {
478                 return E_FAILURE;
479         }
480
481         result r = E_SUCCESS;
482
483         String* pArgStringType = null;
484         String* pArgStringValue = null;
485         String keyViewType;
486         String keyValue;
487         String valueViewType;
488         String value;
489
490         pArgStringType = static_cast<String*>(pArgs->GetAt(0));
491         pArgStringValue = static_cast<String*>(pArgs->GetAt(1));
492
493         TryReturn(pArgStringType != null && pArgStringValue != null, E_FAILURE, "[E_FAILURE] Unable to initialize appcontrol");
494
495         ParseAppControlArgument(*pArgStringType, keyViewType, valueViewType);
496         ParseAppControlArgument(*pArgStringValue, keyValue, value);
497
498         if (keyViewType.Equals(KEY_VIEW_TYPE, false))
499         {
500                 if (valueViewType.Equals(VALUE_VIEW_TYPE_CONTACT, false))
501                 {
502                         if (keyValue.Equals(KEY_VIEW_TYPE_CONTACT_ID, false))
503                         {
504                                 RecordId contactId;
505                                 Integer::Parse(value, contactId);
506                                 r = __pPresentationModel->SetContactId(contactId);
507                                 __appControlViewType = valueViewType;
508
509                                 Footer* pFooter = GetFooter();
510                                 pFooter->RemoveAllItems();
511
512                                 FooterItem footerItemEdit;
513                                 footerItemEdit.Construct(IDA_FOOTER_EDIT);
514                                 footerItemEdit.SetText(ResourceManager::GetString(L"IDS_COM_SK_EDIT"));
515                                 pFooter->AddItem(footerItemEdit);
516
517                                 FooterItem footerItemDelete;
518                                 footerItemDelete.Construct(IDA_FOOTER_DELETE);
519                                 footerItemDelete.SetText(ResourceManager::GetString(L"IDS_COM_SK_DELETE"));
520                                 pFooter->AddItem(footerItemDelete);
521
522                                 __pPresentationModel->AddContactChangeListener(*this);
523                         }
524                         else
525                         {
526                                 AppLogDebug("Invalid KEY(contactId) of AppControl[VIEW]. [%ls] has been input", keyValue.GetPointer());
527                                 r = E_FAILURE;
528                         }
529                 }
530                 else if (valueViewType.Equals(VALUE_VIEW_TYPE_VCF, false))
531                 {
532                         if (keyValue.Equals(KEY_VIEW_TYPE_VCF, false))
533                         {
534                                 r = __pPresentationModel->SetVcfPath(value);
535
536                                 __appControlViewType = valueViewType;
537                                 Footer* pFooter = GetFooter();
538                                 pFooter->RemoveAllItems();
539                                 pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
540
541                                 FooterItem footerItemAdd;
542                                 footerItemAdd.Construct(IDA_FOOTER_ADD);
543                                 footerItemAdd.SetText(ResourceManager::GetString(L"IDS_COM_OPT_ADD_TO_CONTACTS"));
544                                 pFooter->AddItem(footerItemAdd);
545                         }
546                         else
547                         {
548                                 AppLogDebug("Invalid KEY(path) of AppControl[VIEW]. [%ls] has been input", keyValue.GetPointer());
549                                 r = E_FAILURE;
550                         }
551                 }
552                 else
553                 {
554                         AppLogDebug("viewType of AppControl[VIEW] should be either vcf or contact. [%ls] has been inpue", keyValue.GetPointer());
555                         r = E_FAILURE;
556                 }
557         }
558         else
559         {
560                 AppLogDebug("Invalid KEY(viewType) of AppControl[VIEW]. [%ls] has been input", keyViewType.GetPointer());
561                 r = E_FAILURE;
562         }
563
564         return r;
565 }
566
567 void
568 ContactDetailsForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
569 {
570         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
571         pContactsApp->RemoveContactsAppChangeEventListener(*this);
572
573         delete __pAppControl;
574         __pAppControl = null;
575 }
576
577 void
578 ContactDetailsForm::InitializeDetailItemList(void)
579 {
580         if (__pItemList->GetCount() > 0)
581         {
582                 __pItemList->RemoveAll();
583         }
584
585         // Default area
586         __pItemList->Add(DETAIL_PROPERTY_MAIN_INFO);
587
588         // Other Phone Numbers
589         Footer* pFooter = GetFooter();
590         pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
591         int otherNumberCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
592         if (otherNumberCount > 1)
593         {
594                 ButtonItem footerItemMore;
595                 footerItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
596                 footerItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, ResourceManager::GetBitmapN(IDB_MORE_NORMAL));
597                 footerItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, ResourceManager::GetBitmapN(IDB_MORE_PRESSED));
598
599                 if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
600                 {
601                         pFooter->SetButton(BUTTON_POSITION_LEFT, footerItemMore);
602                 }
603
604                 String otherNumber;
605                 String otherNumberType;
606                 String defaultNumber = __pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER);
607                 String defaultNumberType = __pPresentationModel->GetType(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER);
608                 for (int subIndex = 0; subIndex < otherNumberCount; subIndex++)
609                 {
610                         //omit default number
611                         otherNumber = __pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, subIndex);
612                         otherNumberType = __pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, subIndex);
613
614                         if (otherNumber.CompareTo(defaultNumber) == 0 && otherNumberType.CompareTo(defaultNumberType) == 0)
615                         {
616                                 continue;
617                         }
618
619                         __pItemList->Add(DETAIL_PROPERTY_PHONE_NUMBER + subIndex);
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                         title = ResourceManager::GetString(L"IDS_PB_BODY_NOTE");
1161                         value = __pPresentationModel->GetValue(DETAIL_PROPERTY_NOTE);
1162
1163                         TextBox* pNote = new (std::nothrow) TextBox();
1164                         pNote->Construct(Rectangle(0, 0, itemWidth - W_TEXT_MARGIN * 2, itemHeight));
1165                         pNote->SetText(value);
1166                         lineCount = pNote->GetLineCount();
1167
1168                         delete pNote;
1169
1170                         itemHeight += H_ADDITIONAL_ITEM * (lineCount - 1);
1171                 }
1172                 break;
1173         default:
1174                 break;
1175         }
1176
1177         pItem->Construct(Dimension(itemWidth, itemHeight), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1178         CreateTitleValueTypeItem(itemWidth, pItem, title, value, type, lineCount);
1179 }
1180
1181 void
1182 ContactDetailsForm::AddGroup(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1183 {
1184         pItem->Construct(Dimension(itemWidth, H_ITEM_DOUBLE_LINE), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1185         pItem->SetName(Integer::ToString(DETAIL_PROPERTY_GROUP));
1186
1187         String title = ResourceManager::GetString(L"IDS_PB_BODY_GROUPS");
1188         String value =  __pPresentationModel->GetValue(DETAIL_PROPERTY_GROUP);
1189
1190         if (value.IsEmpty())
1191         {
1192                 value = ResourceManager::GetString(L"IDS_PB_BODY_NOT_ASSIGNED");
1193         }
1194
1195         AddGroupStylePanel(itemWidth, pItem, GROUP_STYLE_TOP);
1196
1197         CreateTitleValueTypeItem(itemWidth, pItem, title, value);
1198 }
1199
1200 void
1201 ContactDetailsForm::AddRingTone(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1202 {
1203         pItem->Construct(Dimension(itemWidth, H_ITEM_DOUBLE_LINE), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1204         pItem->SetName(Integer::ToString(DETAIL_PROPERTY_RINGTONE));
1205
1206         String title = ResourceManager::GetString(L"IDS_PB_BODY_RINGTONE");
1207         String value = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
1208
1209         int index = 0;
1210         String trimmedPath;
1211         value.LastIndexOf(L"/", value.GetLength() - 1, index);
1212
1213         if (index != 0)
1214         {
1215                 value.SubString(index + 1, trimmedPath);
1216         }
1217
1218         AddGroupStylePanel(itemWidth, pItem, GROUP_STYLE_BOTTOM);
1219
1220         CreateTitleValueTypeItem(itemWidth, pItem, title, trimmedPath);
1221
1222         if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
1223         {
1224                 Button* pClearButton = new (std::nothrow) Button();
1225                 pClearButton->Construct(Rectangle(itemWidth - H_ICON - W_TEXT_MARGIN, (H_ITEM_DOUBLE_LINE - H_ICON) / 2, H_ICON, H_ICON));
1226                 pClearButton->SetActionId(IDA_BUTTON_RINGTONE_CLEAR);
1227                 pClearButton->AddActionEventListener(*this);
1228
1229                 Bitmap* pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_NORMAL);
1230                 if (pReset != null)
1231                 {
1232                         pClearButton->SetNormalBitmap(Point(0, 0), *pReset);
1233                         delete pReset;
1234                 }
1235                 pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_PRESSED);
1236                 if (pReset != null)
1237                 {
1238                         pClearButton->SetPressedBitmap(Point(0, 0), *pReset);
1239                         delete pReset;
1240                 }
1241
1242                 pItem->AddControl(*pClearButton);
1243                 pItem->SetIndividualSelectionEnabled(pClearButton, true);
1244         }
1245 }
1246
1247 void
1248 ContactDetailsForm::AddShareButtons(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1249 {
1250         pItem->Construct(Dimension(itemWidth, H_BUTTON_CONTAINER));
1251
1252         int buttonWidth = itemWidth - W_BUTTON_GAP * 2;
1253
1254         Button* pSendNameButton = new (std::nothrow) Button();
1255         pSendNameButton->Construct(Rectangle(W_BUTTON_GAP, Y_BUTTON, buttonWidth, H_BUTTON), ResourceManager::GetString(L"IDS_PB_HEADER_SEND_NAMECARD"));
1256         pSendNameButton->SetActionId(IDA_BUTTON_SHARE_NAME_CARD);
1257         pSendNameButton->AddActionEventListener(*this);
1258         pItem->AddControl(*pSendNameButton);
1259 }
1260
1261 void
1262 ContactDetailsForm::CreateValueTypeItem(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, const Tizen::Base::String& value, const Tizen::Base::String& type)
1263 {
1264         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1265         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1266
1267         Label* pValueLabel = new (std::nothrow) Label();
1268         pValueLabel->Construct(Rectangle(W_TEXT_MARGIN, 0, itemWidth - W_TEXT_MARGIN * 2 - W_TYPE, H_ITEM), value);
1269         pValueLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1270         pValueLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1271         pValueLabel->SetTextConfig(FONT_SIZE_MAIN_TEXT, LABEL_TEXT_STYLE_NORMAL);
1272         pValueLabel->SetTextColor(COLOR_OTHER_NUMBER);
1273         pItem->AddControl(*pValueLabel);
1274
1275         Label* pTypeLabel = new (std::nothrow) Label();
1276         pTypeLabel->Construct(Rectangle((itemWidth - W_TEXT_MARGIN - W_TYPE), 0, W_TYPE, H_ITEM), type);
1277         pTypeLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1278         pTypeLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1279         pTypeLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1280         pTypeLabel->SetTextColor(COLOR_ITEM_TYPE);
1281         pItem->AddControl(*pTypeLabel);
1282 }
1283
1284 void
1285 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)
1286 {
1287         int valueWidth = itemWidth - (W_TEXT_MARGIN * 2);
1288
1289         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1290         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1291
1292         Label* pTitleLabel = new (std::nothrow) Label();
1293         pTitleLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE, itemWidth - W_TEXT_MARGIN, H_ITEM_TITLE), title);
1294         pTitleLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1295         pTitleLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1296         pTitleLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1297         pTitleLabel->SetTextColor(COLOR_ITEM_TITLE);
1298         pItem->AddControl(*pTitleLabel);
1299
1300         if (type.IsEmpty() == false)
1301         {
1302                 Label* pTypeLabel = new (std::nothrow) Label();
1303                 pTypeLabel->Construct(Rectangle((itemWidth - W_TEXT_MARGIN - W_TYPE), Y_ITEM_TITLE + H_ITEM_TITLE, W_TYPE, H_ITEM_VALUE), type);
1304                 pTypeLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1305                 pTypeLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1306                 pTypeLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1307                 pTypeLabel->SetTextColor(COLOR_ITEM_TYPE);
1308                 pItem->AddControl(*pTypeLabel);
1309
1310                 valueWidth = itemWidth - (W_TEXT_MARGIN * 2) - W_TYPE;
1311         }
1312         else if (title.Equals(ResourceManager::GetString(L"IDS_PB_BODY_RINGTONE"), false))
1313         {
1314                 valueWidth = itemWidth - (W_TEXT_MARGIN * 2) - H_ICON;
1315         }
1316
1317         Label* pValueLabel = new (std::nothrow) Label();
1318         pValueLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE + H_ITEM_TITLE, valueWidth, H_ITEM_VALUE * lineCount), value);
1319         pValueLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1320         pValueLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1321         pValueLabel->SetTextConfig(FONT_SIZE_MAIN_TEXT, LABEL_TEXT_STYLE_NORMAL);
1322         pValueLabel->SetTextColor(COLOR_ITEM_VALUE);
1323         pItem->AddControl(*pValueLabel);
1324 }
1325
1326 void
1327 ContactDetailsForm::CreateTitleValueTypeItem(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, int detailProperty)
1328 {
1329         String title;
1330
1331         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1332         pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1333
1334         switch (detailProperty)
1335         {
1336         case DETAIL_PROPERTY_EMAIL:
1337                 {
1338                         title = ResourceManager::GetString(L"IDS_COM_BODY_EMAIL");
1339                 }
1340                 break;
1341         case DETAIL_PROPERTY_ADDRESS:
1342                 {
1343                         title = ResourceManager::GetString(L"IDS_PB_BODY_ADDRESS");
1344                 }
1345                 break;
1346         case DETAIL_PROPERTY_URL:
1347                 {
1348                         title = ResourceManager::GetString(L"IDS_PB_BODY_URL");
1349                 }
1350                 break;
1351         case DETAIL_PROPERTY_IM_ADDRESS:
1352                 {
1353                         title = ResourceManager::GetString(L"IDS_PB_HEADER_INSTANT_MESSENGER_ABB");
1354                 }
1355                 break;
1356         default:
1357                 break;
1358         }
1359
1360         Label* pTitleLabel = new (std::nothrow) Label();
1361         pTitleLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE, itemWidth - W_TEXT_MARGIN, H_ITEM_TITLE), title);
1362         pTitleLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1363         pTitleLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1364         pTitleLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1365         pTitleLabel->SetTextColor(COLOR_ITEM_TITLE);
1366         pItem->AddControl(*pTitleLabel);
1367
1368         for (int i = 0; i < __pPresentationModel->GetMultiValuesCount(static_cast<DetailProperty>(detailProperty)); i++)
1369         {
1370                 String type = __pPresentationModel->GetType(static_cast<DetailProperty>(detailProperty), i);
1371                 String value = __pPresentationModel->GetValue(static_cast<DetailProperty>(detailProperty), i);
1372
1373                 int valueWidth = itemWidth - (W_TEXT_MARGIN * 2);
1374                 if (type.IsEmpty() == false)
1375                 {
1376                         Label* pTypeLabel = new (std::nothrow) Label();
1377                         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);
1378                         pTypeLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1379                         pTypeLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1380                         pTypeLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_BOLD);
1381                         pTypeLabel->SetTextColor(COLOR_ITEM_TYPE);
1382                         pItem->AddControl(*pTypeLabel);
1383
1384                         valueWidth = itemWidth - (W_TEXT_MARGIN * 2) - W_TYPE;
1385                 }
1386
1387                 Label* pValueLabel = new (std::nothrow) Label();
1388                 pValueLabel->Construct(Rectangle(W_TEXT_MARGIN, Y_ITEM_TITLE + H_ITEM_TITLE + (H_ADDITIONAL_ITEM * i), valueWidth, H_ITEM_VALUE), value);
1389                 pValueLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1390                 pValueLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1391                 pValueLabel->SetTextConfig(FONT_SIZE_MAIN_TEXT, LABEL_TEXT_STYLE_NORMAL);
1392                 pValueLabel->SetTextColor(COLOR_ITEM_VALUE);
1393                 pItem->AddControl(*pValueLabel);
1394         }
1395 }
1396
1397 void
1398 ContactDetailsForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1399 {
1400         SceneManager* pSceneManager = SceneManager::GetInstance();
1401
1402         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1403         {
1404                 String itemName = pItem->GetName();
1405
1406                 if (itemName.Equals(Integer::ToString(DETAIL_PROPERTY_GROUP), true) == true)
1407                 {
1408                         if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == true)
1409                         {
1410                                 return;
1411                         }
1412
1413                         if (__pPresentationModel->GetCategoryCount() > 0)
1414                         {
1415                                 IList* pCategoryList = __pPresentationModel->GetAssignedCategoryIdListN();
1416
1417                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_SELECTOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pCategoryList);
1418                         }
1419                         else
1420                         {
1421                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
1422                         }
1423                 }
1424                 else if (itemName.Equals(Integer::ToString(DETAIL_PROPERTY_RINGTONE), true) == true)
1425                 {
1426                         if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == true)
1427                         {
1428                                 return;
1429                         }
1430
1431                         result r = LaunchAppControl(PROVIDER_ID_FILEMANAGER, OPERATION_ID_PICK);
1432                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
1433                 }
1434                 else if (itemName.IsEmpty() == false)
1435                 {
1436                         Point itemPoint;
1437                         itemPoint.x = GetClientAreaBounds().width / 2;
1438                         itemPoint.y = GetClientAreaBounds().y + pItem->GetY() + (pItem->GetHeight() / 2) - __scrolledDistance;
1439
1440                         __pContextMenuCall->SetName(itemName);
1441                         __pContextMenuCall->SetAnchorPosition(itemPoint);
1442                         __pContextMenuCall->SetShowState(true);
1443                         __pContextMenuCall->Show();
1444                 }
1445         }
1446 }
1447
1448 void
1449 ContactDetailsForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1450 {
1451 }
1452
1453 void
1454 ContactDetailsForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo)
1455 {
1456 }
1457
1458 void
1459 ContactDetailsForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
1460 {
1461 }
1462
1463 void
1464 ContactDetailsForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1465 {
1466         if (source.GetName().Equals(FAVORITE_LABEL, true))
1467         {
1468                 Label* pLabel = static_cast<Label*>(&const_cast<Control&>(source));
1469                 if (pLabel == null)
1470                 {
1471                         return;
1472                 }
1473
1474                 __pPresentationModel->SetAsFavorite(!__pPresentationModel->IsFavorite());
1475
1476                 Bitmap* pBitmap = null;
1477                 if (__pPresentationModel->IsFavorite())
1478                 {
1479                         pBitmap = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_ON);
1480                 }
1481                 else
1482                 {
1483                         pBitmap = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_OFF);
1484                 }
1485
1486                 if (pBitmap != null)
1487                 {
1488                         pLabel->SetBackgroundBitmap(*pBitmap);
1489                         delete pBitmap;
1490                 }
1491                 pLabel->Invalidate(false);
1492         }
1493 }
1494
1495 void
1496 ContactDetailsForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1497 {
1498 }
1499
1500 void
1501 ContactDetailsForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1502 {
1503 }
1504
1505 void
1506 ContactDetailsForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1507 {
1508 }
1509
1510 void
1511 ContactDetailsForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1512 {
1513 }
1514
1515 void
1516 ContactDetailsForm::OnScrollEndReached (Tizen::Ui::Control &source, Tizen::Ui::Controls::ScrollEndEvent type)
1517 {
1518 }
1519
1520 void
1521 ContactDetailsForm::OnScrollPositionChanged (Tizen::Ui::Control &source, int scrollPos)
1522 {
1523         __scrolledDistance = scrollPos;
1524 }
1525
1526 void
1527 ContactDetailsForm::OnScrollStopped (Tizen::Ui::Control &source)
1528 {
1529 }
1530
1531 void
1532 ContactDetailsForm::OnContactsChanged(void)
1533 {
1534         if (__pPresentationModel->IsContactRemoved())
1535         {
1536                 if (__appControlViewType.IsEmpty() == true)
1537                 {
1538                         SceneManager* pSceneManager = SceneManager::GetInstance();
1539
1540                         result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
1541                         TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
1542                 }
1543                 else
1544                 {
1545                         UiApp::GetInstance()->Terminate();
1546                 }
1547         }
1548         else
1549         {
1550                 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1551                 TryReturnVoid(pContactsApp != null, "Unable to get ContactsApp instance.");
1552
1553                 if (pContactsApp->GetAppUiState() == APP_UI_STATE_BACKGROUND)
1554                 {
1555                         __pTableView->UpdateTableView();
1556                 }
1557         }
1558
1559         delete __pDefaultSelectorPopup;
1560         __pDefaultSelectorPopup = null;
1561 }
1562
1563 void
1564 ContactDetailsForm::OnCategoriesChanged(void)
1565 {
1566 }
1567
1568 result
1569 ContactDetailsForm::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, const Tizen::Base::String& launchType, const Tizen::Base::String& value)
1570 {
1571         result r = E_SUCCESS;
1572
1573         if (__pAppControl != null)
1574         {
1575                 return E_FAILURE;
1576         }
1577
1578         String uri;
1579         String mimeType;
1580         HashMap extraData;
1581         extraData.Construct();
1582         IAppControlResponseListener* pEvent = null;
1583
1584         if (appId.Equals(String(PROVIDER_ID_PHONE)) && operationId.Equals(String(OPERATION_ID_CALL)))
1585         {
1586                 uri.Append(INPUT_URI_TEL);
1587
1588                 if (value.IsEmpty())
1589                 {
1590                         uri.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER));
1591                 }
1592                 else
1593                 {
1594                         uri.Append(value);
1595                 }
1596
1597                 extraData.Add(new (std::nothrow) String(INPUT_KEY_CALL_TYPE), new (std::nothrow) String(launchType));
1598         }
1599         else if (appId.Equals(String(PROVIDER_ID_MESSAGE)) && operationId.Equals(String(OPERATION_ID_COMPOSE)))
1600         {
1601                 String recipientAddress;
1602
1603                 if (value.IsEmpty())
1604                 {
1605                         recipientAddress.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER));
1606                 }
1607                 else
1608                 {
1609                         recipientAddress.Append(value);
1610                 }
1611                 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TO), new (std::nothrow) String(recipientAddress));
1612                 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TYPE), new (std::nothrow) String(INPUT_TYPE_SMS));
1613         }
1614         else if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
1615         {
1616                 mimeType.Append(INPUT_MIME_TYPE_AUDIO);
1617                 extraData.Add(new (std::nothrow) String(INPUT_KEY_SELECTION_MODE), new (std::nothrow) String(INPUT_DATA_SELECTION_MODE_SINGLE));
1618
1619                 pEvent = this;
1620         }
1621         else if (appId.Equals(String(PROVIDER_ID_EMAIL)) && operationId.Equals(String(OPERATION_ID_COMPOSE)))
1622         {
1623                 ArrayList* pArgList = new (std::nothrow) ArrayList();
1624                 pArgList->Construct();
1625
1626                 pArgList->Add(new (std::nothrow) String(__pPresentationModel->GetValue(DETAIL_PROPERTY_EMAIL, 0)));
1627                 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TO), pArgList);
1628         }
1629
1630         __pAppControl = AppManager::FindAppControlN(appId, operationId);
1631         if (__pAppControl != null)
1632         {
1633                 r = __pAppControl->Start(&uri, &mimeType, &extraData, pEvent);
1634                 TryCatch(r == E_SUCCESS, , "[%s] Unable to launch app control", GetErrorMessage(r));
1635
1636                 if (operationId.Equals(String(OPERATION_ID_PICK)))
1637                 {
1638                         SetEnabled(false);
1639                         Invalidate(true);
1640                 }
1641         }
1642
1643 CATCH:
1644         extraData.RemoveAll(true);
1645
1646         return r;
1647 }
1648
1649 void
1650 ContactDetailsForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1651 {
1652         AppLogDebug("ENTER");
1653
1654         SetEnabled(true);
1655         Invalidate(true);
1656
1657         if (pExtraData == null)
1658         {
1659                 return;
1660         }
1661
1662         if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
1663         {
1664                 if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1665                 {
1666                         const String *pResultString = null;
1667                         const ArrayList* pResultList = dynamic_cast<const ArrayList*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
1668                         if (pResultList != null)
1669                         {
1670                                 pResultString = static_cast<const String*>(pResultList->GetAt(0));
1671                         }
1672                         else
1673                         {
1674                                 pResultString = static_cast<const String*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
1675                         }
1676
1677                         if (pResultString != null && pResultString->IsEmpty() == false)
1678                         {
1679                                 __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, *pResultString);
1680                                 __pPresentationModel->UpdateContact();
1681                                 __pTableView->RefreshItem(__pItemList->GetCount() - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1682                         }
1683                 }
1684         }
1685
1686         AppLogDebug("EXIT");
1687 }
1688
1689 void
1690 ContactDetailsForm::AddGroupStylePanel(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::GroupStyle groupStyle)
1691 {
1692         Panel* pGroupStyle = new (std::nothrow) Panel();
1693         pGroupStyle->Construct(Rectangle(W_GROUP_STYLE_MARGIN, 0, itemWidth - W_GROUP_STYLE_MARGIN * 2, H_ITEM_DOUBLE_LINE), groupStyle);
1694         pGroupStyle->SetBackgroundColor(COLOR_GROUP_STYLE);
1695         pItem->AddControl(*pGroupStyle);
1696 }
1697
1698 result
1699 ContactDetailsForm::ParseAppControlArgument(const Tizen::Base::String& argument, Tizen::Base::String& type, Tizen::Base::String& content)
1700 {
1701         result r = E_SUCCESS;
1702
1703         if (argument.IsEmpty() || argument.Contains(DELIMITER) == false)
1704         {
1705                 return E_FAILURE;
1706         }
1707
1708         StringTokenizer stringToken(argument, DELIMITER);
1709
1710         r = stringToken.GetNextToken(type);
1711         TryReturn(r == E_SUCCESS, r, "[%s] Unable to get type", GetErrorMessage(r));
1712
1713         r = stringToken.GetNextToken(content);
1714         TryReturn(r == E_SUCCESS, r, "[%s] Unable to get content", GetErrorMessage(r));
1715
1716         return r;
1717 }
1718
1719 void
1720 ContactDetailsForm::ShowDefaultSelectorPopup(void)
1721 {
1722         ArrayList* pList = new (std::nothrow) ArrayList();
1723         pList->Construct();
1724
1725         String numberWithType;
1726         int numberCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
1727         for (int index = 0; index < numberCount; index++)
1728         {
1729                 numberWithType = __pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, index) + L"  ";
1730                 numberWithType += __pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, index);
1731
1732                 pList->Add(*(new (std::nothrow) String(numberWithType)));
1733         }
1734         ContactValueListItemProvider* pProvider = new (std::nothrow) ContactValueListItemProvider(pList);
1735
1736         delete __pDefaultSelectorPopup;
1737         __pDefaultSelectorPopup = new (std::nothrow) Popup();
1738         __pDefaultSelectorPopup->Construct(true, Dimension(W_POPUP, H_POPUP));
1739         __pDefaultSelectorPopup->SetTitleText(ResourceManager::GetString(L"IDS_PB_BODY_MARK_AS_DEFAULT_NUMBER"));
1740
1741         Rectangle popupClientBounds = __pDefaultSelectorPopup->GetClientAreaBounds();
1742
1743         ListView* pOtherNumberList = new (std::nothrow) ListView();
1744         pOtherNumberList->Construct(Rectangle(0, 0, popupClientBounds.width, H_POPUP_LIST_VIEW));
1745         pOtherNumberList->AddListViewItemEventListener(*this);
1746         pOtherNumberList->SetItemProvider(*pProvider);
1747
1748         __pDefaultSelectorPopup->AddControl(*pOtherNumberList);
1749
1750         Button* pCloseButton = new (std::nothrow) Button();
1751         pCloseButton->Construct(Rectangle((popupClientBounds.width - W_POPUP_BUTTON) / 2, Y_POPUP_BUTTON,
1752                                                                         W_POPUP_BUTTON, H_POPUP_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CLOSE"));
1753         pCloseButton->SetActionId(IDA_POPUP_CLOSE);
1754         pCloseButton->AddActionEventListener(*this);
1755
1756         __pDefaultSelectorPopup->AddControl(*pCloseButton);
1757         __pDefaultSelectorPopup->SetShowState(true);
1758         __pDefaultSelectorPopup->Show();
1759 }
1760
1761 void
1762 ContactDetailsForm::HideDefaultSelectorPopup(void)
1763 {
1764         __pDefaultSelectorPopup->SetShowState(false);
1765
1766         Invalidate(true);
1767 }
1768
1769 void
1770 ContactDetailsForm::ShowInvalidFilePopup(void)
1771 {
1772         if (__pInvalidFilePopup != null)
1773         {
1774                 delete __pInvalidFilePopup;
1775         }
1776
1777         __pInvalidFilePopup = new (std::nothrow) Popup();
1778         __pInvalidFilePopup->Construct(false, Dimension(W_POPUP, H_INVALID_FILE_POPUP));
1779
1780         Rectangle clientBounds = __pInvalidFilePopup->GetClientAreaBounds();
1781
1782         Label* pLabelText = new (std::nothrow) Label();
1783         pLabelText->Construct(Rectangle(0, Y_POPUP_TEXT_LABEL, clientBounds.width, H_POPUP_TEXT_LABEL), ResourceManager::GetString(L"IDS_RSSR_BODY_INVALID_FORMAT"));
1784         pLabelText->SetTextColor(COLOR_POPUP_TEXT);
1785         pLabelText->SetTextConfig(FONT_SIZE_POPUP_TEXT, LABEL_TEXT_STYLE_BOLD);
1786         pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1787
1788         __pInvalidFilePopup->AddControl(*pLabelText);
1789
1790         Button* pButtonClose = new (std::nothrow) Button();
1791         pButtonClose->Construct(Rectangle((clientBounds.width - W_POPUP_BUTTON) / 2, pLabelText->GetY() + pLabelText->GetHeight(), W_POPUP_BUTTON, H_POPUP_BUTTON));
1792         pButtonClose->SetText(ResourceManager::GetString("IDS_COM_SK_OK"));
1793         pButtonClose->SetActionId(IDA_INVALID_FILE_POPUP_CLOSE);
1794         pButtonClose->AddActionEventListener(*this);
1795
1796         __pInvalidFilePopup->AddControl(*pButtonClose);
1797
1798         __pInvalidFilePopup->Show();
1799 }
1800
1801 void
1802 ContactDetailsForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1803 {
1804         __pPresentationModel->SetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER, L"", index);
1805         __pPresentationModel->AddAddressBook();
1806         InitializeDetailItemList();
1807         __pTableView->UpdateTableView();
1808
1809         HideDefaultSelectorPopup();
1810 }
1811
1812 void
1813 ContactDetailsForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1814 {
1815 }
1816
1817 void
1818 ContactDetailsForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
1819 {
1820 }
1821
1822 void
1823 ContactDetailsForm::OnForeground(void)
1824 {
1825         if (IsEnabled() == false)
1826         {
1827                 SetEnabled(true);
1828                 Invalidate(true);
1829         }
1830
1831         delete __pAppControl;
1832         __pAppControl = null;
1833 }
1834
1835 void
1836 ContactDetailsForm::OnBackground(void)
1837 {
1838 }