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 // Regular expression to check the beginning is with Pause/Wait
949 String phoneNumberPattern(L"^(,|;)");
950 RegularExpression checkPhoneNumber;
951 checkPhoneNumber.Construct(phoneNumberPattern);
952 //If phone number starts with , or ; then show an error popup
953 bool resultMatch = checkPhoneNumber.Match(contactNo,false);
954 if(resultMatch == true)
956 MessageBox numberStartsWithPW;
957 String msg(L"Phone number ");
958 msg.Append(contactNo);
959 msg.Append(L" is Invalid");
960 numberStartsWithPW.Construct(L"Invalid Number", msg, MSGBOX_STYLE_NONE,3000);
962 numberStartsWithPW.ShowAndWait(modalResult);
965 if (DialOutgoingCall(contactNo) == true)
967 __pDialPresentationModel->ClearSearchResults();
976 //show latest dialed or incoming number from Logs
977 String* number = __pDialPresentationModel->FetchLatestNumberFromLogsN();
980 ShowFormattedText(pEditField,*number);
981 UpdateSearchResults();
991 ShowFormattedText(pEditField,STAR_KEY);
992 if (pEditField->GetTextLength() == 0)
1000 UpdateSearchResults();
1007 pEditField->AppendText(L"#");
1008 if (pEditField->GetTextLength() == 0)
1016 UpdateSearchResults();
1021 /* case VIDEOCALL_KEY:
1029 if(pApp->IsOpenAsAppControl() == true)
1037 case IDA_BTN_ADD_TO_CONTACTS:
1039 if(pEditField->GetTextLength() > 0)
1041 String contactNo = pEditField->GetText();
1042 contactNo.Replace(L"-",L"");
1043 result r = __pDialPresentationModel->LaunchAddContactsAppControl(contactNo);
1046 SetAppControlLaunched(true);
1053 case IDA_SPEEDDIAL_POPUP_YES:
1055 if(__pConfirmationPopup != null)
1057 __pConfirmationPopup->SetShowState(false);
1059 SwitchToSpeedDialForm();
1063 case IDA_SPEEDDIAL_POPUP_NO:
1065 if(__pConfirmationPopup != null)
1067 __pConfirmationPopup->SetShowState(false);
1072 case IDA_MENU_ADD_PAUSE:
1078 case IDA_MENU_ADD_WAIT:
1092 case IDA_MENU_SEND_MESSAGE:
1094 String contactNo = pEditField->GetText();
1095 contactNo.Replace(L"-",L"");
1096 result r = __pDialPresentationModel->OpenMessagingAppControl(contactNo);
1099 SetAppControlLaunched(true);
1105 case IDA_MENU_SPEED_DIAL:
1107 SwitchToSpeedDialForm();
1112 case IDA_BTN_USE_CONTACT_DATA:
1114 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(0);
1115 if(pDialInfo != null)
1117 //fetch contact number
1118 String phNumber = pDialInfo->GetPhoneNumber();
1119 if(phNumber.Equals(pEditField->GetText()) == false)
1121 pEditField->Clear();
1122 ShowFormattedText(pEditField,phNumber);
1123 pEditField->Invalidate(true);
1124 if (__isSearchListOpened == true)
1126 HideSearchListView();
1128 UpdateSearchResults();
1134 case IDA_BTN_DISPLAY_CONTACTS:
1136 if (__isSearchListOpened == true)
1138 Form* pForm = dynamic_cast<Form *>(GetParent());
1139 int noOfItems = MAX_SEARCH_LIST_ITEMS;
1140 if(__pDialPresentationModel->GetNumberOfSuggestions() < (noOfItems+1))
1142 noOfItems = __pDialPresentationModel->GetNumberOfSuggestions() - 1;
1144 if(pForm != null && (pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE))
1148 SetOrigPosUseContact();
1151 HideSearchListView();
1155 ShowSearchListView();
1163 pEditField->Invalidate(true);
1165 AppLogDebug("EXIT");
1170 DialTabDialer::OnLongPressGestureDetected(TouchLongPressGestureDetector& gestureDetector)
1172 AppLogDebug("ENTER");
1173 if (GetAppControlLaunched() == true)
1175 //If call AppControl is already launched, ignore any further requests.
1179 if (gestureDetector.GetControl() != null)
1181 Button* pButton = static_cast<Button*>(gestureDetector.GetControl());
1182 int actionId = pButton->GetActionId();
1195 //first check if there is any number present in the edit fiels
1196 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1197 if(pEditField->GetTextLength() != 0)
1199 //append / clear last character to contact
1200 int oldtextlen = pEditField->GetTextLength();
1201 ShowFormattedText(pEditField, actionId);
1202 if (pEditField->GetTextLength() == 0)
1204 __pDialPresentationModel->ClearSearchResults();
1210 if(oldtextlen != pEditField->GetTextLength())
1213 UpdateSearchResults();
1216 pEditField->Invalidate(true);
1219 //Check if Speed Dial setting exist for pressed key
1220 String* contactNumber = __pDialPresentationModel->FetchSpeedDialNumberN(actionId);
1221 if(contactNumber != null)
1223 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1225 //pass ownership to arraylist
1226 pArgs->Add(contactNumber);
1227 SendUserEvent(REQUEST_CALL_SPEED_DIAL_NUM,pArgs);
1231 //show speed Dial Confirmation Popup msg
1232 if(actionId == NUM_KEY1)
1234 SendUserEvent(REQUEST_SHOW_VOICE_MAIL_POPUP,null);
1238 SendUserEvent(REQUEST_SHOW_SPEED_DIAL_POPUP,null);
1253 //Handle Mute / UnMute
1254 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1255 if(pEditField->GetTextLength() == 0)
1257 bool enabled = false;
1258 String title = L"http://tizen.org/setting/sound.silent_mode";
1259 SettingInfo::GetValue(title, enabled);
1260 //enable or disable the phone silent mode.
1261 result r = E_FAILURE;
1262 r = SettingInfo::SetValue(title, !enabled);
1265 ShowSilentModeToggle(!enabled);
1273 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1274 if (pEditField != null && pEditField->GetTextLength() > 0)
1276 pEditField->Clear();
1277 pEditField->SetTextSize(IDI_MAX_TXT_FONT);
1278 //pEditField->SetCursorPosition(0);
1279 pEditField->SetFocus();
1280 pEditField->Invalidate(true);
1289 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1290 if(pEditField != null && pEditField->GetTextLength() > 0)
1292 String contactNo = pEditField->GetText();
1293 contactNo.Replace(L"-",L"");
1294 ShowCallContextMenu(contactNo);
1310 AppLogDebug("EXIT");
1315 DialTabDialer::ShowCallContextMenu(Tizen::Base::String& contactNumber)
1318 AppLogDebug("ENTER");
1320 Form *pForm = dynamic_cast<Form*>(GetParent());
1321 Button* pCallButton = static_cast<Button*>(pForm->GetControl(IDC_BUTTON_CALL,true));
1322 Panel* pLastRowPanel = static_cast<Panel*>(pForm->GetControl(IDC_PANEL_LASTROW,true));
1323 int portraitAnchorPositionY = pForm->GetHeight() - pLastRowPanel->GetHeight() +
1324 ((pLastRowPanel->GetHeight()- pCallButton->GetHeight())/2);
1325 int portraitAnchorPositionX = pLastRowPanel->GetWidth()/2;
1326 int landscapeAnchorPositionX = pForm->GetWidth()/2 + pLastRowPanel->GetWidth()/2 - pCallButton->GetWidth()/2;
1327 if(__pCallContextMenu != null)
1329 delete __pCallContextMenu;
1330 __pCallContextMenu = null;
1332 __pCallContextMenu = new (std::nothrow) ContextMenu();
1333 __pCallContextMenu->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
1334 //minimum available option count
1335 int visibleItems = MIN_CONTEXT_MENU_ITEMS + 1;
1336 __pCallContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_PAUSE), IDA_MENU_ADD_PAUSE);
1337 __pCallContextMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_ADD_WAIT), IDA_MENU_ADD_WAIT);
1338 __pCallContextMenu->AddActionEventListener(*this);
1339 __pCallContextMenu->SetFocusable(true);
1340 __pCallContextMenu->SetMaxVisibleItemsCount(visibleItems);
1341 // Set the anchor position of the ContextMenu
1342 if(pForm != null && (pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE))
1344 __pCallContextMenu->SetAnchorPosition(Point(landscapeAnchorPositionX, portraitAnchorPositionY));
1348 __pCallContextMenu->SetAnchorPosition(Point(portraitAnchorPositionX, portraitAnchorPositionY));
1350 // Show the ContextMenu
1351 __pCallContextMenu->Show();
1353 AppLogDebug("EXIT");
1360 DialTabDialer::AddPause(void)
1362 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1363 if (pEditField != null && pEditField->GetTextLength() > 0)
1365 ShowFormattedText(pEditField,PAUSE_KEY);
1367 UpdateSearchResults();
1368 pEditField->Invalidate(true);
1375 DialTabDialer::AddWait(void)
1377 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1378 if (pEditField != null)
1380 ShowFormattedText(pEditField,WAIT_KEY);
1381 if (pEditField->GetTextLength() == 0)
1389 UpdateSearchResults();
1391 pEditField->Invalidate(true);
1398 DialTabDialer::AddPlus(void)
1400 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1401 if (pEditField != null)
1403 ShowFormattedText(pEditField,PLUS_KEY);
1404 if (pEditField->GetTextLength() == 0)
1412 UpdateSearchResults();
1414 pEditField->Invalidate(true);
1420 DialTabDialer::DialOutgoingCall(const String& contactNumber)
1422 AppLogDebug("Enter");
1423 bool isSuccess = false;
1424 if (__isAppControlLaunched == true)
1426 //If call AppControl is already launched, ignore any further requests.
1430 if(__dialerState == DIALER_STATE_FIRST_SCENE || __dialerState == DIALER_STATE_NORMAL_APPCONTROL)
1432 ErrorCodes error = __pDialPresentationModel->DialCall(contactNumber);
1433 if (error == ERROR_NONE)
1435 __isAppControlLaunched = true;
1440 __isAppControlLaunched = false;
1442 //Show error message Popup
1443 if (__pErrorMsgPopup == null)
1445 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
1446 __pErrorMsgPopup->ShowErrorMsgPopupN(error);
1452 //Dialer was launched as AppControl in "AddCall" Scenario.
1453 if (__dialerState == DIALER_STATE_ADD_CALL_APPCONTROL)
1457 resultData.Construct();
1458 resultData.Add(new (std::nothrow) String(PARAM_PHONE_NUMBER), new (std::nothrow) String(contactNumber));
1459 //send "APP_CTRL_RESULT_SUCCEEDED" and 'contactNumber' as result.
1460 PhoneApp* pApp = static_cast<PhoneApp*>(UiApp::GetInstance());
1461 pApp->SendAppControlResponseMessage(APP_CTRL_RESULT_SUCCEEDED, &resultData);
1462 resultData.RemoveAll(true);
1470 DialTabDialer::SwitchToSpeedDialForm(void)
1472 SceneManager* pSceneManager = SceneManager::GetInstance();
1473 AppAssert(pSceneManager);
1474 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_SPEED_DIAL), null);
1479 DialTabDialer::ShowSpeedDialConfirmationPopup(bool isVoiceMail)
1481 String popupTitleMsg;
1484 if(__pConfirmationPopup == null)
1486 FloatRectangle rect = GetBoundsF();
1487 __pConfirmationPopup = new (std::nothrow) Popup();
1488 __pConfirmationPopup->Construct(true, FloatDimension(W_SPEEDDIAL_POPUP, H_SPEEDDIAL_POPUP));
1490 rect = __pConfirmationPopup->GetBoundsF();
1491 pMsgLabel = new (std::nothrow) Label();
1492 if(isVoiceMail == true)
1494 popupTitleMsg = AppUtility::GetResourceString(IDS_DIALER_VOICE_POPUP_TITLE_MSG);
1495 popupMsg = AppUtility::GetResourceString(IDS_DIALER_VOICE_POPUP_MSG);
1499 popupTitleMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_TITLE_MSG);
1500 popupMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_MSG);
1502 __pConfirmationPopup->SetTitleText(popupTitleMsg);
1503 __pConfirmationPopup->SetPropagatedKeyEventListener(this);
1504 __pConfirmationPopup->Invalidate(true);
1505 pMsgLabel->Construct(Rectangle(0, IDI_PADDING, rect.width, H_POPUP_MSG_LABEL), popupMsg);
1506 pMsgLabel->SetName(IDC_SPEED_DIAL_TXT_LABEL);
1507 pMsgLabel->SetTextConfig(44,LABEL_TEXT_STYLE_NORMAL);
1508 pMsgLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1509 pMsgLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1510 __pConfirmationPopup->AddControl(*pMsgLabel);
1512 rect = pMsgLabel->GetBoundsF();
1513 Button *pButtonYes = new (std::nothrow) Button();
1514 String btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_YES_BTN_STRING);
1515 pButtonYes->Construct(Rectangle(rect.x+ IDI_PADDING, (rect.y + rect.height + IDI_PADDING), ((rect.width - (3 * IDI_PADDING)) / 2), H_POPUP_BTN), btnName);
1516 pButtonYes->SetActionId(IDA_SPEEDDIAL_POPUP_YES);
1517 pButtonYes->AddActionEventListener(*this);
1518 __pConfirmationPopup->AddControl(*pButtonYes);
1520 rect = pButtonYes->GetBoundsF();
1521 Button *pButtonNo = new (std::nothrow) Button();
1522 btnName = AppUtility::GetResourceString(IDS_SPEEDDIAL_POP_NO_BTN_STRING);
1523 pButtonNo->Construct(Rectangle((rect.x + rect.width + IDI_PADDING), rect.y, rect.width, rect.height), btnName);
1524 pButtonNo->SetActionId(IDA_SPEEDDIAL_POPUP_NO);
1525 pButtonNo->AddActionEventListener(*this);
1526 __pConfirmationPopup->AddControl(pButtonNo);
1530 if(isVoiceMail == true)
1532 popupTitleMsg = AppUtility::GetResourceString(IDS_DIALER_VOICE_POPUP_TITLE_MSG);
1533 popupMsg = AppUtility::GetResourceString(IDS_DIALER_VOICE_POPUP_MSG);
1537 popupTitleMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_TITLE_MSG);
1538 popupMsg = AppUtility::GetResourceString(IDS_DIALER_SPEEDDIAL_POPUP_MSG);
1540 __pConfirmationPopup->SetTitleText(popupTitleMsg);
1541 pMsgLabel = static_cast<Label*>(__pConfirmationPopup->GetControl(IDC_SPEED_DIAL_TXT_LABEL, true));
1542 pMsgLabel->SetText(popupMsg);
1545 //Show Popup message
1546 __pConfirmationPopup->SetShowState(true);
1547 __pConfirmationPopup->Show();
1551 DialTabDialer::ShowAddToContactsButton(void)
1553 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1554 Button* pButtonContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
1555 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
1556 Button* pButtonPullUp = static_cast<Button*>(GetControl(IDC_BUTTON_PULL_UP, true));
1557 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
1558 pButtonContacts->SetShowState(false);
1559 pButtonDropDown->SetShowState(false);
1560 pButtonPullUp->SetShowState(false);
1561 pButtonAddContacts->SetShowState(true);
1562 pSearchPanel->SetShowState(true);
1563 pSearchPanel->Invalidate(true);
1568 DialTabDialer::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1572 case REQUEST_SHOW_SUGGESTION:
1574 String* pDisplayname = static_cast<String*> (pArgs->GetAt(0));
1575 String* pMobileNo = static_cast<String*> (pArgs->GetAt(1));
1576 String* pMatchedSearchStr = static_cast<String*> (pArgs->GetAt(2));
1577 String* pResultCount = static_cast<String*> (pArgs->GetAt(3));
1578 if(pDisplayname != null && pMobileNo != null && pMatchedSearchStr != null && pResultCount != null)
1580 if (__isSearchListOpened == true)
1582 HideSearchListView();
1584 ShowSuggestionBox(*pDisplayname, *pMobileNo, *pMatchedSearchStr, *pResultCount);
1590 case REQUEST_SHOW_ADD_TO_CONTACTS:
1592 if (__isSearchListOpened == true)
1594 HideSearchListView();
1596 ShowAddToContactsButton();
1600 case REQUEST_CALL_SPEED_DIAL_NUM:
1604 String *number = static_cast<String*> (pArgs->GetAt(0));
1608 DialOutgoingCall(*number);
1615 case REQUEST_SHOW_VOICE_MAIL_POPUP:
1617 ShowSpeedDialConfirmationPopup(true);
1620 case REQUEST_SHOW_SPEED_DIAL_POPUP:
1622 //show speed Dial Confirmation Popup msg
1623 ShowSpeedDialConfirmationPopup();
1630 DialTabDialer::SetShiftedPosUseContact(void)
1632 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1633 Panel* pPanelUseContact = static_cast<Panel*>(pSearchPanel->GetControl(IDC_PANEL_USE_CONTACT, true));
1634 Panel* pPanelDropDown = static_cast<Panel*>(pSearchPanel->GetControl(IDC_PANEL_DROPDOWN, true));
1636 Point pointUseContact = pPanelUseContact->GetPosition();
1637 pointUseContact.y = 0;
1638 Point pointDropDown = pPanelDropDown->GetPosition();
1639 pointDropDown.y = 10;
1641 pPanelUseContact->SetPosition(pointUseContact.x,pointUseContact.y);
1642 pPanelDropDown->SetPosition(pointDropDown.x,pointDropDown.y);
1644 pPanelUseContact->SetShowState(true);
1645 pPanelDropDown->SetShowState(true);
1647 SetControlAlwaysOnTop(*pPanelUseContact,true);
1648 SetControlAlwaysOnTop(*pPanelDropDown,true);
1649 pSearchPanel->Invalidate(true);
1652 DialTabDialer::SetOrigPosUseContact(void)
1654 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1655 Panel* pPanelUseContact = static_cast<Panel*>(pSearchPanel->GetControl(IDC_PANEL_USE_CONTACT, true));
1656 Panel* pPanelDropDown = static_cast<Panel*>(pSearchPanel->GetControl(IDC_PANEL_DROPDOWN, true));
1658 Point pointUseContact = pPanelUseContact->GetPosition();
1659 pointUseContact.y = 119;
1660 Point pointDropDown = pPanelDropDown->GetPosition();
1661 pointDropDown.y = 147;
1663 pPanelUseContact->SetPosition(pointUseContact.x,pointUseContact.y);
1664 pPanelDropDown->SetPosition(pointDropDown.x,pointDropDown.y);
1666 SetControlAlwaysOnTop(*pPanelUseContact,true);
1667 SetControlAlwaysOnTop(*pPanelDropDown,true);
1668 pSearchPanel->Invalidate(true);
1672 DialTabDialer::ShowSuggestionBox(String& name, String& mobileNo, String& matchedKey, String& resultCount)
1674 AppLogDebug("ENTER");
1676 //"UseContact" Button
1677 Button* pButtonUseContacts = static_cast<Button*>(GetControl(IDC_BUTTON_USE_CONTACT, true));
1678 Canvas pCanvasNormalContacts;
1679 pCanvasNormalContacts.Construct(pButtonUseContacts->GetBounds());
1680 Canvas pCanvasPressedContacts;
1681 pCanvasPressedContacts.Construct(pButtonUseContacts->GetBounds());
1682 String mobileStr = AppUtility::GetResourceString(IDS_DIALER_MOBILE_STR);
1683 pCanvasNormalContacts.SetBackgroundColor(COLOR_SEARCHLIST_BG);
1684 pCanvasNormalContacts.Clear();
1685 //Add text, Bg to normal state
1686 DialUtil::DrawTextAndHighlightedKeywordToCanvas(name, matchedKey, FONT_SUGGESTION_NAME, pCanvasNormalContacts, POSITION_SUGGESTION_NAME);
1687 DialUtil::DrawTextAndHighlightedKeywordToCanvas(mobileNo, matchedKey, FONT_SUGGESTION_MOBILE, pCanvasNormalContacts, POSITION_SUGGESTION_NUMBER);
1688 //Add text, Bg to pressed state
1689 pCanvasPressedContacts.SetBackgroundColor(COLOR_SEARCHLIST_PRESS_BG);
1690 pCanvasPressedContacts.Clear();
1691 DialUtil::DrawTextAndHighlightedKeywordToCanvas(name, matchedKey, FONT_SUGGESTION_NAME, pCanvasPressedContacts, POSITION_SUGGESTION_NAME);
1692 DialUtil::DrawTextAndHighlightedKeywordToCanvas(mobileNo, matchedKey, FONT_SUGGESTION_MOBILE, pCanvasPressedContacts, POSITION_SUGGESTION_NUMBER);
1693 //add normal, pressed bg bitmap to button
1694 DialUtil::DrawCanvasToButton(&pCanvasNormalContacts, &pCanvasPressedContacts, pButtonUseContacts);
1697 Button* pButtonDropDown = static_cast<Button*>(GetControl(IDC_BUTTON_DROP_DOWN, true));
1698 Canvas pCanvasNormalDropDown;
1699 pCanvasNormalDropDown.Construct(pButtonDropDown->GetBounds());
1700 Canvas pCanvasPressedDropDown;
1701 pCanvasPressedDropDown.Construct(pButtonDropDown->GetBounds());
1702 //Add text, Bg to normal state
1703 DialUtil::Draw9PatchToCanvas(pCanvasNormalDropDown, IDB_BTN_OPTION_BG_ICON);
1704 DialUtil::DrawTextToCanvas(resultCount, FONT_EXPAND_BUTTON_TEXT, pCanvasNormalDropDown, POSITION_CENTER, BUTTON_STATUS_NORMAL);
1705 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasNormalDropDown, POSITION_BOTTOM_CENTER);
1706 //Add text, Bg to pressed state
1707 DialUtil::Draw9PatchToCanvas(pCanvasPressedDropDown, IDB_BTN_OPTION_PRESS_BG_ICON);
1708 DialUtil::DrawTextToCanvas(resultCount, FONT_EXPAND_BUTTON_TEXT, pCanvasPressedDropDown, POSITION_CENTER, BUTTON_STATUS_NORMAL);
1709 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_PRESS_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasPressedDropDown, POSITION_BOTTOM_CENTER);
1710 //add background to button
1711 DialUtil::DrawCanvasToButton(&pCanvasNormalDropDown, &pCanvasPressedDropDown, pButtonDropDown);
1714 Button* pButtonPullUp = static_cast<Button*>(GetControl(IDC_BUTTON_PULL_UP, true));
1715 Canvas pCanvasNormalPullUp;
1716 pCanvasNormalPullUp.Construct(pButtonPullUp->GetBounds());
1717 Canvas pCanvasPressedPullUp;
1718 pCanvasPressedPullUp.Construct(pButtonPullUp->GetBounds());
1719 //Add text, Bg to normal state
1720 DialUtil::Draw9PatchToCanvas(pCanvasNormalPullUp, IDB_BTN_OPTION_BG_ICON);
1721 DialUtil::DrawTextToCanvas(resultCount, FONT_EXPAND_BUTTON_TEXT, pCanvasNormalPullUp, POSITION_CENTER, BUTTON_STATUS_NORMAL);
1722 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_UP_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasNormalPullUp, POSITION_BOTTOM_CENTER);
1723 //Add text, Bg to pressed state
1724 DialUtil::Draw9PatchToCanvas(pCanvasPressedPullUp, IDB_BTN_OPTION_PRESS_BG_ICON);
1725 DialUtil::DrawTextToCanvas(resultCount, FONT_EXPAND_BUTTON_TEXT, pCanvasPressedPullUp, POSITION_CENTER, BUTTON_STATUS_NORMAL);
1726 DialUtil::DrawImageToCanvas(IDB_POPUP_BUBBLE_UP_PRESS_ICON, Dimension(W_SUGGESTION_POPUP_BUBBLE_ICON, H_SUGGESTION_POPUP_BUBBLE_ICON), pCanvasPressedPullUp, POSITION_BOTTOM_CENTER);
1727 //add background to button
1728 DialUtil::DrawCanvasToButton(&pCanvasNormalPullUp, &pCanvasPressedPullUp, pButtonPullUp);
1730 Button* pButtonAddContacts = static_cast<Button*>(GetControl(IDC_BUTTON_ADD_CONTACTS, true));
1731 pButtonAddContacts->SetShowState(false);
1733 Form* pForm = dynamic_cast<Form *>(GetParent());
1734 int noOfItems = MAX_SEARCH_LIST_ITEMS;
1735 if(__pDialPresentationModel->GetNumberOfSuggestions() < (noOfItems+1))
1737 noOfItems = __pDialPresentationModel->GetNumberOfSuggestions() - 1;
1739 if(pForm != null && (pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE))
1741 SetOrigPosUseContact();
1743 pButtonUseContacts->SetShowState(true);
1745 Panel* pSearchListPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_LIST, true));
1746 //Show pull up or drop down based on list view state
1747 if(pSearchListPanel->GetShowState() == false)
1749 pButtonPullUp->SetShowState(false);
1750 pButtonPullUp->Invalidate(false);
1752 pButtonDropDown->SetShowState(true);
1753 pButtonDropDown->Invalidate(true);
1757 pButtonDropDown->SetShowState(false);
1758 pButtonDropDown->Invalidate(false);
1760 pButtonPullUp->SetShowState(true);
1761 pButtonPullUp->Invalidate(true);
1764 Panel* pSearchPanel = static_cast<Panel*>(GetControl(IDC_PANEL_SEARCH_BOX, true));
1765 pSearchPanel->SetShowState(true);
1766 pSearchPanel->Invalidate(true);
1768 AppLogDebug("EXIT");
1773 DialTabDialer::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
1775 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(index+1);
1776 if(pDialInfo != null)
1778 String phNumber = pDialInfo->GetPhoneNumber();
1779 EditField* pTextBox = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1780 if(pTextBox != null)
1783 ShowFormattedText(pTextBox,phNumber);
1784 pTextBox->Invalidate(true);
1786 HideSearchListView();
1787 UpdateSearchResults();
1793 DialTabDialer::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1795 AppLogDebug("Enter");
1796 Form* pForm = static_cast<Form*>(GetParent());
1798 Label* pEditFieldBgLbl = static_cast<Label*>(GetControl(L"IDC_LABEL_BACKGROUND", true));
1799 Dimension editFieldBgLblDimen = pEditFieldBgLbl->GetSize();
1800 if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1802 editFieldBgLblDimen.height = 461;
1804 else if(orientationStatus == ORIENTATION_STATUS_PORTRAIT || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1806 editFieldBgLblDimen.height = 315;
1808 pEditFieldBgLbl->SetSize(editFieldBgLblDimen);
1810 //Show last row label bg in landscape only.
1811 Panel* pLastRowPanel = static_cast<Panel*>(GetControl(IDC_PANEL_LASTROW, true));
1812 Rectangle lastRowRect = pLastRowPanel->GetBounds();
1813 lastRowRect.y = pForm->GetClientAreaBounds().height - lastRowRect.height;
1814 pLastRowPanel->SetBounds(lastRowRect);
1815 Label* pLastRowLabel = static_cast<Label*>(pLastRowPanel->GetControl(IDC_LABEL_LASTROW_BG, true));
1816 if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1818 pLastRowLabel->SetShowState(true);
1820 else if(orientationStatus == ORIENTATION_STATUS_PORTRAIT || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1822 pLastRowLabel->SetShowState(false);
1825 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1826 if (pEditField->GetTextLength() > 0)
1828 if (__pDialPresentationModel->GetNumberOfSuggestions() == 0)
1830 ShowAddToContactsButton();
1834 //contact suggestion is present, change it bitmap based on new orientation
1835 DialContactInfo* pDialInfo = __pDialPresentationModel->GetSuggestionAtIndex(0);
1836 if (pDialInfo != null)
1838 String name = pDialInfo->GetDisplayName();
1839 String mobileNo = pDialInfo->GetPhoneNumber();
1840 String* pMatchedSearchStr = pDialInfo->GetSearchKey();
1842 resultCount.Append(__pDialPresentationModel->GetNumberOfSuggestions());
1843 ShowSuggestionBox(name, mobileNo, *pMatchedSearchStr, resultCount);
1845 //Check if search list view is open
1846 if(__isSearchListOpened == true)
1848 HideSearchListView();
1849 ShowSearchListView();
1854 //reset the bitmaps to button based on new orientation.
1855 if (__pDialKeypad != null)
1857 __pDialKeypad->SetBitmapToKeypadButtons();
1858 __pDialKeypad->Invalidate(true);
1866 DialTabDialer::HandlePopupClosed(void)
1869 if(__pErrorMsgPopup != null)
1871 __pErrorMsgPopup->SetShowState(false);
1877 DialTabDialer::OnForeground(void)
1879 AppLogDebug("Enter");
1880 __isAppForeground = true;
1881 //If app control was launched
1882 //as we do not know if it success or failed
1883 // we need to UpdateSearchResults
1884 //Returned from app control if app control does not
1885 //send any response we need to do this
1886 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1887 String editText(L"");
1888 if(pEditField != null)
1890 editText = pEditField->GetText();
1893 if(editText.IsEmpty() == true)
1895 //Fetch auto area code setting, if present
1896 SettingsPresentationModel::GetInstance()->GetActivePrefixDialNumber(editText);
1897 if(editText.IsEmpty() == false)
1899 editText.Replace(L"P",L";");
1900 editText.Replace(L"p",L";");
1904 if(pEditField != null)
1906 ShowFormattedText(pEditField,editText);
1907 //pEditField->SetCursorPosition(editText.GetLength());
1908 pEditField->Invalidate(true);
1909 //show search results
1910 if (pEditField->GetTextLength() == 0)
1918 UpdateSearchResults();
1921 SetAppControlLaunched(false);
1925 DialTabDialer::OnBackground(void)
1927 AppLogDebug("Enter");
1928 __isAppForeground = false;
1932 DialTabDialer::IsForeground()
1934 AppLogDebug("Enter %d",__isAppForeground);
1935 return __isAppForeground;
1939 DialTabDialer::OnContactsChanged(const IList& contactChangeInfoList)
1941 if(contactChangeInfoList.GetCount() > 0)
1943 //clear old search results
1944 __pDialPresentationModel->ClearSearchResults();
1945 UpdateSearchResults();
1950 DialTabDialer::SetAppControlLaunched(bool launched)
1952 AppLogDebug("%d",__isAppControlLaunched);
1953 __isAppControlLaunched = launched;
1957 DialTabDialer::GetAppControlLaunched(void)
1959 AppLogDebug("%d",__isAppControlLaunched);
1960 return __isAppControlLaunched;
1964 DialTabDialer::OnTextValueChanged(const Tizen::Ui::Control& source)
1966 AppLogDebug("OnTextValueChanged");
1967 EditField* pEditField = static_cast<EditField*>(GetControl(IDC_NUMERIC_EDITFIELD, true));
1968 if (pEditField->GetTextLength() == 0)
1975 String number = pEditField->GetText();
1976 pEditField->Clear();
1977 ShowFormattedText(pEditField,number);
1979 UpdateSearchResults();
1984 DialTabDialer::ShowOptionsMenu()
1986 if(__pOptionMenu != null)
1988 delete __pOptionMenu;
1989 __pOptionMenu = null;
1991 __pOptionMenu = new (std::nothrow) OptionMenu();
1992 __pOptionMenu->Construct();
1993 __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SEND_MSG), IDA_MENU_SEND_MESSAGE);
1994 __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_DIALER_MENU_ITEM_SPEED_DIAL), IDA_MENU_SPEED_DIAL);
1995 __pOptionMenu->AddActionEventListener(*this);
1996 __pOptionMenu->SetShowState(true);
1997 __pOptionMenu->Show();
2001 DialTabDialer::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
2003 AppLogDebug("Enter");
2004 if(keyEventInfo.GetKeyCode() == KEY_BACK)
2006 if(__pConfirmationPopup != null && __pConfirmationPopup->GetShowState() == true)
2008 __pConfirmationPopup->SetShowState(false);
2015 DialTabDialer::ShowSilentModeToggle(bool bEnabled)
2017 // Creates an instance of MessageBox
2018 String message = (bEnabled ? AppUtility::GetResourceString(IDS_SILENT_MODE_ENABLED):AppUtility::GetResourceString(IDS_SILENT_MODE_DISABLED));
2019 MessageBox silentMsgBox;
2021 silentMsgBox.Construct(L"", message, MSGBOX_STYLE_NONE, 2000);
2022 // Calls ShowAndWait() : Draws and Shows itself and processes events
2025 silentMsgBox.ShowAndWait(modalResult);