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