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 CtFavoriteListEditorPanel.cpp
19 * @brief This is the implementation file for the FavoriteListEditorPanel class.
22 #include "CtContactsApp.h"
23 #include "CtCommonUtil.h"
24 #include "CtFavoriteListEditorPanel.h"
25 #include "CtFavoriteListPresentationModel.h"
26 #include "CtMainForm.h"
27 #include "CtResourceManager.h"
28 #include "CtSceneRegister.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
39 static const int IDA_FOOTER_REMOVE_FAVORITE = 0;
40 static const int IDA_FOOTER_CANCEL = 1;
41 static const int IDA_FOOTER_DONE = 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;
47 static const int W_INITAIL_PANEL = 10;
48 static const int H_INITIAL_PANEL = 10;
49 static const int W_ICONLISTVIEW_LEFT_MARGIN = 14;
50 static const int W_ICONLISTVIEW_RIGHT_MARGIN = 10;
51 static const int W_ICONLISTVIEW_ITEM = 216;
52 static const int H_ICONLISTVIEW_ITEM = 216;
53 static const int H_TEXT_BACKGROUND = 64;
54 static const int H_TEXT_SPACE = 96;
55 static const int W_ITEM_SPACE = 24;
56 static const int H_ITEM_SPACE = 24;
57 static const int W_CONTACT_VALUE_POPUP = 688;
58 static const int H_CONTACT_VALUE_POPUP = 532;
59 static const int H_CONTACT_VALUE_POPUP_LIST_VIEW = 338;
60 static const int Y_CLOSE_BUTTON = 358;
61 static const int W_CLOSE_BUTTON = 394;
62 static const int H_CLOSE_BUTTON = 74;
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_BOTTOM_LABEL = 48;
70 static const int W_NAME_TEXT_MARGIN = 10;
72 static const int FONT_SIZE_WITH_THUMBNAIL = 24;
73 static const int FONT_SIZE_EMPTY_COMMENT = 32;
74 static const int FONT_SIZE = 40;
75 static const int FONT_SIZE_BOTTOM_LABEL = 32;
77 static const wchar_t* IDB_NO_FAVORITES = L"00_Nocontents_picture.png";
79 static const unsigned int COLOR_ITEM_BACKGROUND = Color32<201, 201, 201>::Value;
80 static const unsigned int COLOR_ITEM_TEXT_BACKGROUND = Color32<0, 0, 0, 89>::Value;
81 static const unsigned int COLOR_TEXT_WITH_THUMBNAIL = Color32<249, 249, 249>::Value;
82 static const unsigned int COLOR_TEXT = Color32<255, 255, 255>::Value;
83 static const unsigned int COLOR_LINE = Color32<225, 225, 225, 26>::Value;
84 static const unsigned int COLOR_EMPTY_COMMENT = Color32<102, 102, 102>::Value;
85 static const unsigned int COLOR_BOTTOM_LABEL_BG = Color32<68, 68, 68>::Value;
86 static const unsigned int COLOR_BOTTOM_LABEL_FONT = Color32<255, 255, 255>::Value;
88 FavoriteListEditorPanel::FavoriteListEditorPanel(void)
89 : __pFavoriteListView(null)
90 , __pMultipleContactValuePopup(null)
91 , __pEmptyImageLabel(null)
92 , __pEmptyCommentLabel(null)
93 , __pBottomLabel(null)
94 , __pTempContactValueHashMap(null)
95 , __pPresentationModel(null)
96 , __pContactValueListProvider(null)
100 FavoriteListEditorPanel::~FavoriteListEditorPanel(void)
105 FavoriteListEditorPanel::Initialize(void)
107 Construct(Rectangle(0, 0, W_INITAIL_PANEL, H_INITIAL_PANEL));
111 FavoriteListEditorPanel::OnInitializing(void)
113 result r = E_SUCCESS;
115 const Form* pForm = dynamic_cast<Form*>(GetParent());
118 FloatRectangle clientBounds = ((MainForm*)pForm)->GetClientBounds();
120 SetBounds(FloatRectangle(0, 0, clientBounds.width, clientBounds.height));
122 __pPresentationModel = FavoriteListPresentationModel::GetInstance();
124 __pFavoriteListView = new (std::nothrow) IconListView();
125 __pFavoriteListView->Construct(Rectangle(0, 0, clientBounds.width, clientBounds.height - H_BOTTOM_LABEL), Dimension(W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM), ICON_LIST_VIEW_STYLE_MARK);
126 __pFavoriteListView->SetItemProvider(*this);
127 __pFavoriteListView->AddIconListViewItemEventListener(*this);
128 __pFavoriteListView->SetItemLayoutHorizontalAlignment(ALIGNMENT_LEFT);
129 __pFavoriteListView->SetItemLayoutVerticalAlignment(ALIGNMENT_TOP);
130 __pFavoriteListView->SetItemSpacing(W_ITEM_SPACE, H_ITEM_SPACE);
131 __pFavoriteListView->SetMargin(MARGIN_TYPE_LEFT, W_ICONLISTVIEW_LEFT_MARGIN);
132 __pFavoriteListView->SetMargin(MARGIN_TYPE_RIGHT, W_ICONLISTVIEW_RIGHT_MARGIN);
133 __pFavoriteListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT);
134 __pFavoriteListView->SetTouchAnimationEnabled(false);
136 AddControl(__pFavoriteListView);
138 __pEmptyImageLabel = new (std::nothrow) Label();
139 __pEmptyImageLabel->Construct(Rectangle(X_EMPTY_IMAGE, Y_EMPTY_IMAGE, W_EMPTY_IMAGE, H_EMPTY_IMAGE), L"");
140 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_NO_FAVORITES);
143 __pEmptyImageLabel->SetBackgroundBitmap(*pBitmap);
146 __pEmptyImageLabel->SetShowState(false);
148 AddControl(__pEmptyImageLabel);
150 __pEmptyCommentLabel = new (std::nothrow) Label();
151 __pEmptyCommentLabel->Construct(Rectangle(0, Y_EMPTY_COMMENT, clientBounds.width, H_EMPTY_COMMENT),
152 ResourceManager::GetString(L"IDS_PB_BODY_NO_FAVOURITES"));
153 __pEmptyCommentLabel->SetTextConfig(FONT_SIZE_EMPTY_COMMENT, LABEL_TEXT_STYLE_NORMAL);
154 __pEmptyCommentLabel->SetTextColor(Color(COLOR_EMPTY_COMMENT));
155 __pEmptyCommentLabel->SetShowState(false);
157 AddControl(__pEmptyCommentLabel);
159 __pBottomLabel = new (std::nothrow) Label();
160 __pBottomLabel->Construct(FloatRectangle(0, clientBounds.height - H_BOTTOM_LABEL, clientBounds.width, H_BOTTOM_LABEL),
161 ResourceManager::GetString(L"IDS_COM_POP_SELECTED") + INITIAL_SELECTED_COUNT);
162 __pBottomLabel->SetBackgroundColor(Color(COLOR_BOTTOM_LABEL_BG));
163 __pBottomLabel->SetTextColor(Color(COLOR_BOTTOM_LABEL_FONT));
164 __pBottomLabel->SetTextConfig(FONT_SIZE_BOTTOM_LABEL, LABEL_TEXT_STYLE_BOLD);
165 __pBottomLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
166 __pBottomLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
167 AddControl(__pBottomLabel);
169 __pTempContactValueHashMap = new (std::nothrow) HashMap();
170 __pTempContactValueHashMap->Construct();
176 FavoriteListEditorPanel::OnTerminating(void)
178 result r = E_SUCCESS;
180 if (__pPresentationModel != null)
182 __pPresentationModel->RemoveContactChangeListener(*this);
185 if (__pTempContactValueHashMap != null)
187 __pTempContactValueHashMap->RemoveAll(true);
188 delete __pTempContactValueHashMap;
191 delete __pMultipleContactValuePopup;
197 FavoriteListEditorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
199 SceneManager* pSceneManager = SceneManager::GetInstance();
200 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
204 case IDA_HEADER_CONTACTS:
206 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
208 if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_SINGLE)
210 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST));
212 else if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
214 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST_EDITOR));
219 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST));
223 case IDA_HEADER_GROUPS:
225 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_LIST));
228 case IDA_HEADER_FAVORITES:
230 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
232 if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_SINGLE)
234 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
236 else if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
238 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST_EDITOR));
243 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
247 case IDA_FOOTER_REMOVE_FAVORITE:
250 pSceneManager->GoBackward(BackwardSceneTransition());
253 case IDA_FOOTER_CANCEL:
255 pSceneManager->GoBackward(BackwardSceneTransition());
258 case IDA_FOOTER_DONE:
260 ReturnMultipleValues();
263 case IDA_POPUP_CONTACT_VALUE_CLOSE:
265 HideContactValuePopup();
274 FavoriteListEditorPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
276 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
278 const Form* pForm = dynamic_cast<Form*>(GetParent());
281 Header* pHeader = pForm->GetHeader();
282 pHeader->AddActionEventListener(*this);
284 Footer* pFooter = pForm->GetFooter();
285 pFooter->RemoveAllItems();
286 pFooter->RemoveAllButtons();
287 pFooter->AddActionEventListener(*this);
289 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
291 FloatRectangle clientBounds = ((MainForm*)pForm)->GetClientBounds();
293 SetBounds(FloatRectangle(0, 0, clientBounds.width, clientBounds.height));
295 pFooter->SetShowState(true);
297 __pPresentationModel->InitializeFavoriteList(pContactsApp->GetReturnType());
298 __pFavoriteListView->UpdateList();
300 FooterItem footerItemDone;
301 footerItemDone.Construct(IDA_FOOTER_DONE);
302 footerItemDone.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
303 pFooter->AddItem(footerItemDone);
305 if (__pPresentationModel->GetFavoriteCount() > 0)
307 for (int index = 0; index < __pPresentationModel->GetFavoriteCount(); index++)
309 __pFavoriteListView->SetItemChecked(index, false);
312 pFooter->SetItemEnabled(0, false);
314 __pFavoriteListView->SetShowState(true);
315 __pEmptyImageLabel->SetShowState(false);
316 __pEmptyCommentLabel->SetShowState(false);
320 pFooter->SetItemEnabled(0, false);
321 __pFavoriteListView->SetShowState(false);
322 __pEmptyImageLabel->SetShowState(true);
323 __pEmptyCommentLabel->SetShowState(true);
324 __pBottomLabel->SetShowState(false);
329 for (int index = 0; index < __pPresentationModel->GetFavoriteCount(); index++)
331 __pFavoriteListView->SetItemChecked(index, false);
334 __pPresentationModel->InitializeFavoriteList();
335 __pFavoriteListView->UpdateList();
337 if (__pPresentationModel->GetFavoriteCount() > 0)
339 __pFavoriteListView->SetShowState(true);
340 __pEmptyImageLabel->SetShowState(false);
341 __pEmptyCommentLabel->SetShowState(false);
345 __pFavoriteListView->SetShowState(false);
346 __pEmptyImageLabel->SetShowState(true);
347 __pEmptyCommentLabel->SetShowState(true);
350 FooterItem footerItemCancel;
351 footerItemCancel.Construct(IDA_FOOTER_CANCEL);
352 footerItemCancel.SetText(ResourceManager::GetString(L"IDS_PB_SK_CANCEL"));
353 pFooter->AddItem(footerItemCancel);
355 FooterItem footerItemRemove;
356 footerItemRemove.Construct(IDA_FOOTER_REMOVE_FAVORITE);
357 footerItemRemove.SetText(ResourceManager::GetString(L"IDS_COM_BODY_REMOVE"));
358 pFooter->AddItem(footerItemRemove);
359 pFooter->SetItemEnabled(1, false);
364 __pPresentationModel->AddContactChangeListener(*this);
370 FavoriteListEditorPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
372 const Form* pForm = dynamic_cast<Form*>(GetParent());
375 Header* pHeader = pForm->GetHeader();
376 pHeader->RemoveActionEventListener(*this);
378 Footer* pFooter = pForm->GetFooter();
379 pFooter->RemoveActionEventListener(*this);
381 __pPresentationModel->RemoveContactChangeListener(*this);
385 FavoriteListEditorPanel::OnContactsChanged(void)
387 const Form* pForm = dynamic_cast<Form*>(GetParent());
390 HideContactValuePopup();
392 Footer* pFooter = pForm->GetFooter();
394 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
396 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
398 int favoriteCount = __pPresentationModel->GetFavoriteCount();
399 for (int index = 0; index < favoriteCount; index++)
401 __pFavoriteListView->SetItemChecked(index, false);
404 __pPresentationModel->InitializeFavoriteList(pContactsApp->GetReturnType());
406 if (__pPresentationModel->GetFavoriteCount() > 0)
408 pFooter->SetItemEnabled(0, false);
409 pFooter->Invalidate(true);
411 __pFavoriteListView->SetShowState(true);
412 __pEmptyImageLabel->SetShowState(false);
413 __pEmptyCommentLabel->SetShowState(false);
414 __pBottomLabel->SetShowState(true);
418 pFooter->SetItemEnabled(0, false);
420 __pFavoriteListView->SetShowState(false);
421 __pEmptyImageLabel->SetShowState(true);
422 __pEmptyCommentLabel->SetShowState(true);
423 __pBottomLabel->SetShowState(false);
428 for (int index = 0; index < __pPresentationModel->GetFavoriteCount(); index++)
430 __pFavoriteListView->SetItemChecked(index, false);
433 __pPresentationModel->InitializeFavoriteList();
435 if (__pPresentationModel->GetFavoriteCount() > 0)
437 pFooter->SetItemEnabled(1, false);
438 pFooter->Invalidate(true);
440 __pFavoriteListView->SetShowState(true);
441 __pEmptyImageLabel->SetShowState(false);
442 __pEmptyCommentLabel->SetShowState(false);
443 __pBottomLabel->SetShowState(true);
447 pFooter->SetItemEnabled(1, false);
448 __pFavoriteListView->SetShowState(false);
449 __pEmptyImageLabel->SetShowState(true);
450 __pEmptyCommentLabel->SetShowState(true);
451 __pBottomLabel->SetShowState(false);
455 __pFavoriteListView->UpdateList();
461 FavoriteListEditorPanel::OnCategoriesChanged(void)
466 FavoriteListEditorPanel::OnIconListViewItemReordered(Tizen::Ui::Controls::IconListView &iconListView, int indexFrom, int indexTo)
471 FavoriteListEditorPanel::OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView &iconListView, int index, Tizen::Ui::Controls::IconListViewItemStatus status)
473 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
475 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
477 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE ||
478 pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
480 IList* pList = __pPresentationModel->GetMultiValuesN(pContactsApp->GetReturnType(), index);
483 HashMap* pReturnValue = new (std::nothrow) HashMap();
484 pReturnValue->Construct();
486 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
491 if (iconListView.IsItemChecked(index) == true)
493 if (pList->GetCount() > 1)
495 iconListView.SetItemChecked(index, false);
496 __pContactValueListProvider = new (std::nothrow) ContactValueListItemProvider(pList);
497 ShowContactValuePopup(index);
499 else if (pList->GetCount() == 1)
501 String* pReturnValue = static_cast<String*>(pList->GetAt(0));
503 pReturnValue->IndexOf(CHARACTER_SPACE, 0, blankIndex);
504 pReturnValue->Remove(0, blankIndex + 1);
505 __pTempContactValueHashMap->Add(*(new (std::nothrow) Integer(index)), *(new (std::nothrow) String(*pReturnValue)));
512 __pTempContactValueHashMap->Remove(Integer(index), true);
521 FavoriteListEditorPanel::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
526 FavoriteListEditorPanel::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
528 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
530 int selectedIndex = -1;
531 Integer::Parse(listView.GetName(), selectedIndex);
533 IList* pList = __pPresentationModel->GetMultiValuesN(pContactsApp->GetReturnType(), selectedIndex);
536 HashMap* pReturnValue = new (std::nothrow) HashMap();
537 pReturnValue->Construct();
539 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
544 String* pReturnValueInfo = static_cast<String*>(pList->GetAt(index));
546 pReturnValueInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
547 pReturnValueInfo->Remove(0, blankIndex + 1);
548 __pTempContactValueHashMap->Add(*(new (std::nothrow) Integer(selectedIndex)), *(new (std::nothrow) String(*pReturnValueInfo)));
552 __pFavoriteListView->SetItemChecked(selectedIndex, true);
553 HideContactValuePopup();
558 FavoriteListEditorPanel::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
562 Tizen::Ui::Controls::IconListViewItem*
563 FavoriteListEditorPanel::CreateItem(int index)
565 Bitmap* pThumbnail = null;
571 TextHorizontalAlignment alignment = TEXT_ALIGNMENT_LEFT;
573 if (__pPresentationModel->GetFavoriteItemInfo(index, name, pThumbnail) != E_SUCCESS)
578 Canvas* pCanvas = new (std::nothrow) Canvas();
579 pCanvas->Construct(Rectangle(0, 0, W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM));
582 if (pThumbnail != null)
584 textFont.Construct(FONT_STYLE_BOLD , FONT_SIZE_WITH_THUMBNAIL);
585 textY = H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND;
586 textHeight = H_TEXT_BACKGROUND;
587 textColor = Color(COLOR_TEXT_WITH_THUMBNAIL);
589 pCanvas->DrawBitmap(pCanvas->GetBounds(), *pThumbnail, Rectangle(0, 0, pThumbnail->GetWidth(), pThumbnail->GetHeight()));
590 pCanvas->SetForegroundColor(Color(COLOR_LINE));
591 pCanvas->DrawLine(Point(0, H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND), Point(W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND));
592 pCanvas->FillRectangle(Color(COLOR_ITEM_TEXT_BACKGROUND), Rectangle(0, H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND, W_ICONLISTVIEW_ITEM, H_TEXT_BACKGROUND));
596 textFont.Construct(FONT_STYLE_BOLD , FONT_SIZE);
597 textY = (H_ICONLISTVIEW_ITEM / 2) - (H_TEXT_SPACE / 2);
598 textHeight = H_TEXT_SPACE;
599 textColor = Color(COLOR_TEXT);
600 alignment = TEXT_ALIGNMENT_CENTER;
602 pCanvas->FillRectangle(Color(COLOR_ITEM_BACKGROUND), pCanvas->GetBounds());
605 EnrichedText* pEnrichedTextName = new (std::nothrow) EnrichedText();
606 pEnrichedTextName->Construct(Dimension(W_ICONLISTVIEW_ITEM - (W_NAME_TEXT_MARGIN * 2), textHeight));
607 pEnrichedTextName->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
608 pEnrichedTextName->SetHorizontalAlignment(alignment);
609 pEnrichedTextName->SetTextWrapStyle(TEXT_WRAP_WORD_WRAP);
610 pEnrichedTextName->SetTextAbbreviationEnabled(true);
612 TextElement* pTextElementName = new (std::nothrow) TextElement();
613 pTextElementName->Construct(name);
614 pTextElementName->SetFont(textFont);
615 pTextElementName->SetTextColor(textColor);
617 pEnrichedTextName->Add(*pTextElementName);
619 pCanvas->DrawText(Point(W_NAME_TEXT_MARGIN, textY), *pEnrichedTextName);
621 Bitmap* pBitmapItem = new (std::nothrow) Bitmap();
622 pBitmapItem->Construct(*pCanvas, Rectangle(0, 0, W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM));
624 IconListViewItem* pFavoriteItem = new (std::nothrow) IconListViewItem();
625 pFavoriteItem->Construct(*pBitmapItem);
630 delete pEnrichedTextName;
631 delete pTextElementName;
633 return pFavoriteItem;
637 FavoriteListEditorPanel::DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem *pItem)
646 FavoriteListEditorPanel::GetItemCount(void)
648 return __pPresentationModel->GetFavoriteCount();
652 FavoriteListEditorPanel::RemoveFavorites(void)
654 result r = E_SUCCESS;
656 for (int i = 0; i < __pPresentationModel->GetFavoriteCount(); i++)
658 if (__pFavoriteListView->IsItemChecked(i))
660 r = __pPresentationModel->SetAsFavorite(__pPresentationModel->GetContactId(i), false);
662 if (r == E_STORAGE_FULL)
664 CommonUtil::showMemoryFullMessageBox();
672 FavoriteListEditorPanel::ReturnValues(RequestId requestId, Tizen::App::AppCtrlResult appCtrlResult, const Tizen::Base::Collection::IMap* pReturnValue)
674 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
676 result r = pAppManager->SendAppControlResult(requestId, appCtrlResult, pReturnValue);
677 AppLogDebug("[%s] The return result from SendAppControlResult(), AppCtrlResult value : %d.", GetErrorMessage(r), appCtrlResult);
679 UiApp::GetInstance()->Terminate();
683 FavoriteListEditorPanel::ReturnMultipleValues(void)
685 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
687 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
690 ArrayList* pValueList = new (std::nothrow) ArrayList();
691 pValueList->Construct();
693 HashMap* pReturnValue = new (std::nothrow) HashMap();
694 pReturnValue->Construct();
696 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_ITEM_ID)
698 for (int index = 0; index < __pPresentationModel->GetFavoriteCount(); index++)
700 if (__pFavoriteListView->IsItemChecked(index))
702 int contactId = __pPresentationModel->GetContactId(index);
703 pValueList->Add(new (std::nothrow) String(Integer::ToString(contactId)));
706 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), pValueList);
708 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
713 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
715 keyType.Append(CONTACT_KEY_PHONE);
717 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
719 keyType.Append(CONTACT_KEY_EMAIL);
725 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
730 IMapEnumerator* pMapEnum = __pTempContactValueHashMap->GetMapEnumeratorN();
731 while (pMapEnum->MoveNext() == E_SUCCESS)
733 String* pValue = static_cast<String*> (pMapEnum->GetValue());
734 pValueList->Add(new (std::nothrow) String(*pValue));
738 pReturnValue->Add(new (std::nothrow) String(keyType), pValueList);
740 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
745 FavoriteListEditorPanel::ShowContactValuePopup(int index)
748 Bitmap* pEmpty = null;
750 delete __pMultipleContactValuePopup;
751 __pMultipleContactValuePopup = new (std::nothrow) Popup();
752 __pMultipleContactValuePopup->Construct(true, Dimension(W_CONTACT_VALUE_POPUP, H_CONTACT_VALUE_POPUP));
753 __pPresentationModel->GetFavoriteItemInfo(index, name, pEmpty);
754 __pMultipleContactValuePopup->SetTitleText(name);
755 __pMultipleContactValuePopup->SetPropagatedKeyEventListener(this);
757 Rectangle popupClientBounds = __pMultipleContactValuePopup->GetClientAreaBounds();
759 ListView* pListView = new (std::nothrow) ListView();
760 pListView->Construct(Rectangle(0, 0, popupClientBounds.width, H_CONTACT_VALUE_POPUP_LIST_VIEW));
761 pListView->SetItemProvider(*__pContactValueListProvider);
762 pListView->AddListViewItemEventListener(*this);
763 pListView->SetName(String(Integer::ToString(index)));
765 __pMultipleContactValuePopup->AddControl(pListView);
767 Button* pCancelButton = new (std::nothrow) Button();
768 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"));
769 pCancelButton->SetActionId(IDA_POPUP_CONTACT_VALUE_CLOSE);
770 pCancelButton->AddActionEventListener(*this);
772 __pMultipleContactValuePopup->AddControl(pCancelButton);
773 __pMultipleContactValuePopup->SetShowState(true);
774 __pMultipleContactValuePopup->Show();
778 FavoriteListEditorPanel::HideContactValuePopup(void)
780 if (__pMultipleContactValuePopup)
782 __pMultipleContactValuePopup->SetShowState(false);
788 FavoriteListEditorPanel::UpdateBottomLabel(void)
790 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
792 int selectedCount = 0;
793 int favoriteCount = __pPresentationModel->GetFavoriteCount();
794 int fotterItemIndex = 1;
796 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
801 for (int index = 0; index < favoriteCount; index++)
803 if (__pFavoriteListView->IsItemChecked(index))
809 String string = ResourceManager::GetString(L"IDS_COM_POP_SELECTED");
810 string.Append(L" (");
811 string.Append(selectedCount);
813 __pBottomLabel->SetText(string);
814 Form* pForm = dynamic_cast<Form*>(GetParent());
817 FloatRectangle clientBounds = ((MainForm*)pForm)->GetClientBounds();
819 Footer* pFooter = pForm->GetFooter();
821 if (selectedCount > 0)
823 if(__pBottomLabel->GetShowState() == false)
825 __pBottomLabel->SetShowState(true);
826 __pFavoriteListView->SetSize(__pFavoriteListView->GetSizeF().width, clientBounds.height - H_BOTTOM_LABEL);
828 pFooter->SetItemEnabled(fotterItemIndex, true);
830 else if (selectedCount == 0)
832 if(__pBottomLabel->GetShowState() == true)
834 __pBottomLabel->SetShowState(false);
835 __pFavoriteListView->SetSize(__pFavoriteListView->GetSizeF().width, clientBounds.height);
837 pFooter->SetItemEnabled(fotterItemIndex, false);
839 __pBottomLabel->Invalidate(true);
840 pFooter->Invalidate(true);
844 FavoriteListEditorPanel::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
850 FavoriteListEditorPanel::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
852 if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
854 if (__pMultipleContactValuePopup && __pMultipleContactValuePopup->GetShowState() == true)
856 HideContactValuePopup();
864 FavoriteListEditorPanel::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
870 FavoriteListEditorPanel::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)