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