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