b386bbde4753d88e923995498897fa4991b09fd4
[apps/osp/Contacts.git] / src / CtGroupContactListForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        CtGroupContactListForm.cpp
19  * @brief       This is the implementation file for the GroupContactListForm class.
20  */
21
22 #include "CtContactListItem.h"
23 #include "CtContactsApp.h"
24 #include "CtGroupContactListForm.h"
25 #include "CtGroupContactListPresentationModel.h"
26 #include "CtResourceManager.h"
27 #include "CtSceneRegister.h"
28 #include "CtSearchListEventListener.h"
29 #include "CtSearchListItem.h"
30 #include "CtTypes.h"
31
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Base::Utility;
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
40 using namespace Tizen::Social;
41
42 static const int IDA_FOOTER_ADD_MEMBER = 11;
43 static const int IDA_MORE_REMOVE = 12;
44 static const int IDA_LIST_ELEMENT_DELETE = 40;
45 static const int IDA_LIST_ELEMENT_CALL = 41;
46 static const int IDA_LIST_ELEMENT_MESSAGE = 42;
47 static const int IDA_LIST_ELEMENT_VIDEO_CALL = 43;
48 static const int IDA_POPUP_DELETE_YES = 30;
49 static const int IDA_POPUP_DELETE_CANCEL = 31;
50 static const int IDA_POPUP_CONTACT_VALUE_CLOSE = 32;
51
52 static const wchar_t* IDB_NO_CONTENTS = L"00_Nocontents_text.png";
53
54 static const int H_SEARCHBAR = 86;
55 static const int H_GROUP_ITEM = 76;
56
57 static const int X_EMPTY_IMAGE = 220;
58 static const int Y_EMPTY_IMAGE = 300;
59 static const int W_EMPTY_IMAGE = 280;
60 static const int H_EMPTY_IMAGE = 280;
61 static const int Y_EMPTY_COMMENT = 618;
62 static const int H_EMPTY_COMMENT = 38;
63 static const int W_DELETE_BUTTON_GAP = 20;
64 static const int W_CONTACT_VALUE_POPUP = 688;
65 static const int H_CONTACT_VALUE_POPUP = 532;
66 static const int H_CONTACT_VALUE_POPUP_LIST_VIEW = 338;
67 static const int Y_CLOSE_BUTTON = 358;
68 static const int H_CLOSE_BUTTON = 74;
69 static const int W_CLOSE_BUTTON = 394;
70
71 static const int FONT_SIZE_EMPTY_COMMENT = 32;
72
73 static const unsigned int COLOR_EMPTY_COMMENT = Color32<102, 102, 102>::Value;
74 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<213, 82, 82>::Value;
75 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
76 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
77 static const unsigned int COLOR_DELETE_ELEMENT_NORMAL = Color32<208, 82, 82>::Value;
78 static const unsigned int COLOR_DELETE_ELEMENT_PRESSED = Color32<194, 71, 71>::Value;
79 static const unsigned int COLOR_DELETE_ELEMENT_TEXT = Color32<248, 246, 239>::Value;
80
81 static const int LIST_VIEW_GROUP_INDEX_SHIFT = 16;
82 static const int LIST_VIEW_MASK = 0xFFFF;
83
84 static const wchar_t* INPUT_KEY_CALL_TYPE = L"http://tizen.org/appcontrol/data/call/type";
85 static const wchar_t* INPUT_KEY_MESSAGE_TYPE = L"http://tizen.org/appcontrol/data/message/type";
86 static const wchar_t* INPUT_KEY_MESSAGE_TO = L"http://tizen.org/appcontrol/data/to";
87 static const wchar_t* INPUT_TYPE_VIDEO = L"video";
88 static const wchar_t* INPUT_TYPE_VOICE = L"voice";
89 static const wchar_t* INPUT_TYPE_SMS = L"sms";
90 static const wchar_t* INPUT_URI_TEL = L"tel:";
91
92 GroupContactListForm::GroupContactListForm(void)
93  : __pAppControl(null)
94  , __pListView(null)
95  , __pSearchListView(null)
96  , __pSearchBar(null)
97  , __pDeletePopup(null)
98  , __pMultipleContactValuePopup(null)
99  , __pEmptyImageLabel(null)
100  , __pEmptyCommentLabel(null)
101  , __pOptionMenu(null)
102  , __categoryId(0)
103  , __pContactValueListEvent(null)
104  , __pPresentationModel(null)
105  , __pSearchListEvent(null)
106  , __isCategoryUpdating(false)
107  , __sweptItemIndex(-1)
108  , __selectedIndex(-1)
109 {
110 }
111
112 GroupContactListForm::~GroupContactListForm(void)
113 {
114 }
115
116 void
117 GroupContactListForm::Initialize(void)
118 {
119         Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
120 }
121
122 result
123 GroupContactListForm::OnInitializing(void)
124 {
125         Footer* pFooter = GetFooter();
126         pFooter->AddActionEventListener(*this);
127
128         SetFormBackEventListener(this);
129         SetFormMenuEventListener(this);
130
131         __pPresentationModel = GroupContactListPresentationModel::GetInstance();
132
133         __pListView = new (std::nothrow) GroupedListView();
134         __pListView->Construct(Rectangle(0, H_SEARCHBAR, GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCHBAR), GROUPED_LIST_VIEW_STYLE_INDEXED, true, true);
135         __pListView->SetItemProvider(*this);
136         __pListView->AddFastScrollListener(*this);
137         __pListView->AddGroupedListViewItemEventListener(*this);
138         __pListView->AddTouchEventListener(*this);
139         AddControl(__pListView);
140
141         __pSearchBar = new (std::nothrow) SearchBar();
142         __pSearchBar->Construct(Rectangle(0, 0, GetClientAreaBounds().width, H_SEARCHBAR));
143         __pSearchBar->SetGuideText(ResourceManager::GetString(L"IDS_COM_BODY_SEARCH"));
144         __pSearchBar->AddSearchBarEventListener(*this);
145         __pSearchBar->AddFocusEventListener(*this);
146         __pSearchBar->AddTextEventListener(*this);
147         __pSearchBar->AddKeypadEventListener(*this);
148         __pSearchBar->SetContentAreaSize(Dimension(0, 0));
149
150         __pSearchListEvent = new (std::nothrow) SearchListEventListener(LIST_ANNEX_STYLE_NORMAL, __pPresentationModel);
151         AddControl(__pSearchBar);
152
153         __pSearchListView = new (std::nothrow) GroupedListView();
154         __pSearchListView->Construct(Rectangle(0, H_SEARCHBAR, GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCHBAR), GROUPED_LIST_VIEW_STYLE_INDEXED, true, false);
155         __pSearchListView->SetItemProvider(*__pSearchListEvent);
156         __pSearchListView->AddGroupedListViewItemEventListener(*this);
157         __pSearchListView->AddTouchEventListener(*this);
158         __pSearchListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_PB_BODY_NO_CONTACTS"));
159         __pSearchListView->SetShowState(false);
160         __pListView->AddTouchEventListener(*this);
161         AddControl(__pSearchListView);
162
163         __pEmptyImageLabel = new (std::nothrow) Label();
164         __pEmptyImageLabel->Construct(Rectangle(X_EMPTY_IMAGE, Y_EMPTY_IMAGE, W_EMPTY_IMAGE, H_EMPTY_IMAGE), L"");
165         Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_NO_CONTENTS);
166         if (pBitmap != null)
167         {
168                 __pEmptyImageLabel->SetBackgroundBitmap(*pBitmap);
169                 delete pBitmap;
170         }
171         __pEmptyImageLabel->SetShowState(false);
172
173         AddControl(__pEmptyImageLabel);
174
175         __pEmptyCommentLabel = new (std::nothrow) Label();
176         __pEmptyCommentLabel->Construct(Rectangle(0, Y_EMPTY_COMMENT, GetClientAreaBounds().width, H_EMPTY_COMMENT),
177                                                                                                                                 ResourceManager::GetString(L"IDS_PB_BODY_NO_CONTACTS"));
178         __pEmptyCommentLabel->SetTextConfig(FONT_SIZE_EMPTY_COMMENT, LABEL_TEXT_STYLE_NORMAL);
179         __pEmptyCommentLabel->SetTextColor(Color(COLOR_EMPTY_COMMENT));
180         __pEmptyCommentLabel->SetShowState(false);
181
182         AddControl(__pEmptyCommentLabel);
183
184         __pOptionMenu = new (std::nothrow) OptionMenu();
185         __pOptionMenu->Construct();
186         __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_REMOVE"), IDA_MORE_REMOVE);
187         __pOptionMenu->AddActionEventListener(*this);
188         __pOptionMenu->SetShowState(false);
189
190         return E_SUCCESS;
191 }
192
193 result
194 GroupContactListForm::OnTerminating(void)
195 {
196         result r = E_SUCCESS;
197
198         if (__pPresentationModel != null)
199         {
200                 __pPresentationModel->RemoveContactChangeListener(*this);
201         }
202         if (__pDeletePopup != null)
203         {
204                 delete __pDeletePopup;
205         }
206         if (__pSearchListEvent != null)
207         {
208                 delete __pSearchListEvent;
209         }
210         delete __pAppControl;
211         delete __pOptionMenu;
212         delete __pMultipleContactValuePopup;
213
214         return r;
215 }
216
217 void
218 GroupContactListForm::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
219 {
220         if (__pListView->GetShowState() == true)
221         {
222                 __pListView->SetFocus();
223         }
224         else if (__pSearchListView->GetShowState() == true)
225         {
226                 __pSearchListView->SetFocus();
227         }
228
229         if(__pPresentationModel->GetContactCount() > 0)
230         {
231                 __pOptionMenu->SetShowState(true);
232                 __pOptionMenu->Show();
233         }
234 }
235
236 void
237 GroupContactListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
238 {
239         SceneManager* pSceneManager = SceneManager::GetInstance();
240         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_GROUP_LIST, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
241 }
242
243 void
244 GroupContactListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
245 {
246         SceneManager* pSceneManager = SceneManager::GetInstance();
247
248         if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
249         {
250                 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
251         }
252
253         switch (actionId)
254         {
255         case IDA_FOOTER_ADD_MEMBER:
256                 {
257                         ArrayList* pArgList = new (std::nothrow) ArrayList();
258                         pArgList->Construct();
259
260                         for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount(); groupIndex++)
261                         {
262                                 for (int itemIndex = 0; itemIndex < __pListView->GetItemCountAt(groupIndex); itemIndex++)
263                                 {
264                                         pArgList->Add(*(new (std::nothrow) Integer(__pPresentationModel->GetContactId(groupIndex, itemIndex))));
265                                 }
266                         }
267                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_SELECTOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgList);
268                 }
269                 break;
270         case IDA_MORE_REMOVE:
271                 {
272                         ArrayList* pArgList = new (std::nothrow) ArrayList();
273                         pArgList->Construct();
274                         pArgList->Add(*(new (std::nothrow) Integer(__categoryId)));
275                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_CONTACT_LIST_EDITOR), pArgList);
276                 }
277                 break;
278         case IDA_POPUP_DELETE_YES:
279                 {
280                         int groupIndex = (__sweptItemIndex >> LIST_VIEW_GROUP_INDEX_SHIFT) & LIST_VIEW_MASK;
281                         int itemIndex = __sweptItemIndex & LIST_VIEW_MASK;
282
283                         __pPresentationModel->RemoveContactFromCategory(groupIndex, itemIndex);
284                         HideDeletePopup();
285                 }
286                 break;
287         case IDA_POPUP_DELETE_CANCEL:
288                 {
289                         HideDeletePopup();
290                 }
291                 break;
292         case IDA_POPUP_CONTACT_VALUE_CLOSE:
293                 {
294                         HideContactValuePopup();
295                 }
296                 break;
297         default:
298                 break;
299         }
300 }
301
302 void
303 GroupContactListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
304 {
305         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
306
307         if (pArgs != null)
308         {
309                 if (previousSceneId.Equals(IDSCN_GROUP_LIST, true))
310                 {
311                         Integer* pCategoryId = null;
312                         IEnumerator* pEnum = pArgs->GetEnumeratorN();
313                         while (pEnum->MoveNext() == E_SUCCESS)
314                         {
315                                 pCategoryId = static_cast<Integer*>(pEnum->GetCurrent());
316                                 if (pCategoryId != null)
317                                 {
318                                         __categoryId = pCategoryId->ToInt();
319
320                                         if (__categoryId == ID_GROUP_CONTACT_NOT_ASSIGNED)
321                                         {
322                                                 __pPresentationModel->InitializeGroupContactList(Tizen::Social::INVALID_RECORD_ID);
323                                                 GetFooter()->SetShowState(false);
324                                         }
325                                         else
326                                         {
327                                                 __pPresentationModel->InitializeGroupContactList(__categoryId);
328                                                 GetFooter()->SetShowState(true);
329                                         }
330                                         __pListView->SetSize(__pListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
331                                         __pSearchListView->SetSize(__pListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
332                                         Invalidate(true);
333                                 }
334                         }
335                         delete pEnum;
336                 }
337                 else if (previousSceneId.Equals(IDSCN_CONTACT_SELECTOR, true))
338                 {
339                         result r = __pPresentationModel->AddContactToCategory(pArgs);
340
341                         if (r == E_SUCCESS)
342                         {
343                                 __isCategoryUpdating = true;
344                         }
345                 }
346
347                 pArgs->RemoveAll(true);
348                 delete pArgs;
349
350         }
351
352         if (previousSceneId.Equals(IDSCN_CONTACT_DETAILS, true))
353         {
354                 if (__categoryId == ID_GROUP_CONTACT_NOT_ASSIGNED)
355                 {
356                         __pPresentationModel->InitializeGroupContactList(Tizen::Social::INVALID_RECORD_ID);
357                 }
358                 else
359                 {
360                         __pPresentationModel->InitializeGroupContactList(__categoryId);
361                 }
362         }
363
364         if (__categoryId == ID_GROUP_CONTACT_NOT_ASSIGNED && __pSearchListEvent != null)
365         {
366                 __pSearchListEvent->SetShowDeleteOption(false);
367         }
368
369         if (__pPresentationModel->IsCategoryValid())
370         {
371                 String groupName = __pPresentationModel->GetCategoryName();
372
373                 Header* pHeader = GetHeader();
374                 pHeader->SetTitleText(groupName);
375
376                 Footer* pFooter = GetFooter();
377                 SetFormMenuEventListener(null);
378
379                 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
380                 {
381                         pFooter->SetShowState(false);
382                         __pListView->SetSize(__pListView->GetWidth(), GetClientAreaBounds().height - H_SEARCHBAR );
383                         __pSearchListView->SetSize(__pSearchListView->GetWidth(), GetClientAreaBounds().height - H_SEARCHBAR);
384                         Invalidate(true);
385
386                         if (__pPresentationModel->GetContactCount() == 0)
387                         {
388                                 __pSearchBar->SetShowState(false);
389                                 __pListView->SetShowState(false);
390                                 __pEmptyImageLabel->SetShowState(true);
391                                 __pEmptyCommentLabel->SetShowState(true);
392                         }
393                         __pPresentationModel->AddContactChangeListener(*this);
394                         return;
395                 }
396
397                 if (__categoryId != ID_GROUP_CONTACT_NOT_ASSIGNED)
398                 {
399                         if (pFooter->GetItemCount() == 0)
400                         {
401                                 FooterItem footerItemAdd;
402                                 footerItemAdd.Construct(IDA_FOOTER_ADD_MEMBER);
403                                 footerItemAdd.SetText(ResourceManager::GetString(L"IDS_PB_SK_ADD_MEMBER"));
404                                 pFooter->AddItem(footerItemAdd);
405                         }
406
407                         if (__pPresentationModel->GetAllContactsCount() <= __pPresentationModel->GetContactCount())
408                         {
409                                 pFooter->SetItemEnabled(0, false);
410                         }
411                         else
412                         {
413                                 pFooter->SetItemEnabled(0, true);
414                         }
415
416                         if (__pPresentationModel->GetContactCount() > 0)
417                         {
418                                 SetFormMenuEventListener(this);
419                         }
420                         else
421                         {
422                                 SetFormMenuEventListener(null);
423                         }
424                 }
425
426                 if (__pPresentationModel->GetContactCount() > 0)
427                 {
428                         __pSearchBar->SetShowState(true);
429                         __pListView->SetShowState(true);
430                         __pEmptyImageLabel->SetShowState(false);
431                         __pEmptyCommentLabel->SetShowState(false);
432
433                         __pListView->SetFastScrollIndex(__pPresentationModel->GetAllKeys(), false);
434                         __pListView->UpdateList();
435
436                         if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT && __pSearchBar->GetTextLength() != 0)
437                         {
438                                 String searchText = __pSearchBar->GetText();
439                                 searchText.Trim();
440
441                                 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
442                                 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
443                                 {
444                                         __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_PHONE_ONLY);
445                                 }
446                                 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
447                                 {
448                                         __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_EMAIL_ONLY);
449                                 }
450                                 else
451                                 {
452                                         __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_NORMAL);
453                                 }
454                                 __pSearchListView->UpdateList();
455                                 __pListView->SetShowState(false);
456                                 __pSearchListView->SetShowState(true);
457                         }
458                         else
459                         {
460                                 __pListView->SetShowState(true);
461                                 __pSearchListView->SetShowState(false);
462                         }
463                 }
464                 else
465                 {
466                         __pSearchBar->SetShowState(false);
467                         __pListView->SetShowState(false);
468                         __pSearchListView->SetShowState(false);
469                         __pEmptyImageLabel->SetShowState(true);
470                         __pEmptyCommentLabel->SetShowState(true);
471                 }
472         }
473         __pPresentationModel->AddContactChangeListener(*this);
474         pContactsApp->AddContactsAppChangeEventListener(*this);
475 }
476
477 void
478 GroupContactListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
479 {
480         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
481
482         __pPresentationModel->RemoveContactChangeListener(*this);
483         pContactsApp->RemoveContactsAppChangeEventListener(*this);
484
485         delete __pAppControl;
486         __pAppControl = null;
487 }
488
489 int
490 GroupContactListForm::GetGroupCount(void)
491 {
492         return __pPresentationModel->GetKeyCount();
493 }
494
495 int
496 GroupContactListForm::GetItemCount(int groupIndex)
497 {
498         return __pPresentationModel->GetContactCount(groupIndex);
499 }
500
501 Tizen::Ui::Controls::ListItemBase*
502 GroupContactListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
503 {
504         String name;
505         Bitmap* pThumbnail = null;
506
507         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
508         CustomItem* pItem = new (std::nothrow) CustomItem();
509         pItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight()), LIST_ANNEX_STYLE_NORMAL);
510
511         __pPresentationModel->GetContactItemInfoN(groupIndex, itemIndex, name, pThumbnail);
512
513         ContactListItem* pCustomElement = new (std::nothrow) ContactListItem(name, pThumbnail);
514         pItem->AddElement(Rectangle(0, 0, itemWidth, pContactsApp->GetListItemSingleLineHeight()), 0, *(static_cast<ICustomElement*>(pCustomElement)));
515
516         if (pContactsApp->GetOperationId().IsEmpty() == false)
517         {
518                 return pItem;
519         }
520
521         bool isCallEnabled = true;
522         bool isMessageEnabled = true;
523         if (__pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex).IsEmpty())
524         {
525                 isCallEnabled = false;
526         }
527
528         if ((__pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex).IsEmpty()) && (__pPresentationModel->GetDefaultEmail(groupIndex, itemIndex).IsEmpty()))
529         {
530                 isMessageEnabled = false;
531         }
532
533         ListContextItem* pItemContext = new (std::nothrow) ListContextItem();
534         pItemContext->Construct();
535         pItemContext->AddElement(IDA_LIST_ELEMENT_CALL, ResourceManager::GetString(L"IDS_COM_BODY_CALL"), isCallEnabled);
536         pItemContext->AddElement(IDA_LIST_ELEMENT_MESSAGE, ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"), isMessageEnabled);
537 #if __SUPPORT_VIDEO_CALL
538         pItemContext->AddElement(IDA_LIST_ELEMENT_VIDEO_CALL, ResourceManager::GetString(L"IDS_COM_BODY_VIDEO_CALL"), isEnabled);
539 #endif
540         if (__categoryId != ID_GROUP_CONTACT_NOT_ASSIGNED)
541         {
542                 pItemContext->AddElement(IDA_LIST_ELEMENT_DELETE, ResourceManager::GetString(L"IDS_COM_SK_DELETE"));
543         }
544         pItemContext->SetElementBackgroundColor(IDA_LIST_ELEMENT_DELETE, LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL, COLOR_DELETE_ELEMENT_NORMAL);
545         pItemContext->SetElementBackgroundColor(IDA_LIST_ELEMENT_DELETE, LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED, COLOR_DELETE_ELEMENT_PRESSED);
546         pItemContext->SetElementTextColor(IDA_LIST_ELEMENT_DELETE, LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL, COLOR_DELETE_ELEMENT_TEXT);
547
548         pItem->SetContextItem(pItemContext);
549
550         return pItem;
551 }
552
553 Tizen::Ui::Controls::GroupItem*
554 GroupContactListForm::CreateGroupItem(int groupIndex, int itemWidth)
555 {
556         GroupItem* pItem = new (std::nothrow) GroupItem();
557         pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM));
558         pItem->SetElement(__pPresentationModel->GetKey(groupIndex), null);
559
560         return pItem;
561 }
562
563 bool
564 GroupContactListForm::DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
565 {
566         CustomItem* pCustomItem = static_cast<CustomItem *>(pItem);
567         pCustomItem->RemoveAllElements();
568
569         delete pItem;
570         pItem = null;
571
572         return true;
573 }
574
575 bool
576 GroupContactListForm::DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::GroupItem* pItem, int itemWidth)
577 {
578         delete pItem;
579         pItem = null;
580
581         return true;
582 }
583
584 void
585 GroupContactListForm::OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
586 {
587         int index = 0;
588
589         if (listView.Equals(*__pSearchListView) == true)
590         {
591                 __pPresentationModel->GetItemMainIndex(itemIndex, groupIndex, itemIndex);
592         }
593
594         index |= groupIndex << LIST_VIEW_GROUP_INDEX_SHIFT;
595         index |= itemIndex;
596
597         __sweptItemIndex = index;
598
599         switch (elementId)
600         {
601         case IDA_LIST_ELEMENT_DELETE:
602                 {
603                         ShowDeletePopup();
604                 }
605                 break;
606         case IDA_LIST_ELEMENT_CALL:
607                 {
608                         String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
609                         LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, phoneNumber, INPUT_TYPE_VOICE);
610                 }
611                 break;
612         case IDA_LIST_ELEMENT_MESSAGE:
613                 {
614                         if (!(__pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex).IsEmpty()))
615                         {
616                                 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
617                                 LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, phoneNumber, INPUT_TYPE_SMS);
618                         }
619                         else if (!(__pPresentationModel->GetDefaultEmail(groupIndex, itemIndex).IsEmpty()))
620                         {
621                                 String emailId = __pPresentationModel->GetDefaultEmail(groupIndex, itemIndex);
622                                 LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, emailId, null);
623                         }
624                 }
625                 break;
626         case IDA_LIST_ELEMENT_VIDEO_CALL:
627                 {
628                         String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
629                         LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, phoneNumber, INPUT_TYPE_VIDEO);
630                 }
631                 break;
632         default:
633                 break;
634         }
635 }
636
637 void
638 GroupContactListForm::OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus state)
639 {
640         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
641
642         if (listView.Equals(*__pSearchListView) == true)
643         {
644                 __pPresentationModel->GetItemMainIndex(itemIndex, groupIndex, itemIndex);
645         }
646
647         int index = 0;
648
649         index |= groupIndex << LIST_VIEW_GROUP_INDEX_SHIFT;
650         index |= itemIndex;
651
652         __selectedIndex = index;
653
654         if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
655         {
656                 IList* pList = null;
657                 HashMap* pReturnValue = new (std::nothrow) HashMap();
658                 pReturnValue->Construct();
659
660                 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
661                 {
662                         pList = __pPresentationModel->GetAllPhoneNumbersN(groupIndex, itemIndex);
663
664                         if (pList == null)
665                         {
666                                 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
667                         }
668                         else
669                         {
670                                 if (pList->GetCount() > 1)
671                                 {
672                                         __pContactValueListEvent = new (std::nothrow) ContactValueListItemProvider(pList);
673                                         ShowContactValuePopup(groupIndex, itemIndex);
674                                 }
675                                 else if (pList->GetCount() == 1)
676                                 {
677                                         String* pPhoneNumberInfo = static_cast<String *>(pList->GetAt(0));
678                                         int blankIndex = 0;
679                                         ArrayList* pValueList = new (std::nothrow) ArrayList();
680                                         pValueList->Construct();
681
682                                         pPhoneNumberInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
683                                         pPhoneNumberInfo->Remove(0, blankIndex + 1);
684                                         pValueList->Add(new (std::nothrow) String(*pPhoneNumberInfo));
685                                         pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_PHONE), pValueList);
686
687                                         ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
688                                         delete pList;
689                                 }
690                         }
691                 }
692                 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
693                 {
694                         pList = __pPresentationModel->GetAllEmailsN(groupIndex, itemIndex);
695
696                         if (pList == null)
697                         {
698                                 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
699                         }
700                         else
701                         {
702                                 if (pList->GetCount() > 1)
703                                 {
704                                         __pContactValueListEvent = new (std::nothrow) ContactValueListItemProvider(pList);
705                                         ShowContactValuePopup(groupIndex, itemIndex);
706                                 }
707                                 else if (pList->GetCount() == 1)
708                                 {
709                                         String* pEmailInfo = static_cast<String *>(pList->GetAt(0));
710                                         int blankIndex = 0;
711                                         ArrayList* pValueList = new (std::nothrow) ArrayList();
712                                         pValueList->Construct();
713
714                                         pEmailInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
715                                         pEmailInfo->Remove(0, blankIndex + 1);
716                                         pValueList->Add(new (std::nothrow) String(*pEmailInfo));
717                                         pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_EMAIL), pValueList);
718
719                                         ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
720                                         delete pList;
721                                 }
722                         }
723                 }
724                 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_ITEM_ID)
725                 {
726                         AppCtrlResult appCtrlResult = APP_CTRL_RESULT_SUCCEEDED;
727                         RecordId contactId = __pPresentationModel->GetContactId(groupIndex, itemIndex);
728                         if (contactId == INVALID_RECORD_ID)
729                         {
730                                 appCtrlResult = APP_CTRL_RESULT_FAILED;
731                         }
732                         else
733                         {
734                                 String contactIdString;
735                                 ArrayList* pValueList = new (std::nothrow) ArrayList();
736                                 pValueList->Construct();
737
738                                 contactIdString.Append(contactId);
739                                 pValueList->Add(new (std::nothrow) String(contactIdString));
740                                 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), pValueList);
741                         }
742
743                         ReturnValues(pContactsApp->GetRequestId(), appCtrlResult, pReturnValue);
744                 }
745                 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_VCARD)
746                 {
747                         AppCtrlResult appCtrlResult = APP_CTRL_RESULT_SUCCEEDED;
748                         String vCardPath = __pPresentationModel->ExportToVcard(groupIndex, itemIndex);
749
750                         if (vCardPath.IsEmpty())
751                         {
752                                 appCtrlResult = APP_CTRL_RESULT_FAILED;
753                         }
754                         else
755                         {
756                                 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_PATH), new (std::nothrow) String(vCardPath));
757                         }
758
759                         ReturnValues(pContactsApp->GetRequestId(), appCtrlResult, pReturnValue);
760                 }
761
762                 delete pReturnValue;
763         }
764         else
765         {
766                 ArrayList* pContactId = new (std::nothrow) ArrayList();
767                 pContactId->Construct();
768
769                 pContactId->Add(*(new (std::nothrow) Integer(__pPresentationModel->GetContactId(groupIndex, itemIndex))));
770                 SceneManager* pSceneManager = SceneManager::GetInstance();
771
772                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_DETAILS, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pContactId);
773         }
774 }
775
776 void
777 GroupContactListForm::OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, Tizen::Ui::Controls::SweepDirection direction)
778 {
779 }
780
781 void
782 GroupContactListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
783 {
784 }
785
786 void
787 GroupContactListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
788 {
789         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
790
791         IList* pList = null;
792
793         HashMap* pReturnValue = new (std::nothrow) HashMap();
794         pReturnValue->Construct();
795
796         int groupIndex = (__selectedIndex >> LIST_VIEW_GROUP_INDEX_SHIFT) & LIST_VIEW_MASK;
797         int itemIndex = __selectedIndex & LIST_VIEW_MASK;
798
799         if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
800         {
801                 pList = __pPresentationModel->GetAllPhoneNumbersN(groupIndex, itemIndex);
802                 String* pPhoneNumberInfo = static_cast<String *>(pList->GetAt(index));
803                 int blankIndex = 0;
804                 ArrayList* pValueList = new (std::nothrow) ArrayList();
805                 pValueList->Construct();
806
807                 pPhoneNumberInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
808                 pPhoneNumberInfo->Remove(0, blankIndex + 1);
809                 pValueList->Add(new (std::nothrow) String(*pPhoneNumberInfo));
810                 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_PHONE), pValueList);
811         }
812         else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
813         {
814                 pList = __pPresentationModel->GetAllEmailsN(groupIndex, itemIndex);
815                 String* pEmailInfo = static_cast<String *>(pList->GetAt(index));
816                 int blankIndex = 0;
817                 ArrayList* pValueList = new (std::nothrow) ArrayList();
818                 pValueList->Construct();
819
820                 pEmailInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
821                 pEmailInfo->Remove(0, blankIndex + 1);
822                 pValueList->Add(new (std::nothrow) String(*pEmailInfo));
823                 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_EMAIL), pValueList);
824         }
825
826         delete pList;
827
828         ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
829 }
830
831 void
832 GroupContactListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
833 {
834 }
835
836 void
837 GroupContactListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, SearchBarMode mode)
838 {
839         if (mode == SEARCH_BAR_MODE_NORMAL)
840         {
841                 __pListView->SetShowState(true);
842                 __pSearchListView->SetShowState(false);
843                 __pPresentationModel->ResetSearchedContactList();
844                 __pSearchListView->UpdateList();
845                 __pListView->UpdateList();
846         }
847         else
848         {
849                 //[TODO] to restore swept item.
850                 // need to be fixed with better idea..
851                 Rectangle bounds = __pListView->GetBounds();
852                 __pListView->SetBounds(bounds.x, bounds.y, bounds.width, bounds.height + 1);
853                 __pListView->Invalidate(true);
854                 __pListView->SetBounds(bounds);
855         }
856 }
857
858 void
859 GroupContactListForm::OnTextValueChanged(const Tizen::Ui::Control& source)
860 {
861         String searchText = __pSearchBar->GetText();
862         searchText.Trim();
863
864         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
865         if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
866         {
867                 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_PHONE_ONLY);
868         }
869         else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
870         {
871                 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_EMAIL_ONLY);
872         }
873         else
874         {
875                 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_NORMAL);
876         }
877
878         if (searchText.GetLength() != 0)
879         {
880                 __pSearchListView->SetShowState(true);
881                 __pListView->SetShowState(false);
882         }
883         else
884         {
885                 __pSearchListView->SetShowState(false);
886                 __pListView->SetShowState(true);
887         }
888
889         __pSearchListView->UpdateList();
890 }
891
892 void
893 GroupContactListForm::OnFastScrollIndexSelected (Tizen::Ui::Control& source, Tizen::Base::String& index)
894 {
895         __pListView->ScrollToItem(__pPresentationModel->GetKeyIndex(index), -1);
896         __pListView->Invalidate(false);
897 }
898
899 void
900 GroupContactListForm::OnFocusGained(const Tizen::Ui::Control& source)
901 {
902         if (source.Equals(*__pSearchBar))
903         {
904                 if (__pListView->GetShowState() == true )
905                 {
906                         int groupCount   = __pPresentationModel->GetKeyCount();
907                         bool isContextItemOpenend = false;
908
909                         for (int i = 0; i < groupCount; i++)
910                         {
911                                 int contactCount = __pPresentationModel->GetContactCount(i);
912                                 for (int j = 0; j < contactCount; j++)
913                                 {
914                                         if (__pListView->IsContextItemOpened(i, j) == true)
915                                         {
916                                                 isContextItemOpenend = true;
917                                                 break;
918                                         }
919                                 }
920                         }
921
922                         if (isContextItemOpenend == true)
923                         {
924                                 __pListView->UpdateList();
925                         }
926                 }
927                 else if (__pSearchListView->GetShowState() == true )
928                 {
929                         int groupCount   = 0;
930                         bool isContextItemOpenend = false;
931
932                         if (__pSearchListEvent == null)
933                         {
934                                 return;
935                         }
936                         groupCount   = __pSearchListEvent->GetGroupCount();
937                         for (int i = 0; i < groupCount; i++)
938                         {
939                                 int contactCount = __pSearchListEvent->GetItemCount(i);
940                                 for (int j = 0; j < contactCount; j++)
941                                 {
942                                         if (__pSearchListView->IsContextItemOpened(i, j) == true)
943                                         {
944                                                 isContextItemOpenend = true;
945                                                 break;
946                                         }
947                                 }
948                         }
949
950                         if (isContextItemOpenend == true)
951                         {
952                                 __pSearchListView->UpdateList();
953                         }
954                 }
955         }
956 }
957
958 void
959 GroupContactListForm::OnFocusLost(const Tizen::Ui::Control& source)
960 {
961 }
962
963 void
964 GroupContactListForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
965 {
966 }
967
968 void
969 GroupContactListForm::OnContactsChanged(void)
970 {
971         HideContactValuePopup();
972         HideDeletePopup();
973
974         if (__isCategoryUpdating)
975         {
976                 __isCategoryUpdating = false;
977
978                 return;
979         }
980
981         if (__categoryId == ID_GROUP_CONTACT_NOT_ASSIGNED)
982         {
983                 __pPresentationModel->InitializeGroupContactList(Tizen::Social::INVALID_RECORD_ID);
984         }
985         else
986         {
987                 __pPresentationModel->InitializeGroupContactList(__categoryId);
988         }
989
990         if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
991         {
992                 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
993                 SetFocus();
994         }
995
996         if (__categoryId != ID_GROUP_CONTACT_NOT_ASSIGNED)
997         {
998                 Footer* pFooter = GetFooter();
999
1000                 if (__pPresentationModel->GetAllContactsCount() <= __pPresentationModel->GetContactCount())
1001                 {
1002                         pFooter->SetItemEnabled(0, false);
1003                         pFooter->Invalidate(true);
1004                 }
1005                 else
1006                 {
1007                         pFooter->SetItemEnabled(0, true);
1008                         pFooter->Invalidate(true);
1009                 }
1010
1011                 if (__pPresentationModel->GetContactCount() > 0)
1012                 {
1013                         SetFormMenuEventListener(this);
1014                 }
1015                 else
1016                 {
1017                         SetFormMenuEventListener(null);
1018                 }
1019         }
1020
1021         if (__pPresentationModel->GetContactCount() > 0)
1022         {
1023                 __pSearchBar->SetShowState(true);
1024                 __pListView->SetShowState(true);
1025                 __pEmptyImageLabel->SetShowState(false);
1026                 __pEmptyCommentLabel->SetShowState(false);
1027
1028                 __pPresentationModel->InitializeContactList();
1029                 __pListView->SetFastScrollIndex(__pPresentationModel->GetAllKeys(), false);
1030                 __pListView->UpdateList();
1031         }
1032         else
1033         {
1034                 __pSearchBar->SetShowState(false);
1035                 __pListView->SetShowState(false);
1036                 __pEmptyImageLabel->SetShowState(true);
1037                 __pEmptyCommentLabel->SetShowState(true);
1038         }
1039 }
1040
1041 void
1042 GroupContactListForm::OnCategoriesChanged(void)
1043 {
1044         if (__pPresentationModel->IsCategoryValid() == false)
1045         {
1046                 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(IDSCN_GROUP_LIST));
1047         }
1048 }
1049
1050 void
1051 GroupContactListForm::ShowDeletePopup(void)
1052 {
1053         if (__pDeletePopup == null)
1054         {
1055                 __pDeletePopup = new (std::nothrow) Popup();
1056                 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
1057                 __pDeletePopup->SetPropagatedKeyEventListener(this);
1058
1059                 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
1060
1061                 Label* pLabel = new (std::nothrow) Label();
1062                 pLabel->Construct(Rectangle(X_DELETE_LABEL, Y_DELETE_LABEL, W_DELETE_LABEL, H_DELETE_LABEL), ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
1063                 pLabel->SetTextConfig(FONT_SIZE_DELETE_CONFIRM, LABEL_TEXT_STYLE_NORMAL);
1064                 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1065                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1066
1067                 Button* pDeleteButton = new (std::nothrow) Button();
1068                 pDeleteButton->Construct(Rectangle(X_DELETE_LABEL + W_DELETE_BUTTON + W_DELETE_BUTTON_GAP, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_SK_DELETE"));
1069                 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
1070                 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
1071                 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
1072                 pDeleteButton->SetTextSize(FONT_SIZE_DELETE_BUTTON);
1073                 pDeleteButton->SetActionId(IDA_POPUP_DELETE_YES);
1074                 pDeleteButton->AddActionEventListener(*this);
1075
1076                 Button* pCancelButton = new (std::nothrow) Button();
1077                 pCancelButton->Construct(Rectangle(X_DELETE_LABEL, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_PB_SK_CANCEL"));
1078                 pCancelButton->SetTextSize(FONT_SIZE_DELETE_BUTTON);
1079                 pCancelButton->SetActionId(IDA_POPUP_DELETE_CANCEL);
1080                 pCancelButton->AddActionEventListener(*this);
1081
1082                 __pDeletePopup->AddControl(pLabel);
1083                 __pDeletePopup->AddControl(pDeleteButton);
1084                 __pDeletePopup->AddControl(pCancelButton);
1085         }
1086
1087         __pDeletePopup->SetShowState(true);
1088         __pDeletePopup->Show();
1089 }
1090
1091 void
1092 GroupContactListForm::HideDeletePopup(void)
1093 {
1094         if (__pDeletePopup != null)
1095         {
1096                 __pDeletePopup->SetShowState(false);
1097                 Invalidate(true);
1098         }
1099
1100         delete __pContactValueListEvent;
1101         __pContactValueListEvent = null;
1102 }
1103
1104 void
1105 GroupContactListForm::ShowContactValuePopup(int groupIndex, int itemIndex)
1106 {
1107         delete __pMultipleContactValuePopup;
1108         __pMultipleContactValuePopup = new (std::nothrow) Popup();
1109         __pMultipleContactValuePopup->Construct(true, Dimension(W_CONTACT_VALUE_POPUP, H_CONTACT_VALUE_POPUP));
1110         __pMultipleContactValuePopup->SetTitleText(__pPresentationModel->GetName(groupIndex, itemIndex));
1111         __pMultipleContactValuePopup->SetPropagatedKeyEventListener(this);
1112
1113         Rectangle popupClientBounds = __pMultipleContactValuePopup->GetClientAreaBounds();
1114
1115         ListView* pListView = new (std::nothrow) ListView();
1116         pListView->Construct(Rectangle(0, 0, popupClientBounds.width, H_CONTACT_VALUE_POPUP_LIST_VIEW));
1117         pListView->SetItemProvider(*__pContactValueListEvent);
1118         pListView->AddListViewItemEventListener(*this);
1119
1120         __pMultipleContactValuePopup->AddControl(pListView);
1121
1122         Button* pCancelButton = new (std::nothrow) Button();
1123         pCancelButton->Construct(Rectangle((popupClientBounds.width - W_CLOSE_BUTTON) / 2, Y_CLOSE_BUTTON, W_CLOSE_BUTTON, H_CLOSE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CLOSE"));
1124         pCancelButton->SetActionId(IDA_POPUP_CONTACT_VALUE_CLOSE);
1125         pCancelButton->AddActionEventListener(*this);
1126
1127         __pMultipleContactValuePopup->AddControl(pCancelButton);
1128         __pMultipleContactValuePopup->SetShowState(true);
1129         __pMultipleContactValuePopup->Show();
1130 }
1131
1132 void
1133 GroupContactListForm::HideContactValuePopup(void)
1134 {
1135         if (__pMultipleContactValuePopup != null)
1136         {
1137                 __pMultipleContactValuePopup->SetShowState(false);
1138                 Invalidate(true);
1139         }
1140 }
1141
1142 result
1143 GroupContactListForm::ParseAppControlArgument(const Tizen::Base::String& argument, Tizen::Base::String& type, Tizen::Base::String& content)
1144 {
1145         result r = E_SUCCESS;
1146
1147         if (argument.IsEmpty() || argument.Contains(DELIMITER) == false)
1148         {
1149                 return E_FAILURE;
1150         }
1151
1152         StringTokenizer stringToken(argument, DELIMITER);
1153
1154         r = stringToken.GetNextToken(type);
1155         TryReturn(r == E_SUCCESS, r, "[%s] Unable to get type", GetErrorMessage(r));
1156
1157         r = stringToken.GetNextToken(content);
1158         TryReturn(r == E_SUCCESS, r, "[%s] Unable to get content", GetErrorMessage(r));
1159
1160         return r;
1161 }
1162
1163 void
1164 GroupContactListForm::ReturnValues(RequestId requestId, Tizen::App::AppCtrlResult appCtrlResult, const Tizen::Base::Collection::IMap* pReturnValue)
1165 {
1166         AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
1167
1168         result r = pAppManager->SendAppControlResult(requestId, appCtrlResult, pReturnValue);
1169         AppLogDebug("[%s] The return result from SendAppControlResult(), AppCtrlResult value : %d.", GetErrorMessage(r), appCtrlResult);
1170
1171         UiApp::GetInstance()->Terminate();
1172 }
1173
1174 result
1175 GroupContactListForm::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, const Tizen::Base::String& argument, const Tizen::Base::String& type)
1176 {
1177         result r = E_SUCCESS;
1178
1179         if (__pAppControl != null)
1180         {
1181                 return E_FAILURE;
1182         }
1183
1184         String uri;
1185         HashMap extraData;
1186         extraData.Construct();
1187
1188         if (appId.Equals(String(PROVIDER_ID_PHONE)))
1189         {
1190                 uri.Append(INPUT_URI_TEL);
1191                 uri.Append(argument);
1192                 extraData.Add(new (std::nothrow) String(INPUT_KEY_CALL_TYPE), new (std::nothrow) String(type));
1193         }
1194         else if (appId.Equals(String(PROVIDER_ID_MESSAGE)))
1195         {
1196                 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TO), new (std::nothrow) String(argument));
1197                 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TYPE), new (std::nothrow) String(INPUT_TYPE_SMS));
1198         }
1199
1200         __pAppControl = AppManager::FindAppControlN(appId, operationId);
1201         if (__pAppControl != null)
1202         {
1203                 r = __pAppControl->Start(&uri, null, &extraData, null);
1204                 if (IsFailed(r))
1205                 {
1206                         AppLogDebug("[%s] Unable to launch app control", GetErrorMessage(r));
1207                 }
1208                 else
1209                 {
1210                         if (__pListView->GetShowState() == true)
1211                         {
1212                                 __pListView->SetEnabled(false);
1213                         }
1214
1215                         if (__pSearchListView->GetShowState() == true)
1216                         {
1217                                 __pSearchListView->SetEnabled(false);
1218                         }
1219                 }
1220         }
1221
1222         extraData.RemoveAll(true);
1223
1224         return r;
1225 }
1226
1227 void
1228 GroupContactListForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1229 {
1230 }
1231
1232 void
1233 GroupContactListForm::OnKeypadOpened(Tizen::Ui::Control& source)
1234 {
1235         __pSearchListView->SetSize(__pListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1236 }
1237
1238 void
1239 GroupContactListForm::OnKeypadClosed(Tizen::Ui::Control& source)
1240 {
1241         if (__categoryId == ID_GROUP_CONTACT_NOT_ASSIGNED)
1242         {
1243                 __pPresentationModel->InitializeGroupContactList(Tizen::Social::INVALID_RECORD_ID);
1244                 GetFooter()->SetShowState(false);
1245         }
1246         else
1247         {
1248                 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1249                 __pPresentationModel->InitializeGroupContactList(__categoryId);
1250                 if (pContactsApp->GetOperationId() != OPERATION_ID_PICK)
1251                 {
1252                         GetFooter()->SetShowState(true);
1253                 }
1254         }
1255         __pListView->SetSize(__pListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1256         __pSearchListView->SetSize(__pListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1257         Invalidate(true);
1258 }
1259
1260 void
1261 GroupContactListForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1262 {
1263         __pSearchListView->SetSize(__pListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1264 }
1265
1266 void
1267 GroupContactListForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1268 {
1269         if (keypadAction == KEYPAD_ACTION_SEARCH)
1270         {
1271                 __pSearchBar->HideKeypad();
1272         }
1273 }
1274
1275 void
1276 GroupContactListForm::OnForeground(void)
1277 {
1278         delete __pAppControl;
1279         __pAppControl = null;
1280
1281         if (__pListView->IsEnabled() == false)
1282         {
1283                 __pListView->SetEnabled(true);
1284         }
1285
1286         if (__pSearchListView->IsEnabled() == false)
1287         {
1288                 __pSearchListView->SetEnabled(true);
1289         }
1290 }
1291
1292 void
1293 GroupContactListForm::OnBackground(void)
1294 {
1295 }
1296
1297 void
1298 GroupContactListForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
1299 {
1300         GroupedListView* pList = static_cast<GroupedListView*>(&const_cast<Control&>(source));
1301         if (pList != null)
1302         {
1303                 pList->SetFocus();
1304         }
1305 }
1306
1307 void
1308 GroupContactListForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1309 {
1310 }
1311
1312 void
1313 GroupContactListForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1314 {
1315 }
1316
1317 void
1318 GroupContactListForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1319 {
1320 }
1321
1322 void
1323 GroupContactListForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1324 {
1325 }
1326
1327 bool
1328 GroupContactListForm::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
1329 {
1330         return false;
1331 }
1332
1333 bool
1334 GroupContactListForm::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
1335 {
1336         if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
1337         {
1338                 if (__pMultipleContactValuePopup && __pMultipleContactValuePopup->GetShowState() == true)
1339                 {
1340                         HideContactValuePopup();
1341                         return true;
1342                 }
1343                 else if (__pDeletePopup && __pDeletePopup->GetShowState() == true)
1344                 {
1345                         HideDeletePopup();
1346                         return true;
1347                 }
1348         }
1349         return false;
1350 }
1351
1352 bool
1353 GroupContactListForm::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
1354 {
1355         return false;
1356 }
1357
1358 bool
1359 GroupContactListForm::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
1360 {
1361         return false;
1362 }