Merge "Remove generic call merge button." into lmp-dev
diff --git a/InCallUI/res/layout-land/call_card_content.xml b/InCallUI/res/layout-land/call_card_content.xml
index b1b5275..f317353 100644
--- a/InCallUI/res/layout-land/call_card_content.xml
+++ b/InCallUI/res/layout-land/call_card_content.xml
@@ -43,12 +43,15 @@
         <FrameLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent" >
+
             <!-- Secondary "Call info" block, for the background ("on hold") call. -->
             <include layout="@layout/secondary_call_info"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_gravity="bottom" />
+
         </FrameLayout>
+
     </LinearLayout>
 
     <!-- Contact photo for primary call info -->
diff --git a/InCallUI/res/layout/call_card_content.xml b/InCallUI/res/layout/call_card_content.xml
index 605d630..c45553f 100644
--- a/InCallUI/res/layout/call_card_content.xml
+++ b/InCallUI/res/layout/call_card_content.xml
@@ -96,10 +96,7 @@
     </FrameLayout>
 
     <!-- Secondary "Call info" block, for the background ("on hold") call. -->
-    <include layout="@layout/secondary_call_info"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentBottom="true"/>
+    <include layout="@layout/secondary_call_info" />
 
     <!-- Placeholder for the dialpad which is replaced with the dialpad fragment when shown. -->
     <FrameLayout
diff --git a/InCallUI/res/layout/extra_button_row.xml b/InCallUI/res/layout/extra_button_row.xml
index 1bff4c5..417c4d6 100644
--- a/InCallUI/res/layout/extra_button_row.xml
+++ b/InCallUI/res/layout/extra_button_row.xml
@@ -46,28 +46,4 @@
             android:text="@string/onscreenManageConferenceText" />
     </LinearLayout>
 
-    <!-- CDMA-specific "Merge" -->
-    <!-- This button is used only on CDMA devices, where we can't use
-         the Merge button in the main button row (because the "Add Call"
-         button might need to be enabled at the same time.) -->
-    <LinearLayout android:id="@+id/cdmaMergeButton"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingStart="@dimen/button_cluster_horizontal_padding"
-        android:paddingEnd="@dimen/button_cluster_horizontal_padding"
-        android:background="?android:attr/selectableItemBackground"
-        android:visibility="gone">
-        <!-- The entire LinearLayout here is clickable, so we don't
-             care about clicks on the ImageButton itself. -->
-        <ImageButton android:id="@+id/cdmaMergeButtonImage"
-            android:clickable="false"
-            style="@style/InCallExtraRowButton"
-            android:src="@drawable/ic_toolbar_merge"
-            android:contentDescription="@string/onscreenMergeCallsText" />
-        <TextView android:id="@+id/cdmaMergeButtonLabel"
-            style="@style/InCallExtraRowButtonLabel"
-            android:text="@string/onscreenMergeCallsText" />
-    </LinearLayout>
-
 </FrameLayout>
diff --git a/InCallUI/res/layout/secondary_call_info.xml b/InCallUI/res/layout/secondary_call_info.xml
index cbe1fa2..237559d 100644
--- a/InCallUI/res/layout/secondary_call_info.xml
+++ b/InCallUI/res/layout/secondary_call_info.xml
@@ -27,7 +27,7 @@
     android:paddingTop="@dimen/call_banner_secondary_call_top_bottom_padding"
     android:paddingBottom="@dimen/call_banner_secondary_call_top_bottom_padding"
     android:background="@color/incall_banner_secondary_background_color"
-    android:elevation="@dimen/secondary_call_elevation" >
+    android:elevation="@dimen/secondary_call_elevation">
 
     <LinearLayout
         android:layout_width="0dp"
diff --git a/InCallUI/res/values/colors.xml b/InCallUI/res/values/colors.xml
index bd2642d..3060339 100644
--- a/InCallUI/res/values/colors.xml
+++ b/InCallUI/res/values/colors.xml
@@ -62,7 +62,7 @@
     <color name="glowpad_text_widget_ring_color">#ffffff</color>
     <color name="glowpad_widget_active_color">#ffffff</color>
     <color name="glowpad_text_widget_normal_tint">#cccccc</color>
-    <color name="glowpad_call_widget_normal_tint">#00e5ff</color>
+    <color name="glowpad_call_widget_normal_tint">@color/dialtacts_theme_color</color>
     <color name="glowpad_end_call_widget_normal_tint">#ff1744</color>
     <color name="glowpad_incoming_widget_tint">#a3a3a3</color>
     <color name="glowpad_incoming_widget_background_tint">#ffffff</color>
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index 74aeaf3..5744cc5 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -60,7 +60,6 @@
     private PopupMenu mOverflowPopup;
     private View mExtraRowButton;
     private View mManageConferenceButton;
-    private View mGenericMergeButton;
 
     private int mPrevAudioMode = 0;
 
@@ -95,8 +94,6 @@
 
         mManageConferenceButton = parent.findViewById(R.id.manageConferenceButton);
         mManageConferenceButton.setOnClickListener(this);
-        mGenericMergeButton = parent.findViewById(R.id.cdmaMergeButton);
-        mGenericMergeButton.setOnClickListener(this);
 
         mAudioButton = (ImageButton) parent.findViewById(R.id.audioButton);
         mAudioButton.setOnClickListener(this);
@@ -166,7 +163,6 @@
                 getPresenter().muteClicked(!button.isSelected());
                 break;
             }
-            case R.id.cdmaMergeButton:
             case R.id.mergeButton:
                 getPresenter().mergeClicked();
                 break;
@@ -679,14 +675,6 @@
     public void showManageConferenceCallButton() {
         mExtraRowButton.setVisibility(View.VISIBLE);
         mManageConferenceButton.setVisibility(View.VISIBLE);
-        mGenericMergeButton.setVisibility(View.GONE);
-    }
-
-    @Override
-    public void showGenericMergeButton() {
-        mExtraRowButton.setVisibility(View.VISIBLE);
-        mManageConferenceButton.setVisibility(View.GONE);
-        mGenericMergeButton.setVisibility(View.VISIBLE);
     }
 
     @Override
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index 6cdc657..393c0f6 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -40,7 +40,6 @@
     private Call mCall;
     private boolean mAutomaticallyMuted = false;
     private boolean mPreviousMuteState = false;
-    private boolean mShowGenericMerge = false;
     private boolean mShowManageConference = false;
     private InCallCameraManager mInCallCameraManager;
 
@@ -305,18 +304,6 @@
         }
 
         ui.enableMute(call.can(PhoneCapabilities.MUTE));
-
-        // Finally, update the "extra button row": It's displayed above the "End" button, but only
-        // if necessary. It's never displayed while the dialpad is visible since it would overlap.
-        //
-        // The row contains two buttons:
-        //     - "Manage conference" (used only on GSM devices)
-        //     - "Merge" button (used only on CDMA devices)
-        final boolean canMerge = call.can(PhoneCapabilities.MERGE_CALLS);
-        final boolean isGenericConference = call.can(PhoneCapabilities.GENERIC_CONFERENCE);
-        mShowGenericMerge = isGenericConference && canMerge;
-        mShowManageConference = (call.isConferenceCall() && !isGenericConference);
-        updateExtraButtonRow(ui.isDialpadVisible());
     }
 
     private void updateVideoCallButtons() {
@@ -361,20 +348,18 @@
 
         final boolean canMerge = call.can(PhoneCapabilities.MERGE_CALLS);
         final boolean canAdd = call.can(PhoneCapabilities.ADD_CALL);
-        final boolean isGenericConference = call.can(PhoneCapabilities.GENERIC_CONFERENCE);
         final boolean canHold = call.can(PhoneCapabilities.HOLD);
         final boolean canSwap = call.can(PhoneCapabilities.SWAP_CALLS);
         final boolean supportHold = call.can(PhoneCapabilities.SUPPORT_HOLD);
+        final boolean isGenericConference = call.can(PhoneCapabilities.GENERIC_CONFERENCE);
+
         boolean canVideoCall = call.can(PhoneCapabilities.SUPPORTS_VT_LOCAL)
                 && call.can(PhoneCapabilities.SUPPORTS_VT_REMOTE);
-
-        final boolean showMerge = !isGenericConference && canMerge;
-
         ui.showChangeToVideoButton(canVideoCall);
 
-        // Show either MERGE or ADD, but not both.
-        final boolean showMergeOption = showMerge;
-        final boolean showAddCallOption = !showMerge;
+        // Show either MERGE or ADD. Only show both if, for CDMA, we're in a generic conference.
+        final boolean showMergeOption = canMerge;
+        final boolean showAddCallOption = canAdd && (isGenericConference || !canMerge);
         final boolean enableAddCallOption = showAddCallOption && canAdd;
         // Show either HOLD or SWAP, but not both.
         // If neither HOLD or SWAP is available:
@@ -385,8 +370,14 @@
         final boolean showSwapOption = !canHold && canSwap;
 
         ui.setHold(call.getState() == Call.State.ONHOLD);
-        if (canVideoCall && (showAddCallOption || showMergeOption)
-                && (showHoldOption || showSwapOption)) {
+        // If we show video upgrade and add/merge and hold/swap, the overflow menu is needed.
+        final boolean isVideoOverflowScenario = canVideoCall
+                && (showAddCallOption || showMergeOption) && (showHoldOption || showSwapOption);
+        // If we show hold/swap, add, and merge simultaneously, the overflow menu is needed.
+        final boolean isCdmaConferenceOverflowScenario =
+                (showHoldOption || showSwapOption) && showMergeOption && showAddCallOption;
+
+        if (isVideoOverflowScenario) {
             ui.showHoldButton(false);
             ui.showSwapButton(false);
             ui.showAddCallButton(false);
@@ -399,28 +390,39 @@
                     showHoldOption && enableHoldOption /* showHoldMenuOption */,
                     showSwapOption);
         } else {
-            ui.showMergeButton(showMergeOption);
-            ui.showAddCallButton(showAddCallOption);
-            ui.enableAddCall(enableAddCallOption);
+            if (isCdmaConferenceOverflowScenario) {
+                ui.showAddCallButton(false);
+                ui.showMergeButton(false);
+
+                ui.configureOverflowMenu(
+                        showMergeOption,
+                        showAddCallOption && enableAddCallOption /* showAddMenuOption */,
+                        false /* showHoldMenuOption */,
+                        false /* showSwapMenuOption */);
+            } else {
+                ui.showMergeButton(showMergeOption);
+                ui.showAddCallButton(showAddCallOption);
+                ui.enableAddCall(enableAddCallOption);
+            }
 
             ui.showHoldButton(showHoldOption);
             ui.enableHold(enableHoldOption);
             ui.showSwapButton(showSwapOption);
         }
+
+        // Only show the conference call button if we are not in a generic conference.
+        // On CDMA devices, instead of a conference call button we show "add" and "merge" buttons.
+        mShowManageConference = (call.isConferenceCall() && !isGenericConference);
+        updateExtraButtonRow(ui.isDialpadVisible());
     }
 
     private void updateExtraButtonRow(boolean isDialpadVisible) {
-        final boolean showExtraButtonRow = (mShowGenericMerge || mShowManageConference) &&
-                !isDialpadVisible;
+        final boolean showExtraButtonRow = mShowManageConference && !isDialpadVisible;
 
-        Log.d(this, "isGeneric: " + mShowGenericMerge);
         Log.d(this, "mShowManageConference : " + mShowManageConference);
-        Log.d(this, "mShowGenericMerge: " + mShowGenericMerge);
         Log.d(this, "isDialpadVisible: " + isDialpadVisible);
         if (showExtraButtonRow) {
-            if (mShowGenericMerge) {
-                getUi().showGenericMergeButton();
-            } else if (mShowManageConference) {
+            if (mShowManageConference) {
                 getUi().showManageConferenceCallButton();
             }
         } else {
@@ -467,7 +469,6 @@
         void configureOverflowMenu(boolean showMergeMenuOption, boolean showAddMenuOption,
                 boolean showHoldMenuOption, boolean showSwapMenuOption);
         void showManageConferenceCallButton();
-        void showGenericMergeButton();
         void hideExtraRow();
         void displayManageConferencePanel(boolean on);
         Context getContext();