Merge "IMS: Grey out merge menu item in more options" into atel.lnx.2.0-dev
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index cdc0359..fa76bba 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -290,6 +290,7 @@
         } else if (id == R.id.overflowButton) {
             if (mOverflowPopup != null) {
                 updateRecordMenu();
+                updateMergeCallsMenuItem();
                 mOverflowPopup.show();
             }
         } else if (id == R.id.manageVideoCallConferenceButton) {
@@ -356,6 +357,13 @@
         }
     }
 
+    private void updateMergeCallsMenuItem() {
+        MenuItem item = mOverflowPopup.getMenu().findItem(BUTTON_MERGE);
+        if (item != null) {
+            item.setEnabled(mMergeButton.isEnabled());
+        }
+    }
+
     public void updateColors() {
         MaterialPalette themeColors = InCallPresenter.getInstance().getThemeColors();
 
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index ec330a2..0a8e0bd 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -268,6 +268,10 @@
     }
 
     public void mergeClicked() {
+        if (mCall == null) {
+            return;
+        }
+
         if (getUi().getContext().getResources().getBoolean(
                 R.bool.add_multi_participants_enabled)){
             int participantsCount = 0;