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;
127 static const int H_EXPANDABLE_EDIT_AREA_EXTENDED = 8;
129 static const int X_MORE_INFO_PANEL_GAP = 5;
130 static const int H_MORE_INFO_PANEL_GAP = 10;
132 static const int FONT_SIZE_TITLE_TEXT = 32;
134 static const int GROUP_ITEM_COUNT = 11;
135 static const int NAME_FIELD_ITEM_COUNT = 1;
137 static const int EDIT_FIELD_EXTENDED_LENGTH = 100;
139 static const int MESSAGE_BOX_TIMEOUT_MS = 300000;
141 static const int DEFAULT_EXPAND_NAME_FIELD_COUNT = 6;
143 static const wchar_t* EXPAND_BUTTON = L"ExpandButton";
145 static const unsigned int COLOR_TABLE_VIEW_BG = Color32<248, 246, 239>::Value;
146 static const unsigned int COLOR_DIVIDER = Color32<169, 169, 169>::Value;
147 static const unsigned int COLOR_THUMBNAIL_BACKGROUND = Color32<239, 237, 229>::Value;
148 static const unsigned int COLOR_ITEM_TITLE = Color32<128, 128, 128>::Value;
149 static const unsigned int COLOR_ITEM_VALUE = Color32<0, 0, 0>::Value;
150 static const unsigned int COLOR_ITEM_PRESSED = Color32<248, 246, 239>::Value;
151 static const unsigned int COLOR_PRESSED = Color32<87, 135, 194>::Value;
153 static const int TABLE_VIEW_DELETE_INPUT_FIELD_ID = 0xE0000000;
154 static const int TABLE_VIEW_INPUT_FIELD_ACTION_MASK = 0xF0000000;
155 static const int TABLE_VIEW_INPUT_FIELD_INDEX_MASK = 0x0F000000;
156 static const int TABLE_VIEW_GROUP_INDEX_MASK = 0x00FF0000;
157 static const int TABLE_VIEW_ITEM_INDEX_MASK = 0x0000FFFF;
158 static const int TABLE_VIEW_GROUP_INDEX_SHIFT = 16;
159 static const int TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT = 24;
160 static const int TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT = 28;
161 static const int TABLE_VIEW_THUMBNAIL_FIELD_INDEX = 0;
162 static const int TABLE_VIEW_NAME_FIELD_INDEX = 1;
163 static const int TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX = 2;
164 static const int TABLE_VIEW_EMAIL_FIELD_INDEX = 3;
165 static const int TABLE_VIEW_ADDRESS_FIELD_INDEX = 4;
166 static const int TABLE_VIEW_IM_ADDRESS_FIELD_INDEX = 5;
167 static const int TABLE_VIEW_URL_FIELD_INDEX = 6;
168 static const int TABLE_VIEW_BIRTHDAY_FIELD_INDEX = 7;
169 static const int TABLE_VIEW_NOTE_FIELD_INDEX = 8;
170 static const int TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX = 9;
171 static const int TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX = 10;
173 static const wchar_t* INPUT_TYPE_PHONE = L"phone";
174 static const wchar_t* INPUT_TYPE_EMAIL = L"email";
175 static const wchar_t* INPUT_TYPE_URL = L"url";
176 static const wchar_t* VIEW_TYPE = L"viewType";
177 static const wchar_t* VIEW_TYPE_VALUE_CONTACT = L"contact";
178 static const wchar_t* VIEW_TYPE_CONTACT_ID = L"contactId";
179 static const wchar_t* GROUP_LABEL_TITLE = L"GroupLabelTitle";
180 static const wchar_t* GROUP_LABEL_VALUE = L"GroupLabelValue";
181 static const wchar_t* GROUP_STYLE_PANEL = L"GroupStylePanel";
183 ContactEditorForm::ContactEditorForm(void)
184 : __isExpandable(false)
185 , __isAppControl(false)
186 , __isJobTitleEnabled(false)
187 , __isDepartmentEnabled(false)
188 , __isDefaultPhoneNumberButtonEnabled(false)
190 , __isMoreInformationContextMenuShowing(false)
191 , __isTypeContextMenuShowing(false)
192 , __isKeypadOpened(false)
193 , __isScrollOccurred(false)
194 , __isContactModified(false)
195 , __scrolledDistance(0)
196 , __origScrolledDistance(0)
199 , __previousItemIndex(-1)
200 , __previousGroupIndex(-1)
201 , __pAppControl(null)
202 , __pPhoneNumberFieldItem(null)
203 , __pEmailFieldItem(null)
204 , __pAddressFieldItem(null)
205 , __pImAddressFieldItem(null)
206 , __pUrlFieldItem(null)
207 , __pDeletedItemList(null)
208 , __pFileEventManager(null)
209 , __pDiscardChangesPopup(null)
210 , __pCurrentFocusedItem(null)
211 , __pMoreInformationItem(null)
212 , __pMoreInformationButton(null)
213 , __pDefaultPhoneNumberContextMenu(null)
214 , __pMoreInformationContextMenu(null)
215 , __pThumbnailContextMenu(null)
216 , __pTypeContextMenu(null)
218 , __pNameFieldItem(null)
219 , __pNoteFieldItem(null)
220 , __pPresentationModel(null)
224 ContactEditorForm::~ContactEditorForm(void)
229 ContactEditorForm::Initialize(void)
231 Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
235 ContactEditorForm::OnInitializing(void)
237 SetFormBackEventListener(this);
238 SettingInfo::AddSettingEventListener(*this);
240 Footer* pFooter = GetFooter();
242 FooterItem footerItemSave;
243 footerItemSave.Construct(IDA_ACTION_BAR_SAVE);
244 footerItemSave.SetText(ResourceManager::GetString(L"IDS_COM_SK_SAVE"));
246 pFooter->AddItem(footerItemSave);
247 pFooter->AddActionEventListener(*this);
249 __pTableView = new (std::nothrow) GroupedTableView();
250 __pTableView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), false, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
251 __pTableView->SetItemProvider(this);
252 __pTableView->AddScrollEventListener(*this);
253 __pTableView->AddGroupedTableViewItemEventListener(*this);
254 AddControl(__pTableView);
256 __pPhoneNumberFieldItem = new (std::nothrow) ArrayList();
257 __pPhoneNumberFieldItem->Construct();
259 __pEmailFieldItem = new (std::nothrow) ArrayList();
260 __pEmailFieldItem->Construct();
262 __pAddressFieldItem = new (std::nothrow) ArrayList();
263 __pAddressFieldItem->Construct();
265 __pImAddressFieldItem = new (std::nothrow) ArrayList();
266 __pImAddressFieldItem->Construct();
268 __pUrlFieldItem = new (std::nothrow) ArrayList();
269 __pUrlFieldItem->Construct();
271 __pPresentationModel = new (std::nothrow) ContactPresentationModel();
272 __pPresentationModel->Construct();
273 __pPresentationModel->AddContactChangeListener(*this);
275 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
277 __pDeletedItemList = new ArrayList();
278 __pDeletedItemList->Construct();
284 ContactEditorForm::OnTerminating(void)
286 AppLog("ContactEditorForm::OnTerminating()");
288 result r = E_SUCCESS;
290 __pTableView->SetItemProvider(null);
292 if (__pPresentationModel != null)
294 __pPresentationModel->RemoveContactChangeListener(*this);
295 delete __pPresentationModel;
298 if (__pPhoneNumberFieldItem)
300 __pPhoneNumberFieldItem->RemoveAll(true);
301 delete __pPhoneNumberFieldItem;
304 if (__pEmailFieldItem)
306 __pEmailFieldItem->RemoveAll(true);
307 delete __pEmailFieldItem;
310 if (__pAddressFieldItem)
312 __pAddressFieldItem->RemoveAll(true);
313 delete __pAddressFieldItem;
318 __pUrlFieldItem->RemoveAll(true);
319 delete __pUrlFieldItem;
322 if (__pImAddressFieldItem)
324 __pImAddressFieldItem->RemoveAll(true);
325 delete __pImAddressFieldItem;
328 if (__pDeletedItemList)
330 __pDeletedItemList->RemoveAll(true);
331 delete __pDeletedItemList;
334 if (__pDiscardChangesPopup)
336 delete __pDiscardChangesPopup;
338 delete __pAppControl;
339 delete __pNameFieldItem;
340 delete __pNoteFieldItem;
341 delete __pDefaultPhoneNumberContextMenu;
342 delete __pMoreInformationContextMenu;
343 delete __pThumbnailContextMenu;
344 delete __pTypeContextMenu;
345 delete __pFileEventManager;
347 DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
348 SettingInfo::RemoveSettingEventListener(*this);
354 ContactEditorForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
358 if( IsSaveContactValid() == true && __isContactModified == true)
360 ShowDiscardChangesPopup();
363 if (__isAppControl == true)
365 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
366 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
368 result r = pAppManager->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_CANCELED, null);
369 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
371 UiApp::GetInstance()->Terminate();
375 SceneManager* pSceneManager = SceneManager::GetInstance();
377 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
378 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
383 ContactEditorForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
385 AppLog("ContactEditorForm::OnActionPerformed(), actionId %d", actionId);
387 if ((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) == TABLE_VIEW_DELETE_INPUT_FIELD_ID)
389 int groupIndex = (actionId & TABLE_VIEW_GROUP_INDEX_MASK) >> TABLE_VIEW_GROUP_INDEX_SHIFT;
390 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
392 if (groupIndex > TABLE_VIEW_NAME_FIELD_INDEX)
394 DeleteInputField(groupIndex, itemIndex);
395 if (groupIndex == __previousGroupIndex && itemIndex < __previousItemIndex) //if we deleted a number on top of the item to be deleted
397 __previousItemIndex--; //adjust the index of the item to be deleted
399 __isContactModified = true;
404 else if (&source == __pDefaultPhoneNumberContextMenu)
406 SetAsDefaultPhoneNumber(actionId, true);
407 __isContactModified = true;
411 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX)
413 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
414 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
416 TableViewItem* pItem = static_cast<TableViewItem *>(__pPhoneNumberFieldItem->GetAt(itemIndex));
421 pItem->SetName(Integer::ToString(selectedItemIndex));
423 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
424 if (pButtonType == null)
429 pButtonType->SetText(__pPresentationModel->GetPhoneNumberTypeString((DetailPhoneNumberType)selectedItemIndex));
430 pButtonType->Invalidate(false);
432 __isContactModified = true;
435 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_EMAIL_FIELD_INDEX)
437 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
438 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
440 TableViewItem* pItem = static_cast<TableViewItem *>(__pEmailFieldItem->GetAt(itemIndex));
445 pItem->SetName(Integer::ToString(selectedItemIndex));
447 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
448 if (pButtonType == null)
453 pButtonType->SetText(__pPresentationModel->GetEmailTypeString((DetailEmailType)selectedItemIndex));
454 pButtonType->Invalidate(false);
456 __isContactModified = true;
459 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_ADDRESS_FIELD_INDEX)
461 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
462 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
464 TableViewItem* pItem = static_cast<TableViewItem *>(__pAddressFieldItem->GetAt(itemIndex));
469 pItem->SetName(Integer::ToString(selectedItemIndex));
471 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
472 if (pButtonType == null)
477 pButtonType->SetText(__pPresentationModel->GetAddressTypeString((DetailAddressType)selectedItemIndex));
478 pButtonType->Invalidate(false);
480 __isContactModified = true;
483 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_IM_ADDRESS_FIELD_INDEX)
485 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
486 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
488 TableViewItem* pItem = static_cast<TableViewItem *>(__pImAddressFieldItem->GetAt(itemIndex));
493 pItem->SetName(Integer::ToString(selectedItemIndex));
495 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
496 if (pButtonType == null)
501 pButtonType->SetText(__pPresentationModel->GetImAddressTypeString((DetailImAddressType)selectedItemIndex));
502 pButtonType->Invalidate(false);
504 __isContactModified = true;
507 else if (((actionId & TABLE_VIEW_INPUT_FIELD_ACTION_MASK) >> TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT) == TABLE_VIEW_URL_FIELD_INDEX)
509 int itemIndex = (actionId & TABLE_VIEW_ITEM_INDEX_MASK);
510 int selectedItemIndex = (actionId & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
512 TableViewItem* pItem = static_cast<TableViewItem *>(__pUrlFieldItem->GetAt(itemIndex));
517 pItem->SetName(Integer::ToString(selectedItemIndex));
519 Button* pButtonType = static_cast<Button *>(pItem->GetControl(1));
520 if (pButtonType == null)
525 pButtonType->SetText(__pPresentationModel->GetUrlTypeString((DetailUrlType)selectedItemIndex));
526 pButtonType->Invalidate(false);
528 __isContactModified = true;
534 case IDA_ACTION_BAR_SAVE:
536 result r = E_SUCCESS;
538 r = SaveContactData();
548 case IDA_BUTTON_THUMBNAIL_ADD:
550 if (__pCurrentFocusedItem != null)
554 LaunchAppControl(PROVIDER_ID_GALLERY, OPERATION_ID_PICK);
557 case IDA_BUTTON_THUMBNAIL_DELETE:
559 __pPresentationModel->SetThumbnail(L"");
560 __isContactModified = true;
561 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
563 delete __pFileEventManager;
564 __pFileEventManager = null;
567 case IDA_BUTTON_CAMERA:
569 if (__pCurrentFocusedItem != null)
573 LaunchAppControl(PROVIDER_ID_CAMERA, OPERATION_ID_CREATE_CONTENT);
576 case IDA_BUTTON_EXPANDABLE:
578 ChangeNameFieldStatus();
579 if (__previousItemIndex != -1 && __previousGroupIndex != -1)
581 DeleteInputField(__previousGroupIndex, __previousItemIndex, true);
583 if (__pCurrentFocusedItem == __pNameFieldItem)
585 __pCurrentFocusedItem = null;
588 __pTableView->UpdateTableView();
589 static_cast<Button*>(__pNameFieldItem->GetControl(EXPAND_BUTTON))->SetFocus();
591 Rectangle clientBounds = GetClientAreaBounds();
592 __pTableView->SetSize(clientBounds.width, clientBounds.height);
594 if (__pCurrentFocusedItem != null)
600 case IDA_BUTTON_MORE_INFO:
602 if (__pCurrentFocusedItem != null)
604 if (__isKeypadOpened)
606 __isMoreInformationContextMenuShowing = true;
607 __scrolledDistance = 0;
611 __pMoreInformationButton = static_cast<Button*>(&(const_cast<Control&>(source)));
613 Control* pParentPanel = source.GetParent();
614 if (pParentPanel == null)
619 __pMoreInformationItem = pParentPanel->GetParent();
620 if (__pMoreInformationItem == null)
625 Point contextMenuPos;
627 contextMenuPos.x = __pMoreInformationItem->GetWidth() / 2;
628 contextMenuPos.y = GetClientAreaBounds().y + __pMoreInformationItem->GetY() + source.GetY() - __scrolledDistance;
630 ShowMoreInformationContextMenu(contextMenuPos);
632 __pMoreInformationButton->SetFocus();
635 case IDA_BUTTON_BIRTHDAY_CLEAR:
637 DateTime currentDate;
638 Tizen::System::SystemTime::GetCurrentTime(currentDate);
639 __pPresentationModel->SetBirthday(currentDate);
641 __pTableView->RefreshItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
642 __isContactModified = true;
645 case IDA_CONTEXT_MENU_ITEM_JOB_TITLE:
647 __isExpandable = false;
648 __isJobTitleEnabled = true;
650 ChangeNameFieldStatus();
652 __pTableView->UpdateTableView();
654 if (IsMoreInformationButtonVisible() == false)
656 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
658 __pTableView->ScrollToItem(TABLE_VIEW_NAME_FIELD_INDEX, 0);
661 case IDA_CONTEXT_MENU_ITEM_DEPARTMENT:
663 __isExpandable = false;
664 __isDepartmentEnabled = true;
666 ChangeNameFieldStatus();
668 __pTableView->UpdateTableView();
670 if (IsMoreInformationButtonVisible() == false)
672 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
674 __pTableView->ScrollToItem(TABLE_VIEW_NAME_FIELD_INDEX, 0);
677 case IDA_CONTEXT_MENU_ITEM_INSTANT_MESSENGER:
679 SaveContactData(false);
681 int index = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS);
683 __pTableView->RefreshItem(TABLE_VIEW_IM_ADDRESS_FIELD_INDEX, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
685 if (IsMoreInformationButtonVisible() == false)
687 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
689 __pTableView->ScrollToItem(TABLE_VIEW_IM_ADDRESS_FIELD_INDEX, 0);
692 case IDA_CONTEXT_MENU_ITEM_URL:
694 SaveContactData(false);
696 int index = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL);
698 __pTableView->RefreshItem(TABLE_VIEW_URL_FIELD_INDEX, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
700 if (IsMoreInformationButtonVisible() == false)
702 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
704 __pTableView->ScrollToItem(TABLE_VIEW_URL_FIELD_INDEX, 0);
707 case IDA_CONTEXT_MENU_ITEM_BIRTHDAY:
709 DateTime currentDate;
711 Tizen::System::SystemTime::GetCurrentTime(currentDate);
712 __pPresentationModel->SetBirthday(currentDate);
714 __pTableView->RefreshItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
716 if (IsMoreInformationButtonVisible() == false)
718 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
720 __pTableView->ScrollToItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0);
723 case IDA_CONTEXT_MENU_ITEM_NOTE:
725 __pTableView->RefreshItem(TABLE_VIEW_NOTE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
727 if (IsMoreInformationButtonVisible() == false)
729 __pTableView->RefreshItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
731 __pTableView->ScrollToItem(TABLE_VIEW_NOTE_FIELD_INDEX, 0);
734 case IDA_BUTTON_DEFAULT_PHONE_NUMBER:
736 Control* pParent = source.GetParent();
737 Point contextMenuPos;
739 contextMenuPos.x = pParent->GetWidth() / 2;
740 contextMenuPos.y = GetClientAreaBounds().y + pParent->GetY() + source.GetY() + (source.GetHeight() / 2) - __scrolledDistance;
742 if (__pCurrentFocusedItem != null)
747 SaveContactData(false);
748 ShowDefaultPhoneNumberContextMenu(contextMenuPos);
751 case IDA_POPUP_DISCARD_CHANGES_CANCEL:
753 HideDiscardChangesPopup();
756 case IDA_POPUP_DISCARD_CHANGES_OK:
758 HideDiscardChangesPopup();
760 if (__isAppControl == true)
762 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
763 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
765 result r = pAppManager->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_CANCELED, null);
766 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
768 UiApp::GetInstance()->Terminate();
773 SceneManager* pSceneManager = SceneManager::GetInstance();
775 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
776 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
780 case IDA_BUTTON_RINGTONE_CLEAR:
782 __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, L"", 0);
783 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
786 case IDA_BUTTON_BIRTHDAY_DELETE:
788 __pPresentationModel->RemoveBirthday();
789 __isContactModified = true;
790 __pTableView->UpdateTableView();
793 case IDA_BUTTON_TYPE:
795 Control* pParent = source.GetParent();
796 Point position = pParent->GetPosition();
797 Point itemPosition(position.x + source.GetX(), GetClientAreaBounds().y + position.y + source.GetY() + (source.GetHeight() / 2) - __scrolledDistance);
798 String typeString = pParent->GetName();
799 String itemIndexTag = source.GetName();
803 Integer::Parse(itemIndexTag, itemIndex);
804 Integer::Parse(typeString, type);
805 ShowTypeContextMenu(type, itemPosition, itemIndex);
814 ContactEditorForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId,
815 Tizen::Base::Collection::IList* pArgs)
817 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
818 TryReturnVoid(pContactsApp != null, "Unable to cast UiApp to ContactsApp");
820 pContactsApp->AddContactsAppChangeEventListener(*this);
822 Header* pHeader = GetHeader();
823 Footer* pFooter = GetFooter();
825 if (previousSceneId.Equals(IDSCN_GROUP_SELECTOR, true) || previousSceneId.Equals(IDSCN_GROUP_EDITOR, true))
829 Integer* pCategoryId = null;
833 IList* pCategoryList = __pPresentationModel->GetAssignedCategoryIdListN();
834 prevCount = pCategoryList->GetCount();
835 delete pCategoryList;
837 __pPresentationModel->RemoveContactFromAllCategories();
839 IEnumerator* pEnum = pArgs->GetEnumeratorN();
840 while (pEnum->MoveNext() == E_SUCCESS)
842 pCategoryId = static_cast<Integer*>(pEnum->GetCurrent());
843 if (pCategoryId != null)
845 __pPresentationModel->AddContactToCategory(pCategoryId->ToInt());
846 __isContactModified = true;
851 if(prevCount > 0 && curCount == 0)
853 __isContactModified = true;
858 pArgs->RemoveAll(true);
862 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
867 if (pContactsApp->GetOperationId() == OPERATION_ID_ADD)
869 __isAppControl = true;
870 __pPresentationModel->PrepareNewContact();
872 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_CREATE"));
873 pFooter->SetItemEnabled(0, false);
875 else if (pContactsApp->GetOperationId() == OPERATION_ID_EDIT)
877 __isAppControl = true;
881 String* pArgString = null;
885 IEnumerator* pEnum = pArgs->GetEnumeratorN();
886 while (pEnum->MoveNext() == E_SUCCESS)
888 pArgString = static_cast<String*>(pEnum->GetCurrent());
889 if (pArgString != null)
891 ParseAppControlArgument(*pArgString, type, content);
893 if (type.Equals(RETURN_TYPE_ITEM_ID, false))
896 Integer::Parse(content, contactId);
897 result r = __pPresentationModel->SetContactId(contactId, true);
901 AppLogDebug("Invalid contactId has been input : %d", contactId);
902 UiApp::GetInstance()->Terminate();
905 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_JOB_TITLE).IsEmpty() == false)
907 __isJobTitleEnabled = true;
909 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_DEPARTMENT).IsEmpty() == false)
911 __isDepartmentEnabled = true;
919 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_SK_EDIT"));
926 Integer* pContactId = null;
928 pContactId = static_cast<Integer*>(pArgs->GetAt(0));
929 if (pContactId != null)
931 if (pContactId->ToInt() != INVALID_RECORD_ID)
933 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_SK_EDIT"));
934 __pPresentationModel->SetContactId(pContactId->ToInt(), true);
938 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_CREATE"));
940 String* pVcfPath = static_cast<String*>(pArgs->GetAt(1));
941 if (pVcfPath != null)
943 __pPresentationModel->SetVcfPath(*pVcfPath, true);
944 SetSaveButtonEnabled(IsSaveContactValid());
949 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_JOB_TITLE).IsEmpty() == false)
951 __isJobTitleEnabled = true;
953 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_DEPARTMENT).IsEmpty() == false)
955 __isDepartmentEnabled = true;
960 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_CREATE"));
961 pFooter->SetItemEnabled(0, false);
962 __pPresentationModel->PrepareNewContact();
966 if (__isAppControl == true)
970 String* pArgString = null;
974 IEnumerator* pEnum = pArgs->GetEnumeratorN();
975 while (pEnum->MoveNext() == E_SUCCESS)
977 pArgString = static_cast<String*>(pEnum->GetCurrent());
978 if (pArgString != null)
980 result r = E_SUCCESS;
981 ParseAppControlArgument(*pArgString, type, content);
983 if (type.Equals(INPUT_TYPE_PHONE, false))
985 r = __pPresentationModel->SetValue(DETAIL_PROPERTY_PHONE_NUMBER, content, __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER));
987 else if (type.Equals(INPUT_TYPE_EMAIL, false))
989 r = __pPresentationModel->SetValue(DETAIL_PROPERTY_EMAIL, content, __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL));
991 else if (type.Equals(INPUT_TYPE_URL, false))
993 r = __pPresentationModel->SetValue(DETAIL_PROPERTY_URL, content, __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL));
998 pFooter->SetItemEnabled(0, true);
1008 pArgs->RemoveAll(true);
1014 ContactEditorForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
1016 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1018 pContactsApp->RemoveContactsAppChangeEventListener(*this);
1019 if (__previousItemIndex != -1 && __previousGroupIndex != -1)
1021 DeleteInputField(__previousGroupIndex, __previousItemIndex);
1026 ContactEditorForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1031 ContactEditorForm::OnKeypadOpened(Tizen::Ui::Control& source)
1033 Rectangle clientBounds = GetClientAreaBounds();
1035 __pTableView->SetSize(clientBounds.width, clientBounds.height);
1036 __isKeypadOpened = true;
1040 ContactEditorForm::OnKeypadClosed(Tizen::Ui::Control& source)
1042 Rectangle clientBounds = GetClientAreaBounds();
1043 AppLogDebug("Contacts::OnKeypadclosed bounds are width:(%d), height:(%d)", clientBounds.width, clientBounds.height);
1044 __pTableView->SetSize(clientBounds.width, clientBounds.height);
1046 if (__isMoreInformationContextMenuShowing)
1048 if (__pCurrentFocusedItem != null)
1050 __isMoreInformationContextMenuShowing = false;
1051 __isKeypadOpened = false;
1055 AppLogDebug("__isMoreInformationContextMenuShowing is True");
1056 Point anchorPosition = __pMoreInformationContextMenu->GetAnchorPosition();
1057 __pTableView->ScrollToItem(TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX, 0, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
1058 if (__scrolledDistance != __origScrolledDistance)
1060 __scrolledDistance = __origScrolledDistance;
1063 if (__pMoreInformationItem != null && __pMoreInformationButton != null)
1065 anchorPosition.x = __pMoreInformationItem->GetWidth() / 2;
1066 anchorPosition.y = GetClientAreaBounds().y + __pMoreInformationItem->GetY() + __pMoreInformationButton->GetY() - __scrolledDistance;
1068 __pMoreInformationItem = null;
1069 __pMoreInformationButton = null;
1072 __pMoreInformationContextMenu->SetAnchorPosition(anchorPosition);
1073 __pMoreInformationContextMenu->Show();
1075 __isMoreInformationContextMenuShowing = false;
1077 __isKeypadOpened = false;
1081 ContactEditorForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1086 ContactEditorForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1088 Rectangle clientBounds = GetClientAreaBounds();
1089 int diff = clientBounds.height - __pTableView->GetHeight();
1091 if (__pTypeContextMenu != null)
1093 int yPos = __pTypeContextMenu->GetAnchorPosition().y;
1094 __pTypeContextMenu->SetAnchorPosition(Point(__pTypeContextMenu->GetAnchorPosition().x, yPos + diff));
1095 __pTypeContextMenu->Show();
1097 __pTableView->SetSize(clientBounds.width, clientBounds.height);
1101 ContactEditorForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView &tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem *pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1103 SceneManager* pSceneManager = SceneManager::GetInstance();
1105 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED && groupIndex == TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX)
1107 if (__pCurrentFocusedItem != null)
1114 if (__isMoreInformationContextMenuShowing == true)
1116 __isMoreInformationContextMenuShowing = false;
1119 if (__pPresentationModel->GetCategoryCount() > 0)
1121 IList* pCategoryList = __pPresentationModel->GetAssignedCategoryIdListN();
1123 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_SELECTOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pCategoryList);
1127 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
1132 else if (itemIndex == 2)
1134 if (__isMoreInformationContextMenuShowing == true)
1136 __isMoreInformationContextMenuShowing = false;
1139 Panel* pPanel = static_cast<Panel*>(pItem->GetControl(0));
1142 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(1));
1143 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(0));
1145 pPanel->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
1146 if (pLabelValue != null)
1148 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
1151 if (pLabelValue != null)
1153 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
1155 pPanel->Invalidate(true);
1158 LaunchAppControl(PROVIDER_ID_FILEMANAGER, OPERATION_ID_PICK);
1164 ContactEditorForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView &tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem *pContextItem, bool activated)
1169 ContactEditorForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView &tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem *pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1174 ContactEditorForm::GetGroupCount(void)
1176 return GROUP_ITEM_COUNT;
1180 ContactEditorForm::GetItemCount(int groupIndex)
1186 case TABLE_VIEW_THUMBNAIL_FIELD_INDEX:
1191 case TABLE_VIEW_NAME_FIELD_INDEX:
1193 itemCount = NAME_FIELD_ITEM_COUNT;
1196 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
1198 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) + 1;
1200 if (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) > 1)
1202 __isDefaultPhoneNumberButtonEnabled = true;
1207 __isDefaultPhoneNumberButtonEnabled = false;
1211 case TABLE_VIEW_EMAIL_FIELD_INDEX:
1213 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL) + 1;
1216 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
1218 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_ADDRESS) + 1;
1221 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
1223 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS);
1225 if ((itemCount == 0 && __pImAddressFieldItem->GetCount() > 0) || itemCount > 0)
1231 case TABLE_VIEW_URL_FIELD_INDEX:
1233 itemCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL);
1235 if ((itemCount == 0 && __pUrlFieldItem->GetCount() > 0) || itemCount > 0)
1241 case TABLE_VIEW_BIRTHDAY_FIELD_INDEX:
1244 if (__pPresentationModel->GetBirthday(birthday) != E_SUCCESS)
1254 case TABLE_VIEW_NOTE_FIELD_INDEX:
1256 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_NOTE).IsEmpty() == false || __pNoteFieldItem != null )
1266 case TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX:
1271 case TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX:
1273 if (IsMoreInformationButtonVisible())
1291 ContactEditorForm::GetDefaultGroupItemHeight(void)
1293 return H_EMPTY_SPACE;
1297 ContactEditorForm::GetDefaultItemHeight(void)
1299 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1300 return pContactsApp->GetListItemSingleLineHeight();
1304 ContactEditorForm::CreateGroupItem(int groupIndex, int itemWidth)
1306 int groupItemHeight = H_EMPTY_SPACE;
1308 if (groupIndex == TABLE_VIEW_THUMBNAIL_FIELD_INDEX)
1310 groupItemHeight = H_THUMBNAIL_GROUP_ITEM_HEIGHT;
1312 else if (groupIndex == TABLE_VIEW_NAME_FIELD_INDEX)
1314 groupItemHeight = H_NAMEFIELD_GROUP_ITEM_HEIGHT;
1316 else if (groupIndex == TABLE_VIEW_BIRTHDAY_FIELD_INDEX)
1318 groupItemHeight = Y_EDIT_FIELD_GAP;
1320 else if (groupIndex == TABLE_VIEW_NOTE_FIELD_INDEX)
1322 groupItemHeight = H_EDIT_FIELD_GAP;
1324 else if ((groupIndex > TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX && groupIndex < TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX) || groupIndex == TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX)
1326 groupItemHeight = 0;
1329 TableViewGroupItem* pGroupItem = new (std::nothrow) TableViewGroupItem();
1330 pGroupItem->Construct(Dimension(itemWidth, groupItemHeight));
1331 pGroupItem->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
1332 pGroupItem->SetEnabled(false);
1334 Panel* pPanel = new (std::nothrow) Panel();
1335 pPanel->Construct(Rectangle(0, -(H_DIVIDER), itemWidth, groupItemHeight + H_DIVIDER));
1336 pPanel->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG));
1338 pGroupItem->AddControl(pPanel);
1344 ContactEditorForm::DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1353 ContactEditorForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
1355 TableViewItem* pItem = null;
1359 case TABLE_VIEW_THUMBNAIL_FIELD_INDEX:
1361 pItem = GetThumbnailField(itemWidth);
1364 case TABLE_VIEW_NAME_FIELD_INDEX:
1366 pItem = GetNameFields(itemWidth);
1369 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
1371 if ((itemIndex == __pTableView->GetItemCountAt(groupIndex) - 1) && __isDefaultPhoneNumberButtonEnabled == true)
1373 pItem = GetDefaultPhoneNumberItem(itemWidth);
1377 pItem = GetPhoneNumberFields(itemIndex, itemWidth);
1380 case TABLE_VIEW_EMAIL_FIELD_INDEX:
1382 pItem = GetEmailFields(itemIndex, itemWidth);
1385 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
1387 pItem = GetAddressFields(itemIndex, itemWidth);
1390 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
1392 pItem = GetImAddressFields(itemIndex, itemWidth);
1395 case TABLE_VIEW_URL_FIELD_INDEX:
1397 pItem = GetUrlFields(itemIndex, itemWidth);
1400 case TABLE_VIEW_BIRTHDAY_FIELD_INDEX:
1402 pItem = GetBirthdayField(itemWidth);
1405 case TABLE_VIEW_NOTE_FIELD_INDEX:
1407 pItem = GetNoteField(itemWidth);
1410 case TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX:
1415 pItem = GetGroupsField(itemWidth);
1419 pItem = new (std::nothrow) TableViewItem();
1420 pItem->Construct(Dimension(itemWidth, H_DIVIDER * 2));
1421 pItem->SetEnabled(false);
1425 pItem = GetRingtoneField(itemWidth);
1432 case TABLE_VIEW_MORE_INFORMATION_FIELD_INDEX:
1434 if (IsMoreInformationButtonVisible())
1436 pItem = GetMoreInformationField(itemWidth);
1452 ContactEditorForm::DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1454 if ((groupIndex > TABLE_VIEW_NAME_FIELD_INDEX && groupIndex < TABLE_VIEW_BIRTHDAY_FIELD_INDEX) || groupIndex == TABLE_VIEW_NOTE_FIELD_INDEX)
1457 __pDeletedItemList->IndexOf(*pItem, index);
1461 __pDeletedItemList->RemoveAt(index);
1468 else if (groupIndex == TABLE_VIEW_NAME_FIELD_INDEX)
1471 __pNameFieldItem = null;
1474 if (__pCurrentFocusedItem == pItem && __isKeypadOpened)
1476 __isKeypadOpened = false;
1486 ContactEditorForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem *pItem)
1491 ContactEditorForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem *pItem)
1500 case TABLE_VIEW_THUMBNAIL_FIELD_INDEX:
1502 SetThumbnailControls(*pItem, true);
1503 pItem->Invalidate(true);
1506 case TABLE_VIEW_NAME_FIELD_INDEX:
1508 if (__pCurrentFocusedItem == pItem && __isKeypadOpened)
1510 __isKeypadOpened = false;
1512 pItem->RemoveAllControls();
1513 SetNameFields(*pItem);
1517 case TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX:
1520 Panel* pPanel = static_cast<Panel*>(pItem->GetControl(0));
1527 Label* pLabel = static_cast<Label*>(pPanel->GetControl(1));
1536 valueString = __pPresentationModel->GetValue(DETAIL_PROPERTY_GROUP);
1537 if (valueString.IsEmpty() == true)
1539 valueString = ResourceManager::GetString(L"IDS_PB_BODY_NOT_ASSIGNED");
1542 else if (itemIndex == 2)
1544 String ringtoneName = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
1547 ringtoneName.LastIndexOf(L"/", ringtoneName.GetLength() - 1, index);
1551 ringtoneName.SubString(index + 1, valueString);
1555 pLabel->SetText(valueString);
1556 pLabel->Invalidate(false);
1559 case TABLE_VIEW_BIRTHDAY_FIELD_INDEX:
1561 EditDate* pBirthday = static_cast<EditDate *>(pItem->GetControl(1));
1562 if (pBirthday == null)
1566 pBirthday->Invalidate(false);
1569 case TABLE_VIEW_NOTE_FIELD_INDEX:
1571 Control* pNoteField = pItem->GetControl(1);
1572 Control* pNoteLabel = pItem->GetControl(0);
1573 if (pNoteField == null)
1578 pItem->SetSize(pItem->GetWidth(), pNoteLabel->GetHeight() + pNoteField->GetHeight() + H_EDIT_FIELD_GAP + H_EXPANDABLE_EDIT_AREA_EXTENDED);
1587 Tizen::Ui::Controls::TableViewItem*
1588 ContactEditorForm::GetThumbnailField(int itemWidth)
1590 TableViewItem* pThumbnailItem = new (std::nothrow) TableViewItem();
1591 pThumbnailItem->Construct(Dimension(itemWidth, W_THUMBNAIL + H_THUMBNAIL_DELETE_BUTTON_GAP + Y_EDIT_FIELD_GAP * 2));
1592 pThumbnailItem->SetBackgroundColor(Color(0), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1594 SetThumbnailControls(*pThumbnailItem);
1596 return pThumbnailItem;
1599 Tizen::Ui::Controls::TableViewItem*
1600 ContactEditorForm::GetNameFields(int itemWidth)
1602 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1604 __pNameFieldItem = new (std::nothrow) TableViewItem();
1605 __pNameFieldItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight()));
1606 __pNameFieldItem->SetBackgroundColor(Color(0), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1608 SetNameFields(*__pNameFieldItem);
1610 return __pNameFieldItem;
1614 ContactEditorForm::SetNameFields(Tizen::Ui::Controls::TableViewItem& item)
1616 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1618 int itemWidth = item.GetWidth();
1619 int itemHeight = pContactsApp->GetListItemSingleLineHeight();
1621 if (__isExpandable == true)
1623 itemHeight = DEFAULT_EXPAND_NAME_FIELD_COUNT * pContactsApp->GetListItemSingleLineHeight();
1625 if (__isJobTitleEnabled == true)
1627 itemHeight += pContactsApp->GetListItemSingleLineHeight();
1630 if (__isDepartmentEnabled)
1632 itemHeight += pContactsApp->GetListItemSingleLineHeight();
1636 item.SetSize(itemWidth, itemHeight);
1638 Rectangle itemBounds(W_ITEM_GAP, Y_EDIT_FIELD_GAP, itemWidth - (W_ITEM_GAP * 3) - H_BUTTON, pContactsApp->GetListItemSingleLineHeight() - H_EDIT_FIELD_GAP);
1640 if (__isExpandable == true)
1642 EditField* pFirstName = new (std::nothrow) EditField();
1643 pFirstName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, __pPresentationModel->GetValue(DETAIL_PROPERTY_FIRST_NAME).GetLength() + EDIT_FIELD_EXTENDED_LENGTH);
1644 pFirstName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_FIRST_NAME"));
1645 pFirstName->AddFocusEventListener(*this);
1646 pFirstName->AddKeypadEventListener(*this);
1647 pFirstName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_FIRST_NAME"));
1648 pFirstName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_FIRST_NAME));
1649 pFirstName->AddTextEventListener(*this);
1650 pFirstName->SetTextSize(pContactsApp->GetFontSize());
1652 item.AddControl(pFirstName);
1653 item.SetIndividualSelectionEnabled(pFirstName, true);
1655 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1656 EditField* pMiddleName = new (std::nothrow) EditField();
1657 pMiddleName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, __pPresentationModel->GetValue(DETAIL_PROPERTY_MIDDLE_NAME).GetLength() + EDIT_FIELD_EXTENDED_LENGTH);
1658 pMiddleName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_MIDDLE_NAME"));
1659 pMiddleName->AddFocusEventListener(*this);
1660 pMiddleName->AddKeypadEventListener(*this);
1661 pMiddleName->AddTextEventListener(*this);
1662 pMiddleName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_MIDDLE_NAME"));
1663 pMiddleName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_MIDDLE_NAME));
1664 pMiddleName->SetTextSize(pContactsApp->GetFontSize());
1666 item.AddControl(pMiddleName);
1667 item.SetIndividualSelectionEnabled(pMiddleName, true);
1669 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1670 EditField* pLastName = new (std::nothrow) EditField();
1671 pLastName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, __pPresentationModel->GetValue(DETAIL_PROPERTY_LAST_NAME).GetLength() + EDIT_FIELD_EXTENDED_LENGTH);
1672 pLastName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_LAST_NAME"));
1673 pLastName->AddFocusEventListener(*this);
1674 pLastName->AddKeypadEventListener(*this);
1675 pLastName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_LAST_NAME"));
1676 pLastName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_LAST_NAME));
1677 pLastName->SetTextSize(pContactsApp->GetFontSize());
1678 pLastName->AddTextEventListener(*this);
1680 item.AddControl(pLastName);
1681 item.SetIndividualSelectionEnabled(pLastName, true);
1683 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1684 EditField* pSuffix = new (std::nothrow) EditField();
1685 pSuffix->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, __pPresentationModel->GetValue(DETAIL_PROPERTY_NAME_SUFFIX).GetLength() + EDIT_FIELD_EXTENDED_LENGTH);
1686 pSuffix->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_SUFFIX"));
1687 pSuffix->AddFocusEventListener(*this);
1688 pSuffix->AddKeypadEventListener(*this);
1689 pSuffix->AddTextEventListener(*this);
1690 pSuffix->SetName(ResourceManager::GetString(L"IDS_PB_BODY_SUFFIX"));
1691 pSuffix->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_NAME_SUFFIX));
1692 pSuffix->SetTextSize(pContactsApp->GetFontSize());
1694 item.AddControl(pSuffix);
1695 item.SetIndividualSelectionEnabled(pSuffix, true);
1697 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1698 EditField* pNickName = new (std::nothrow) EditField();
1699 pNickName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY);
1700 pNickName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_NICKNAME"));
1701 pNickName->AddFocusEventListener(*this);
1702 pNickName->AddKeypadEventListener(*this);
1703 pNickName->AddTextEventListener(*this);
1704 pNickName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_NICKNAME"));
1705 pNickName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_NICK_NAME));
1706 pNickName->SetTextSize(pContactsApp->GetFontSize());
1708 item.AddControl(pNickName);
1709 item.SetIndividualSelectionEnabled(pNickName, true);
1711 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1712 if (__isJobTitleEnabled == true)
1714 EditField* pJobTitle = new (std::nothrow) EditField();
1715 pJobTitle->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY);
1716 pJobTitle->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_JOB_TITLE"));
1717 pJobTitle->AddFocusEventListener(*this);
1718 pJobTitle->AddKeypadEventListener(*this);
1719 pJobTitle->AddTextEventListener(*this);
1720 pJobTitle->SetName(ResourceManager::GetString(L"IDS_PB_BODY_JOB_TITLE"));
1721 pJobTitle->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_JOB_TITLE));
1722 pJobTitle->SetTextSize(pContactsApp->GetFontSize());
1724 item.AddControl(pJobTitle);
1725 item.SetIndividualSelectionEnabled(pJobTitle, true);
1727 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1730 if (__isDepartmentEnabled == true)
1732 EditField* pDepartment = new (std::nothrow) EditField();
1733 pDepartment->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY);
1734 pDepartment->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_DEPARTMENT"));
1735 pDepartment->AddFocusEventListener(*this);
1736 pDepartment->AddKeypadEventListener(*this);
1737 pDepartment->AddTextEventListener(*this);
1738 pDepartment->SetName(ResourceManager::GetString(L"IDS_PB_BODY_DEPARTMENT"));
1739 pDepartment->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_DEPARTMENT));
1740 pDepartment->SetTextSize(pContactsApp->GetFontSize());
1742 item.AddControl(pDepartment);
1743 item.SetIndividualSelectionEnabled(pDepartment, true);
1745 itemBounds.y += pContactsApp->GetListItemSingleLineHeight();
1748 EditField* pCompanyName = new (std::nothrow) EditField();
1749 pCompanyName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY);
1750 pCompanyName->SetGuideText(ResourceManager::GetString(L"IDS_PB_BODY_COMPANY"));
1751 pCompanyName->AddFocusEventListener(*this);
1752 pCompanyName->AddKeypadEventListener(*this);
1753 pCompanyName->SetName(ResourceManager::GetString(L"IDS_PB_BODY_COMPANY"));
1754 pCompanyName->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_COMPANY));
1755 pCompanyName->SetTextSize(pContactsApp->GetFontSize());
1757 item.AddControl(pCompanyName);
1758 item.SetIndividualSelectionEnabled(pCompanyName, true);
1763 String firstName(__pPresentationModel->GetValue(DETAIL_PROPERTY_FIRST_NAME));
1764 String lastName(__pPresentationModel->GetValue(DETAIL_PROPERTY_LAST_NAME));
1765 String middleName(__pPresentationModel->GetValue(DETAIL_PROPERTY_MIDDLE_NAME));
1766 String suffix(__pPresentationModel->GetValue(DETAIL_PROPERTY_NAME_SUFFIX));
1768 nameLength = firstName.GetLength() + lastName.GetLength() + middleName.GetLength();
1769 if (suffix.IsEmpty() == false)
1771 nameLength = nameLength + suffix.GetLength() + 1;
1774 EditField* pName = new (std::nothrow) EditField();
1775 pName->Construct(itemBounds, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, false, nameLength + EDIT_FIELD_EXTENDED_LENGTH);
1776 pName->SetGuideText(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS_NAME"));
1777 pName->AddFocusEventListener(*this);
1778 pName->AddKeypadEventListener(*this);
1779 pName->SetName(Integer::ToString(IDA_INPUT_FIELD_DISPLAY_NAME));
1780 pName->AddTextEventListener(*this);
1781 pName->SetTextSize(pContactsApp->GetFontSize());
1783 if (firstName.IsEmpty() == false)
1785 pName->SetText(firstName);
1788 if (middleName.IsEmpty() == false)
1790 pName->AppendText(CHARACTER_SPACE + middleName);
1793 if (lastName.IsEmpty() == false)
1795 pName->AppendText(CHARACTER_SPACE + lastName);
1798 if (suffix.IsEmpty() == false)
1800 pName->AppendText(DELIMITER_COMMA);
1801 pName->AppendText(CHARACTER_SPACE + suffix);
1804 item.AddControl(pName);
1805 item.SetIndividualSelectionEnabled(pName, true);
1806 __fullName = pName->GetText();
1809 Button* pButtonExpand = new (std::nothrow) Button();
1810 pButtonExpand->Construct(Rectangle(itemWidth - (H_BUTTON + W_ITEM_GAP), (pContactsApp->GetListItemSingleLineHeight() - H_BUTTON) / 2, H_BUTTON, H_BUTTON));
1811 pButtonExpand->SetActionId(IDA_BUTTON_EXPANDABLE);
1812 pButtonExpand->SetName(EXPAND_BUTTON);
1813 pButtonExpand->AddActionEventListener(*this);
1815 Bitmap* pBitmap = null;
1816 Bitmap* pBitmapPressed = null;
1818 if (__isExpandable == true)
1820 pBitmap = ResourceManager::GetBitmapN(IDB_EXPAND_OPENED);
1821 pBitmapPressed = ResourceManager::GetBitmapN(IDB_EXPAND_OPENED_PRESSED);
1825 pBitmap = ResourceManager::GetBitmapN(IDB_EXPAND_CLOSED);
1826 pBitmapPressed = ResourceManager::GetBitmapN(IDB_EXPAND_CLOSED_PRESSED);
1829 if (pBitmap != null)
1831 pButtonExpand->SetNormalBitmap(Point(0, 0), *pBitmap);
1834 if (pBitmapPressed != null)
1836 pButtonExpand->SetPressedBitmap(Point(0, 0), *pBitmapPressed);
1840 delete pBitmapPressed;
1842 pBitmap = ResourceManager::GetBitmapN(IDB_EXPAND_BUTTON_NORMAL);
1843 pBitmapPressed = ResourceManager::GetBitmapN(IDB_EXPAND_BUTTON_PRESSED);
1845 if (pBitmap != null)
1847 pButtonExpand->SetNormalBackgroundBitmap(*pBitmap);
1850 if (pBitmapPressed != null)
1852 pButtonExpand->SetPressedBackgroundBitmap(*pBitmapPressed);
1853 delete pBitmapPressed;
1856 item.AddControl(pButtonExpand);
1857 item.SetIndividualSelectionEnabled(pButtonExpand, true);
1860 Tizen::Ui::Controls::TableViewItem*
1861 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)
1863 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1865 TableViewItem* pTableViewItem = new (std::nothrow) TableViewItem();
1866 pTableViewItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight()), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1867 pTableViewItem->SetBackgroundColor(Color(0), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
1869 EditField* pInputField = new (std::nothrow) EditField();
1870 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);
1871 pInputField->SetGuideText(guideText);
1872 pInputField->SetText(text);
1873 pInputField->SetTextSize(pContactsApp->GetFontSize());
1874 pInputField->AddKeypadEventListener(*this);
1875 pInputField->AddFocusEventListener(*this);
1876 pInputField->AddTextEventListener(*this);
1877 pInputField->SetEnabled(true);
1879 int parsedItemIndex = 0;
1880 parsedItemIndex |= (groupIndex << TABLE_VIEW_INPUT_FIELD_ACTION_SHIFT);
1881 parsedItemIndex |= (groupIndex << TABLE_VIEW_GROUP_INDEX_SHIFT);
1882 parsedItemIndex |= itemIndex;
1884 pInputField->SetName(Integer::ToString(parsedItemIndex));
1885 pTableViewItem->AddControl(pInputField);
1887 Button *pButtonType = new (std::nothrow) Button();
1888 pButtonType->Construct(Rectangle(pInputField->GetX() + pInputField->GetWidth() + W_ITEM_GAP, (pContactsApp->GetListItemSingleLineHeight() - H_BUTTON) / 2, W_TYPE_BUTTON, H_BUTTON));
1889 pButtonType->SetText(titleText);
1890 pButtonType->SetActionId(IDA_BUTTON_TYPE);
1891 pButtonType->AddActionEventListener(*this);
1892 pButtonType->AddTouchEventListener(*this);
1893 pButtonType->SetName(Integer::ToString(parsedItemIndex));
1895 Bitmap* pDropBoxIcon = ResourceManager::GetBitmapN(IDB_BUTTON_DROPBOX);
1897 if (pDropBoxIcon != null)
1899 pButtonType->SetNormalBitmap(Point(W_TYPE_BUTTON - W_DROPBOX_ICON, H_BUTTON - H_DROPBOX_ICON), *pDropBoxIcon);
1900 pButtonType->SetPressedBitmap(Point(W_TYPE_BUTTON - W_DROPBOX_ICON, H_BUTTON - H_DROPBOX_ICON), *pDropBoxIcon);
1901 pButtonType->SetDisabledBitmap(Point(W_TYPE_BUTTON - W_DROPBOX_ICON, H_BUTTON - H_DROPBOX_ICON), *pDropBoxIcon);
1902 delete pDropBoxIcon;
1904 pTableViewItem->AddControl(pButtonType);
1906 Button *pButtonDelete = new (std::nothrow) Button();
1907 pButtonDelete->Construct(Rectangle(itemWidth - H_BUTTON - W_ITEM_GAP, (pContactsApp->GetListItemSingleLineHeight() - H_BUTTON) / 2, H_BUTTON, H_BUTTON));
1908 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS);
1909 Bitmap* pBitmapPressed = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS_PRESSED);
1911 if (pBitmap != null)
1913 pButtonDelete->SetNormalBitmap(Point(0, 0), *pBitmap);
1916 if (pBitmapPressed != null)
1918 pButtonDelete->SetPressedBitmap(Point(0, 0), *pBitmapPressed);
1919 delete pBitmapPressed;
1922 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_NORMAL);
1923 pBitmapPressed = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_PRESSED);
1925 if (pBitmap != null)
1927 pButtonDelete->SetNormalBackgroundBitmap(*pBitmap);
1930 if (pBitmapPressed != null)
1932 pButtonDelete->SetPressedBackgroundBitmap(*pBitmapPressed);
1933 delete pBitmapPressed;
1937 actionId |= TABLE_VIEW_DELETE_INPUT_FIELD_ID;
1938 actionId |= (groupIndex << TABLE_VIEW_GROUP_INDEX_SHIFT);
1939 actionId |= itemIndex;
1941 pButtonDelete->SetActionId(actionId);
1942 pButtonDelete->AddActionEventListener(*this);
1944 pTableViewItem->AddControl(pButtonDelete);
1946 if (isDeleteButton == false)
1948 pButtonDelete->SetShowState(false);
1951 pTableViewItem->SetIndividualSelectionEnabled(pInputField, true);
1952 pTableViewItem->SetIndividualSelectionEnabled(pButtonType, true);
1953 pTableViewItem->SetIndividualSelectionEnabled(pButtonDelete, true);
1955 return pTableViewItem;
1958 Tizen::Ui::Controls::TableViewItem*
1959 ContactEditorForm::GetPhoneNumberFields(int itemIndex, int itemWidth)
1961 if (__pPhoneNumberFieldItem->GetCount() == 0)
1963 int phoneNumberCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
1964 String guideText = ResourceManager::GetString(L"IDS_PB_BODY_NUMBER");
1965 String defaultPhoneNumber = __pPresentationModel->GetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER);
1967 for (int i = 0; i < phoneNumberCount; i++)
1969 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, i);
1970 String phoneNumberString = __pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, i);
1972 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_PHONE_NUMBER, typeString, guideText, phoneNumberString, true);
1973 pItem->SetName(Integer::ToString(__pPresentationModel->GetPhoneNumberType(i)));
1975 __pPhoneNumberFieldItem->Add(*pItem);
1978 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX, phoneNumberCount, itemWidth, EDIT_FIELD_STYLE_PHONE_NUMBER, __pPresentationModel->GetPhoneNumberTypeString(DETAIL_PHONENUMBER_TYPE_MOBILE), guideText);
1979 pItem->SetName(Integer::ToString(DETAIL_PHONENUMBER_TYPE_MOBILE));
1981 __pPhoneNumberFieldItem->Add(*pItem);
1982 SetAsDefaultPhoneNumber(__pPresentationModel->GetDefaultNumberIndex());
1985 if (__pPhoneNumberFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) + 1))
1987 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"));
1988 pItem->SetName(Integer::ToString(DETAIL_PHONENUMBER_TYPE_MOBILE));
1990 __pPhoneNumberFieldItem->Add(*pItem);
1993 TableViewItem* pItem = static_cast<TableViewItem *>(__pPhoneNumberFieldItem->GetAt(itemIndex));
2002 Tizen::Ui::Controls::TableViewItem*
2003 ContactEditorForm::GetEmailFields(int itemIndex, int itemWidth)
2005 if (__pEmailFieldItem->GetCount() == 0)
2007 int emailCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL);
2008 String guideText = ResourceManager::GetString(L"IDS_COM_BODY_EMAIL");
2010 for (int i = 0; i < emailCount; i++)
2012 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_EMAIL, i);
2013 String emailString = __pPresentationModel->GetValue(DETAIL_PROPERTY_EMAIL, i);
2015 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_EMAIL_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_EMAIL, typeString, guideText, emailString, true);
2016 pItem->SetName(Integer::ToString(__pPresentationModel->GetEmailType(i)));
2018 __pEmailFieldItem->Add(*pItem);
2021 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_EMAIL_FIELD_INDEX, emailCount, itemWidth, EDIT_FIELD_STYLE_EMAIL, __pPresentationModel->GetEmailTypeString(DETAIL_EMAIL_TYPE_HOME), guideText);
2022 pItem->SetName(Integer::ToString(DETAIL_EMAIL_TYPE_HOME));
2024 __pEmailFieldItem->Add(*pItem);
2027 if (__pEmailFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL) + 1))
2029 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"));
2030 pItem->SetName(Integer::ToString(DETAIL_EMAIL_TYPE_HOME));
2032 __pEmailFieldItem->Add(*pItem);
2035 TableViewItem* pItem = static_cast<TableViewItem *>(__pEmailFieldItem->GetAt(itemIndex));
2044 Tizen::Ui::Controls::TableViewItem*
2045 ContactEditorForm::GetAddressFields(int itemIndex, int itemWidth)
2047 if (__pAddressFieldItem->GetCount() == 0)
2049 int addressCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_ADDRESS);
2050 String guideText = ResourceManager::GetString(L"IDS_PB_BODY_ADDRESS");
2052 for (int i = 0; i < addressCount; i++)
2054 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_ADDRESS, i);
2055 String addressString = __pPresentationModel->GetValue(DETAIL_PROPERTY_ADDRESS, i);
2057 TableViewItem* pItem= GetInputFieldN(TABLE_VIEW_ADDRESS_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_NORMAL, typeString, guideText, addressString, true);
2058 pItem->SetName(Integer::ToString(__pPresentationModel->GetAddressType(DETAIL_PROPERTY_ADDRESS, i)));
2060 __pAddressFieldItem->Add(*pItem);
2063 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_ADDRESS_FIELD_INDEX, addressCount, itemWidth, EDIT_FIELD_STYLE_NORMAL, ResourceManager::GetString(L"IDS_PB_BODY_HOME"), guideText);
2064 pItem->SetName(Integer::ToString(DETAIL_ADDRESS_TYPE_HOME));
2066 __pAddressFieldItem->Add(*pItem);
2069 if (__pAddressFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_ADDRESS) + 1))
2071 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"));
2072 pItem->SetName(Integer::ToString(DETAIL_ADDRESS_TYPE_HOME));
2074 __pAddressFieldItem->Add(*pItem);
2077 TableViewItem* pItem = static_cast<TableViewItem *>(__pAddressFieldItem->GetAt(itemIndex));
2086 Tizen::Ui::Controls::TableViewItem*
2087 ContactEditorForm::GetImAddressFields(int itemIndex, int itemWidth)
2089 if (__pImAddressFieldItem->GetCount() == 0)
2091 int imCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS);
2092 String guideText = ResourceManager::GetString(L"IDS_PB_HEADER_INSTANT_MESSENGER_ABB");
2094 for (int i = 0; i < imCount; i++)
2096 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_IM_ADDRESS, i);
2097 String imString = __pPresentationModel->GetValue(DETAIL_PROPERTY_IM_ADDRESS, i);
2099 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_IM_ADDRESS_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_NORMAL, typeString, guideText, imString, true);
2100 pItem->SetName(Integer::ToString(__pPresentationModel->GetImAddressType(i)));
2102 __pImAddressFieldItem->Add(*pItem);
2105 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_IM_ADDRESS_FIELD_INDEX, imCount, itemWidth, EDIT_FIELD_STYLE_NORMAL, IM_ADDRESS_YAHOO, guideText);
2106 pItem->SetName(Integer::ToString(DETAIL_IM_ADDRESS_TYPE_YAHOO));
2108 __pImAddressFieldItem->Add(*pItem);
2111 if (__pImAddressFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_IM_ADDRESS) + 1))
2113 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"));
2114 pItem->SetName(Integer::ToString(DETAIL_IM_ADDRESS_TYPE_YAHOO));
2116 __pImAddressFieldItem->Add(*pItem);
2119 TableViewItem* pItem = static_cast<TableViewItem *>(__pImAddressFieldItem->GetAt(itemIndex));
2128 Tizen::Ui::Controls::TableViewItem*
2129 ContactEditorForm::GetUrlFields(int itemIndex, int itemWidth)
2131 if (__pUrlFieldItem->GetCount() == 0)
2133 int urlCount = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL);
2134 String guideText = ResourceManager::GetString(L"IDS_PB_BODY_URL");
2136 for (int i = 0; i < urlCount; i++)
2138 String typeString = __pPresentationModel->GetType(DETAIL_PROPERTY_URL, i);
2139 String urlString = __pPresentationModel->GetValue(DETAIL_PROPERTY_URL, i);
2141 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_URL_FIELD_INDEX, i, itemWidth, EDIT_FIELD_STYLE_URL, typeString, guideText, urlString, true);
2142 pItem->SetName(Integer::ToString(__pPresentationModel->GetUrlType(i)));
2144 __pUrlFieldItem->Add(*pItem);
2147 TableViewItem* pItem = GetInputFieldN(TABLE_VIEW_URL_FIELD_INDEX, urlCount, itemWidth, EDIT_FIELD_STYLE_URL, __pPresentationModel->GetUrlTypeString(DETAIL_URL_TYPE_HOME), guideText);
2148 pItem->SetName(Integer::ToString(DETAIL_URL_TYPE_HOME));
2150 __pUrlFieldItem->Add(*pItem);
2153 if (__pUrlFieldItem->GetCount() < (__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_URL) + 1))
2155 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"));
2156 pItem->SetName(Integer::ToString(DETAIL_URL_TYPE_HOME));
2158 __pUrlFieldItem->Add(*pItem);
2161 TableViewItem* pItem = static_cast<TableViewItem *>(__pUrlFieldItem->GetAt(itemIndex));
2169 Tizen::Ui::Controls::TableViewItem*
2170 ContactEditorForm::GetGroupsField(int itemWidth)
2172 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2174 TableViewItem* pGroupsItem = new (std::nothrow) TableViewItem();
2175 pGroupsItem->Construct(Dimension(itemWidth, H_DOUBLE_LINE_ITEM + pContactsApp->GetFontHeightOffset()), TABLE_VIEW_ANNEX_STYLE_NORMAL);
2176 pGroupsItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
2177 pGroupsItem->AddKeyEventListener(*this);
2179 Panel* pGroupStyle = new (std::nothrow) Panel();
2180 pGroupStyle->Construct(Rectangle(0, 0, itemWidth , H_DOUBLE_LINE_ITEM + pContactsApp->GetFontHeightOffset()), GROUP_STYLE_NONE);
2181 pGroupStyle->SetName(GROUP_STYLE_PANEL);
2182 pGroupStyle->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
2183 pGroupStyle->AddTouchEventListener(*this);
2184 pGroupsItem->AddControl(pGroupStyle);
2186 Label* pLabelTitle = new (std::nothrow) Label();
2187 pLabelTitle->Construct(Rectangle(0, H_GROUP_RINGTONE_TITLE_GAP, itemWidth, H_GROUP_RINGTONE_TITLE_LABEL), ResourceManager::GetString(L"IDS_PB_BODY_GROUPS"));
2188 pLabelTitle->SetName(GROUP_LABEL_TITLE);
2189 pLabelTitle->AddTouchEventListener(*this);
2190 pLabelTitle->SetTextConfig(FONT_SIZE_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
2191 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
2192 pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2194 pGroupStyle->AddControl(pLabelTitle);
2196 String groupsName = __pPresentationModel->GetValue(DETAIL_PROPERTY_GROUP);
2197 if (groupsName.IsEmpty() == true)
2199 groupsName = ResourceManager::GetString(L"IDS_PB_BODY_NOT_ASSIGNED");
2202 Label* pLabelGroupName = new (std::nothrow) Label();
2203 pLabelGroupName->Construct(Rectangle(0, H_GROUP_RINGTONE_TITLE_GAP + H_GROUP_RINGTONE_TITLE_LABEL, itemWidth, H_GROUP_RINGTONE_VALUE_LABEL + pContactsApp->GetFontHeightOffset()), groupsName);
2204 pLabelGroupName->SetName(GROUP_LABEL_VALUE);
2205 pLabelGroupName->AddTouchEventListener(*this);
2206 pLabelGroupName->SetTextConfig(pContactsApp->GetFontSize(), LABEL_TEXT_STYLE_NORMAL);
2207 pLabelGroupName->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2209 pGroupStyle->AddControl(pLabelGroupName);
2214 Tizen::Ui::Controls::TableViewItem*
2215 ContactEditorForm::GetBirthdayField(int itemWidth)
2217 DateTime birthdayDate;
2218 EditDate* pBirthday = new (std::nothrow) EditDate();
2219 pBirthday->Construct(Point(W_TITLE_LABEL, 0));
2220 pBirthday->AddDateChangeEventListener(*this);
2222 __pPresentationModel->GetBirthday(birthdayDate);
2223 pBirthday->SetDate(birthdayDate);
2225 DateTime currentDate;
2226 Tizen::System::SystemTime::GetCurrentTime(currentDate);
2229 pBirthday->GetYearRange(min, max);
2230 max = currentDate.GetYear();
2231 pBirthday->SetYearRange(max - BIRTHDAY_MIN_YEAR_DIFF, max + BIRTHDAY_MAX_YEAR_DIFF);
2233 if (birthdayDate.GetYear() < (currentDate.GetYear() - BIRTHDAY_MIN_YEAR_DIFF))
2235 birthdayDate.SetValue(currentDate.GetYear() - BIRTHDAY_MIN_YEAR_DIFF, birthdayDate.GetMonth(), birthdayDate.GetDay());
2236 __pPresentationModel->SetBirthday(birthdayDate);
2239 TableViewItem* pBirthdayItem = new (std::nothrow) TableViewItem();
2240 pBirthdayItem->Construct(Dimension(itemWidth, H_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL);
2241 pBirthdayItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
2242 pBirthdayItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
2244 Label* pLabelTitle = new (std::nothrow) Label();
2245 pLabelTitle->Construct(Rectangle(0, 0, W_TITLE_LABEL, pBirthdayItem->GetHeight()), L"");
2246 pLabelTitle->SetText(ResourceManager::GetString(L"IDS_PB_BODY_BIRTHDAY"));
2247 pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2248 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
2249 pLabelTitle->SetTextConfig(FONT_SIZE_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
2251 pBirthdayItem->AddControl(pLabelTitle);
2252 pBirthdayItem->AddControl(pBirthday);
2254 Button* pClearButton = new (std::nothrow) Button();
2255 pClearButton->Construct(Rectangle(itemWidth - (H_BUTTON * 2) - H_BUTTON/2, (pBirthdayItem->GetHeight() - H_BUTTON) / 2, H_BUTTON, H_BUTTON));
2256 pClearButton->SetActionId(IDA_BUTTON_BIRTHDAY_CLEAR);
2257 pClearButton->AddActionEventListener(*this);
2259 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_RESET_NORMAL);
2260 if (pBitmap != null)
2262 pClearButton->SetNormalBitmap(Point(0, 0), *pBitmap);
2265 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_RESET_PRESSED);
2266 if (pBitmap != null)
2268 pClearButton->SetPressedBitmap(Point(0, 0), *pBitmap);
2272 pBirthdayItem->AddControl(pClearButton);
2274 Button *pButtonDelete = new (std::nothrow) Button();
2275 pButtonDelete->Construct(Rectangle(itemWidth - H_BUTTON - W_ITEM_GAP, (H_ITEM - H_BUTTON) / 2, H_BUTTON, H_BUTTON));
2277 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS);
2278 if (pBitmap != null)
2280 pButtonDelete->SetNormalBitmap(Point(0, 0), *pBitmap);
2284 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS_PRESSED);
2285 if (pBitmap != null)
2287 pButtonDelete->SetPressedBitmap(Point(0, 0), *pBitmap);
2291 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_NORMAL);
2292 if (pBitmap != null)
2294 pButtonDelete->SetNormalBackgroundBitmap(*pBitmap);
2298 pBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_PRESSED);
2299 if (pBitmap != null)
2301 pButtonDelete->SetPressedBackgroundBitmap(*pBitmap);
2305 pButtonDelete->SetActionId(IDA_BUTTON_BIRTHDAY_DELETE);
2306 pButtonDelete->AddActionEventListener(*this);
2308 pBirthdayItem->AddControl(pButtonDelete);
2310 pBirthdayItem->SetIndividualSelectionEnabled(pBirthday, true);
2311 pBirthdayItem->SetIndividualSelectionEnabled(pClearButton, true);
2312 pBirthdayItem->SetIndividualSelectionEnabled(pButtonDelete, true);
2314 return pBirthdayItem;
2317 Tizen::Ui::Controls::TableViewItem*
2318 ContactEditorForm::GetNoteField(int itemWidth)
2320 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2322 if (__pNoteFieldItem != null)
2324 return __pNoteFieldItem;
2327 __pNoteFieldItem = new (std::nothrow) TableViewItem();
2328 __pNoteFieldItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight() + Y_EDIT_FIELD_GAP + H_EXPANDABLE_EDIT_AREA_EXTENDED), TABLE_VIEW_ANNEX_STYLE_NORMAL);
2329 __pNoteFieldItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
2330 __pNoteFieldItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
2333 Label* pNoteTitle = new (std::nothrow) Label();
2334 pNoteTitle->Construct(Rectangle(0, 0, itemWidth, H_LABEL), ResourceManager::GetString(L"IDS_PB_BODY_NOTE"));
2335 pNoteTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2336 pNoteTitle->SetTextColor(COLOR_ITEM_TITLE);
2337 pNoteTitle->SetTextConfig(FONT_SIZE_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
2338 __pNoteFieldItem->AddControl(pNoteTitle);
2340 ExpandableEditArea* pNoteEditArea = new (std::nothrow) ExpandableEditArea();
2341 pNoteEditArea->Construct(Rectangle(Y_EDIT_FIELD_GAP, H_LABEL, itemWidth - H_EDIT_FIELD_GAP, pContactsApp->GetListItemSingleLineHeight() - H_LABEL + Y_EDIT_FIELD_GAP + H_EXPANDABLE_EDIT_AREA_EXTENDED), EXPANDABLE_EDIT_AREA_STYLE_NORMAL, EXPANDABLE_EDIT_AREA_TITLE_STYLE_NONE);
2342 pNoteEditArea->SetTitleText(ResourceManager::GetString(L"IDS_PB_BODY_NOTE"));
2343 pNoteEditArea->SetText(__pPresentationModel->GetValue(DETAIL_PROPERTY_NOTE));
2344 pNoteEditArea->AddExpandableEditAreaEventListener(*this);
2345 pNoteEditArea->AddKeypadEventListener(*this);
2346 pNoteEditArea->AddFocusEventListener(*this);
2347 pNoteEditArea->SetTextSize(pContactsApp->GetFontSize());
2348 pNoteEditArea->AddTextEventListener(*this);
2350 __pNoteFieldItem->AddControl(pNoteEditArea);
2351 __pNoteFieldItem->SetIndividualSelectionEnabled(pNoteEditArea, true);
2353 return __pNoteFieldItem;
2356 Tizen::Ui::Controls::TableViewItem*
2357 ContactEditorForm::GetRingtoneField(int itemWidth)
2359 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2361 TableViewItem* pRingtoneItem = new (std::nothrow) TableViewItem();
2362 pRingtoneItem->Construct(Dimension(itemWidth, H_DOUBLE_LINE_ITEM + pContactsApp->GetFontHeightOffset()), TABLE_VIEW_ANNEX_STYLE_NORMAL);
2363 pRingtoneItem->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
2364 pRingtoneItem->AddKeyEventListener(*this);
2366 Panel* pGroupStyle = new (std::nothrow) Panel();
2367 pGroupStyle->Construct(Rectangle(0, 0, itemWidth , H_DOUBLE_LINE_ITEM + pContactsApp->GetFontHeightOffset()), GROUP_STYLE_NONE);
2368 pGroupStyle->SetName(GROUP_STYLE_PANEL);
2369 pGroupStyle->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
2370 pGroupStyle->AddTouchEventListener(*this);
2371 pRingtoneItem->AddControl(pGroupStyle);
2373 Label* pLabelTitle = new (std::nothrow) Label();
2374 pLabelTitle->Construct(Rectangle(0, H_GROUP_RINGTONE_TITLE_GAP, itemWidth, H_GROUP_RINGTONE_TITLE_LABEL), ResourceManager::GetString(L"IDS_PB_BODY_RINGTONE"));
2375 pLabelTitle->SetName(GROUP_LABEL_TITLE);
2376 pLabelTitle->AddTouchEventListener(*this);
2377 pLabelTitle->SetTextConfig(FONT_SIZE_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
2378 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
2379 pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2381 pGroupStyle->AddControl(pLabelTitle);
2383 String ringtoneName = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
2387 ringtoneName.LastIndexOf(L"/", ringtoneName.GetLength() - 1, index);
2391 ringtoneName.SubString(index + 1, trimmedPath);
2394 Label* pLabelRingToneName = new (std::nothrow) Label();
2395 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);
2396 pLabelRingToneName->SetName(GROUP_LABEL_VALUE);
2397 pLabelRingToneName->AddTouchEventListener(*this);
2398 pLabelRingToneName->SetTextConfig(pContactsApp->GetFontSize(), LABEL_TEXT_STYLE_NORMAL);
2399 pLabelRingToneName->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2400 pGroupStyle->AddControl(pLabelRingToneName);
2402 Button* pClearButton = new (std::nothrow) Button();
2403 pClearButton->Construct(Rectangle(itemWidth - X_REFRESH_BUTTON_MARGIN, (pRingtoneItem->GetHeight() - H_ICON_BUTTON) / 2, H_ICON_BUTTON, H_ICON_BUTTON));
2404 pClearButton->SetActionId(IDA_BUTTON_RINGTONE_CLEAR);
2405 pClearButton->AddActionEventListener(*this);
2407 Bitmap* pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_NORMAL);
2410 pClearButton->SetNormalBitmap(Point(0, 0), *pReset);
2413 pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_PRESSED);
2416 pClearButton->SetPressedBitmap(Point(0, 0), *pReset);
2420 pRingtoneItem->AddControl(pClearButton);
2421 pRingtoneItem->SetIndividualSelectionEnabled(pClearButton, true);
2423 return pRingtoneItem;
2426 Tizen::Ui::Controls::TableViewItem*
2427 ContactEditorForm::GetMoreInformationField(int itemWidth)
2429 TableViewItem* pMoreInformationItem = new (std::nothrow) TableViewItem();
2430 pMoreInformationItem->Construct(Dimension(itemWidth, H_DESCRIPTION_CONTAINER));
2431 pMoreInformationItem->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
2432 pMoreInformationItem->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
2434 Panel* pPanel = new (std::nothrow) Panel();
2435 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));
2436 pPanel->SetBackgroundColor(Color(COLOR_TABLE_VIEW_BG));
2438 pMoreInformationItem->AddControl(pPanel);
2440 Button* pButtonMoreInformation = new (std::nothrow) Button();
2441 pButtonMoreInformation->Construct(Rectangle(X_MORE_INFORMATION_BUTTON, Y_MORE_INFORMATION_BUTTON, itemWidth - (X_MORE_INFORMATION_BUTTON * 2), H_BUTTON));
2442 pButtonMoreInformation->SetText(ResourceManager::GetString(L"IDS_KA_BODY_MORE_INFORMATION"));
2443 pButtonMoreInformation->SetActionId(IDA_BUTTON_MORE_INFO);
2444 pButtonMoreInformation->AddActionEventListener(*this);
2446 pPanel->AddControl(pButtonMoreInformation);
2448 return pMoreInformationItem;
2451 Tizen::Ui::Controls::TableViewItem*
2452 ContactEditorForm::GetDefaultPhoneNumberItem(int itemWidth)
2454 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2456 TableViewItem* pDefaultPhoneNumberItem = new (std::nothrow) TableViewItem();
2457 pDefaultPhoneNumberItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight()));
2458 pDefaultPhoneNumberItem->SetBackgroundColor(Color(0), TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
2460 Button* pButtonDefaultNumber = new (std::nothrow) Button();
2461 pButtonDefaultNumber->Construct(Rectangle(X_MORE_INFORMATION_BUTTON, Y_DEFAULT_NUMBER_BUTTON, itemWidth - (X_MORE_INFORMATION_BUTTON * 2), H_BUTTON));
2462 pButtonDefaultNumber->SetText(ResourceManager::GetString(L"IDS_PB_BODY_MARK_AS_DEFAULT_NUMBER"));
2463 pButtonDefaultNumber->SetActionId(IDA_BUTTON_DEFAULT_PHONE_NUMBER);
2464 pButtonDefaultNumber->AddActionEventListener(*this);
2466 pDefaultPhoneNumberItem->AddControl(pButtonDefaultNumber);
2467 pDefaultPhoneNumberItem->SetIndividualSelectionEnabled(pButtonDefaultNumber, true);
2469 return pDefaultPhoneNumberItem;
2473 ContactEditorForm::DeleteInputField(int groupIndex, int itemIndex, int isUpdating)
2475 result r = E_SUCCESS;
2476 ArrayList* pFieldList = null;
2480 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
2482 pFieldList = __pPhoneNumberFieldItem;
2483 __pPresentationModel->SetPhoneNumber(DETAIL_PHONENUMBER_TYPE_NONE, L"", itemIndex); //phoneNumberType doesn't matter
2486 case TABLE_VIEW_EMAIL_FIELD_INDEX:
2488 pFieldList = __pEmailFieldItem;
2489 __pPresentationModel->SetEmail(DETAIL_EMAIL_TYPE_NONE, L"", itemIndex);
2492 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
2494 pFieldList = __pAddressFieldItem;
2495 __pPresentationModel->SetAddress(DETAIL_ADDRESS_TYPE_NONE, L"", itemIndex);
2498 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
2500 pFieldList = __pImAddressFieldItem;
2501 __pPresentationModel->SetImAddress(DETAIL_IM_ADDRESS_TYPE_NONE, L"", itemIndex);
2504 case TABLE_VIEW_URL_FIELD_INDEX:
2506 pFieldList = __pUrlFieldItem;
2507 __pPresentationModel->SetUrl(DETAIL_URL_TYPE_NONE, L"", itemIndex);
2514 TryReturn(pFieldList != null, E_FAILURE, "[E_FAILURE] Unable to delete the item.")
2516 __pDeletedItemList->Add(pFieldList->GetAt(itemIndex));
2518 r = pFieldList->RemoveAt(itemIndex, false);
2520 if (__previousGroupIndex == groupIndex && __previousItemIndex == itemIndex)
2522 __previousGroupIndex = -1;
2523 __previousItemIndex = -1;
2525 if (isUpdating == false)
2527 __pTableView->RefreshItem(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
2530 Rectangle clientBounds = GetClientAreaBounds();
2531 __pTableView->SetSize(clientBounds.width, clientBounds.height);
2533 for (int i = itemIndex; i < pFieldList->GetCount(); i++)
2535 TableViewItem* pItem = static_cast<TableViewItem *>(pFieldList->GetAt(i));
2542 EditField* pInputField = static_cast<EditField*>(pItem->GetControl(0));
2543 if (pInputField == null)
2548 result r = Integer::Decode(pInputField->GetName(), parsedIndex);
2549 if (r == E_NUM_FORMAT)
2553 pInputField->SetName(Integer::ToString(parsedIndex - 1));
2555 Button* pTypeButton = static_cast<Button*>(pItem->GetControl(1));
2556 if (pTypeButton == null)
2561 r = Integer::Decode(pTypeButton->GetName(), parsedIndex);
2562 if (r == E_NUM_FORMAT)
2566 pTypeButton->SetName(Integer::ToString(parsedIndex - 1));
2568 Button* pDeleteButton = static_cast<Button *>(pItem->GetControl(2));
2569 if (pDeleteButton == null)
2573 pDeleteButton->SetActionId(pDeleteButton->GetActionId() - 1);
2576 SaveContactData(false);
2577 SetSaveButtonEnabled(IsSaveContactValid());
2579 if (groupIndex == TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX)
2581 if (itemIndex == __pPresentationModel->GetDefaultNumberIndex())
2583 SetAsDefaultPhoneNumber(0);
2585 else if (itemIndex < __pPresentationModel->GetDefaultNumberIndex())
2587 SetAsDefaultPhoneNumber(__pPresentationModel->GetDefaultNumberIndex() - 1);
2591 if (__isDefaultPhoneNumberButtonEnabled == true && __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) < 2)
2593 if (isUpdating == false)
2595 __pTableView->RefreshItem(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX, __pTableView->GetItemCountAt(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX) - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
2597 __isDefaultPhoneNumberButtonEnabled = false;
2604 ContactEditorForm::SetThumbnailControls(Tizen::Ui::Controls::TableViewItem& item, bool isUpdated)
2606 Label* pLabelThumbnail = null;
2607 Button* pButtonAdd = null;
2608 Button* pButtonDelete = null;
2610 if (isUpdated == false)
2612 int itemWidth = GetBounds().width;
2614 pLabelThumbnail = new (std::nothrow) Label();
2615 pLabelThumbnail->Construct(Rectangle((itemWidth - W_THUMBNAIL) / 2, H_THUMBNAIL_DELETE_BUTTON_GAP + Y_EDIT_FIELD_GAP, W_THUMBNAIL, W_THUMBNAIL), L"");
2617 item.AddControl(pLabelThumbnail);
2619 Bitmap* pBitmapItem = null;
2620 Bitmap* pBitmapItemPressed = null;
2622 pButtonAdd = new (std::nothrow) Button();
2623 pButtonAdd->Construct(Rectangle(pLabelThumbnail->GetX() + ((pLabelThumbnail->GetWidth() - H_BUTTON) / 2), pLabelThumbnail->GetY() + ((pLabelThumbnail->GetHeight() - H_BUTTON) / 2), H_BUTTON, H_BUTTON));
2624 pButtonAdd->SetActionId(IDA_BUTTON_THUMBNAIL_ADD);
2625 pButtonAdd->AddActionEventListener(*this);
2627 pBitmapItem = ResourceManager::GetBitmapN(IDB_BUTTON_ADD);
2628 pBitmapItemPressed = ResourceManager::GetBitmapN(IDB_BUTTON_ADD_PRESSED);
2630 if (pBitmapItem != null)
2632 pButtonAdd->SetNormalBackgroundBitmap(*pBitmapItem);
2635 if (pBitmapItemPressed != null)
2637 pButtonAdd->SetPressedBackgroundBitmap(*pBitmapItemPressed);
2638 delete pBitmapItemPressed;
2640 item.AddControl(pButtonAdd);
2641 item.SetIndividualSelectionEnabled(pButtonAdd, true);
2643 pButtonDelete = new (std::nothrow) Button();
2644 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));
2645 pButtonDelete->SetActionId(IDA_BUTTON_THUMBNAIL_DELETE);
2646 pButtonDelete->AddActionEventListener(*this);
2648 pBitmapItem = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS);
2649 pBitmapItemPressed = ResourceManager::GetBitmapN(IDB_BUTTON_MINUS_PRESSED);
2651 if (pBitmapItem != null)
2653 pButtonDelete->SetNormalBitmap(Point(0, 0), *pBitmapItem);
2656 if (pBitmapItemPressed != null)
2658 pButtonDelete->SetPressedBitmap(Point(0, 0), *pBitmapItemPressed);
2659 delete pBitmapItemPressed;
2662 pBitmapItem = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_NORMAL);
2663 pBitmapItemPressed = ResourceManager::GetBitmapN(IDB_BUTTON_DELETE_PRESSED);
2665 if (pBitmapItem != null)
2667 pButtonDelete->SetNormalBackgroundBitmap(*pBitmapItem);
2670 if (pBitmapItemPressed != null)
2672 pButtonDelete->SetPressedBackgroundBitmap(*pBitmapItemPressed);
2673 delete pBitmapItemPressed;
2675 item.AddControl(pButtonDelete);
2676 item.SetIndividualSelectionEnabled(pButtonDelete, true);
2678 Button* pButtonCamera = new (std::nothrow) Button();
2679 pButtonCamera->Construct(Rectangle(pLabelThumbnail->GetX() + pLabelThumbnail->GetWidth(), pLabelThumbnail->GetY() + pLabelThumbnail->GetHeight() - H_BUTTON, H_BUTTON, H_BUTTON));
2680 pButtonCamera->SetActionId(IDA_BUTTON_CAMERA);
2681 pButtonCamera->AddActionEventListener(*this);
2683 pBitmapItem = ResourceManager::GetBitmapN(IDB_BUTTON_CAMERA);
2684 pBitmapItemPressed = ResourceManager::GetBitmapN(IDB_BUTTON_CAMERA_PRESSED);
2685 if (pBitmapItem != null)
2687 pButtonCamera->SetNormalBackgroundBitmap(*pBitmapItem);
2690 if (pBitmapItemPressed != null)
2692 pButtonCamera->SetPressedBackgroundBitmap(*pBitmapItemPressed);
2693 delete pBitmapItemPressed;
2696 item.AddControl(pButtonCamera);
2697 item.SetIndividualSelectionEnabled(pButtonCamera, true);
2701 pLabelThumbnail = static_cast<Label*>(item.GetControl(0));
2702 TryReturnVoid(pLabelThumbnail != null, "[E_FAILURE] Unable to get a thumbnail control.");
2704 pButtonAdd = static_cast<Button*>(item.GetControl(1));
2705 TryReturnVoid(pButtonAdd != null, "[E_FAILURE] Unable to get a button.");
2707 pButtonDelete = static_cast<Button*>(item.GetControl(2));
2708 TryReturnVoid(pButtonDelete != null, "[E_FAILURE] Unable to get a button.");
2711 Bitmap* pThumbnail = null;
2712 String thumbnailPath = __pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL);
2714 if (thumbnailPath.IsEmpty() == false)
2716 ImageBuffer thumbnailImageBuffer;
2717 result r = thumbnailImageBuffer.Construct(thumbnailPath);
2720 pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);
2722 if (pThumbnail != null)
2724 pThumbnail->SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
2725 pThumbnail->Scale(Dimension(W_THUMBNAIL, W_THUMBNAIL));
2726 pLabelThumbnail->SetBackgroundBitmap(*pThumbnail);
2728 pButtonAdd->SetShowState(false);
2729 pButtonAdd->SetEnabled(false);
2730 pButtonDelete->SetShowState(true);
2734 pThumbnail = ResourceManager::GetBitmapN(IDB_THUMBNAIL_BACKGROUND);
2735 if (pThumbnail != null)
2737 pLabelThumbnail->SetBackgroundBitmap(*pThumbnail);
2738 pButtonAdd->SetShowState(true);
2739 pButtonAdd->SetEnabled(true);
2740 pButtonDelete->SetShowState(false);
2748 ContactEditorForm::AddHorizontalDivider(Tizen::Ui::Controls::TableViewItem* pItem, int positionY, int width)
2750 Label* pDivider = new (std::nothrow) Label();
2751 pDivider->Construct(Rectangle(0, positionY, width, H_DIVIDER), L"");
2752 pDivider->SetBackgroundColor(Color(COLOR_DIVIDER));
2753 pDivider->SetEnabled(false);
2755 pItem->AddControl(pDivider);
2759 ContactEditorForm::AddVerticalDivider(Tizen::Ui::Controls::TableViewItem* pItem, int positionX, int positionY)
2761 ContactsApp *pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
2763 Label* pDivider = new (std::nothrow) Label();
2764 pDivider->Construct(Rectangle(positionX, positionY, W_DIVIDER, pContactsApp->GetListItemSingleLineHeight()), L"");
2765 pDivider->SetBackgroundColor(Color(COLOR_DIVIDER));
2766 pDivider->SetEnabled(false);
2768 pItem->AddControl(pDivider);
2772 ContactEditorForm::SetAsDefaultPhoneNumber(int index, bool scrollToItem)
2774 result r = E_SUCCESS;
2775 TableViewItem* pItem = null;
2776 EditField* pEditField = null;
2778 pItem = static_cast<TableViewItem *>(__pPhoneNumberFieldItem->GetAt(index));
2785 pEditField = static_cast<EditField *>(pItem->GetControl(0));
2786 if (pEditField == null)
2792 __pPresentationModel->SetValue(DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER, L"", index);
2794 if (pEditField->IsVisible() == false && scrollToItem == true)
2796 __pTableView->ScrollToItem(TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX, index);
2798 pEditField->Invalidate(true);
2805 ContactEditorForm::ChangeNameFieldStatus(void)
2807 result r = E_SUCCESS;
2809 r = SaveNameFields();
2811 __isExpandable = (__isExpandable == true) ? false : true;
2817 ContactEditorForm::SaveContactData(bool isSaved)
2819 result r = E_SUCCESS;
2821 if (isSaved == true)
2823 if (CommonUtil::isMemoryAvailable() == false)
2825 CommonUtil::showMemoryFullMessageBox();
2830 r = SaveNameFields();
2832 for (int i = 0; i < __pPhoneNumberFieldItem->GetCount(); i++)
2835 TableViewItem* pItem = static_cast<TableViewItem *>(__pPhoneNumberFieldItem->GetAt(i));
2842 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
2843 if (pEditField == null)
2849 String phoneNumberString(pEditField->GetText());
2850 String phoneNumberTypeString(pItem->GetName());
2851 int phoneNumberType;
2852 phoneNumberString.Trim();
2855 for (int i = 0; i < phoneNumberString.GetLength(); i++)
2857 phoneNumberString.GetCharAt(i, ch);
2859 if(ch == '+' && i == 0)
2863 if((ch == ',' || ch == ';' || ch == 'p') && i == 0)
2868 else if ((ch < '0' || ch > '9') && (ch != '*') && (ch != '#') && (ch != ',') && (ch != ';') && (ch != 'p'))
2879 if (isSaved == true && phoneNumberString.GetLength() > 0 && r != E_SUCCESS)
2882 MessageBox invalidNumberMessage;
2883 invalidNumberMessage.Construct(L"", ResourceManager::GetString(L"IDS_PB_BODY_INVALID_NUMBER"), MSGBOX_STYLE_OK, MESSAGE_BOX_TIMEOUT_MS);
2884 invalidNumberMessage.ShowAndWait(modalResult);
2889 Integer::Parse(phoneNumberTypeString, phoneNumberType);
2891 __pPresentationModel->SetPhoneNumber((DetailPhoneNumberType)phoneNumberType, phoneNumberString, i);
2894 for (int i = 0; i < __pEmailFieldItem->GetCount(); i++)
2896 TableViewItem* pItem = static_cast<TableViewItem *>(__pEmailFieldItem->GetAt(i));
2903 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
2904 if (pEditField == null)
2910 String emailString(pEditField->GetText());
2911 String remainingString;
2912 String emailTypeString(pItem->GetName());
2916 Integer::Parse(emailTypeString, emailType);
2918 r = __pPresentationModel->SetEmail((DetailEmailType)emailType, emailString, i);
2920 if (isSaved == true && r == E_SUCCESS)
2922 if(emailString.GetLength() > 0)
2924 bool isValidEmail = ValidateEmailAddress(emailString);
2925 if (isValidEmail != true)
2928 MessageBox invalidEmailMessage;
2929 invalidEmailMessage.Construct(L"", ResourceManager::GetString(L"IDS_PB_POP_INVALID_EMAIL_ADDRESS"), MSGBOX_STYLE_OK, MESSAGE_BOX_TIMEOUT_MS);
2930 invalidEmailMessage.ShowAndWait(modalResult);
2931 pEditField->ShowKeypad();
2939 for (int i = 0; i < __pAddressFieldItem->GetCount(); i++)
2941 TableViewItem* pItem = static_cast<TableViewItem *>(__pAddressFieldItem->GetAt(i));
2948 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
2949 if (pEditField == null)
2955 String addressString(pEditField->GetText());
2956 String addressTypeString(pItem->GetName());
2959 addressString.Trim();
2960 Integer::Parse(addressTypeString, addressType);
2962 __pPresentationModel->SetAddress((DetailAddressType)addressType, addressString, i);
2965 for (int i = 0; i < __pImAddressFieldItem->GetCount(); i++)
2967 TableViewItem* pItem = static_cast<TableViewItem *>(__pImAddressFieldItem->GetAt(i));
2974 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
2975 if (pEditField == null)
2981 String addressString(pEditField->GetText());
2982 String addressTypeString(pItem->GetName());
2985 addressString.Trim();
2986 Integer::Parse(addressTypeString, addressType);
2988 __pPresentationModel->SetImAddress((DetailImAddressType)addressType, addressString, i);
2991 for (int i = 0; i < __pUrlFieldItem->GetCount(); i++)
2993 TableViewItem* pItem = static_cast<TableViewItem *>(__pUrlFieldItem->GetAt(i));
3000 EditField* pEditField = static_cast<EditField *>(pItem->GetControl(0));
3001 if (pEditField == null)
3007 String urlString(pEditField->GetText());
3008 String urlTypeString(pItem->GetName());
3012 Integer::Parse(urlTypeString, urlType);
3014 __pPresentationModel->SetUrl((DetailUrlType)urlType, urlString, i);
3017 if (__pNoteFieldItem != null)
3020 ExpandableEditArea* pNoteEditArea = static_cast<ExpandableEditArea *>(__pNoteFieldItem->GetControl(1));
3021 if (pNoteEditArea != null)
3023 noteString.Append(pNoteEditArea->GetText());
3026 __pPresentationModel->SetValue(DETAIL_PROPERTY_NOTE, noteString);
3029 if (isSaved == true)
3031 r = __pPresentationModel->AddAddressBook();
3037 ContactEditorForm::SaveNameFields(void)
3039 result r = E_SUCCESS;
3041 if (__pNameFieldItem == null)
3046 if (__isExpandable == true)
3048 EditField* pFirstName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_FIRST_NAME"), false));
3049 if (pFirstName == null)
3053 __pPresentationModel->SetValue(DETAIL_PROPERTY_FIRST_NAME, pFirstName->GetText());
3055 EditField* pLastName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_LAST_NAME"), false));
3056 if (pLastName == null)
3061 __pPresentationModel->SetValue(DETAIL_PROPERTY_LAST_NAME, pLastName->GetText());
3063 EditField* pMiddleName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_MIDDLE_NAME"), false));
3064 if (pMiddleName == null)
3068 __pPresentationModel->SetValue(DETAIL_PROPERTY_MIDDLE_NAME, pMiddleName->GetText());
3070 EditField* pSuffix = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_SUFFIX"), false));
3071 if (pSuffix == null)
3075 __pPresentationModel->SetValue(DETAIL_PROPERTY_NAME_SUFFIX, pSuffix->GetText());
3077 EditField* pNickName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_NICKNAME"), false));
3078 if (pNickName == null)
3082 __pPresentationModel->SetValue(DETAIL_PROPERTY_NICK_NAME, pNickName->GetText());
3084 EditField* pCompanyName = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_COMPANY"), false));
3085 if (pCompanyName == null)
3089 __pPresentationModel->SetValue(DETAIL_PROPERTY_COMPANY, pCompanyName->GetText());
3091 if (__isJobTitleEnabled == true)
3093 EditField* pJobTitle = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_JOB_TITLE"), false));
3094 if (pJobTitle == null)
3098 __pPresentationModel->SetValue(DETAIL_PROPERTY_JOB_TITLE, pJobTitle->GetText());
3101 if (__isDepartmentEnabled == true)
3103 EditField* pDepartment = static_cast<EditField *>(__pNameFieldItem->GetControl(ResourceManager::GetString(L"IDS_PB_BODY_DEPARTMENT"), false));
3104 if (pDepartment == null)
3108 __pPresentationModel->SetValue(DETAIL_PROPERTY_DEPARTMENT, pDepartment->GetText());
3113 EditField* pName = static_cast<EditField *>(__pNameFieldItem->GetControl(Integer::ToString(IDA_INPUT_FIELD_DISPLAY_NAME), false));
3119 String firstName = L"";
3120 String lastName = L"";
3121 String middleName = L"";
3122 String suffix = L"";
3124 int delimeterIndex = -1;
3125 int delimcommaIndex = -1;
3127 String displayName(pName->GetText());
3128 if (displayName != __fullName)
3131 if (!displayName.IsEmpty())
3133 displayName.IndexOf(DELIMITER_COMMA, 0, delimcommaIndex);
3134 if (delimcommaIndex >= 0)
3136 displayName.SubString(delimcommaIndex + 1, displayName.GetLength() - (delimcommaIndex + 1), suffix);
3137 displayName.SetLength(delimcommaIndex);
3141 if (!displayName.IsEmpty())
3143 delimeterIndex = -1;
3144 displayName.IndexOf(CHARACTER_SPACE, 0, delimeterIndex);
3145 if (delimeterIndex < 0)
3147 firstName.Append(displayName);
3151 displayName.SubString(0, delimeterIndex++, firstName);
3152 displayName.SubString(delimeterIndex, displayName.GetLength() - delimeterIndex, displayName);
3154 delimeterIndex = -1;
3157 if (!displayName.IsEmpty())
3159 displayName.IndexOf(CHARACTER_SPACE, 0, delimeterIndex);
3160 if (delimeterIndex < 0)
3162 lastName.Append(displayName);
3166 displayName.SubString(0, delimeterIndex, middleName);
3167 displayName.SubString(delimeterIndex + 1, displayName.GetLength() - (delimeterIndex + 1), lastName);
3173 __pPresentationModel->SetValue(DETAIL_PROPERTY_FIRST_NAME, firstName);
3174 __pPresentationModel->SetValue(DETAIL_PROPERTY_MIDDLE_NAME, middleName);
3175 __pPresentationModel->SetValue(DETAIL_PROPERTY_LAST_NAME, lastName);
3176 __pPresentationModel->SetValue(DETAIL_PROPERTY_NAME_SUFFIX, suffix);
3178 else if (displayName.IsEmpty() == true)
3180 __pPresentationModel->SetValue(DETAIL_PROPERTY_FIRST_NAME, firstName);
3181 __pPresentationModel->SetValue(DETAIL_PROPERTY_MIDDLE_NAME, middleName);
3182 __pPresentationModel->SetValue(DETAIL_PROPERTY_LAST_NAME, lastName);
3183 __pPresentationModel->SetValue(DETAIL_PROPERTY_NAME_SUFFIX, suffix);
3191 ContactEditorForm::IsSaveContactValid(void)
3193 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_FIRST_NAME).IsEmpty() == false)
3198 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_LAST_NAME).IsEmpty() == false)
3203 for (int i = 0; i < __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER); i++)
3205 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, i).IsEmpty() == false)
3211 for (int i = 0; i < __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_EMAIL); i++)
3213 if (__pPresentationModel->GetValue(DETAIL_PROPERTY_EMAIL, i).IsEmpty() == false)
3223 ContactEditorForm::SetSaveButtonEnabled(bool enable)
3225 Footer* pFooter = GetFooter();
3229 pFooter->SetItemEnabled(0, true);
3233 pFooter->SetItemEnabled(0, false);
3236 pFooter->Invalidate(true);
3240 ContactEditorForm::IsMoreInformationButtonVisible(void)
3242 if (__isJobTitleEnabled == false)
3247 if (__isDepartmentEnabled == false)
3252 if (__pImAddressFieldItem->GetCount() == 0)
3257 if (__pUrlFieldItem->GetCount() == 0)
3263 if (__pPresentationModel->GetBirthday(birthday) != E_SUCCESS)
3268 if (__pNoteFieldItem == null)
3277 ContactEditorForm::OnTextValueChanged(const Tizen::Ui::Control& source)
3279 TableViewItem* pTableViewItem = static_cast<TableViewItem *>(source.GetParent());
3281 __isContactModified = true;
3283 if (pTableViewItem == null)
3288 SaveContactData(false);
3289 SetSaveButtonEnabled(IsSaveContactValid());
3291 if (__pNameFieldItem == pTableViewItem)
3296 EditField* pEditField = const_cast<EditField *>(static_cast<const EditField *>(&source));
3297 if (pEditField == null)
3302 Control* pDeleteButton = pTableViewItem->GetControl(2);
3303 if (pDeleteButton == null)
3313 Integer::Decode(pEditField->GetName(), index);
3314 groupIndex = (index & TABLE_VIEW_GROUP_INDEX_MASK) >> TABLE_VIEW_GROUP_INDEX_SHIFT;
3315 inputFlag = (index & TABLE_VIEW_INPUT_FIELD_INDEX_MASK) >> TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3316 int itemIndex = (index & TABLE_VIEW_ITEM_INDEX_MASK);
3317 itemCount = __pTableView->GetItemCountAt(groupIndex);
3319 String trimmedString = pEditField->GetText();
3320 trimmedString.Trim();
3322 if (trimmedString.IsEmpty())
3324 pDeleteButton->SetShowState(false);
3326 int Itemcount = __pTableView->GetItemCountAt(groupIndex);
3327 if (itemIndex == Itemcount - 1)
3333 __previousItemIndex = itemIndex; //if the entered text is empty store the index of the field for deletion
3334 __previousGroupIndex = groupIndex;
3337 else if (pDeleteButton->GetShowState() == false)
3339 __previousItemIndex = -1;
3340 __previousGroupIndex = -1;
3341 pDeleteButton->SetShowState(true);
3344 index |= (1 << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT);
3345 pEditField->SetName(Integer::ToString(index));
3347 if (groupIndex == TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX)
3349 if (__isDefaultPhoneNumberButtonEnabled == false && __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) > 1)
3351 __isDefaultPhoneNumberButtonEnabled = true;
3352 __pTableView->RefreshItem(groupIndex, __pTableView->GetItemCountAt(groupIndex), TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
3354 else if (itemCount > 1)
3360 ArrayList* pFieldList = null;
3363 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
3365 pFieldList = __pPhoneNumberFieldItem;
3368 case TABLE_VIEW_EMAIL_FIELD_INDEX:
3370 pFieldList = __pEmailFieldItem;
3373 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
3375 pFieldList = __pAddressFieldItem;
3378 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
3380 pFieldList = __pImAddressFieldItem;
3383 case TABLE_VIEW_URL_FIELD_INDEX:
3385 pFieldList = __pUrlFieldItem;
3392 if (pFieldList != null)
3394 TableViewItem* pItem = static_cast<TableViewItem*>(pFieldList->GetAt(pFieldList->GetCount() - 1));
3397 EditField* pInputField = static_cast<EditField*>(pItem->GetControl(0));
3399 if (pInputField != null && pInputField->GetTextLength() != 0)
3401 __pTableView->RefreshItem(groupIndex, itemCount, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
3409 __previousItemIndex = -1;
3410 __previousGroupIndex = -1;
3412 if(__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) <= 1 && __isDefaultPhoneNumberButtonEnabled == true)
3414 __isDefaultPhoneNumberButtonEnabled = false;
3415 __pTableView->RefreshItem(groupIndex, __pTableView->GetItemCountAt(groupIndex) - 1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
3417 else if(__pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER) > 1 && __isDefaultPhoneNumberButtonEnabled == false)
3419 __isDefaultPhoneNumberButtonEnabled = true;
3420 __pTableView->RefreshItem(groupIndex, __pTableView->GetItemCountAt(groupIndex), TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
3425 ContactEditorForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
3430 ContactEditorForm::ParseAppControlArgument(const Tizen::Base::String& argument, Tizen::Base::String& type, Tizen::Base::String& content)
3432 result r = E_SUCCESS;
3434 if (argument.IsEmpty() || argument.Contains(DELIMITER) == false)
3441 argument.IndexOf(DELIMITER, 0, delimiterIndex);
3442 argument.SubString(0, delimiterIndex++, type);
3443 TryReturn(r == E_SUCCESS, r, "[%s] Unable to get type", GetErrorMessage(r));
3444 argument.SubString(delimiterIndex, argument.GetLength() - delimiterIndex, content);
3445 TryReturn(r == E_SUCCESS, r, "[%s] Unable to get type", GetErrorMessage(r));
3451 ContactEditorForm::OnFocusGained(const Tizen::Ui::Control& source)
3453 __pCurrentFocusedItem = source.GetParent();
3455 if (__previousItemIndex != -1 && __previousGroupIndex != -1)
3457 const EditField* pEditField = static_cast<const EditField*>(&source);
3458 if (pEditField == null)
3467 Integer::Decode(pEditField->GetName(), index);
3468 groupIndex = (index & TABLE_VIEW_GROUP_INDEX_MASK) >> TABLE_VIEW_GROUP_INDEX_SHIFT;
3469 itemIndex = (index & TABLE_VIEW_ITEM_INDEX_MASK);
3471 if (groupIndex == __previousGroupIndex && itemIndex == __previousItemIndex)
3473 //Same item is focused. Hence not deleting it
3477 DeleteInputField(__previousGroupIndex, __previousItemIndex);
3483 ContactEditorForm::OnFocusLost(const Tizen::Ui::Control& source)
3485 if (__pCurrentFocusedItem == __pNameFieldItem)
3490 __pCurrentFocusedItem = null;
3494 ContactEditorForm::ShowDefaultPhoneNumberContextMenu(const Tizen::Graphics::Point& position)
3496 if (__pDefaultPhoneNumberContextMenu != null)
3498 delete __pDefaultPhoneNumberContextMenu;
3499 __pDefaultPhoneNumberContextMenu = null;
3502 __pDefaultPhoneNumberContextMenu = new (std::nothrow) ContextMenu();
3503 __pDefaultPhoneNumberContextMenu->Construct(position, CONTEXT_MENU_STYLE_LIST);
3504 __pDefaultPhoneNumberContextMenu->AddActionEventListener(*this);
3505 __pDefaultPhoneNumberContextMenu->SetFocusable(true);
3507 int count = __pPresentationModel->GetMultiValuesCount(DETAIL_PROPERTY_PHONE_NUMBER);
3508 int defaultPhoneNumberIndex = __pPresentationModel->GetDefaultNumberIndex();
3510 for (int i = 0; i < count; i++)
3512 String phoneNumber(__pPresentationModel->GetValue(DETAIL_PROPERTY_PHONE_NUMBER, i));
3514 if (i != defaultPhoneNumberIndex)
3516 phoneNumber.Insert(__pPresentationModel->GetType(DETAIL_PROPERTY_PHONE_NUMBER, i) + CHARACTER_SPACE, 0);
3517 __pDefaultPhoneNumberContextMenu->AddItem(phoneNumber, i);
3521 if (__pDefaultPhoneNumberContextMenu->GetItemCount() > 0)
3523 __pDefaultPhoneNumberContextMenu->Show();
3528 ContactEditorForm::ShowMoreInformationContextMenu(const Tizen::Graphics::Point& position)
3530 if (__pMoreInformationContextMenu != null)
3532 delete __pMoreInformationContextMenu;
3533 __pMoreInformationContextMenu = null;
3536 __pMoreInformationContextMenu = new (std::nothrow) ContextMenu();
3537 __pMoreInformationContextMenu->Construct(position, CONTEXT_MENU_STYLE_LIST);
3539 __pMoreInformationContextMenu->SetMaxVisibleItemsCount(6);
3540 __pMoreInformationContextMenu->AddActionEventListener(*this);
3541 __pMoreInformationContextMenu->SetFocusable(true);
3543 if (__isJobTitleEnabled == false)
3545 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_JOB_TITLE"), IDA_CONTEXT_MENU_ITEM_JOB_TITLE);
3548 if (__isDepartmentEnabled == false)
3550 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_DEPARTMENT"), IDA_CONTEXT_MENU_ITEM_DEPARTMENT);
3553 if (__pImAddressFieldItem->GetCount() == 0)
3555 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_HEADER_INSTANT_MESSENGER_ABB"), IDA_CONTEXT_MENU_ITEM_INSTANT_MESSENGER);
3558 if (__pUrlFieldItem->GetCount() == 0)
3560 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_URL"), IDA_CONTEXT_MENU_ITEM_URL);
3564 if (__pPresentationModel->GetBirthday(birthday) != E_SUCCESS)
3566 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_BIRTHDAY"), IDA_CONTEXT_MENU_ITEM_BIRTHDAY);
3569 if (__pNoteFieldItem == null)
3571 __pMoreInformationContextMenu->AddItem(ResourceManager::GetString(L"IDS_PB_BODY_NOTE"), IDA_CONTEXT_MENU_ITEM_NOTE);
3574 if (__isMoreInformationContextMenuShowing == false)
3576 __pMoreInformationContextMenu->Show();
3581 ContactEditorForm::ShowTypeContextMenu(int currentType, const Tizen::Graphics::Point& position, int itemTag)
3583 int groupIndex = (itemTag & TABLE_VIEW_GROUP_INDEX_MASK) >> TABLE_VIEW_GROUP_INDEX_SHIFT;
3585 __groupIndex = groupIndex;
3586 __itemIndex = itemTag;
3588 if (__isKeypadOpened)
3590 __isTypeContextMenuShowing = true;
3593 if (__pTypeContextMenu != null)
3595 delete __pTypeContextMenu;
3596 __pTypeContextMenu = null;
3599 __pTypeContextMenu = new (std::nothrow) ContextMenu();
3600 __pTypeContextMenu->Construct(position, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_LEFTWARD);
3601 __pTypeContextMenu->AddActionEventListener(*this);
3602 __pTypeContextMenu->SetFocusable(true);
3606 case TABLE_VIEW_PHONE_NUMBER_FIELD_INDEX:
3608 __pTypeContextMenu->SetMaxVisibleItemsCount(DETAIL_PHONENUMBER_TYPE_OTHER + 1);
3609 for (int i = 0; i <= DETAIL_PHONENUMBER_TYPE_OTHER; i++)
3611 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3612 __pTypeContextMenu->AddItem(__pPresentationModel->GetPhoneNumberTypeString((DetailPhoneNumberType)i), itemTag | index);
3616 case TABLE_VIEW_EMAIL_FIELD_INDEX:
3618 __pTypeContextMenu->SetMaxVisibleItemsCount(DETAIL_EMAIL_TYPE_OTHER + 1);
3619 for (int i = 0; i <= DETAIL_EMAIL_TYPE_OTHER; i++)
3621 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3622 __pTypeContextMenu->AddItem(__pPresentationModel->GetAddressTypeString((DetailAddressType)i), itemTag | index);
3626 case TABLE_VIEW_ADDRESS_FIELD_INDEX:
3628 __pTypeContextMenu->SetMaxVisibleItemsCount(DETAIL_ADDRESS_TYPE_OTHER + 1);
3629 for (int i = 0; i <= DETAIL_ADDRESS_TYPE_OTHER; i++)
3631 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3632 __pTypeContextMenu->AddItem(__pPresentationModel->GetAddressTypeString((DetailAddressType)i), itemTag | index);
3636 case TABLE_VIEW_IM_ADDRESS_FIELD_INDEX:
3638 __pTypeContextMenu->SetMaxVisibleItemsCount(7); // Temporary the code due to limit max count(8) by UI framework.
3639 for (int i = 0; i <= DETAIL_IM_ADDRESS_TYPE_OTHER; i++)
3641 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3642 __pTypeContextMenu->AddItem(__pPresentationModel->GetImAddressTypeString((DetailImAddressType)i), itemTag | index);
3646 case TABLE_VIEW_URL_FIELD_INDEX:
3648 __pTypeContextMenu->SetMaxVisibleItemsCount(DETAIL_URL_TYPE_OTHER + 1);
3649 for (int i = 0; i <= DETAIL_URL_TYPE_OTHER; i++)
3651 int index = i << TABLE_VIEW_INPUT_FIELD_INDEX_SHIFT;
3652 __pTypeContextMenu->AddItem(__pPresentationModel->GetUrlTypeString((DetailUrlType)i), itemTag | index);
3658 __isTypeContextMenuShowing = false;
3661 delete __pTypeContextMenu;
3662 __pTypeContextMenu = null;
3667 if (__pTypeContextMenu != null)
3669 __pTypeContextMenu->RemoveItemAt(currentType);
3670 __pTypeContextMenu->Show();
3675 ContactEditorForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3677 __isScrollOccurred = false;
3679 Panel* pPanel = null;
3681 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
3683 pPanel = static_cast<Panel*>(&(const_cast<Control&>(source)));
3685 else if (source.GetName().Equals(GROUP_LABEL_TITLE, true) || source.GetName().Equals(GROUP_LABEL_VALUE, true))
3687 pPanel = static_cast<Panel*>(source.GetParent());
3692 pPanel->SetBackgroundColor(COLOR_PRESSED);
3694 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_VALUE, true));
3695 pLabelValue->SetTextColor(Color(COLOR_ITEM_PRESSED));
3697 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_TITLE, true));
3698 pLabelTitle->SetTextColor(COLOR_ITEM_PRESSED);
3700 pPanel->Invalidate(true);
3705 ContactEditorForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3707 Panel* pPanel = null;
3709 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
3711 pPanel = static_cast<Panel*>(&(const_cast<Control&>(source)));
3713 else if (source.GetName().Equals(GROUP_LABEL_TITLE, true) || source.GetName().Equals(GROUP_LABEL_VALUE, true))
3715 pPanel = static_cast<Panel*>(source.GetParent());
3720 pPanel->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
3722 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_VALUE, true));
3723 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
3725 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_TITLE, true));
3726 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
3728 pPanel->Invalidate(true);
3731 if (__isScrollOccurred || source.Contains(currentPosition) == false)
3738 ContactEditorForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3740 Panel* pPanel = null;
3742 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
3744 pPanel = static_cast<Panel*>(&(const_cast<Control&>(source)));
3746 else if (source.GetName().Equals(GROUP_LABEL_TITLE, true) || source.GetName().Equals(GROUP_LABEL_VALUE, true))
3748 pPanel = static_cast<Panel*>(source.GetParent());
3753 pPanel->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
3755 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_VALUE, true));
3756 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
3758 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_TITLE, true));
3759 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
3761 pPanel->Invalidate(true);
3766 ContactEditorForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
3768 if (keyCode == KEY_ENTER )
3770 TableViewItem* pItem = static_cast<TableViewItem*>(&(const_cast<Control&>(source)));
3772 Panel* pPanel = static_cast<Panel*>(pItem->GetControl(0));
3779 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(1));
3781 if (pLabelValue == null)
3786 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(0));
3788 if (pLabelTitle == null)
3793 pPanel->SetBackgroundColor(COLOR_PRESSED);
3794 pLabelValue->SetTextColor(Color(COLOR_ITEM_PRESSED));
3795 pLabelTitle->SetTextColor(COLOR_ITEM_PRESSED);
3796 pPanel->Invalidate(true);
3801 ContactEditorForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
3803 if (keyCode == KEY_ENTER )
3806 TableViewItem* pItem = static_cast<TableViewItem*>(&(const_cast<Control&>(source)));
3808 Panel* pPanel = static_cast<Panel*>(pItem->GetControl(0));
3815 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(1));
3817 if (pLabelValue == null)
3822 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(0));
3824 if (pLabelTitle == null)
3829 pPanel->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
3830 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
3831 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
3832 pPanel->Invalidate(true);
3837 ContactEditorForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
3843 ContactEditorForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3848 ContactEditorForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3853 ContactEditorForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3855 Panel* pPanel = null;
3857 if (source.GetName().Equals(GROUP_STYLE_PANEL, true))
3859 pPanel = static_cast<Panel*>(&(const_cast<Control&>(source)));
3861 else if (source.GetName().Equals(GROUP_LABEL_TITLE, true) || source.GetName().Equals(GROUP_LABEL_VALUE, true))
3863 pPanel = static_cast<Panel*>(source.GetParent());
3868 pPanel->SetBackgroundColor(COLOR_THUMBNAIL_BACKGROUND);
3870 Label* pLabelValue = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_VALUE, true));
3871 pLabelValue->SetTextColor(Color(COLOR_ITEM_VALUE));
3873 Label* pLabelTitle = static_cast<Label*>(pPanel->GetControl(GROUP_LABEL_TITLE, true));
3874 pLabelTitle->SetTextColor(COLOR_ITEM_TITLE);
3876 pPanel->Invalidate(true);
3879 if (__isScrollOccurred || source.Contains(currentPosition) == false)
3886 ContactEditorForm::OnScrollEndReached (Tizen::Ui::Control &source, Tizen::Ui::Controls::ScrollEndEvent type)
3891 ContactEditorForm::OnScrollPositionChanged (Tizen::Ui::Control &source, int scrollPos)
3893 int scrollDif = scrollPos - __scrolledDistance;
3894 if (__isTypeContextMenuShowing)
3896 Point anchorPosition = __pTypeContextMenu->GetAnchorPosition();
3898 anchorPosition.y -= scrollDif;
3899 __pTypeContextMenu->SetAnchorPosition(anchorPosition);
3900 __pTypeContextMenu->Show();
3902 __isTypeContextMenuShowing = false;
3906 if (__pDefaultPhoneNumberContextMenu != null)
3908 Point anchorPosition = __pDefaultPhoneNumberContextMenu->GetAnchorPosition();
3910 anchorPosition.y -= scrollDif;
3911 __pDefaultPhoneNumberContextMenu->SetAnchorPosition(anchorPosition);
3912 __pDefaultPhoneNumberContextMenu->Show();
3915 __scrolledDistance = scrollPos;
3916 __origScrolledDistance = scrollPos;
3918 if (__isScrollOccurred == false)
3920 __isScrollOccurred = true;
3925 ContactEditorForm::OnScrollStopped (Tizen::Ui::Control &source)
3930 ContactEditorForm::OnExpandableEditAreaLineAdded (Tizen::Ui::Controls::ExpandableEditArea &source, int newLineCount)
3932 __pTableView->RefreshItem(TABLE_VIEW_NOTE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
3936 ContactEditorForm::OnExpandableEditAreaLineRemoved (Tizen::Ui::Controls::ExpandableEditArea &source, int newLineCount)
3938 __pTableView->RefreshItem(TABLE_VIEW_NOTE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
3942 ContactEditorForm::OnDateChanged(const Tizen::Ui::Control& source, int year, int month, int day)
3944 DateTime changedDate;
3946 changedDate.SetValue(year, month, day);
3947 __pPresentationModel->SetBirthday(changedDate);
3948 __isContactModified = true;
3952 ContactEditorForm::OnDateChangeCanceled(const Tizen::Ui::Control& source)
3957 ContactEditorForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
3959 AppLogDebug("ENTER");
3961 if (__pAppControl != null)
3963 delete __pAppControl;
3964 __pAppControl = null;
3967 TryReturnVoid(appControlResult == APP_CTRL_RESULT_SUCCEEDED, "[E_FAILURE] The result of an appcontrol is not succeeded.");
3968 TryReturnVoid(pExtraData != null, "[E_FAILURE] The extra data is null.");
3970 const String *pResultString = null;
3971 const ArrayList* pResultList = dynamic_cast<const ArrayList*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
3972 if (pResultList != null)
3974 pResultString = static_cast<const String*>(pResultList->GetAt(0));
3978 pResultString = static_cast<const String*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
3980 TryReturnVoid(pResultString != null, "[E_FAILURE] Unable to get file path.");
3982 if (appId.Equals(String(PROVIDER_ID_CAMERA)) && operationId.Equals(String(OPERATION_ID_CREATE_CONTENT)))
3984 __pPresentationModel->SetThumbnail(*pResultString);
3985 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
3987 if (__pFileEventManager == null)
3989 __pFileEventManager = new (std::nothrow) FileEventManager();
3990 __pFileEventManager->Construct(*this);
3992 __pFileEventManager->AddPath(*pResultString, FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_DELETE_SELF | FILE_EVENT_TYPE_MODIFY | FILE_EVENT_TYPE_MOVE_SELF);
3993 __isContactModified = true;
3995 else if (appId.Equals(String(PROVIDER_ID_GALLERY)) && operationId.Equals(String(OPERATION_ID_PICK)))
3999 ImageFormat imageFormat;
4000 result r = ImageBuffer::GetImageInfo(*pResultString, imageFormat, width, height);
4002 if (appControlResult == APP_CTRL_RESULT_FAILED || r != E_SUCCESS)
4004 int modalResult = 0;
4005 MessageBox unsupportedMessageBox;
4006 unsupportedMessageBox.Construct(L"", ResourceManager::GetString(L"IDS_MP_POP_INVALID_FILE"), MSGBOX_STYLE_NONE, 3000);
4007 unsupportedMessageBox.ShowAndWait(modalResult);
4012 __pPresentationModel->SetThumbnail(*pResultString);
4013 AppLogDebug("pResultString is %ls", pResultString->GetPointer());
4014 __isContactModified = true;
4015 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4017 if (__pFileEventManager == null)
4019 __pFileEventManager = new (std::nothrow) FileEventManager();
4020 __pFileEventManager->Construct(*this);
4022 __pFileEventManager->AddPath(*pResultString, FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_DELETE_SELF | FILE_EVENT_TYPE_MODIFY | FILE_EVENT_TYPE_MOVE_SELF);
4024 else if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
4026 __pPresentationModel->SetValue(DETAIL_PROPERTY_RINGTONE, *pResultString);
4027 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4029 if (__pFileEventManager == null)
4031 __pFileEventManager = new (std::nothrow) FileEventManager();
4032 __pFileEventManager->Construct(*this);
4034 __pFileEventManager->AddPath(*pResultString, FILE_EVENT_TYPE_DELETE | FILE_EVENT_TYPE_DELETE_SELF | FILE_EVENT_TYPE_MODIFY | FILE_EVENT_TYPE_MOVE_SELF);
4036 __isContactModified = true;
4038 AppLogDebug("EXIT");
4042 ContactEditorForm::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId)
4044 result r = E_SUCCESS;
4049 extraData.Construct();
4051 if (appId.Equals(String(PROVIDER_ID_CAMERA)) && operationId.Equals(String(OPERATION_ID_CREATE_CONTENT)))
4053 mimeType.Append(INPUT_MIME_TYPE_CAMERA);
4054 extraData.Add(new (std::nothrow) String(INPUT_KEY_ALLOW_SWITCH), new (std::nothrow) String(INPUT_VALUE_FALSE));
4056 else if (appId.Equals(String(PROVIDER_ID_GALLERY)) && operationId.Equals(String(OPERATION_ID_PICK)))
4058 mimeType.Append(INPUT_MIME_TYPE_GALLERY);
4059 extraData.Add(new (std::nothrow) String(INPUT_KEY_SELECTION_MODE), new (std::nothrow) String(INPUT_DATA_SELECTION_MODE_SINGLE));
4060 extraData.Add(new (std::nothrow) String(INPUT_KEY_IMAGEVIEWER_MODE), new (std::nothrow) String(INPUT_VALUE_IMAGEVIEWER_TYPE));
4062 else if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
4064 mimeType.Append(INPUT_MIME_TYPE_AUDIO);
4065 extraData.Add(new (std::nothrow) String(INPUT_KEY_SELECTION_MODE), new (std::nothrow) String(INPUT_DATA_SELECTION_MODE_SINGLE));
4068 __pAppControl = AppManager::FindAppControlN(appId, operationId);
4070 if (__pAppControl != null)
4072 r = __pAppControl->Start(&uri, &mimeType, &extraData, this);
4073 TryCatch(r == E_SUCCESS, , "[%s] Unable to launch app control.", GetErrorMessage(r));
4078 extraData.RemoveAll(true);
4083 extraData.RemoveAll(true);
4084 delete __pAppControl;
4085 __pAppControl = null;
4091 ContactEditorForm::OnContactsChanged(void)
4093 SceneManager* pSceneManager = SceneManager::GetInstance();
4094 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
4096 if (__isSaved == false)
4098 if (__pPresentationModel->IsContactRemoved())
4100 if (pContactsApp->GetOperationId() == OPERATION_ID_VIEW)
4102 __pPresentationModel->RemoveContactChangeListener(*this);
4106 if (__pAppControl != null)
4108 __pAppControl->Stop();
4110 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
4121 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
4122 HashMap* pReturnValue = new (std::nothrow) HashMap();
4123 pReturnValue->Construct();
4125 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), new (std::nothrow) String(Integer::ToString(__pPresentationModel->GetContactId())));
4127 result r = pAppManager->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
4128 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
4130 UiApp::GetInstance()->Terminate();
4134 ArrayList* pArg = null;
4136 if (__pPresentationModel->GetVcfPath().IsEmpty() == false)
4138 pArg = new (std::nothrow) ArrayList();
4141 String* pViewType = new (std::nothrow) String();
4142 String* pValueType = new (std::nothrow) String();
4144 pViewType->Append(VIEW_TYPE);
4145 pViewType->Append(DELIMITER);
4146 pViewType->Append(VIEW_TYPE_VALUE_CONTACT);
4148 pValueType->Append(VIEW_TYPE_CONTACT_ID);
4149 pValueType->Append(DELIMITER);
4150 pValueType->Append(Integer::ToString(__pPresentationModel->GetContactId()));
4152 pArg->Add(pViewType);
4153 pArg->Add(pValueType);
4155 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), pArg);
4162 ContactEditorForm::OnCategoriesChanged(void)
4164 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4168 ContactEditorForm::OnForeground(void)
4173 ContactEditorForm::OnBackground(void)
4175 if (__previousItemIndex != -1 && __previousGroupIndex != -1)
4177 DeleteInputField(__previousGroupIndex, __previousItemIndex);
4179 if (IsEnabled() == false)
4181 result r = SetEnabled(true);
4182 AppLogDebug("Form Enabled = %s", GetErrorMessage(r));
4188 ContactEditorForm::OnFileEventOccured(const unsigned long events, const Tizen::Base::String &path, const unsigned int eventId)
4190 String thumbnailPath = __pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL);
4191 if (thumbnailPath.Equals(path, false) == true)
4193 __pPresentationModel->SetThumbnail(L"");
4194 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4198 String ringtonePath = __pPresentationModel->GetValue(DETAIL_PROPERTY_RINGTONE);
4199 if (ringtonePath.Equals(ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT"), false) == true )
4201 __pTableView->RefreshItem(TABLE_VIEW_GROUP_RINGTONE_FIELD_INDEX, 2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4207 ContactEditorForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String &state)
4209 if (deviceType != DEVICE_TYPE_STORAGE_CARD || __pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL).IsEmpty())
4214 if (state.Equals(SD_CARD_UNMOUNTED, false) && File::IsFileExist(__pPresentationModel->GetValue(DETAIL_PROPERTY_THUMBNAIL)) == false)
4216 __pPresentationModel->SetThumbnail(L"");
4217 __pTableView->RefreshItem(TABLE_VIEW_THUMBNAIL_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4221 bool ContactEditorForm::ValidateEmailAddress(const Tizen::Base::String& emailAddress)
4225 const wchar_t* tmpChar;
4226 const wchar_t* tmpDomain;
4227 String splChars = L"([<@,;\\:\">])";
4229 for (tmpChar = emailAddress.GetPointer(), index=0; index < emailAddress.GetLength(); tmpChar++, index++)
4231 if (*tmpChar == '\"' && (tmpChar == emailAddress.GetPointer() || *(tmpChar-1) == '.' || *(tmpChar-1) == '\"'))
4235 if (*tmpChar == '\"')
4239 if (*tmpChar == '\\' && (*++tmpChar == ' '))
4243 if (*tmpChar <= ' ' || *tmpChar >= 127)
4252 if (*tmpChar == '@')
4256 if (*tmpChar != '.')
4262 if (*tmpChar == '@')
4266 if (*tmpChar <= ' ' || *tmpChar >= 127)
4270 if (splChars.IndexOf(*tmpChar, 0, index) != E_OBJ_NOT_FOUND)
4275 if (tmpChar == emailAddress.GetPointer() || *(tmpChar-1) == '.')
4280 if (!*(tmpDomain = ++tmpChar))
4286 if (*tmpChar == '.')
4288 if (tmpChar == tmpDomain || *(tmpChar-1) == '.')
4294 if (*tmpChar <= ' ' || *tmpChar >= 127)
4298 if (splChars.IndexOf(*tmpChar, 0, index) != E_OBJ_NOT_FOUND)
4302 } while (*++tmpChar);
4304 if (*(tmpChar-1) == '.')
4318 ContactEditorForm::OnSettingChanged(Tizen::Base::String &key)
4320 if(key == L"http://tizen.org/setting/locale.date_time")
4323 __pPresentationModel->GetBirthday(bday);
4325 DateTime currentDate;
4326 Tizen::System::SystemTime::GetCurrentTime(currentDate);
4328 __pTableView->RefreshItem(TABLE_VIEW_BIRTHDAY_FIELD_INDEX, 0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
4333 ContactEditorForm::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
4339 ContactEditorForm::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
4341 if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
4343 if (__pDiscardChangesPopup && __pDiscardChangesPopup->GetShowState() == true)
4345 HideDiscardChangesPopup();
4353 ContactEditorForm::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
4359 ContactEditorForm::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
4365 ContactEditorForm::ShowDiscardChangesPopup(void)
4367 if (__pDiscardChangesPopup == null)
4369 __pDiscardChangesPopup = new (std::nothrow) Popup();
4370 __pDiscardChangesPopup->Construct(false, Dimension(W_SAVE_POPUP, H_SAVE_POPUP));
4371 __pDiscardChangesPopup->SetPropagatedKeyEventListener(this);
4373 Rectangle popupClientBounds = __pDiscardChangesPopup->GetClientAreaBounds();
4375 Label* pLabel = new (std::nothrow) Label();
4376 pLabel->Construct(Rectangle(X_SAVE_LABEL, Y_SAVE_LABEL, W_SAVE_LABEL, H_SAVE_LABEL), ResourceManager::GetString(L"IDS_PB_POP_DISCARD_CHANGES_Q"));
4377 pLabel->SetTextConfig(FONT_SIZE_SAVE_CONFIRM, LABEL_TEXT_STYLE_NORMAL);
4378 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
4379 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
4381 Button* pSaveButton = new (std::nothrow) Button();
4382 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"));
4383 pSaveButton->SetTextSize(FONT_SIZE_SAVE_BUTTON);
4384 pSaveButton->SetActionId(IDA_POPUP_DISCARD_CHANGES_OK);
4385 pSaveButton->AddActionEventListener(*this);
4387 Button* pCancelButton = new (std::nothrow) Button();
4388 pCancelButton->Construct(Rectangle(X_SAVE_LABEL, Y_SAVE_BUTTON, W_SAVE_BUTTON, H_SAVE_BUTTON), ResourceManager::GetString(L"IDS_PB_SK_CANCEL"));
4389 pCancelButton->SetTextSize(FONT_SIZE_SAVE_BUTTON);
4390 pCancelButton->SetActionId(IDA_POPUP_DISCARD_CHANGES_CANCEL);
4391 pCancelButton->AddActionEventListener(*this);
4393 __pDiscardChangesPopup->AddControl(pLabel);
4394 __pDiscardChangesPopup->AddControl(pSaveButton);
4395 __pDiscardChangesPopup->AddControl(pCancelButton);
4398 __pDiscardChangesPopup->SetShowState(true);
4399 __pDiscardChangesPopup->Show();
4403 ContactEditorForm::HideDiscardChangesPopup(void)
4405 __pDiscardChangesPopup->SetShowState(false);