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 "CtFavoriteListEditorPanel.h"
24 #include "CtFavoriteListPresentationModel.h"
25 #include "CtMainForm.h"
26 #include "CtResourceManager.h"
27 #include "CtSceneRegister.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
37 static const int IDA_FOOTER_REMOVE_FAVORITE = 0;
38 static const int IDA_FOOTER_CANCEL = 1;
39 static const int IDA_FOOTER_DONE = 2;
40 static const int IDA_HEADER_CONTACTS = 10;
41 static const int IDA_HEADER_GROUPS = 11;
42 static const int IDA_HEADER_FAVORITES = 12;
43 static const int IDA_POPUP_CONTACT_VALUE_CLOSE = 20;
45 static const int W_INITAIL_PANEL = 10;
46 static const int H_INITIAL_PANEL = 10;
47 static const int W_ICONLISTVIEW_LEFT_MARGIN = 14;
48 static const int W_ICONLISTVIEW_RIGHT_MARGIN = 10;
49 static const int W_ICONLISTVIEW_ITEM = 216;
50 static const int H_ICONLISTVIEW_ITEM = 216;
51 static const int H_TEXT_BACKGROUND = 64;
52 static const int H_TEXT_SPACE = 96;
53 static const int W_ITEM_SPACE = 24;
54 static const int H_ITEM_SPACE = 24;
55 static const int W_CONTACT_VALUE_POPUP = 688;
56 static const int H_CONTACT_VALUE_POPUP = 532;
57 static const int H_CONTACT_VALUE_POPUP_LIST_VIEW = 338;
58 static const int Y_CLOSE_BUTTON = 358;
59 static const int W_CLOSE_BUTTON = 394;
60 static const int H_CLOSE_BUTTON = 74;
61 static const int X_EMPTY_IMAGE = 220;
62 static const int Y_EMPTY_IMAGE = 300;
63 static const int W_EMPTY_IMAGE = 280;
64 static const int H_EMPTY_IMAGE = 280;
65 static const int Y_EMPTY_COMMENT = 618;
66 static const int H_EMPTY_COMMENT = 38;
67 static const int H_BOTTOM_LABEL = 48;
68 static const int W_NAME_TEXT_MARGIN = 10;
70 static const int FONT_SIZE_WITH_THUMBNAIL = 24;
71 static const int FONT_SIZE_EMPTY_COMMENT = 32;
72 static const int FONT_SIZE = 40;
73 static const int FONT_SIZE_BOTTOM_LABEL = 32;
75 static const wchar_t* IDB_NO_FAVORITES = L"00_Nocontents_picture.png";
77 static const unsigned int COLOR_ITEM_BACKGROUND = Color32<201, 201, 201>::Value;
78 static const unsigned int COLOR_ITEM_TEXT_BACKGROUND = Color32<0, 0, 0, 89>::Value;
79 static const unsigned int COLOR_TEXT_WITH_THUMBNAIL = Color32<249, 249, 249>::Value;
80 static const unsigned int COLOR_TEXT = Color32<255, 255, 255>::Value;
81 static const unsigned int COLOR_LINE = Color32<225, 225, 225, 26>::Value;
82 static const unsigned int COLOR_EMPTY_COMMENT = Color32<102, 102, 102>::Value;
83 static const unsigned int COLOR_BOTTOM_LABEL_BG = Color32<68, 68, 68>::Value;
84 static const unsigned int COLOR_BOTTOM_LABEL_FONT = Color32<255, 255, 255>::Value;
86 FavoriteListEditorPanel::FavoriteListEditorPanel(void)
87 : __pFavoriteListView(null)
88 , __pMultipleContactValuePopup(null)
89 , __pEmptyImageLabel(null)
90 , __pEmptyCommentLabel(null)
91 , __pBottomLabel(null)
92 , __pTempContactValueHashMap(null)
93 , __pPresentationModel(null)
94 , __pContactValueListProvider(null)
98 FavoriteListEditorPanel::~FavoriteListEditorPanel(void)
103 FavoriteListEditorPanel::Initialize(void)
105 Construct(Rectangle(0, 0, W_INITAIL_PANEL, H_INITIAL_PANEL));
109 FavoriteListEditorPanel::OnInitializing(void)
111 result r = E_SUCCESS;
113 const Form* pForm = dynamic_cast<Form*>(GetParent());
116 Rectangle clientBounds = pForm->GetClientAreaBounds();
117 SetBounds(Rectangle(0, 0, clientBounds.width, clientBounds.height));
119 __pPresentationModel = FavoriteListPresentationModel::GetInstance();
121 __pFavoriteListView = new (std::nothrow) IconListView();
122 __pFavoriteListView->Construct(Rectangle(0, 0, clientBounds.width, clientBounds.height - H_BOTTOM_LABEL), Dimension(W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM), ICON_LIST_VIEW_STYLE_MARK);
123 __pFavoriteListView->SetItemProvider(*this);
124 __pFavoriteListView->AddIconListViewItemEventListener(*this);
125 __pFavoriteListView->SetItemLayoutHorizontalAlignment(ALIGNMENT_LEFT);
126 __pFavoriteListView->SetItemLayoutVerticalAlignment(ALIGNMENT_TOP);
127 __pFavoriteListView->SetItemSpacing(W_ITEM_SPACE, H_ITEM_SPACE);
128 __pFavoriteListView->SetMargin(MARGIN_TYPE_LEFT, W_ICONLISTVIEW_LEFT_MARGIN);
129 __pFavoriteListView->SetMargin(MARGIN_TYPE_RIGHT, W_ICONLISTVIEW_RIGHT_MARGIN);
130 __pFavoriteListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT);
131 __pFavoriteListView->SetTouchAnimationEnabled(false);
133 AddControl(__pFavoriteListView);
135 __pEmptyImageLabel = new (std::nothrow) Label();
136 __pEmptyImageLabel->Construct(Rectangle(X_EMPTY_IMAGE, Y_EMPTY_IMAGE, W_EMPTY_IMAGE, H_EMPTY_IMAGE), L"");
137 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_NO_FAVORITES);
140 __pEmptyImageLabel->SetBackgroundBitmap(*pBitmap);
143 __pEmptyImageLabel->SetShowState(false);
145 AddControl(__pEmptyImageLabel);
147 __pEmptyCommentLabel = new (std::nothrow) Label();
148 __pEmptyCommentLabel->Construct(Rectangle(0, Y_EMPTY_COMMENT, clientBounds.width, H_EMPTY_COMMENT),
149 ResourceManager::GetString(L"IDS_PB_BODY_NO_FAVOURITES"));
150 __pEmptyCommentLabel->SetTextConfig(FONT_SIZE_EMPTY_COMMENT, LABEL_TEXT_STYLE_NORMAL);
151 __pEmptyCommentLabel->SetTextColor(Color(COLOR_EMPTY_COMMENT));
152 __pEmptyCommentLabel->SetShowState(false);
154 AddControl(__pEmptyCommentLabel);
156 __pBottomLabel = new (std::nothrow) Label();
157 __pBottomLabel->Construct(Rectangle(0, clientBounds.height - H_BOTTOM_LABEL, clientBounds.width, H_BOTTOM_LABEL),
158 ResourceManager::GetString(L"IDS_COM_POP_SELECTED") + INITIAL_SELECTED_COUNT);
159 __pBottomLabel->SetBackgroundColor(Color(COLOR_BOTTOM_LABEL_BG));
160 __pBottomLabel->SetTextColor(Color(COLOR_BOTTOM_LABEL_FONT));
161 __pBottomLabel->SetTextConfig(FONT_SIZE_BOTTOM_LABEL, LABEL_TEXT_STYLE_BOLD);
162 __pBottomLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
163 __pBottomLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
164 AddControl(__pBottomLabel);
166 __pTempContactValueHashMap = new (std::nothrow) HashMap();
167 __pTempContactValueHashMap->Construct();
173 FavoriteListEditorPanel::OnTerminating(void)
175 result r = E_SUCCESS;
177 if (__pPresentationModel != null)
179 __pPresentationModel->RemoveContactChangeListener(*this);
182 if (__pTempContactValueHashMap != null)
184 __pTempContactValueHashMap->RemoveAll(true);
185 delete __pTempContactValueHashMap;
188 delete __pMultipleContactValuePopup;
194 FavoriteListEditorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
196 SceneManager* pSceneManager = SceneManager::GetInstance();
197 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
201 case IDA_HEADER_CONTACTS:
203 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
205 if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_SINGLE)
207 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST));
209 else if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
211 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST_EDITOR));
216 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST));
220 case IDA_HEADER_GROUPS:
222 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_LIST));
225 case IDA_HEADER_FAVORITES:
227 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
230 case IDA_FOOTER_REMOVE_FAVORITE:
233 pSceneManager->GoBackward(BackwardSceneTransition());
236 case IDA_FOOTER_CANCEL:
238 pSceneManager->GoBackward(BackwardSceneTransition());
241 case IDA_FOOTER_DONE:
243 ReturnMultipleValues();
246 case IDA_POPUP_CONTACT_VALUE_CLOSE:
248 HideContactValuePopup();
257 FavoriteListEditorPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
259 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
261 const Form* pForm = dynamic_cast<Form*>(GetParent());
264 Header* pHeader = pForm->GetHeader();
265 pHeader->AddActionEventListener(*this);
267 Footer* pFooter = pForm->GetFooter();
268 pFooter->RemoveAllItems();
269 pFooter->RemoveAllButtons();
270 pFooter->AddActionEventListener(*this);
272 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
274 pFooter->SetBackButton();
276 __pPresentationModel->InitializeFavoriteList(pContactsApp->GetReturnType());
278 if (__pPresentationModel->GetFavoriteCount() > 0)
280 FooterItem footerItemDone;
281 footerItemDone.Construct(IDA_FOOTER_DONE);
282 footerItemDone.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
283 pFooter->AddItem(footerItemDone);
285 bool isChecked = false;
286 int favoriteCount = __pPresentationModel->GetFavoriteCount();
287 for (int index = 0; index < favoriteCount; index++)
289 if (__pFavoriteListView->IsItemChecked(index))
296 if (isChecked == false)
298 pFooter->SetItemEnabled(0, false);
303 __pFavoriteListView->SetShowState(false);
304 __pEmptyImageLabel->SetShowState(true);
305 __pEmptyCommentLabel->SetShowState(true);
306 __pBottomLabel->SetShowState(false);
311 for (int index = 0; index < __pPresentationModel->GetFavoriteCount(); index++)
313 __pFavoriteListView->SetItemChecked(index, false);
316 __pPresentationModel->InitializeFavoriteList();
317 __pFavoriteListView->UpdateList();
319 FooterItem footerItemRemove;
320 footerItemRemove.Construct(IDA_FOOTER_REMOVE_FAVORITE);
321 footerItemRemove.SetText(ResourceManager::GetString(L"IDS_COM_BODY_REMOVE"));
322 pFooter->AddItem(footerItemRemove);
323 pFooter->SetItemEnabled(0, false);
325 FooterItem footerItemCancel;
326 footerItemCancel.Construct(IDA_FOOTER_CANCEL);
327 footerItemCancel.SetText(ResourceManager::GetString(L"IDS_PB_SK_CANCEL"));
328 pFooter->AddItem(footerItemCancel);
333 __pPresentationModel->AddContactChangeListener(*this);
339 FavoriteListEditorPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
341 const Form* pForm = dynamic_cast<Form*>(GetParent());
344 Header* pHeader = pForm->GetHeader();
345 pHeader->RemoveActionEventListener(*this);
347 Footer* pFooter = pForm->GetFooter();
348 pFooter->RemoveActionEventListener(*this);
350 __pPresentationModel->RemoveContactChangeListener(*this);
354 FavoriteListEditorPanel::OnContactsChanged(void)
356 const Form* pForm = dynamic_cast<Form*>(GetParent());
357 Footer* pFooter = pForm->GetFooter();
359 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
361 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
363 int favoriteCount = __pPresentationModel->GetFavoriteCount();
364 for (int index = 0; index < favoriteCount; index++)
366 __pFavoriteListView->SetItemChecked(index, false);
369 __pPresentationModel->InitializeFavoriteList(pContactsApp->GetReturnType());
371 if (__pPresentationModel->GetFavoriteCount() > 0)
373 pFooter->SetItemEnabled(0, false);
374 pFooter->Invalidate(true);
376 __pFavoriteListView->SetShowState(true);
377 __pEmptyImageLabel->SetShowState(false);
378 __pEmptyCommentLabel->SetShowState(false);
379 __pBottomLabel->SetShowState(true);
383 __pFavoriteListView->SetShowState(false);
384 __pEmptyImageLabel->SetShowState(true);
385 __pEmptyCommentLabel->SetShowState(true);
386 __pBottomLabel->SetShowState(false);
391 for (int index = 0; index < __pPresentationModel->GetFavoriteCount(); index++)
393 __pFavoriteListView->SetItemChecked(index, false);
396 __pPresentationModel->InitializeFavoriteList();
398 if (__pPresentationModel->GetFavoriteCount() > 0)
400 pFooter->SetItemEnabled(0, false);
401 pFooter->Invalidate(true);
403 __pFavoriteListView->SetShowState(true);
404 __pEmptyImageLabel->SetShowState(false);
405 __pEmptyCommentLabel->SetShowState(false);
406 __pBottomLabel->SetShowState(true);
410 __pFavoriteListView->SetShowState(false);
411 __pEmptyImageLabel->SetShowState(true);
412 __pEmptyCommentLabel->SetShowState(true);
413 __pBottomLabel->SetShowState(false);
417 __pFavoriteListView->UpdateList();
424 FavoriteListEditorPanel::OnCategoriesChanged(void)
429 FavoriteListEditorPanel::OnIconListViewItemReordered(Tizen::Ui::Controls::IconListView &iconListView, int indexFrom, int indexTo)
434 FavoriteListEditorPanel::OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView &iconListView, int index, Tizen::Ui::Controls::IconListViewItemStatus status)
436 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
438 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
440 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE ||
441 pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
443 IList* pList = __pPresentationModel->GetMultiValuesN(pContactsApp->GetReturnType(), index);
446 HashMap* pReturnValue = new (std::nothrow) HashMap();
447 pReturnValue->Construct();
449 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
454 if (iconListView.IsItemChecked(index) == true)
456 if (pList->GetCount() > 1)
458 iconListView.SetItemChecked(index, false);
459 __pContactValueListProvider = new (std::nothrow) ContactValueListItemProvider(pList);
460 ShowContactValuePopup(index);
462 else if (pList->GetCount() == 1)
464 String* pReturnValue = static_cast<String*>(pList->GetAt(0));
466 pReturnValue->IndexOf(CHARACTER_SPACE, 0, blankIndex);
467 pReturnValue->Remove(0, blankIndex + 1);
468 __pTempContactValueHashMap->Add(*(new (std::nothrow) Integer(index)), *(new (std::nothrow) String(*pReturnValue)));
475 __pTempContactValueHashMap->Remove(Integer(index), true);
484 FavoriteListEditorPanel::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
489 FavoriteListEditorPanel::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
491 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
493 int selectedIndex = -1;
494 Integer::Parse(listView.GetName(), selectedIndex);
496 IList* pList = __pPresentationModel->GetMultiValuesN(pContactsApp->GetReturnType(), selectedIndex);
499 HashMap* pReturnValue = new (std::nothrow) HashMap();
500 pReturnValue->Construct();
502 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
507 String* pReturnValueInfo = static_cast<String*>(pList->GetAt(index));
509 pReturnValueInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
510 pReturnValueInfo->Remove(0, blankIndex + 1);
511 __pTempContactValueHashMap->Add(*(new (std::nothrow) Integer(selectedIndex)), *(new (std::nothrow) String(*pReturnValueInfo)));
515 __pFavoriteListView->SetItemChecked(selectedIndex, true);
516 HideContactValuePopup();
521 FavoriteListEditorPanel::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
525 Tizen::Ui::Controls::IconListViewItem*
526 FavoriteListEditorPanel::CreateItem(int index)
528 Bitmap* pThumbnail = null;
534 TextHorizontalAlignment alignment = TEXT_ALIGNMENT_LEFT;
536 if (__pPresentationModel->GetFavoriteItemInfo(index, name, pThumbnail) != E_SUCCESS)
541 Canvas* pCanvas = new (std::nothrow) Canvas();
542 pCanvas->Construct(Rectangle(0, 0, W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM));
545 if (pThumbnail != null)
547 textFont.Construct(FONT_STYLE_BOLD , FONT_SIZE_WITH_THUMBNAIL);
548 textY = H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND;
549 textHeight = H_TEXT_BACKGROUND;
550 textColor = Color(COLOR_TEXT_WITH_THUMBNAIL);
552 pCanvas->DrawBitmap(pCanvas->GetBounds(), *pThumbnail, Rectangle(0, 0, pThumbnail->GetWidth(), pThumbnail->GetHeight()));
553 pCanvas->SetForegroundColor(Color(COLOR_LINE));
554 pCanvas->DrawLine(Point(0, H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND), Point(W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND));
555 pCanvas->FillRectangle(Color(COLOR_ITEM_TEXT_BACKGROUND), Rectangle(0, H_ICONLISTVIEW_ITEM - H_TEXT_BACKGROUND, W_ICONLISTVIEW_ITEM, H_TEXT_BACKGROUND));
559 textFont.Construct(FONT_STYLE_BOLD , FONT_SIZE);
560 textY = (H_ICONLISTVIEW_ITEM / 2) - (H_TEXT_SPACE / 2);
561 textHeight = H_TEXT_SPACE;
562 textColor = Color(COLOR_TEXT);
563 alignment = TEXT_ALIGNMENT_CENTER;
565 pCanvas->FillRectangle(Color(COLOR_ITEM_BACKGROUND), pCanvas->GetBounds());
568 EnrichedText* pEnrichedTextName = new (std::nothrow) EnrichedText();
569 pEnrichedTextName->Construct(Dimension(W_ICONLISTVIEW_ITEM - (W_NAME_TEXT_MARGIN * 2), textHeight));
570 pEnrichedTextName->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
571 pEnrichedTextName->SetHorizontalAlignment(alignment);
572 pEnrichedTextName->SetTextWrapStyle(TEXT_WRAP_WORD_WRAP);
573 pEnrichedTextName->SetTextAbbreviationEnabled(true);
575 TextElement* pTextElementName = new (std::nothrow) TextElement();
576 pTextElementName->Construct(name);
577 pTextElementName->SetFont(textFont);
578 pTextElementName->SetTextColor(textColor);
580 pEnrichedTextName->Add(*pTextElementName);
582 pCanvas->DrawText(Point(W_NAME_TEXT_MARGIN, textY), *pEnrichedTextName);
584 Bitmap* pBitmapItem = new (std::nothrow) Bitmap();
585 pBitmapItem->Construct(*pCanvas, Rectangle(0, 0, W_ICONLISTVIEW_ITEM, H_ICONLISTVIEW_ITEM));
587 IconListViewItem* pFavoriteItem = new (std::nothrow) IconListViewItem();
588 pFavoriteItem->Construct(*pBitmapItem);
593 delete pEnrichedTextName;
594 delete pTextElementName;
596 return pFavoriteItem;
600 FavoriteListEditorPanel::DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem *pItem)
609 FavoriteListEditorPanel::GetItemCount(void)
611 return __pPresentationModel->GetFavoriteCount();
615 FavoriteListEditorPanel::RemoveFavorites(void)
617 for (int i = 0; i < __pPresentationModel->GetFavoriteCount(); i++)
619 if (__pFavoriteListView->IsItemChecked(i))
621 __pPresentationModel->SetAsFavorite(__pPresentationModel->GetContactId(i), false);
627 FavoriteListEditorPanel::ReturnValues(RequestId requestId, Tizen::App::AppCtrlResult appCtrlResult, const Tizen::Base::Collection::IMap* pReturnValue)
629 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
631 result r = pAppManager->SendAppControlResult(requestId, appCtrlResult, pReturnValue);
632 AppLogDebug("[%s] The return result from SendAppControlResult(), AppCtrlResult value : %d.", GetErrorMessage(r), appCtrlResult);
634 UiApp::GetInstance()->Terminate();
638 FavoriteListEditorPanel::ReturnMultipleValues(void)
640 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
642 if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
645 ArrayList* pValueList = new (std::nothrow) ArrayList();
646 pValueList->Construct();
648 HashMap* pReturnValue = new (std::nothrow) HashMap();
649 pReturnValue->Construct();
651 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_ITEM_ID)
653 for (int index = 0; index < __pPresentationModel->GetFavoriteCount(); index++)
655 if (__pFavoriteListView->IsItemChecked(index))
657 int contactId = __pPresentationModel->GetContactId(index);
658 pValueList->Add(new (std::nothrow) String(Integer::ToString(contactId)));
661 pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), pValueList);
663 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
668 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
670 keyType.Append(CONTACT_KEY_PHONE);
672 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
674 keyType.Append(CONTACT_KEY_EMAIL);
680 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
685 IMapEnumerator* pMapEnum = __pTempContactValueHashMap->GetMapEnumeratorN();
686 while (pMapEnum->MoveNext() == E_SUCCESS)
688 String* pValue = static_cast<String*> (pMapEnum->GetValue());
689 pValueList->Add(new (std::nothrow) String(*pValue));
693 pReturnValue->Add(new (std::nothrow) String(keyType), pValueList);
695 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
700 FavoriteListEditorPanel::ShowContactValuePopup(int index)
703 Bitmap* pEmpty = null;
705 delete __pMultipleContactValuePopup;
706 __pMultipleContactValuePopup = new (std::nothrow) Popup();
707 __pMultipleContactValuePopup->Construct(true, Dimension(W_CONTACT_VALUE_POPUP, H_CONTACT_VALUE_POPUP));
708 __pPresentationModel->GetFavoriteItemInfo(index, name, pEmpty);
709 __pMultipleContactValuePopup->SetTitleText(name);
711 Rectangle popupClientBounds = __pMultipleContactValuePopup->GetClientAreaBounds();
713 ListView* pListView = new (std::nothrow) ListView();
714 pListView->Construct(Rectangle(0, 0, popupClientBounds.width, H_CONTACT_VALUE_POPUP_LIST_VIEW));
715 pListView->SetItemProvider(*__pContactValueListProvider);
716 pListView->AddListViewItemEventListener(*this);
717 pListView->SetName(String(Integer::ToString(index)));
719 __pMultipleContactValuePopup->AddControl(pListView);
721 Button* pCancelButton = new (std::nothrow) Button();
722 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"));
723 pCancelButton->SetActionId(IDA_POPUP_CONTACT_VALUE_CLOSE);
724 pCancelButton->AddActionEventListener(*this);
726 __pMultipleContactValuePopup->AddControl(pCancelButton);
727 __pMultipleContactValuePopup->SetShowState(true);
728 __pMultipleContactValuePopup->Show();
732 FavoriteListEditorPanel::HideContactValuePopup(void)
734 __pMultipleContactValuePopup->SetShowState(false);
736 delete __pContactValueListProvider;
737 __pContactValueListProvider = null;
743 FavoriteListEditorPanel::UpdateBottomLabel(void)
745 int selectedCount = 0;
746 int favoriteCount = __pPresentationModel->GetFavoriteCount();
747 for (int index = 0; index < favoriteCount; index++)
749 if (__pFavoriteListView->IsItemChecked(index))
755 String string = ResourceManager::GetString(L"IDS_COM_POP_SELECTED");
756 string.Append(L" (");
757 string.Append(selectedCount);
759 __pBottomLabel->SetText(string);
760 Form* pForm = dynamic_cast<Form*>(GetParent());
763 Footer* pFooter = pForm->GetFooter();
765 if (selectedCount > 0)
767 __pBottomLabel->SetShowState(true);
768 __pFavoriteListView->SetSize(__pFavoriteListView->GetSize().width, pForm->GetClientAreaBounds().height - H_BOTTOM_LABEL);
769 pFooter->SetItemEnabled(0, true);
773 __pBottomLabel->SetShowState(false);
774 __pFavoriteListView->SetSize(__pFavoriteListView->GetSize().width, pForm->GetClientAreaBounds().height);
775 pFooter->SetItemEnabled(0, false);
777 __pBottomLabel->Invalidate(true);
778 pFooter->Invalidate(true);