2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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 PhnSettingsSpeedDialForm.cpp
19 * @brief Setting Speed dial form
23 #include "PhnAppUtility.h"
24 #include "PhnSettingsConstants.h"
25 #include "PhnSettingsSpeedDialForm.h"
26 #include "PhnSceneRegister.h"
27 #include "PhnSpeedDialInfo.h"
28 #include "PhnSettingsPresentationModel.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::App;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Social;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
41 const int H_DELETE_ICON_BMP = 56;
42 const int W_DELETE_ICON_BMP = 56;
43 const int W_VOICEMAIL_ICON_BG = 213;
44 const int H_VOICEMAIL_ICON_BG = 213;
45 const int W_VOICEMAIL_ICON = 100;
46 const int H_VOICEMAIL_ICON = 100;
47 const int W_SPEED_DIAL_CHECK_ICON = 64;
48 const int H_SPEED_DIAL_CHECK_ICON = 64;
49 const unsigned int COLOR_EMPTY_PHOTO = Color32<103, 103, 103>::Value;
50 //String contants for control name
51 static const wchar_t* IDL_SETTINGS_SPEEDDIAL_FORM = L"IDL_SETTINGS_SPEEDDIAL_FORM";
52 static const wchar_t* IDC_PHOTO_BTN2 = L"IDC_PHOTO_BUTTON2";
53 static const wchar_t* IDC_PHOTO_BTN3 = L"IDC_PHOTO_BUTTON3";
54 static const wchar_t* IDC_PHOTO_BTN4 = L"IDC_PHOTO_BUTTON4";
55 static const wchar_t* IDC_PHOTO_BTN5 = L"IDC_PHOTO_BUTTON5";
56 static const wchar_t* IDC_PHOTO_BTN6 = L"IDC_PHOTO_BUTTON6";
57 static const wchar_t* IDC_PHOTO_BTN7 = L"IDC_PHOTO_BUTTON7";
58 static const wchar_t* IDC_PHOTO_BTN8 = L"IDC_PHOTO_BUTTON8";
59 static const wchar_t* IDC_PHOTO_BTN9 = L"IDC_PHOTO_BUTTON9";
61 static const wchar_t* IDC_NAME_LABEL2 = L"IDC_NAME_LABEL2";
62 static const wchar_t* IDC_NAME_LABEL3 = L"IDC_NAME_LABEL3";
63 static const wchar_t* IDC_NAME_LABEL4 = L"IDC_NAME_LABEL4";
64 static const wchar_t* IDC_NAME_LABEL5 = L"IDC_NAME_LABEL5";
65 static const wchar_t* IDC_NAME_LABEL6 = L"IDC_NAME_LABEL6";
66 static const wchar_t* IDC_NAME_LABEL7 = L"IDC_NAME_LABEL7";
67 static const wchar_t* IDC_NAME_LABEL8 = L"IDC_NAME_LABEL8";
68 static const wchar_t* IDC_NAME_LABEL9 = L"IDC_NAME_LABEL9";
70 static const wchar_t* IDB_SPEED_DIAL_CHECK = L"C01-5_icon_speeddial_check.png";
72 SettingsSpeedDialForm::SettingsSpeedDialForm(void)
74 __pSpeedDialMappingList = null;
75 __pSettingsPresentor = null;
78 __isDeleteMode = false;
79 __pAddressbook = null;
80 __pSpeedDialPopup = null;
82 __pPreviousSceneId = null;
83 __isContactAppControlLaunched = false;
86 SettingsSpeedDialForm::~SettingsSpeedDialForm(void)
88 // SettingsPresentationModel::DeleteInstance();
89 if(__pPreviousSceneId != null)
91 delete __pPreviousSceneId;
96 SettingsSpeedDialForm::Initialize(void)
98 Construct(IDL_SETTINGS_SPEEDDIAL_FORM);
99 //Initialise voice mail
100 InitializeVoiceMail();
105 SettingsSpeedDialForm::OnInitializing(void)
107 result r = E_SUCCESS;
109 // Setup back event listener
110 SetFormBackEventListener(this);
111 __pSettingsPresentor = SettingsPresentationModel::GetInstance();
112 AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
113 __pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
114 if (__pAddressbook == null)
122 SettingsSpeedDialForm::InitializeFooter(void)
124 Footer* pFooter = GetFooter();
127 pFooter->RemoveAllButtons();
128 pFooter->RemoveAllItems();
129 pFooter->RemoveBackButton();
131 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
134 String footerItemName(L"");
135 footerItemName.Append(AppUtility::GetResourceString(IDS_REMOVE_CONTACT));
136 FooterItem delFooterItem;
137 delFooterItem.Construct(IDA_DELETE_FOOTER_ITEMID);
138 delFooterItem.SetText(footerItemName);
139 pFooter->AddItem(delFooterItem);
140 if(__isDeleteMode == false)
142 if(__pSpeedDialMappingList != null)
144 if(__pSpeedDialMappingList->GetCount() == 0)
146 pFooter->SetItemEnabled(0,false);
150 pFooter->SetItemEnabled(0,true);
155 pFooter->SetItemEnabled(0,false);
160 pFooter->SetBackButton();
161 pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, pFooter->GetColor());
162 pFooter->AddActionEventListener(*this);
163 pFooter->RequestRedraw(true);
168 if(__pDeleteList != null)
170 if(__pDeleteList->GetCount() == 0)
172 pFooter->SetItemEnabled(0,false);
176 pFooter->SetItemEnabled(0,true);
181 pFooter->SetItemEnabled(0,false);
184 FooterItem cancelFooterItem;
185 cancelFooterItem.Construct(IDA_CANCEL_FOOTER_ITEMID);
186 String cancelString = AppUtility::GetResourceString(L"IDS_CANCEL");
187 cancelFooterItem.SetText(cancelString);
188 pFooter->AddItem(cancelFooterItem);
189 pFooter->RequestRedraw(true);
195 SettingsSpeedDialForm::InitializeVoiceMail(void)
197 Button* pVoiceMailBtn = static_cast<Button*>(GetControl(IDC_VOICEMAIL_BUTTON));
198 if (pVoiceMailBtn != null)
200 Bitmap* pIcon = AppUtility::GetBitmapFromResourcesN(IDB_VOICECALL_ICON, W_VOICEMAIL_ICON, H_VOICEMAIL_ICON);
201 Point iconPos(((pVoiceMailBtn->GetBounds().width - W_VOICEMAIL_ICON) / 2), ((pVoiceMailBtn->GetBounds().height - H_VOICEMAIL_ICON) / 2));
202 pVoiceMailBtn->SetNormalBitmap(iconPos, *pIcon);
203 pVoiceMailBtn->SetPressedBitmap(iconPos, *pIcon);
204 pVoiceMailBtn->SetColor(BUTTON_STATUS_NORMAL, COLOR_EMPTY_PHOTO);
205 pVoiceMailBtn->SetActionId(IDA_VOICEMAIL);
206 pVoiceMailBtn->AddActionEventListener(*this);
213 SettingsSpeedDialForm::InitializePhotoButtons(const String& btnName, const String& lblName, ActionId actionId)
215 Button* pButton = static_cast<Button*>(GetControl(btnName));
216 Label* pNameLabel = static_cast<Label*>(GetControl(lblName));
217 if (pButton != null && pNameLabel != null)
220 RecordId recordId = INVALID_RECORD_ID;
221 SpeedDialInfo speedDialInfo;
223 if (__pSpeedDialMappingList != null)
225 __pSpeedDialMappingList->GetValue(actionId,speedDialInfo);
226 if (speedDialInfo.keyMapping == actionId && speedDialInfo.contactId.IsEmpty() == false)
228 // Convert String value to long long type value
229 Integer::Parse(speedDialInfo.contactId, recordId);
233 //Fetch contacts Photo and name
234 Bitmap* pContactPhoto = null;
235 String contactName(L"");
236 Contact* pMappedContact = null;
237 if (recordId != Tizen::Social::INVALID_RECORD_ID)
239 pMappedContact = __pAddressbook->GetContactN(recordId);
240 if(pMappedContact != null)
242 pContactPhoto = pMappedContact->GetThumbnailN();
243 if (pContactPhoto != null)
245 Canvas* pCanvas = new (std::nothrow) Canvas;
246 Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height));
247 pCanvas->Construct(canvasRect);
248 //draw the contact bitmap
249 pCanvas->DrawBitmap(canvasRect,*pContactPhoto);
250 delete pContactPhoto;
251 pContactPhoto = new Bitmap();
252 pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds());
260 if (recordId != Tizen::Social::INVALID_RECORD_ID)
263 if (pMappedContact != null)
266 if (pContactPhoto != null)
268 if ((__isDeleteMode == true) && (__pDeleteList != null))
270 if(actionId == __keyToMap)
272 if(__pDeleteList->Contains(__keyToMap) == true)
274 __pDeleteList->Remove(__keyToMap);
278 //update photo bitmap with check icon
279 Canvas* pCanvas = new (std::nothrow) Canvas;
280 Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height));
281 pCanvas->Construct(canvasRect);
282 //draw the contact bitmap
283 pCanvas->DrawBitmap(canvasRect,*pContactPhoto);
285 pCanvas->DrawRectangle(canvasRect);
286 pCanvas->FillRectangle(Color(103,103,103,127),canvasRect);
288 Bitmap* pBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPEED_DIAL_CHECK,W_SPEED_DIAL_CHECK_ICON,H_SPEED_DIAL_CHECK_ICON);
289 pCanvas->DrawBitmap(Point((((canvasRect.width)/2) - (W_SPEED_DIAL_CHECK_ICON/2)),(((canvasRect.height)/2)- (H_SPEED_DIAL_CHECK_ICON/2))),*pBitmap);
291 //construct the final Bitmap to Button
292 delete pContactPhoto;
293 pContactPhoto = new Bitmap();
294 pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds());
297 __pDeleteList->Add(__keyToMap);
304 if (__isDeleteMode == false)
306 //Create a new canvas
307 Canvas* pCanvas = new (std::nothrow) Canvas;
308 Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height));
309 pCanvas->Construct(canvasRect);
310 pCanvas->DrawRectangle(canvasRect);
311 pCanvas->FillRectangle(COLOR_EMPTY_PHOTO,canvasRect);
312 //create the final Bitmap
313 pContactPhoto = new Bitmap();
314 pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds());
319 if ((__pDeleteList != null))
321 if(__pDeleteList->Contains(__keyToMap) == true)
323 //Create a new canvas
324 Canvas* pCanvas = new (std::nothrow) Canvas;
325 Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height));
326 pCanvas->Construct(canvasRect);
327 pCanvas->DrawRectangle(canvasRect);
328 pCanvas->FillRectangle(COLOR_EMPTY_PHOTO,canvasRect);
329 //Set the final Bitmap to Button
330 pContactPhoto = new Bitmap();
331 pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds());
333 __pDeleteList->Remove(__keyToMap);
337 Canvas* pCanvas = new (std::nothrow) Canvas;
338 Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height));
339 pCanvas->Construct(canvasRect);
341 pCanvas->DrawRectangle(canvasRect);
342 pCanvas->FillRectangle(Color(103,103,103,127),canvasRect);
344 Bitmap* pBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPEED_DIAL_CHECK,W_SPEED_DIAL_CHECK_ICON,H_SPEED_DIAL_CHECK_ICON);
345 pCanvas->DrawBitmap(Point((((canvasRect.width)/2) - (W_SPEED_DIAL_CHECK_ICON/2)),(((canvasRect.height)/2)- (H_SPEED_DIAL_CHECK_ICON/2))),*pBitmap);
346 //Set the final Bitmap to Button
347 pContactPhoto = new Bitmap();
348 pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds());
351 __pDeleteList->Add(__keyToMap);
357 //fetch Display name for selected contact
358 pMappedContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME,contactName);
359 if (contactName.IsEmpty() == true)
362 pMappedContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME,firstName);
364 pMappedContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME,lastName);
365 contactName.Append(firstName + L" " + lastName);
367 delete pMappedContact;
372 //Create a new canvas - invalid record
373 Canvas* pCanvas = new (std::nothrow) Canvas;
374 Rectangle canvasRect(Rectangle(0, 0, pButton->GetBounds().width, pButton->GetBounds().height));
375 pCanvas->Construct(canvasRect);
376 pCanvas->DrawRectangle(canvasRect);
377 pCanvas->FillRectangle(COLOR_EMPTY_PHOTO,canvasRect);
378 //create the final Bitmap
379 pContactPhoto = new Bitmap();
380 pContactPhoto->Construct(*pCanvas, pCanvas->GetBounds());
383 //reset display name - invalid record
384 contactName.Append(actionId);
385 contactName.Append(AppUtility::GetResourceString(L"IDS_DEFAULT_SPEED_DIAL_TEXT"));
388 pButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_EMPTY_PHOTO);
389 //set contact photo to button
390 if(pContactPhoto != null)
392 // pButton->SetNormalBackgroundBitmap(*pContactPhoto);
393 pButton->SetNormalBitmap(Point(0,0),*pContactPhoto);
394 pButton->Invalidate(true);
395 delete pContactPhoto;
397 //update contacts name
398 if (pNameLabel != null)
400 pNameLabel->SetText(contactName);
401 pNameLabel->Invalidate(true);
404 if(pButton->GetActionId() != actionId)
406 pButton->SetActionId(actionId);
407 pButton->AddActionEventListener(*this);
414 SettingsSpeedDialForm::OnTerminating(void)
416 result r = E_SUCCESS;
418 if (__pSpeedDialMappingList)
420 delete __pSpeedDialMappingList;
421 __pSpeedDialMappingList = null;
424 __pSettingsPresentor = null;
427 delete __pAddressbook;
430 if (__pDeleteList != null)
432 delete __pDeleteList;
438 SettingsSpeedDialForm::OnActionPerformed(const Control& source, int actionId)
442 case IDA_CANCEL_FOOTER_ITEMID:
444 String titleString = AppUtility::GetResourceString(L"IDS_SPEED_DIAL_TITLE");
445 Header* pHeader = GetHeader();
446 pHeader->SetTitleText(titleString);
447 pHeader->RequestRedraw(true);
448 if (__pDeleteList != null)
450 __pDeleteList->RemoveAll();
453 __isDeleteMode = false;
458 case IDA_DELETE_FOOTER_ITEMID:
460 Header* pHeader = GetHeader();
461 if (__isDeleteMode == false)
463 __isDeleteMode = true;
464 String titleString = AppUtility::GetResourceString(L"IDS_SPEED_DIAL_DELETE_TITLE");
465 pHeader->SetTitleText(titleString);
466 pHeader->RequestRedraw(true);
468 /* Footer* pFooter = GetFooter();
471 pFooter->RemoveAllButtons();
472 pFooter->RemoveAllItems();
473 pFooter->RemoveBackButton();
474 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
477 String footerItemName(L"");
478 footerItemName.Append(AppUtility::GetResourceString(IDS_REMOVE_CONTACT));
479 FooterItem delFooterItem;
480 delFooterItem.Construct(IDA_DELETE_FOOTER_ITEMID);
481 delFooterItem.SetText(footerItemName);
482 pFooter->AddItem(delFooterItem);
484 FooterItem cancelFooterItem;
485 cancelFooterItem.Construct(IDA_CANCEL_FOOTER_ITEMID);
486 String cancelString = AppUtility::GetResourceString(L"IDS_CANCEL");
487 cancelFooterItem.SetText(cancelString);
488 pFooter->AddItem(cancelFooterItem);
489 pFooter->RequestRedraw(true);
494 String titleString = AppUtility::GetResourceString(L"IDS_SPEED_DIAL_TITLE");
495 pHeader->SetTitleText(titleString);
496 pHeader->RequestRedraw(true);
497 if (__pDeleteList != null)
499 for (int index = 0; index < __pDeleteList->GetCount(); index++)
502 __pDeleteList->GetAt(index,keyToDelete);
503 SpeedDialInfo speedDialInfo;
504 __pSpeedDialMappingList->GetValue(keyToDelete,speedDialInfo);
505 __pSettingsPresentor->RemoveSpeedDialMapping(speedDialInfo.rowId);
508 if (__pSpeedDialMappingList)
510 delete __pSpeedDialMappingList;
511 __pSpeedDialMappingList = null;
513 __pSpeedDialMappingList = static_cast<HashMapT<int,SpeedDialInfo>*>(__pSettingsPresentor->GetSpeedDialMappingN());
514 if (__pDeleteList != null)
516 __pDeleteList->RemoveAll();
518 __isDeleteMode = false;
525 if (actionId > IDA_VOICEMAIL && actionId < IDA_SELECT_CONTACT)
527 __keyToMap = actionId;
528 if (__isDeleteMode == false)
531 if (__pSpeedDialMappingList != null)
533 SpeedDialInfo speedDialInfo;
534 result r = __pSpeedDialMappingList->GetValue(actionId,speedDialInfo);
540 if (__isUpdate == true)
542 if (__pSpeedDialPopup)
544 delete __pSpeedDialPopup;
545 __pSpeedDialPopup = null;
547 __pSpeedDialPopup = new (std::nothrow) SpeedDialPopup(*this);
548 __pSpeedDialPopup->Initialize();
549 __pSpeedDialPopup->SetShowState(true);
550 __pSpeedDialPopup->Draw();
551 __pSpeedDialPopup->Show();
570 SettingsSpeedDialForm::LaunchAppControl(void)
572 if(__isContactAppControlLaunched == true)
574 //app control already launched.
577 __isContactAppControlLaunched = true;
578 result r = E_SUCCESS;
580 extraData.Construct();
582 extraData.Add(new (std::nothrow) String(SELECTION_MODE), new (std::nothrow) String(SELECTION_MODE_SINGLE));
583 extraData.Add(new (std::nothrow) String(RETURN_TYPE), new (std::nothrow) String(RETURN_TYPE_CONTACT_ID));
585 AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_PICK);
588 r = pAc->Start(null, null, &extraData, this);
591 //app control request failed
592 __isContactAppControlLaunched = false;
596 extraData.RemoveAll(true);
600 SettingsSpeedDialForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData)
603 if (appId.Equals(String(PROVIDER_ID_CONTACTS)) && operationId.Equals(String(OPERATION_ID_PICK)))
605 //app control request completed
606 __isContactAppControlLaunched = false;
607 //check if results are available.
608 if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
610 const String* rettype = static_cast<const String *>(pExtraData->GetValue(String(RETURN_TYPE)));
611 if (rettype->Equals(String(RETURN_TYPE_CONTACT_ID),false))
613 const String* pPickResult = static_cast<const String *>(pExtraData->GetValue(String(RETURN_KEY_VALUE)));
614 if (pPickResult != null && pPickResult->IsEmpty() == false)
616 if (__isUpdate == true)
618 SpeedDialInfo speedDialInfo;
619 __pSpeedDialMappingList->GetValue(__keyToMap,speedDialInfo);
620 __pSettingsPresentor->UpdateSpeedDialMapping(speedDialInfo.rowId,*pPickResult,__keyToMap);
625 __pSettingsPresentor->SetSpeedDialMapping(*pPickResult,__keyToMap);
636 SettingsSpeedDialForm::UpdateAllButtons(void)
639 InitializePhotoButtons(IDC_PHOTO_BTN2, IDC_NAME_LABEL2, IDA_SELECT_PHOTO2);
640 InitializePhotoButtons(IDC_PHOTO_BTN3, IDC_NAME_LABEL3, IDA_SELECT_PHOTO3);
641 InitializePhotoButtons(IDC_PHOTO_BTN4, IDC_NAME_LABEL4, IDA_SELECT_PHOTO4);
642 InitializePhotoButtons(IDC_PHOTO_BTN5, IDC_NAME_LABEL5, IDA_SELECT_PHOTO5);
643 InitializePhotoButtons(IDC_PHOTO_BTN6, IDC_NAME_LABEL6, IDA_SELECT_PHOTO6);
644 InitializePhotoButtons(IDC_PHOTO_BTN7, IDC_NAME_LABEL7, IDA_SELECT_PHOTO7);
645 InitializePhotoButtons(IDC_PHOTO_BTN8, IDC_NAME_LABEL8, IDA_SELECT_PHOTO8);
646 InitializePhotoButtons(IDC_PHOTO_BTN9, IDC_NAME_LABEL9, IDA_SELECT_PHOTO9);
650 SettingsSpeedDialForm::UpdateButton(void)
652 if (__pSpeedDialMappingList)
654 delete __pSpeedDialMappingList;
655 __pSpeedDialMappingList = null;
657 __pSpeedDialMappingList = static_cast<HashMapT<int,SpeedDialInfo>*>(__pSettingsPresentor->GetSpeedDialMappingN());
660 case IDA_SELECT_PHOTO2:
662 InitializePhotoButtons(IDC_PHOTO_BTN2, IDC_NAME_LABEL2, IDA_SELECT_PHOTO2);
665 case IDA_SELECT_PHOTO3:
667 InitializePhotoButtons(IDC_PHOTO_BTN3, IDC_NAME_LABEL3, IDA_SELECT_PHOTO3);
670 case IDA_SELECT_PHOTO4:
672 InitializePhotoButtons(IDC_PHOTO_BTN4, IDC_NAME_LABEL4, IDA_SELECT_PHOTO4);
675 case IDA_SELECT_PHOTO5:
677 InitializePhotoButtons(IDC_PHOTO_BTN5, IDC_NAME_LABEL5, IDA_SELECT_PHOTO5);
680 case IDA_SELECT_PHOTO6:
682 InitializePhotoButtons(IDC_PHOTO_BTN6, IDC_NAME_LABEL6, IDA_SELECT_PHOTO6);
685 case IDA_SELECT_PHOTO7:
687 InitializePhotoButtons(IDC_PHOTO_BTN7, IDC_NAME_LABEL7, IDA_SELECT_PHOTO7);
690 case IDA_SELECT_PHOTO8:
692 InitializePhotoButtons(IDC_PHOTO_BTN8, IDC_NAME_LABEL8, IDA_SELECT_PHOTO8);
695 case IDA_SELECT_PHOTO9:
697 InitializePhotoButtons(IDC_PHOTO_BTN9, IDC_NAME_LABEL9, IDA_SELECT_PHOTO9);
706 SettingsSpeedDialForm::OnFormBackRequested(Form& source)
708 SceneManager* pSceneManager = SceneManager::GetInstance();
709 AppAssert(pSceneManager != null);
710 pSceneManager->GoForward(ForwardSceneTransition(*__pPreviousSceneId), null);
714 SettingsSpeedDialForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
716 __isDeleteMode = false;
717 __isContactAppControlLaunched = false;
718 //save previous scene id
719 __pPreviousSceneId = new (std::nothrow) SceneId(previousSceneId);
721 if (__pSpeedDialMappingList != null)
723 delete __pSpeedDialMappingList;
724 __pSpeedDialMappingList = null;
727 if (__pDeleteList != null)
729 delete __pDeleteList;
730 __pDeleteList = null;
733 __pSpeedDialMappingList = static_cast<HashMapT<int,SpeedDialInfo>*>(__pSettingsPresentor->GetSpeedDialMappingN());
736 __pDeleteList = new (std::nothrow) ArrayListT<int>();
737 if(__pAddressbook != null)
739 __pAddressbook->SetEventListener(this);
744 SettingsSpeedDialForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
746 if(__pPreviousSceneId != null)
748 delete __pPreviousSceneId;
749 __pPreviousSceneId = null;
751 if(__pAddressbook != null)
753 __pAddressbook->SetEventListener(null);
758 SettingsSpeedDialForm::OnItemSelected(int itemIndex)
762 case IDA_UPDATE_SPEED_DIAL:
769 case IDA_REMOVE_SPEED_DIAL:
771 SpeedDialInfo speedDialInfo;
772 __pSpeedDialMappingList->GetValue(__keyToMap,speedDialInfo);
773 __pSettingsPresentor->RemoveSpeedDialMapping(speedDialInfo.rowId);
783 SettingsSpeedDialForm::OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList)
785 IEnumerator* pEnum = contactChangeInfoList.GetEnumeratorN();
786 while (pEnum->MoveNext() == E_SUCCESS)
788 ContactChangeInfo* pInfo = (ContactChangeInfo*) pEnum->GetCurrent();
789 switch(pInfo->GetChangeType())
791 case RECORD_CHANGE_TYPE_REMOVED:
793 if(__pSpeedDialMappingList == null || __pSpeedDialMappingList->GetCount() == 0)
797 IListT<SpeedDialInfo>* pSpeedDialList = __pSpeedDialMappingList->GetValuesN();
798 IEnumeratorT<SpeedDialInfo> *pSpeedDialListEnum = pSpeedDialList->GetEnumeratorN();
800 while(pSpeedDialListEnum->MoveNext() == E_SUCCESS)
802 SpeedDialInfo speeDialInfo;
803 RecordId recordId = INVALID_RECORD_ID;
804 pSpeedDialListEnum->GetCurrent(speeDialInfo);
805 Integer::Parse(speeDialInfo.contactId, recordId);
806 if(recordId == pInfo->GetContactId())
808 __pSettingsPresentor->RemoveSpeedDialMapping(speeDialInfo.rowId);
813 delete pSpeedDialListEnum;
814 delete pSpeedDialList;
817 if (__pSpeedDialMappingList)
819 delete __pSpeedDialMappingList;
820 __pSpeedDialMappingList = null;
822 __pSpeedDialMappingList = static_cast<HashMapT<int,SpeedDialInfo>*>(__pSettingsPresentor->GetSpeedDialMappingN());
828 case RECORD_CHANGE_TYPE_UPDATED:
830 if(__pSpeedDialMappingList == null || __pSpeedDialMappingList->GetCount() == 0)
834 IListT<SpeedDialInfo>* pSpeedDialList = __pSpeedDialMappingList->GetValuesN();
835 IEnumeratorT<SpeedDialInfo> *pSpeedDialListEnum = pSpeedDialList->GetEnumeratorN();
837 while(pSpeedDialListEnum->MoveNext() == E_SUCCESS)
839 SpeedDialInfo speeDialInfo;
840 RecordId recordId = INVALID_RECORD_ID;
841 pSpeedDialListEnum->GetCurrent(speeDialInfo);
842 Integer::Parse(speeDialInfo.contactId, recordId);
843 if(recordId == pInfo->GetContactId())
849 delete pSpeedDialListEnum;
850 delete pSpeedDialList;
858 case RECORD_CHANGE_TYPE_ADDED:
863 AppLog("Contact changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetContactId(), pInfo->GetVersion());