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 CtContactEditorForm.cpp
19 * @brief This is the implementation file for the ContactEditorForm class.
24 #include "CtContactEditorForm.h"
25 #include "CtContactPresentationModel.h"
26 #include "CtContactsApp.h"
27 #include "CtContactValueListItemProvider.h"
28 #include "CtResourceManager.h"
29 #include "CtSceneRegister.h"
31 #include "CtCommonUtil.h"
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Utility;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Io;
39 using namespace Tizen::Media;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43 using namespace Tizen::Social;
44 using namespace Tizen::System;
46 static const int IDA_ACTION_BAR_SAVE = 11;
47 static const int IDA_BUTTON_THUMBNAIL_ADD = 21;
48 static const int IDA_BUTTON_THUMBNAIL_DELETE = 22;
49 static const int IDA_BUTTON_CAMERA = 23;
50 static const int IDA_BUTTON_EXPANDABLE = 24;
51 static const int IDA_BUTTON_MORE_INFO = 25;
52 static const int IDA_BUTTON_BIRTHDAY_CLEAR = 26;
53 static const int IDA_BUTTON_DEFAULT_PHONE_NUMBER = 27;
54 static const int IDA_BUTTON_RINGTONE_CLEAR = 28;
55 static const int IDA_BUTTON_TYPE = 29;
56 static const int IDA_BUTTON_BIRTHDAY_DELETE = 30;
57 static const int IDA_CONTEXT_MENU_ITEM_JOB_TITLE = 31;
58 static const int IDA_CONTEXT_MENU_ITEM_DEPARTMENT = 32;
59 static const int IDA_CONTEXT_MENU_ITEM_INSTANT_MESSENGER = 33;
60 static const int IDA_CONTEXT_MENU_ITEM_URL = 34;
61 static const int IDA_CONTEXT_MENU_ITEM_BIRTHDAY = 35;
62 static const int IDA_CONTEXT_MENU_ITEM_NOTE = 36;
63 static const int IDA_INPUT_FIELD_DISPLAY_NAME = 41;
64 static const int IDA_POPUP_DISCARD_CHANGES_OK = 44;
65 static const int IDA_POPUP_DISCARD_CHANGES_CANCEL = 45;
67 static const wchar_t* IDB_EXPAND_BUTTON_NORMAL = L"00_circle_button.png";
68 static const wchar_t* IDB_EXPAND_BUTTON_PRESSED = L"00_circle_button_press.png";
69 static const wchar_t* IDB_EXPAND_CLOSED = L"00_button_expand_closed.png";
70 static const wchar_t* IDB_EXPAND_CLOSED_PRESSED = L"00_button_expand_closed_press.png";
71 static const wchar_t* IDB_EXPAND_OPENED = L"00_button_expand_opened.png";
72 static const wchar_t* IDB_EXPAND_OPENED_PRESSED = L"00_button_expand_opened_press.png";
73 static const wchar_t* IDB_BUTTON_DELETE_NORMAL = L"00_circle_button_delete.png";
74 static const wchar_t* IDB_BUTTON_DELETE_PRESSED = L"00_circle_button_delete_press.png";
75 static const wchar_t* IDB_BUTTON_MINUS = L"00_button_expand_minus_press.png";
76 static const wchar_t* IDB_BUTTON_MINUS_PRESSED = L"00_button_expand_minus_press.png";
77 static const wchar_t* IDB_BUTTON_RESET_NORMAL = L"00_button_refresh.png";
78 static const wchar_t* IDB_BUTTON_RESET_PRESSED = L"00_button_refresh_press.png";
79 static const wchar_t* IDB_BUTTON_ADD= L"C02_caller_id_icon_add.png";
80 static const wchar_t* IDB_BUTTON_ADD_PRESSED = L"C02_caller_id_icon_add_press.png";
81 static const wchar_t* IDB_BUTTON_CAMERA = L"C02_caller_id_icon_camera.png";
82 static const wchar_t* IDB_BUTTON_CAMERA_PRESSED = L"C02_caller_id_icon_camera_press.png";
83 static const wchar_t* IDB_BUTTON_DROPBOX = L"C02_button_icon_dropbox.png";
84 static const wchar_t* IDB_THUMBNAIL_BACKGROUND = L"C02_created_photo_bg.png";
85 static const wchar_t* IDB_DETAILS_RESET_NORMAL = L"00_button_refresh.png";
86 static const wchar_t* IDB_DETAILS_RESET_PRESSED = L"00_button_refresh_press.png";
88 static const wchar_t* INPUT_DATA_SELECTION_MODE_SINGLE = L"single";
89 static const wchar_t* INPUT_KEY_SELECTION_MODE = L"http://tizen.org/appcontrol/data/selection_mode";
90 static const wchar_t* INPUT_KEY_IMAGEVIEWER_MODE = L"http://tizen.org/appcontrol/data/image/crop_mode";
91 static const wchar_t* INPUT_KEY_ALLOW_SWITCH = L"http://tizen.org/appcontrol/data/camera/allow_switch";
92 static const wchar_t* INPUT_MIME_TYPE_CAMERA = L"image/jpg";
93 static const wchar_t* INPUT_MIME_TYPE_GALLERY = L"image/*";
94 static const wchar_t* INPUT_MIME_TYPE_AUDIO = L"audio/*";
95 static const wchar_t* INPUT_VALUE_FALSE = L"false";
96 static const wchar_t* INPUT_VALUE_IMAGEVIEWER_TYPE = L"fit_to_screen";
97 static const wchar_t* OUTPUT_KEY_SELECTED = L"http://tizen.org/appcontrol/data/selected";
98 static const wchar_t* SD_CARD_UNMOUNTED = L"Unmounted";
100 static const int H_ITEM = 112;
101 static const int H_DOUBLE_LINE_ITEM = 140;
102 static const int H_LABEL = 40;
103 static const int H_DESCRIPTION_CONTAINER = 136;
104 static const int H_DIVIDER = 1;
105 static const int W_DIVIDER = 1;
106 static const int H_EMPTY_SPACE = 32;
107 static const int H_BUTTON = 74;
108 static const int H_ICON_BUTTON = 74;
109 static const int W_THUMBNAIL = 360;
110 static const int W_TITLE_LABEL = 170;
111 static const int X_MORE_INFORMATION_BUTTON = 60;
112 static const int Y_MORE_INFORMATION_BUTTON = 30;
113 static const int Y_DEFAULT_NUMBER_BUTTON = 19;
114 static const int W_ITEM_GAP = 16;
115 static const int W_TYPE_BUTTON = 186;
116 static const int H_THUMBNAIL_DELETE_BUTTON_GAP = 31;
117 static const int H_THUMBNAIL_GROUP_ITEM_HEIGHT = 34;
118 static const int H_NAMEFIELD_GROUP_ITEM_HEIGHT = 40;
119 static const int H_GROUP_RINGTONE_TITLE_GAP = 22;
120 static const int H_GROUP_RINGTONE_TITLE_LABEL = 42;
121 static const int H_GROUP_RINGTONE_VALUE_LABEL = 62;
122 static const int W_DROPBOX_ICON = 29;
123 static const int H_DROPBOX_ICON = 29;
124 static const int X_REFRESH_BUTTON_MARGIN = 88;
125 static const int Y_EDIT_FIELD_GAP = 5;
126 static const int H_EDIT_FIELD_GAP = 10;
128 static const int X_MORE_INFO_PANEL_GAP = 5;
129 static const int H_MORE_INFO_PANEL_GAP = 10;
131 static const int FONT_SIZE_TITLE_TEXT = 32;
133 static const int GROUP_ITEM_COUNT = 11;
134 static const int NAME_FIELD_ITEM_COUNT = 1;
136 static const int EDIT_FIELD_EXTENDED_LENGTH = 100;
138 static const int MESSAGE_BOX_TIMEOUT_MS = 300000;
140 static const int DEFAULT_EXPAND_NAME_FIELD_COUNT = 6;
142 static const wchar_t* EXPAND_BUTTON = L"ExpandButton";
144 static const unsigned int COLOR_TABLE_VIEW_BG = Color32<248, 246, 239>::Value;
145 static const unsigned int COLOR_DIVIDER = Color32<169, 169, 169>::Value;
146 static const unsigned int COLOR_THUMBNAIL_BACKGROUND = Color32<239, 237, 229>::Value;
147 static const unsigned int COLOR_ITEM_TITLE = Color32<128, 128, 128>::Value;
148 static const unsigned int COLOR_ITEM_VALUE = Color32<0, 0, 0>::Value;
149 static const unsigned int COLOR_ITEM_PRESSED = Color32<248, 246, 239>::Value;
150 static const unsigned int COLOR_PRESSED = Color32<87, 135, 194>::Value;
152 static const int TABLE_VIEW_DELETE_INPUT_FIELD_ID = 0xE0000000;
153 static const int TABLE_VIEW_INPUT_FIELD_ACTION_MASK = 0xF0000000;
154 static const int TABLE_VIEW_INPUT_FIELD_INDEX_MASK = 0x0F000000;
155 static const int TABLE_VIEW_GROUP_INDEX_MASK = 0x00FF0000;
156 static const int TABLE_VIEW_ITEM_INDEX_MASK = 0x0000FFFF;
157 static const int TABLE_VIEW_GROUP_INDEX_SHIFT = 16;
158 static const int TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT = 24;
159 static const int TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT = 28;
160 static const int TABLE_VIEW_THUMBNAIL_FIELD_INDEX = 0;
161 static const int TABLE_VIEW_NAME_FIELD_INDEX = 1;
162 static const int TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX = 2;
163 static const int TABLE_VIEW_EMAIL_FIELD_INDEX = 3;
164 static const int TABLE_VIEW_ADDRESS_FIELD_INDEX = 4;
165 static const int TABLE_VIEW_IM_ADDRESS_FIELD_INDEX = 5;
166 static const int TABLE_VIEW_URL_FIELD_INDEX = 6;
167 static const int TABLE_VIEW_BIRTHDAY_FIELD_INDEX = 7;
168 static const int TABLE_VIEW_NOTE_FIELD_INDEX = 8;
169 static const int TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX = 9;
170 static const int TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX = 10;
172 static const wchar_t* INPUT_TYPE_PHONE = L"phone";
173 static const wchar_t* INPUT_TYPE_EMAIL = L"email";
174 static const wchar_t* INPUT_TYPE_URL = L"url";
175 static const wchar_t* VIEW_TYPE = L"viewType";
176 static const wchar_t* VIEW_TYPE_VALUE_CONTACT = L"contact";
177 static const wchar_t* VIEW_TYPE_CONTACT_ID = L"contactId";
178 static const wchar_t* GROUP_LABEL_TITLE = L"GroupLabelTitle";
179 static const wchar_t* GROUP_LABEL_VALUE = L"GroupLabelValue";
180 static const wchar_t* GROUP_STYLE_PANEL = L"GroupStylePanel";
182 ContactEditorForm::ContactEditorForm(void)
183 : __isExpandable(false)
184 , __isAppControl(false)
185 , __isJobTitleEnabled(false)
186 , __isDepartmentEnabled(false)
187 , __isDefaultPhoneNumberButtonEnabled(false)
189 , __isMoreInformationContextMenuShowing(false)
190 , __isTypeContextMenuShowing(false)
191 , __isKeypadOpened(false)
192 , __isScrollOccurred(false)
193 , __isContactModified(false)
194 , __scrolledDistance(0)
195 , __origScrolledDistance(0)
198 , __previousItemIndex(-1)
199 , __previousGroupIndex(-1)
200 , __pAppControl(null)
201 , __pPhoneNumberFieldItem(null)
202 , __pEmailFieldItem(null)
203 , __pAddressFieldItem(null)
204 , __pImAddressFieldItem(null)
205 , __pUrlFieldItem(null)
206 , __pDeletedItemList(null)
207 , __pFileEventManager(null)
208 , __pDiscardChangesPopup(null)
209 , __pCurrentFocusedItem(null)
210 , __pDefaultPhoneNumberContextMenu(null)
211 , __pMoreInformationContextMenu(null)
212 , __pThumbnailContextMenu(null)
213 , __pTypeContextMenu(null)
215 , __pNameFieldItem(null)
216 , __pNoteFieldItem(null)
217 , __pPresentationModel(null)
221 ContactEditorForm::~ContactEditorForm(void)
226 ContactEditorForm::Initialize(void)
228 Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
232 ContactEditorForm::OnInitializing(void)
234 SetFormBackEventListener(this);
235 SettingInfo::AddSettingEventListener(*this);
237 Footer* pFooter = GetFooter();
239 FooterItem footerItemSave;
240 footerItemSave.Construct(IDA_ACTION_BAR_SAVE);
241 footerItemSave.SetText(ResourceManager::GetString(L"IDS_COM_SK_SAVE"));
243 pFooter->AddItem(footerItemSave);
244 pFooter->AddActionEventListener(*this);
246 __pTableView = new (std::nothrow) GroupedTableView();
247 __pTableView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), false, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
248 __pTableView->SetItemProvider(this);
249 __pTableView->AddScrollEventListener(*this);
250 __pTableView->AddGroupedTableViewItemEventListener(*this);
251 AddControl(__pTableView);
253 __pPhoneNumberFieldItem = new (std::nothrow) ArrayList();
254 __pPhoneNumberFieldItem->Construct();
256 __pEmailFieldItem = new (std::nothrow) ArrayList();
257 __pEmailFieldItem->Construct();
259 __pAddressFieldItem = new (std::nothrow) ArrayList();
260 __pAddressFieldItem->Construct();
262 __pImAddressFieldItem = new (std::nothrow) ArrayList();
263 __pImAddressFieldItem->Construct();
265 __pUrlFieldItem = new (std::nothrow) ArrayList();
266 __pUrlFieldItem->Construct();
268 __pPresentationModel = new (std::nothrow) ContactPresentationModel();
269 __pPresentationModel->Construct();
270 __pPresentationModel->AddContactChangeListener(*this);
272 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
274 __pDeletedItemList = new ArrayList();
275 __pDeletedItemList->Construct();
281 ContactEditorForm::OnTerminating(void)
283 AppLog("ContactEditorForm::OnTerminating()");
285 result r = E_SUCCESS;
287 __pTableView->SetItemProvider(null);
289 if (__pPresentationModel != null)
291 __pPresentationModel->RemoveContactChangeListener(*this);
292 delete __pPresentationModel;
295 if (__pPhoneNumberFieldItem)
297 __pPhoneNumberFieldItem->RemoveAll(true);
298 delete __pPhoneNumberFieldItem;
301 if (__pEmailFieldItem)
303 __pEmailFieldItem->RemoveAll(true);
304 delete __pEmailFieldItem;
307 if (__pAddressFieldItem)
309 __pAddressFieldItem->RemoveAll(true);
310 delete __pAddressFieldItem;
315 __pUrlFieldItem->RemoveAll(true);
316 delete __pUrlFieldItem;
319 if (__pImAddressFieldItem)
321 __pImAddressFieldItem->RemoveAll(true);
322 delete __pImAddressFieldItem;
325 if (__pDeletedItemList)
327 __pDeletedItemList->RemoveAll(true);
328 delete __pDeletedItemList;
331 if (__pDiscardChangesPopup)
333 delete __pDiscardChangesPopup;
335 delete __pAppControl;
336 delete __pNameFieldItem;
337 delete __pNoteFieldItem;
338 delete __pDefaultPhoneNumberContextMenu;
339 delete __pMoreInformationContextMenu;
340 delete __pThumbnailContextMenu;
341 delete __pTypeContextMenu;
342 delete __pFileEventManager;
344 DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
345 SettingInfo::RemoveSettingEventListener(*this);
351 ContactEditorForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
355 if( IsSaveContactValid() == true && __isContactModified == true)
357 ShowDiscardChangesPopup();
360 if (__isAppControl == true)
362 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
363 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
365 result r = pAppManager->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_CANCELED, null);
366 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
368 UiApp::GetInstance()->Terminate();
372 SceneManager* pSceneManager = SceneManager::GetInstance();
374 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
375 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
380 ContactEditorForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
382 AppLog("ContactEditorForm::OnActionPerformed(), actionId %d", actionId);
384 if ((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) == TABLE_VIEW_DELETE_INPUT_FIELD_ID)
386 int groupIndex = (actionId & TABLE_VIEW_GROUP_INDEX_MASK) >> TABLE_VIEW_GROUP_INDEX_SHIFT;
387 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
389 if (groupIndex > TABLE_VIEW_NAME_FIELD_INDEX)
391 DeleteInputField(groupIndex, itemIndex);
392 if (groupIndex == __previousGroupIndex && itemIndex < __previousItemIndex) //if we deleted a number on top of the item to be deleted
394 __previousItemIndex--; //adjust the index of the item to be deleted
396 __isContactModified = true;
401 else if (&source == __pDefaultPhoneNumberContextMenu)
403 SetAsDefaultPhoneNumber(actionId, true);
404 __isContactModified = true;
408 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX)
410 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
411 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
413 TableViewItem* pItem = static_cast<TableViewItem *>(__pPhoneNumberFieldItem->GetAt(itemIndex));
418 pItem->SetName(Integer::ToString(selectedItemIndex));
420 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
421 if (pButtonType == null)
426 pButtonType->SetText(__pPresentationModel->GetPhoneNumberTypeString((DetailPhoneNumberType)selectedItemIndex));
427 pButtonType->Invalidate(false);
429 __isContactModified = true;
432 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_EMAIL_FIELD_INDEX)
434 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
435 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
437 TableViewItem* pItem = static_cast<TableViewItem *>(__pEmailFieldItem->GetAt(itemIndex));
442 pItem->SetName(Integer::ToString(selectedItemIndex));
444 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
445 if (pButtonType == null)
450 pButtonType->SetText(__pPresentationModel->GetEmailTypeString((DetailEmailType)selectedItemIndex));
451 pButtonType->Invalidate(false);
453 __isContactModified = true;
456 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_ADDRESS_FIELD_INDEX)
458 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
459 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
461 TableViewItem* pItem = static_cast<TableViewItem *>(__pAddressFieldItem->GetAt(itemIndex));
466 pItem->SetName(Integer::ToString(selectedItemIndex));
468 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
469 if (pButtonType == null)
474 pButtonType->SetText(__pPresentationModel->GetAddressTypeString((DetailAddressType)selectedItemIndex));
475 pButtonType->Invalidate(false);
477 __isContactModified = true;
480 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_IM_ADDRESS_FIELD_INDEX)
482 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
483 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
485 TableViewItem* pItem = static_cast<TableViewItem *>(__pImAddressFieldItem->GetAt(itemIndex));
490 pItem->SetName(Integer::ToString(selectedItemIndex));
492 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
493 if (pButtonType == null)
498 pButtonType->SetText(__pPresentationModel->GetImAddressTypeString((DetailImAddressType)selectedItemIndex));
499 pButtonType->Invalidate(false);
501 __isContactModified = true;
504 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_URL_FIELD_INDEX)
506 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
507 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
509 TableViewItem* pItem = static_cast<TableViewItem *>(__pUrlFieldItem->GetAt(itemIndex));
514 pItem->SetName(Integer::ToString(selectedItemIndex));
516 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
517 if (pButtonType == null)
522 pButtonType->SetText(__pPresentationModel->GetUrlTypeString((DetailUrlType)selectedItemIndex));
523 pButtonType->Invalidate(false);
525 __isContactModified = true;
531 case IDA_ACTION_BAR_SAVE:
533 result r = E_SUCCESS;
535 DateTime changedDate;
536 DateTime currentDate;
537 SystemTime::GetCurrentTime(currentDate);
539 __pPresentationModel->GetBirthday(changedDate);
541 if (changedDate.CompareTo(currentDate) > 0)
544 MessageBox invalidBirthYear;
545 invalidBirthYear.Construct(L"", ResourceManager::GetString(L"IDS_SAPPS_POP_INVALID_DATE_OF_BIRTH"), MSGBOX_STYLE_OK, MESSAGE_BOX_TIMEOUT_MS);
546 invalidBirthYear.ShowAndWait(modalResult);
547 __pPresentationModel->SetBirthday(currentDate);
548 __pTableView->RefreshItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
552 r = SaveContactData();
563 case IDA_BUTTON_THUMBNAIL_ADD:
565 if (__pCurrentFocusedItem != null)
569 LaunchAppControl(PROVIDER_ID_GALLERY, OPERATION_ID_PICK);
572 case IDA_BUTTON_THUMBNAIL_DELETE:
574 __pPresentationModel->SetThumbnail(L"");
575 __isContactModified = true;
576 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
578 delete __pFileEventManager;
579 __pFileEventManager = null;
582 case IDA_BUTTON_CAMERA:
584 if (__pCurrentFocusedItem != null)
588 LaunchAppControl(PROVIDER_ID_CAMERA, OPERATION_ID_CREATE_CONTENT);
591 case IDA_BUTTON_EXPANDABLE:
593 ChangeNameFieldStatus();
594 if (__previousItemIndex != -1 && __previousGroupIndex != -1)
596 DeleteInputField(__previousGroupIndex, __previousItemIndex, true);
598 if (__pCurrentFocusedItem == __pNameFieldItem)
600 __pCurrentFocusedItem = null;
603 __pTableView->UpdateTableView();
604 static_cast<Button*>(__pNameFieldItem->GetControl(EXPAND_BUTTON))->SetFocus();
606 Rectangle clientBounds = GetClientAreaBounds();
607 __pTableView->SetSize(clientBounds.width, clientBounds.height);
609 if (__pCurrentFocusedItem != null)
615 case IDA_BUTTON_MORE_INFO:
617 if (__pCurrentFocusedItem != null)
619 if (__isKeypadOpened)
621 __isMoreInformationContextMenuShowing = true;
622 __scrolledDistance = 0;
626 Control* pParentPanel = source.GetParent();
627 if (pParentPanel == null)
632 Control* pParentTableViewItem = pParentPanel->GetParent();
633 if (pParentTableViewItem == null)
638 Point contextMenuPos;
640 contextMenuPos.x = pParentTableViewItem->GetWidth() / 2;
641 contextMenuPos.y = GetClientAreaBounds().y + pParentTableViewItem->GetY() + source.GetY() - __scrolledDistance;
643 ShowMoreInformationContextMenu(contextMenuPos);
645 Button* pMoreInfo = static_cast<Button*>(&(const_cast<Control&>(source)));
646 pMoreInfo->SetFocus();
649 case IDA_BUTTON_BIRTHDAY_CLEAR:
651 DateTime currentDate;
652 Tizen::System::SystemTime::GetCurrentTime(currentDate);
653 __pPresentationModel->SetBirthday(currentDate);
655 __pTableView->RefreshItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
656 __isContactModified = true;
659 case IDA_CONTEXT_MENU_ITEM_JOB_TITLE:
661 __isExpandable = false;
662 __isJobTitleEnabled = true;
664 ChangeNameFieldStatus();
666 __pTableView->UpdateTableView();
668 if (IsMoreInformationButtonVisible() == false)
670 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
672 __pTableView->ScrollToItem(TABLE_VIEW_NAME_FIELD_INDEX, 0);
675 case IDA_CONTEXT_MENU_ITEM_DEPARTMENT:
677 __isExpandable = false;
678 __isDepartmentEnabled = true;
680 ChangeNameFieldStatus();
682 __pTableView->UpdateTableView();
684 if (IsMoreInformationButtonVisible() == false)
686 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
688 __pTableView->ScrollToItem(TABLE_VIEW_NAME_FIELD_INDEX, 0);
691 case IDA_CONTEXT_MENU_ITEM_INSTANT_MESSENGER:
693 SaveContactData(false);
695 int index = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS);
697 __pTableView->RefreshItem(TABLE_VIEW_IM_ADDRESS_FIELD_INDEX, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
699 if (IsMoreInformationButtonVisible() == false)
701 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
703 __pTableView->ScrollToItem(TABLE_VIEW_IM_ADDRESS_FIELD_INDEX, 0);
706 case IDA_CONTEXT_MENU_ITEM_URL:
708 SaveContactData(false);
710 int index = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL);
712 __pTableView->RefreshItem(TABLE_VIEW_URL_FIELD_INDEX, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
714 if (IsMoreInformationButtonVisible() == false)
716 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
718 __pTableView->ScrollToItem(TABLE_VIEW_URL_FIELD_INDEX, 0);
721 case IDA_CONTEXT_MENU_ITEM_BIRTHDAY:
723 DateTime currentDate;
725 Tizen::System::SystemTime::GetCurrentTime(currentDate);
726 __pPresentationModel->SetBirthday(currentDate);
728 __pTableView->RefreshItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
730 if (IsMoreInformationButtonVisible() == false)
732 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
734 __pTableView->ScrollToItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0);
737 case IDA_CONTEXT_MENU_ITEM_NOTE:
739 __pTableView->RefreshItem(TABLE_VIEW_NOTE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
741 if (IsMoreInformationButtonVisible() == false)
743 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
745 __pTableView->ScrollToItem(TABLE_VIEW_NOTE_FIELD_INDEX, 0);
748 case IDA_BUTTON_DEFAULT_PHONE_NUMBER:
750 Control* pParent = source.GetParent();
751 Point contextMenuPos;
753 contextMenuPos.x = pParent->GetWidth() / 2;
754 contextMenuPos.y = GetClientAreaBounds().y + pParent->GetY() + source.GetY() + (source.GetHeight() / 2) - __scrolledDistance;
756 if (__pCurrentFocusedItem != null)
761 SaveContactData(false);
762 ShowDefaultPhoneNumberContextMenu(contextMenuPos);
765 case IDA_POPUP_DISCARD_CHANGES_CANCEL:
767 HideDiscardChangesPopup();
770 case IDA_POPUP_DISCARD_CHANGES_OK:
772 HideDiscardChangesPopup();
774 if (__isAppControl == true)
776 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
777 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
779 result r = pAppManager->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_CANCELED, null);
780 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
782 UiApp::GetInstance()->Terminate();
787 SceneManager* pSceneManager = SceneManager::GetInstance();
789 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
790 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
794 case IDA_BUTTON_RINGTONE_CLEAR:
796 __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, L"", 0);
797 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
800 case IDA_BUTTON_BIRTHDAY_DELETE:
802 __pPresentationModel->RemoveBirthday();
803 __pTableView->RefreshItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
806 case IDA_BUTTON_TYPE:
808 Control* pParent = source.GetParent();
809 Point position = pParent->GetPosition();
810 Point itemPosition(position.x + source.GetX(), GetClientAreaBounds().y + position.y + source.GetY() + (source.GetHeight() / 2) - __scrolledDistance);
811 String typeString = pParent->GetName();
812 String itemIndexTag = source.GetName();
816 Integer::Parse(itemIndexTag, itemIndex);
817 Integer::Parse(typeString, type);
818 ShowTypeContextMenu(type, itemPosition, itemIndex);
827 ContactEditorForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId,
828 Tizen::Base::Collection::IList* pArgs)
830 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
831 TryReturnVoid(pContactsApp != null, "Unable to cast UiApp to ContactsApp");
833 pContactsApp->AddContactsAppChangeEventListener(*this);
835 Header* pHeader = GetHeader();
836 Footer* pFooter = GetFooter();
838 if (previousSceneId.Equals(IDSCN_GROUP_SELECTOR, true) || previousSceneId.Equals(IDSCN_GROUP_EDITOR, true))
842 Integer* pCategoryId = null;
846 IList* pCategoryList = __pPresentationModel->GetAssignedCategoryIdListN();
847 prevCount = pCategoryList->GetCount();
848 delete pCategoryList;
850 __pPresentationModel->RemoveContactFromAllCategories();
852 IEnumerator* pEnum = pArgs->GetEnumeratorN();
853 while (pEnum->MoveNext() == E_SUCCESS)
855 pCategoryId = static_cast<Integer*>(pEnum->GetCurrent());
856 if (pCategoryId != null)
858 __pPresentationModel->AddContactToCategory(pCategoryId->ToInt());
859 __isContactModified = true;
864 if(prevCount > 0 && curCount == 0)
866 __isContactModified = true;
871 pArgs->RemoveAll(true);
875 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
880 if (pContactsApp->GetOperationId() == OPERATION_ID_ADD)
882 __isAppControl = true;
883 __pPresentationModel->PrepareNewContact();
885 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_CREATE"));
886 pFooter->SetItemEnabled(0, false);
888 else if (pContactsApp->GetOperationId() == OPERATION_ID_EDIT)
890 __isAppControl = true;
894 String* pArgString = null;
898 IEnumerator* pEnum = pArgs->GetEnumeratorN();
899 while (pEnum->MoveNext() == E_SUCCESS)
901 pArgString = static_cast<String*>(pEnum->GetCurrent());
902 if (pArgString != null)
904 ParseAppControlArgument(*pArgString, type, content);
906 if (type.Equals(RETURN_TYPE_ITEM_ID, false))
909 Integer::Parse(content, contactId);
910 result r = __pPresentationModel->SetContactId(contactId, true);
914 AppLogDebug("Invalid contactId has been input : %d", contactId);
915 UiApp::GetInstance()->Terminate();
918 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_JOB_TITLE).IsEmpty() == false)
920 __isJobTitleEnabled = true;
922 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_DEPARTMENT).IsEmpty() == false)
924 __isDepartmentEnabled = true;
932 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_SK_EDIT"));
939 Integer* pContactId = null;
941 pContactId = static_cast<Integer*>(pArgs->GetAt(0));
942 if (pContactId != null)
944 if (pContactId->ToInt() != INVALID_RECORD_ID)
946 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_SK_EDIT"));
947 __pPresentationModel->SetContactId(pContactId->ToInt(), true);
951 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_CREATE"));
953 String* pVcfPath = static_cast<String*>(pArgs->GetAt(1));
954 if (pVcfPath != null)
956 __pPresentationModel->SetVcfPath(*pVcfPath, true);
961 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_JOB_TITLE).IsEmpty() == false)
963 __isJobTitleEnabled = true;
965 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_DEPARTMENT).IsEmpty() == false)
967 __isDepartmentEnabled = true;
972 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_CREATE"));
973 pFooter->SetItemEnabled(0, false);
974 __pPresentationModel->PrepareNewContact();
978 if (__isAppControl == true)
982 String* pArgString = null;
986 IEnumerator* pEnum = pArgs->GetEnumeratorN();
987 while (pEnum->MoveNext() == E_SUCCESS)
989 pArgString = static_cast<String*>(pEnum->GetCurrent());
990 if (pArgString != null)
992 result r = E_SUCCESS;
993 ParseAppControlArgument(*pArgString, type, content);
995 if (type.Equals(INPUT_TYPE_PHONE, false))
997 r = __pPresentationModel->SetValue(DETAIL_PROPERTY_PHONE_NUMBER, content, __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER));
999 else if (type.Equals(INPUT_TYPE_EMAIL, false))
1001 r = __pPresentationModel->SetValue(DETAIL_PROPERTY_EMAIL, content, __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL));
1003 else if (type.Equals(INPUT_TYPE_URL, false))
1005 r = __pPresentationModel->SetValue(DETAIL_PROPERTY_URL, content, __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL));
1010 pFooter->SetItemEnabled(0, true);
1020 pArgs->RemoveAll(true);
1026 ContactEditorForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
1028 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1030 pContactsApp->RemoveContactsAppChangeEventListener(*this);
1031 if (__previousItemIndex != -1 && __previousGroupIndex != -1)
1033 DeleteInputField(__previousGroupIndex, __previousItemIndex);
1038 ContactEditorForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1043 ContactEditorForm::OnKeypadOpened(Tizen::Ui::Control& source)
1045 Rectangle clientBounds = GetClientAreaBounds();
1047 __pTableView->SetSize(clientBounds.width, clientBounds.height);
1048 __isKeypadOpened = true;
1052 ContactEditorForm::OnKeypadClosed(Tizen::Ui::Control& source)
1054 Rectangle clientBounds = GetClientAreaBounds();
1055 AppLogDebug("Contacts::OnKeypadclosed bounds are width:(%d), height:(%d)", clientBounds.width, clientBounds.height);
1056 __pTableView->SetSize(clientBounds.width, clientBounds.height);
1058 if (__isMoreInformationContextMenuShowing)
1060 Point anchorPosition = __pMoreInformationContextMenu->GetAnchorPosition();
1061 __pTableView->ScrollToItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
1062 if (__scrolledDistance != __origScrolledDistance)
1064 __scrolledDistance = __origScrolledDistance;
1066 anchorPosition.y -= __scrolledDistance;
1067 __pMoreInformationContextMenu->SetAnchorPosition(anchorPosition);
1068 __pMoreInformationContextMenu->Show();
1070 __isMoreInformationContextMenuShowing = false;
1072 __isKeypadOpened = false;
1076 ContactEditorForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1081 ContactEditorForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1083 Rectangle clientBounds = GetClientAreaBounds();
1084 int diff = clientBounds.height - __pTableView->GetHeight();
1086 if (__pTypeContextMenu != null)
1088 int yPos = __pTypeContextMenu->GetAnchorPosition().y;
1089 __pTypeContextMenu->SetAnchorPosition(Point(__pTypeContextMenu->GetAnchorPosition().x, yPos + diff));
1090 __pTypeContextMenu->Show();
1092 __pTableView->SetSize(clientBounds.width, clientBounds.height);
1096 ContactEditorForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView &tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem *pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1098 SceneManager* pSceneManager = SceneManager::GetInstance();
1100 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED && groupIndex == TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX)
1102 if (__pCurrentFocusedItem != null)
1109 if (__pPresentationModel->GetCategoryCount() > 0)
1111 IList* pCategoryList = __pPresentationModel->GetAssignedCategoryIdListN();
1113 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_SELECTOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pCategoryList);
1117 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
1122 else if (itemIndex == 2)
1124 LaunchAppControl(PROVIDER_ID_FILEMANAGER, OPERATION_ID_PICK);
1130 ContactEditorForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView &tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem *pContextItem, bool activated)
1135 ContactEditorForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView &tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem *pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1140 ContactEditorForm::GetGroupCount(void)
1142 return GROUP_ITEM_COUNT;
1146 ContactEditorForm::GetItemCount(int groupIndex)
1152 case TABLE_VIEW_THUMBNAIL_FIELD_INDEX:
1157 case TABLE_VIEW_NAME_FIELD_INDEX:
1159 itemCount = NAME_FIELD_ITEM_COUNT;
1162 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
1164 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) + 1;
1166 if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) > 1)
1168 __isDefaultPhoneNumberButtonEnabled = true;
1173 __isDefaultPhoneNumberButtonEnabled = false;
1177 case TABLE_VIEW_EMAIL_FIELD_INDEX:
1179 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL) + 1;
1182 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
1184 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_ADDRESS) + 1;
1187 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
1189 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS);
1191 if ((itemCount == 0 && __pImAddressFieldItem->GetCount() > 0) || itemCount > 0)
1197 case TABLE_VIEW_URL_FIELD_INDEX:
1199 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL);
1201 if ((itemCount == 0 && __pUrlFieldItem->GetCount() > 0) || itemCount > 0)
1207 case TABLE_VIEW_BIRTHDAY_FIELD_INDEX:
1210 if (__pPresentationModel->GetBirthday(birthday) != E_SUCCESS)
1220 case TABLE_VIEW_NOTE_FIELD_INDEX:
1222 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_NOTE).IsEmpty() == false || __pNoteFieldItem != null )
1232 case TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX:
1237 case TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX:
1239 if (IsMoreInformationButtonVisible())
1257 ContactEditorForm::GetDefaultGroupItemHeight(void)
1259 return H_EMPTY_SPACE;
1263 ContactEditorForm::GetDefaultItemHeight(void)
1265 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1266 return pContactsApp->GetListItemSingleLineHeight();
1270 ContactEditorForm::CreateGroupItem(int groupIndex, int itemWidth)
1272 int groupItemHeight = H_EMPTY_SPACE;
1274 if (groupIndex == TABLE_VIEW_THUMBNAIL_FIELD_INDEX)
1276 groupItemHeight = H_THUMBNAIL_GROUP_ITEM_HEIGHT;
1278 else if (groupIndex == TABLE_VIEW_NAME_FIELD_INDEX)
1280 groupItemHeight = H_NAMEFIELD_GROUP_ITEM_HEIGHT;
1282 else if (groupIndex == TABLE_VIEW_BIRTHDAY_FIELD_INDEX)
1284 groupItemHeight = Y_EDIT_FIELD_GAP;
1286 else if (groupIndex == TABLE_VIEW_NOTE_FIELD_INDEX)
1288 groupItemHeight = H_EDIT_FIELD_GAP;
1290 else if ((groupIndex > TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX && groupIndex < TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX) || groupIndex == TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX)
1292 groupItemHeight = 0;
1295 TableViewGroupItem* pGroupItem = new (std::nothrow) TableViewGroupItem();
1296 pGroupItem->Construct(Dimension(itemWidth, groupItemHeight));
1297 pGroupItem->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1298 pGroupItem->SetEnabled(false);
1300 Panel* pPanel = new (std::nothrow) Panel();
1301 pPanel->Construct(Rectangle(0, -(H_DIVIDER), itemWidth, groupItemHeight + H_DIVIDER));
1302 pPanel->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG));
1304 pGroupItem->AddControl(pPanel);
1310 ContactEditorForm::DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1319 ContactEditorForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
1321 TableViewItem* pItem = null;
1325 case TABLE_VIEW_THUMBNAIL_FIELD_INDEX:
1327 pItem = GetThumbnailField(itemWidth);
1330 case TABLE_VIEW_NAME_FIELD_INDEX:
1332 pItem = GetNameFields(itemWidth);
1335 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
1337 if ((itemIndex == __pTableView->GetItemCountAt(groupIndex) - 1) && __isDefaultPhoneNumberButtonEnabled == true)
1339 pItem = GetDefaultPhoneNumberItem(itemWidth);
1343 pItem = GetPhoneNumberFields(itemIndex, itemWidth);
1346 case TABLE_VIEW_EMAIL_FIELD_INDEX:
1348 pItem = GetEmailFields(itemIndex, itemWidth);
1351 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
1353 pItem = GetAddressFields(itemIndex, itemWidth);
1356 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
1358 pItem = GetImAddressFields(itemIndex, itemWidth);
1361 case TABLE_VIEW_URL_FIELD_INDEX:
1363 pItem = GetUrlFields(itemIndex, itemWidth);
1366 case TABLE_VIEW_BIRTHDAY_FIELD_INDEX:
1368 pItem = GetBirthdayField(itemWidth);
1371 case TABLE_VIEW_NOTE_FIELD_INDEX:
1373 pItem = GetNoteField(itemWidth);
1376 case TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX:
1381 pItem = GetGroupsField(itemWidth);
1385 pItem = new (std::nothrow) TableViewItem();
1386 pItem->Construct(Dimension(itemWidth, H_DIVIDER * 2));
1387 pItem->SetEnabled(false);
1391 pItem = GetRingtoneField(itemWidth);
1398 case TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX:
1400 if (IsMoreInformationButtonVisible())
1402 pItem = GetMoreInformationField(itemWidth);
1418 ContactEditorForm::DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1420 if ((groupIndex > TABLE_VIEW_NAME_FIELD_INDEX && groupIndex < TABLE_VIEW_BIRTHDAY_FIELD_INDEX) || groupIndex == TABLE_VIEW_NOTE_FIELD_INDEX)
1423 __pDeletedItemList->IndexOf(*pItem, index);
1427 __pDeletedItemList->RemoveAt(index);
1434 else if (groupIndex == TABLE_VIEW_NAME_FIELD_INDEX)
1437 __pNameFieldItem = null;
1440 if (__pCurrentFocusedItem == pItem && __isKeypadOpened)
1442 __isKeypadOpened = false;
1452 ContactEditorForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem *pItem)
1457 ContactEditorForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem *pItem)
1466 case TABLE_VIEW_THUMBNAIL_FIELD_INDEX:
1468 SetThumbnailControls(*pItem, true);
1469 pItem->Invalidate(true);
1472 case TABLE_VIEW_NAME_FIELD_INDEX:
1474 if (__pCurrentFocusedItem == pItem && __isKeypadOpened)
1476 __isKeypadOpened = false;
1478 pItem->RemoveAllControls();
1479 SetNameFields(*pItem);
1483 case TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX:
1486 Panel* pPanel = static_cast<Panel*>(pItem->GetControl(0));
1493 Label* pLabel = static_cast<Label*>(pPanel->GetControl(1));
1502 valueString = __pPresentationModel->GetValue(DETAIL_PROPERTY_GROUP);
1503 if (valueString.IsEmpty() == true)
1505 valueString = ResourceManager::GetString(L"IDS_PB_BODY_NOT_ASSIGNED");
1508 else if (itemIndex == 2)
1510 String ringtoneName = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
1513 ringtoneName.LastIndexOf(L"/", ringtoneName.GetLength() - 1, index);
1517 ringtoneName.SubString(index + 1, valueString);
1521 pLabel->SetText(valueString);
1522 pLabel->Invalidate(false);
1525 case TABLE_VIEW_BIRTHDAY_FIELD_INDEX:
1529 DateTime birthdayDate;
1530 EditDate* pBirthday = static_cast<EditDate *>(pItem->GetControl(1));
1532 if (pBirthday == null)
1537 __pPresentationModel->GetBirthday(birthdayDate);
1539 pBirthday->GetYearRange(min, max);
1540 max = birthdayDate.GetYear();
1541 pBirthday->SetYearRange(max - BIRTHDAY_MIN_YEAR_DIFF, max);
1542 pBirthday->SetDate(birthdayDate);
1543 pBirthday->Invalidate(false);
1546 case TABLE_VIEW_NOTE_FIELD_INDEX:
1548 Control* pNoteField = pItem->GetControl(1);
1549 Control* pNoteLabel = pItem->GetControl(0);
1550 if (pNoteField == null)
1555 pItem->SetSize(pItem->GetWidth(), pNoteLabel->GetHeight() + pNoteField->GetHeight() + H_EDIT_FIELD_GAP);
1563 Tizen::Ui::Controls::TableViewItem*
1564 ContactEditorForm::GetThumbnailField(int itemWidth)
1566 TableViewItem* pThumbnailItem = new (std::nothrow) TableViewItem();
1567 pThumbnailItem->Construct(Dimension(itemWidth, W_THUMBNAIL + H_THUMBNAIL_DELETE_BUTTON_GAP + Y_EDIT_FIELD_GAP * 2));
1568 pThumbnailItem->SetBackgroundColor(Color(0), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1570 SetThumbnailControls(*pThumbnailItem);
1572 return pThumbnailItem;
1575 Tizen::Ui::Controls::TableViewItem*
1576 ContactEditorForm::GetNameFields(int itemWidth)
1578 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1580 __pNameFieldItem = new (std::nothrow) TableViewItem();
1581 __pNameFieldItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight()));
1582 __pNameFieldItem->SetBackgroundColor(Color(0), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1584 SetNameFields(*__pNameFieldItem);
1586 return __pNameFieldItem;
1590 ContactEditorForm::SetNameFields(Tizen::Ui::Controls::TableViewItem& item)
1592 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1594 int itemWidth = item.GetWidth();
1595 int itemHeight = pContactsApp->GetListItemSingleLineHeight();
1597 if (__isExpandable == true)
1599 itemHeight = DEFAULT_EXPAND_NAME_FIELD_COUNT * pContactsApp->GetListItemSingleLineHeight();
1601 if (__isJobTitleEnabled == true)
1603 itemHeight += pContactsApp->GetListItemSingleLineHeight();
1606 if (__isDepartmentEnabled)
1608 itemHeight += pContactsApp->GetListItemSingleLineHeight();
1612 item.SetSize(itemWidth, itemHeight);
1614 Rectangle itemBounds(W_ITEM_GAP, Y_EDIT_FIELD_GAP, itemWidth - (W_ITEM_GAP * 3) - H_BUTTON, pContactsApp->GetListItemSingleLineHeight() - H_EDIT_FIELD_GAP);
1616 if (__isExpandable == true)
1618 EditField* pFirstName = new (std::nothrow) EditField();
1619 pFirstName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, __pPresentationModel->GetValue(DETAIL_PROPERTY_FIRST_NAME).GetLength() + EDIT_FIELD_EXTENDED_LENGTH);
1620 pFirstName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_FIRST_NAME"));
1621 pFirstName->AddFocusEventListener(*this);
1622 pFirstName->AddKeypadEventListener(*this);
1623 pFirstName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_FIRST_NAME"));
1624 pFirstName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_FIRST_NAME));
1625 pFirstName->AddTextEventListener(*this);
1626 pFirstName->SetTextSize(pContactsApp->GetFontSize());
1628 item.AddControl(pFirstName);
1629 item.SetIndividualSelectionEnabled(pFirstName, true);
1631 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1632 EditField* pMiddleName = new (std::nothrow) EditField();
1633 pMiddleName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, __pPresentationModel->GetValue(DETAIL_PROPERTY_MIDDLE_NAME).GetLength() + EDIT_FIELD_EXTENDED_LENGTH);
1634 pMiddleName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_MIDDLE_NAME"));
1635 pMiddleName->AddFocusEventListener(*this);
1636 pMiddleName->AddKeypadEventListener(*this);
1637 pMiddleName->AddTextEventListener(*this);
1638 pMiddleName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_MIDDLE_NAME"));
1639 pMiddleName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_MIDDLE_NAME));
1640 pMiddleName->SetTextSize(pContactsApp->GetFontSize());
1642 item.AddControl(pMiddleName);
1643 item.SetIndividualSelectionEnabled(pMiddleName, true);
1645 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1646 EditField* pLastName = new (std::nothrow) EditField();
1647 pLastName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, __pPresentationModel->GetValue(DETAIL_PROPERTY_LAST_NAME).GetLength() + EDIT_FIELD_EXTENDED_LENGTH);
1648 pLastName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_LAST_NAME"));
1649 pLastName->AddFocusEventListener(*this);
1650 pLastName->AddKeypadEventListener(*this);
1651 pLastName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_LAST_NAME"));
1652 pLastName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_LAST_NAME));
1653 pLastName->SetTextSize(pContactsApp->GetFontSize());
1654 pLastName->AddTextEventListener(*this);
1656 item.AddControl(pLastName);
1657 item.SetIndividualSelectionEnabled(pLastName, true);
1659 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1660 EditField* pSuffix = new (std::nothrow) EditField();
1661 pSuffix->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, __pPresentationModel->GetValue(DETAIL_PROPERTY_NAME_SUFFIX).GetLength() + EDIT_FIELD_EXTENDED_LENGTH);
1662 pSuffix->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_SUFFIX"));
1663 pSuffix->AddFocusEventListener(*this);
1664 pSuffix->AddKeypadEventListener(*this);
1665 pSuffix->AddTextEventListener(*this);
1666 pSuffix->SetName(ResourceManager::GetString(L"IDS_PB_BODY_SUFFIX"));
1667 pSuffix->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_NAME_SUFFIX));
1668 pSuffix->SetTextSize(pContactsApp->GetFontSize());
1670 item.AddControl(pSuffix);
1671 item.SetIndividualSelectionEnabled(pSuffix, true);
1673 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1674 EditField* pNickName = new (std::nothrow) EditField();
1675 pNickName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY);
1676 pNickName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_NICKNAME"));
1677 pNickName->AddFocusEventListener(*this);
1678 pNickName->AddKeypadEventListener(*this);
1679 pNickName->AddTextEventListener(*this);
1680 pNickName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_NICKNAME"));
1681 pNickName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_NICK_NAME));
1682 pNickName->SetTextSize(pContactsApp->GetFontSize());
1684 item.AddControl(pNickName);
1685 item.SetIndividualSelectionEnabled(pNickName, true);
1687 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1688 if (__isJobTitleEnabled == true)
1690 EditField* pJobTitle = new (std::nothrow) EditField();
1691 pJobTitle->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY);
1692 pJobTitle->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_JOB_TITLE"));
1693 pJobTitle->AddFocusEventListener(*this);
1694 pJobTitle->AddKeypadEventListener(*this);
1695 pJobTitle->AddTextEventListener(*this);
1696 pJobTitle->SetName(ResourceManager::GetString(L"IDS_PB_BODY_JOB_TITLE"));
1697 pJobTitle->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_JOB_TITLE));
1698 pJobTitle->SetTextSize(pContactsApp->GetFontSize());
1700 item.AddControl(pJobTitle);
1701 item.SetIndividualSelectionEnabled(pJobTitle, true);
1703 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1706 if (__isDepartmentEnabled == true)
1708 EditField* pDepartment = new (std::nothrow) EditField();
1709 pDepartment->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY);
1710 pDepartment->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_DEPARTMENT"));
1711 pDepartment->AddFocusEventListener(*this);
1712 pDepartment->AddKeypadEventListener(*this);
1713 pDepartment->AddTextEventListener(*this);
1714 pDepartment->SetName(ResourceManager::GetString(L"IDS_PB_BODY_DEPARTMENT"));
1715 pDepartment->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEPARTMENT));
1716 pDepartment->SetTextSize(pContactsApp->GetFontSize());
1718 item.AddControl(pDepartment);
1719 item.SetIndividualSelectionEnabled(pDepartment, true);
1721 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1724 EditField* pCompanyName = new (std::nothrow) EditField();
1725 pCompanyName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY);
1726 pCompanyName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_COMPANY"));
1727 pCompanyName->AddFocusEventListener(*this);
1728 pCompanyName->AddKeypadEventListener(*this);
1729 pCompanyName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_COMPANY"));
1730 pCompanyName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_COMPANY));
1731 pCompanyName->SetTextSize(pContactsApp->GetFontSize());
1733 item.AddControl(pCompanyName);
1734 item.SetIndividualSelectionEnabled(pCompanyName, true);
1739 String firstName(__pPresentationModel->GetValue(DETAIL_PROPERTY_FIRST_NAME));
1740 String lastName(__pPresentationModel->GetValue(DETAIL_PROPERTY_LAST_NAME));
1741 String middleName(__pPresentationModel->GetValue(DETAIL_PROPERTY_MIDDLE_NAME));
1742 String suffix(__pPresentationModel->GetValue(DETAIL_PROPERTY_NAME_SUFFIX));
1744 nameLength = firstName.GetLength() + lastName.GetLength() + middleName.GetLength();
1745 if (suffix.IsEmpty() == false)
1747 nameLength = nameLength + suffix.GetLength() + 1;
1750 EditField* pName = new (std::nothrow) EditField();
1751 pName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, nameLength + EDIT_FIELD_EXTENDED_LENGTH);
1752 pName->SetGuideText(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS_NAME"));
1753 pName->AddFocusEventListener(*this);
1754 pName->AddKeypadEventListener(*this);
1755 pName->SetName(Integer::ToString(IDA_INPUT_FIELD_DISPLAY_NAME));
1756 pName->AddTextEventListener(*this);
1757 pName->SetTextSize(pContactsApp->GetFontSize());
1759 if (firstName.IsEmpty() == false)
1761 pName->SetText(firstName);
1764 if (middleName.IsEmpty() == false)
1766 pName->AppendText(CHARACTER_SPACE + middleName);
1769 if (lastName.IsEmpty() == false)
1771 pName->AppendText(CHARACTER_SPACE + lastName);
1774 if (suffix.IsEmpty() == false)
1776 pName->AppendText(DELIMITER_COMMA);
1777 pName->AppendText(CHARACTER_SPACE + suffix);
1780 item.AddControl(pName);
1781 item.SetIndividualSelectionEnabled(pName, true);
1782 __fullName = pName->GetText();
1785 Button* pButtonExpand = new (std::nothrow) Button();
1786 pButtonExpand->Construct(Rectangle(itemWidth - (H_BUTTON + W_ITEM_GAP), (pContactsApp->GetListItemSingleLineHeight() - H_BUTTON) / 2, H_BUTTON, H_BUTTON));
1787 pButtonExpand->SetActionId(IDA_BUTTON_EXPANDABLE);
1788 pButtonExpand->SetName(EXPAND_BUTTON);
1789 pButtonExpand->AddActionEventListener(*this);
1791 Bitmap* pBitmap = null;
1792 Bitmap* pBitmapPressed = null;
1794 if (__isExpandable == true)
1796 pBitmap = ResourceManager::GetBitmapN(IDB_EXPAND_OPENED);
1797 pBitmapPressed = ResourceManager::GetBitmapN(IDB_EXPAND_OPENED_PRESSED);
1801 pBitmap = ResourceManager::GetBitmapN(IDB_EXPAND_CLOSED);
1802 pBitmapPressed = ResourceManager::GetBitmapN(IDB_EXPAND_CLOSED_PRESSED);
1805 if (pBitmap != null)
1807 pButtonExpand->SetNormalBitmap(Point(0, 0), *pBitmap);
1810 if (pBitmapPressed != null)
1812 pButtonExpand->SetPressedBitmap(Point(0, 0), *pBitmapPressed);
1816 delete pBitmapPressed;
1818 pBitmap = ResourceManager::GetBitmapN(IDB_EXPAND_BUTTON_NORMAL);
1819 pBitmapPressed = ResourceManager::GetBitmapN(IDB_EXPAND_BUTTON_PRESSED);
1821 if (pBitmap != null)
1823 pButtonExpand->SetNormalBackgroundBitmap(*pBitmap);
1826 if (pBitmapPressed != null)
1828 pButtonExpand->SetPressedBackgroundBitmap(*pBitmapPressed);
1829 delete pBitmapPressed;
1832 item.AddControl(pButtonExpand);
1833 item.SetIndividualSelectionEnabled(pButtonExpand, true);
1836 Tizen::Ui::Controls::TableViewItem*
1837 ContactEditorForm::GetInputFieldN(int groupIndex, int itemIndex, int itemWidth, Tizen::Ui::Controls::EditFieldStyle style, const Tizen::Base::String& titleText, const Tizen::Base::String& guideText, const Tizen::Base::String& text, bool isDeleteButton)
1839 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1841 TableViewItem* pTableViewItem = new (std::nothrow) TableViewItem();
1842 pTableViewItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight()), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1843 pTableViewItem->SetBackgroundColor(Color(0), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1845 EditField* pInputField = new (std::nothrow) EditField();
1846 pInputField->Construct(Rectangle(W_ITEM_GAP, Y_EDIT_FIELD_GAP, itemWidth - (W_ITEM_GAP * 4) - H_BUTTON - W_TYPE_BUTTON, pContactsApp->GetListItemSingleLineHeight() - H_EDIT_FIELD_GAP), style, INPUT_STYLE_OVERLAY);
1847 pInputField->SetGuideText(guideText);
1848 pInputField->SetText(text);
1849 pInputField->SetTextSize(pContactsApp->GetFontSize());
1850 pInputField->AddKeypadEventListener(*this);
1851 pInputField->AddFocusEventListener(*this);
1852 pInputField->AddTextEventListener(*this);
1853 pInputField->SetEnabled(true);
1855 int parsedItemIndex = 0;
1856 parsedItemIndex |= (groupIndex << TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT);
1857 parsedItemIndex |= (groupIndex << TABLE_VIEW_GROUP_INDEX_SHIFT);
1858 parsedItemIndex |= itemIndex;
1860 pInputField->SetName(Integer::ToString(parsedItemIndex));
1861 pTableViewItem->AddControl(pInputField);
1863 Button *pButtonType = new (std::nothrow) Button();
1864 pButtonType->Construct(Rectangle(pInputField->GetX() + pInputField->GetWidth() + W_ITEM_GAP, (pContactsApp->GetListItemSingleLineHeight() - H_BUTTON) / 2, W_TYPE_BUTTON, H_BUTTON));
1865 pButtonType->SetText(titleText);
1866 pButtonType->SetActionId(IDA_BUTTON_TYPE);
1867 pButtonType->AddActionEventListener(*this);
1868 pButtonType->AddTouchEventListener(*this);
1869 pButtonType->SetName(Integer::ToString(parsedItemIndex));
1871 Bitmap* pDropBoxIcon = ResourceManager::GetBitmapN(IDB_BUTTON_DROPBOX);
1873 if (pDropBoxIcon != null)
1875 pButtonType->SetNormalBitmap(Point(W_TYPE_BUTTON - W_DROPBOX_ICON, H_BUTTON - H_DROPBOX_ICON), *pDropBoxIcon);
1876 pButtonType->SetPressedBitmap(Point(W_TYPE_BUTTON - W_DROPBOX_ICON, H_BUTTON - H_DROPBOX_ICON), *pDropBoxIcon);
1877 pButtonType->SetDisabledBitmap(Point(W_TYPE_BUTTON - W_DROPBOX_ICON, H_BUTTON - H_DROPBOX_ICON), *pDropBoxIcon);
1878 delete pDropBoxIcon;
1880 pTableViewItem->AddControl(pButtonType);
1882 Button *pButtonDelete = new (std::nothrow) Button();
1883 pButtonDelete->Construct(Rectangle(itemWidth - H_BUTTON - W_ITEM_GAP, (pContactsApp->GetListItemSingleLineHeight() - H_BUTTON) / 2, H_BUTTON, H_BUTTON));
1884 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS);
1885 Bitmap* pBitmapPressed = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS_PRESSED);
1887 if (pBitmap != null)
1889 pButtonDelete->SetNormalBitmap(Point(0, 0), *pBitmap);
1892 if (pBitmapPressed != null)
1894 pButtonDelete->SetPressedBitmap(Point(0, 0), *pBitmapPressed);
1895 delete pBitmapPressed;
1898 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_NORMAL);
1899 pBitmapPressed = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_PRESSED);
1901 if (pBitmap != null)
1903 pButtonDelete->SetNormalBackgroundBitmap(*pBitmap);
1906 if (pBitmapPressed != null)
1908 pButtonDelete->SetPressedBackgroundBitmap(*pBitmapPressed);
1909 delete pBitmapPressed;
1913 actionId |= TABLE_VIEW_DELETE_INPUT_FIELD_ID;
1914 actionId |= (groupIndex << TABLE_VIEW_GROUP_INDEX_SHIFT);
1915 actionId |= itemIndex;
1917 pButtonDelete->SetActionId(actionId);
1918 pButtonDelete->AddActionEventListener(*this);
1920 pTableViewItem->AddControl(pButtonDelete);
1922 if (isDeleteButton == false)
1924 pButtonDelete->SetShowState(false);
1927 pTableViewItem->SetIndividualSelectionEnabled(pInputField, true);
1928 pTableViewItem->SetIndividualSelectionEnabled(pButtonType, true);
1929 pTableViewItem->SetIndividualSelectionEnabled(pButtonDelete, true);
1931 return pTableViewItem;
1934 Tizen::Ui::Controls::TableViewItem*
1935 ContactEditorForm::GetPhoneNumberFields(int itemIndex, int itemWidth)
1937 if (__pPhoneNumberFieldItem->GetCount() == 0)
1939 int phoneNumberCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
1940 String guideText = ResourceManager::GetString(L"IDS_PB_BODY_NUMBER");
1941 String defaultPhoneNumber = __pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER);
1943 for (int i = 0; i < phoneNumberCount; i++)
1945 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, i);
1946 String phoneNumberString = __pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, i);
1948 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_PHONE_NUMBER, typeString, guideText, phoneNumberString, true);
1949 pItem->SetName(Integer::ToString(__pPresentationModel->GetPhoneNumberType(i)));
1951 __pPhoneNumberFieldItem->Add(*pItem);
1954 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX, phoneNumberCount, itemWidth, EDIT_FIELD_STYLE_PHONE_NUMBER, __pPresentationModel->GetPhoneNumberTypeString(DETAIL_PHONENUMBER_TYPE_MOBILE), guideText);
1955 pItem->SetName(Integer::ToString(DETAIL_PHONENUMBER_TYPE_MOBILE));
1957 __pPhoneNumberFieldItem->Add(*pItem);
1958 SetAsDefaultPhoneNumber(__pPresentationModel->GetDefaultNumberIndex());
1961 if (__pPhoneNumberFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) + 1))
1963 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX, __pPhoneNumberFieldItem->GetCount(), itemWidth, EDIT_FIELD_STYLE_PHONE_NUMBER, __pPresentationModel->GetPhoneNumberTypeString(DETAIL_PHONENUMBER_TYPE_MOBILE), ResourceManager::GetString(L"IDS_PB_BODY_NUMBER"));
1964 pItem->SetName(Integer::ToString(DETAIL_PHONENUMBER_TYPE_MOBILE));
1966 __pPhoneNumberFieldItem->Add(*pItem);
1969 TableViewItem* pItem = static_cast<TableViewItem *>(__pPhoneNumberFieldItem->GetAt(itemIndex));
1978 Tizen::Ui::Controls::TableViewItem*
1979 ContactEditorForm::GetEmailFields(int itemIndex, int itemWidth)
1981 if (__pEmailFieldItem->GetCount() == 0)
1983 int emailCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL);
1984 String guideText = ResourceManager::GetString(L"IDS_COM_BODY_EMAIL");
1986 for (int i = 0; i < emailCount; i++)
1988 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_EMAIL, i);
1989 String emailString = __pPresentationModel->GetValue(DETAIL_PROPERTY_EMAIL, i);
1991 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_EMAIL_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_EMAIL, typeString, guideText, emailString, true);
1992 pItem->SetName(Integer::ToString(__pPresentationModel->GetEmailType(i)));
1994 __pEmailFieldItem->Add(*pItem);
1997 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_EMAIL_FIELD_INDEX, emailCount, itemWidth, EDIT_FIELD_STYLE_EMAIL, __pPresentationModel->GetEmailTypeString(DETAIL_EMAIL_TYPE_HOME), guideText);
1998 pItem->SetName(Integer::ToString(DETAIL_EMAIL_TYPE_HOME));
2000 __pEmailFieldItem->Add(*pItem);
2003 if (__pEmailFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL) + 1))
2005 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_EMAIL_FIELD_INDEX, __pEmailFieldItem->GetCount(), itemWidth, EDIT_FIELD_STYLE_EMAIL, __pPresentationModel->GetEmailTypeString(DETAIL_EMAIL_TYPE_HOME), ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"));
2006 pItem->SetName(Integer::ToString(DETAIL_EMAIL_TYPE_HOME));
2008 __pEmailFieldItem->Add(*pItem);
2011 TableViewItem* pItem = static_cast<TableViewItem *>(__pEmailFieldItem->GetAt(itemIndex));
2020 Tizen::Ui::Controls::TableViewItem*
2021 ContactEditorForm::GetAddressFields(int itemIndex, int itemWidth)
2023 if (__pAddressFieldItem->GetCount() == 0)
2025 int addressCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_ADDRESS);
2026 String guideText = ResourceManager::GetString(L"IDS_PB_BODY_ADDRESS");
2028 for (int i = 0; i < addressCount; i++)
2030 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_ADDRESS, i);
2031 String addressString = __pPresentationModel->GetValue(DETAIL_PROPERTY_ADDRESS, i);
2033 TableViewItem* pItem= GetInputFieldN(TABLE_VIEW_ADDRESS_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_NORMAL, typeString, guideText, addressString, true);
2034 pItem->SetName(Integer::ToString(__pPresentationModel->GetAddressType(DETAIL_PROPERTY_ADDRESS, i)));
2036 __pAddressFieldItem->Add(*pItem);
2039 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_ADDRESS_FIELD_INDEX, addressCount, itemWidth, EDIT_FIELD_STYLE_NORMAL, ResourceManager::GetString(L"IDS_PB_BODY_HOME"), guideText);
2040 pItem->SetName(Integer::ToString(DETAIL_ADDRESS_TYPE_HOME));
2042 __pAddressFieldItem->Add(*pItem);
2045 if (__pAddressFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_ADDRESS) + 1))
2047 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_ADDRESS_FIELD_INDEX, __pAddressFieldItem->GetCount(), itemWidth, EDIT_FIELD_STYLE_NORMAL, ResourceManager::GetString(L"IDS_PB_BODY_HOME"), ResourceManager::GetString(L"IDS_PB_BODY_ADDRESS"));
2048 pItem->SetName(Integer::ToString(DETAIL_ADDRESS_TYPE_HOME));
2050 __pAddressFieldItem->Add(*pItem);
2053 TableViewItem* pItem = static_cast<TableViewItem *>(__pAddressFieldItem->GetAt(itemIndex));
2062 Tizen::Ui::Controls::TableViewItem*
2063 ContactEditorForm::GetImAddressFields(int itemIndex, int itemWidth)
2065 if (__pImAddressFieldItem->GetCount() == 0)
2067 int imCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS);
2068 String guideText = ResourceManager::GetString(L"IDS_PB_HEADER_INSTANT_MESSENGER_ABB");
2070 for (int i = 0; i < imCount; i++)
2072 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_IM_ADDRESS, i);
2073 String imString = __pPresentationModel->GetValue(DETAIL_PROPERTY_IM_ADDRESS, i);
2075 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_IM_ADDRESS_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_NORMAL, typeString, guideText, imString, true);
2076 pItem->SetName(Integer::ToString(__pPresentationModel->GetImAddressType(i)));
2078 __pImAddressFieldItem->Add(*pItem);
2081 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_IM_ADDRESS_FIELD_INDEX, imCount, itemWidth, EDIT_FIELD_STYLE_NORMAL, IM_ADDRESS_YAHOO, guideText);
2082 pItem->SetName(Integer::ToString(DETAIL_IM_ADDRESS_TYPE_YAHOO));
2084 __pImAddressFieldItem->Add(*pItem);
2087 if (__pImAddressFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS) + 1))
2089 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_IM_ADDRESS_FIELD_INDEX, __pImAddressFieldItem->GetCount(), itemWidth, EDIT_FIELD_STYLE_NORMAL, IM_ADDRESS_YAHOO, ResourceManager::GetString(L"IDS_PB_HEADER_INSTANT_MESSENGER_ABB"));
2090 pItem->SetName(Integer::ToString(DETAIL_IM_ADDRESS_TYPE_YAHOO));
2092 __pImAddressFieldItem->Add(*pItem);
2095 TableViewItem* pItem = static_cast<TableViewItem *>(__pImAddressFieldItem->GetAt(itemIndex));
2104 Tizen::Ui::Controls::TableViewItem*
2105 ContactEditorForm::GetUrlFields(int itemIndex, int itemWidth)
2107 if (__pUrlFieldItem->GetCount() == 0)
2109 int urlCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL);
2110 String guideText = ResourceManager::GetString(L"IDS_PB_BODY_URL");
2112 for (int i = 0; i < urlCount; i++)
2114 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_URL, i);
2115 String urlString = __pPresentationModel->GetValue(DETAIL_PROPERTY_URL, i);
2117 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_URL_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_URL, typeString, guideText, urlString, true);
2118 pItem->SetName(Integer::ToString(__pPresentationModel->GetUrlType(i)));
2120 __pUrlFieldItem->Add(*pItem);
2123 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_URL_FIELD_INDEX, urlCount, itemWidth, EDIT_FIELD_STYLE_URL, __pPresentationModel->GetUrlTypeString(DETAIL_URL_TYPE_HOME), guideText);
2124 pItem->SetName(Integer::ToString(DETAIL_URL_TYPE_HOME));
2126 __pUrlFieldItem->Add(*pItem);
2129 if (__pUrlFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL) + 1))
2131 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_URL_FIELD_INDEX, __pUrlFieldItem->GetCount(), itemWidth, EDIT_FIELD_STYLE_URL, __pPresentationModel->GetUrlTypeString(DETAIL_URL_TYPE_HOME), ResourceManager::GetString(L"IDS_PB_BODY_URL"));
2132 pItem->SetName(Integer::ToString(DETAIL_URL_TYPE_HOME));
2134 __pUrlFieldItem->Add(*pItem);
2137 TableViewItem* pItem = static_cast<TableViewItem *>(__pUrlFieldItem->GetAt(itemIndex));
2145 Tizen::Ui::Controls::TableViewItem*
2146 ContactEditorForm::GetGroupsField(int itemWidth)
2148 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2150 TableViewItem* pGroupsItem = new (std::nothrow) TableViewItem();
2151 pGroupsItem->Construct(Dimension(itemWidth, H_DOUBLE_LINE_ITEM + pContactsApp->GetFontHeightOffset()), TABLE_VIEW_ANNEX_STYLE_NORMAL);
2152 pGroupsItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
2153 pGroupsItem->AddKeyEventListener(*this);
2155 Panel* pGroupStyle = new (std::nothrow) Panel();
2156 pGroupStyle->Construct(Rectangle(0, 0, itemWidth , H_DOUBLE_LINE_ITEM + pContactsApp->GetFontHeightOffset()), GROUP_STYLE_NONE);
2157 pGroupStyle->SetName(GROUP_STYLE_PANEL);
2158 pGroupStyle->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
2159 pGroupStyle->AddTouchEventListener(*this);
2160 pGroupsItem->AddControl(pGroupStyle);
2162 Label* pLabelTitle = new (std::nothrow) Label();
2163 pLabelTitle->Construct(Rectangle(0, H_GROUP_RINGTONE_TITLE_GAP, itemWidth, H_GROUP_RINGTONE_TITLE_LABEL), ResourceManager::GetString(L"IDS_PB_BODY_GROUPS"));
2164 pLabelTitle->SetName(GROUP_LABEL_TITLE);
2165 pLabelTitle->AddTouchEventListener(*this);
2166 pLabelTitle->SetTextConfig(FONT_SIZE_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
2167 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
2168 pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2170 pGroupStyle->AddControl(pLabelTitle);
2172 String groupsName = __pPresentationModel->GetValue(DETAIL_PROPERTY_GROUP);
2173 if (groupsName.IsEmpty() == true)
2175 groupsName = ResourceManager::GetString(L"IDS_PB_BODY_NOT_ASSIGNED");
2178 Label* pLabelGroupName = new (std::nothrow) Label();
2179 pLabelGroupName->Construct(Rectangle(0, H_GROUP_RINGTONE_TITLE_GAP + H_GROUP_RINGTONE_TITLE_LABEL, itemWidth, H_GROUP_RINGTONE_VALUE_LABEL + pContactsApp->GetFontHeightOffset()), groupsName);
2180 pLabelGroupName->SetName(GROUP_LABEL_VALUE);
2181 pLabelGroupName->AddTouchEventListener(*this);
2182 pLabelGroupName->SetTextConfig(pContactsApp->GetFontSize(), LABEL_TEXT_STYLE_NORMAL);
2183 pLabelGroupName->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2185 pGroupStyle->AddControl(pLabelGroupName);
2190 Tizen::Ui::Controls::TableViewItem*
2191 ContactEditorForm::GetBirthdayField(int itemWidth)
2193 DateTime birthdayDate;
2194 EditDate* pBirthday = new (std::nothrow) EditDate();
2195 pBirthday->Construct(Point(W_TITLE_LABEL, 0));
2196 pBirthday->AddDateChangeEventListener(*this);
2198 __pPresentationModel->GetBirthday(birthdayDate);
2199 pBirthday->SetDate(birthdayDate);
2201 DateTime currentDate;
2202 Tizen::System::SystemTime::GetCurrentTime(currentDate);
2205 pBirthday->GetYearRange(min, max);
2206 max = currentDate.GetYear();
2207 pBirthday->SetYearRange(max - BIRTHDAY_MIN_YEAR_DIFF, max);
2209 if (birthdayDate.GetYear() < (currentDate.GetYear() - BIRTHDAY_MIN_YEAR_DIFF))
2211 birthdayDate.SetValue(currentDate.GetYear() - BIRTHDAY_MIN_YEAR_DIFF, birthdayDate.GetMonth(), birthdayDate.GetDay());
2212 __pPresentationModel->SetBirthday(birthdayDate);
2215 TableViewItem* pBirthdayItem = new (std::nothrow) TableViewItem();
2216 pBirthdayItem->Construct(Dimension(itemWidth, H_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL);
2217 pBirthdayItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
2218 pBirthdayItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
2220 Label* pLabelTitle = new (std::nothrow) Label();
2221 pLabelTitle->Construct(Rectangle(0, 0, W_TITLE_LABEL, pBirthdayItem->GetHeight()), L"");
2222 pLabelTitle->SetText(ResourceManager::GetString(L"IDS_PB_BODY_BIRTHDAY"));
2223 pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2224 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
2225 pLabelTitle->SetTextConfig(FONT_SIZE_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
2227 pBirthdayItem->AddControl(pLabelTitle);
2228 pBirthdayItem->AddControl(pBirthday);
2230 Button* pClearButton = new (std::nothrow) Button();
2231 pClearButton->Construct(Rectangle(itemWidth - (H_BUTTON * 2) - H_BUTTON/2, (pBirthdayItem->GetHeight() - H_BUTTON) / 2, H_BUTTON, H_BUTTON));
2232 pClearButton->SetActionId(IDA_BUTTON_BIRTHDAY_CLEAR);
2233 pClearButton->AddActionEventListener(*this);
2235 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_RESET_NORMAL);
2236 if (pBitmap != null)
2238 pClearButton->SetNormalBitmap(Point(0, 0), *pBitmap);
2241 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_RESET_PRESSED);
2242 if (pBitmap != null)
2244 pClearButton->SetPressedBitmap(Point(0, 0), *pBitmap);
2248 pBirthdayItem->AddControl(pClearButton);
2250 Button *pButtonDelete = new (std::nothrow) Button();
2251 pButtonDelete->Construct(Rectangle(itemWidth - H_BUTTON - W_ITEM_GAP, (H_ITEM - H_BUTTON) / 2, H_BUTTON, H_BUTTON));
2253 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS);
2254 if (pBitmap != null)
2256 pButtonDelete->SetNormalBitmap(Point(0, 0), *pBitmap);
2260 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS_PRESSED);
2261 if (pBitmap != null)
2263 pButtonDelete->SetPressedBitmap(Point(0, 0), *pBitmap);
2267 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_NORMAL);
2268 if (pBitmap != null)
2270 pButtonDelete->SetNormalBackgroundBitmap(*pBitmap);
2274 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_PRESSED);
2275 if (pBitmap != null)
2277 pButtonDelete->SetPressedBackgroundBitmap(*pBitmap);
2281 pButtonDelete->SetActionId(IDA_BUTTON_BIRTHDAY_DELETE);
2282 pButtonDelete->AddActionEventListener(*this);
2284 pBirthdayItem->AddControl(pButtonDelete);
2286 pBirthdayItem->SetIndividualSelectionEnabled(pBirthday, true);
2287 pBirthdayItem->SetIndividualSelectionEnabled(pClearButton, true);
2288 pBirthdayItem->SetIndividualSelectionEnabled(pButtonDelete, true);
2290 return pBirthdayItem;
2293 Tizen::Ui::Controls::TableViewItem*
2294 ContactEditorForm::GetNoteField(int itemWidth)
2296 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2298 if (__pNoteFieldItem != null)
2300 return __pNoteFieldItem;
2303 __pNoteFieldItem = new (std::nothrow) TableViewItem();
2304 __pNoteFieldItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight() + Y_EDIT_FIELD_GAP), TABLE_VIEW_ANNEX_STYLE_NORMAL);
2305 __pNoteFieldItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
2306 __pNoteFieldItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
2309 Label* pNoteTitle = new (std::nothrow) Label();
2310 pNoteTitle->Construct(Rectangle(0, 0, itemWidth, H_LABEL), ResourceManager::GetString(L"IDS_PB_BODY_NOTE"));
2311 pNoteTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2312 pNoteTitle->SetTextColor(COLOR_ITEM_TITLE);
2313 pNoteTitle->SetTextConfig(FONT_SIZE_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
2314 __pNoteFieldItem->AddControl(pNoteTitle);
2316 ExpandableEditArea* pNoteEditArea = new (std::nothrow) ExpandableEditArea();
2317 pNoteEditArea->Construct(Rectangle(Y_EDIT_FIELD_GAP, H_LABEL, itemWidth - H_EDIT_FIELD_GAP, pContactsApp->GetListItemSingleLineHeight() - H_LABEL + Y_EDIT_FIELD_GAP), EXPANDABLE_EDIT_AREA_STYLE_NORMAL, EXPANDABLE_EDIT_AREA_TITLE_STYLE_NONE);
2318 pNoteEditArea->SetTitleText(ResourceManager::GetString(L"IDS_PB_BODY_NOTE"));
2319 pNoteEditArea->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_NOTE));
2320 pNoteEditArea->AddExpandableEditAreaEventListener(*this);
2321 pNoteEditArea->AddKeypadEventListener(*this);
2322 pNoteEditArea->AddFocusEventListener(*this);
2323 pNoteEditArea->SetTextSize(pContactsApp->GetFontSize());
2324 pNoteEditArea->AddTextEventListener(*this);
2326 __pNoteFieldItem->AddControl(pNoteEditArea);
2327 __pNoteFieldItem->SetIndividualSelectionEnabled(pNoteEditArea, true);
2329 return __pNoteFieldItem;
2332 Tizen::Ui::Controls::TableViewItem*
2333 ContactEditorForm::GetRingtoneField(int itemWidth)
2335 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2337 TableViewItem* pRingtoneItem = new (std::nothrow) TableViewItem();
2338 pRingtoneItem->Construct(Dimension(itemWidth, H_DOUBLE_LINE_ITEM + pContactsApp->GetFontHeightOffset()), TABLE_VIEW_ANNEX_STYLE_NORMAL);
2339 pRingtoneItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
2340 pRingtoneItem->AddKeyEventListener(*this);
2342 Panel* pGroupStyle = new (std::nothrow) Panel();
2343 pGroupStyle->Construct(Rectangle(0, 0, itemWidth , H_DOUBLE_LINE_ITEM + pContactsApp->GetFontHeightOffset()), GROUP_STYLE_NONE);
2344 pGroupStyle->SetName(GROUP_STYLE_PANEL);
2345 pGroupStyle->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
2346 pGroupStyle->AddTouchEventListener(*this);
2347 pRingtoneItem->AddControl(pGroupStyle);
2349 Label* pLabelTitle = new (std::nothrow) Label();
2350 pLabelTitle->Construct(Rectangle(0, H_GROUP_RINGTONE_TITLE_GAP, itemWidth, H_GROUP_RINGTONE_TITLE_LABEL), ResourceManager::GetString(L"IDS_PB_BODY_RINGTONE"));
2351 pLabelTitle->SetName(GROUP_LABEL_TITLE);
2352 pLabelTitle->AddTouchEventListener(*this);
2353 pLabelTitle->SetTextConfig(FONT_SIZE_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
2354 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
2355 pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2357 pGroupStyle->AddControl(pLabelTitle);
2359 String ringtoneName = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
2363 ringtoneName.LastIndexOf(L"/", ringtoneName.GetLength() - 1, index);
2367 ringtoneName.SubString(index + 1, trimmedPath);
2370 Label* pLabelRingToneName = new (std::nothrow) Label();
2371 pLabelRingToneName->Construct(Rectangle(0, H_GROUP_RINGTONE_TITLE_GAP + H_GROUP_RINGTONE_TITLE_LABEL, itemWidth - H_GROUP_RINGTONE_TITLE_GAP - H_ICON_BUTTON, H_GROUP_RINGTONE_VALUE_LABEL + pContactsApp->GetFontHeightOffset()), trimmedPath);
2372 pLabelRingToneName->SetName(GROUP_LABEL_VALUE);
2373 pLabelRingToneName->AddTouchEventListener(*this);
2374 pLabelRingToneName->SetTextConfig(pContactsApp->GetFontSize(), LABEL_TEXT_STYLE_NORMAL);
2375 pLabelRingToneName->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2376 pGroupStyle->AddControl(pLabelRingToneName);
2378 Button* pClearButton = new (std::nothrow) Button();
2379 pClearButton->Construct(Rectangle(itemWidth - X_REFRESH_BUTTON_MARGIN, (pRingtoneItem->GetHeight() - H_ICON_BUTTON) / 2, H_ICON_BUTTON, H_ICON_BUTTON));
2380 pClearButton->SetActionId(IDA_BUTTON_RINGTONE_CLEAR);
2381 pClearButton->AddActionEventListener(*this);
2383 Bitmap* pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_NORMAL);
2386 pClearButton->SetNormalBitmap(Point(0, 0), *pReset);
2389 pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_PRESSED);
2392 pClearButton->SetPressedBitmap(Point(0, 0), *pReset);
2396 pGroupStyle->AddControl(pClearButton);
2397 pRingtoneItem->SetIndividualSelectionEnabled(pClearButton, true);
2399 return pRingtoneItem;
2402 Tizen::Ui::Controls::TableViewItem*
2403 ContactEditorForm::GetMoreInformationField(int itemWidth)
2405 TableViewItem* pMoreInformationItem = new (std::nothrow) TableViewItem();
2406 pMoreInformationItem->Construct(Dimension(itemWidth, H_DESCRIPTION_CONTAINER));
2407 pMoreInformationItem->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
2408 pMoreInformationItem->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
2410 Panel* pPanel = new (std::nothrow) Panel();
2411 pPanel->Construct(Rectangle(X_MORE_INFO_PANEL_GAP, X_MORE_INFO_PANEL_GAP, itemWidth - H_MORE_INFO_PANEL_GAP, H_DESCRIPTION_CONTAINER - H_MORE_INFO_PANEL_GAP));
2412 pPanel->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG));
2414 pMoreInformationItem->AddControl(pPanel);
2416 Button* pButtonMoreInformation = new (std::nothrow) Button();
2417 pButtonMoreInformation->Construct(Rectangle(X_MORE_INFORMATION_BUTTON, Y_MORE_INFORMATION_BUTTON, itemWidth - (X_MORE_INFORMATION_BUTTON * 2), H_BUTTON));
2418 pButtonMoreInformation->SetText(ResourceManager::GetString(L"IDS_KA_BODY_MORE_INFORMATION"));
2419 pButtonMoreInformation->SetActionId(IDA_BUTTON_MORE_INFO);
2420 pButtonMoreInformation->AddActionEventListener(*this);
2422 pPanel->AddControl(pButtonMoreInformation);
2424 return pMoreInformationItem;
2427 Tizen::Ui::Controls::TableViewItem*
2428 ContactEditorForm::GetDefaultPhoneNumberItem(int itemWidth)
2430 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2432 TableViewItem* pDefaultPhoneNumberItem = new (std::nothrow) TableViewItem();
2433 pDefaultPhoneNumberItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight()));
2434 pDefaultPhoneNumberItem->SetBackgroundColor(Color(0), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
2436 Button* pButtonDefaultNumber = new (std::nothrow) Button();
2437 pButtonDefaultNumber->Construct(Rectangle(X_MORE_INFORMATION_BUTTON, Y_DEFAULT_NUMBER_BUTTON, itemWidth - (X_MORE_INFORMATION_BUTTON * 2), H_BUTTON));
2438 pButtonDefaultNumber->SetText(ResourceManager::GetString(L"IDS_PB_BODY_MARK_AS_DEFAULT_NUMBER"));
2439 pButtonDefaultNumber->SetActionId(IDA_BUTTON_DEFAULT_PHONE_NUMBER);
2440 pButtonDefaultNumber->AddActionEventListener(*this);
2442 pDefaultPhoneNumberItem->AddControl(pButtonDefaultNumber);
2443 pDefaultPhoneNumberItem->SetIndividualSelectionEnabled(pButtonDefaultNumber, true);
2445 return pDefaultPhoneNumberItem;
2449 ContactEditorForm::DeleteInputField(int groupIndex, int itemIndex, int isUpdating)
2451 result r = E_SUCCESS;
2452 ArrayList* pFieldList = null;
2456 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
2458 pFieldList = __pPhoneNumberFieldItem;
2459 __pPresentationModel->SetPhoneNumber(DETAIL_PHONENUMBER_TYPE_NONE, L"", itemIndex); //phoneNumberType doesn't matter
2462 case TABLE_VIEW_EMAIL_FIELD_INDEX:
2464 pFieldList = __pEmailFieldItem;
2465 __pPresentationModel->SetEmail(DETAIL_EMAIL_TYPE_NONE, L"", itemIndex);
2468 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
2470 pFieldList = __pAddressFieldItem;
2471 __pPresentationModel->SetAddress(DETAIL_ADDRESS_TYPE_NONE, L"", itemIndex);
2474 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
2476 pFieldList = __pImAddressFieldItem;
2477 __pPresentationModel->SetImAddress(DETAIL_IM_ADDRESS_TYPE_NONE, L"", itemIndex);
2480 case TABLE_VIEW_URL_FIELD_INDEX:
2482 pFieldList = __pUrlFieldItem;
2483 __pPresentationModel->SetUrl(DETAIL_URL_TYPE_NONE, L"", itemIndex);
2490 TryReturn(pFieldList != null, E_FAILURE, "[E_FAILURE] Unable to delete the item.")
2492 __pDeletedItemList->Add(pFieldList->GetAt(itemIndex));
2494 r = pFieldList->RemoveAt(itemIndex, false);
2496 if (__previousGroupIndex == groupIndex && __previousItemIndex == itemIndex)
2498 __previousGroupIndex = -1;
2499 __previousItemIndex = -1;
2501 if (isUpdating == false)
2503 __pTableView->RefreshItem(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
2506 Rectangle clientBounds = GetClientAreaBounds();
2507 __pTableView->SetSize(clientBounds.width, clientBounds.height);
2509 for (int i = itemIndex; i < pFieldList->GetCount(); i++)
2511 TableViewItem* pItem = static_cast<TableViewItem *>(pFieldList->GetAt(i));
2518 EditField* pInputField = static_cast<EditField*>(pItem->GetControl(0));
2519 if (pInputField == null)
2524 result r = Integer::Decode(pInputField->GetName(), parsedIndex);
2525 if (r == E_NUM_FORMAT)
2529 pInputField->SetName(Integer::ToString(parsedIndex - 1));
2531 Button* pTypeButton = static_cast<Button*>(pItem->GetControl(1));
2532 if (pTypeButton == null)
2537 r = Integer::Decode(pTypeButton->GetName(), parsedIndex);
2538 if (r == E_NUM_FORMAT)
2542 pTypeButton->SetName(Integer::ToString(parsedIndex - 1));
2544 Button* pDeleteButton = static_cast<Button *>(pItem->GetControl(2));
2545 if (pDeleteButton == null)
2549 pDeleteButton->SetActionId(pDeleteButton->GetActionId() - 1);
2552 SaveContactData(false);
2553 SetSaveButtonEnabled(IsSaveContactValid());
2555 if (groupIndex == TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX)
2557 if (itemIndex == __pPresentationModel->GetDefaultNumberIndex())
2559 SetAsDefaultPhoneNumber(0);
2561 else if (itemIndex < __pPresentationModel->GetDefaultNumberIndex())
2563 SetAsDefaultPhoneNumber(__pPresentationModel->GetDefaultNumberIndex() - 1);
2567 if (__isDefaultPhoneNumberButtonEnabled == true && __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) < 2)
2569 if (isUpdating == false)
2571 __pTableView->RefreshItem(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX, __pTableView->GetItemCountAt(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX) - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
2573 __isDefaultPhoneNumberButtonEnabled = false;
2580 ContactEditorForm::SetThumbnailControls(Tizen::Ui::Controls::TableViewItem& item, bool isUpdated)
2582 Label* pLabelThumbnail = null;
2583 Button* pButtonAdd = null;
2584 Button* pButtonDelete = null;
2586 if (isUpdated == false)
2588 int itemWidth = GetBounds().width;
2590 pLabelThumbnail = new (std::nothrow) Label();
2591 pLabelThumbnail->Construct(Rectangle((itemWidth - W_THUMBNAIL) / 2, H_THUMBNAIL_DELETE_BUTTON_GAP + Y_EDIT_FIELD_GAP, W_THUMBNAIL, W_THUMBNAIL), L"");
2593 item.AddControl(pLabelThumbnail);
2595 Bitmap* pBitmapItem = null;
2596 Bitmap* pBitmapItemPressed = null;
2598 pButtonAdd = new (std::nothrow) Button();
2599 pButtonAdd->Construct(Rectangle(pLabelThumbnail->GetX() + ((pLabelThumbnail->GetWidth() - H_BUTTON) / 2), pLabelThumbnail->GetY() + ((pLabelThumbnail->GetHeight() - H_BUTTON) / 2), H_BUTTON, H_BUTTON));
2600 pButtonAdd->SetActionId(IDA_BUTTON_THUMBNAIL_ADD);
2601 pButtonAdd->AddActionEventListener(*this);
2603 pBitmapItem = ResourceManager::GetBitmapN(IDB_BUTTON_ADD);
2604 pBitmapItemPressed = ResourceManager::GetBitmapN(IDB_BUTTON_ADD_PRESSED);
2606 if (pBitmapItem != null)
2608 pButtonAdd->SetNormalBackgroundBitmap(*pBitmapItem);
2611 if (pBitmapItemPressed != null)
2613 pButtonAdd->SetPressedBackgroundBitmap(*pBitmapItemPressed);
2614 delete pBitmapItemPressed;
2616 item.AddControl(pButtonAdd);
2617 item.SetIndividualSelectionEnabled(pButtonAdd, true);
2619 pButtonDelete = new (std::nothrow) Button();
2620 pButtonDelete->Construct(Rectangle(pLabelThumbnail->GetX() - H_THUMBNAIL_DELETE_BUTTON_GAP, pLabelThumbnail->GetY() - H_THUMBNAIL_DELETE_BUTTON_GAP + Y_EDIT_FIELD_GAP, H_BUTTON, H_BUTTON));
2621 pButtonDelete->SetActionId(IDA_BUTTON_THUMBNAIL_DELETE);
2622 pButtonDelete->AddActionEventListener(*this);
2624 pBitmapItem = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS);
2625 pBitmapItemPressed = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS_PRESSED);
2627 if (pBitmapItem != null)
2629 pButtonDelete->SetNormalBitmap(Point(0, 0), *pBitmapItem);
2632 if (pBitmapItemPressed != null)
2634 pButtonDelete->SetPressedBitmap(Point(0, 0), *pBitmapItemPressed);
2635 delete pBitmapItemPressed;
2638 pBitmapItem = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_NORMAL);
2639 pBitmapItemPressed = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_PRESSED);
2641 if (pBitmapItem != null)
2643 pButtonDelete->SetNormalBackgroundBitmap(*pBitmapItem);
2646 if (pBitmapItemPressed != null)
2648 pButtonDelete->SetPressedBackgroundBitmap(*pBitmapItemPressed);
2649 delete pBitmapItemPressed;
2651 item.AddControl(pButtonDelete);
2652 item.SetIndividualSelectionEnabled(pButtonDelete, true);
2654 Button* pButtonCamera = new (std::nothrow) Button();
2655 pButtonCamera->Construct(Rectangle(pLabelThumbnail->GetX() + pLabelThumbnail->GetWidth(), pLabelThumbnail->GetY() + pLabelThumbnail->GetHeight() - H_BUTTON, H_BUTTON, H_BUTTON));
2656 pButtonCamera->SetActionId(IDA_BUTTON_CAMERA);
2657 pButtonCamera->AddActionEventListener(*this);
2659 pBitmapItem = ResourceManager::GetBitmapN(IDB_BUTTON_CAMERA);
2660 pBitmapItemPressed = ResourceManager::GetBitmapN(IDB_BUTTON_CAMERA_PRESSED);
2661 if (pBitmapItem != null)
2663 pButtonCamera->SetNormalBackgroundBitmap(*pBitmapItem);
2666 if (pBitmapItemPressed != null)
2668 pButtonCamera->SetPressedBackgroundBitmap(*pBitmapItemPressed);
2669 delete pBitmapItemPressed;
2672 item.AddControl(pButtonCamera);
2673 item.SetIndividualSelectionEnabled(pButtonCamera, true);
2677 pLabelThumbnail = static_cast<Label*>(item.GetControl(0));
2678 TryReturnVoid(pLabelThumbnail != null, "[E_FAILURE] Unable to get a thumbnail control.");
2680 pButtonAdd = static_cast<Button*>(item.GetControl(1));
2681 TryReturnVoid(pButtonAdd != null, "[E_FAILURE] Unable to get a button.");
2683 pButtonDelete = static_cast<Button*>(item.GetControl(2));
2684 TryReturnVoid(pButtonDelete != null, "[E_FAILURE] Unable to get a button.");
2687 Bitmap* pThumbnail = null;
2688 String thumbnailPath = __pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL);
2690 if (thumbnailPath.IsEmpty() == false)
2692 ImageBuffer thumbnailImageBuffer;
2693 result r = thumbnailImageBuffer.Construct(thumbnailPath);
2696 pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);
2698 if (pThumbnail != null)
2700 pThumbnail->SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
2701 pThumbnail->Scale(Dimension(W_THUMBNAIL, W_THUMBNAIL));
2702 pLabelThumbnail->SetBackgroundBitmap(*pThumbnail);
2704 pButtonAdd->SetShowState(false);
2705 pButtonAdd->SetEnabled(false);
2706 pButtonDelete->SetShowState(true);
2710 pThumbnail = ResourceManager::GetBitmapN(IDB_THUMBNAIL_BACKGROUND);
2711 if (pThumbnail != null)
2713 pLabelThumbnail->SetBackgroundBitmap(*pThumbnail);
2714 pButtonAdd->SetShowState(true);
2715 pButtonAdd->SetEnabled(true);
2716 pButtonDelete->SetShowState(false);
2724 ContactEditorForm::AddHorizontalDivider(Tizen::Ui::Controls::TableViewItem* pItem, int positionY, int width)
2726 Label* pDivider = new (std::nothrow) Label();
2727 pDivider->Construct(Rectangle(0, positionY, width, H_DIVIDER), L"");
2728 pDivider->SetBackgroundColor(Color(COLOR_DIVIDER));
2729 pDivider->SetEnabled(false);
2731 pItem->AddControl(pDivider);
2735 ContactEditorForm::AddVerticalDivider(Tizen::Ui::Controls::TableViewItem* pItem, int positionX, int positionY)
2737 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2739 Label* pDivider = new (std::nothrow) Label();
2740 pDivider->Construct(Rectangle(positionX, positionY, W_DIVIDER, pContactsApp->GetListItemSingleLineHeight()), L"");
2741 pDivider->SetBackgroundColor(Color(COLOR_DIVIDER));
2742 pDivider->SetEnabled(false);
2744 pItem->AddControl(pDivider);
2748 ContactEditorForm::SetAsDefaultPhoneNumber(int index, bool scrollToItem)
2750 result r = E_SUCCESS;
2751 TableViewItem* pItem = null;
2752 EditField* pEditField = null;
2754 pItem = static_cast<TableViewItem *>(__pPhoneNumberFieldItem->GetAt(index));
2761 pEditField = static_cast<EditField *>(pItem->GetControl(0));
2762 if (pEditField == null)
2768 __pPresentationModel->SetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER, L"", index);
2770 if (pEditField->IsVisible() == false && scrollToItem == true)
2772 __pTableView->ScrollToItem(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX, index);
2774 pEditField->Invalidate(true);
2781 ContactEditorForm::ChangeNameFieldStatus(void)
2783 result r = E_SUCCESS;
2785 r = SaveNameFields();
2787 __isExpandable = (__isExpandable == true) ? false : true;
2793 ContactEditorForm::SaveContactData(bool isSaved)
2795 result r = E_SUCCESS;
2797 if (isSaved == true)
2799 if (CommonUtil::isMemoryAvailable() == false)
2801 CommonUtil::showMemoryFullMessageBox();
2806 r = SaveNameFields();
2808 for (int i = 0; i < __pPhoneNumberFieldItem->GetCount(); i++)
2811 TableViewItem* pItem = static_cast<TableViewItem *>(__pPhoneNumberFieldItem->GetAt(i));
2818 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
2819 if (pEditField == null)
2825 String phoneNumberString(pEditField->GetText());
2826 String phoneNumberTypeString(pItem->GetName());
2827 int phoneNumberType;
2828 phoneNumberString.Trim();
2831 for (int i = 0; i < phoneNumberString.GetLength(); i++)
2833 phoneNumberString.GetCharAt(i, ch);
2835 if(ch == '+' && i == 0)
2839 if((ch == ',' || ch == ';' || ch == 'p') && i == 0)
2844 else if ((ch < '0' || ch > '9') && (ch != '*') && (ch != '#') && (ch != ',') && (ch != ';') && (ch != 'p'))
2855 if (isSaved == true && phoneNumberString.GetLength() > 0 && r != E_SUCCESS)
2858 MessageBox invalidNumberMessage;
2859 invalidNumberMessage.Construct(L"", ResourceManager::GetString(L"IDS_PB_BODY_INVALID_NUMBER"), MSGBOX_STYLE_OK, MESSAGE_BOX_TIMEOUT_MS);
2860 invalidNumberMessage.ShowAndWait(modalResult);
2865 Integer::Parse(phoneNumberTypeString, phoneNumberType);
2867 __pPresentationModel->SetPhoneNumber((DetailPhoneNumberType)phoneNumberType, phoneNumberString, i);
2870 for (int i = 0; i < __pEmailFieldItem->GetCount(); i++)
2872 TableViewItem* pItem = static_cast<TableViewItem *>(__pEmailFieldItem->GetAt(i));
2879 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
2880 if (pEditField == null)
2886 String emailString(pEditField->GetText());
2887 String remainingString;
2888 String emailTypeString(pItem->GetName());
2892 Integer::Parse(emailTypeString, emailType);
2894 r = __pPresentationModel->SetEmail((DetailEmailType)emailType, emailString, i);
2896 if (isSaved == true && r == E_SUCCESS)
2898 if(emailString.GetLength() > 0)
2900 bool isValidEmail = ValidateEmailAddress(emailString);
2901 if (isValidEmail != true)
2904 MessageBox invalidEmailMessage;
2905 invalidEmailMessage.Construct(L"", ResourceManager::GetString(L"IDS_PB_POP_INVALID_EMAIL_ADDRESS"), MSGBOX_STYLE_OK, MESSAGE_BOX_TIMEOUT_MS);
2906 invalidEmailMessage.ShowAndWait(modalResult);
2907 pEditField->ShowKeypad();
2915 for (int i = 0; i < __pAddressFieldItem->GetCount(); i++)
2917 TableViewItem* pItem = static_cast<TableViewItem *>(__pAddressFieldItem->GetAt(i));
2924 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
2925 if (pEditField == null)
2931 String addressString(pEditField->GetText());
2932 String addressTypeString(pItem->GetName());
2935 addressString.Trim();
2936 Integer::Parse(addressTypeString, addressType);
2938 __pPresentationModel->SetAddress((DetailAddressType)addressType, addressString, i);
2941 for (int i = 0; i < __pImAddressFieldItem->GetCount(); i++)
2943 TableViewItem* pItem = static_cast<TableViewItem *>(__pImAddressFieldItem->GetAt(i));
2950 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
2951 if (pEditField == null)
2957 String addressString(pEditField->GetText());
2958 String addressTypeString(pItem->GetName());
2961 addressString.Trim();
2962 Integer::Parse(addressTypeString, addressType);
2964 __pPresentationModel->SetImAddress((DetailImAddressType)addressType, addressString, i);
2967 for (int i = 0; i < __pUrlFieldItem->GetCount(); i++)
2969 TableViewItem* pItem = static_cast<TableViewItem *>(__pUrlFieldItem->GetAt(i));
2976 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
2977 if (pEditField == null)
2983 String urlString(pEditField->GetText());
2984 String urlTypeString(pItem->GetName());
2988 Integer::Parse(urlTypeString, urlType);
2990 __pPresentationModel->SetUrl((DetailUrlType)urlType, urlString, i);
2993 if (__pNoteFieldItem != null)
2996 ExpandableEditArea* pNoteEditArea = static_cast<ExpandableEditArea *>(__pNoteFieldItem->GetControl(1));
2997 if (pNoteEditArea != null)
2999 noteString.Append(pNoteEditArea->GetText());
3002 __pPresentationModel->SetValue(DETAIL_PROPERTY_NOTE, noteString);
3005 if (isSaved == true)
3007 r = __pPresentationModel->AddAddressBook();
3013 ContactEditorForm::SaveNameFields(void)
3015 result r = E_SUCCESS;
3017 if (__pNameFieldItem == null)
3022 if (__isExpandable == true)
3024 EditField* pFirstName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_FIRST_NAME"), false));
3025 if (pFirstName == null)
3029 __pPresentationModel->SetValue(DETAIL_PROPERTY_FIRST_NAME, pFirstName->GetText());
3031 EditField* pLastName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_LAST_NAME"), false));
3032 if (pLastName == null)
3037 __pPresentationModel->SetValue(DETAIL_PROPERTY_LAST_NAME, pLastName->GetText());
3039 EditField* pMiddleName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_MIDDLE_NAME"), false));
3040 if (pMiddleName == null)
3044 __pPresentationModel->SetValue(DETAIL_PROPERTY_MIDDLE_NAME, pMiddleName->GetText());
3046 EditField* pSuffix = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_SUFFIX"), false));
3047 if (pSuffix == null)
3051 __pPresentationModel->SetValue(DETAIL_PROPERTY_NAME_SUFFIX, pSuffix->GetText());
3053 EditField* pNickName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_NICKNAME"), false));
3054 if (pNickName == null)
3058 __pPresentationModel->SetValue(DETAIL_PROPERTY_NICK_NAME, pNickName->GetText());
3060 EditField* pCompanyName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_COMPANY"), false));
3061 if (pCompanyName == null)
3065 __pPresentationModel->SetValue(DETAIL_PROPERTY_COMPANY, pCompanyName->GetText());
3067 if (__isJobTitleEnabled == true)
3069 EditField* pJobTitle = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_JOB_TITLE"), false));
3070 if (pJobTitle == null)
3074 __pPresentationModel->SetValue(DETAIL_PROPERTY_JOB_TITLE, pJobTitle->GetText());
3077 if (__isDepartmentEnabled == true)
3079 EditField* pDepartment = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_DEPARTMENT"), false));
3080 if (pDepartment == null)
3084 __pPresentationModel->SetValue(DETAIL_PROPERTY_DEPARTMENT, pDepartment->GetText());
3089 EditField* pName = static_cast<EditField *>(__pNameFieldItem->GetControl(Integer::ToString(IDA_INPUT_FIELD_DISPLAY_NAME), false));
3095 int delimeterIndex = -1;
3096 int delimcommaIndex = -1;
3098 String displayName(pName->GetText());
3099 if (displayName != __fullName)
3107 if (!displayName.IsEmpty())
3109 displayName.IndexOf(DELIMITER_COMMA, 0, delimcommaIndex);
3110 if (delimcommaIndex >= 0)
3112 displayName.SubString(delimcommaIndex + 1, displayName.GetLength() - (delimcommaIndex + 1), suffix);
3113 displayName.SetLength(delimcommaIndex);
3117 if (!displayName.IsEmpty())
3119 delimeterIndex = -1;
3120 displayName.IndexOf(CHARACTER_SPACE, 0, delimeterIndex);
3121 if (delimeterIndex < 0)
3123 firstName.Append(displayName);
3127 displayName.SubString(0, delimeterIndex++, firstName);
3128 displayName.SubString(delimeterIndex, displayName.GetLength() - delimeterIndex, displayName);
3130 delimeterIndex = -1;
3133 if (!displayName.IsEmpty())
3135 displayName.IndexOf(CHARACTER_SPACE, 0, delimeterIndex);
3136 if (delimeterIndex < 0)
3138 lastName.Append(displayName);
3142 displayName.SubString(0, delimeterIndex, middleName);
3143 displayName.SubString(delimeterIndex + 1, displayName.GetLength() - (delimeterIndex + 1), lastName);
3149 __pPresentationModel->SetValue(DETAIL_PROPERTY_FIRST_NAME, firstName);
3150 __pPresentationModel->SetValue(DETAIL_PROPERTY_MIDDLE_NAME, middleName);
3151 __pPresentationModel->SetValue(DETAIL_PROPERTY_LAST_NAME, lastName);
3152 __pPresentationModel->SetValue(DETAIL_PROPERTY_NAME_SUFFIX, suffix);
3160 ContactEditorForm::IsSaveContactValid(void)
3162 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_FIRST_NAME).IsEmpty() == false)
3167 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_LAST_NAME).IsEmpty() == false)
3172 for (int i = 0; i < __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER); i++)
3174 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, i).IsEmpty() == false)
3180 for (int i = 0; i < __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL); i++)
3182 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_EMAIL, i).IsEmpty() == false)
3192 ContactEditorForm::SetSaveButtonEnabled(bool enable)
3194 Footer* pFooter = GetFooter();
3198 pFooter->SetItemEnabled(0, true);
3202 pFooter->SetItemEnabled(0, false);
3205 pFooter->Invalidate(true);
3209 ContactEditorForm::IsMoreInformationButtonVisible(void)
3211 if (__isJobTitleEnabled == false)
3216 if (__isDepartmentEnabled == false)
3221 if (__pImAddressFieldItem->GetCount() == 0)
3226 if (__pUrlFieldItem->GetCount() == 0)
3232 if (__pPresentationModel->GetBirthday(birthday) != E_SUCCESS)
3237 if (__pNoteFieldItem == null)
3246 ContactEditorForm::OnTextValueChanged(const Tizen::Ui::Control& source)
3248 TableViewItem* pTableViewItem = static_cast<TableViewItem *>(source.GetParent());
3250 __isContactModified = true;
3252 if (pTableViewItem == null)
3257 SaveContactData(false);
3258 SetSaveButtonEnabled(IsSaveContactValid());
3260 if (__pNameFieldItem == pTableViewItem)
3265 EditField* pEditField = const_cast<EditField *>(static_cast<const EditField *>(&source));
3266 if (pEditField == null)
3271 Control* pDeleteButton = pTableViewItem->GetControl(2);
3272 if (pDeleteButton == null)
3282 Integer::Decode(pEditField->GetName(), index);
3283 groupIndex = (index & TABLE_VIEW_GROUP_INDEX_MASK) >> TABLE_VIEW_GROUP_INDEX_SHIFT;
3284 inputFlag = (index & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3285 int itemIndex = (index & TABLE_VIEW_ITEM_INDEX_MASK);
3286 itemCount = __pTableView->GetItemCountAt(groupIndex);
3288 String trimmedString = pEditField->GetText();
3289 trimmedString.Trim();
3291 if (trimmedString.IsEmpty())
3293 pDeleteButton->SetShowState(false);
3294 __previousItemIndex = itemIndex; //if the entered text is empty store the index of the field for deletion
3295 __previousGroupIndex = groupIndex;
3297 else if (pDeleteButton->GetShowState() == false)
3299 __previousItemIndex = -1;
3300 __previousGroupIndex = -1;
3301 pDeleteButton->SetShowState(true);
3304 index |= (1 << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT);
3305 pEditField->SetName(Integer::ToString(index));
3307 if (groupIndex == TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX)
3309 if (__isDefaultPhoneNumberButtonEnabled == false && __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) > 1)
3311 __isDefaultPhoneNumberButtonEnabled = true;
3312 __pTableView->RefreshItem(groupIndex, __pTableView->GetItemCountAt(groupIndex), TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
3314 else if (itemCount > 1)
3320 ArrayList* pFieldList = null;
3323 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
3325 pFieldList = __pPhoneNumberFieldItem;
3328 case TABLE_VIEW_EMAIL_FIELD_INDEX:
3330 pFieldList = __pEmailFieldItem;
3333 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
3335 pFieldList = __pAddressFieldItem;
3338 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
3340 pFieldList = __pImAddressFieldItem;
3343 case TABLE_VIEW_URL_FIELD_INDEX:
3345 pFieldList = __pUrlFieldItem;
3352 if (pFieldList != null)
3354 TableViewItem* pItem = static_cast<TableViewItem*>(pFieldList->GetAt(pFieldList->GetCount() - 1));
3357 EditField* pInputField = static_cast<EditField*>(pItem->GetControl(0));
3359 if (pInputField != null && pInputField->GetTextLength() != 0)
3361 __pTableView->RefreshItem(groupIndex, itemCount, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
3369 __previousItemIndex = -1;
3370 __previousGroupIndex = -1;
3372 if(__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) <= 1 && __isDefaultPhoneNumberButtonEnabled == true)
3374 __isDefaultPhoneNumberButtonEnabled = false;
3375 __pTableView->RefreshItem(groupIndex, __pTableView->GetItemCountAt(groupIndex) - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
3377 else if(__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) > 1 && __isDefaultPhoneNumberButtonEnabled == false)
3379 __isDefaultPhoneNumberButtonEnabled = true;
3380 __pTableView->RefreshItem(groupIndex, __pTableView->GetItemCountAt(groupIndex), TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
3385 ContactEditorForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
3390 ContactEditorForm::ParseAppControlArgument(const Tizen::Base::String& argument, Tizen::Base::String& type, Tizen::Base::String& content)
3392 result r = E_SUCCESS;
3394 if (argument.IsEmpty() || argument.Contains(DELIMITER) == false)
3401 argument.IndexOf(DELIMITER, 0, delimiterIndex);
3402 argument.SubString(0, delimiterIndex++, type);
3403 TryReturn(r == E_SUCCESS, r, "[%s] Unable to get type", GetErrorMessage(r));
3404 argument.SubString(delimiterIndex, argument.GetLength() - delimiterIndex, content);
3405 TryReturn(r == E_SUCCESS, r, "[%s] Unable to get type", GetErrorMessage(r));
3411 ContactEditorForm::OnFocusGained(const Tizen::Ui::Control& source)
3413 __pCurrentFocusedItem = source.GetParent();
3415 if (__previousItemIndex != -1 && __previousGroupIndex != -1)
3417 const EditField* pEditField = static_cast<const EditField*>(&source);
3418 if (pEditField == null)
3427 Integer::Decode(pEditField->GetName(), index);
3428 groupIndex = (index & TABLE_VIEW_GROUP_INDEX_MASK) >> TABLE_VIEW_GROUP_INDEX_SHIFT;
3429 itemIndex = (index & TABLE_VIEW_ITEM_INDEX_MASK);
3431 if (groupIndex == __previousGroupIndex && itemIndex == __previousItemIndex)
3433 //Same item is focused. Hence not deleting it
3437 DeleteInputField(__previousGroupIndex, __previousItemIndex);
3443 ContactEditorForm::OnFocusLost(const Tizen::Ui::Control& source)
3445 if (__pCurrentFocusedItem == __pNameFieldItem)
3450 __pCurrentFocusedItem = null;
3454 ContactEditorForm::ShowDefaultPhoneNumberContextMenu(const Tizen::Graphics::Point& position)
3456 if (__pDefaultPhoneNumberContextMenu != null)
3458 delete __pDefaultPhoneNumberContextMenu;
3459 __pDefaultPhoneNumberContextMenu = null;
3462 __pDefaultPhoneNumberContextMenu = new (std::nothrow) ContextMenu();
3463 __pDefaultPhoneNumberContextMenu->Construct(position, CONTEXT_MENU_STYLE_LIST);
3464 __pDefaultPhoneNumberContextMenu->AddActionEventListener(*this);
3465 __pDefaultPhoneNumberContextMenu->SetFocusable(true);
3467 int count = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
3468 int defaultPhoneNumberIndex = __pPresentationModel->GetDefaultNumberIndex();
3470 for (int i = 0; i < count; i++)
3472 String phoneNumber(__pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, i));
3474 if (i != defaultPhoneNumberIndex)
3476 phoneNumber.Insert(__pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, i) + CHARACTER_SPACE, 0);
3477 __pDefaultPhoneNumberContextMenu->AddItem(phoneNumber, i);
3481 if (__pDefaultPhoneNumberContextMenu->GetItemCount() > 0)
3483 __pDefaultPhoneNumberContextMenu->Show();
3488 ContactEditorForm::ShowMoreInformationContextMenu(const Tizen::Graphics::Point& position)
3490 if (__pMoreInformationContextMenu != null)
3492 delete __pMoreInformationContextMenu;
3493 __pMoreInformationContextMenu = null;
3496 __pMoreInformationContextMenu = new (std::nothrow) ContextMenu();
3497 __pMoreInformationContextMenu->Construct(position, CONTEXT_MENU_STYLE_LIST);
3499 __pMoreInformationContextMenu->SetMaxVisibleItemsCount(6);
3500 __pMoreInformationContextMenu->AddActionEventListener(*this);
3501 __pMoreInformationContextMenu->SetFocusable(true);
3503 if (__isJobTitleEnabled == false)
3505 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_JOB_TITLE"), IDA_CONTEXT_MENU_ITEM_JOB_TITLE);
3508 if (__isDepartmentEnabled == false)
3510 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_DEPARTMENT"), IDA_CONTEXT_MENU_ITEM_DEPARTMENT);
3513 if (__pImAddressFieldItem->GetCount() == 0)
3515 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_HEADER_INSTANT_MESSENGER_ABB"), IDA_CONTEXT_MENU_ITEM_INSTANT_MESSENGER);
3518 if (__pUrlFieldItem->GetCount() == 0)
3520 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_URL"), IDA_CONTEXT_MENU_ITEM_URL);
3524 if (__pPresentationModel->GetBirthday(birthday) != E_SUCCESS)
3526 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_BIRTHDAY"), IDA_CONTEXT_MENU_ITEM_BIRTHDAY);
3529 if (__pNoteFieldItem == null)
3531 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_NOTE"), IDA_CONTEXT_MENU_ITEM_NOTE);
3534 if (__isMoreInformationContextMenuShowing == false)
3536 __pMoreInformationContextMenu->Show();
3541 ContactEditorForm::ShowTypeContextMenu(int currentType, const Tizen::Graphics::Point& position, int itemTag)
3543 int groupIndex = (itemTag & TABLE_VIEW_GROUP_INDEX_MASK) >> TABLE_VIEW_GROUP_INDEX_SHIFT;
3545 __groupIndex = groupIndex;
3546 __itemIndex = itemTag;
3548 if (__isKeypadOpened)
3550 __isTypeContextMenuShowing = true;
3553 if (__pTypeContextMenu != null)
3555 delete __pTypeContextMenu;
3556 __pTypeContextMenu = null;
3559 __pTypeContextMenu = new (std::nothrow) ContextMenu();
3560 __pTypeContextMenu->Construct(position, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_LEFTWARD);
3561 __pTypeContextMenu->AddActionEventListener(*this);
3562 __pTypeContextMenu->SetFocusable(true);
3566 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
3568 __pTypeContextMenu->SetMaxVisibleItemsCount(DETAIL_PHONENUMBER_TYPE_OTHER + 1);
3569 for (int i = 0; i <= DETAIL_PHONENUMBER_TYPE_OTHER; i++)
3571 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3572 __pTypeContextMenu->AddItem(__pPresentationModel->GetPhoneNumberTypeString((DetailPhoneNumberType)i), itemTag | index);
3576 case TABLE_VIEW_EMAIL_FIELD_INDEX:
3578 __pTypeContextMenu->SetMaxVisibleItemsCount(DETAIL_EMAIL_TYPE_OTHER + 1);
3579 for (int i = 0; i <= DETAIL_EMAIL_TYPE_OTHER; i++)
3581 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3582 __pTypeContextMenu->AddItem(__pPresentationModel->GetAddressTypeString((DetailAddressType)i), itemTag | index);
3586 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
3588 __pTypeContextMenu->SetMaxVisibleItemsCount(DETAIL_ADDRESS_TYPE_OTHER + 1);
3589 for (int i = 0; i <= DETAIL_ADDRESS_TYPE_OTHER; i++)
3591 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3592 __pTypeContextMenu->AddItem(__pPresentationModel->GetAddressTypeString((DetailAddressType)i), itemTag | index);
3596 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
3598 __pTypeContextMenu->SetMaxVisibleItemsCount(7); // Temporary the code due to limit max count(8) by UI framework.
3599 for (int i = 0; i <= DETAIL_IM_ADDRESS_TYPE_OTHER; i++)
3601 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3602 __pTypeContextMenu->AddItem(__pPresentationModel->GetImAddressTypeString((DetailImAddressType)i), itemTag | index);
3606 case TABLE_VIEW_URL_FIELD_INDEX:
3608 __pTypeContextMenu->SetMaxVisibleItemsCount(DETAIL_URL_TYPE_OTHER + 1);
3609 for (int i = 0; i <= DETAIL_URL_TYPE_OTHER; i++)
3611 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3612 __pTypeContextMenu->AddItem(__pPresentationModel->GetUrlTypeString((DetailUrlType)i), itemTag | index);
3618 __isTypeContextMenuShowing = false;
3621 delete __pTypeContextMenu;
3622 __pTypeContextMenu = null;
3627 if (__pTypeContextMenu != null)
3629 __pTypeContextMenu->RemoveItemAt(currentType);
3630 __pTypeContextMenu->Show();
3635 ContactEditorForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3637 __isScrollOccurred = false;
3639 Panel* pPanel = null;
3641 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
3643 pPanel = static_cast<Panel*>(&(const_cast<Control&>(source)));
3645 else if (source.GetName().Equals(GROUP_LABEL_TITLE, true) || source.GetName().Equals(GROUP_LABEL_VALUE, true))
3647 pPanel = static_cast<Panel*>(source.GetParent());
3652 pPanel->SetBackgroundColor(COLOR_PRESSED);
3654 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_VALUE, true));
3655 pLabelValue->SetTextColor(Color(COLOR_ITEM_PRESSED));
3657 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_TITLE, true));
3658 pLabelTitle->SetTextColor(COLOR_ITEM_PRESSED);
3660 pPanel->Invalidate(true);
3665 ContactEditorForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3667 Panel* pPanel = null;
3669 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
3671 pPanel = static_cast<Panel*>(&(const_cast<Control&>(source)));
3673 else if (source.GetName().Equals(GROUP_LABEL_TITLE, true) || source.GetName().Equals(GROUP_LABEL_VALUE, true))
3675 pPanel = static_cast<Panel*>(source.GetParent());
3680 pPanel->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
3682 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_VALUE, true));
3683 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
3685 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_TITLE, true));
3686 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
3688 pPanel->Invalidate(true);
3691 if (__isScrollOccurred || source.Contains(currentPosition) == false)
3698 ContactEditorForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3700 Panel* pPanel = null;
3702 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
3704 pPanel = static_cast<Panel*>(&(const_cast<Control&>(source)));
3706 else if (source.GetName().Equals(GROUP_LABEL_TITLE, true) || source.GetName().Equals(GROUP_LABEL_VALUE, true))
3708 pPanel = static_cast<Panel*>(source.GetParent());
3713 pPanel->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
3715 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_VALUE, true));
3716 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
3718 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_TITLE, true));
3719 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
3721 pPanel->Invalidate(true);
3726 ContactEditorForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
3728 if (keyCode == KEY_ENTER )
3730 TableViewItem* pItem = static_cast<TableViewItem*>(&(const_cast<Control&>(source)));
3732 Panel* pPanel = static_cast<Panel*>(pItem->GetControl(0));
3739 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(1));
3741 if (pLabelValue == null)
3746 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(0));
3748 if (pLabelTitle == null)
3753 pPanel->SetBackgroundColor(COLOR_PRESSED);
3754 pLabelValue->SetTextColor(Color(COLOR_ITEM_PRESSED));
3755 pLabelTitle->SetTextColor(COLOR_ITEM_PRESSED);
3756 pPanel->Invalidate(true);
3761 ContactEditorForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
3763 if (keyCode == KEY_ENTER )
3766 TableViewItem* pItem = static_cast<TableViewItem*>(&(const_cast<Control&>(source)));
3768 Panel* pPanel = static_cast<Panel*>(pItem->GetControl(0));
3775 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(1));
3777 if (pLabelValue == null)
3782 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(0));
3784 if (pLabelTitle == null)
3789 pPanel->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
3790 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
3791 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
3792 pPanel->Invalidate(true);
3797 ContactEditorForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
3803 ContactEditorForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3808 ContactEditorForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3813 ContactEditorForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3815 Panel* pPanel = null;
3817 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
3819 pPanel = static_cast<Panel*>(&(const_cast<Control&>(source)));
3821 else if (source.GetName().Equals(GROUP_LABEL_TITLE, true) || source.GetName().Equals(GROUP_LABEL_VALUE, true))
3823 pPanel = static_cast<Panel*>(source.GetParent());
3828 pPanel->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
3830 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_VALUE, true));
3831 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
3833 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_TITLE, true));
3834 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
3836 pPanel->Invalidate(true);
3839 if (__isScrollOccurred || source.Contains(currentPosition) == false)
3846 ContactEditorForm::OnScrollEndReached (Tizen::Ui::Control &source, Tizen::Ui::Controls::ScrollEndEvent type)
3851 ContactEditorForm::OnScrollPositionChanged (Tizen::Ui::Control &source, int scrollPos)
3853 int scrollDif = scrollPos - __scrolledDistance;
3854 if (__isTypeContextMenuShowing)
3856 Point anchorPosition = __pTypeContextMenu->GetAnchorPosition();
3858 anchorPosition.y -= scrollDif;
3859 __pTypeContextMenu->SetAnchorPosition(anchorPosition);
3860 __pTypeContextMenu->Show();
3862 __isTypeContextMenuShowing = false;
3866 if (__pDefaultPhoneNumberContextMenu != null)
3868 Point anchorPosition = __pDefaultPhoneNumberContextMenu->GetAnchorPosition();
3870 anchorPosition.y -= scrollDif;
3871 __pDefaultPhoneNumberContextMenu->SetAnchorPosition(anchorPosition);
3872 __pDefaultPhoneNumberContextMenu->Show();
3875 __scrolledDistance = scrollPos;
3876 __origScrolledDistance = scrollPos;
3878 if (__isScrollOccurred == false)
3880 __isScrollOccurred = true;
3885 ContactEditorForm::OnScrollStopped (Tizen::Ui::Control &source)
3890 ContactEditorForm::OnExpandableEditAreaLineAdded (Tizen::Ui::Controls::ExpandableEditArea &source, int newLineCount)
3892 __pTableView->RefreshItem(TABLE_VIEW_NOTE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
3896 ContactEditorForm::OnExpandableEditAreaLineRemoved (Tizen::Ui::Controls::ExpandableEditArea &source, int newLineCount)
3898 __pTableView->RefreshItem(TABLE_VIEW_NOTE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
3902 ContactEditorForm::OnDateChanged(const Tizen::Ui::Control& source, int year, int month, int day)
3904 DateTime changedDate;
3906 changedDate.SetValue(year, month, day);
3907 __pPresentationModel->SetBirthday(changedDate);
3908 __isContactModified = true;
3912 ContactEditorForm::OnDateChangeCanceled(const Tizen::Ui::Control& source)
3917 ContactEditorForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
3919 AppLogDebug("ENTER");
3921 if (__pAppControl != null)
3923 delete __pAppControl;
3924 __pAppControl = null;
3927 TryReturnVoid(appControlResult == APP_CTRL_RESULT_SUCCEEDED, "[E_FAILURE] The result of an appcontrol is not succeeded.");
3928 TryReturnVoid(pExtraData != null, "[E_FAILURE] The extra data is null.");
3930 const String *pResultString = null;
3931 const ArrayList* pResultList = dynamic_cast<const ArrayList*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
3932 if (pResultList != null)
3934 pResultString = static_cast<const String*>(pResultList->GetAt(0));
3938 pResultString = static_cast<const String*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
3940 TryReturnVoid(pResultString != null, "[E_FAILURE] Unable to get file path.");
3942 if (appId.Equals(String(PROVIDER_ID_CAMERA)) && operationId.Equals(String(OPERATION_ID_CREATE_CONTENT)))
3944 __pPresentationModel->SetThumbnail(*pResultString);
3945 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
3947 if (__pFileEventManager == null)
3949 __pFileEventManager = new (std::nothrow) FileEventManager();
3950 __pFileEventManager->Construct(*this);
3952 __pFileEventManager->AddPath(*pResultString, FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_DELETE_SELF | FILE_EVENT_TYPE_MODIFY | FILE_EVENT_TYPE_MOVE_SELF);
3953 __isContactModified = true;
3955 else if (appId.Equals(String(PROVIDER_ID_GALLERY)) && operationId.Equals(String(OPERATION_ID_PICK)))
3959 ImageFormat imageFormat;
3960 result r = ImageBuffer::GetImageInfo(*pResultString, imageFormat, width, height);
3962 if (appControlResult == APP_CTRL_RESULT_FAILED || r != E_SUCCESS)
3964 int modalResult = 0;
3965 MessageBox unsupportedMessageBox;
3966 unsupportedMessageBox.Construct(L"", ResourceManager::GetString(L"IDS_MP_POP_INVALID_FILE"), MSGBOX_STYLE_NONE, 3000);
3967 unsupportedMessageBox.ShowAndWait(modalResult);
3972 r = LaunchImageViewerAppControl(*pResultString);
3974 else if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
3976 __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, *pResultString);
3977 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
3979 if (__pFileEventManager == null)
3981 __pFileEventManager = new (std::nothrow) FileEventManager();
3982 __pFileEventManager->Construct(*this);
3984 __pFileEventManager->AddPath(*pResultString, FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_DELETE_SELF | FILE_EVENT_TYPE_MODIFY | FILE_EVENT_TYPE_MOVE_SELF);
3986 __isContactModified = true;
3988 else if(appId.Equals(String(PROVIDER_ID_IMAGEVIEWER)) && operationId.Equals(String(OPERATION_ID_CROP)))
3992 ImageFormat imageFormat;
3993 result r = ImageBuffer::GetImageInfo(*pResultString, imageFormat, width, height);
3995 if (appControlResult == APP_CTRL_RESULT_FAILED || r != E_SUCCESS)
3997 int modalResult = 0;
3998 MessageBox unsupportedMessageBox;
3999 unsupportedMessageBox.Construct(L"", ResourceManager::GetString(L"IDS_MP_POP_INVALID_FILE"), MSGBOX_STYLE_NONE, 3000);
4000 unsupportedMessageBox.ShowAndWait(modalResult);
4005 __pPresentationModel->SetThumbnail(*pResultString);
4006 AppLogDebug("pResultString is %ls", pResultString->GetPointer());
4007 __isContactModified = true;
4008 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4010 if (__pFileEventManager == null)
4012 __pFileEventManager = new (std::nothrow) FileEventManager();
4013 __pFileEventManager->Construct(*this);
4015 __pFileEventManager->AddPath(*pResultString, FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_DELETE_SELF | FILE_EVENT_TYPE_MODIFY | FILE_EVENT_TYPE_MOVE_SELF);
4018 AppLogDebug("EXIT");
4022 ContactEditorForm::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId)
4024 result r = E_SUCCESS;
4029 extraData.Construct();
4031 if (appId.Equals(String(PROVIDER_ID_CAMERA)) && operationId.Equals(String(OPERATION_ID_CREATE_CONTENT)))
4033 mimeType.Append(INPUT_MIME_TYPE_CAMERA);
4034 extraData.Add(new (std::nothrow) String(INPUT_KEY_ALLOW_SWITCH), new (std::nothrow) String(INPUT_VALUE_FALSE));
4036 else if (appId.Equals(String(PROVIDER_ID_GALLERY)) && operationId.Equals(String(OPERATION_ID_PICK)))
4038 mimeType.Append(INPUT_MIME_TYPE_GALLERY);
4039 extraData.Add(new (std::nothrow) String(INPUT_KEY_SELECTION_MODE), new (std::nothrow) String(INPUT_DATA_SELECTION_MODE_SINGLE));
4041 else if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
4043 mimeType.Append(INPUT_MIME_TYPE_AUDIO);
4044 extraData.Add(new (std::nothrow) String(INPUT_KEY_SELECTION_MODE), new (std::nothrow) String(INPUT_DATA_SELECTION_MODE_SINGLE));
4047 __pAppControl = AppManager::FindAppControlN(appId, operationId);
4049 if (__pAppControl != null)
4051 r = __pAppControl->Start(&uri, &mimeType, &extraData, this);
4052 TryCatch(r == E_SUCCESS, , "[%s] Unable to launch app control.", GetErrorMessage(r));
4057 extraData.RemoveAll(true);
4062 extraData.RemoveAll(true);
4063 delete __pAppControl;
4064 __pAppControl = null;
4070 ContactEditorForm::LaunchImageViewerAppControl(const Tizen::Base::String& filePath)
4072 result r = E_SUCCESS;
4075 extraData.Construct();
4076 extraData.Add(new (std::nothrow) String(INPUT_KEY_IMAGEVIEWER_MODE), new (std::nothrow) String(INPUT_VALUE_IMAGEVIEWER_TYPE));
4078 __pAppControl = AppManager::FindAppControlN(PROVIDER_ID_IMAGEVIEWER, OPERATION_ID_CROP);
4082 r = __pAppControl->Start(&filePath, null, &extraData, this);
4083 TryCatch(r == E_SUCCESS, , "[%s] Unable to launch app control.", GetErrorMessage(r));
4088 extraData.RemoveAll(true);
4093 extraData.RemoveAll(true);
4094 delete __pAppControl;
4095 __pAppControl = null;
4101 ContactEditorForm::OnContactsChanged(void)
4103 SceneManager* pSceneManager = SceneManager::GetInstance();
4104 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
4106 if (__isSaved == false)
4108 if (__pPresentationModel->IsContactRemoved())
4110 if (pContactsApp->GetOperationId() == OPERATION_ID_VIEW)
4112 __pPresentationModel->RemoveContactChangeListener(*this);
4116 if (__pAppControl != null)
4118 __pAppControl->Stop();
4120 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
4131 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
4132 HashMap* pReturnValue = new (std::nothrow) HashMap();
4133 pReturnValue->Construct();
4135 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), new (std::nothrow) String(Integer::ToString(__pPresentationModel->GetContactId())));
4137 result r = pAppManager->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
4138 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
4140 UiApp::GetInstance()->Terminate();
4144 ArrayList* pArg = null;
4146 if (__pPresentationModel->GetVcfPath().IsEmpty() == false)
4148 pArg = new (std::nothrow) ArrayList();
4151 String* pViewType = new (std::nothrow) String();
4152 String* pValueType = new (std::nothrow) String();
4154 pViewType->Append(VIEW_TYPE);
4155 pViewType->Append(DELIMITER);
4156 pViewType->Append(VIEW_TYPE_VALUE_CONTACT);
4158 pValueType->Append(VIEW_TYPE_CONTACT_ID);
4159 pValueType->Append(DELIMITER);
4160 pValueType->Append(Integer::ToString(__pPresentationModel->GetContactId()));
4162 pArg->Add(pViewType);
4163 pArg->Add(pValueType);
4165 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), pArg);
4172 ContactEditorForm::OnCategoriesChanged(void)
4174 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4178 ContactEditorForm::OnForeground(void)
4183 ContactEditorForm::OnBackground(void)
4185 if (__previousItemIndex != -1 && __previousGroupIndex != -1)
4187 DeleteInputField(__previousGroupIndex, __previousItemIndex);
4189 if (IsEnabled() == false)
4197 ContactEditorForm::OnFileEventOccured(const unsigned long events, const Tizen::Base::String &path, const unsigned int eventId)
4199 String thumbnailPath = __pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL);
4200 if (thumbnailPath.Equals(path, false) == true)
4202 __pPresentationModel->SetThumbnail(L"");
4203 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4207 String ringtonePath = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
4208 if (ringtonePath.Equals(ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT"), false) == true )
4210 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4216 ContactEditorForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String &state)
4218 if (deviceType != DEVICE_TYPE_STORAGE_CARD || __pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL).IsEmpty())
4223 if (state.Equals(SD_CARD_UNMOUNTED, false) && File::IsFileExist(__pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL)) == false)
4225 __pPresentationModel->SetThumbnail(L"");
4226 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4230 bool ContactEditorForm::ValidateEmailAddress(const Tizen::Base::String& emailAddress)
4234 const wchar_t* tmpChar;
4235 const wchar_t* tmpDomain;
4236 String splChars = L"([<@,;\\:\">])";
4238 for (tmpChar = emailAddress.GetPointer(), index=0; index < emailAddress.GetLength(); tmpChar++, index++)
4240 if (*tmpChar == '\"' && (tmpChar == emailAddress.GetPointer() || *(tmpChar-1) == '.' || *(tmpChar-1) == '\"'))
4244 if (*tmpChar == '\"')
4248 if (*tmpChar == '\\' && (*++tmpChar == ' '))
4252 if (*tmpChar <= ' ' || *tmpChar >= 127)
4261 if (*tmpChar == '@')
4265 if (*tmpChar != '.')
4271 if (*tmpChar == '@')
4275 if (*tmpChar <= ' ' || *tmpChar >= 127)
4279 if (splChars.IndexOf(*tmpChar, 0, index) != E_OBJ_NOT_FOUND)
4284 if (tmpChar == emailAddress.GetPointer() || *(tmpChar-1) == '.')
4289 if (!*(tmpDomain = ++tmpChar))
4295 if (*tmpChar == '.')
4297 if (tmpChar == tmpDomain || *(tmpChar-1) == '.')
4303 if (*tmpChar <= ' ' || *tmpChar >= 127)
4307 if (splChars.IndexOf(*tmpChar, 0, index) != E_OBJ_NOT_FOUND)
4311 } while (*++tmpChar);
4313 if (*(tmpChar-1) == '.')
4327 ContactEditorForm::OnSettingChanged(Tizen::Base::String &key)
4329 if(key == L"http://tizen.org/setting/locale.date_time")
4332 __pPresentationModel->GetBirthday(bday);
4334 DateTime currentDate;
4335 Tizen::System::SystemTime::GetCurrentTime(currentDate);
4337 if(bday > currentDate)
4339 __pPresentationModel->SetBirthday(currentDate);
4340 __pTableView->RefreshItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4346 ContactEditorForm::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
4352 ContactEditorForm::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
4354 if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
4356 if (__pDiscardChangesPopup && __pDiscardChangesPopup->GetShowState() == true)
4358 HideDiscardChangesPopup();
4366 ContactEditorForm::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
4372 ContactEditorForm::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
4378 ContactEditorForm::ShowDiscardChangesPopup(void)
4380 if (__pDiscardChangesPopup == null)
4382 __pDiscardChangesPopup = new (std::nothrow) Popup();
4383 __pDiscardChangesPopup->Construct(false, Dimension(W_SAVE_POPUP, H_SAVE_POPUP));
4384 __pDiscardChangesPopup->SetPropagatedKeyEventListener(this);
4386 Rectangle popupClientBounds = __pDiscardChangesPopup->GetClientAreaBounds();
4388 Label* pLabel = new (std::nothrow) Label();
4389 pLabel->Construct(Rectangle(X_SAVE_LABEL, Y_SAVE_LABEL, W_SAVE_LABEL, H_SAVE_LABEL), ResourceManager::GetString(L"IDS_PB_POP_DISCARD_CHANGES_Q"));
4390 pLabel->SetTextConfig(FONT_SIZE_SAVE_CONFIRM, LABEL_TEXT_STYLE_NORMAL);
4391 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
4392 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
4394 Button* pSaveButton = new (std::nothrow) Button();
4395 pSaveButton->Construct(Rectangle(X_SAVE_LABEL + W_SAVE_BUTTON + W_POPUP_ITEM_GAP, Y_SAVE_BUTTON, W_SAVE_BUTTON, H_SAVE_BUTTON), ResourceManager::GetString(L"IDS_COM_SK_OK"));
4396 pSaveButton->SetTextSize(FONT_SIZE_SAVE_BUTTON);
4397 pSaveButton->SetActionId(IDA_POPUP_DISCARD_CHANGES_OK);
4398 pSaveButton->AddActionEventListener(*this);
4400 Button* pCancelButton = new (std::nothrow) Button();
4401 pCancelButton->Construct(Rectangle(X_SAVE_LABEL, Y_SAVE_BUTTON, W_SAVE_BUTTON, H_SAVE_BUTTON), ResourceManager::GetString(L"IDS_PB_SK_CANCEL"));
4402 pCancelButton->SetTextSize(FONT_SIZE_SAVE_BUTTON);
4403 pCancelButton->SetActionId(IDA_POPUP_DISCARD_CHANGES_CANCEL);
4404 pCancelButton->AddActionEventListener(*this);
4406 __pDiscardChangesPopup->AddControl(pLabel);
4407 __pDiscardChangesPopup->AddControl(pSaveButton);
4408 __pDiscardChangesPopup->AddControl(pCancelButton);
4411 __pDiscardChangesPopup->SetShowState(true);
4412 __pDiscardChangesPopup->Show();
4416 ContactEditorForm::HideDiscardChangesPopup(void)
4418 __pDiscardChangesPopup->SetShowState(false);