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->AddFocusEventListener(*this);
178 __pSearchBar->AddTextEventListener(*this);
179 __pSearchBar->AddKeypadEventListener(*this);
180 __pSearchBar->SetContentAreaSize(Dimension(0, 0));
182 __pSearchListEvent = new (std::nothrow) SearchListEventListener(LIST_ANNEX_STYLE_NORMAL, __pPresentationModel);
184 AddControl(__pSearchBar);
186 __pSearchListView = new (std::nothrow) GroupedListView();
187 __pSearchListView->Construct(Rectangle(0, H_SEARCHBAR, clientBounds.width, clientBounds.height - H_SEARCHBAR), GROUPED_LIST_VIEW_STYLE_INDEXED, true, false);
188 __pSearchListView->SetItemProvider(*__pSearchListEvent);
189 __pSearchListView->AddGroupedListViewItemEventListener(*this);
190 __pSearchListView->AddTouchEventListener(*this);
191 __pSearchListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_PB_BODY_NO_CONTACTS"));
192 __pSearchListView->SetShowState(false);
193 AddControl(__pSearchListView);
195 __pEmptyImageLabel = new (std::nothrow) Label();
196 __pEmptyImageLabel->Construct(Rectangle(X_EMPTY_IMAGE, Y_EMPTY_IMAGE, W_EMPTY_IMAGE, H_EMPTY_IMAGE), L"");
197 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_NO_CONTENTS);
200 __pEmptyImageLabel->SetBackgroundBitmap(*pBitmap);
203 __pEmptyImageLabel->SetShowState(false);
205 AddControl(__pEmptyImageLabel);
207 __pEmptyCommentLabel = new (std::nothrow) Label();
208 __pEmptyCommentLabel->Construct(Rectangle(0, Y_EMPTY_COMMENT, clientBounds.width, H_EMPTY_COMMENT),
209 ResourceManager::GetString(L"IDS_PB_BODY_NO_CONTACTS"));
210 __pEmptyCommentLabel->SetTextConfig(FONT_SIZE_EMPTY_COMMENT, LABEL_TEXT_STYLE_NORMAL);
211 __pEmptyCommentLabel->SetTextColor(Color(COLOR_EMPTY_COMMENT));
212 __pEmptyCommentLabel->SetShowState(false);
214 AddControl(__pEmptyCommentLabel);
216 __pOptionMenu = new (std::nothrow) OptionMenu();
217 __pOptionMenu->Construct();
218 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_SK_DELETE"), IDA_MORE_DELETE);
219 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_MORE_SETTING);
220 __pOptionMenu->AddActionEventListener(*this);
221 __pOptionMenu->SetShowState(false);
226 ContactListPanel::OnTerminating(void)
228 result r = E_SUCCESS;
230 if (__pPresentationModel != null)
232 __pPresentationModel->RemoveContactChangeListener(*this);
235 if (__pArgList != null)
237 __pArgList->RemoveAll(true);
241 delete __pAppControl;
242 delete __pDeletePopup;
243 delete __pAccountPopup;
244 delete __pSearchListEvent;
245 delete __pAccountListEvent;
246 delete __pOptionMenu;
247 delete __pMultipleContactValuePopup;
253 ContactListPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
255 SceneManager* pSceneManager = SceneManager::GetInstance();
256 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
257 Form* pForm = dynamic_cast<Form*>(GetParent());
262 case IDA_HEADER_CONTACTS:
264 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST));
267 case IDA_HEADER_GROUPS:
271 if (__isKeypadOpened)
273 __changedSceneId = IDSCN_GROUP_LIST;
277 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_LIST));
281 case IDA_HEADER_FAVORITES:
285 if (__isKeypadOpened)
287 __changedSceneId = IDSCN_FAVORITE_LIST;
289 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
291 if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_SINGLE)
293 __changedSceneId = IDSCN_FAVORITE_LIST;
295 else if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
297 __changedSceneId = IDSCN_FAVORITE_LIST_EDITOR;
303 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
305 if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_SINGLE)
307 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
309 else if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
311 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST_EDITOR));
316 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
320 case IDA_FOOTER_CREATE:
322 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
325 case IDA_MORE_DELETE:
327 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST_EDITOR));
330 case IDA_MORE_SETTING:
332 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTINGS, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
335 case IDA_POPUP_DELETE_OK:
337 int groupIndex = (__sweptItemIndex >> LIST_VIEW_GROUP_INDEX_SHIFT) & LIST_VIEW_MASK;
338 int itemIndex = __sweptItemIndex & LIST_VIEW_MASK;
340 __pPresentationModel->RemoveContact(groupIndex, itemIndex);
344 case IDA_POPUP_DELETE_CANCEL:
349 case IDA_POPUP_VIEW_OK:
354 case IDA_POPUP_VIEW_CANCEL:
359 case IDA_POPUP_CONTACT_VALUE_CLOSE:
361 HideContactValuePopup();
370 ContactListPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
371 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
373 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
375 const Form* pForm = dynamic_cast<Form*>(GetParent());
378 Form *pEventForm = const_cast<Form*>(pForm);
379 pEventForm->SetFormMenuEventListener(this);
381 Header* pHeader = pForm->GetHeader();
382 pHeader->AddActionEventListener(*this);
384 Footer* pFooter = pForm->GetFooter();
385 pFooter->RemoveAllItems();
386 pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
387 pFooter->SetBackButton();
388 pFooter->AddActionEventListener(*this);
389 pFooter->RemoveMenuButton();
391 __pPresentationModel->InitializeContactList();
393 __pListView->SetFastScrollIndex(__pPresentationModel->GetAllKeys(), false);
394 __pListView->UpdateList();
396 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK || pContactsApp->GetOperationId() == OPERATION_ID_EDIT)
398 if (__pPresentationModel->GetContactCount() == 0)
400 pFooter->RemoveMenuButton();
401 __pSearchBar->SetShowState(false);
402 __pListView->SetShowState(false);
403 __pEmptyImageLabel->SetShowState(true);
404 __pEmptyCommentLabel->SetShowState(true);
408 pFooter->SetMenuButton();
413 __pArgList = new (std::nothrow) ArrayList();
414 __pArgList->Construct();
416 for (int i = 0; i < pArgs->GetCount(); i++)
418 __pArgList->Add(new (std::nothrow) String(*static_cast<String*>(pArgs->GetAt(i))));
424 FooterItem footerItemCreate;
425 footerItemCreate.Construct(IDA_FOOTER_CREATE);
426 footerItemCreate.SetText(ResourceManager::GetString(L"IDS_COM_BODY_CREATE"));
427 pFooter->AddItem(footerItemCreate);
429 if (__pPresentationModel->GetContactCount() > 0)
431 pFooter->SetMenuButton();
432 __pSearchBar->SetShowState(true);
433 __pListView->SetShowState(true);
434 __pEmptyImageLabel->SetShowState(false);
435 __pEmptyCommentLabel->SetShowState(false);
439 pFooter->RemoveMenuButton();
440 __pSearchBar->SetShowState(false);
441 __pListView->SetShowState(false);
442 __pEmptyImageLabel->SetShowState(true);
443 __pEmptyCommentLabel->SetShowState(true);
445 pContactsApp->AddContactsAppChangeEventListener(*this);
448 __pPresentationModel->AddContactChangeListener(*this);
452 pArgs->RemoveAll(true);
458 ContactListPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
459 const Tizen::Ui::Scenes::SceneId& nextSceneId)
461 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
463 Form* pForm = dynamic_cast<Form*>(GetParent());
466 Form *pEventForm = const_cast<Form*>(pForm);
467 pEventForm->SetFormMenuEventListener(null);
469 if (pForm->IsFooterVisible() == false)
471 pForm->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
474 Header* pHeader = pForm->GetHeader();
475 pHeader->RemoveActionEventListener(*this);
477 Footer* pFooter = pForm->GetFooter();
478 pFooter->RemoveActionEventListener(*this);
480 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
482 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
485 __pPresentationModel->RemoveContactChangeListener(*this);
486 pContactsApp->RemoveContactsAppChangeEventListener(*this);
488 delete __pAppControl;
489 __pAppControl = null;
493 ContactListPanel::GetGroupCount(void)
495 return __pPresentationModel->GetKeyCount();
499 ContactListPanel::GetItemCount(int groupIndex)
501 return __pPresentationModel->GetContactCount(groupIndex);
504 Tizen::Ui::Controls::ListItemBase*
505 ContactListPanel::CreateItem(int groupIndex, int itemIndex, int itemWidth)
508 Bitmap* pThumbnail = null;
510 CustomItem* pItem = new (std::nothrow) CustomItem();
511 pItem->Construct(Dimension(itemWidth, H_ITEM), LIST_ANNEX_STYLE_NORMAL);
513 __pPresentationModel->GetContactItemInfoN(groupIndex, itemIndex, name, pThumbnail);
515 ContactListItem* pCustomElement = new (std::nothrow) ContactListItem(name, pThumbnail);
516 pItem->AddElement(Rectangle(0, 0, itemWidth, H_ITEM), 0, *(static_cast<ICustomElement *>(pCustomElement)));
518 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
520 if (pContactsApp->GetOperationId().IsEmpty() == false)
525 bool isCallEnabled = true;
526 bool isMessageEnabled = true;
527 if (__pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex).IsEmpty())
529 isCallEnabled = false;
532 if ((__pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex).IsEmpty()) && (__pPresentationModel->GetDefaultEmail(groupIndex, itemIndex).IsEmpty()))
534 isMessageEnabled = false;
538 ListContextItem* pItemContext = new (std::nothrow) ListContextItem();
539 pItemContext->Construct();
540 pItemContext->AddElement(IDA_LIST_ELEMENT_CALL, ResourceManager::GetString(L"IDS_COM_BODY_CALL"), isCallEnabled);
541 pItemContext->AddElement(IDA_LIST_ELEMENT_MESSAGE, ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"), isMessageEnabled);
542 #if __SUPPORT_VIDEO_CALL
543 pItemContext->AddElement(IDA_LIST_ELEMENT_VIDEO_CALL, ResourceManager::GetString(L"IDS_COM_BODY_VIDEO_CALL"), isCallEnabled);
545 pItemContext->AddElement(IDA_LIST_ELEMENT_DELETE, ResourceManager::GetString(L"IDS_COM_SK_DELETE"));
546 pItemContext->SetElementBackgroundColor(IDA_LIST_ELEMENT_DELETE, LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL, COLOR_DELETE_ELEMENT_NORMAL);
547 pItemContext->SetElementBackgroundColor(IDA_LIST_ELEMENT_DELETE, LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED, COLOR_DELETE_ELEMENT_PRESSED);
548 pItemContext->SetElementTextColor(IDA_LIST_ELEMENT_DELETE, LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL, COLOR_DELETE_ELEMENT_TEXT);
550 pItem->SetContextItem(pItemContext);
555 Tizen::Ui::Controls::GroupItem*
556 ContactListPanel::CreateGroupItem(int groupIndex, int itemWidth)
558 GroupItem* pItem = new (std::nothrow) GroupItem();
559 pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM));
560 pItem->SetElement(__pPresentationModel->GetKey(groupIndex), null);
566 ContactListPanel::DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
568 CustomItem* pCustomItem = static_cast<CustomItem *>(pItem);
570 pCustomItem->RemoveAllElements();
579 ContactListPanel::DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::GroupItem* pItem, int itemWidth)
588 ContactListPanel::OnContactsChanged(void)
590 Form* pForm = dynamic_cast<Form*>(GetParent());
595 Footer* pFooter = pForm->GetFooter();
597 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
599 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
603 __pPresentationModel->InitializeContactList();
605 if (__pPresentationModel->GetContactCount() > 0)
610 pFooter->SetMenuButton();
611 __pSearchBar->SetShowState(true);
612 __pListView->SetShowState(true);
613 __pEmptyImageLabel->SetShowState(false);
614 __pEmptyCommentLabel->SetShowState(false);
616 __pListView->GetTopDrawnItemIndex(groupIndex, itemIndex);
617 __pListView->UpdateList();
618 __pListView->SetFastScrollIndex(__pPresentationModel->GetAllKeys(), false);
619 __pListView->Invalidate(true);
620 __pListView->ScrollToItem(groupIndex, itemIndex);
624 pFooter->RemoveMenuButton();
625 __pSearchBar->SetShowState(false);
626 __pListView->SetShowState(false);
627 __pEmptyImageLabel->SetShowState(true);
628 __pEmptyCommentLabel->SetShowState(true);
633 ContactListPanel::OnCategoriesChanged(void)
638 ContactListPanel::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
640 if (mode == SEARCH_BAR_MODE_NORMAL)
642 __pListView->SetShowState(true);
643 __pSearchListView->SetShowState(false);
644 __pPresentationModel->ResetSearchedContactList();
645 __pSearchListView->UpdateList();
646 __pListView->UpdateList();
650 //[TODO] to restore swept item.
651 // need to be fixed with better idea..
652 Rectangle bounds = __pListView->GetBounds();
653 __pListView->SetBounds(bounds.x, bounds.y, bounds.width, bounds.height + 1);
654 __pListView->Invalidate(true);
655 __pListView->SetBounds(bounds);
660 ContactListPanel::OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
664 index |= groupIndex << LIST_VIEW_GROUP_INDEX_SHIFT;
667 __sweptItemIndex = index;
671 case IDA_LIST_ELEMENT_DELETE:
676 case IDA_LIST_ELEMENT_CALL:
678 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
679 LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, phoneNumber, INPUT_TYPE_VOICE);
682 case IDA_LIST_ELEMENT_MESSAGE:
684 if (!(__pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex).IsEmpty()))
686 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
687 LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, phoneNumber, INPUT_TYPE_SMS);
689 else if (!(__pPresentationModel->GetDefaultEmail(groupIndex, itemIndex).IsEmpty()))
691 String emailId = __pPresentationModel->GetDefaultEmail(groupIndex, itemIndex);
692 LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, emailId, null);
696 case IDA_LIST_ELEMENT_VIDEO_CALL:
698 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
699 LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, phoneNumber, INPUT_TYPE_VIDEO);
708 ContactListPanel::OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus state)
710 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
712 if (listView.Equals(*__pSearchListView) == true)
714 __pPresentationModel->GetItemMainIndex(itemIndex, groupIndex, itemIndex);
718 __selectedIndex |= groupIndex << LIST_VIEW_GROUP_INDEX_SHIFT;
719 __selectedIndex |= itemIndex;
721 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
724 HashMap* pReturnValue = new (std::nothrow) HashMap();
725 pReturnValue->Construct();
727 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
729 pList = __pPresentationModel->GetAllPhoneNumbersN(groupIndex, itemIndex);
733 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
737 if (pList->GetCount() > 1)
739 __pContactValueListEvent = new (std::nothrow) ContactValueListItemProvider(pList);
740 ShowContactValuePopup(groupIndex, itemIndex);
742 else if (pList->GetCount() == 1)
744 AddContactValueOnList(pList, CONTACT_KEY_PHONE, 0, pReturnValue);
746 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
751 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
753 pList = __pPresentationModel->GetAllEmailsN(groupIndex, itemIndex);
757 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
761 if (pList->GetCount() > 1)
763 __pContactValueListEvent = new (std::nothrow) ContactValueListItemProvider(pList);
764 ShowContactValuePopup(groupIndex, itemIndex);
766 else if (pList->GetCount() == 1)
768 AddContactValueOnList(pList, CONTACT_KEY_EMAIL, 0, pReturnValue);
770 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
775 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_ITEM_ID)
777 AppCtrlResult appCtrlResult = APP_CTRL_RESULT_SUCCEEDED;
778 RecordId contactId = __pPresentationModel->GetContactId(groupIndex, itemIndex);
779 if (contactId == INVALID_RECORD_ID)
781 appCtrlResult = APP_CTRL_RESULT_FAILED;
786 ArrayList* pValueList = new (std::nothrow) ArrayList();
787 pValueList->Construct();
789 contactId.Append(__pPresentationModel->GetContactId(groupIndex, itemIndex));
790 pValueList->Add(new (std::nothrow) String(contactId));
792 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), pValueList);
795 ReturnValues(pContactsApp->GetRequestId(), appCtrlResult, pReturnValue);
797 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_VCARD)
799 AppCtrlResult appCtrlResult = APP_CTRL_RESULT_SUCCEEDED;
800 String vCardPath = __pPresentationModel->ExportToVcard(groupIndex, itemIndex);
802 if (vCardPath.IsEmpty())
804 appCtrlResult = APP_CTRL_RESULT_FAILED;
808 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_PATH), new (std::nothrow) String(vCardPath));
811 ReturnValues(pContactsApp->GetRequestId(), appCtrlResult, pReturnValue);
816 else if (pContactsApp->GetOperationId() == OPERATION_ID_EDIT)
818 ArrayList* pArgList = null;
819 SceneManager* pSceneManager = SceneManager::GetInstance();
821 if (__pArgList != null)
823 pArgList = new (std::nothrow) ArrayList();
824 pArgList->Construct();
826 for (int i = 0; i < __pArgList->GetCount(); i++)
828 pArgList->Add(new (std::nothrow) String(*static_cast<String*>(__pArgList->GetAt(i))));
831 String* pContactId = new (std::nothrow) String(RETURN_TYPE_ITEM_ID);
832 pContactId->Append(DELIMITER);
833 pContactId->Append(__pPresentationModel->GetContactId(groupIndex, itemIndex));
834 pArgList->InsertAt(pContactId, 0);
836 __pArgList->RemoveAll(true);
839 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgList);
843 ArrayList* pContactId = new (std::nothrow) ArrayList();
844 pContactId->Construct();
846 pContactId->Add(*(new (std::nothrow) Integer(__pPresentationModel->GetContactId(groupIndex, itemIndex))));
847 SceneManager* pSceneManager = SceneManager::GetInstance();
849 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_DETAILS, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pContactId);
854 ContactListPanel::OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, Tizen::Ui::Controls::SweepDirection direction)
859 ContactListPanel::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
865 ContactListPanel::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
867 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
870 int groupIndex = (__selectedIndex >> LIST_VIEW_GROUP_INDEX_SHIFT) & LIST_VIEW_MASK;
871 int itemIndex = __selectedIndex & LIST_VIEW_MASK;
872 AppCtrlResult appCtrlResult = APP_CTRL_RESULT_SUCCEEDED;
874 HashMap* pReturnValue = new (std::nothrow) HashMap();
875 pReturnValue->Construct();
877 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
879 pList = __pPresentationModel->GetAllPhoneNumbersN(groupIndex, itemIndex);
882 appCtrlResult = APP_CTRL_RESULT_FAILED;
886 AddContactValueOnList(pList, CONTACT_KEY_PHONE, index, pReturnValue);
889 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
892 pList = __pPresentationModel->GetAllEmailsN(groupIndex, itemIndex);
895 appCtrlResult = APP_CTRL_RESULT_FAILED;
899 AddContactValueOnList(pList, CONTACT_KEY_EMAIL, index, pReturnValue);
904 ReturnValues(pContactsApp->GetRequestId(), appCtrlResult, pReturnValue);
908 ContactListPanel::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
914 ContactListPanel::OnTextValueChanged(const Tizen::Ui::Control& source)
916 String searchText = __pSearchBar->GetText();
919 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
920 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
922 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_PHONE_ONLY);
924 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
926 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_EMAIL_ONLY);
930 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_NORMAL);
933 if (searchText.GetLength() != 0)
935 __pSearchListView->SetShowState(true);
936 __pListView->SetShowState(false);
940 __pSearchListView->SetShowState(false);
941 __pListView->SetShowState(true);
944 __pSearchListView->UpdateList();
948 ContactListPanel::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
953 ContactListPanel::ShowDeletePopup(void)
955 if (__pDeletePopup == null)
957 __pDeletePopup = new (std::nothrow) Popup();
958 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
960 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
962 Label* pLabel = new (std::nothrow) Label();
963 pLabel->Construct(Rectangle(X_DELETE_LABEL, Y_DELETE_LABEL, W_DELETE_LABEL, H_DELETE_LABEL), ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
964 pLabel->SetTextConfig(FONT_SIZE_DELETE_CONFIRM, LABEL_TEXT_STYLE_NORMAL);
965 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
966 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
968 Button* pDeleteButton = new (std::nothrow) Button();
969 pDeleteButton->Construct(Rectangle(X_DELETE_LABEL, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_SK_DELETE"));
970 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
971 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
972 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
973 pDeleteButton->SetTextSize(FONT_SIZE_DELETE_BUTTON);
974 pDeleteButton->SetActionId(IDA_POPUP_DELETE_OK);
975 pDeleteButton->AddActionEventListener(*this);
977 Button* pCancelButton = new (std::nothrow) Button();
978 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"));
979 pCancelButton->SetTextSize(FONT_SIZE_DELETE_BUTTON);
980 pCancelButton->SetActionId(IDA_POPUP_DELETE_CANCEL);
981 pCancelButton->AddActionEventListener(*this);
983 __pDeletePopup->AddControl(pLabel);
984 __pDeletePopup->AddControl(pDeleteButton);
985 __pDeletePopup->AddControl(pCancelButton);
988 __pDeletePopup->SetShowState(true);
989 __pDeletePopup->Show();
993 ContactListPanel::HideDeletePopup(void)
995 delete __pDeletePopup;
996 __pDeletePopup = null;
1002 ContactListPanel::ShowAccountPopup(void)
1004 if (__pAccountListEvent != null)
1006 delete __pAccountListEvent;
1007 __pAccountListEvent = null;
1010 if (__pAccountPopup != null)
1012 delete __pAccountPopup;
1013 __pAccountPopup = null;
1016 if (__pAccountPopup == null)
1018 __pAccountPopup = new (std::nothrow) Popup();
1019 __pAccountPopup->Construct(true, Dimension(W_ACCOUNT_POPUP, H_ACCOUNT_POPUP));
1020 __pAccountPopup->SetTitleText(ResourceManager::GetString(L"IDS_PB_OPT_VIEW"));
1022 Rectangle popupClientBounds = __pAccountPopup->GetClientAreaBounds();
1024 ListView* pAccountListView = new (std::nothrow) ListView();
1025 pAccountListView->Construct(Rectangle(0, 0, popupClientBounds.width, popupClientBounds.height - H_ACCOUNT_POPUP_BUTTON));
1027 __pAccountListEvent = new (std::nothrow) AccountListItemProvider(pAccountListView, __pPresentationModel);
1029 pAccountListView->SetItemProvider(*__pAccountListEvent);
1031 __pAccountPopup->AddControl(pAccountListView);
1033 Button* pViewButton = new (std::nothrow) Button();
1034 pViewButton->Construct(Rectangle(0, popupClientBounds.height - H_ACCOUNT_POPUP_BUTTON, popupClientBounds.width / 2 - W_POPUP_ITEM_GAP, H_ACCOUNT_POPUP_BUTTON),
1035 ResourceManager::GetString(L"IDS_PB_OPT_VIEW"));
1036 pViewButton->SetActionId(IDA_POPUP_VIEW_OK);
1037 pViewButton->AddActionEventListener(*this);
1039 Button* pCancelButton = new (std::nothrow) Button();
1040 pCancelButton->Construct(Rectangle(popupClientBounds.width / 2 + W_POPUP_ITEM_GAP, popupClientBounds.height - H_ACCOUNT_POPUP_BUTTON,
1041 popupClientBounds.width / 2 - W_POPUP_ITEM_GAP, H_ACCOUNT_POPUP_BUTTON), ResourceManager::GetString(L"IDS_PB_SK_CANCEL"));
1042 pCancelButton->SetActionId(IDA_POPUP_VIEW_CANCEL);
1043 pCancelButton->AddActionEventListener(*this);
1045 __pAccountPopup->AddControl(pViewButton);
1046 __pAccountPopup->AddControl(pCancelButton);
1049 __pAccountPopup->SetShowState(true);
1050 __pAccountPopup->Show();
1054 ContactListPanel::HideAccountPopup(void)
1056 delete __pAccountPopup;
1057 __pAccountPopup = null;
1063 ContactListPanel::OnFastScrollIndexSelected (Tizen::Ui::Control& source, Tizen::Base::String& index)
1065 __pListView->ScrollToItem(__pPresentationModel->GetKeyIndex(index), -1);
1066 __pListView->Invalidate(false);
1070 ContactListPanel::OnFocusGained(const Tizen::Ui::Control& source)
1072 if (source.Equals(*__pSearchBar))
1074 if (__pListView->GetShowState() == true)
1076 __pListView->UpdateList();
1082 ContactListPanel::OnFocusLost(const Tizen::Ui::Control& source)
1087 ContactListPanel::ShowContactValuePopup(int groupIndex, int itemIndex)
1089 delete __pMultipleContactValuePopup;
1090 __pMultipleContactValuePopup = new (std::nothrow) Popup();
1091 __pMultipleContactValuePopup->Construct(true, Dimension(W_CONTACT_VALUE_POPUP, H_CONTACT_VALUE_POPUP));
1092 __pMultipleContactValuePopup->SetTitleText(__pPresentationModel->GetName(groupIndex, itemIndex));
1094 Rectangle popupClientBounds = __pMultipleContactValuePopup->GetClientAreaBounds();
1096 ListView* pListView = new (std::nothrow) ListView();
1097 pListView->Construct(Rectangle(0, 0, popupClientBounds.width, H_CONTACT_VALUE_POPUP_LIST_VIEW));
1098 pListView->SetItemProvider(*__pContactValueListEvent);
1099 pListView->AddListViewItemEventListener(*this);
1101 __pMultipleContactValuePopup->AddControl(pListView);
1103 Button* pCancelButton = new (std::nothrow) Button();
1104 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"));
1105 pCancelButton->SetActionId(IDA_POPUP_CONTACT_VALUE_CLOSE);
1106 pCancelButton->AddActionEventListener(*this);
1108 __pMultipleContactValuePopup->AddControl(pCancelButton);
1109 __pMultipleContactValuePopup->SetShowState(true);
1110 __pMultipleContactValuePopup->Show();
1114 ContactListPanel::HideContactValuePopup(void)
1116 __pMultipleContactValuePopup->SetShowState(false);
1118 delete __pContactValueListEvent;
1119 __pContactValueListEvent = null;
1125 ContactListPanel::ReturnValues(RequestId requestId, Tizen::App::AppCtrlResult appCtrlResult, const Tizen::Base::Collection::IMap* pReturnValue)
1127 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
1128 result r = pAppManager->SendAppControlResult(requestId, appCtrlResult, pReturnValue);
1129 AppLogDebug("[%s] The return result from SendAppControlResult(), AppCtrlResult value : %d.", GetErrorMessage(r), appCtrlResult);
1131 UiApp::GetInstance()->Terminate();
1135 ContactListPanel::AddContactValueOnList(const Tizen::Base::Collection::IList* pList, const Tizen::Base::String& keyType, int index, Tizen::Base::Collection::HashMap* pReturnValue)
1139 String value(*(static_cast<const String *>(pList->GetAt(index))));
1140 value.LastIndexOf(CHARACTER_SPACE, value.GetLength()-1, blankIndex);
1141 value.Remove(0, blankIndex + 1);
1143 ArrayList* pValueList = new (std::nothrow) ArrayList();
1144 pValueList->Construct();
1145 pValueList->Add(new (std::nothrow) String(value));
1147 pReturnValue->Add(new (std::nothrow) String(keyType), pValueList);
1151 ContactListPanel::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, const Tizen::Base::String& argument, const Tizen::Base::String& type)
1153 result r = E_SUCCESS;
1155 if (__pAppControl != null)
1162 extraData.Construct();
1164 if (appId.Equals(String(PROVIDER_ID_PHONE)))
1166 uri.Append(INPUT_URI_TEL);
1167 uri.Append(argument);
1168 extraData.Add(new (std::nothrow) String(INPUT_KEY_CALL_TYPE), new (std::nothrow) String(type));
1170 else if (appId.Equals(String(PROVIDER_ID_MESSAGE)))
1172 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TO), new (std::nothrow) String(argument));
1173 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TYPE), new (std::nothrow) String(type));
1176 __pAppControl = AppManager::FindAppControlN(appId, operationId);
1177 if (__pAppControl != null)
1179 r = __pAppControl->Start(&uri, null, &extraData, null);
1182 AppLogDebug("[%s] Unable to launch app control", GetErrorMessage(r));
1186 extraData.RemoveAll(true);
1192 ContactListPanel::OnKeypadWillOpen(Tizen::Ui::Control& source)
1197 ContactListPanel::OnKeypadOpened(Tizen::Ui::Control& source)
1199 Form* pForm = dynamic_cast<Form*>(GetParent());
1202 pForm->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1203 __isKeypadOpened = true;
1207 ContactListPanel::OnKeypadClosed(Tizen::Ui::Control& source)
1209 Form* pForm = dynamic_cast<Form*>(GetParent());
1212 pForm->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1213 pForm->Invalidate(true);
1215 __isKeypadOpened = false;
1217 if (__changedSceneId.Equals(IDSCN_CONTACT_LIST, true) == false)
1219 SceneManager* pSceneManager = SceneManager::GetInstance();
1220 pSceneManager->GoForward(ForwardSceneTransition(__changedSceneId));
1222 __changedSceneId = IDSCN_CONTACT_LIST;
1227 ContactListPanel::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1229 if (keypadAction == KEYPAD_ACTION_SEARCH)
1231 __pSearchBar->HideKeypad();
1236 ContactListPanel::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
1238 if(__pPresentationModel->GetContactCount() > 0)
1240 __pOptionMenu->SetShowState(true);
1241 __pOptionMenu->Show();
1246 ContactListPanel::OnForeground(void)
1248 delete __pAppControl;
1249 __pAppControl = null;
1253 ContactListPanel::OnBackground(void)
1258 ContactListPanel::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
1260 if (source.Equals(*__pListView))
1262 __pListView->SetFocus();
1267 ContactListPanel::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1272 ContactListPanel::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1277 ContactListPanel::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1282 ContactListPanel::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)