2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file CtContactListPanel.cpp
19 * @brief This is the implementation file for the ContactListPanel class.
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"
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;
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;
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;
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;
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;
105 static const int LIST_VIEW_GROUP_INDEX_SHIFT = 16;
106 static const int LIST_VIEW_MASK = 0xFFFF;
108 static const wchar_t* IDB_NO_CONTENTS = L"00_Nocontents_text.png";
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:";
119 ContactListPanel::ContactListPanel(void)
120 : __pAppControl(null)
123 , __pSearchListView(null)
124 , __pAccountPopup(null)
125 , __pDeletePopup(null)
126 , __pMultipleContactValuePopup(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)
142 ContactListPanel::~ContactListPanel(void)
147 ContactListPanel::Initialize(void)
149 Construct(Rectangle(0, 0, W_INITIAL_PANEL, H_INITIAL_PANEL));
153 ContactListPanel::OnInitializing(void)
155 const Form* pForm = dynamic_cast<Form*>(GetParent());
158 Rectangle clientBounds = pForm->GetClientAreaBounds();
159 SetBounds(Rectangle(0, 0, clientBounds.width, clientBounds.height));
161 __pPresentationModel = ContactListPresentationModel::GetInstance();
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);
171 AddControl(__pListView);
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));
181 __pSearchListEvent = new (std::nothrow) SearchListEventListener(LIST_ANNEX_STYLE_NORMAL, __pPresentationModel);
183 AddControl(__pSearchBar);
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);
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);
199 __pEmptyImageLabel->SetBackgroundBitmap(*pBitmap);
202 __pEmptyImageLabel->SetShowState(false);
204 AddControl(__pEmptyImageLabel);
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);
213 AddControl(__pEmptyCommentLabel);
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);
225 ContactListPanel::OnTerminating(void)
227 result r = E_SUCCESS;
229 if (__pPresentationModel != null)
231 __pPresentationModel->RemoveContactChangeListener(*this);
234 if (__pArgList != null)
236 __pArgList->RemoveAll(true);
240 delete __pAppControl;
241 delete __pDeletePopup;
242 delete __pAccountPopup;
243 delete __pSearchListEvent;
244 delete __pAccountListEvent;
245 delete __pOptionMenu;
246 delete __pMultipleContactValuePopup;
252 ContactListPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
254 SceneManager* pSceneManager = SceneManager::GetInstance();
255 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
256 Form* pForm = dynamic_cast<Form*>(GetParent());
261 case IDA_HEADER_CONTACTS:
263 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST));
266 case IDA_HEADER_GROUPS:
270 if (__isKeypadOpened)
272 __changedSceneId = IDSCN_GROUP_LIST;
276 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_LIST));
280 case IDA_HEADER_FAVORITES:
284 if (__isKeypadOpened)
286 __changedSceneId = IDSCN_FAVORITE_LIST;
288 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
290 if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_SINGLE)
292 __changedSceneId = IDSCN_FAVORITE_LIST;
294 else if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
296 __changedSceneId = IDSCN_FAVORITE_LIST_EDITOR;
302 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
304 if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_SINGLE)
306 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
308 else if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
310 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST_EDITOR));
315 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
319 case IDA_FOOTER_CREATE:
321 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
324 case IDA_MORE_DELETE:
326 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST_EDITOR));
329 case IDA_MORE_SETTING:
331 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTINGS, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
334 case IDA_POPUP_DELETE_OK:
336 int groupIndex = (__sweptItemIndex >> LIST_VIEW_GROUP_INDEX_SHIFT) & LIST_VIEW_MASK;
337 int itemIndex = __sweptItemIndex & LIST_VIEW_MASK;
339 __pPresentationModel->RemoveContact(groupIndex, itemIndex);
343 case IDA_POPUP_DELETE_CANCEL:
348 case IDA_POPUP_VIEW_OK:
353 case IDA_POPUP_VIEW_CANCEL:
358 case IDA_POPUP_CONTACT_VALUE_CLOSE:
360 HideContactValuePopup();
369 ContactListPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
370 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
372 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
374 const Form* pForm = dynamic_cast<Form*>(GetParent());
377 Form *pEventForm = const_cast<Form*>(pForm);
378 pEventForm->SetFormMenuEventListener(this);
380 Header* pHeader = pForm->GetHeader();
381 pHeader->AddActionEventListener(*this);
383 Footer* pFooter = pForm->GetFooter();
384 pFooter->RemoveAllItems();
385 pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
386 pFooter->SetBackButton();
387 pFooter->AddActionEventListener(*this);
388 pFooter->RemoveMenuButton();
390 __pPresentationModel->InitializeContactList();
392 __pListView->SetFastScrollIndex(__pPresentationModel->GetAllKeys(), false);
393 __pListView->UpdateList();
395 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK || pContactsApp->GetOperationId() == OPERATION_ID_EDIT)
397 if (__pPresentationModel->GetContactCount() == 0)
399 pFooter->RemoveMenuButton();
400 __pSearchBar->SetShowState(false);
401 __pListView->SetShowState(false);
402 __pEmptyImageLabel->SetShowState(true);
403 __pEmptyCommentLabel->SetShowState(true);
407 pFooter->SetMenuButton();
412 __pArgList = new (std::nothrow) ArrayList();
413 __pArgList->Construct();
415 for (int i = 0; i < pArgs->GetCount(); i++)
417 __pArgList->Add(new (std::nothrow) String(*static_cast<String*>(pArgs->GetAt(i))));
423 FooterItem footerItemCreate;
424 footerItemCreate.Construct(IDA_FOOTER_CREATE);
425 footerItemCreate.SetText(ResourceManager::GetString(L"IDS_COM_BODY_CREATE"));
426 pFooter->AddItem(footerItemCreate);
428 if (__pPresentationModel->GetContactCount() > 0)
430 pFooter->SetMenuButton();
431 __pSearchBar->SetShowState(true);
432 __pListView->SetShowState(true);
433 __pEmptyImageLabel->SetShowState(false);
434 __pEmptyCommentLabel->SetShowState(false);
438 pFooter->RemoveMenuButton();
439 __pSearchBar->SetShowState(false);
440 __pListView->SetShowState(false);
441 __pEmptyImageLabel->SetShowState(true);
442 __pEmptyCommentLabel->SetShowState(true);
444 pContactsApp->AddContactsAppChangeEventListener(*this);
447 __pPresentationModel->AddContactChangeListener(*this);
451 pArgs->RemoveAll(true);
457 ContactListPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
458 const Tizen::Ui::Scenes::SceneId& nextSceneId)
460 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
462 Form* pForm = dynamic_cast<Form*>(GetParent());
465 Form *pEventForm = const_cast<Form*>(pForm);
466 pEventForm->SetFormMenuEventListener(null);
468 if (pForm->IsFooterVisible() == false)
470 pForm->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
473 Header* pHeader = pForm->GetHeader();
474 pHeader->RemoveActionEventListener(*this);
476 Footer* pFooter = pForm->GetFooter();
477 pFooter->RemoveActionEventListener(*this);
479 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
481 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
484 __pPresentationModel->RemoveContactChangeListener(*this);
485 pContactsApp->RemoveContactsAppChangeEventListener(*this);
487 delete __pAppControl;
488 __pAppControl = null;
492 ContactListPanel::GetGroupCount(void)
494 return __pPresentationModel->GetKeyCount();
498 ContactListPanel::GetItemCount(int groupIndex)
500 return __pPresentationModel->GetContactCount(groupIndex);
503 Tizen::Ui::Controls::ListItemBase*
504 ContactListPanel::CreateItem(int groupIndex, int itemIndex, int itemWidth)
507 Bitmap* pThumbnail = null;
509 CustomItem* pItem = new (std::nothrow) CustomItem();
510 pItem->Construct(Dimension(itemWidth, H_ITEM), LIST_ANNEX_STYLE_NORMAL);
512 __pPresentationModel->GetContactItemInfoN(groupIndex, itemIndex, name, pThumbnail);
514 ContactListItem* pCustomElement = new (std::nothrow) ContactListItem(name, pThumbnail);
515 pItem->AddElement(Rectangle(0, 0, itemWidth, H_ITEM), 0, *(static_cast<ICustomElement *>(pCustomElement)));
517 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
519 if (pContactsApp->GetOperationId().IsEmpty() == false)
524 bool isCallEnabled = true;
525 bool isMessageEnabled = true;
526 if (__pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex).IsEmpty())
528 isCallEnabled = false;
531 if ((__pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex).IsEmpty()) && (__pPresentationModel->GetDefaultEmail(groupIndex, itemIndex).IsEmpty()))
533 isMessageEnabled = false;
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);
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);
549 pItem->SetContextItem(pItemContext);
554 Tizen::Ui::Controls::GroupItem*
555 ContactListPanel::CreateGroupItem(int groupIndex, int itemWidth)
557 GroupItem* pItem = new (std::nothrow) GroupItem();
558 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM));
559 pItem->SetElement(__pPresentationModel->GetKey(groupIndex), null);
565 ContactListPanel::DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
567 CustomItem* pCustomItem = static_cast<CustomItem *>(pItem);
569 pCustomItem->RemoveAllElements();
578 ContactListPanel::DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::GroupItem* pItem, int itemWidth)
587 ContactListPanel::OnContactsChanged(void)
589 Form* pForm = dynamic_cast<Form*>(GetParent());
594 Footer* pFooter = pForm->GetFooter();
596 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
598 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
602 __pPresentationModel->InitializeContactList();
604 if (__pPresentationModel->GetContactCount() > 0)
609 pFooter->SetMenuButton();
610 __pSearchBar->SetShowState(true);
611 __pListView->SetShowState(true);
612 __pEmptyImageLabel->SetShowState(false);
613 __pEmptyCommentLabel->SetShowState(false);
615 __pListView->GetTopDrawnItemIndex(groupIndex, itemIndex);
616 __pListView->UpdateList();
617 __pListView->SetFastScrollIndex(__pPresentationModel->GetAllKeys(), false);
618 __pListView->Invalidate(true);
619 __pListView->ScrollToItem(groupIndex, itemIndex);
623 pFooter->RemoveMenuButton();
624 __pSearchBar->SetShowState(false);
625 __pListView->SetShowState(false);
626 __pEmptyImageLabel->SetShowState(true);
627 __pEmptyCommentLabel->SetShowState(true);
632 ContactListPanel::OnCategoriesChanged(void)
637 ContactListPanel::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
639 if (mode == SEARCH_BAR_MODE_NORMAL)
641 __pListView->SetShowState(true);
642 __pSearchListView->SetShowState(false);
643 __pPresentationModel->ResetSearchedContactList();
644 __pSearchListView->UpdateList();
645 __pListView->UpdateList();
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);
659 ContactListPanel::OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
663 index |= groupIndex << LIST_VIEW_GROUP_INDEX_SHIFT;
666 __sweptItemIndex = index;
670 case IDA_LIST_ELEMENT_DELETE:
675 case IDA_LIST_ELEMENT_CALL:
677 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
678 LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, phoneNumber, INPUT_TYPE_VOICE);
681 case IDA_LIST_ELEMENT_MESSAGE:
683 if (!(__pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex).IsEmpty()))
685 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
686 LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, phoneNumber, INPUT_TYPE_SMS);
688 else if (!(__pPresentationModel->GetDefaultEmail(groupIndex, itemIndex).IsEmpty()))
690 String emailId = __pPresentationModel->GetDefaultEmail(groupIndex, itemIndex);
691 LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, emailId, null);
695 case IDA_LIST_ELEMENT_VIDEO_CALL:
697 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
698 LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, phoneNumber, INPUT_TYPE_VIDEO);
707 ContactListPanel::OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus state)
709 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
711 if (listView.Equals(*__pSearchListView) == true)
713 __pPresentationModel->GetItemMainIndex(itemIndex, groupIndex, itemIndex);
717 __selectedIndex |= groupIndex << LIST_VIEW_GROUP_INDEX_SHIFT;
718 __selectedIndex |= itemIndex;
720 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
723 HashMap* pReturnValue = new (std::nothrow) HashMap();
724 pReturnValue->Construct();
726 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
728 pList = __pPresentationModel->GetAllPhoneNumbersN(groupIndex, itemIndex);
732 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
736 if (pList->GetCount() > 1)
738 __pContactValueListEvent = new (std::nothrow) ContactValueListItemProvider(pList);
739 ShowContactValuePopup(groupIndex, itemIndex);
741 else if (pList->GetCount() == 1)
743 AddContactValueOnList(pList, CONTACT_KEY_PHONE, 0, pReturnValue);
745 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
750 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
752 pList = __pPresentationModel->GetAllEmailsN(groupIndex, itemIndex);
756 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
760 if (pList->GetCount() > 1)
762 __pContactValueListEvent = new (std::nothrow) ContactValueListItemProvider(pList);
763 ShowContactValuePopup(groupIndex, itemIndex);
765 else if (pList->GetCount() == 1)
767 AddContactValueOnList(pList, CONTACT_KEY_EMAIL, 0, pReturnValue);
769 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
774 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_ITEM_ID)
776 AppCtrlResult appCtrlResult = APP_CTRL_RESULT_SUCCEEDED;
777 RecordId contactId = __pPresentationModel->GetContactId(groupIndex, itemIndex);
778 if (contactId == INVALID_RECORD_ID)
780 appCtrlResult = APP_CTRL_RESULT_FAILED;
785 ArrayList* pValueList = new (std::nothrow) ArrayList();
786 pValueList->Construct();
788 contactId.Append(__pPresentationModel->GetContactId(groupIndex, itemIndex));
789 pValueList->Add(new (std::nothrow) String(contactId));
791 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), pValueList);
794 ReturnValues(pContactsApp->GetRequestId(), appCtrlResult, pReturnValue);
796 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_VCARD)
798 AppCtrlResult appCtrlResult = APP_CTRL_RESULT_SUCCEEDED;
799 String vCardPath = __pPresentationModel->ExportToVcard(groupIndex, itemIndex);
801 if (vCardPath.IsEmpty())
803 appCtrlResult = APP_CTRL_RESULT_FAILED;
807 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_PATH), new (std::nothrow) String(vCardPath));
810 ReturnValues(pContactsApp->GetRequestId(), appCtrlResult, pReturnValue);
815 else if (pContactsApp->GetOperationId() == OPERATION_ID_EDIT)
817 ArrayList* pArgList = null;
818 SceneManager* pSceneManager = SceneManager::GetInstance();
820 if (__pArgList != null)
822 pArgList = new (std::nothrow) ArrayList();
823 pArgList->Construct();
825 for (int i = 0; i < __pArgList->GetCount(); i++)
827 pArgList->Add(new (std::nothrow) String(*static_cast<String*>(__pArgList->GetAt(i))));
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);
835 __pArgList->RemoveAll(true);
838 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgList);
842 ArrayList* pContactId = new (std::nothrow) ArrayList();
843 pContactId->Construct();
845 pContactId->Add(*(new (std::nothrow) Integer(__pPresentationModel->GetContactId(groupIndex, itemIndex))));
846 SceneManager* pSceneManager = SceneManager::GetInstance();
848 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_DETAILS, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pContactId);
853 ContactListPanel::OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, Tizen::Ui::Controls::SweepDirection direction)
858 ContactListPanel::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
864 ContactListPanel::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
866 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
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;
873 HashMap* pReturnValue = new (std::nothrow) HashMap();
874 pReturnValue->Construct();
876 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
878 pList = __pPresentationModel->GetAllPhoneNumbersN(groupIndex, itemIndex);
881 appCtrlResult = APP_CTRL_RESULT_FAILED;
885 AddContactValueOnList(pList, CONTACT_KEY_PHONE, index, pReturnValue);
888 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
891 pList = __pPresentationModel->GetAllEmailsN(groupIndex, itemIndex);
894 appCtrlResult = APP_CTRL_RESULT_FAILED;
898 AddContactValueOnList(pList, CONTACT_KEY_EMAIL, index, pReturnValue);
903 ReturnValues(pContactsApp->GetRequestId(), appCtrlResult, pReturnValue);
907 ContactListPanel::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
913 ContactListPanel::OnTextValueChanged(const Tizen::Ui::Control& source)
915 String searchText = __pSearchBar->GetText();
918 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
919 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
921 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_PHONE_ONLY);
923 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
925 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_EMAIL_ONLY);
929 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_NORMAL);
932 if (searchText.GetLength() != 0)
934 __pSearchListView->SetShowState(true);
935 __pListView->SetShowState(false);
939 __pSearchListView->SetShowState(false);
940 __pListView->SetShowState(true);
943 __pSearchListView->UpdateList();
947 ContactListPanel::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
952 ContactListPanel::ShowDeletePopup(void)
954 if (__pDeletePopup == null)
956 __pDeletePopup = new (std::nothrow) Popup();
957 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
959 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
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);
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);
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);
982 __pDeletePopup->AddControl(pLabel);
983 __pDeletePopup->AddControl(pDeleteButton);
984 __pDeletePopup->AddControl(pCancelButton);
987 __pDeletePopup->SetShowState(true);
988 __pDeletePopup->Show();
992 ContactListPanel::HideDeletePopup(void)
994 delete __pDeletePopup;
995 __pDeletePopup = null;
1001 ContactListPanel::ShowAccountPopup(void)
1003 if (__pAccountListEvent != null)
1005 delete __pAccountListEvent;
1006 __pAccountListEvent = null;
1009 if (__pAccountPopup != null)
1011 delete __pAccountPopup;
1012 __pAccountPopup = null;
1015 if (__pAccountPopup == null)
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"));
1021 Rectangle popupClientBounds = __pAccountPopup->GetClientAreaBounds();
1023 ListView* pAccountListView = new (std::nothrow) ListView();
1024 pAccountListView->Construct(Rectangle(0, 0, popupClientBounds.width, popupClientBounds.height - H_ACCOUNT_POPUP_BUTTON));
1026 __pAccountListEvent = new (std::nothrow) AccountListItemProvider(pAccountListView, __pPresentationModel);
1028 pAccountListView->SetItemProvider(*__pAccountListEvent);
1030 __pAccountPopup->AddControl(pAccountListView);
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);
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);
1044 __pAccountPopup->AddControl(pViewButton);
1045 __pAccountPopup->AddControl(pCancelButton);
1048 __pAccountPopup->SetShowState(true);
1049 __pAccountPopup->Show();
1053 ContactListPanel::HideAccountPopup(void)
1055 delete __pAccountPopup;
1056 __pAccountPopup = null;
1062 ContactListPanel::OnFastScrollIndexSelected (Tizen::Ui::Control& source, Tizen::Base::String& index)
1064 __pListView->ScrollToItem(__pPresentationModel->GetKeyIndex(index), -1);
1065 __pListView->Invalidate(false);
1069 ContactListPanel::ShowContactValuePopup(int groupIndex, int itemIndex)
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));
1076 Rectangle popupClientBounds = __pMultipleContactValuePopup->GetClientAreaBounds();
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);
1083 __pMultipleContactValuePopup->AddControl(pListView);
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);
1090 __pMultipleContactValuePopup->AddControl(pCancelButton);
1091 __pMultipleContactValuePopup->SetShowState(true);
1092 __pMultipleContactValuePopup->Show();
1096 ContactListPanel::HideContactValuePopup(void)
1098 __pMultipleContactValuePopup->SetShowState(false);
1100 delete __pContactValueListEvent;
1101 __pContactValueListEvent = null;
1107 ContactListPanel::ReturnValues(RequestId requestId, Tizen::App::AppCtrlResult appCtrlResult, const Tizen::Base::Collection::IMap* pReturnValue)
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);
1113 UiApp::GetInstance()->Terminate();
1117 ContactListPanel::AddContactValueOnList(const Tizen::Base::Collection::IList* pList, const Tizen::Base::String& keyType, int index, Tizen::Base::Collection::HashMap* pReturnValue)
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);
1125 ArrayList* pValueList = new (std::nothrow) ArrayList();
1126 pValueList->Construct();
1127 pValueList->Add(new (std::nothrow) String(value));
1129 pReturnValue->Add(new (std::nothrow) String(keyType), pValueList);
1133 ContactListPanel::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, const Tizen::Base::String& argument, const Tizen::Base::String& type)
1135 result r = E_SUCCESS;
1137 if (__pAppControl != null)
1144 extraData.Construct();
1146 if (appId.Equals(String(PROVIDER_ID_PHONE)))
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));
1152 else if (appId.Equals(String(PROVIDER_ID_MESSAGE)))
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));
1158 __pAppControl = AppManager::FindAppControlN(appId, operationId);
1159 if (__pAppControl != null)
1161 r = __pAppControl->Start(&uri, null, &extraData, null);
1164 AppLogDebug("[%s] Unable to launch app control", GetErrorMessage(r));
1168 extraData.RemoveAll(true);
1174 ContactListPanel::OnKeypadWillOpen(Tizen::Ui::Control& source)
1179 ContactListPanel::OnKeypadOpened(Tizen::Ui::Control& source)
1181 Form* pForm = dynamic_cast<Form*>(GetParent());
1184 pForm->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1185 __isKeypadOpened = true;
1187 if(__pListView->GetShowState() == true)
1189 __pListView->UpdateList();
1194 ContactListPanel::OnKeypadClosed(Tizen::Ui::Control& source)
1196 Form* pForm = dynamic_cast<Form*>(GetParent());
1199 pForm->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1200 pForm->Invalidate(true);
1202 __isKeypadOpened = false;
1204 if (__changedSceneId.Equals(IDSCN_CONTACT_LIST, true) == false)
1206 SceneManager* pSceneManager = SceneManager::GetInstance();
1207 pSceneManager->GoForward(ForwardSceneTransition(__changedSceneId));
1209 __changedSceneId = IDSCN_CONTACT_LIST;
1212 if(__pListView->GetShowState() == true && __pSearchBar->GetMode() != SEARCH_BAR_MODE_INPUT)
1214 __pListView->UpdateList();
1219 ContactListPanel::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1221 if (keypadAction == KEYPAD_ACTION_SEARCH)
1223 __pSearchBar->HideKeypad();
1228 ContactListPanel::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
1230 if(__pPresentationModel->GetContactCount() > 0)
1232 __pOptionMenu->SetShowState(true);
1233 __pOptionMenu->Show();
1238 ContactListPanel::OnForeground(void)
1240 delete __pAppControl;
1241 __pAppControl = null;
1245 ContactListPanel::OnBackground(void)
1250 ContactListPanel::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
1252 if (source.Equals(*__pListView))
1254 __pListView->SetFocus();
1259 ContactListPanel::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1264 ContactListPanel::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1269 ContactListPanel::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1274 ContactListPanel::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)