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)
651 UpdateSearchResults();
658 if (pEditField->GetTextLength() > 0)
660 String contactNo = pEditField->GetText();
661 contactNo.Replace(L"-",L"");
662 SwitchToOutgoingCallScreen(contactNo);
667 //show latest dialed or incoming number from Logs
668 String* number = __pDialPresentationModel->FetchLatestNumberFromLogsN();
671 pEditField->SetText(*number);
672 UpdateSearchResults();
681 pEditField->AppendText(L"*");
682 if (pEditField->GetTextLength() == 0)
688 UpdateSearchResults();
695 pEditField->AppendText(L"#");
696 if (pEditField->GetTextLength() == 0)
702 UpdateSearchResults();
715 PhoneApp* pApp = static_cast<PhoneApp*>(UiApp::GetInstance());
716 bool isAppControl = pApp->IsOpenAsAppControl();
717 if(isAppControl == true && __pPreviousSceneId == null)
721 else if(__pCallPresentor->GetCurrentCallCount() > 0)
723 //Switch back to previous screen
724 SwitchToPreviousActiveCallScreen();
730 case IDA_BTN_SHOW_CONTEXTMENU:
732 // Show the ContextMenu
733 String contactNo = pEditField->GetText();
734 contactNo.Replace(L"-",L"");
735 ShowContextMenu(contactNo);
736 if (__isSearchListOpened == true)
738 HideSearchListView();
743 case IDA_MENU_SEND_MESSAGE:
745 String contactNo = pEditField->GetText();
746 contactNo.Replace(L"-",L"");
747 __pDialPresentationModel->OpenMessagingAppControl(contactNo);
752 case IDA_BTN_ADD_TO_CONTACTS:
753 case IDA_MENU_ADD_CONTACT:
755 if(pEditField->GetTextLength() > 0)
757 String contactNo = pEditField->GetText();
758 contactNo.Replace(L"-",L"");
759 __pDialPresentationModel->AddContactsToAddressBook(contactNo);
760 SetAppControlLaunched(true);
766 case IDA_SPEEDDIAL_POPUP_YES:
768 __pConfirmationPopup->SetShowState(false);
769 SwitchToSpeedDialForm();
773 case IDA_SPEEDDIAL_POPUP_NO:
775 __pConfirmationPopup->SetShowState(false);
780 case IDA_MENU_SPEED_DIAL:
782 SwitchToSpeedDialForm();
787 case IDA_MENU_ADD_PAUSE:
793 case IDA_MENU_ADD_WAIT:
801 if(__pCallPresentor->GetCurrentCallCount() > 0)
803 //Switch back to previous screen
804 SwitchToPreviousActiveCallScreen();
810 UiApp::GetInstance()->Terminate();
815 case IDA_BTN_USE_CONTACT_DATA:
817 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(0);
818 if(pDialInfo != null)
820 //fetch contact number
821 String phNumber = pDialInfo->GetPhoneNumber();
822 if(phNumber.Equals(pEditField->GetText()) == false)
825 pEditField->SetText(phNumber);
826 pEditField->Invalidate(true);
827 if (__isSearchListOpened == true)
829 HideSearchListView();
831 UpdateSearchResults();
837 case IDA_BTN_DISPLAY_CONTACTS:
839 if (__isSearchListOpened == true)
841 HideSearchListView();
845 ShowSearchListView();
853 pEditField->Invalidate(true);
860 DialTabDialer::OnLongPressGestureDetected(TouchLongPressGestureDetector& gestureDetector)
862 AppLogDebug("ENTER");
864 if (gestureDetector.GetControl() != null)
866 Button* pButton = static_cast<Button*>(gestureDetector.GetControl());
867 int actionId = pButton->GetActionId();
879 //Check if Speed Dial setting exist for pressed key
880 String* contactNumber = __pDialPresentationModel->FetchSpeedDialNumberN(actionId);
881 if(contactNumber != null)
883 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
885 //pass ownership to arraylist
886 pArgs->Add(contactNumber);
887 SendUserEvent(REQUEST_CALL_SPEED_DIAL_NUM,pArgs);
891 //show speed Dial Confirmation Popup msg
892 SendUserEvent(REQUEST_SHOW_SPEED_DIAL_POPUP,null);
906 //Handle Mute / UnMute
907 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
908 if(pEditField->GetTextLength() == 0)
910 bool enabled = false;
911 String title = L"http://tizen.org/setting/sound.silent_mode";
912 SettingInfo::GetValue(title, enabled);
913 //enable or disable the phone silent mode.
914 result r = E_FAILURE;
915 r = SettingInfo::SetValue(title, !enabled);
916 if(r == E_OBJ_NOT_FOUND)
918 AppLog("Object not found");
926 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
927 if (pEditField != null && pEditField->GetTextLength() > 0)
930 pEditField->SetTextSize(IDI_MAX_TXT_FONT);
931 pEditField->SetCursorPosition(0);
932 pEditField->SetFocus();
933 pEditField->Invalidate(true);
954 DialTabDialer::ShowContextMenu(String& contactNumber)
956 AppLogDebug("ENTER");
958 if(__pContextMenu != null)
960 delete __pContextMenu;
961 __pContextMenu = null;
963 __pContextMenu = new (std::nothrow) ContextMenu();
964 __pContextMenu->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
966 //minimum available option count
967 int visibleItems = MIN_CONTEXT_MENU_ITEMS;
969 //Show SendMsg Option only if NOT opened from Outgoing Call
970 if(__pPreviousSceneId == null)
972 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SEND_MSG), IDA_MENU_SEND_MESSAGE);
975 //Don't show 'AddContact' if empty text field
976 //or contact number is already saved.
977 if(contactNumber.IsEmpty() != true)
979 Contact* pContact = __pCallPresentor->GetContactN(contactNumber);
982 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_CONTACT), IDA_MENU_ADD_CONTACT);
990 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SPEED_DIAL), IDA_MENU_SPEED_DIAL);
991 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_PAUSE), IDA_MENU_ADD_PAUSE);
992 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_WAIT), IDA_MENU_ADD_WAIT);
993 __pContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_EXIT), IDA_MENU_EXIT);
994 __pContextMenu->AddActionEventListener(*this);
996 __pContextMenu->SetMaxVisibleItemsCount(visibleItems);
997 // Set the anchor position of the ContextMenu
998 __pContextMenu->SetAnchorPosition(Point(X_CONTEXT_MENU_ANCHOR, Y_CONTEXT_MENU_ANCHOR));
999 // Show the ContextMenu
1000 __pContextMenu->Show();
1002 AppLogDebug("EXIT");
1007 DialTabDialer::AddPause(void)
1009 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1010 if (pEditField != null)
1012 pEditField->AppendText(L";");
1013 if (pEditField->GetTextLength() == 0)
1019 UpdateSearchResults();
1021 pEditField->Invalidate(true);
1027 DialTabDialer::AddWait(void)
1029 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1030 if (pEditField != null)
1032 pEditField->AppendText(L",");
1033 if (pEditField->GetTextLength() == 0)
1039 UpdateSearchResults();
1041 pEditField->Invalidate(true);
1047 DialTabDialer::AddPlus(void)
1049 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1050 if (pEditField != null)
1052 pEditField->AppendText(L"+");
1053 if (pEditField->GetTextLength() == 0)
1059 UpdateSearchResults();
1061 pEditField->Invalidate(true);
1067 DialTabDialer::SwitchToPreviousActiveCallScreen(void)
1069 AppLogDebug("ENTER");
1071 SceneManager* pSceneManager = SceneManager::GetInstance();
1072 AppAssert(pSceneManager);
1073 if(__pCallPresentor == null)
1075 __pCallPresentor = CallPresentationModel::GetInstance();
1077 //Fetch call info list
1078 IListT<CallInfo>* pCallList = __pCallPresentor->GetCallListN();
1079 IEnumeratorT<CallInfo>* pCallEnum = pCallList->GetEnumeratorN();
1080 if(pCallEnum != null)
1082 ArrayList* pCallArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1083 pCallArgs->Construct();
1084 while(pCallEnum->MoveNext() == E_SUCCESS)
1087 if(pCallEnum->GetCurrent(callInfo) == E_SUCCESS)
1089 CallInfo* pActiveCall = new (std::nothrow) CallInfo();
1090 *pActiveCall = callInfo;
1091 pCallArgs->Add(pActiveCall);
1095 if(pCallArgs->GetCount() == 1 && (static_cast<CallInfo*>(pCallArgs->GetAt(0)))->IsConferenceCall() == true)
1097 //move back to previous conf. call screen - ownership of 'pCallArgs' transferred
1098 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallArgs);
1102 //move back to previous screen - ownership of 'pCallArgs' transferred
1103 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallArgs);
1111 AppLogDebug("EXIT");
1115 DialTabDialer::SwitchToOutgoingCallScreen(const String& contactNumber)
1117 AppLogDebug("ENTER");
1119 SceneManager* pSceneManager = SceneManager::GetInstance();
1120 AppAssert(pSceneManager);
1122 //Check if dialing a call is possible
1123 if(__pCallPresentor == null)
1125 __pCallPresentor = CallPresentationModel::GetInstance();
1127 bool isSimInitialized = __pCallPresentor->CheckSimInitializationIsCompleted();
1128 if (isSimInitialized == true)
1130 //make an outgoing call with given number
1131 String* contactTxt = new (std::nothrow) String(contactNumber);
1132 //switch to dialing outgoing call form
1133 ArrayList* pContact = new (std::nothrow) ArrayList(SingleObjectDeleter);
1134 pContact->Construct(1);
1135 pContact->Add(contactTxt);
1136 //Check if dialing an emergency call
1137 bool isEmergencyCall = __pCallPresentor->IsEmergencyNumber(*contactTxt, true);
1138 if (isEmergencyCall)
1140 pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL), pContact);
1144 pSceneManager->GoForward( ForwardSceneTransition(IDSCN_SCENE_OUTCALL), pContact);
1149 //TODO: check what to do for SOS calls
1150 //Show error message Popup
1151 if (__pErrorMsgPopup == null)
1153 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
1155 __pErrorMsgPopup->ShowErrorMsgPopupN(ERROR_CODE_SIM_INITIALIZATION_FAILED);
1157 AppLogDebug("EXIT");
1162 DialTabDialer::SwitchToSpeedDialForm(void)
1164 SceneManager* pSceneManager = SceneManager::GetInstance();
1165 AppAssert(pSceneManager);
1166 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_SPEED_DIAL), null);
1171 DialTabDialer::ShowSpeedDialConfirmationPopup(void)
1173 if(__pConfirmationPopup == null)
1175 Rectangle rect = GetBounds();
1176 __pConfirmationPopup = new (std::nothrow) Popup();
1177 __pConfirmationPopup->Construct(false, Dimension(rect.width, H_SPEEDDIAL_POPUP));
1179 rect = __pConfirmationPopup->GetBounds();
1180 Label* pMsgLabel = new (std::nothrow) Label();
1181 String popupMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_MSG);
1182 pMsgLabel->Construct(Rectangle(0, IDI_PADDING, rect.width, H_POPUP_MSG_LABEL), popupMsg);
1183 pMsgLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1184 pMsgLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1185 __pConfirmationPopup->AddControl(*pMsgLabel);
1187 rect = pMsgLabel->GetBounds();
1188 Button *pButtonYes = new (std::nothrow) Button();
1189 String btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_YES_BTN_STRING);
1190 pButtonYes->Construct(Rectangle(rect.x, (rect.y + rect.height + IDI_PADDING), ((rect.width - (6 * IDI_PADDING)) / 2), H_POPUP_BTN), btnName);
1191 pButtonYes->SetActionId(IDA_SPEEDDIAL_POPUP_YES);
1192 pButtonYes->AddActionEventListener(*this);
1193 __pConfirmationPopup->AddControl(*pButtonYes);
1195 rect = pButtonYes->GetBounds();
1196 Button *pButtonNo = new (std::nothrow) Button();
1197 btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_NO_BTN_STRING);
1198 pButtonNo->Construct(Rectangle((rect.x + rect.width + IDI_PADDING), rect.y, rect.width, rect.height), btnName);
1199 pButtonNo->SetActionId(IDA_SPEEDDIAL_POPUP_NO);
1200 pButtonNo->AddActionEventListener(*this);
1201 __pConfirmationPopup->AddControl(*pButtonNo);
1203 //Show Popup message
1204 __pConfirmationPopup->SetShowState(true);
1205 __pConfirmationPopup->Show();
1209 DialTabDialer::ShowAddToContactsButton(void)
1211 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1212 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
1213 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
1214 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
1215 pButtonContacts->SetShowState(false);
1216 pButtonDropDown->SetShowState(false);
1217 pButtonAddContacts->SetShowState(true);
1218 pSearchPanel->SetShowState(true);
1219 pSearchPanel->Invalidate(true);
1224 DialTabDialer::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1228 case REQUEST_SHOW_SUGGESTION:
1230 String *displayname = static_cast<String*> (pArgs->GetAt(0));
1231 String *mobileNo = static_cast<String*> (pArgs->GetAt(1));
1232 String *resultCount = static_cast<String*> (pArgs->GetAt(2));
1233 if(displayname != null && mobileNo != null && resultCount != null)
1235 ShowSuggestionBox(*displayname, *mobileNo, *resultCount);
1241 case REQUEST_SHOW_ADD_TO_CONTACTS:
1243 ShowAddToContactsButton();
1247 case REQUEST_CALL_SPEED_DIAL_NUM:
1251 String *number = static_cast<String*> (pArgs->GetAt(0));
1255 SwitchToOutgoingCallScreen(*number);
1262 case REQUEST_SHOW_SPEED_DIAL_POPUP:
1264 //show speed Dial Confirmation Popup msg
1265 ShowSpeedDialConfirmationPopup();
1272 DialTabDialer::ShowSuggestionBox(String& name, String& mobileNo, String& resultCount)
1274 AppLogDebug("ENTER");
1276 //"UseContact" Button
1277 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
1278 Canvas pCanvasNormalContacts;
1279 pCanvasNormalContacts.Construct(pButtonContacts->GetBounds());
1280 Canvas pCanvasPressedContacts;
1281 pCanvasPressedContacts.Construct(pButtonContacts->GetBounds());
1282 String mobileStr = AppUtility::GetResourceString(IDS_DIALER_MOBILE_STR);
1283 //Add text, Bg to normal state
1284 DialUtil::Draw9PatchToCanvas(pCanvasNormalContacts, IDB_BTN_OPTION_BG_ICON);
1285 DialUtil::DrawTextToCanvas(name, FONT_SUGGESTION_NAME, pCanvasNormalContacts, POSITION_TOP_LEFT, BUTTON_STATUS_NORMAL);
1286 DialUtil::DrawTextToCanvas(mobileStr, FONT_SUGGESTION_MOBILE, pCanvasNormalContacts, POSITION_BOTTOM_LEFT, BUTTON_STATUS_NORMAL);
1287 DialUtil::DrawTextToCanvas(mobileNo, FONT_SUGGESTION_NUMBER, pCanvasNormalContacts, POSITION_BOTTOM_CENTER, BUTTON_STATUS_NORMAL);
1288 //Add text, Bg to pressed state
1289 DialUtil::Draw9PatchToCanvas(pCanvasPressedContacts, IDB_BTN_OPTION_PRESS_BG_ICON);
1290 DialUtil::DrawTextToCanvas(name, FONT_SUGGESTION_NAME, pCanvasPressedContacts, POSITION_TOP_LEFT, BUTTON_STATUS_NORMAL);
1291 DialUtil::DrawTextToCanvas(mobileStr, FONT_SUGGESTION_MOBILE, pCanvasPressedContacts, POSITION_BOTTOM_LEFT, BUTTON_STATUS_NORMAL);
1292 DialUtil::DrawTextToCanvas(mobileNo, FONT_SUGGESTION_NUMBER, pCanvasPressedContacts, POSITION_BOTTOM_CENTER, BUTTON_STATUS_NORMAL);
1293 //add normal, pressed bg bitmap to button
1294 DialUtil::DrawCanvasToButton(&pCanvasNormalContacts, &pCanvasPressedContacts, pButtonContacts);
1297 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
1298 Canvas pCanvasNormalDropDown;
1299 pCanvasNormalDropDown.Construct(pButtonDropDown->GetBounds());
1300 Canvas pCanvasPressedDropDown;
1301 pCanvasPressedDropDown.Construct(pButtonDropDown->GetBounds());
1302 //Add text, Bg to normal state
1303 DialUtil::Draw9PatchToCanvas(pCanvasNormalDropDown, IDB_BTN_OPTION_BG_ICON);
1304 DialUtil::DrawTextToCanvas(resultCount, FONT_SUGGESTION_LIST_NUMBER, pCanvasNormalDropDown, POSITION_TOP_CENTER, BUTTON_STATUS_NORMAL);
1305 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasNormalDropDown, POSITION_BOTTOM_CENTER);
1306 //Add text, Bg to pressed state
1307 DialUtil::Draw9PatchToCanvas(pCanvasPressedDropDown, IDB_BTN_OPTION_PRESS_BG_ICON);
1308 DialUtil::DrawTextToCanvas(resultCount, FONT_SUGGESTION_LIST_NUMBER, pCanvasPressedDropDown, POSITION_TOP_CENTER, BUTTON_STATUS_NORMAL);
1309 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasPressedDropDown, POSITION_BOTTOM_CENTER);
1310 //add background to button
1311 DialUtil::DrawCanvasToButton(&pCanvasNormalDropDown, &pCanvasPressedDropDown, pButtonDropDown);
1313 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
1314 pButtonContacts->SetShowState(true);
1315 pButtonDropDown->SetShowState(true);
1316 pButtonDropDown->Invalidate(true);
1317 pButtonAddContacts->SetShowState(false);
1319 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1320 pSearchPanel->SetShowState(true);
1321 pSearchPanel->Invalidate(true);
1323 AppLogDebug("EXIT");
1328 DialTabDialer::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
1330 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(index+1);
1331 if(pDialInfo != null)
1333 String phNumber = pDialInfo->GetPhoneNumber();
1334 EditField* pTextBox = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1335 if(pTextBox != null)
1338 pTextBox->SetText(phNumber);
1339 pTextBox->Invalidate(true);
1341 HideSearchListView();
1342 UpdateSearchResults();
1348 DialTabDialer::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1350 Form* pForm = static_cast<Form*>(GetParent());
1351 pForm->SetOrientation(ORIENTATION_PORTRAIT);
1352 pForm->Invalidate(true);
1357 DialTabDialer::HandlePopupClosed(void)
1360 delete __pErrorMsgPopup;
1361 __pErrorMsgPopup = null;
1366 DialTabDialer::IsOpenedFromOtherView(void)
1368 if(__pPreviousSceneId != null)
1376 DialTabDialer::OnForeground(void)
1378 AppLogDebug("Enter");
1379 __isAppForeground = true;
1380 //If app control was launched
1381 //as we do not know if it success or failed
1382 // we need to UpdateSearchResults
1383 //Returned from app control if app control does not
1384 //send any response we need to do this
1385 SetAppControlLaunched(false);
1389 DialTabDialer::OnBackground(void)
1391 AppLogDebug("Enter");
1392 __isAppForeground = false;
1396 DialTabDialer::IsForeground()
1398 AppLogDebug("Enter %d",__isAppForeground);
1399 return __isAppForeground;
1403 DialTabDialer::OnContactsChanged(const IList& contactChangeInfoList)
1405 if(contactChangeInfoList.GetCount() > 0)
1407 //clear old search results
1408 __pDialPresentationModel->ClearSearchResults();
1409 UpdateSearchResults();
1414 DialTabDialer::SetAppControlLaunched(bool launched)
1416 AppLogDebug("%d",__isAppControlLaunched);
1417 __isAppControlLaunched = launched;
1421 DialTabDialer::GetAppControlLaunched(void)
1423 AppLogDebug("%d",__isAppControlLaunched);
1424 return __isAppControlLaunched;