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 CtFavoriteListPanel.cpp
19 * @brief This is the implementation file for the FavoriteListPanel class.
23 #include "CtContactsApp.h"
24 #include "CtContactValueListItemProvider.h"
25 #include "CtFavoriteListPanel.h"
26 #include "CtFavoriteListPresentationModel.h"
27 #include "CtMainForm.h"
28 #include "CtResourceManager.h"
29 #include "CtSceneRegister.h"
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
40 static const int IDA_FOOTER_ADD_FAVORITE = 1;
41 static const int IDA_MORE_EDIT_FAVORITE = 2;
42 static const int IDA_HEADER_CONTACTS = 10;
43 static const int IDA_HEADER_GROUPS = 11;
44 static const int IDA_HEADER_FAVORITES = 12;
45 static const int IDA_POPUP_CONTACT_VALUE_CLOSE = 20;
46 static const int IDA_FAVORITE_QUICK_MENU = 21;
47 static const int IDA_CONTEXTMENU_CALL = 30;
48 static const int IDA_CONTEXTMENU_MESSAGE = 31;
49 static const int IDA_CONTEXTMENU_VIDEO_CALL = 32;
50 static const int IDA_CONTEXTMENU_REMOVE = 33;
52 static const wchar_t* IDB_NO_FAVORITES = L"00_Nocontents_picture.png";
53 static const wchar_t* IDB_QUICK_MENU = L"00_button_expand_closed_press.png";
55 static const int W_INITAIL_PANEL = 10;
56 static const int H_INITIAL_PANEL = 10;
57 static const int W_ICONLISTVIEW_ITEM = 239;
58 static const int H_ICONLISTVIEW_ITEM = 239;
59 static const int H_TEXT_BACKGROUND = 64;
60 static const int H_TEXT_SPACE = 96;
61 static const int W_CONTACT_VALUE_POPUP = 688;
62 static const int H_CONTACT_VALUE_POPUP = 532;
63 static const int H_CONTACT_VALUE_POPUP_LIST_VIEW = 338;
64 static const int Y_CLOSE_BUTTON = 358;
65 static const int W_CLOSE_BUTTON = 394;
66 static const int H_CLOSE_BUTTON = 74;
67 static const int W_QUICK_MENU_BUTTON = 74;
68 static const int X_EMPTY_IMAGE = 220;
69 static const int Y_EMPTY_IMAGE = 300;
70 static const int W_EMPTY_IMAGE = 280;
71 static const int H_EMPTY_IMAGE = 280;
72 static const int Y_EMPTY_COMMENT = 618;
73 static const int H_EMPTY_COMMENT = 38;
74 static const int W_ITEM_SPACE = 1;
75 static const int H_ITEM_SPACE = 1;
76 static const int W_NAME_TEXT_MARGIN = 10;
78 static const int FONT_SIZE_WITH_THUMBNAIL = 24;
79 static const int FONT_SIZE_EMPTY_COMMENT = 32;
80 static const int FONT_SIZE = 40;
82 static const unsigned int COLOR_ITEM_BACKGROUND = Color32<201, 201, 201>::Value;
83 static const unsigned int COLOR_ITEM_TEXT_BACKGROUND = Color32<0, 0, 0, 89>::Value;
84 static const unsigned int COLOR_TEXT_WITH_THUMBNAIL = Color32<249, 249, 249>::Value;
85 static const unsigned int COLOR_TEXT = Color32<255, 255, 255>::Value;
86 static const unsigned int COLOR_LINE = Color32<225, 225, 225, 26>::Value;
87 static const unsigned int COLOR_EMPTY_COMMENT = Color32<102, 102, 102>::Value;
89 static const wchar_t* INPUT_KEY_CALL_TYPE = L"http://tizen.org/appcontrol/data/call/type";
90 static const wchar_t* INPUT_KEY_MESSAGE_TYPE = L"http://tizen.org/appcontrol/data/message/type";
91 static const wchar_t* INPUT_KEY_MESSAGE_TO = L"http://tizen.org/appcontrol/data/to";
92 static const wchar_t* INPUT_TYPE_VIDEO = L"video";
93 static const wchar_t* INPUT_TYPE_VOICE = L"voice";
94 static const wchar_t* INPUT_TYPE_SMS = L"sms";
95 static const wchar_t* INPUT_URI_TEL = L"tel:";
97 FavoriteListPanel::FavoriteListPanel(void)
98 : __isAppControlLaunching(false)
99 , __scrolledDistance(0)
100 , __selectedItemIndex(0)
101 , __pAppControl(null)
102 , __pContextMenuAction(null)
103 , __pOptionMenu(null)
104 , __pFavoriteListView(null)
105 , __pMultipleContactValuePopup(null)
106 , __pEmptyImageLabel(null)
107 , __pEmptyCommentLabel(null)
108 , __pPresentationModel(null)
109 , __pContactValueListProvider(null)
113 FavoriteListPanel::~FavoriteListPanel(void)
118 FavoriteListPanel::Initialize(void)
120 Construct(Rectangle(0, 0, W_INITAIL_PANEL, H_INITIAL_PANEL));
124 FavoriteListPanel::OnInitializing(void)
126 result r = E_SUCCESS;
128 const Form* pForm = dynamic_cast<Form*>(GetParent());
131 Rectangle clientBounds = pForm->GetClientAreaBounds();
132 SetBounds(Rectangle(0, 0, clientBounds.width, clientBounds.height));
134 __pPresentationModel = FavoriteListPresentationModel::GetInstance();
136 __pFavoriteListView = new (std::nothrow) IconListView();
137 __pFavoriteListView->Construct(Rectangle(0, 0, clientBounds.width, clientBounds.height), Dimension(W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM));
138 __pFavoriteListView->SetItemProvider(*this);
139 __pFavoriteListView->AddIconListViewItemEventListener(*this);
140 __pFavoriteListView->AddScrollEventListener(*this);
141 __pFavoriteListView->SetItemLayoutHorizontalAlignment(ALIGNMENT_LEFT);
142 __pFavoriteListView->SetItemLayoutVerticalAlignment(ALIGNMENT_TOP);
143 __pFavoriteListView->SetItemSpacing(W_ITEM_SPACE, H_ITEM_SPACE);
144 __pFavoriteListView->SetMargin(MARGIN_TYPE_LEFT, 0);
145 __pFavoriteListView->SetMargin(MARGIN_TYPE_RIGHT, 0);
146 __pFavoriteListView->SetTouchAnimationEnabled(false);
148 AddControl(__pFavoriteListView);
150 __pEmptyImageLabel = new (std::nothrow) Label();
151 __pEmptyImageLabel->Construct(Rectangle(X_EMPTY_IMAGE, Y_EMPTY_IMAGE, W_EMPTY_IMAGE, H_EMPTY_IMAGE), L"");
152 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_NO_FAVORITES);
155 __pEmptyImageLabel->SetBackgroundBitmap(*pBitmap);
158 __pEmptyImageLabel->SetShowState(false);
160 AddControl(__pEmptyImageLabel);
162 __pEmptyCommentLabel = new (std::nothrow) Label();
163 __pEmptyCommentLabel->Construct(Rectangle(0, Y_EMPTY_COMMENT, clientBounds.width, H_EMPTY_COMMENT),
164 ResourceManager::GetString(L"IDS_PB_BODY_NO_FAVOURITES"));
165 __pEmptyCommentLabel->SetTextConfig(FONT_SIZE_EMPTY_COMMENT, LABEL_TEXT_STYLE_NORMAL);
166 __pEmptyCommentLabel->SetTextColor(Color(COLOR_EMPTY_COMMENT));
167 __pEmptyCommentLabel->SetShowState(false);
169 AddControl(__pEmptyCommentLabel);
171 __pOptionMenu = new (std::nothrow) OptionMenu();
172 __pOptionMenu->Construct();
173 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_SK_EDIT"), IDA_MORE_EDIT_FAVORITE);
174 __pOptionMenu->AddActionEventListener(*this);
175 __pOptionMenu->SetShowState(false);
181 FavoriteListPanel::OnTerminating(void)
183 result r = E_SUCCESS;
185 if (__pPresentationModel != null)
187 __pPresentationModel->RemoveContactChangeListener(*this);
190 delete __pAppControl;
191 delete __pContextMenuAction;
192 delete __pMultipleContactValuePopup;
198 FavoriteListPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
200 SceneManager* pSceneManager = SceneManager::GetInstance();
201 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
205 case IDA_HEADER_CONTACTS:
207 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
209 if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_SINGLE)
211 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST));
213 else if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
215 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST_EDITOR));
220 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST));
224 case IDA_HEADER_GROUPS:
226 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_LIST));
229 case IDA_HEADER_FAVORITES:
231 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
234 case IDA_FOOTER_ADD_FAVORITE:
236 ArrayList* pArgList = new (std::nothrow) ArrayList();
237 pArgList->Construct();
239 for (int i = 0; i < __pPresentationModel->GetFavoriteCount(); i++)
241 pArgList->Add(*(new (std::nothrow) Integer(__pPresentationModel->GetContactId(i))));
244 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_SELECTOR, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgList);
247 case IDA_MORE_EDIT_FAVORITE:
249 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST_EDITOR));
252 case IDA_POPUP_CONTACT_VALUE_CLOSE:
254 HideContactValuePopup();
257 case IDA_CONTEXTMENU_CALL:
259 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(__selectedItemIndex);
260 LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, phoneNumber, INPUT_TYPE_VOICE);
263 case IDA_CONTEXTMENU_MESSAGE:
265 if (!(__pPresentationModel->GetDefaultPhoneNumber(__selectedItemIndex).IsEmpty()))
267 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(__selectedItemIndex);
268 LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, phoneNumber, INPUT_TYPE_SMS);
270 else if (!(__pPresentationModel->GetDefaultEmail(__selectedItemIndex).IsEmpty()))
272 String emailId = __pPresentationModel->GetDefaultEmail(__selectedItemIndex);
273 LaunchAppControl(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE, emailId, null);
277 case IDA_CONTEXTMENU_VIDEO_CALL:
279 String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(__selectedItemIndex);
280 LaunchAppControl(PROVIDER_ID_PHONE, OPERATION_ID_CALL, phoneNumber, INPUT_TYPE_VIDEO);
283 case IDA_CONTEXTMENU_REMOVE:
285 __pPresentationModel->SetAsFavorite(__pPresentationModel->GetContactId(__selectedItemIndex), false);
286 __pPresentationModel->InitializeFavoriteList();
288 const Form* pForm = dynamic_cast<Form*>(GetParent());
290 Footer* pFooter = pForm->GetFooter();
291 if (__pPresentationModel->GetContactCount() > __pPresentationModel->GetFavoriteCount())
293 pFooter->SetItemEnabled(0, true);
294 pFooter->Invalidate(true);
297 if (__pPresentationModel->GetFavoriteCount() == 0)
299 __pFavoriteListView->SetShowState(false);
300 __pEmptyImageLabel->SetShowState(true);
301 __pEmptyCommentLabel->SetShowState(true);
302 pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
305 __pFavoriteListView->UpdateList();
314 FavoriteListPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
316 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
318 if (previousSceneId.Equals(IDSCN_CONTACT_SELECTOR, true) && pArgs != null)
320 Integer* pContactId = null;
321 IEnumerator* pEnum = pArgs->GetEnumeratorN();
323 while (pEnum->MoveNext() == E_SUCCESS)
325 pContactId = static_cast<Integer*>(pEnum->GetCurrent());
326 if (pContactId != null)
328 __pPresentationModel->SetAsFavorite(pContactId->ToInt(), true);
332 pArgs->RemoveAll(true);
336 Form* pForm = dynamic_cast<Form*>(GetParent());
339 Form *pEventForm = const_cast<Form*>(pForm);
340 pEventForm->SetFormMenuEventListener(this);
342 Header* pHeader = pForm->GetHeader();
343 pHeader->AddActionEventListener(*this);
345 Footer* pFooter = pForm->GetFooter();
346 pFooter->RemoveAllItems();
347 pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
348 pFooter->AddActionEventListener(*this);
350 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
352 pEventForm->SetFormMenuEventListener(null);
353 __pPresentationModel->InitializeFavoriteList(pContactsApp->GetReturnType());
357 __pPresentationModel->InitializeFavoriteList();
359 FooterItem footerItemAdd;
360 footerItemAdd.Construct(IDA_FOOTER_ADD_FAVORITE);
361 footerItemAdd.SetText(ResourceManager::GetString(L"IDS_PB_OPT_ADD_TO_FAVORITES"));
362 pFooter->AddItem(footerItemAdd);
363 if (__pPresentationModel->GetContactCount() <= __pPresentationModel->GetFavoriteCount())
365 pFooter->SetItemEnabled(0, false);
368 if (__pPresentationModel->GetFavoriteCount() > 0 )
370 pForm->SetFormMenuEventListener(this);
374 pForm->SetFormMenuEventListener(null);
377 pContactsApp->AddContactsAppChangeEventListener(*this);
380 if (__pPresentationModel->GetFavoriteCount() > 0)
382 __pFavoriteListView->SetShowState(true);
383 __pEmptyImageLabel->SetShowState(false);
384 __pEmptyCommentLabel->SetShowState(false);
386 __pFavoriteListView->UpdateList();
390 __pFavoriteListView->SetShowState(false);
391 __pEmptyImageLabel->SetShowState(true);
392 __pEmptyCommentLabel->SetShowState(true);
395 __pPresentationModel->AddContactChangeListener(*this);
399 FavoriteListPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
401 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
402 pContactsApp->RemoveContactsAppChangeEventListener(*this);
404 const Form* pForm = dynamic_cast<Form*>(GetParent());
407 Form *pEventForm = const_cast<Form*>(pForm);
408 pEventForm->SetFormMenuEventListener(null);
410 Header* pHeader = pForm->GetHeader();
411 pHeader->RemoveActionEventListener(*this);
413 Footer* pFooter = pForm->GetFooter();
414 pFooter->RemoveActionEventListener(*this);
416 __pPresentationModel->RemoveContactChangeListener(*this);
418 delete __pAppControl;
419 __pAppControl = null;
423 FavoriteListPanel::OnIconListViewItemReordered(Tizen::Ui::Controls::IconListView &iconListView, int indexFrom, int indexTo)
428 FavoriteListPanel::OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView &iconListView, int index, Tizen::Ui::Controls::IconListViewItemStatus status)
430 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
432 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
434 HashMap* pReturnValue = new (std::nothrow) HashMap();
435 pReturnValue->Construct();
437 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_ITEM_ID)
440 ArrayList* pValueList = new (std::nothrow) ArrayList();
441 pValueList->Construct();
443 contactId.Append(__pPresentationModel->GetContactId(index));
444 pValueList->Add(new (std::nothrow) String(contactId));
446 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), pValueList);
448 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
452 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_VCARD)
454 AppCtrlResult appCtrlResult = APP_CTRL_RESULT_SUCCEEDED;
455 String vCardPath = __pPresentationModel->ExportToVcard(index);
457 if (vCardPath.IsEmpty())
459 appCtrlResult = APP_CTRL_RESULT_FAILED;
463 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_PATH), new (std::nothrow) String(vCardPath));
465 ReturnValues(pContactsApp->GetRequestId(), appCtrlResult, pReturnValue);
470 IList* pList = __pPresentationModel->GetMultiValuesN(pContactsApp->GetReturnType(), index);
473 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
478 if (pList->GetCount() > 1)
480 __pContactValueListProvider = new (std::nothrow) ContactValueListItemProvider(pList);
481 ShowContactValuePopup(index);
483 else if (pList->GetCount() == 1)
487 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
489 keyType.Append(CONTACT_KEY_PHONE);
491 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
493 keyType.Append(CONTACT_KEY_EMAIL);
500 String* pReturnInfo = static_cast<String*>(pList->GetAt(0));
502 ArrayList* pValueList = new (std::nothrow) ArrayList();
503 pValueList->Construct();
505 pReturnInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
506 pReturnInfo->Remove(0, blankIndex + 1);
508 pValueList->Add(new (std::nothrow) String(*pReturnInfo));
509 pReturnValue->Add(new (std::nothrow) String(keyType), pValueList);
511 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
519 SceneManager* pSceneManager = SceneManager::GetInstance();
521 ArrayList* pContactId = new (std::nothrow) ArrayList();
522 pContactId->Construct();
524 pContactId->Add(*(new (std::nothrow) Integer(__pPresentationModel->GetContactId(index))));
525 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_DETAILS, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pContactId);
530 FavoriteListPanel::OnIconListViewOverlayBitmapSelected(Tizen::Ui::Controls::IconListView& iconListView, int index, int overlayBitmapId)
532 if(__isAppControlLaunching == true)
536 if (__pContextMenuAction != null)
538 delete __pContextMenuAction;
541 if (overlayBitmapId == IDA_FAVORITE_QUICK_MENU)
543 const Form* pForm = dynamic_cast<Form*>(GetParent());
546 Point itemPosition(W_ICONLISTVIEW_ITEM * (index % iconListView.GetItemCountPerAxis() + 1) - (W_QUICK_MENU_BUTTON / 2), pForm->GetClientAreaBounds().y + H_ICONLISTVIEW_ITEM * (index / iconListView.GetItemCountPerAxis() + 1) - __scrolledDistance);
548 __pContextMenuAction = new (std::nothrow) ContextMenu();
549 __pContextMenuAction->Construct(itemPosition, CONTEXT_MENU_STYLE_GRID, CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD);
551 if (__pPresentationModel->GetDefaultPhoneNumber(index).IsEmpty() == false)
553 __pContextMenuAction->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_CALL"), IDA_CONTEXTMENU_CALL);
554 #if __SUPPORT_VIDEO_CALL
555 __pContextMenuAction->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_VIDEO_CALL"), IDA_CONTEXTMENU_VIDEO_CALL);
558 if ((__pPresentationModel->GetDefaultPhoneNumber(index).IsEmpty() == false)||(__pPresentationModel->GetDefaultEmail(index).IsEmpty() == false))
560 __pContextMenuAction->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"), IDA_CONTEXTMENU_MESSAGE);
562 __pContextMenuAction->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_REMOVE"), IDA_CONTEXTMENU_REMOVE);
563 __pContextMenuAction->AddActionEventListener(*this);
564 __pContextMenuAction->SetFocusable(true);
565 __pContextMenuAction->Show();
566 __selectedItemIndex = index;
571 FavoriteListPanel::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
573 if(__pPresentationModel->GetFavoriteCount() > 0)
575 __pOptionMenu->SetShowState(true);
576 __pOptionMenu->Show();
580 Tizen::Ui::Controls::IconListViewItem*
581 FavoriteListPanel::CreateItem(int index)
583 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
584 Bitmap* pThumbnail = null;
585 Bitmap* pBitmapQuickMenu = null;
591 int textWidth = W_ICONLISTVIEW_ITEM - (W_NAME_TEXT_MARGIN * 2);
592 TextHorizontalAlignment alignment = TEXT_ALIGNMENT_LEFT;
594 if (__pPresentationModel->GetFavoriteItemInfo(index, name, pThumbnail) != E_SUCCESS)
599 Canvas* pCanvas = new (std::nothrow) Canvas();
600 pCanvas->Construct(Rectangle(0, 0, W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM));
603 if (pThumbnail != null)
605 textFont.Construct(FONT_STYLE_BOLD , FONT_SIZE_WITH_THUMBNAIL);
606 textY = H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND;
607 textHeight = H_TEXT_BACKGROUND;
608 textColor = Color(COLOR_TEXT_WITH_THUMBNAIL);
610 if (pContactsApp->GetOperationId() != OPERATION_ID_PICK)
612 textWidth = W_ICONLISTVIEW_ITEM - W_QUICK_MENU_BUTTON - W_NAME_TEXT_MARGIN;
615 pCanvas->DrawBitmap(pCanvas->GetBounds(), *pThumbnail, Rectangle(0, 0, pThumbnail->GetWidth(), pThumbnail->GetHeight()));
616 pCanvas->SetForegroundColor(Color(COLOR_LINE));
617 pCanvas->DrawLine(Point(0, H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND), Point(W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND));
618 pCanvas->FillRectangle(Color(COLOR_ITEM_TEXT_BACKGROUND), Rectangle(0, H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND, W_ICONLISTVIEW_ITEM, H_TEXT_BACKGROUND));
622 textFont.Construct(FONT_STYLE_BOLD , FONT_SIZE);
623 textY = (H_ICONLISTVIEW_ITEM / 2) - (H_TEXT_SPACE / 2);
624 textHeight = H_TEXT_SPACE;
625 textColor = Color(COLOR_TEXT);
626 alignment = TEXT_ALIGNMENT_CENTER;
628 pCanvas->FillRectangle(Color(COLOR_ITEM_BACKGROUND), pCanvas->GetBounds());
631 EnrichedText* pEnrichedTextName = new (std::nothrow) EnrichedText();
632 pEnrichedTextName->Construct(Dimension(textWidth, textHeight));
633 pEnrichedTextName->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
634 pEnrichedTextName->SetHorizontalAlignment(alignment);
635 pEnrichedTextName->SetTextWrapStyle(TEXT_WRAP_WORD_WRAP);
636 pEnrichedTextName->SetTextAbbreviationEnabled(true);
638 TextElement* pTextElementName = new (std::nothrow) TextElement();
639 pTextElementName->Construct(name);
640 pTextElementName->SetFont(textFont);
641 pTextElementName->SetTextColor(textColor);
643 pEnrichedTextName->Add(*pTextElementName);
645 pCanvas->DrawText(Point(W_NAME_TEXT_MARGIN, textY), *pEnrichedTextName);
647 Bitmap* pBitmapItem = new (std::nothrow) Bitmap();
648 pBitmapItem->Construct(*pCanvas, Rectangle(0, 0, W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM));
650 IconListViewItem* pFavoriteItem = new (std::nothrow) IconListViewItem();
651 pFavoriteItem->Construct(*pBitmapItem);
653 if (pContactsApp->GetOperationId() != OPERATION_ID_PICK)
655 pBitmapQuickMenu = ResourceManager::GetBitmapN(IDB_QUICK_MENU);
657 if (pBitmapQuickMenu != null)
659 pFavoriteItem->SetOverlayBitmap(IDA_FAVORITE_QUICK_MENU, pBitmapQuickMenu, ALIGNMENT_RIGHT, ALIGNMENT_BOTTOM);
664 delete pBitmapQuickMenu;
667 delete pEnrichedTextName;
668 delete pTextElementName;
670 return pFavoriteItem;
674 FavoriteListPanel::DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem *pItem)
683 FavoriteListPanel::GetItemCount(void)
685 return __pPresentationModel->GetFavoriteCount();
689 FavoriteListPanel::OnContactsChanged(void)
691 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
693 HideContactValuePopup();
694 if (__pContextMenuAction != null)
696 delete __pContextMenuAction;
697 __pContextMenuAction = null;
700 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
702 __pPresentationModel->InitializeFavoriteList(pContactsApp->GetReturnType());
706 __pPresentationModel->InitializeFavoriteList();
709 Form* pForm = dynamic_cast<Form*>(GetParent());
712 Footer* pFooter = pForm->GetFooter();
714 if (__pPresentationModel->GetContactCount() <= __pPresentationModel->GetFavoriteCount())
716 pFooter->SetItemEnabled(0, false);
717 pFooter->Invalidate(true);
721 pFooter->SetItemEnabled(0, true);
722 pFooter->Invalidate(true);
725 if (__pPresentationModel->GetFavoriteCount() > 0)
727 pForm->SetFormMenuEventListener(this);
731 pForm->SetFormMenuEventListener(null);
734 if (__pPresentationModel->GetFavoriteCount() > 0)
736 __pFavoriteListView->SetShowState(true);
737 __pEmptyImageLabel->SetShowState(false);
738 __pEmptyCommentLabel->SetShowState(false);
742 __pFavoriteListView->SetShowState(false);
743 __pEmptyImageLabel->SetShowState(true);
744 __pEmptyCommentLabel->SetShowState(true);
746 __pFavoriteListView->UpdateList();
750 FavoriteListPanel::OnCategoriesChanged(void)
755 FavoriteListPanel::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
760 FavoriteListPanel::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
762 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
764 HashMap* pReturnValue = new (std::nothrow) HashMap();
765 pReturnValue->Construct();
768 int selectedIndex = -1;
769 Integer::Parse(listView.GetName(), selectedIndex);
771 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
773 keyType.Append(CONTACT_KEY_PHONE);
775 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
777 keyType.Append(CONTACT_KEY_EMAIL);
781 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
786 IList* pList = __pPresentationModel->GetMultiValuesN(pContactsApp->GetReturnType(), selectedIndex);
787 String* pReturnInfo = static_cast<String *>(pList->GetAt(index));
789 ArrayList* pValueList = new (std::nothrow) ArrayList();
790 pValueList->Construct();
792 pReturnInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
793 pReturnInfo->Remove(0, blankIndex + 1);
794 pValueList->Add(new (std::nothrow) String(*pReturnInfo));
795 pReturnValue->Add(new (std::nothrow) String(keyType), pValueList);
799 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
803 FavoriteListPanel::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
808 FavoriteListPanel::ReturnValues(RequestId requestId, Tizen::App::AppCtrlResult appCtrlResult, const Tizen::Base::Collection::IMap* pReturnValue)
810 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
812 result r = pAppManager->SendAppControlResult(requestId, appCtrlResult, pReturnValue);
813 AppLogDebug("[%s] The return result from SendAppControlResult(), AppCtrlResult value : %d.", GetErrorMessage(r), appCtrlResult);
815 UiApp::GetInstance()->Terminate();
819 FavoriteListPanel::ShowContactValuePopup(int index)
822 Bitmap* pEmpty = null;
824 delete __pMultipleContactValuePopup;
825 __pMultipleContactValuePopup = new (std::nothrow) Popup();
826 __pMultipleContactValuePopup->Construct(true, Dimension(W_CONTACT_VALUE_POPUP, H_CONTACT_VALUE_POPUP));
827 __pPresentationModel->GetFavoriteItemInfo(index, name, pEmpty);
828 __pMultipleContactValuePopup->SetTitleText(name);
829 __pMultipleContactValuePopup->SetPropagatedKeyEventListener(this);
831 Rectangle popupClientBounds = __pMultipleContactValuePopup->GetClientAreaBounds();
833 ListView* pListView = new (std::nothrow) ListView();
834 pListView->Construct(Rectangle(0, 0, popupClientBounds.width, H_CONTACT_VALUE_POPUP_LIST_VIEW));
835 pListView->SetItemProvider(*__pContactValueListProvider);
836 pListView->AddListViewItemEventListener(*this);
837 pListView->SetName(String(Integer::ToString(index)));
839 __pMultipleContactValuePopup->AddControl(pListView);
841 Button* pCancelButton = new (std::nothrow) Button();
842 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"));
843 pCancelButton->SetActionId(IDA_POPUP_CONTACT_VALUE_CLOSE);
844 pCancelButton->AddActionEventListener(*this);
846 __pMultipleContactValuePopup->AddControl(pCancelButton);
847 __pMultipleContactValuePopup->SetShowState(true);
848 __pMultipleContactValuePopup->Show();
852 FavoriteListPanel::HideContactValuePopup(void)
854 if (__pMultipleContactValuePopup)
856 __pMultipleContactValuePopup->SetShowState(false);
862 FavoriteListPanel::OnScrollEndReached (Tizen::Ui::Control &source, Tizen::Ui::Controls::ScrollEndEvent type)
864 if (type == SCROLL_END_EVENT_END_BOTTOM)
866 if (type == SCROLL_END_EVENT_END_BOTTOM)
868 IconListView* iconListView = static_cast<IconListView*>(&source);
870 int listViewHeight = iconListView->GetHeight();
871 int ItemHeight = H_ICONLISTVIEW_ITEM;
872 int noOfItems = __pPresentationModel->GetFavoriteCount();
874 int NoOfRows = noOfItems/iconListView->GetItemCountPerAxis();
875 if(noOfItems%iconListView->GetItemCountPerAxis() != 0)
877 NoOfRows = NoOfRows + 1;
880 int TotalHeight = NoOfRows * ItemHeight;
882 __scrolledDistance = TotalHeight - listViewHeight;
885 else if (type == SCROLL_END_EVENT_END_TOP)
887 __scrolledDistance = 0;
892 FavoriteListPanel::OnScrollPositionChanged (Tizen::Ui::Control &source, int scrollPos)
894 __scrolledDistance = scrollPos;
898 FavoriteListPanel::OnScrollStopped (Tizen::Ui::Control &source)
903 FavoriteListPanel::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, const Tizen::Base::String& argument, const Tizen::Base::String& type)
905 result r = E_SUCCESS;
907 if (__pAppControl != null)
914 extraData.Construct();
916 if (appId.Equals(String(PROVIDER_ID_PHONE)))
918 uri.Append(INPUT_URI_TEL);
919 uri.Append(argument);
920 extraData.Add(new (std::nothrow) String(INPUT_KEY_CALL_TYPE), new (std::nothrow) String(type));
922 else if (appId.Equals(String(PROVIDER_ID_MESSAGE)))
924 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TO), new (std::nothrow) String(argument));
925 extraData.Add(new (std::nothrow) String(INPUT_KEY_MESSAGE_TYPE), new (std::nothrow) String(INPUT_TYPE_SMS));
928 __pAppControl = AppManager::FindAppControlN(appId, operationId);
929 if (__pAppControl != null)
931 r = __pAppControl->Start(&uri, null, &extraData, null);
934 AppLogDebug("[%s] Unable to launch app control", GetErrorMessage(r));
938 __isAppControlLaunching = true;
942 extraData.RemoveAll(true);
948 FavoriteListPanel::OnForeground(void)
950 __pFavoriteListView->SetEnabled(true);
951 __pFavoriteListView->UpdateList();
953 delete __pAppControl;
954 __pAppControl = null;
956 __isAppControlLaunching = false;
960 FavoriteListPanel::OnBackground(void)
965 FavoriteListPanel::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
971 FavoriteListPanel::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
973 if (keyEventInfo.GetKeyCode() == KEY_BACK)
975 if (__pMultipleContactValuePopup && __pMultipleContactValuePopup->GetShowState() == true)
977 HideContactValuePopup();
985 FavoriteListPanel::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
991 FavoriteListPanel::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)