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