2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file PhnTabDialer.cpp
19 * @brief The dialer Tab
24 #include <FTelephony.h>
25 #include "PhnAppUtility.h"
26 #include "PhnPhoneApp.h"
27 #include "PhnCalllogManager.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;
47 using namespace Tizen::Telephony;
48 using namespace Tizen::Base::Utility;
51 const int H_SPEEDDIAL_POPUP = 350;
52 const int W_SPEEDDIAL_POPUP = 720;
53 const int H_POPUP_MSG_LABEL = 100;
54 const int H_POPUP_BTN = 90;
55 const int H_SEARCHLIST_ITEM = 140;
56 const int IDI_PADDING = 15;
57 const int IDI_MAX_LIMIT_LENGTH = 18;
58 const int IDI_MAX_TXT_FONT = 94;
59 const int IDI_MIN_TXT_FONT = 67;
60 const int IDI_DELTA_FONT_SIZE = 5;
61 const int MAX_SEARCH_LIST_ITEMS = 6;
62 const int MAX_SEARCH_LIST_ITEMS_LANDSCAPE = 2;
63 const int MIN_CONTEXT_MENU_ITEMS = 1;
64 const int X_CONTEXT_MENU_ANCHOR = 57;
65 const int Y_CONTEXT_MENU_ANCHOR = 1218;
66 const int X_CONTEXT_MENU_LANDSCAPE_ANCHOR = 666;
67 const int Y_CONTEXT_MENU_LANDSCAPE_ANCHOR = 545;
68 const int X_CALL_CONTEXT_MENU_ANCHOR = 360;
69 const int Y_CALL_CONTEXT_MENU_ANCHOR = 1168;
70 const int X_CALL_CONTEXT_MENU_LANDSCAPE_ANCHOR = 815;
71 const int Y_CALL_CONTEXT_MENU_LANDSCAPE_ANCHOR = 650;
72 const int MAX_NUMBER_WITH_SEPERATOR = 12;
73 const int MIN_NUMBER_WITH_ONE_SEPERATOR = 3;
74 const int MIN_NUMBER_WITH_TWO_SEPERATOR = 7;
75 const int MAX_TXT_LENGTH_WITH_SEPERATOR = 11;
76 const int MAX_VISIBLE_TXT_WITH_MIN_FONT = 15;
77 const int W_MORE_BUTTON = 74;
78 const int H_MORE_BUTTON = 74;
79 const int W_SUGGESTION_POPUP_BUBBLE_ICON = 40;
80 const int H_SUGGESTION_POPUP_BUBBLE_ICON = 20;
83 static const wchar_t* IDL_PANEL_DIALER = L"IDL_PANEL_DIALER";
84 const wchar_t* IDC_NUMERIC_EDITFIELD = L"IDC_EDITFIELD";
85 const wchar_t* IDC_PANEL_SEARCH_BOX = L"IDC_PANEL_SEARCH_BOX";
86 const wchar_t* IDC_BUTTON_ADD_CONTACTS = L"IDC_BUTTON_ADD_CONTACTS";
87 const wchar_t* IDC_BUTTON_USE_CONTACT = L"IDC_BUTTON_USE_CONTACT";
88 const wchar_t* IDC_BUTTON_DROP_DOWN = L"IDC_BUTTON_DROP_DOWN";
89 const wchar_t* IDC_BUTTON_PULL_UP = L"IDC_BUTTON_PULL_UP";
90 const wchar_t* IDC_PANEL_SEARCH_LIST = L"IDC_PANEL_SEARCH_LIST";
91 const wchar_t* IDC_PANEL_MENU = L"IDC_PANEL_MENU";
92 const wchar_t* IDC_BUTTON_MENU = L"IDC_BUTTON_MENU";
93 const wchar_t* IDC_LISTVIEW_SEARCH = L"IDC_LISTVIEW_SEARCH";
94 const wchar_t* IDC_BUTTON_SEARCHFIELD = L"IDC_BUTTON_SEARCHFIELD";
95 const wchar_t* IDC_BUTTON_SEARCHICON = L"IDC_BUTTON_SEARCHICON";
96 const wchar_t* IDC_LABEL_LASTROW_BG = L"IDC_LABEL_LASTROW_BG";
97 const wchar_t* IDC_PANEL_DROPDOWN = L"IDC_PANEL_DROPDOWN";
98 const wchar_t* IDC_PANEL_USE_CONTACT = L"IDC_PANEL_USE_CONTACT";
99 const wchar_t* IDC_SPEED_DIAL_TXT_LABEL = L"IDC_SPEED_DIAL_TXT_LABEL";
103 const int DialTabDialer::IDI_BGBITMAP_WIDTH = 75;
104 const int DialTabDialer::IDI_BGBITMAP_HEIGHT = 75;
105 const int DialTabDialer::IDI_BGBITMAP_POS_X = 56;
106 const int DialTabDialer::IDI_BGBITMAP_POS_Y = 56;
107 const int DialTabDialer::IDI_TEXT1_SIZE = 116;
108 const int DialTabDialer::IDI_TEXT2_SIZE = 40;
109 const int MAXUSECONTACTNAMELENGTH = 20;
110 const int MAXUSECONTACTNUMBERLENGTH = 27;
113 const unsigned int COLOR_SEARCHLIST_BG = Color32<248, 246, 239>::Value;
114 const unsigned int COLOR_SEARCHLIST_PRESS_BG = Color32<87, 135, 194>::Value;
116 DialTabDialer::DialTabDialer(void)
118 AppLogDebug("ENTER");
119 __pDialPresentationModel = null;
120 __pSuggestionListProvider = null;
121 __pSearchListView = null;
122 __isSearchListOpened = false;
123 __pErrorMsgPopup = null;
124 __pCallContextMenu = null;
125 __pDialKeypad = null;
126 __pConfirmationPopup = null;
127 __isAppForeground = true;
128 __pAddressBook = null;
129 __isAppControlLaunched = false;
130 __dialerState = DIALER_STATE_FIRST_SCENE;
131 __pOptionMenu = null;
135 DialTabDialer::~DialTabDialer(void)
137 AppLogDebug("ENTER");
139 if(__pDialKeypad != null)
141 __pDialKeypad = null;
143 if(__pConfirmationPopup != null)
145 delete __pConfirmationPopup;
146 __pConfirmationPopup = null;
148 if (__pAddressBook != null)
150 delete __pAddressBook;
151 __pAddressBook = null;
153 if(__pErrorMsgPopup != null)
155 delete __pErrorMsgPopup;
156 __pErrorMsgPopup = null;
158 delete __pOptionMenu;
159 delete __pCallContextMenu;
164 DialTabDialer::Initialize(void)
166 AppLogDebug("ENTER");
167 Construct(IDL_PANEL_DIALER);
173 DialTabDialer::OnInitializing(void)
175 AppLogDebug("ENTER");
176 result r = E_SUCCESS;
178 Form* pForm = dynamic_cast<Form*>(GetParent());
184 __pDialPresentationModel = new DialPresentationModel(*this);
185 __pSuggestionListProvider = new SuggestionItemProvider(*__pDialPresentationModel);
186 __pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN();
188 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN());
189 if (pRelativeLayout != null)
191 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
192 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
193 delete pRelativeLayout;
195 pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN());
196 if (pRelativeLayout != null)
198 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
199 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
200 delete pRelativeLayout;
204 pForm->GetFooter()->SetShowState(false);
207 ConstructSearchMenu();
208 //Initialize text box
209 InitializeContactsTextBox();
210 //Create and hide Search data display panel
211 InitializeSearchBox();
212 //initialize search list view and hide it.
213 InitializeSearchListView();
214 HideSearchListView();
223 DialTabDialer::OnTerminating(void)
225 result r = E_SUCCESS;
226 if (__pDialPresentationModel != null)
228 delete __pDialPresentationModel;
229 __pDialPresentationModel = null;
231 if (__pSuggestionListProvider != null)
233 delete __pSuggestionListProvider;
234 __pSuggestionListProvider = null;
236 // Add your termination code here
241 DialTabDialer::InitializeContactsTextBox(void)
243 AppLogDebug("ENTER");
245 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
246 if (pEditField != null)
250 pEditField->SetOverlayKeypadCommandButtonVisible(false);
259 DialTabDialer::ShowFormattedText(EditField* pEditField, String contactNumber)
261 contactNumber.Replace(L"-",L"");
262 int textLength = contactNumber.GetLength();
266 pEditField->Invalidate(true);
270 //Insert separator if required
271 if(textLength < MAX_NUMBER_WITH_SEPERATOR)
273 if(textLength > MIN_NUMBER_WITH_TWO_SEPERATOR)
275 contactNumber.Insert(L"-",MIN_NUMBER_WITH_TWO_SEPERATOR);
277 if(textLength > MIN_NUMBER_WITH_ONE_SEPERATOR)
279 contactNumber.Insert(L"-",MIN_NUMBER_WITH_ONE_SEPERATOR);
283 textLength = contactNumber.GetLength();
285 //need to change font to fit inside text box
286 //With size 94 -> 12 chars, 67 -> 18 chars
287 int fontSize = pEditField->GetTextSize();
289 if(textLength < MAX_VISIBLE_TXT_WITH_MIN_FONT)
292 fontSize += IDI_DELTA_FONT_SIZE;
294 else if(textLength > MAX_TXT_LENGTH_WITH_SEPERATOR)
297 fontSize -= IDI_DELTA_FONT_SIZE;
300 if(fontSize > IDI_MAX_TXT_FONT )
302 fontSize = IDI_MAX_TXT_FONT;
304 if(fontSize < IDI_MIN_TXT_FONT)
306 fontSize = IDI_MIN_TXT_FONT;
308 pEditField->SetTextSize(fontSize);
309 //set text to edit field
310 pEditField->SetText(contactNumber);
311 //pEditField->SetFocus();
312 pEditField->SetCursorPosition(contactNumber.GetLength()+1);
318 DialTabDialer::ShowFormattedText(EditField* pEditField, int actionId)
320 AppLogDebug("ENTER");
321 bool clearflag = false;
322 int startpos=-1,endpos=-1;
323 pEditField->GetBlockRange(startpos,endpos);
324 AppLogDebug("GetBlockRange %d %d",startpos,endpos);
326 if((actionId != CLEAR_KEY) && (pEditField->GetRemainingLength()==0))
332 if(actionId == CLEAR_KEY)
336 pEditField->Remove();
337 pEditField->ReleaseBlock();
341 String contactNumber = pEditField->GetText();
342 int intialCursorPos = pEditField->GetCursorPosition();
343 if(actionId == CLEAR_KEY && intialCursorPos == 0)
348 if(pEditField->GetText().Contains(L"-"))
350 if( intialCursorPos > MIN_NUMBER_WITH_ONE_SEPERATOR)
354 if(intialCursorPos > MIN_NUMBER_WITH_TWO_SEPERATOR)
360 contactNumber.Replace(L"-",L"");
362 if(actionId == CLEAR_KEY)
364 if(clearflag == false)
366 contactNumber.Remove(intialCursorPos-1,1);
372 contactNumber.Insert(DialUtil::ConvertDialedNumberToString(actionId),intialCursorPos);
377 int textLength = contactNumber.GetLength();
381 pEditField->Invalidate(true);
386 //Insert separator if required
387 if(textLength < MAX_NUMBER_WITH_SEPERATOR)
389 if(textLength > MIN_NUMBER_WITH_TWO_SEPERATOR)
391 contactNumber.Insert(L"-",MIN_NUMBER_WITH_TWO_SEPERATOR);
392 if(intialCursorPos > MIN_NUMBER_WITH_TWO_SEPERATOR)
397 if(textLength > MIN_NUMBER_WITH_ONE_SEPERATOR)
399 contactNumber.Insert(L"-",MIN_NUMBER_WITH_ONE_SEPERATOR);
400 if(intialCursorPos > MIN_NUMBER_WITH_ONE_SEPERATOR)
408 textLength = contactNumber.GetLength();
410 //need to change font to fit inside text box
411 //With size 94 -> 12 chars, 67 -> 18 chars
412 int fontSize = pEditField->GetTextSize();
413 if((actionId == CLEAR_KEY) && (textLength < MAX_VISIBLE_TXT_WITH_MIN_FONT))
416 fontSize += IDI_DELTA_FONT_SIZE;
418 else if(textLength > MAX_TXT_LENGTH_WITH_SEPERATOR)
421 fontSize -= IDI_DELTA_FONT_SIZE;
424 if(fontSize > IDI_MAX_TXT_FONT)
426 fontSize = IDI_MAX_TXT_FONT;
428 if(fontSize < IDI_MIN_TXT_FONT)
430 fontSize = IDI_MIN_TXT_FONT;
432 pEditField->SetTextSize(fontSize);
433 //set text to edit field
434 pEditField->SetText(contactNumber);
435 //pEditField->SetFocus();
436 pEditField->SetCursorPosition(intialCursorPos);
443 DialTabDialer::InitializeSearchBox(void)
445 AppLogDebug("ENTER");
448 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
449 pSearchPanel->SetShowState(false);
451 //"Add to contacts" button
452 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
453 pButtonAddContacts->SetActionId(IDA_BTN_ADD_TO_CONTACTS);
454 pButtonAddContacts->AddActionEventListener(*this);
455 pButtonAddContacts->SetShowState(false);
457 //"Use Contacts" button
458 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
459 pButtonContacts->SetActionId(IDA_BTN_USE_CONTACT_DATA);
460 pButtonContacts->AddActionEventListener(*this);
462 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
463 pButtonDropDown->SetActionId(IDA_BTN_DISPLAY_CONTACTS);
464 pButtonDropDown->AddActionEventListener(*this);
465 Button* pButtonPullUp = static_cast<Button*>(GetControl(IDC_BUTTON_PULL_UP, true));
466 pButtonPullUp->SetActionId(IDA_BTN_DISPLAY_CONTACTS);
467 pButtonPullUp->AddActionEventListener(*this);
469 pSearchPanel->Invalidate(true);
475 DialTabDialer::UpdateSearchResults(void)
477 AppLogDebug("ENTER");
479 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
480 //send request to search for suggestion list
481 String searchStr = pEditField->GetText();
482 searchStr.Replace(L"-",L"");
483 if(searchStr.IsEmpty() == false)
485 __pDialPresentationModel->FetchSuggestionList(searchStr);
493 DialTabDialer::HideSearchBox(void)
495 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
496 pButtonAddContacts->SetShowState(false);
497 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
498 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
499 pButtonContacts->SetShowState(true);
500 pButtonDropDown->SetShowState(true);
502 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
503 pSearchPanel->SetShowState(false);
504 pSearchPanel->Invalidate(true);
506 HideSearchListView();
511 DialTabDialer::InitializeSearchListView(void)
514 __pSearchListView = static_cast<ListView*>(GetControl(IDC_LISTVIEW_SEARCH,true));
515 if(__pSearchListView != null)
517 __pSearchListView->SetSweepEnabled(true);
518 __pSearchListView->SetItemProvider(*__pSuggestionListProvider);
519 __pSearchListView->AddListViewItemEventListener(*this);
520 __pSearchListView->SetBackgroundColor(Color(COLOR_SEARCHLIST_BG));
521 Panel* pSearchListPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_LIST, true));
522 if(pSearchListPanel != null)
524 SetControlAlwaysOnTop(*pSearchListPanel, true);
530 DialTabDialer::ShowSearchListView(void)
532 AppLogDebug("ENTER");
534 Form* pForm = dynamic_cast<Form *>(GetParent());
537 AppLog("pForm == null");
540 //find the no. of search rows to be shown - Maximum 5 can be shown.
541 int noOfItems = MAX_SEARCH_LIST_ITEMS;
542 if(pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
544 noOfItems = MAX_SEARCH_LIST_ITEMS_LANDSCAPE;
546 if(__pDialPresentationModel->GetNumberOfSuggestions() < (noOfItems+1))
548 noOfItems = __pDialPresentationModel->GetNumberOfSuggestions() - 1;
555 if(pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
559 SetShiftedPosUseContact();
561 else if(noOfItems <= 1)
563 SetOrigPosUseContact();
567 Panel* pSearchListPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_LIST, true));
568 if(pSearchListPanel != null)
570 Rectangle searchPanelbounds = pSearchListPanel->GetBounds();
571 if(pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
575 searchPanelbounds.y = 350;
576 searchPanelbounds.height = 500;
580 searchPanelbounds.y = 470;
584 pSearchListPanel->SetBounds(searchPanelbounds);
585 pSearchListPanel->SetShowState(true);
586 pSearchListPanel->InvalidateBounds(searchPanelbounds);
589 if (__pSearchListView != null)
592 Rectangle searchListbounds = __pSearchListView->GetBounds();
593 if(pForm->GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || pForm->GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
595 searchListbounds.height = H_SEARCHLIST_ITEM * noOfItems;
599 searchListbounds.height = H_SEARCHLIST_ITEM * noOfItems;
601 __pSearchListView->SetMinimumSize(Dimension(searchListbounds.width - 100,searchListbounds.height));
602 __pSearchListView->SetBounds(searchListbounds);
603 Form* pForm = dynamic_cast<Form *>(GetParent());
604 if(pSearchListPanel->GetBounds().y + __pSearchListView->GetBounds().height > pForm->GetClientAreaBounds().height)
606 searchListbounds.height -= (pSearchListPanel->GetBounds().y + __pSearchListView->GetBounds().height) - pForm->GetClientAreaBounds().height;
607 __pSearchListView->SetMinimumSize(Dimension(searchListbounds.width - 100,searchListbounds.height));
608 __pSearchListView->SetBounds(searchListbounds);
610 __pSearchListView->InvalidateBounds(searchListbounds);
611 __pSearchListView->SetItemProvider(*__pSuggestionListProvider);
612 __pSearchListView->UpdateList();
613 __pSearchListView->ScrollToItem(0);
617 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
618 Button* pButtonPullUp = static_cast<Button*>(GetControl(IDC_BUTTON_PULL_UP, true));
619 //Show dropdown button
620 pButtonDropDown->SetShowState(false);
621 pButtonDropDown->Invalidate(false);
622 pButtonPullUp->SetShowState(true);
623 pButtonPullUp->Invalidate(true);
624 __isSearchListOpened = true;
630 DialTabDialer::HideSearchListView(void)
632 Panel* pSearchListPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_LIST, true));
633 pSearchListPanel->SetShowState(false);
634 pSearchListPanel->Invalidate(true);
636 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
637 Button* pButtonPullUp = static_cast<Button*>(GetControl(IDC_BUTTON_PULL_UP, true));
638 //Show dropdown button
639 pButtonPullUp->SetShowState(false);
640 pButtonPullUp->Invalidate(true);
641 pButtonDropDown->SetShowState(true);
642 pButtonDropDown->Invalidate(true);
643 __isSearchListOpened = false;
648 DialTabDialer::ShowSearchGadget(void)
650 //Commenting as search is not supported for 2.1
651 /*Button* pButtonSearchIcon = static_cast<Button*>(GetControl(IDC_BUTTON_SEARCHICON, true));
652 pButtonSearchIcon->SetShowState(true);
653 Button* pButtonSearchField = static_cast<Button*>(GetControl(IDC_BUTTON_SEARCHFIELD, true));
654 pButtonSearchField->SetShowState(true);
655 Button* pButtonClear = static_cast<Button*>(GetControl(IDC_BUTTON_KEYPADCLEAR, true));
656 pButtonClear->SetShowState(false);
663 DialTabDialer::HideSearchGadget(void)
665 //Commenting as search is not supported for 2.1
666 /*Button* pButtonSearchIcon = static_cast<Button*>(GetControl(IDC_BUTTON_SEARCHICON, true));
667 pButtonSearchIcon->SetShowState(false);
668 Button* pButtonSearchField = static_cast<Button*>(GetControl(IDC_BUTTON_SEARCHFIELD, true));
669 pButtonSearchField->SetShowState(false);
670 Button* pButtonClear = static_cast<Button*>(GetControl(IDC_BUTTON_KEYPADCLEAR, true));
671 pButtonClear->SetShowState(true);*/
677 DialTabDialer::ConstructSearchMenu(void)
679 AppLogDebug("ENTER");
681 //Construct button for menu open and close
682 Button* pButtonSearchField = static_cast<Button*>(GetControl(IDC_BUTTON_SEARCHFIELD, true));
683 pButtonSearchField->SetActionId(IDA_SEARCH_FIELD);
684 pButtonSearchField->AddActionEventListener(*this);
685 Button* pButtonSearchIcon = static_cast<Button*>(GetControl(IDC_BUTTON_SEARCHICON, true));
686 pButtonSearchIcon->SetActionId(IDA_SEARCH_ICON);
687 pButtonSearchIcon->AddActionEventListener(*this);
688 //Hiding as search is not supported for 2.1
689 pButtonSearchIcon->SetShowState(false);
690 pButtonSearchField->SetShowState(false);
697 DialTabDialer::ConstructKeypad(void)
699 AppLogDebug("ENTER");
700 //Construct Alpha numeric Keypad
701 if(__pDialKeypad == null)
703 __pDialKeypad = new (std::nothrow) DialerKeypad(__dialerState);
704 __pDialKeypad->ConstructPanel(this, this);
705 //add keypad to dial panel
706 AddControl(__pDialKeypad);
707 __pDialKeypad->AddListenersToLastRowButtons();
714 DialTabDialer::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
716 AppLogDebug("ENTER");
717 //When outgoing call is made and immediately before a call is made if
718 // we switch to logs then __isAppControlLaunched wont be set to false anywhere else
719 //as OnforeGround of logs will get called instead . Hence Keypad wont work.
720 SetAppControlLaunched(false);
721 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
722 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
723 pEditField->SetFocus();
724 String editText(L"");
726 //While coming from Logs scene, disable footer
727 Form* pForm = dynamic_cast<Form*>(GetParent());
730 AppLog("pForm == null");
733 pForm->GetFooter()->SetShowState(false);
734 pForm->AddOrientationEventListener(*this);
735 Label* pLastRowLabel = static_cast<Label*>(GetControl(IDC_LABEL_LASTROW_BG, true));
736 OrientationStatus orientationStatus = pForm->GetOrientationStatus();
737 if (orientationStatus == ORIENTATION_STATUS_PORTRAIT || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
739 pLastRowLabel->SetShowState(false);
741 else if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
743 pLastRowLabel->SetShowState(true);
746 //If opened as AppControl then it is either from Single Active Call
747 //or Conf. Call screen with 'Add Call' scenario.
748 __dialerState = DIALER_STATE_FIRST_SCENE;
749 if (pPhoneApp->IsOpenAsAppControl() == true)
751 __dialerState = DIALER_STATE_ADD_CALL_APPCONTROL;
754 String* pPhoneNumber = static_cast<String*>(pArgs->GetAt(0));
755 if(pPhoneNumber != null && pPhoneNumber->IsEmpty() == false)
757 //From AppControl request for normal call
758 editText.Append(*pPhoneNumber);
759 __dialerState = DIALER_STATE_NORMAL_APPCONTROL;
767 if(pEditField != null)
769 editText = pEditField->GetText();
772 //If this is not an AppControlRequest and editText is empty, then fetch auto area code.
773 if(editText.IsEmpty() == true)
775 //Fetch auto area code setting, if present
776 SettingsPresentationModel::GetInstance()->GetActivePrefixDialNumber(editText);
777 if(editText.IsEmpty() == false)
779 editText.Replace(L"P",L";");
780 editText.Replace(L"p",L";");
784 if(pEditField != null)
786 ShowFormattedText(pEditField,editText);
787 pEditField->SetFocus();
788 pEditField->Invalidate(true);
789 __pDialPresentationModel->ClearSearchResults();
790 //show search results
791 if (pEditField->GetTextLength() == 0)
799 UpdateSearchResults();
803 if (__pDialKeypad != null)
805 __pDialKeypad->SetBitmapToKeypadButtons();
806 __pDialKeypad->Invalidate(true);
808 pPhoneApp->AddAppStateChangeListener(*this);
809 //Add address book listener to listen to contacts changed events
810 if(__pAddressBook != null)
812 __pAddressBook->SetAddressbookChangeEventListener(this);
814 //Set the last row position and height programatically
815 Panel* plastRowPanel = static_cast<Panel*>(GetParent()->GetControl(IDC_PANEL_LASTROW,true));
816 int yPos = pForm->GetClientAreaBounds().height - plastRowPanel->GetBounds().height;
817 plastRowPanel->SetPosition(0,yPos);
819 if(pEditField != null)
821 pEditField->AddTextEventListener(*this);
828 DialTabDialer::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
830 AppLogDebug("ENTER");
831 //While coming from Logs scene, disable footer
832 Form* pForm = static_cast<Form*>(GetParent());
833 pForm->RemoveOrientationEventListener(*this);
834 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
835 //hide search result list, if shown.
836 if (__isSearchListOpened == true)
838 HideSearchListView();
841 if(__pConfirmationPopup != null)
843 __pConfirmationPopup->SetShowState(false);
845 pPhoneApp->RemoveAppStateChangeListener(*this);
846 //remove contact change event listener
847 if(__pAddressBook != null)
849 __pAddressBook->SetAddressbookChangeEventListener(null);
851 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
852 int startpos=-1,endpos=-1;
853 pEditField->GetBlockRange(startpos,endpos);
854 AppLogDebug("GetBlockRange %d %d",startpos,endpos);
857 pEditField->Remove();
858 pEditField->ReleaseBlock();
860 pEditField->RemoveTextEventListener(*this);
866 DialTabDialer::OnActionPerformed(const Control& source, int actionId)
868 AppLogDebug("ENTER");
870 PhoneApp* pApp = static_cast<PhoneApp*>(UiApp::GetInstance());
871 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
872 if (pEditField == null || GetAppControlLaunched() == true)
874 AppLogDebug("GetAppControlLaunched() == true");
880 case IDA_SEARCH_FIELD:
881 case IDA_SEARCH_ICON:
883 //Put Search click launch code here
884 AppLog("Search ICON/Field Clicked");
885 AppManager* pAppManager = AppManager::GetInstance();
886 pAppManager->LaunchApplication(PROVIDER_ID_CONTACTS);
890 case IDA_BTN_SHOW_CONTEXTMENU:
892 // Show the ContextMenu
893 String contactNo = pEditField->GetText();
894 contactNo.Replace(L"-",L"");
896 if (__isSearchListOpened == true)
898 HideSearchListView();
916 //append / clear last character to contact
917 int oldtextlen = pEditField->GetTextLength();
918 ShowFormattedText(pEditField, actionId);
919 if (pEditField->GetTextLength() == 0)
921 __pDialPresentationModel->ClearSearchResults();
927 if(oldtextlen != pEditField->GetTextLength())
930 UpdateSearchResults();
938 //If context menu is shown do not trigger call
939 //As platform sends release event when context menu is shown
940 if(__pCallContextMenu != null && __pCallContextMenu->GetShowState() == true)
944 if (pEditField->GetTextLength() > 0)
946 String contactNo = pEditField->GetText();
947 contactNo.Replace(L"-",L"");
948 String phoneNumberPattern(L"#$");
949 RegularExpression checkPhoneNumber;
950 checkPhoneNumber.Construct(phoneNumberPattern);
951 //If phone number ends with # then show an error popup
952 /* bool resultMatch = checkPhoneNumber.Match(contactNo,false);
953 if(resultMatch == true)
955 MessageBox numberEndsWithHash;
956 String msg(L"Phone number ");
957 msg.Append(contactNo);
958 msg.Append(L" ends with # ");
959 numberEndsWithHash.Construct(L"GPRS is not supported", msg, MSGBOX_STYLE_NONE,3000);
961 numberEndsWithHash.ShowAndWait(modalResult);
964 if (DialOutgoingCall(contactNo) == true)
966 __pDialPresentationModel->ClearSearchResults();
975 //show latest dialed or incoming number from Logs
976 String* number = __pDialPresentationModel->FetchLatestNumberFromLogsN();
979 ShowFormattedText(pEditField,*number);
980 UpdateSearchResults();
990 ShowFormattedText(pEditField,STAR_KEY);
991 if (pEditField->GetTextLength() == 0)
999 UpdateSearchResults();
1006 pEditField->AppendText(L"#");
1007 if (pEditField->GetTextLength() == 0)
1015 UpdateSearchResults();
1020 /* case VIDEOCALL_KEY:
1028 if(pApp->IsOpenAsAppControl() == true)
1036 case IDA_BTN_ADD_TO_CONTACTS:
1038 if(pEditField->GetTextLength() > 0)
1040 String contactNo = pEditField->GetText();
1041 contactNo.Replace(L"-",L"");
1042 result r = __pDialPresentationModel->LaunchAddContactsAppControl(contactNo);
1045 SetAppControlLaunched(true);
1052 case IDA_SPEEDDIAL_POPUP_YES:
1054 if(__pConfirmationPopup != null)
1056 __pConfirmationPopup->SetShowState(false);
1058 SwitchToSpeedDialForm();
1062 case IDA_SPEEDDIAL_POPUP_NO:
1064 if(__pConfirmationPopup != null)
1066 __pConfirmationPopup->SetShowState(false);
1071 case IDA_MENU_ADD_PAUSE:
1077 case IDA_MENU_ADD_WAIT:
1091 case IDA_MENU_SEND_MESSAGE:
1093 String contactNo = pEditField->GetText();
1094 contactNo.Replace(L"-",L"");
1095 result r = __pDialPresentationModel->OpenMessagingAppControl(contactNo);
1098 SetAppControlLaunched(true);
1104 case IDA_MENU_SPEED_DIAL:
1106 SwitchToSpeedDialForm();
1111 case IDA_BTN_USE_CONTACT_DATA:
1113 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(0);
1114 if(pDialInfo != null)
1116 //fetch contact number
1117 String phNumber = pDialInfo->GetPhoneNumber();
1118 if(phNumber.Equals(pEditField->GetText()) == false)
1120 pEditField->Clear();
1121 ShowFormattedText(pEditField,phNumber);
1122 pEditField->Invalidate(true);
1123 if (__isSearchListOpened == true)
1125 HideSearchListView();
1127 UpdateSearchResults();
1133 case IDA_BTN_DISPLAY_CONTACTS:
1135 if (__isSearchListOpened == true)
1137 Form* pForm = dynamic_cast<Form *>(GetParent());
1138 int noOfItems = MAX_SEARCH_LIST_ITEMS;
1139 if(__pDialPresentationModel->GetNumberOfSuggestions() < (noOfItems+1))
1141 noOfItems = __pDialPresentationModel->GetNumberOfSuggestions() - 1;
1143 if(pForm != null && (pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE))
1147 SetOrigPosUseContact();
1150 HideSearchListView();
1154 ShowSearchListView();
1162 pEditField->Invalidate(true);
1164 AppLogDebug("EXIT");
1169 DialTabDialer::OnLongPressGestureDetected(TouchLongPressGestureDetector& gestureDetector)
1171 AppLogDebug("ENTER");
1172 if (GetAppControlLaunched() == true)
1174 //If call AppControl is already launched, ignore any further requests.
1178 if (gestureDetector.GetControl() != null)
1180 Button* pButton = static_cast<Button*>(gestureDetector.GetControl());
1181 int actionId = pButton->GetActionId();
1194 //first check if there is any number present in the edit fiels
1195 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1196 if(pEditField->GetTextLength() != 0)
1198 //append / clear last character to contact
1199 int oldtextlen = pEditField->GetTextLength();
1200 ShowFormattedText(pEditField, actionId);
1201 if (pEditField->GetTextLength() == 0)
1203 __pDialPresentationModel->ClearSearchResults();
1209 if(oldtextlen != pEditField->GetTextLength())
1212 UpdateSearchResults();
1215 pEditField->Invalidate(true);
1218 //Check if Speed Dial setting exist for pressed key
1219 String* contactNumber = __pDialPresentationModel->FetchSpeedDialNumberN(actionId);
1220 if(contactNumber != null)
1222 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1224 //pass ownership to arraylist
1225 pArgs->Add(contactNumber);
1226 SendUserEvent(REQUEST_CALL_SPEED_DIAL_NUM,pArgs);
1230 //show speed Dial Confirmation Popup msg
1231 if(actionId == NUM_KEY1)
1233 SendUserEvent(REQUEST_SHOW_VOICE_MAIL_POPUP,null);
1237 SendUserEvent(REQUEST_SHOW_SPEED_DIAL_POPUP,null);
1252 //Handle Mute / UnMute
1253 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1254 if(pEditField->GetTextLength() == 0)
1256 bool enabled = false;
1257 String title = L"http://tizen.org/setting/sound.silent_mode";
1258 SettingInfo::GetValue(title, enabled);
1259 //enable or disable the phone silent mode.
1260 result r = E_FAILURE;
1261 r = SettingInfo::SetValue(title, !enabled);
1264 ShowSilentModeToggle(!enabled);
1272 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1273 if (pEditField != null && pEditField->GetTextLength() > 0)
1275 pEditField->Clear();
1276 pEditField->SetTextSize(IDI_MAX_TXT_FONT);
1277 //pEditField->SetCursorPosition(0);
1278 pEditField->SetFocus();
1279 pEditField->Invalidate(true);
1288 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1289 if(pEditField != null && pEditField->GetTextLength() > 0)
1291 String contactNo = pEditField->GetText();
1292 contactNo.Replace(L"-",L"");
1293 ShowCallContextMenu(contactNo);
1309 AppLogDebug("EXIT");
1314 DialTabDialer::ShowCallContextMenu(Tizen::Base::String& contactNumber)
1317 AppLogDebug("ENTER");
1319 Form *pForm = dynamic_cast<Form*>(GetParent());
1320 Button* pCallButton = static_cast<Button*>(pForm->GetControl(IDC_BUTTON_CALL,true));
1321 Panel* pLastRowPanel = static_cast<Panel*>(pForm->GetControl(IDC_PANEL_LASTROW,true));
1322 int portraitAnchorPositionY = pForm->GetHeight() - pLastRowPanel->GetHeight() +
1323 ((pLastRowPanel->GetHeight()- pCallButton->GetHeight())/2);
1324 int portraitAnchorPositionX = pLastRowPanel->GetWidth()/2;
1325 int landscapeAnchorPositionX = pForm->GetWidth()/2 + pLastRowPanel->GetWidth()/2 - pCallButton->GetWidth()/2;
1326 if(__pCallContextMenu != null)
1328 delete __pCallContextMenu;
1329 __pCallContextMenu = null;
1331 __pCallContextMenu = new (std::nothrow) ContextMenu();
1332 __pCallContextMenu->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
1333 //minimum available option count
1334 int visibleItems = MIN_CONTEXT_MENU_ITEMS + 1;
1335 __pCallContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_PAUSE), IDA_MENU_ADD_PAUSE);
1336 __pCallContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_WAIT), IDA_MENU_ADD_WAIT);
1337 __pCallContextMenu->AddActionEventListener(*this);
1338 __pCallContextMenu->SetFocusable(true);
1339 __pCallContextMenu->SetMaxVisibleItemsCount(visibleItems);
1340 // Set the anchor position of the ContextMenu
1341 if(pForm != null && (pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE))
1343 __pCallContextMenu->SetAnchorPosition(Point(landscapeAnchorPositionX, portraitAnchorPositionY));
1347 __pCallContextMenu->SetAnchorPosition(Point(portraitAnchorPositionX, portraitAnchorPositionY));
1349 // Show the ContextMenu
1350 __pCallContextMenu->Show();
1352 AppLogDebug("EXIT");
1359 DialTabDialer::AddPause(void)
1361 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1362 if (pEditField != null && pEditField->GetTextLength() > 0)
1364 ShowFormattedText(pEditField,PAUSE_KEY);
1366 UpdateSearchResults();
1367 pEditField->Invalidate(true);
1374 DialTabDialer::AddWait(void)
1376 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1377 if (pEditField != null)
1379 ShowFormattedText(pEditField,WAIT_KEY);
1380 if (pEditField->GetTextLength() == 0)
1388 UpdateSearchResults();
1390 pEditField->Invalidate(true);
1397 DialTabDialer::AddPlus(void)
1399 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1400 if (pEditField != null)
1402 ShowFormattedText(pEditField,PLUS_KEY);
1403 if (pEditField->GetTextLength() == 0)
1411 UpdateSearchResults();
1413 pEditField->Invalidate(true);
1419 DialTabDialer::DialOutgoingCall(const String& contactNumber)
1421 AppLogDebug("Enter");
1422 bool isSuccess = false;
1423 if (__isAppControlLaunched == true)
1425 //If call AppControl is already launched, ignore any further requests.
1429 if(__dialerState == DIALER_STATE_FIRST_SCENE || __dialerState == DIALER_STATE_NORMAL_APPCONTROL)
1431 ErrorCodes error = __pDialPresentationModel->DialCall(contactNumber);
1432 if (error == ERROR_NONE)
1434 __isAppControlLaunched = true;
1439 __isAppControlLaunched = false;
1441 //Show error message Popup
1442 if (__pErrorMsgPopup == null)
1444 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
1445 __pErrorMsgPopup->ShowErrorMsgPopupN(error);
1451 //Dialer was launched as AppControl in "AddCall" Scenario.
1452 if (__dialerState == DIALER_STATE_ADD_CALL_APPCONTROL)
1456 resultData.Construct();
1457 resultData.Add(new (std::nothrow) String(PARAM_PHONE_NUMBER), new (std::nothrow) String(contactNumber));
1458 //send "APP_CTRL_RESULT_SUCCEEDED" and 'contactNumber' as result.
1459 PhoneApp* pApp = static_cast<PhoneApp*>(UiApp::GetInstance());
1460 pApp->SendAppControlResponseMessage(APP_CTRL_RESULT_SUCCEEDED, &resultData);
1461 resultData.RemoveAll(true);
1469 DialTabDialer::SwitchToSpeedDialForm(void)
1471 SceneManager* pSceneManager = SceneManager::GetInstance();
1472 AppAssert(pSceneManager);
1473 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_SPEED_DIAL), null);
1478 DialTabDialer::ShowSpeedDialConfirmationPopup(bool isVoiceMail)
1480 String popupTitleMsg;
1483 if(__pConfirmationPopup == null)
1485 FloatRectangle rect = GetBoundsF();
1486 __pConfirmationPopup = new (std::nothrow) Popup();
1487 __pConfirmationPopup->Construct(true, FloatDimension(W_SPEEDDIAL_POPUP, H_SPEEDDIAL_POPUP));
1489 rect = __pConfirmationPopup->GetBoundsF();
1490 pMsgLabel = new (std::nothrow) Label();
1491 if(isVoiceMail == true)
1493 popupTitleMsg = AppUtility::GetResourceString(IDS_DIALER_VOICE_POPUP_TITLE_MSG);
1494 popupMsg = AppUtility::GetResourceString(IDS_DIALER_VOICE_POPUP_MSG);
1498 popupTitleMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_TITLE_MSG);
1499 popupMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_MSG);
1501 __pConfirmationPopup->SetTitleText(popupTitleMsg);
1502 __pConfirmationPopup->SetPropagatedKeyEventListener(this);
1503 __pConfirmationPopup->Invalidate(true);
1504 pMsgLabel->Construct(Rectangle(0, IDI_PADDING, rect.width, H_POPUP_MSG_LABEL), popupMsg);
1505 pMsgLabel->SetName(IDC_SPEED_DIAL_TXT_LABEL);
1506 pMsgLabel->SetTextConfig(44,LABEL_TEXT_STYLE_NORMAL);
1507 pMsgLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1508 pMsgLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1509 __pConfirmationPopup->AddControl(*pMsgLabel);
1511 rect = pMsgLabel->GetBoundsF();
1512 Button *pButtonYes = new (std::nothrow) Button();
1513 String btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_YES_BTN_STRING);
1514 pButtonYes->Construct(Rectangle(rect.x+ IDI_PADDING, (rect.y + rect.height + IDI_PADDING), ((rect.width - (3 * IDI_PADDING)) / 2), H_POPUP_BTN), btnName);
1515 pButtonYes->SetActionId(IDA_SPEEDDIAL_POPUP_YES);
1516 pButtonYes->AddActionEventListener(*this);
1517 __pConfirmationPopup->AddControl(*pButtonYes);
1519 rect = pButtonYes->GetBoundsF();
1520 Button *pButtonNo = new (std::nothrow) Button();
1521 btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_NO_BTN_STRING);
1522 pButtonNo->Construct(Rectangle((rect.x + rect.width + IDI_PADDING), rect.y, rect.width, rect.height), btnName);
1523 pButtonNo->SetActionId(IDA_SPEEDDIAL_POPUP_NO);
1524 pButtonNo->AddActionEventListener(*this);
1525 __pConfirmationPopup->AddControl(pButtonNo);
1529 if(isVoiceMail == true)
1531 popupTitleMsg = AppUtility::GetResourceString(IDS_DIALER_VOICE_POPUP_TITLE_MSG);
1532 popupMsg = AppUtility::GetResourceString(IDS_DIALER_VOICE_POPUP_MSG);
1536 popupTitleMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_TITLE_MSG);
1537 popupMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_MSG);
1539 __pConfirmationPopup->SetTitleText(popupTitleMsg);
1540 pMsgLabel = static_cast<Label*>(__pConfirmationPopup->GetControl(IDC_SPEED_DIAL_TXT_LABEL, true));
1541 pMsgLabel->SetText(popupMsg);
1544 //Show Popup message
1545 __pConfirmationPopup->SetShowState(true);
1546 __pConfirmationPopup->Show();
1550 DialTabDialer::ShowAddToContactsButton(void)
1552 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1553 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
1554 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
1555 Button* pButtonPullUp = static_cast<Button*>(GetControl(IDC_BUTTON_PULL_UP, true));
1556 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
1557 pButtonContacts->SetShowState(false);
1558 pButtonDropDown->SetShowState(false);
1559 pButtonPullUp->SetShowState(false);
1560 pButtonAddContacts->SetShowState(true);
1561 pSearchPanel->SetShowState(true);
1562 pSearchPanel->Invalidate(true);
1567 DialTabDialer::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1571 case REQUEST_SHOW_SUGGESTION:
1573 String* pDisplayname = static_cast<String*> (pArgs->GetAt(0));
1574 String* pMobileNo = static_cast<String*> (pArgs->GetAt(1));
1575 String* pMatchedSearchStr = static_cast<String*> (pArgs->GetAt(2));
1576 String* pResultCount = static_cast<String*> (pArgs->GetAt(3));
1577 if(pDisplayname != null && pMobileNo != null && pMatchedSearchStr != null && pResultCount != null)
1579 if (__isSearchListOpened == true)
1581 HideSearchListView();
1583 ShowSuggestionBox(*pDisplayname, *pMobileNo, *pMatchedSearchStr, *pResultCount);
1589 case REQUEST_SHOW_ADD_TO_CONTACTS:
1591 if (__isSearchListOpened == true)
1593 HideSearchListView();
1595 ShowAddToContactsButton();
1599 case REQUEST_CALL_SPEED_DIAL_NUM:
1603 String *number = static_cast<String*> (pArgs->GetAt(0));
1607 DialOutgoingCall(*number);
1614 case REQUEST_SHOW_VOICE_MAIL_POPUP:
1616 ShowSpeedDialConfirmationPopup(true);
1619 case REQUEST_SHOW_SPEED_DIAL_POPUP:
1621 //show speed Dial Confirmation Popup msg
1622 ShowSpeedDialConfirmationPopup();
1629 DialTabDialer::SetShiftedPosUseContact(void)
1631 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1632 Panel* pPanelUseContact = static_cast<Panel*>(pSearchPanel->GetControl(IDC_PANEL_USE_CONTACT, true));
1633 Panel* pPanelDropDown = static_cast<Panel*>(pSearchPanel->GetControl(IDC_PANEL_DROPDOWN, true));
1635 Point pointUseContact = pPanelUseContact->GetPosition();
1636 pointUseContact.y = 0;
1637 Point pointDropDown = pPanelDropDown->GetPosition();
1638 pointDropDown.y = 10;
1640 pPanelUseContact->SetPosition(pointUseContact.x,pointUseContact.y);
1641 pPanelDropDown->SetPosition(pointDropDown.x,pointDropDown.y);
1643 pPanelUseContact->SetShowState(true);
1644 pPanelDropDown->SetShowState(true);
1646 SetControlAlwaysOnTop(*pPanelUseContact,true);
1647 SetControlAlwaysOnTop(*pPanelDropDown,true);
1648 pSearchPanel->Invalidate(true);
1651 DialTabDialer::SetOrigPosUseContact(void)
1653 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1654 Panel* pPanelUseContact = static_cast<Panel*>(pSearchPanel->GetControl(IDC_PANEL_USE_CONTACT, true));
1655 Panel* pPanelDropDown = static_cast<Panel*>(pSearchPanel->GetControl(IDC_PANEL_DROPDOWN, true));
1657 Point pointUseContact = pPanelUseContact->GetPosition();
1658 pointUseContact.y = 119;
1659 Point pointDropDown = pPanelDropDown->GetPosition();
1660 pointDropDown.y = 147;
1662 pPanelUseContact->SetPosition(pointUseContact.x,pointUseContact.y);
1663 pPanelDropDown->SetPosition(pointDropDown.x,pointDropDown.y);
1665 SetControlAlwaysOnTop(*pPanelUseContact,true);
1666 SetControlAlwaysOnTop(*pPanelDropDown,true);
1667 pSearchPanel->Invalidate(true);
1671 DialTabDialer::ShowSuggestionBox(String& name, String& mobileNo, String& matchedKey, String& resultCount)
1673 AppLogDebug("ENTER");
1675 //"UseContact" Button
1676 Button* pButtonUseContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
1677 Canvas pCanvasNormalContacts;
1678 pCanvasNormalContacts.Construct(pButtonUseContacts->GetBounds());
1679 Canvas pCanvasPressedContacts;
1680 pCanvasPressedContacts.Construct(pButtonUseContacts->GetBounds());
1681 String mobileStr = AppUtility::GetResourceString(IDS_DIALER_MOBILE_STR);
1682 pCanvasNormalContacts.SetBackgroundColor(COLOR_SEARCHLIST_BG);
1683 pCanvasNormalContacts.Clear();
1684 //Add text, Bg to normal state
1685 DialUtil::DrawTextAndHighlightedKeywordToCanvas(name, matchedKey, FONT_SUGGESTION_NAME, pCanvasNormalContacts, POSITION_SUGGESTION_NAME);
1686 DialUtil::DrawTextAndHighlightedKeywordToCanvas(mobileNo, matchedKey, FONT_SUGGESTION_MOBILE, pCanvasNormalContacts, POSITION_SUGGESTION_NUMBER);
1687 //Add text, Bg to pressed state
1688 pCanvasPressedContacts.SetBackgroundColor(COLOR_SEARCHLIST_PRESS_BG);
1689 pCanvasPressedContacts.Clear();
1690 DialUtil::DrawTextAndHighlightedKeywordToCanvas(name, matchedKey, FONT_SUGGESTION_NAME, pCanvasPressedContacts, POSITION_SUGGESTION_NAME);
1691 DialUtil::DrawTextAndHighlightedKeywordToCanvas(mobileNo, matchedKey, FONT_SUGGESTION_MOBILE, pCanvasPressedContacts, POSITION_SUGGESTION_NUMBER);
1692 //add normal, pressed bg bitmap to button
1693 DialUtil::DrawCanvasToButton(&pCanvasNormalContacts, &pCanvasPressedContacts, pButtonUseContacts);
1696 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
1697 Canvas pCanvasNormalDropDown;
1698 pCanvasNormalDropDown.Construct(pButtonDropDown->GetBounds());
1699 Canvas pCanvasPressedDropDown;
1700 pCanvasPressedDropDown.Construct(pButtonDropDown->GetBounds());
1701 //Add text, Bg to normal state
1702 DialUtil::Draw9PatchToCanvas(pCanvasNormalDropDown, IDB_BTN_OPTION_BG_ICON);
1703 DialUtil::DrawTextToCanvas(resultCount, FONT_EXPAND_BUTTON_TEXT, pCanvasNormalDropDown, POSITION_CENTER, BUTTON_STATUS_NORMAL);
1704 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasNormalDropDown, POSITION_BOTTOM_CENTER);
1705 //Add text, Bg to pressed state
1706 DialUtil::Draw9PatchToCanvas(pCanvasPressedDropDown, IDB_BTN_OPTION_PRESS_BG_ICON);
1707 DialUtil::DrawTextToCanvas(resultCount, FONT_EXPAND_BUTTON_TEXT, pCanvasPressedDropDown, POSITION_CENTER, BUTTON_STATUS_NORMAL);
1708 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_PRESS_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasPressedDropDown, POSITION_BOTTOM_CENTER);
1709 //add background to button
1710 DialUtil::DrawCanvasToButton(&pCanvasNormalDropDown, &pCanvasPressedDropDown, pButtonDropDown);
1713 Button* pButtonPullUp = static_cast<Button*>(GetControl(IDC_BUTTON_PULL_UP, true));
1714 Canvas pCanvasNormalPullUp;
1715 pCanvasNormalPullUp.Construct(pButtonPullUp->GetBounds());
1716 Canvas pCanvasPressedPullUp;
1717 pCanvasPressedPullUp.Construct(pButtonPullUp->GetBounds());
1718 //Add text, Bg to normal state
1719 DialUtil::Draw9PatchToCanvas(pCanvasNormalPullUp, IDB_BTN_OPTION_BG_ICON);
1720 DialUtil::DrawTextToCanvas(resultCount, FONT_EXPAND_BUTTON_TEXT, pCanvasNormalPullUp, POSITION_CENTER, BUTTON_STATUS_NORMAL);
1721 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_UP_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasNormalPullUp, POSITION_BOTTOM_CENTER);
1722 //Add text, Bg to pressed state
1723 DialUtil::Draw9PatchToCanvas(pCanvasPressedPullUp, IDB_BTN_OPTION_PRESS_BG_ICON);
1724 DialUtil::DrawTextToCanvas(resultCount, FONT_EXPAND_BUTTON_TEXT, pCanvasPressedPullUp, POSITION_CENTER, BUTTON_STATUS_NORMAL);
1725 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_UP_PRESS_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasPressedPullUp, POSITION_BOTTOM_CENTER);
1726 //add background to button
1727 DialUtil::DrawCanvasToButton(&pCanvasNormalPullUp, &pCanvasPressedPullUp, pButtonPullUp);
1729 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
1730 pButtonAddContacts->SetShowState(false);
1732 Form* pForm = dynamic_cast<Form *>(GetParent());
1733 int noOfItems = MAX_SEARCH_LIST_ITEMS;
1734 if(__pDialPresentationModel->GetNumberOfSuggestions() < (noOfItems+1))
1736 noOfItems = __pDialPresentationModel->GetNumberOfSuggestions() - 1;
1738 if(pForm != null && (pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE))
1740 SetOrigPosUseContact();
1742 pButtonUseContacts->SetShowState(true);
1744 Panel* pSearchListPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_LIST, true));
1745 //Show pull up or drop down based on list view state
1746 if(pSearchListPanel->GetShowState() == false)
1748 pButtonPullUp->SetShowState(false);
1749 pButtonPullUp->Invalidate(false);
1751 pButtonDropDown->SetShowState(true);
1752 pButtonDropDown->Invalidate(true);
1756 pButtonDropDown->SetShowState(false);
1757 pButtonDropDown->Invalidate(false);
1759 pButtonPullUp->SetShowState(true);
1760 pButtonPullUp->Invalidate(true);
1763 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1764 pSearchPanel->SetShowState(true);
1765 pSearchPanel->Invalidate(true);
1767 AppLogDebug("EXIT");
1772 DialTabDialer::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
1774 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(index+1);
1775 if(pDialInfo != null)
1777 String phNumber = pDialInfo->GetPhoneNumber();
1778 EditField* pTextBox = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1779 if(pTextBox != null)
1782 ShowFormattedText(pTextBox,phNumber);
1783 pTextBox->Invalidate(true);
1785 HideSearchListView();
1786 UpdateSearchResults();
1792 DialTabDialer::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1794 AppLogDebug("Enter");
1795 Form* pForm = static_cast<Form*>(GetParent());
1797 Label* pEditFieldBgLbl = static_cast<Label*>(GetControl(L"IDC_LABEL_BACKGROUND", true));
1798 Dimension editFieldBgLblDimen = pEditFieldBgLbl->GetSize();
1799 if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1801 editFieldBgLblDimen.height = 461;
1803 else if(orientationStatus == ORIENTATION_STATUS_PORTRAIT || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1805 editFieldBgLblDimen.height = 315;
1807 pEditFieldBgLbl->SetSize(editFieldBgLblDimen);
1809 //Show last row label bg in landscape only.
1810 Panel* pLastRowPanel = static_cast<Panel*>(GetControl(IDC_PANEL_LASTROW, true));
1811 Rectangle lastRowRect = pLastRowPanel->GetBounds();
1812 lastRowRect.y = pForm->GetClientAreaBounds().height - lastRowRect.height;
1813 pLastRowPanel->SetBounds(lastRowRect);
1814 Label* pLastRowLabel = static_cast<Label*>(pLastRowPanel->GetControl(IDC_LABEL_LASTROW_BG, true));
1815 if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1817 pLastRowLabel->SetShowState(true);
1819 else if(orientationStatus == ORIENTATION_STATUS_PORTRAIT || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1821 pLastRowLabel->SetShowState(false);
1824 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1825 if (pEditField->GetTextLength() > 0)
1827 if (__pDialPresentationModel->GetNumberOfSuggestions() == 0)
1829 ShowAddToContactsButton();
1833 //contact suggestion is present, change it bitmap based on new orientation
1834 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(0);
1835 if (pDialInfo != null)
1837 String name = pDialInfo->GetDisplayName();
1838 String mobileNo = pDialInfo->GetPhoneNumber();
1839 String* pMatchedSearchStr = pDialInfo->GetSearchKey();
1841 resultCount.Append(__pDialPresentationModel->GetNumberOfSuggestions());
1842 ShowSuggestionBox(name, mobileNo, *pMatchedSearchStr, resultCount);
1844 //Check if search list view is open
1845 if(__isSearchListOpened == true)
1847 HideSearchListView();
1848 ShowSearchListView();
1853 //reset the bitmaps to button based on new orientation.
1854 if (__pDialKeypad != null)
1856 __pDialKeypad->SetBitmapToKeypadButtons();
1857 __pDialKeypad->Invalidate(true);
1865 DialTabDialer::HandlePopupClosed(void)
1868 if(__pErrorMsgPopup != null)
1870 __pErrorMsgPopup->SetShowState(false);
1876 DialTabDialer::OnForeground(void)
1878 AppLogDebug("Enter");
1879 __isAppForeground = true;
1880 //If app control was launched
1881 //as we do not know if it success or failed
1882 // we need to UpdateSearchResults
1883 //Returned from app control if app control does not
1884 //send any response we need to do this
1885 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1886 String editText(L"");
1887 if(pEditField != null)
1889 editText = pEditField->GetText();
1892 if(editText.IsEmpty() == true)
1894 //Fetch auto area code setting, if present
1895 SettingsPresentationModel::GetInstance()->GetActivePrefixDialNumber(editText);
1896 if(editText.IsEmpty() == false)
1898 editText.Replace(L"P",L";");
1899 editText.Replace(L"p",L";");
1903 if(pEditField != null)
1905 ShowFormattedText(pEditField,editText);
1906 //pEditField->SetCursorPosition(editText.GetLength());
1907 pEditField->Invalidate(true);
1908 //show search results
1909 if (pEditField->GetTextLength() == 0)
1917 UpdateSearchResults();
1920 SetAppControlLaunched(false);
1924 DialTabDialer::OnBackground(void)
1926 AppLogDebug("Enter");
1927 __isAppForeground = false;
1931 DialTabDialer::IsForeground()
1933 AppLogDebug("Enter %d",__isAppForeground);
1934 return __isAppForeground;
1938 DialTabDialer::OnContactsChanged(const IList& contactChangeInfoList)
1940 if(contactChangeInfoList.GetCount() > 0)
1942 //clear old search results
1943 __pDialPresentationModel->ClearSearchResults();
1944 UpdateSearchResults();
1949 DialTabDialer::SetAppControlLaunched(bool launched)
1951 AppLogDebug("%d",__isAppControlLaunched);
1952 __isAppControlLaunched = launched;
1956 DialTabDialer::GetAppControlLaunched(void)
1958 AppLogDebug("%d",__isAppControlLaunched);
1959 return __isAppControlLaunched;
1963 DialTabDialer::OnTextValueChanged(const Tizen::Ui::Control& source)
1965 AppLogDebug("OnTextValueChanged");
1966 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1967 if (pEditField->GetTextLength() == 0)
1974 String number = pEditField->GetText();
1975 pEditField->Clear();
1976 ShowFormattedText(pEditField,number);
1978 UpdateSearchResults();
1983 DialTabDialer::ShowOptionsMenu()
1985 if(__pOptionMenu != null)
1987 delete __pOptionMenu;
1988 __pOptionMenu = null;
1990 __pOptionMenu = new (std::nothrow) OptionMenu();
1991 __pOptionMenu->Construct();
1992 __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SEND_MSG), IDA_MENU_SEND_MESSAGE);
1993 __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SPEED_DIAL), IDA_MENU_SPEED_DIAL);
1994 __pOptionMenu->AddActionEventListener(*this);
1995 __pOptionMenu->SetShowState(true);
1996 __pOptionMenu->Show();
2000 DialTabDialer::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
2002 AppLogDebug("Enter");
2003 if(keyEventInfo.GetKeyCode() == KEY_BACK)
2005 if(__pConfirmationPopup != null && __pConfirmationPopup->GetShowState() == true)
2007 __pConfirmationPopup->SetShowState(false);
2014 DialTabDialer::ShowSilentModeToggle(bool bEnabled)
2016 // Creates an instance of MessageBox
2017 String message = (bEnabled ? AppUtility::GetResourceString(IDS_SILENT_MODE_ENABLED):AppUtility::GetResourceString(IDS_SILENT_MODE_DISABLED));
2018 MessageBox silentMsgBox;
2020 silentMsgBox.Construct(L"", message, MSGBOX_STYLE_NONE, 2000);
2021 // Calls ShowAndWait() : Draws and Shows itself and processes events
2024 silentMsgBox.ShowAndWait(modalResult);