Fix for Call sate not set properly when there is 1 waiting and 1 active call and...
[apps/osp/Call.git] / src / CallOptionPopup.cpp
index ce619b6..c58099e 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
@@ -80,6 +80,8 @@ CallOptionPopup::Initialize(void)
        int popupHeight = H_CANCEL_BUTTON + listHeight + CANCEL_BUTTON_PADDING + VERTICAL_PADDING;
        r = SetSize(Dimension(W_POPUP + HORIZONTAL_PADDING, popupHeight));
        TryReturn(r == E_SUCCESS, r, "CallOptionPopup::SetSize() failed");
+       SetMinimumSize(Dimension(W_POPUP + HORIZONTAL_PADDING, popupHeight));
+       TryReturn(r == E_SUCCESS, r, "CallOptionPopup::SetMinSize() failed");
 
        String strText;
        Application::GetInstance()->GetAppResource()->GetString(L"IDS_CANCEL", strText);
@@ -87,14 +89,17 @@ CallOptionPopup::Initialize(void)
        r = pCancelButton->Construct(Rectangle(VERTICAL_PADDING, listHeight + CANCEL_BUTTON_PADDING , W_CANCEL_BUTTON, H_CANCEL_BUTTON), strText);
        pCancelButton->SetActionId(IDA_BUTTON_CANCEL_OPTIONS_POPUP);
        pCancelButton->AddActionEventListener(*this);
-       r = AddControl(*pCancelButton);
+       SetPropagatedKeyEventListener(this);
+       r = AddControl(pCancelButton);
        TryReturn(r == E_SUCCESS, r, "CallOptionPopup::AddControl() failed");
 
        ListView* pListView = new (std::nothrow) ListView();
-       pListView->Construct(Rectangle(0, 0, W_POPUP - HORIZONTAL_PADDING, listHeight), true, SCROLL_STYLE_FADE_OUT);
+       pListView->Construct(Rectangle(0, 0, W_POPUP + HORIZONTAL_PADDING, listHeight), true, SCROLL_STYLE_FADE_OUT);
        pListView->AddListViewItemEventListener(*this);
        pListView->SetItemProvider(*this);
-       r = AddControl(*pListView);
+       r = AddControl(pListView);
+
+
 
        return r;
 }
@@ -105,7 +110,7 @@ CallOptionPopup::ConstructListData(void)
        result r = E_FAILURE;
 
        //fetch active call list
-       ArrayListT<CallInfo>* pCallList  = static_cast<ArrayListT<CallInfo>*>(__callPresenter.GetCallListN());
+       ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__callPresenter.GetCallListN());
        if (pCallList != null && pCallList->GetCount() > 0)
        {
                String optionStr(L"");
@@ -117,7 +122,7 @@ CallOptionPopup::ConstructListData(void)
                        //2 calls(Active+Held) present - 3 options are shown
                        for (int index = 0;index < pCallList->GetCount(); index++)
                        {
-                               CallInfo callInfo;
+                               AppCallInfo callInfo;
                                pCallList->GetAt(index,callInfo);
 
                                optionStr.Clear();
@@ -133,14 +138,22 @@ CallOptionPopup::ConstructListData(void)
                                else
                                {
                                        //show display name, if available, Else show contact number
-                                       String* pDisplayName = callInfo.FetchCallerNameN();
+                                       String* pDisplayName = null;
+                                       if(callInfo.GetContactNumber().IsEmpty() == false)
+                                       {
+                                               pDisplayName = callInfo.FetchLatestCallerNameN(callInfo.GetContactNumber());
+                                       }
+                                       else
+                                       {
+                                               pDisplayName = new (std::nothrow) String(L"");
+                                       }
                                        if (pDisplayName->IsEmpty() == true)
                                        {
                                                //If contact number is also not present show unknown
                                                if(callInfo.GetContactNumber().IsEmpty() == false)
                                                {
-                                               pDisplayName->Append(callInfo.GetContactNumber());
-                                       }
+                                                       pDisplayName->Append(callInfo.GetContactNumber());
+                                               }
                                                else
                                                {
                                                        pDisplayName->Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
@@ -168,17 +181,25 @@ CallOptionPopup::ConstructListData(void)
                else
                {
                        //only one call - 2 options are shown.
-                       CallInfo firstCallInfo;
+                       AppCallInfo firstCallInfo;
                        pCallList->GetAt(0,firstCallInfo);
                        if (firstCallInfo.IsConferenceCall() == false)
                        {
                                //show display name if available, else show contact number
-                               String* pDisplayName = firstCallInfo.FetchCallerNameN();
+                               String* pDisplayName = null;
+                               if(firstCallInfo.GetContactNumber().IsEmpty() == false)
+                               {
+                                       pDisplayName = firstCallInfo.FetchLatestCallerNameN(firstCallInfo.GetContactNumber());
+                               }
+                               else
+                               {
+                                       pDisplayName = new (std::nothrow) String(L"");
+                               }
                                if (pDisplayName->IsEmpty() == true)
                                {
                                        if(firstCallInfo.GetContactNumber().IsEmpty() == false)
                                        {
-                                       pDisplayName->Append(firstCallInfo.GetContactNumber());
+                                               pDisplayName->Append(firstCallInfo.GetContactNumber());
                                        }
                                        else
                                        {
@@ -230,6 +251,29 @@ CallOptionPopup::OnListViewItemStateChanged(ListView& listView, int index,
                int elementId, ListItemStatus status)
 {
        Popup::SetShowState(false);
+       if(elementId == -1)
+       {
+               elementId = ANSERWING_OPTION_HOLD_SINGLE_CALL;
+               if (__pOptionsList->GetCount() == 2)
+               {
+                       if(index == 1)
+                       {
+                               elementId = ANSERWING_OPTION_END_SINGLE_CALL;
+                       }
+               }
+               else
+               {
+                       elementId = ANSERWING_OPTION_REPLACE_ACTIVE_CALL;
+                       if(index == 1)
+                       {
+                               elementId = ANSERWING_OPTION_REPLACE_HELD_CALL;
+                       }
+                       else if(index == 2)
+                       {
+                               elementId = ANSERWING_OPTION_END_ALL_CALLS;
+                       }
+               }
+       }
        __popupListener.OnItemSelected(elementId);
        return;
 }
@@ -299,3 +343,17 @@ CallOptionPopup::OnActionPerformed(const Control& source, int actionId)
                break;
        }
 }
+
+bool
+CallOptionPopup::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
+{
+       AppLogDebug("Enter");
+       if(keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
+       {
+               Popup::SetShowState(false);
+               __popupListener.OnItemSelected(IDA_BUTTON_CANCEL_OPTIONS_POPUP);
+               return true;
+
+       }
+       return false;
+}