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 PhnTabDialer.cpp
19 * @brief The dialer Tab
24 #include "PhnAppUtility.h"
25 #include "PhnPhoneApp.h"
26 #include "PhnCalllogManager.h"
27 #include "PhnCallPresentationModel.h"
28 #include "PhnCommonUtils.h"
29 #include "PhnDialAppForm.h"
30 #include "PhnDialContactInfo.h"
31 #include "PhnDialerKeypad.h"
32 #include "PhnTabDialer.h"
33 #include "PhnSceneRegister.h"
34 #include "PhnSettingsPresentationModel.h"
37 using namespace Tizen::App;
38 using namespace Tizen::Base;
39 using namespace Tizen::Base::Collection;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Media;
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Controls;
44 using namespace Tizen::Ui::Scenes;
45 using namespace Tizen::Social;
46 using namespace Tizen::System;
49 const int H_SPEEDDIAL_POPUP = 300;
50 const int H_POPUP_MSG_LABEL = 100;
51 const int H_POPUP_BTN = 90;
52 const int H_SEARCHLIST_ITEM = 129;
53 const int IDI_PADDING = 15;
54 const int IDI_MAX_LIMIT_LENGTH = 18;
55 const int IDI_MAX_TXT_FONT = 94;
56 const int IDI_MIN_TXT_FONT = 67;
57 const int IDI_DELTA_FONT_SIZE = 5;
58 const wchar_t* IDI_ADD_TO_CONTACTS_STR = L"Add To Contacts";
59 const int MAX_SEARCH_LIST_ITEMS = 5;
60 const int MIN_CONTEXT_MENU_ITEMS = 4;
61 const int X_CONTEXT_MENU_ANCHOR = 614;
62 const int Y_CONTEXT_MENU_ANCHOR = 504;
63 const int MAX_NUMBER_WITH_SEPERATOR = 11;
64 const int MIN_NUMBER_WITH_ONE_SEPERATOR = 3;
65 const int MIN_NUMBER_WITH_TWO_SEPERATOR = 7;
66 const int MAX_TXT_LENGTH_WITH_SEPERATOR = 12;
67 const int MAX_VISIBLE_TXT_WITH_MIN_FONT = 18;
68 const int W_MORE_BUTTON = 65;
69 const int H_MORE_BUTTON = 65;
70 const int W_SUGGESTION_POPUP_BUBBLE_ICON = 45;
71 const int H_SUGGESTION_POPUP_BUBBLE_ICON = 30;
74 const wchar_t* IDL_PANEL_DIALER = L"IDL_PANEL_DIALER";
75 const wchar_t* IDC_NUMERIC_EDITFIELD = L"IDC_EDITFIELD";
76 const wchar_t* IDC_PANEL_SEARCH_BOX = L"IDC_PANEL_SEARCH_BOX";
77 const wchar_t* IDC_BUTTON_ADD_CONTACTS = L"IDC_BUTTON_ADD_CONTACTS";
78 const wchar_t* IDC_BUTTON_USE_CONTACT = L"IDC_BUTTON_USE_CONTACT";
79 const wchar_t* IDC_BUTTON_DROP_DOWN = L"IDC_BUTTON_DROP_DOWN";
80 const wchar_t* IDC_PANEL_SEARCH_LIST = L"IDC_PANEL_SEARCH_LIST";
81 static const wchar_t* IDC_PANEL_DISPLAY_DATA = L"IDC_PANEL_DISPLAY_DATA";
82 const wchar_t* IDC_PANEL_MENU = L"IDC_PANEL_MENU";
83 const wchar_t* IDC_BUTTON_MENU = L"IDC_BUTTON_MENU";
84 const wchar_t* IDC_LISTVIEW_SEARCH = L"IDC_LISTVIEW_SEARCH";
87 const int DialTabDialer::IDI_BGBITMAP_WIDTH = 75;
88 const int DialTabDialer::IDI_BGBITMAP_HEIGHT = 75;
89 const int DialTabDialer::IDI_BGBITMAP_POS_X = 56;
90 const int DialTabDialer::IDI_BGBITMAP_POS_Y = 56;
91 const int DialTabDialer::IDI_TEXT1_SIZE = 116;
92 const int DialTabDialer::IDI_TEXT2_SIZE = 40;
95 const unsigned int COLOR_SEARCHLIST_BG = Color32<43, 107, 144>::Value;
97 DialTabDialer::DialTabDialer(void)
100 __pDialPresentationModel = null;
101 __pSuggestionListProvider = null;
102 __pSearchListView = null;
103 __isSearchListOpened = false;
104 __pErrorMsgPopup = null;
105 __pCallPresentor = null;
106 __pContextMenu = null;
107 __pPreviousSceneId = null;
108 __pDialKeypad = null;
109 __pConfirmationPopup = null;
110 __isAppForeground = true;
111 __pAddressBook = null;
112 __isAppControlLaunched = false;
116 DialTabDialer::~DialTabDialer(void)
118 AppLogDebug("ENTER");
120 if(__pDialKeypad != null)
122 //RemoveControl() also deletes the child control.
123 RemoveControl(*__pDialKeypad);
124 __pDialKeypad = null;
126 if(__pConfirmationPopup != null)
128 delete __pConfirmationPopup;
129 __pConfirmationPopup = null;
131 if (__pAddressBook != null)
133 delete __pAddressBook;
134 __pAddressBook = null;
136 delete __pContextMenu;
141 DialTabDialer::Initialize(void)
143 AppLogDebug("ENTER");
144 Construct(IDL_PANEL_DIALER);
150 DialTabDialer::OnInitializing(void)
152 AppLogDebug("ENTER");
153 result r = E_SUCCESS;
156 Form* pForm = dynamic_cast<Form*>(GetParent());
162 __pDialPresentationModel = new DialPresentationModel(*this);
163 __pSuggestionListProvider = new SuggestionItemProvider(*__pDialPresentationModel);
164 __pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN();
166 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN());
167 if (pRelativeLayout != null)
169 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
170 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
171 delete pRelativeLayout;
173 pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN());
174 if (pRelativeLayout != null)
176 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
177 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
178 delete pRelativeLayout;
182 pForm->GetFooter()->SetShowState(false);
183 pForm->AddOrientationEventListener(*this);
187 //Initialize text box
188 InitializeContactsTextBox();
189 //Create and hide Search data display panel
190 InitializeSearchBox();
191 //initialize search list view and hide it.
192 InitializeSearchListView();
193 HideSearchListView();
199 DialTabDialer::OnTerminating(void)
201 result r = E_SUCCESS;
202 if (__pDialPresentationModel != null)
204 delete __pDialPresentationModel;
205 __pDialPresentationModel = null;
207 if (__pSuggestionListProvider != null)
209 delete __pSuggestionListProvider;
210 __pSuggestionListProvider = null;
212 // Add your termination code here
217 DialTabDialer::InitializeContactsTextBox(void)
219 AppLogDebug("ENTER");
220 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
221 if (pEditField != null)
232 DialTabDialer::ShowFormattedText(EditField* pEditField, int actionId)
234 AppLogDebug("ENTER");
235 String contactNumber = pEditField->GetText();
236 contactNumber.Replace(L"-",L"");
237 if(actionId == CLEAR_KEY)
239 contactNumber.Remove(contactNumber.GetLength() - 1, 1);
243 contactNumber.Append(DialUtil::ConvertDialedNumberToString(actionId));
246 int textLength = contactNumber.GetLength();
250 pEditField->SetCursorPosition(0);
251 pEditField->SetFocus();
252 pEditField->Invalidate(true);
257 //Insert separator if required
258 if(textLength < MAX_NUMBER_WITH_SEPERATOR)
260 if(textLength > MIN_NUMBER_WITH_TWO_SEPERATOR)
262 contactNumber.Insert(L"-",MIN_NUMBER_WITH_TWO_SEPERATOR);
264 if(textLength > MIN_NUMBER_WITH_ONE_SEPERATOR)
266 contactNumber.Insert(L"-",MIN_NUMBER_WITH_ONE_SEPERATOR);
270 textLength = contactNumber.GetLength();
272 //need to change font to fit inside text box
273 //With size 94 -> 12 chars, 67 -> 18 chars
274 int fontSize = pEditField->GetTextSize();
275 if((actionId == CLEAR_KEY) && (textLength < MAX_VISIBLE_TXT_WITH_MIN_FONT))
278 fontSize += IDI_DELTA_FONT_SIZE;
280 else if(textLength > MAX_TXT_LENGTH_WITH_SEPERATOR)
283 fontSize -= IDI_DELTA_FONT_SIZE;
286 if(fontSize > IDI_MAX_TXT_FONT)
288 fontSize = IDI_MAX_TXT_FONT;
290 if(fontSize < IDI_MIN_TXT_FONT)
292 fontSize = IDI_MIN_TXT_FONT;
294 pEditField->SetTextSize(fontSize);
295 //set text to edit field
296 pEditField->SetText(contactNumber);
297 pEditField->SetCursorPosition(contactNumber.GetLength());
298 pEditField->SetFocus();
305 DialTabDialer::InitializeSearchBox(void)
307 AppLogDebug("ENTER");
310 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
311 pSearchPanel->SetShowState(false);
312 pSearchPanel->Invalidate(true);
314 //"Add to contacts" button
315 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
316 pButtonAddContacts->SetActionId(IDA_BTN_ADD_TO_CONTACTS);
317 pButtonAddContacts->AddActionEventListener(*this);
318 Canvas pCanvasNormalAdd;
319 pCanvasNormalAdd.Construct(pButtonAddContacts->GetBounds());
320 Canvas pCanvasPressedAdd;
321 pCanvasPressedAdd.Construct(pButtonAddContacts->GetBounds());
322 DialUtil::Draw9PatchToCanvas(pCanvasNormalAdd, IDB_BTN_OPTION_BG_ICON);
323 DialUtil::Draw9PatchToCanvas(pCanvasPressedAdd, IDB_BTN_OPTION_PRESS_BG_ICON);
324 DialUtil::DrawTextToCanvas(IDI_ADD_TO_CONTACTS_STR, FONT_SUGGESTION_NAME, pCanvasNormalAdd, POSITION_CENTER, BUTTON_STATUS_NORMAL);
325 DialUtil::DrawTextToCanvas(IDI_ADD_TO_CONTACTS_STR, FONT_SUGGESTION_NAME, pCanvasPressedAdd, POSITION_CENTER, BUTTON_STATUS_NORMAL);
326 DialUtil::DrawCanvasToButton(&pCanvasNormalAdd, &pCanvasPressedAdd, pButtonAddContacts);
327 pButtonAddContacts->SetShowState(false);
329 //"Use Contacts" button
330 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
331 pButtonContacts->SetActionId(IDA_BTN_USE_CONTACT_DATA);
332 pButtonContacts->AddActionEventListener(*this);
334 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
335 pButtonDropDown->SetActionId(IDA_BTN_DISPLAY_CONTACTS);
336 pButtonDropDown->AddActionEventListener(*this);
343 DialTabDialer::UpdateSearchResults(void)
345 AppLogDebug("ENTER");
347 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
348 //send request to search for suggestion list
349 String searchStr = pEditField->GetText();
350 searchStr.Replace(L"-",L"");
351 if(searchStr.IsEmpty() == false)
353 __pDialPresentationModel->FetchSuggestionList(searchStr);
361 DialTabDialer::HideSearchBox(void)
363 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
364 pButtonAddContacts->SetShowState(false);
365 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
366 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
367 pButtonContacts->SetShowState(true);
368 pButtonDropDown->SetShowState(true);
370 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
371 pSearchPanel->SetShowState(false);
372 pSearchPanel->Invalidate(true);
377 DialTabDialer::InitializeSearchListView(void)
380 __pSearchListView = static_cast<ListView*>(GetControl(IDC_LISTVIEW_SEARCH,true));
381 if(__pSearchListView != null)
383 __pSearchListView->SetSweepEnabled(true);
384 __pSearchListView->SetItemProvider(*__pSuggestionListProvider);
385 __pSearchListView->AddListViewItemEventListener(*this);
386 __pSearchListView->SetBackgroundColor(Color(COLOR_SEARCHLIST_BG));
387 Panel* pSearchListPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_LIST, true));
388 if(pSearchListPanel != null)
390 SetControlAlwaysOnTop(*pSearchListPanel, true);
396 DialTabDialer::ShowSearchListView(void)
398 AppLogDebug("ENTER");
400 //find the no. of search rows to be shown - Maximum 5 can be shown.
401 int noOfItems = MAX_SEARCH_LIST_ITEMS;
402 if(__pDialPresentationModel->GetNumberOfSuggestions() < (noOfItems+1))
404 noOfItems = __pDialPresentationModel->GetNumberOfSuggestions() - 1;
412 if (__pSearchListView != null)
415 Rectangle searchListbounds = __pSearchListView->GetBounds();
416 searchListbounds.height = H_SEARCHLIST_ITEM * noOfItems;
417 __pSearchListView->SetBounds(searchListbounds);
418 __pSearchListView->SetItemProvider(*__pSuggestionListProvider);
421 Panel* pSearchListPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_LIST, true));
422 if(pSearchListPanel != null)
424 pSearchListPanel->SetShowState(true);
425 pSearchListPanel->Invalidate(true);
428 __isSearchListOpened = true;
434 DialTabDialer::HideSearchListView(void)
436 Panel* pSearchListPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_LIST, true));
437 pSearchListPanel->SetShowState(false);
438 pSearchListPanel->Invalidate(true);
439 __isSearchListOpened = false;
444 DialTabDialer::ConstructMenu(void)
446 AppLogDebug("ENTER");
448 //Construct button for menu open and close
449 Panel* pDisplayPanel = static_cast<Panel*>(GetControl(IDC_PANEL_DISPLAY_DATA, true));
450 Button* pButton = static_cast<Button*>(GetControl(IDC_BUTTON_MENU, true));
451 pButton->SetActionId(IDA_BTN_SHOW_CONTEXTMENU);
452 pButton->AddActionEventListener(*this);
454 Canvas pCanvasNormal;
455 pCanvasNormal.Construct(pButton->GetBounds());
456 Canvas pCanvasPressed;
457 pCanvasPressed.Construct(pButton->GetBounds());
459 DialUtil::Draw9PatchToCanvas(pCanvasNormal, IDB_BTN_OPTION_BG_ICON);
460 DialUtil::DrawImageToCanvas(IDB_BTN_MORE_ICON, Dimension(W_MORE_BUTTON, H_MORE_BUTTON), pCanvasNormal, POSITION_CENTER);
461 DialUtil::Draw9PatchToCanvas(pCanvasPressed, IDB_BTN_OPTION_PRESS_BG_ICON);
462 DialUtil::DrawImageToCanvas(IDB_BTN_MORE_PRESS_ICON, Dimension(W_MORE_BUTTON, H_MORE_BUTTON), pCanvasPressed, POSITION_CENTER);
463 DialUtil::DrawCanvasToButton(&pCanvasNormal, &pCanvasPressed, pButton);
464 pDisplayPanel->Invalidate(true);
471 DialTabDialer::ConstructKeypad(int dialerState)
473 AppLogDebug("ENTER");
474 if(__pDialKeypad != null)
476 //RemoveControl() also deletes the child control.
477 RemoveControl(*__pDialKeypad);
478 __pDialKeypad = null;
480 //Construct Alpha numeric Keypad
481 if(__pDialKeypad == null)
483 __pDialKeypad = new (std::nothrow) DialerKeypad(DialerKeypad::DialerState(dialerState));
484 __pDialKeypad->ConstructPanel(this, this);
485 //add keypad to dial panel
486 AddControl(*__pDialKeypad);
493 DialTabDialer::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
495 AppLogDebug("ENTER");
496 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
497 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
498 String editText(L"");
500 if(__pCallPresentor == null)
502 __pCallPresentor = CallPresentationModel::GetInstance();
504 //While coming from Logs scene, disable footer
505 const Form* pForm = dynamic_cast<Form*>(GetParent());
508 pForm->GetFooter()->SetShowState(false);
510 //If previous scene is present & it is either Single Active Call
511 //or Conf. Call with 'Add Call' scenario.
512 DialerKeypad::DialerState dialerState = DialerKeypad::DIALER_STATE_FIRST_SCENE;
513 if (__pCallPresentor->GetCurrentCallCount() > 0)
515 __pPreviousSceneId = new (std::nothrow) SceneId(previousSceneId);
516 dialerState = DialerKeypad::DIALER_STATE_ADD_CALL;
528 //From AppControl request for normal call
529 dialerState = DialerKeypad::DIALER_STATE_NORMAL_APPCONTROL;
530 String* tmpStr = static_cast<String*>(pArgs->GetAt(0));
533 editText.Append(*tmpStr);
540 if(editText.IsEmpty() == true)
542 //Fetch auto area code setting, if present
545 SettingsPresentationModel::GetInstance()->GetActivePrefixDialNumber(editText);
546 res = Integer::Parse(editText,retvalue);
553 if(pEditField != null)
555 pEditField->SetText(editText);
556 pEditField->SetCursorPosition(editText.GetLength());
557 pEditField->SetFocus();
558 pEditField->Invalidate(true);
559 //show search results
560 if (editText.GetLength() == 0)
566 UpdateSearchResults();
571 ConstructKeypad(dialerState);
574 Form* form = static_cast<Form*>(GetParent());
575 form->GetFooter()->SetShowState(false);
576 pPhoneApp->AddAppStateChangeListener(*this);
577 //Add addressbook listener to listen to contacts changed events
578 if(__pAddressBook != null)
580 __pAddressBook->SetEventListener(this);
588 DialTabDialer::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
590 AppLogDebug("ENTER");
591 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
592 //hide search result list, if shown.
593 if (__isSearchListOpened == true)
595 HideSearchListView();
597 if(__pPreviousSceneId != null)
599 delete __pPreviousSceneId;
600 __pPreviousSceneId = null;
602 if(__pConfirmationPopup != null)
604 delete __pConfirmationPopup;
605 __pConfirmationPopup = null;
607 pPhoneApp->RemoveAppStateChangeListener(*this);
608 //remove contact change event listener
609 if(__pAddressBook != null)
611 __pAddressBook->SetEventListener(null);
618 DialTabDialer::OnActionPerformed(const Control& source, int actionId)
620 AppLogDebug("ENTER");
622 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
623 if (pEditField == null || GetAppControlLaunched() == true)
625 AppLogDebug("GetAppControlLaunched() == true");
643 //append / clear last character to contact
644 ShowFormattedText(pEditField, actionId);
645 if (pEditField->GetTextLength() == 0)
647 __pDialPresentationModel->ClearSearchResults();
652 UpdateSearchResults();
659 if (pEditField->GetTextLength() > 0)
661 String contactNo = pEditField->GetText();
662 contactNo.Replace(L"-",L"");
663 SwitchToOutgoingCallScreen(contactNo);
668 //show latest dialed or incoming number from Logs
669 String* number = __pDialPresentationModel->FetchLatestNumberFromLogsN();
672 pEditField->SetText(*number);
673 UpdateSearchResults();
682 pEditField->AppendText(L"*");
683 if (pEditField->GetTextLength() == 0)
689 UpdateSearchResults();
696 pEditField->AppendText(L"#");
697 if (pEditField->GetTextLength() == 0)
703 UpdateSearchResults();
716 PhoneApp* pApp = static_cast<PhoneApp*>(UiApp::GetInstance());
717 bool isAppControl = pApp->IsOpenAsAppControl();
718 if(isAppControl == true && __pPreviousSceneId == null)
722 else if(__pCallPresentor->GetCurrentCallCount() > 0)
724 //Switch back to previous screen
725 SwitchToPreviousActiveCallScreen();
731 case IDA_BTN_SHOW_CONTEXTMENU:
733 // Show the ContextMenu
734 String contactNo = pEditField->GetText();
735 contactNo.Replace(L"-",L"");
736 ShowContextMenu(contactNo);
737 if (__isSearchListOpened == true)
739 HideSearchListView();
744 case IDA_MENU_SEND_MESSAGE:
746 String contactNo = pEditField->GetText();
747 contactNo.Replace(L"-",L"");
748 __pDialPresentationModel->OpenMessagingAppControl(contactNo);
753 case IDA_BTN_ADD_TO_CONTACTS:
754 case IDA_MENU_ADD_CONTACT:
756 if(pEditField->GetTextLength() > 0)
758 String contactNo = pEditField->GetText();
759 contactNo.Replace(L"-",L"");
760 __pDialPresentationModel->AddContactsToAddressBook(contactNo);
761 SetAppControlLaunched(true);
767 case IDA_SPEEDDIAL_POPUP_YES:
769 __pConfirmationPopup->SetShowState(false);
770 SwitchToSpeedDialForm();
774 case IDA_SPEEDDIAL_POPUP_NO:
776 __pConfirmationPopup->SetShowState(false);
781 case IDA_MENU_SPEED_DIAL:
783 SwitchToSpeedDialForm();
788 case IDA_MENU_ADD_PAUSE:
794 case IDA_MENU_ADD_WAIT:
802 if(__pCallPresentor->GetCurrentCallCount() > 0)
804 //Switch back to previous screen
805 SwitchToPreviousActiveCallScreen();
811 UiApp::GetInstance()->Terminate();
816 case IDA_BTN_USE_CONTACT_DATA:
818 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(0);
819 if(pDialInfo != null)
821 //fetch contact number
822 String phNumber = pDialInfo->GetPhoneNumber();
823 if(phNumber.Equals(pEditField->GetText()) == false)
826 pEditField->SetText(phNumber);
827 pEditField->Invalidate(true);
828 if (__isSearchListOpened == true)
830 HideSearchListView();
832 __pDialPresentationModel->ClearSearchResults();
833 UpdateSearchResults();
839 case IDA_BTN_DISPLAY_CONTACTS:
841 if (__isSearchListOpened == true)
843 HideSearchListView();
847 ShowSearchListView();
855 pEditField->Invalidate(true);
862 DialTabDialer::OnLongPressGestureDetected(TouchLongPressGestureDetector& gestureDetector)
864 AppLogDebug("ENTER");
866 if (gestureDetector.GetControl() != null)
868 Button* pButton = static_cast<Button*>(gestureDetector.GetControl());
869 int actionId = pButton->GetActionId();
881 //Check if Speed Dial setting exist for pressed key
882 String* contactNumber = __pDialPresentationModel->FetchSpeedDialNumberN(actionId);
883 if(contactNumber != null)
885 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
887 //pass ownership to arraylist
888 pArgs->Add(contactNumber);
889 SendUserEvent(REQUEST_CALL_SPEED_DIAL_NUM,pArgs);
893 //show speed Dial Confirmation Popup msg
894 SendUserEvent(REQUEST_SHOW_SPEED_DIAL_POPUP,null);
908 //Handle Mute / UnMute
909 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
910 if(pEditField->GetTextLength() == 0)
912 bool enabled = false;
913 String title = L"http://tizen.org/setting/sound.silent_mode";
914 SettingInfo::GetValue(title, enabled);
915 //enable or disable the phone silent mode.
916 result r = E_FAILURE;
917 r = SettingInfo::SetValue(title, !enabled);
918 if(r == E_OBJ_NOT_FOUND)
920 AppLog("Object not found");
928 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
929 if (pEditField != null && pEditField->GetTextLength() > 0)
932 pEditField->SetTextSize(IDI_MAX_TXT_FONT);
933 pEditField->SetCursorPosition(0);
934 pEditField->SetFocus();
935 pEditField->Invalidate(true);
956 DialTabDialer::ShowContextMenu(String& contactNumber)
958 AppLogDebug("ENTER");
960 if(__pContextMenu != null)
962 delete __pContextMenu;
963 __pContextMenu = null;
965 __pContextMenu = new (std::nothrow) ContextMenu();
966 __pContextMenu->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
968 //minimum available option count
969 int visibleItems = MIN_CONTEXT_MENU_ITEMS;
971 //Show SendMsg Option only if NOT opened from Outgoing Call
972 if(__pPreviousSceneId == null)
974 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SEND_MSG), IDA_MENU_SEND_MESSAGE);
977 //Don't show 'AddContact' if empty text field
978 //or contact number is already saved.
979 if(contactNumber.IsEmpty() != true)
981 Contact* pContact = __pCallPresentor->GetContactN(contactNumber);
984 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_CONTACT), IDA_MENU_ADD_CONTACT);
992 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SPEED_DIAL), IDA_MENU_SPEED_DIAL);
993 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_PAUSE), IDA_MENU_ADD_PAUSE);
994 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_WAIT), IDA_MENU_ADD_WAIT);
995 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_EXIT), IDA_MENU_EXIT);
996 __pContextMenu->AddActionEventListener(*this);
998 __pContextMenu->SetMaxVisibleItemsCount(visibleItems);
999 // Set the anchor position of the ContextMenu
1000 __pContextMenu->SetAnchorPosition(Point(X_CONTEXT_MENU_ANCHOR, Y_CONTEXT_MENU_ANCHOR));
1001 // Show the ContextMenu
1002 __pContextMenu->Show();
1004 AppLogDebug("EXIT");
1009 DialTabDialer::AddPause(void)
1011 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1012 if (pEditField != null)
1014 pEditField->AppendText(L";");
1015 if (pEditField->GetTextLength() == 0)
1021 __pDialPresentationModel->ClearSearchResults();
1022 UpdateSearchResults();
1024 pEditField->Invalidate(true);
1030 DialTabDialer::AddWait(void)
1032 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1033 if (pEditField != null)
1035 pEditField->AppendText(L",");
1036 if (pEditField->GetTextLength() == 0)
1042 __pDialPresentationModel->ClearSearchResults();
1043 UpdateSearchResults();
1045 pEditField->Invalidate(true);
1051 DialTabDialer::AddPlus(void)
1053 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1054 if (pEditField != null)
1056 pEditField->AppendText(L"+");
1057 if (pEditField->GetTextLength() == 0)
1063 __pDialPresentationModel->ClearSearchResults();
1064 UpdateSearchResults();
1066 pEditField->Invalidate(true);
1072 DialTabDialer::SwitchToPreviousActiveCallScreen(void)
1074 AppLogDebug("ENTER");
1076 SceneManager* pSceneManager = SceneManager::GetInstance();
1077 AppAssert(pSceneManager);
1078 if(__pCallPresentor == null)
1080 __pCallPresentor = CallPresentationModel::GetInstance();
1082 //Fetch call info list
1083 IListT<CallInfo>* pCallList = __pCallPresentor->GetCallListN();
1084 IEnumeratorT<CallInfo>* pCallEnum = pCallList->GetEnumeratorN();
1085 if(pCallEnum != null)
1087 ArrayList* pCallArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1088 pCallArgs->Construct();
1089 while(pCallEnum->MoveNext() == E_SUCCESS)
1092 if(pCallEnum->GetCurrent(callInfo) == E_SUCCESS)
1094 CallInfo* pActiveCall = new (std::nothrow) CallInfo();
1095 *pActiveCall = callInfo;
1096 pCallArgs->Add(pActiveCall);
1100 if(pCallArgs->GetCount() == 1 && (static_cast<CallInfo*>(pCallArgs->GetAt(0)))->IsConferenceCall() == true)
1102 //move back to previous conf. call screen - ownership of 'pCallArgs' transferred
1103 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallArgs);
1107 //move back to previous screen - ownership of 'pCallArgs' transferred
1108 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallArgs);
1116 AppLogDebug("EXIT");
1120 DialTabDialer::SwitchToOutgoingCallScreen(const String& contactNumber)
1122 AppLogDebug("ENTER");
1124 SceneManager* pSceneManager = SceneManager::GetInstance();
1125 AppAssert(pSceneManager);
1127 //Check if dialing a call is possible
1128 if(__pCallPresentor == null)
1130 __pCallPresentor = CallPresentationModel::GetInstance();
1132 bool isSimInitialized = __pCallPresentor->CheckSimInitializationIsCompleted();
1133 if (isSimInitialized == true)
1135 //make an outgoing call with given number
1136 String* contactTxt = new (std::nothrow) String(contactNumber);
1137 //switch to dialing outgoing call form
1138 ArrayList* pContact = new (std::nothrow) ArrayList(SingleObjectDeleter);
1139 pContact->Construct(1);
1140 pContact->Add(contactTxt);
1141 //Check if dialing an emergency call
1142 bool isEmergencyCall = __pCallPresentor->IsEmergencyNumber(*contactTxt, true);
1143 if (isEmergencyCall)
1145 pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL), pContact);
1149 pSceneManager->GoForward( ForwardSceneTransition(IDSCN_SCENE_OUTCALL), pContact);
1154 //TODO: check what to do for SOS calls
1155 //Show error message Popup
1156 if (__pErrorMsgPopup == null)
1158 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
1160 __pErrorMsgPopup->ShowErrorMsgPopupN(ERROR_CODE_SIM_INITIALIZATION_FAILED);
1162 AppLogDebug("EXIT");
1167 DialTabDialer::SwitchToSpeedDialForm(void)
1169 SceneManager* pSceneManager = SceneManager::GetInstance();
1170 AppAssert(pSceneManager);
1171 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_SPEED_DIAL), null);
1176 DialTabDialer::ShowSpeedDialConfirmationPopup(void)
1178 if(__pConfirmationPopup == null)
1180 Rectangle rect = GetBounds();
1181 __pConfirmationPopup = new (std::nothrow) Popup();
1182 __pConfirmationPopup->Construct(false, Dimension(rect.width, H_SPEEDDIAL_POPUP));
1184 rect = __pConfirmationPopup->GetBounds();
1185 Label* pMsgLabel = new (std::nothrow) Label();
1186 String popupMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_MSG);
1187 pMsgLabel->Construct(Rectangle(0, IDI_PADDING, rect.width, H_POPUP_MSG_LABEL), popupMsg);
1188 pMsgLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1189 pMsgLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1190 __pConfirmationPopup->AddControl(*pMsgLabel);
1192 rect = pMsgLabel->GetBounds();
1193 Button *pButtonYes = new (std::nothrow) Button();
1194 String btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_YES_BTN_STRING);
1195 pButtonYes->Construct(Rectangle(rect.x, (rect.y + rect.height + IDI_PADDING), ((rect.width - (6 * IDI_PADDING)) / 2), H_POPUP_BTN), btnName);
1196 pButtonYes->SetActionId(IDA_SPEEDDIAL_POPUP_YES);
1197 pButtonYes->AddActionEventListener(*this);
1198 __pConfirmationPopup->AddControl(*pButtonYes);
1200 rect = pButtonYes->GetBounds();
1201 Button *pButtonNo = new (std::nothrow) Button();
1202 btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_NO_BTN_STRING);
1203 pButtonNo->Construct(Rectangle((rect.x + rect.width + IDI_PADDING), rect.y, rect.width, rect.height), btnName);
1204 pButtonNo->SetActionId(IDA_SPEEDDIAL_POPUP_NO);
1205 pButtonNo->AddActionEventListener(*this);
1206 __pConfirmationPopup->AddControl(*pButtonNo);
1208 //Show Popup message
1209 __pConfirmationPopup->SetShowState(true);
1210 __pConfirmationPopup->Show();
1214 DialTabDialer::ShowAddToContactsButton(void)
1216 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1217 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
1218 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
1219 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
1220 pButtonContacts->SetShowState(false);
1221 pButtonDropDown->SetShowState(false);
1222 pButtonAddContacts->SetShowState(true);
1223 pSearchPanel->SetShowState(true);
1224 pSearchPanel->Invalidate(true);
1229 DialTabDialer::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1233 case REQUEST_SHOW_SUGGESTION:
1235 String *displayname = static_cast<String*> (pArgs->GetAt(0));
1236 String *mobileNo = static_cast<String*> (pArgs->GetAt(1));
1237 String *resultCount = static_cast<String*> (pArgs->GetAt(2));
1238 if(displayname != null && mobileNo != null && resultCount != null)
1240 ShowSuggestionBox(*displayname, *mobileNo, *resultCount);
1246 case REQUEST_SHOW_ADD_TO_CONTACTS:
1248 ShowAddToContactsButton();
1252 case REQUEST_CALL_SPEED_DIAL_NUM:
1256 String *number = static_cast<String*> (pArgs->GetAt(0));
1260 SwitchToOutgoingCallScreen(*number);
1267 case REQUEST_SHOW_SPEED_DIAL_POPUP:
1269 //show speed Dial Confirmation Popup msg
1270 ShowSpeedDialConfirmationPopup();
1277 DialTabDialer::ShowSuggestionBox(String& name, String& mobileNo, String& resultCount)
1279 AppLogDebug("ENTER");
1281 //"UseContact" Button
1282 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
1283 Canvas pCanvasNormalContacts;
1284 pCanvasNormalContacts.Construct(pButtonContacts->GetBounds());
1285 Canvas pCanvasPressedContacts;
1286 pCanvasPressedContacts.Construct(pButtonContacts->GetBounds());
1287 String mobileStr = AppUtility::GetResourceString(IDS_DIALER_MOBILE_STR);
1288 //Add text, Bg to normal state
1289 DialUtil::Draw9PatchToCanvas(pCanvasNormalContacts, IDB_BTN_OPTION_BG_ICON);
1290 DialUtil::DrawTextToCanvas(name, FONT_SUGGESTION_NAME, pCanvasNormalContacts, POSITION_TOP_LEFT, BUTTON_STATUS_NORMAL);
1291 DialUtil::DrawTextToCanvas(mobileStr, FONT_SUGGESTION_MOBILE, pCanvasNormalContacts, POSITION_BOTTOM_LEFT, BUTTON_STATUS_NORMAL);
1292 DialUtil::DrawTextToCanvas(mobileNo, FONT_SUGGESTION_NUMBER, pCanvasNormalContacts, POSITION_BOTTOM_CENTER, BUTTON_STATUS_NORMAL);
1293 //Add text, Bg to pressed state
1294 DialUtil::Draw9PatchToCanvas(pCanvasPressedContacts, IDB_BTN_OPTION_PRESS_BG_ICON);
1295 DialUtil::DrawTextToCanvas(name, FONT_SUGGESTION_NAME, pCanvasPressedContacts, POSITION_TOP_LEFT, BUTTON_STATUS_NORMAL);
1296 DialUtil::DrawTextToCanvas(mobileStr, FONT_SUGGESTION_MOBILE, pCanvasPressedContacts, POSITION_BOTTOM_LEFT, BUTTON_STATUS_NORMAL);
1297 DialUtil::DrawTextToCanvas(mobileNo, FONT_SUGGESTION_NUMBER, pCanvasPressedContacts, POSITION_BOTTOM_CENTER, BUTTON_STATUS_NORMAL);
1298 //add normal, pressed bg bitmap to button
1299 DialUtil::DrawCanvasToButton(&pCanvasNormalContacts, &pCanvasPressedContacts, pButtonContacts);
1302 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
1303 Canvas pCanvasNormalDropDown;
1304 pCanvasNormalDropDown.Construct(pButtonDropDown->GetBounds());
1305 Canvas pCanvasPressedDropDown;
1306 pCanvasPressedDropDown.Construct(pButtonDropDown->GetBounds());
1307 //Add text, Bg to normal state
1308 DialUtil::Draw9PatchToCanvas(pCanvasNormalDropDown, IDB_BTN_OPTION_BG_ICON);
1309 DialUtil::DrawTextToCanvas(resultCount, FONT_SUGGESTION_LIST_NUMBER, pCanvasNormalDropDown, POSITION_TOP_CENTER, BUTTON_STATUS_NORMAL);
1310 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasNormalDropDown, POSITION_BOTTOM_CENTER);
1311 //Add text, Bg to pressed state
1312 DialUtil::Draw9PatchToCanvas(pCanvasPressedDropDown, IDB_BTN_OPTION_PRESS_BG_ICON);
1313 DialUtil::DrawTextToCanvas(resultCount, FONT_SUGGESTION_LIST_NUMBER, pCanvasPressedDropDown, POSITION_TOP_CENTER, BUTTON_STATUS_NORMAL);
1314 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasPressedDropDown, POSITION_BOTTOM_CENTER);
1315 //add background to button
1316 DialUtil::DrawCanvasToButton(&pCanvasNormalDropDown, &pCanvasPressedDropDown, pButtonDropDown);
1318 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
1319 pButtonContacts->SetShowState(true);
1320 pButtonDropDown->SetShowState(true);
1321 pButtonDropDown->Invalidate(true);
1322 pButtonAddContacts->SetShowState(false);
1324 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1325 pSearchPanel->SetShowState(true);
1326 pSearchPanel->Invalidate(true);
1328 AppLogDebug("EXIT");
1333 DialTabDialer::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
1335 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(index+1);
1336 if(pDialInfo != null)
1338 String phNumber = pDialInfo->GetPhoneNumber();
1339 EditField* pTextBox = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1340 if(pTextBox != null)
1343 pTextBox->SetText(phNumber);
1344 pTextBox->Invalidate(true);
1346 HideSearchListView();
1347 __pDialPresentationModel->ClearSearchResults();
1348 UpdateSearchResults();
1354 DialTabDialer::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1356 Form* pForm = static_cast<Form*>(GetParent());
1357 pForm->SetOrientation(ORIENTATION_PORTRAIT);
1358 pForm->Invalidate(true);
1363 DialTabDialer::HandlePopupClosed(void)
1366 delete __pErrorMsgPopup;
1367 __pErrorMsgPopup = null;
1372 DialTabDialer::IsOpenedFromOtherView(void)
1374 if(__pPreviousSceneId != null)
1382 DialTabDialer::OnForeground(void)
1384 AppLogDebug("Enter");
1385 __isAppForeground = true;
1386 //If app control was launched
1387 //as we do not know if it success or failed
1388 // we need to UpdateSearchResults
1389 //Returned from app control if app control does not
1390 //send any response we need to do this
1391 SetAppControlLaunched(false);
1395 DialTabDialer::OnBackground(void)
1397 AppLogDebug("Enter");
1398 __isAppForeground = false;
1402 DialTabDialer::IsForeground()
1404 AppLogDebug("Enter %d",__isAppForeground);
1405 return __isAppForeground;
1409 DialTabDialer::OnContactsChanged(const IList& contactChangeInfoList)
1411 if(contactChangeInfoList.GetCount() > 0)
1413 //clear old search results
1414 __pDialPresentationModel->ClearSearchResults();
1415 UpdateSearchResults();
1420 DialTabDialer::SetAppControlLaunched(bool launched)
1422 AppLogDebug("%d",__isAppControlLaunched);
1423 __isAppControlLaunched = launched;
1427 DialTabDialer::GetAppControlLaunched(void)
1429 AppLogDebug("%d",__isAppControlLaunched);
1430 return __isAppControlLaunched;