2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
18 * @file CtContactDetailsForm.cpp
19 * @brief This is the implementation file for the ContactDetailsForm class.
26 #include "CtContactDetailsForm.h"
27 #include "CtContactPresentationModel.h"
28 #include "CtContactValueListItemProvider.h"
29 #include "CtContactsApp.h"
30 #include "CtResourceManager.h"
31 #include "CtSceneRegister.h"
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;
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;
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";
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";
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;
92 static const int W_QUICK_BUTTON_GAP = 148;
93 static const int X_QUICK_BUTTON = 148;
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;
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;
121 static const int SUB_INDEX_MASK = 0xF000;
122 static const int MESSAGE_BOX_TIMEOUT_MS = 300000;
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;
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;
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";
160 ContactDetailsForm::ContactDetailsForm(void)
161 : __isAppControlLaunching(false)
162 , __pAppControl(null)
164 , __pContextMenuCall(null)
165 , __pContextMenuShare(null)
166 , __pFileEventManager(null)
167 , __pOptionMenu(null)
168 , __pDefaultSelectorPopup(null)
169 , __pDeletePopup(null)
171 , __pPresentationModel(null)
172 , __scrolledDistance(0)
173 , __pFavoriteButton(null)
174 , __pGroupsItem(null)
175 , __pRingtoneItem(null)
176 , __pClearButton(null)
180 ContactDetailsForm::~ContactDetailsForm(void)
185 ContactDetailsForm::Initialize(void)
187 Construct(L"IDL_CONTACT_DETAILS_FORM");
191 ContactDetailsForm::OnInitializing(void)
193 Footer* pFooter = GetFooter();
194 pFooter->AddActionEventListener(*this);
195 SetFormBackEventListener(this);
196 SetFormMenuEventListener(this);
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);
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);
214 __pContextMenuCall->AddActionEventListener(*this);
215 __pContextMenuCall->SetFocusable(true);
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);
224 __pItemList = new (std::nothrow) ArrayListT<int>();
225 __pItemList->Construct();
227 __pPresentationModel = new (std::nothrow) ContactPresentationModel();
228 __pPresentationModel->Construct();
229 __pPresentationModel->AddContactChangeListener(*this);
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);
241 ContactDetailsForm::OnTerminating(void)
243 delete __pAppControl;
244 delete __pContextMenuCall;
245 delete __pContextMenuShare;
246 delete __pFileEventManager;
247 delete __pOptionMenu;
249 if (__pItemList != null)
251 __pItemList->RemoveAll();
255 if (__pPresentationModel != null)
257 __pPresentationModel->RemoveContactChangeListener(*this);
258 delete __pPresentationModel;
260 if (__pDeletePopup != null)
262 delete __pDeletePopup;
265 delete __pDefaultSelectorPopup;
271 ContactDetailsForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
273 AppLog("ContactDetailsForm::OnActionPerformed(), actionId %d", actionId);
275 result r = E_SUCCESS;
276 SceneManager* pSceneManager = SceneManager::GetInstance();
280 case IDA_FOOTER_EDIT:
282 __currentFocusedItem = L"";
283 ArrayList* pList = new (std::nothrow) ArrayList();
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));
290 case IDA_FOOTER_DELETE:
292 __currentFocusedItem = L"";
298 __currentFocusedItem = L"";
299 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
301 if (pContactsApp->GetOperationId() == OPERATION_ID_VIEW)
303 if(Tizen::Io::File::IsFileExist(__pPresentationModel->GetVcfPath()) == false)
305 ShowInvalidFileMessageBox(ResourceManager::GetString(L"IDS_MP_POP_INVALID_FILE"), true);
310 ArrayList* pList = new (std::nothrow) ArrayList();
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));
318 case IDA_MORE_DEFAULT_NUMBER:
320 __currentFocusedItem = L"";
321 ShowDefaultSelectorPopup();
324 case IDA_BUTTON_RINGTONE_CLEAR:
326 __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, String());
327 __pPresentationModel->UpdateContact();
328 __pTableView->RefreshItem(__pItemList->GetCount() - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
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));
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));
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));
352 case IDA_CONTEXTMENU_SHARE_EMAIL:
354 __currentFocusedItem = L"";
355 r = LaunchAppControl(PROVIDER_ID_EMAIL, OPERATION_ID_COMPOSE);
356 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to launch appcontrol", GetErrorMessage(r));
359 case IDA_CONTEXTMENU_SHARE_MESSAGE:
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));
366 case IDA_BUTTON_SHARE_NAME_CARD:
368 __currentFocusedItem = L"";
370 itemPoint.x = GetClientAreaBounds().width / 2;
373 TableViewItem* pParent = static_cast<TableViewItem*>(source.GetParent());
376 itemPoint.y = GetClientAreaBounds().y + pParent->GetY() + source.GetY() - __scrolledDistance;
379 __pContextMenuShare->SetAnchorPosition(itemPoint);
380 __pContextMenuShare->SetShowState(true);
381 __pContextMenuShare->Show();
384 case IDA_POPUP_CLOSE:
386 HideDefaultSelectorPopup();
389 case IDA_FAVORITE_BUTTON:
391 __pFavoriteButton = static_cast<Button*>(&const_cast<Control&>(source));
392 if (__pFavoriteButton == null)
397 __pPresentationModel->SetAsFavorite(!__pPresentationModel->IsFavorite());
399 Bitmap* pBitmapNormal = null;
400 Bitmap* pBitmapPressed = null;
401 if (__pPresentationModel->IsFavorite())
403 pBitmapNormal = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_ON);
404 pBitmapPressed = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_OFF);
408 pBitmapNormal = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_OFF);
409 pBitmapPressed = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_ON);
412 if (pBitmapNormal != null && pBitmapPressed != null)
414 __pFavoriteButton->SetNormalBackgroundBitmap(*pBitmapNormal);
415 __pFavoriteButton->SetPressedBackgroundBitmap(*pBitmapPressed);
416 delete pBitmapNormal;
417 delete pBitmapPressed;
419 __pFavoriteButton->Invalidate(false);
422 case IDA_POPUP_DELETE_OK:
424 r = __pPresentationModel->RemoveContact();
425 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to remove contact", GetErrorMessage(r));
429 case IDA_POPUP_DELETE_CANCEL:
440 ContactDetailsForm::ShowDeletePopup(void)
442 if (__pDeletePopup == null)
444 __pDeletePopup = new (std::nothrow) Popup();
445 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
446 __pDeletePopup->SetPropagatedKeyEventListener(this);
448 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
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);
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);
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);
471 __pDeletePopup->AddControl(pLabel);
472 __pDeletePopup->AddControl(pDeleteButton);
473 __pDeletePopup->AddControl(pCancelButton);
476 __pDeletePopup->SetShowState(true);
477 __pDeletePopup->Show();
481 ContactDetailsForm::HideDeletePopup(void)
483 if (__pDeletePopup != null)
485 __pDeletePopup->SetShowState(false);
491 ContactDetailsForm::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
493 __pOptionMenu->SetShowState(true);
494 __pOptionMenu->Show();
498 ContactDetailsForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
500 if (__appControlViewType.IsEmpty() == false)
502 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
503 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
505 result r = pAppManager->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_CANCELED, null);
506 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
508 UiApp::GetInstance()->Terminate();
512 SceneManager* pSceneManager = SceneManager::GetInstance();
514 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
515 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
520 ContactDetailsForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, IList* pArgs)
522 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
523 TryReturnVoid(pContactsApp != null, "Unable to cast UiApp to ContactsApp");
525 pContactsApp->AddContactsAppChangeEventListener(*this);
526 SettingInfo::AddSettingEventListener(*this);
528 if (previousSceneId == IDSCN_GROUP_SELECTOR || previousSceneId == IDSCN_GROUP_EDITOR)
535 Integer* pArgument = null;
536 __pPresentationModel->RemoveContactFromAllCategories();
537 IEnumerator* pEnum = pArgs->GetEnumeratorN();
538 while (pEnum->MoveNext() == E_SUCCESS)
540 pArgument = static_cast<Integer*>(pEnum->GetCurrent());
541 if (pArgument != null)
543 __pPresentationModel->AddContactToCategory(pArgument->ToInt());
548 __pTableView->RefreshItem(__pItemList->GetCount() - 2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
550 else if (previousSceneId == IDSCN_CONTACT_EDITOR && __appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
552 InitializeDetailItemList();
553 __pTableView->UpdateTableView();
562 if (pContactsApp->GetOperationId() == OPERATION_ID_VIEW)
564 __pPresentationModel->RemoveContactChangeListener(*this);
565 SettingInfo::RemoveSettingEventListener(*this);
567 String *pError = static_cast<String*>(pArgs->GetAt(2));
570 ShowInvalidFileMessageBox(*pError);
573 result r = InitializeAppControl(pArgs);
577 pArgs->RemoveAll(true);
579 AppLogDebug("Unable to initialize appcontrol");
581 ShowInvalidFileMessageBox(ResourceManager::GetString(L"IDS_RSSR_BODY_INVALID_FORMAT"));
586 InitializeDetailItemList();
590 Integer* pContactId = static_cast<Integer*>(pArgs->GetAt(0));
591 if (pContactId != null)
593 __pPresentationModel->SetContactId(pContactId->ToInt());
594 InitializeDetailItemList();
597 __pTableView->UpdateTableView();
602 pArgs->RemoveAll(true);
608 ContactDetailsForm::InitializeAppControl(Tizen::Base::Collection::IList* pArgs)
615 result r = E_SUCCESS;
617 String* pArgStringType = null;
618 String* pArgStringValue = null;
621 String valueViewType;
624 pArgStringType = static_cast<String*>(pArgs->GetAt(0));
625 pArgStringValue = static_cast<String*>(pArgs->GetAt(1));
627 TryReturn(pArgStringType != null && pArgStringValue != null, E_FAILURE, "[E_FAILURE] Unable to initialize appcontrol");
629 ParseAppControlArgument(*pArgStringType, keyViewType, valueViewType);
630 ParseAppControlArgument(*pArgStringValue, keyValue, value);
632 if (keyViewType.Equals(KEY_VIEW_TYPE, false))
634 if (valueViewType.Equals(VALUE_VIEW_TYPE_CONTACT, false))
636 if (keyValue.Equals(KEY_VIEW_TYPE_CONTACT_ID, false))
639 Integer::Parse(value, contactId);
640 r = __pPresentationModel->SetContactId(contactId);
641 __appControlViewType = valueViewType;
643 Footer* pFooter = GetFooter();
644 pFooter->RemoveAllItems();
646 FooterItem footerItemEdit;
647 footerItemEdit.Construct(IDA_FOOTER_EDIT);
648 footerItemEdit.SetText(ResourceManager::GetString(L"IDS_COM_SK_EDIT"));
649 pFooter->AddItem(footerItemEdit);
651 __pPresentationModel->AddContactChangeListener(*this);
655 AppLogDebug("Invalid KEY(contactId) of AppControl[VIEW]. [%ls] has been input", keyValue.GetPointer());
659 else if (valueViewType.Equals(VALUE_VIEW_TYPE_VCF, false))
661 if (keyValue.Equals(KEY_VIEW_TYPE_VCF, false))
663 r = __pPresentationModel->SetVcfPath(value);
665 __appControlViewType = valueViewType;
666 Footer* pFooter = GetFooter();
667 pFooter->RemoveAllItems();
668 pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
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);
677 AppLogDebug("Invalid KEY(path) of AppControl[VIEW]. [%ls] has been input", keyValue.GetPointer());
683 AppLogDebug("viewType of AppControl[VIEW] should be either vcf or contact. [%ls] has been inpue", keyValue.GetPointer());
689 AppLogDebug("Invalid KEY(viewType) of AppControl[VIEW]. [%ls] has been input", keyViewType.GetPointer());
697 ContactDetailsForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
699 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
700 pContactsApp->RemoveContactsAppChangeEventListener(*this);
701 SettingInfo::RemoveSettingEventListener(*this);
703 delete __pAppControl;
704 __pAppControl = null;
708 ContactDetailsForm::InitializeDetailItemList(void)
710 if (__pItemList->GetCount() > 0)
712 __pItemList->RemoveAll();
716 __pItemList->Add(DETAIL_PROPERTY_MAIN_INFO);
718 // Other Phone Numbers
719 Footer* pFooter = GetFooter();
720 pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
721 int otherNumberCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
723 if (otherNumberCount > 1)
725 if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
727 SetFormMenuEventListener(this);
731 SetFormMenuEventListener(null);
734 for (int subIndex = 0; subIndex < otherNumberCount; subIndex++)
736 if (__pPresentationModel->GetDefaultNumberIndex() != subIndex)
738 __pItemList->Add(DETAIL_PROPERTY_PHONE_NUMBER + subIndex);
744 SetFormMenuEventListener(null);
747 if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL) > 0)
749 __pItemList->Add(DETAIL_PROPERTY_EMAIL);
752 if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_ADDRESS) > 0)
754 __pItemList->Add(DETAIL_PROPERTY_ADDRESS);
757 if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS) > 0)
759 __pItemList->Add(DETAIL_PROPERTY_IM_ADDRESS);
762 if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL) > 0)
764 __pItemList->Add(DETAIL_PROPERTY_URL);
767 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_BIRTHDAY).IsEmpty() == false)
769 __pItemList->Add(DETAIL_PROPERTY_BIRTHDAY);
772 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_NOTE).IsEmpty() == false)
774 __pItemList->Add(DETAIL_PROPERTY_NOTE);
777 __pItemList->Add(DETAIL_PROPERTY_GROUP);
778 __pItemList->Add(DETAIL_PROPERTY_RINGTONE);
782 ContactDetailsForm::GetItemCount(void)
784 return __pItemList->GetCount();
787 Tizen::Ui::Controls::TableViewItem*
788 ContactDetailsForm::CreateItem(int itemIndex, int itemWidth)
790 TableViewItem* pItem = new (std::nothrow) TableViewItem();
792 int contentItemIndex = -1;
793 int itemSubIndex = -1;
794 __pItemList->GetAt(itemIndex, contentItemIndex);
796 switch (contentItemIndex & SUB_INDEX_MASK)
798 case DETAIL_PROPERTY_PHONE_NUMBER:
800 itemSubIndex = contentItemIndex - DETAIL_PROPERTY_PHONE_NUMBER;
801 contentItemIndex = DETAIL_PROPERTY_PHONE_NUMBER;
804 case DETAIL_PROPERTY_EMAIL:
806 contentItemIndex = DETAIL_PROPERTY_EMAIL;
809 case DETAIL_PROPERTY_IM_ADDRESS:
811 contentItemIndex = DETAIL_PROPERTY_IM_ADDRESS;
814 case DETAIL_PROPERTY_ADDRESS:
816 contentItemIndex = DETAIL_PROPERTY_ADDRESS;
819 case DETAIL_PROPERTY_URL:
821 contentItemIndex = DETAIL_PROPERTY_URL;
828 switch (contentItemIndex)
830 case DETAIL_PROPERTY_MAIN_INFO:
832 AddMainInfo(itemWidth, pItem);
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:
843 AddProperty(itemWidth, pItem, contentItemIndex, itemSubIndex);
846 case DETAIL_PROPERTY_GROUP:
848 AddGroup(itemWidth, pItem);
851 case DETAIL_PROPERTY_RINGTONE:
853 AddRingTone(itemWidth, pItem);
868 ContactDetailsForm::DeleteItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
875 ContactDetailsForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
877 int contentItemIndex = -1;
878 __pItemList->GetAt(itemIndex, contentItemIndex);
882 if (contentItemIndex == DETAIL_PROPERTY_GROUP)
884 value = __pPresentationModel->GetValue(DETAIL_PROPERTY_GROUP);
888 value = ResourceManager::GetString(L"IDS_PB_BODY_NOT_ASSIGNED");
891 else if (contentItemIndex == DETAIL_PROPERTY_RINGTONE)
893 String path = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
895 path.LastIndexOf(L"/", path.GetLength() - 1, index);
899 path.SubString(index + 1, value);
903 Label* pValueLabel = static_cast<Label*>(pItem->GetControl(2));
904 if (pValueLabel == null)
909 pValueLabel->SetText(value);
910 pValueLabel->Invalidate(false);
914 ContactDetailsForm::GetDefaultItemHeight(void)
920 ContactDetailsForm::AddMainInfo(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
922 int itemHeight = Y_THUMBNAIL;
924 Label* pThumbnailLabel = null;
926 String thumbnailPath = __pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL);
927 Bitmap* pThumbnail = null;
928 ImageBuffer thumbnailImageBuffer;
929 result r = thumbnailImageBuffer.Construct(thumbnailPath);
932 pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);
934 if (pThumbnail != null)
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);
943 itemHeight += (H_THUMBNAIL + Y_THUMBNAIL);
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);
952 __pPresentationModel->GetDisplayName(name);
955 if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER))
957 name.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER));
961 name.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_EMAIL, 0));
966 if (jobTitle.IsEmpty() == false)
968 companyInfo = jobTitle + CHARACTER_SPACE;
970 if (company.IsEmpty() == false)
972 companyInfo += company + CHARACTER_SPACE;
974 if (department.IsEmpty() == false)
976 companyInfo += department;
979 Label* pNameLabel = null;
980 __pFavoriteButton = null;
981 if (name.IsEmpty() == false)
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);
990 if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
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);
999 Bitmap* pBitmapNormal = null;
1000 Bitmap* pBitmapPressed = null;
1001 if (__pPresentationModel->IsFavorite())
1003 pBitmapNormal = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_ON);
1004 pBitmapPressed = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_OFF);
1008 pBitmapNormal = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_OFF);
1009 pBitmapPressed = ResourceManager::GetBitmapN(IDB_DETAILS_FAVORITE_ON);
1012 if (pBitmapNormal != null && pBitmapPressed != null)
1014 __pFavoriteButton->SetNormalBackgroundBitmap(*pBitmapNormal);
1015 __pFavoriteButton->SetPressedBackgroundBitmap(*pBitmapPressed);
1016 delete pBitmapNormal;
1017 delete pBitmapPressed;
1021 itemHeight += H_NAME;
1024 Label* pSuffixNickNameLabel = null;
1025 if (nickName.IsEmpty() == false)
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);
1035 Label* pCompanyInfoLabel = null;
1036 if (companyInfo.IsEmpty() == false)
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);
1046 Label* pDefaultNumberLabel = null;
1047 Button* pCallButton = null;
1048 Button* pMessageButton = null;
1049 #if __SUPPORT_VIDEO_CALL
1050 Button* pVideoCallButton = null;
1053 String defaultPhoneNumber = __pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER);
1054 if (defaultPhoneNumber.IsEmpty() == false)
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);
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);
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)
1078 pCallButton->SetNormalBackgroundBitmap(*pBgNormal);
1080 if (pBgPressed != null)
1082 pCallButton->SetPressedBackgroundBitmap(*pBgPressed);
1084 if (pCallNormal != null)
1086 pCallButton->SetNormalBitmap(Point(0, 0), *pCallNormal);
1088 if (pCallPressed != null)
1090 pCallButton->SetPressedBitmap(Point(0, 0), *pCallPressed);
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)
1099 pMessageButton->SetNormalBackgroundBitmap(*pBgNormal);
1101 if (pBgPressed != null)
1103 pMessageButton->SetPressedBackgroundBitmap(*pBgPressed);
1105 if (pMessageNormal != null)
1107 pMessageButton->SetNormalBitmap(Point(0, 0), *pMessageNormal);
1109 if (pMessagePressed != null)
1111 pMessageButton->SetPressedBitmap(Point(0, 0), *pMessagePressed);
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)
1120 pVideoCallButton->SetNormalBackgroundBitmap(*pBgNormal);
1122 if (pBgPressed != null)
1124 pVideoCallButton->SetPressedBackgroundBitmap(*pBgPressed);
1126 if (pVideoCallNormal != null)
1128 pVideoCallButton->SetNormalBitmap(Point(0, 0), *pVideoCallNormal);
1130 if (pVideoCallPressed != null)
1132 pVideoCallButton->SetPressedBitmap(Point(0, 0), *pVideoCallPressed);
1139 delete pCallPressed;
1140 delete pMessageNormal;
1141 delete pMessagePressed;
1142 delete pVideoCallNormal;
1143 delete pVideoCallPressed;
1145 itemHeight += (H_QUICK_BUTTON + H_QUICK_BUTTON_DIVIDER);
1149 itemHeight += H_QUICK_BUTTON_DIVIDER;
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);
1156 if (pThumbnailLabel != null)
1158 pItem->AddControl(pThumbnailLabel);
1160 if (pNameLabel != null)
1162 pItem->AddControl(pNameLabel);
1164 if (__pFavoriteButton != null)
1166 pItem->AddControl(__pFavoriteButton);
1168 if (pSuffixNickNameLabel != null)
1170 pItem->AddControl(pSuffixNickNameLabel);
1172 if (pCompanyInfoLabel != null)
1174 pItem->AddControl(pCompanyInfoLabel);
1176 if (pDefaultNumberLabel != null)
1178 pItem->AddControl(pDefaultNumberLabel);
1180 #if __SUPPORT_VIDEO_CALL
1181 if (pCallButton != null && pMessageButton != null && pVideoCallButton != null)
1183 pItem->AddControl(pCallButton);
1184 pItem->AddControl(pMessageButton);
1185 pItem->AddControl(pVideoCallButton);
1188 if (pCallButton != null && pMessageButton != null)
1190 pItem->AddControl(pCallButton);
1191 pItem->AddControl(pMessageButton);
1197 ContactDetailsForm::AddProperty(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, int detailProperty, int itemSubIndex)
1203 int itemHeight = H_ITEM_DOUBLE_LINE;
1204 int valueCount = __pPresentationModel->GetMultiValuesCount(static_cast<DetailProperty>(detailProperty));
1206 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1207 if (detailProperty != DETAIL_PROPERTY_PHONE_NUMBER && valueCount > 1)
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);
1215 switch (detailProperty)
1217 case DETAIL_PROPERTY_PHONE_NUMBER:
1219 type = __pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, itemSubIndex);
1220 value = __pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, itemSubIndex);
1222 pItem->Construct(Dimension(itemWidth, H_ITEM + pContactsApp->GetFontHeightOffset()), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1223 pItem->SetName(value);
1225 CreateValueTypeItem(itemWidth, pItem, value, type);
1230 case DETAIL_PROPERTY_EMAIL:
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);
1237 case DETAIL_PROPERTY_ADDRESS:
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);
1244 case DETAIL_PROPERTY_IM_ADDRESS:
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);
1251 case DETAIL_PROPERTY_URL:
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);
1258 case DETAIL_PROPERTY_BIRTHDAY:
1260 title = ResourceManager::GetString(L"IDS_PB_BODY_BIRTHDAY");
1261 value = __pPresentationModel->GetValue(DETAIL_PROPERTY_BIRTHDAY);
1264 case DETAIL_PROPERTY_NOTE:
1266 pItem->Construct(Dimension(itemWidth, itemHeight + pContactsApp->GetFontHeightOffset()), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1267 CreateNoteItem(itemWidth, pItem);
1276 pItem->Construct(Dimension(itemWidth, itemHeight + pContactsApp->GetFontHeightOffset()), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1277 CreateTitleValueTypeItem(itemWidth, pItem, title, value, type, lineCount);
1281 ContactDetailsForm::AddGroup(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1283 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
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);
1289 String title = ResourceManager::GetString(L"IDS_PB_BODY_GROUPS");
1290 String value = __pPresentationModel->GetValue(DETAIL_PROPERTY_GROUP);
1292 if (value.IsEmpty())
1294 value = ResourceManager::GetString(L"IDS_PB_BODY_NOT_ASSIGNED");
1297 AddGroupStylePanel(itemWidth, pItem, GROUP_STYLE_TOP);
1299 CreateTitleValueTypeItem(itemWidth, pItem, title, value);
1300 __pGroupsItem = pItem;
1304 ContactDetailsForm::AddRingTone(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1306 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
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);
1312 String title = ResourceManager::GetString(L"IDS_PB_BODY_RINGTONE");
1313 String value = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
1317 value.LastIndexOf(L"/", value.GetLength() - 1, index);
1321 value.SubString(index + 1, trimmedPath);
1324 AddGroupStylePanel(itemWidth, pItem, GROUP_STYLE_BOTTOM);
1326 CreateTitleValueTypeItem(itemWidth, pItem, title, trimmedPath);
1328 if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == false)
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);
1337 Bitmap* pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_NORMAL);
1340 __pClearButton->SetNormalBitmap(Point(0, 0), *pReset);
1343 pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_PRESSED);
1346 __pClearButton->SetPressedBitmap(Point(0, 0), *pReset);
1350 pItem->AddControl(__pClearButton);
1351 pItem->SetIndividualSelectionEnabled(__pClearButton, true);
1352 __pRingtoneItem = pItem;
1357 ContactDetailsForm::AddShareButtons(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1359 pItem->Construct(Dimension(itemWidth, H_BUTTON_CONTAINER));
1361 int buttonWidth = itemWidth - W_BUTTON_GAP * 2;
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);
1371 ContactDetailsForm::CreateValueTypeItem(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, const Tizen::Base::String& value, const Tizen::Base::String& type)
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);
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);
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);
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)
1397 int valueWidth = itemWidth - (W_TEXT_MARGIN * 2);
1399 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1401 pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1402 pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
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);
1414 if (type.IsEmpty() == false)
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);
1426 valueWidth = itemWidth - (W_TEXT_MARGIN * 2) - W_TYPE;
1428 else if (title.Equals(ResourceManager::GetString(L"IDS_PB_BODY_RINGTONE"), false))
1430 valueWidth = itemWidth - (W_TEXT_MARGIN * 2) - H_ICON;
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);
1445 ContactDetailsForm::CreateTitleValueTypeItem(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, int detailProperty)
1448 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1450 pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1451 pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1453 switch (detailProperty)
1455 case DETAIL_PROPERTY_EMAIL:
1457 title = ResourceManager::GetString(L"IDS_COM_BODY_EMAIL");
1460 case DETAIL_PROPERTY_ADDRESS:
1462 title = ResourceManager::GetString(L"IDS_PB_BODY_ADDRESS");
1465 case DETAIL_PROPERTY_URL:
1467 title = ResourceManager::GetString(L"IDS_PB_BODY_URL");
1470 case DETAIL_PROPERTY_IM_ADDRESS:
1472 title = ResourceManager::GetString(L"IDS_PB_HEADER_INSTANT_MESSENGER_ABB");
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);
1487 for (int i = 0; i < __pPresentationModel->GetMultiValuesCount(static_cast<DetailProperty>(detailProperty)); i++)
1489 String type = __pPresentationModel->GetType(static_cast<DetailProperty>(detailProperty), i);
1490 String value = __pPresentationModel->GetValue(static_cast<DetailProperty>(detailProperty), i);
1492 int valueWidth = itemWidth - (W_TEXT_MARGIN * 2);
1493 if (type.IsEmpty() == false)
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);
1503 valueWidth = itemWidth - (W_TEXT_MARGIN * 2) - W_TYPE;
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);
1517 ContactDetailsForm::CreateNoteItem(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem)
1519 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1521 pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1522 pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1524 String title = ResourceManager::GetString(L"IDS_PB_BODY_NOTE");
1525 String value = __pPresentationModel->GetValue(DETAIL_PROPERTY_NOTE);
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);
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);
1544 font.Construct(FONT_STYLE_PLAIN, pContactsApp->GetFontSize());
1546 TextElement* pNameElement = new (std::nothrow) TextElement();
1547 pNameElement->Construct(value);
1548 pNameElement->SetFont(font);
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);
1556 pValueLabel->SetSize(pValueLabel->GetWidth(), pEnrichedText->GetTotalLineHeight() + pValueLabel->GetTopMargin());
1557 pItem->SetSize(itemWidth, (Y_ITEM_TITLE * 2) + H_ITEM_TITLE + pEnrichedText->GetTotalLineHeight());
1559 pEnrichedText->RemoveAllTextElements(true);
1560 delete pEnrichedText;
1564 ContactDetailsForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1566 SceneManager* pSceneManager = SceneManager::GetInstance();
1568 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1570 String itemName = pItem->GetName();
1572 if (itemName.Equals(Integer::ToString(DETAIL_PROPERTY_GROUP), true) == true)
1574 if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == true)
1579 if (__isAppControlLaunching == true)
1584 __currentFocusedItem.Clear();
1585 if (__pPresentationModel->GetCategoryCount() > 0)
1587 IList* pCategoryList = __pPresentationModel->GetAssignedCategoryIdListN();
1589 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_SELECTOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pCategoryList);
1593 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
1596 else if (itemName.Equals(Integer::ToString(DETAIL_PROPERTY_RINGTONE), true) == true)
1598 if (__isAppControlLaunching == true)
1603 if (__appControlViewType.Equals(VALUE_VIEW_TYPE_VCF, false) == true)
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));
1612 else if (itemName.IsEmpty() == false)
1614 if (__isAppControlLaunching == true)
1619 itemPoint.x = GetClientAreaBounds().width / 2;
1620 itemPoint.y = GetClientAreaBounds().y + pItem->GetY() + (pItem->GetHeight() / 2) - __scrolledDistance;
1622 __pContextMenuCall->SetName(itemName);
1623 __pContextMenuCall->SetAnchorPosition(itemPoint);
1624 __pContextMenuCall->SetShowState(true);
1625 __pContextMenuCall->Show();
1631 ContactDetailsForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1636 ContactDetailsForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo)
1641 ContactDetailsForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
1643 if (__isAppControlLaunching == true)
1648 Panel* pPanel = null;
1650 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
1652 pPanel = static_cast<Panel*>(&const_cast<Control&>(source));
1654 else if (source.GetName().Equals(GROUP_LABEL, true) || source.GetName().Equals(VALUE_LABEL, true))
1656 pPanel = static_cast<Panel*>(source.GetParent()->GetControl(GROUP_STYLE_PANEL));
1659 pPanel->SetBackgroundColor(COLOR_PRESSED);
1665 pPanel->SetBackgroundColor(COLOR_PRESSED);
1667 Label* pLabelValue = static_cast<Label*>(source.GetParent()->GetControl(VALUE_LABEL, true));
1668 pLabelValue->SetTextColor(Color(COLOR_ITEM_PRESSED));
1670 Label* pLabelTitle = static_cast<Label*>(source.GetParent()->GetControl(GROUP_LABEL, true));
1671 pLabelTitle->SetTextColor(Color(COLOR_ITEM_PRESSED));
1673 pPanel->Invalidate(true);
1674 pLabelValue->Invalidate(true);
1675 pLabelTitle->Invalidate(true);
1680 ContactDetailsForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1682 Panel* pPanel = null;
1684 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
1686 pPanel = static_cast<Panel*>(&const_cast<Control&>(source));
1689 else if (source.GetName().Equals(GROUP_LABEL, true) || source.GetName().Equals(VALUE_LABEL, true))
1691 pPanel = static_cast<Panel*>(source.GetParent()->GetControl(GROUP_STYLE_PANEL));
1696 pPanel->SetBackgroundColor(COLOR_GROUP_STYLE);
1698 Label* pLabelValue = static_cast<Label*>(source.GetParent()->GetControl(VALUE_LABEL, true));
1699 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
1701 Label* pLabelTitle = static_cast<Label*>(source.GetParent()->GetControl(GROUP_LABEL, true));
1702 pLabelTitle->SetTextColor(Color(COLOR_ITEM_TITLE));
1704 pPanel->Invalidate(true);
1705 pLabelValue->Invalidate(true);
1706 pLabelTitle->Invalidate(true);
1711 ContactDetailsForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1713 Panel* pPanel = null;
1715 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
1717 pPanel = static_cast<Panel*>(&const_cast<Control&>(source));
1720 else if (source.GetName().Equals(GROUP_LABEL, true) || source.GetName().Equals(VALUE_LABEL, true))
1722 pPanel = static_cast<Panel*>(source.GetParent()->GetControl(GROUP_STYLE_PANEL));
1727 pPanel->SetBackgroundColor(COLOR_GROUP_STYLE);
1729 Label* pLabelTitle = static_cast<Label*>(source.GetParent()->GetControl(GROUP_LABEL, true));
1730 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
1732 Label* pLabelValue = static_cast<Label*>(source.GetParent()->GetControl(VALUE_LABEL, true));
1733 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
1735 pPanel->Invalidate(true);
1736 pLabelValue->Invalidate(true);
1737 pLabelTitle->Invalidate(true);
1742 ContactDetailsForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1747 ContactDetailsForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1752 ContactDetailsForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1754 Panel* pPanel = null;
1756 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
1758 pPanel = static_cast<Panel*>(&const_cast<Control&>(source));
1761 else if (source.GetName().Equals(GROUP_LABEL, true) || source.GetName().Equals(VALUE_LABEL, true))
1763 pPanel = static_cast<Panel*>(source.GetParent()->GetControl(GROUP_STYLE_PANEL));
1768 pPanel->SetBackgroundColor(COLOR_GROUP_STYLE);
1770 Label* pLabelTitle = static_cast<Label*>(source.GetParent()->GetControl(GROUP_LABEL, true));
1771 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
1773 Label* pLabelValue = static_cast<Label*>(source.GetParent()->GetControl(VALUE_LABEL, true));
1774 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
1776 pPanel->Invalidate(true);
1777 pLabelValue->Invalidate(true);
1778 pLabelTitle->Invalidate(true);
1783 ContactDetailsForm::OnFileEventOccured(const unsigned long events, const Tizen::Base::String &path, const unsigned int eventId)
1785 String ringtonePath = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
1786 if (ringtonePath.Equals(ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT"), false) == true )
1788 __pTableView->RefreshItem(__pItemList->GetCount() - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1793 ContactDetailsForm::OnScrollEndReached(Tizen::Ui::Control &source, Tizen::Ui::Controls::ScrollEndEvent type)
1798 ContactDetailsForm::OnScrollPositionChanged(Tizen::Ui::Control &source, int scrollPos)
1800 __scrolledDistance = scrollPos;
1804 ContactDetailsForm::OnScrollStopped(Tizen::Ui::Control &source)
1809 ContactDetailsForm::OnContactsChanged(void)
1812 if (__pPresentationModel->IsContactRemoved())
1814 if (__pAppControl != null)
1816 __pAppControl->Stop();
1819 if (__appControlViewType.IsEmpty() == true)
1821 SceneManager* pSceneManager = SceneManager::GetInstance();
1823 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
1824 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
1828 UiApp::GetInstance()->Terminate();
1833 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1834 TryReturnVoid(pContactsApp != null, "Unable to get ContactsApp instance.");
1836 InitializeDetailItemList();
1837 __pFavoriteButton = null;
1838 __pClearButton = null;
1839 __pTableView->UpdateTableView();
1841 if (__currentFocusedItem == Integer::ToString(IDA_FAVORITE_BUTTON))
1843 if (__pFavoriteButton != null)
1845 __pFavoriteButton->SetFocus();
1848 else if (__currentFocusedItem == Integer::ToString(IDA_BUTTON_RINGTONE_CLEAR))
1850 if (__pClearButton != null)
1852 __pClearButton->SetFocus();
1857 delete __pDefaultSelectorPopup;
1858 __pDefaultSelectorPopup = null;
1862 ContactDetailsForm::OnCategoriesChanged(void)
1867 ContactDetailsForm::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, const Tizen::Base::String& launchType, const Tizen::Base::String& value)
1869 result r = E_SUCCESS;
1871 if (__pAppControl != null)
1879 extraData.Construct();
1880 IAppControlResponseListener* pEvent = null;
1882 if (appId.Equals(String(PROVIDER_ID_PHONE)) && operationId.Equals(String(OPERATION_ID_CALL)))
1884 uri.Append(INPUT_URI_TEL);
1886 if (value.IsEmpty())
1888 uri.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER));
1895 extraData.Add(new (std::nothrow) String(INPUT_KEY_CALL_TYPE), new (std::nothrow) String(launchType));
1897 else if (appId.Equals(String(PROVIDER_ID_MESSAGE)) && operationId.Equals(String(OPERATION_ID_COMPOSE)))
1899 String recipientAddress;
1901 if (value.IsEmpty())
1903 recipientAddress.Append(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER));
1905 recipientAddress.IndexOf(DELIMITER_SEMICOLON, 0, index);
1908 recipientAddress.SubString(0, index, recipientAddress);
1911 recipientAddress.IndexOf(DELIMITER_COMMA, 0, index);
1914 recipientAddress.SubString(0, index, recipientAddress);
1919 recipientAddress.Append(value);
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));
1924 else if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
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));
1931 else if (appId.Equals(String(PROVIDER_ID_EMAIL)) && operationId.Equals(String(OPERATION_ID_COMPOSE)))
1933 ArrayList* pArgList = new (std::nothrow) ArrayList();
1934 pArgList->Construct();
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);
1940 __pAppControl = AppManager::FindAppControlN(appId, operationId);
1942 if (__pAppControl != null)
1944 r = __pAppControl->Start(&uri, &mimeType, &extraData, pEvent);
1945 TryCatch(r == E_SUCCESS, , "[%s] Unable to launch app control", GetErrorMessage(r));
1947 __isAppControlLaunching = true;
1949 if (operationId.Equals(String(OPERATION_ID_PICK)))
1955 Footer* pFooter = GetFooter();
1956 pFooter->SetEnabled(false);
1960 extraData.RemoveAll(true);
1961 if (__isAppControlLaunching == false && __pAppControl != null)
1963 delete __pAppControl;
1964 __pAppControl = null;
1970 ContactDetailsForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1972 AppLogDebug("ENTER");
1974 if (pExtraData == null)
1979 if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
1981 if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1983 const String *pResultString = null;
1984 const ArrayList* pResultList = dynamic_cast<const ArrayList*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
1985 if (pResultList != null)
1987 pResultString = static_cast<const String*>(pResultList->GetAt(0));
1991 pResultString = static_cast<const String*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
1994 if (pResultString != null && pResultString->IsEmpty() == false)
1996 __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, *pResultString);
1997 __pPresentationModel->UpdateContact();
1998 __pTableView->RefreshItem(__pItemList->GetCount() - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
2000 if (__pFileEventManager == null)
2002 __pFileEventManager = new (std::nothrow) FileEventManager();
2003 __pFileEventManager->Construct(*this);
2005 __pFileEventManager->AddPath(*pResultString, FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_DELETE_SELF | FILE_EVENT_TYPE_MODIFY | FILE_EVENT_TYPE_MOVE_SELF);
2011 AppLogDebug("EXIT");
2015 ContactDetailsForm::AddGroupStylePanel(int itemWidth, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::GroupStyle groupStyle)
2017 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2019 Panel* pGroupStyle = new (std::nothrow) Panel();
2020 pGroupStyle->Construct(Rectangle(W_GROUP_STYLE_MARGIN, 0, itemWidth - W_GROUP_STYLE_MARGIN * 2, H_ITEM_DOUBLE_LINE + pContactsApp->GetFontHeightOffset()), groupStyle);
2021 pGroupStyle->SetName(GROUP_STYLE_PANEL);
2022 pGroupStyle->SetBackgroundColor(COLOR_GROUP_STYLE);
2023 pGroupStyle->AddTouchEventListener(*this);
2024 pItem->AddControl(pGroupStyle);
2028 ContactDetailsForm::ParseAppControlArgument(const Tizen::Base::String& argument, Tizen::Base::String& type, Tizen::Base::String& content)
2030 result r = E_SUCCESS;
2032 if (argument.IsEmpty() || argument.Contains(DELIMITER) == false)
2037 StringTokenizer stringToken(argument, DELIMITER);
2039 r = stringToken.GetNextToken(type);
2040 TryReturn(r == E_SUCCESS, r, "[%s] Unable to get type", GetErrorMessage(r));
2042 r = stringToken.GetNextToken(content);
2043 TryReturn(r == E_SUCCESS, r, "[%s] Unable to get content", GetErrorMessage(r));
2049 ContactDetailsForm::ShowDefaultSelectorPopup(void)
2051 ArrayList* pList = new (std::nothrow) ArrayList();
2054 String numberWithType;
2055 int numberCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
2056 for (int index = 0; index < numberCount; index++)
2058 numberWithType = __pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, index) + L" ";
2059 numberWithType += __pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, index);
2061 pList->Add(*(new (std::nothrow) String(numberWithType)));
2063 ContactValueListItemProvider* pProvider = new (std::nothrow) ContactValueListItemProvider(pList);
2065 delete __pDefaultSelectorPopup;
2066 __pDefaultSelectorPopup = new (std::nothrow) Popup();
2067 __pDefaultSelectorPopup->Construct(true, Dimension(W_POPUP, H_POPUP));
2068 __pDefaultSelectorPopup->SetTitleText(ResourceManager::GetString(L"IDS_PB_BODY_MARK_AS_DEFAULT_NUMBER"));
2069 __pDefaultSelectorPopup->SetPropagatedKeyEventListener(this);
2071 Rectangle popupClientBounds = __pDefaultSelectorPopup->GetClientAreaBounds();
2073 ListView* pOtherNumberList = new (std::nothrow) ListView();
2074 pOtherNumberList->Construct(Rectangle(0, 0, popupClientBounds.width, H_POPUP_LIST_VIEW));
2075 pOtherNumberList->AddListViewItemEventListener(*this);
2076 pOtherNumberList->SetItemProvider(*pProvider);
2078 __pDefaultSelectorPopup->AddControl(pOtherNumberList);
2080 Button* pCloseButton = new (std::nothrow) Button();
2081 pCloseButton->Construct(Rectangle((popupClientBounds.width - W_POPUP_BUTTON) / 2, Y_POPUP_BUTTON,
2082 W_POPUP_BUTTON, H_POPUP_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CLOSE"));
2083 pCloseButton->SetActionId(IDA_POPUP_CLOSE);
2084 pCloseButton->AddActionEventListener(*this);
2086 __pDefaultSelectorPopup->AddControl(pCloseButton);
2087 __pDefaultSelectorPopup->SetShowState(true);
2088 __pDefaultSelectorPopup->Show();
2092 ContactDetailsForm::HideDefaultSelectorPopup(void)
2094 __pDefaultSelectorPopup->SetShowState(false);
2100 ContactDetailsForm::ShowInvalidFileMessageBox(const Tizen::Base::String errorMsg, bool showFooter)
2102 if (showFooter == false)
2104 Footer* pFooter = GetFooter();
2105 if (pFooter != null)
2107 pFooter->SetShowState(false);
2111 int modalResult = 0;
2112 MessageBox unsupportedMessageBox;
2113 unsupportedMessageBox.Construct(L"", errorMsg, MSGBOX_STYLE_OK, MESSAGE_BOX_TIMEOUT_MS);
2114 unsupportedMessageBox.ShowAndWait(modalResult);
2116 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2118 result r = AppControlProviderManager::GetInstance()->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, null);
2119 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
2121 UiApp::GetInstance()->Terminate();
2125 ContactDetailsForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
2127 __pPresentationModel->SetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER, L"", index);
2128 __pPresentationModel->AddAddressBook();
2130 HideDefaultSelectorPopup();
2134 ContactDetailsForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
2139 ContactDetailsForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
2144 ContactDetailsForm::OnForeground(void)
2146 AppLogDebug("ContactDetailsForm::OnForeground");
2147 delete __pAppControl;
2148 __pAppControl = null;
2150 __isAppControlLaunching = false;
2154 ContactDetailsForm::OnBackground(void)
2156 if (IsEnabled() == false)
2158 result r = SetEnabled(true);
2159 AppLogDebug("Form Enabled = %s", GetErrorMessage(r));
2163 Footer* pFooter = GetFooter();
2164 pFooter->SetEnabled(true);
2168 ContactDetailsForm::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
2174 ContactDetailsForm::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
2176 if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
2178 if (__pDefaultSelectorPopup && __pDefaultSelectorPopup->GetShowState() == true)
2180 HideDefaultSelectorPopup();
2184 if (__pDeletePopup && __pDeletePopup->GetShowState() == true)
2195 ContactDetailsForm::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
2201 ContactDetailsForm::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
2207 ContactDetailsForm::OnFocusGained(const Tizen::Ui::Control& source)
2209 if (source.GetName() == Integer::ToString(IDA_FAVORITE_BUTTON))
2211 __currentFocusedItem = Integer::ToString(IDA_FAVORITE_BUTTON);
2213 else if (source.GetName() == Integer::ToString(IDA_BUTTON_RINGTONE_CLEAR))
2215 __currentFocusedItem = Integer::ToString(IDA_BUTTON_RINGTONE_CLEAR);
2220 ContactDetailsForm::OnFocusLost(const Tizen::Ui::Control& source)
2226 ContactDetailsForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
2228 if (keyCode == KEY_ENTER )
2230 TableViewItem* pItem = static_cast<TableViewItem*>(&(const_cast<Control&>(source)));
2232 Panel* pPanel = static_cast<Panel*>(pItem->GetControl(0));
2239 Label* pLabelValue = static_cast<Label*>(pItem->GetControl(VALUE_LABEL, true));
2241 if (pLabelValue == null)
2246 Label* pLabelTitle = static_cast<Label*>(pItem->GetControl(GROUP_LABEL, true));
2248 if (pLabelTitle == null)
2253 pPanel->SetBackgroundColor(COLOR_PRESSED);
2254 pLabelValue->SetTextColor(Color(COLOR_ITEM_PRESSED));
2255 pLabelTitle->SetTextColor(Color(COLOR_ITEM_PRESSED));
2257 pPanel->Invalidate(true);
2258 pLabelValue->Invalidate(true);
2259 pLabelTitle->Invalidate(true);
2264 ContactDetailsForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
2266 if (keyCode == KEY_ENTER )
2269 TableViewItem* pItem = static_cast<TableViewItem*>(&(const_cast<Control&>(source)));
2271 Panel* pPanel = static_cast<Panel*>(pItem->GetControl(0));
2278 Label* pLabelValue = static_cast<Label*>(pItem->GetControl(VALUE_LABEL, true));
2280 if (pLabelValue == null)
2285 Label* pLabelTitle = static_cast<Label*>(pItem->GetControl(GROUP_LABEL, true));
2287 if (pLabelTitle == null)
2293 pPanel->SetBackgroundColor(COLOR_GROUP_STYLE);
2294 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
2295 pLabelTitle->SetTextColor(Color(COLOR_ITEM_TITLE));
2297 pPanel->Invalidate(true);
2298 pLabelValue->Invalidate(true);
2299 pLabelTitle->Invalidate(true);
2304 ContactDetailsForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
2310 ContactDetailsForm::OnSettingChanged(Tizen::Base::String &key)
2312 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2313 TryReturnVoid(pContactsApp != null, "Unable to get ContactsApp instance.");
2315 if(key == L"http://tizen.org/setting/contacts.order.firstname")
2317 InitializeDetailItemList();
2318 __pTableView->UpdateTableView();