FIX 2139254: Get rid of "Manage Conference" button, use the photo instead

If the foreground call is a GSM conference call, replace the usual contact
photo with a big clickable button (with basically the same icon as before)
that brings up the Manage Conference UI.

This allows us to get rid of the original "Manage Conference" button at
the upper-right of the screen, which could collide with the "on hold"
photo.

TESTED: GSM conference calls, hvga and wvga.  Verified this change has no
effect on CDMA devices *or* devices like Dream/Sapphire with no onscreen
touch UI in the phone app.
diff --git a/res/drawable-hdpi/btn_in_call_manage_conf_normal.9.png b/res/drawable-hdpi/btn_in_call_manage_conf_normal.9.png
new file mode 100755
index 0000000..2368b55
--- /dev/null
+++ b/res/drawable-hdpi/btn_in_call_manage_conf_normal.9.png
Binary files differ
diff --git a/res/drawable-hdpi/btn_in_call_manage_conf_pressed.9.png b/res/drawable-hdpi/btn_in_call_manage_conf_pressed.9.png
new file mode 100755
index 0000000..9825031
--- /dev/null
+++ b/res/drawable-hdpi/btn_in_call_manage_conf_pressed.9.png
Binary files differ
diff --git a/res/drawable-hdpi/btn_in_call_manage_conf_selected.9.png b/res/drawable-hdpi/btn_in_call_manage_conf_selected.9.png
new file mode 100755
index 0000000..9e409da
--- /dev/null
+++ b/res/drawable-hdpi/btn_in_call_manage_conf_selected.9.png
Binary files differ
diff --git a/res/drawable-mdpi/btn_in_call_manage_conf_normal.9.png b/res/drawable-mdpi/btn_in_call_manage_conf_normal.9.png
new file mode 100755
index 0000000..3eab57b
--- /dev/null
+++ b/res/drawable-mdpi/btn_in_call_manage_conf_normal.9.png
Binary files differ
diff --git a/res/drawable-mdpi/btn_in_call_manage_conf_pressed.9.png b/res/drawable-mdpi/btn_in_call_manage_conf_pressed.9.png
new file mode 100755
index 0000000..1cfea1c
--- /dev/null
+++ b/res/drawable-mdpi/btn_in_call_manage_conf_pressed.9.png
Binary files differ
diff --git a/res/drawable-mdpi/btn_in_call_manage_conf_selected.9.png b/res/drawable-mdpi/btn_in_call_manage_conf_selected.9.png
new file mode 100755
index 0000000..de71406
--- /dev/null
+++ b/res/drawable-mdpi/btn_in_call_manage_conf_selected.9.png
Binary files differ
diff --git a/res/drawable/manage_conference_photo_button.xml b/res/drawable/manage_conference_photo_button.xml
new file mode 100644
index 0000000..c221565
--- /dev/null
+++ b/res/drawable/manage_conference_photo_button.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- StateListDrawable for the big "Manage conference" button that we show
+     in place of the usual contact photo during a conference call. -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true"
+        android:drawable="@drawable/btn_in_call_manage_conf_pressed" />
+    <item android:state_focused="true"
+        android:drawable="@drawable/btn_in_call_manage_conf_selected" />
+    <item
+        android:drawable="@drawable/btn_in_call_manage_conf_normal" />
+</selector>
diff --git a/res/layout/call_card_person_info.xml b/res/layout/call_card_person_info.xml
index 4a10646..353b07e 100644
--- a/res/layout/call_card_person_info.xml
+++ b/res/layout/call_card_person_info.xml
@@ -43,6 +43,21 @@
                    android:background="@drawable/incall_photo_border_lg"
                    />
 
+        <!-- The big "Manage conference" button that we show in place of
+             the contact photo during a conference call (but only on
+             devices where the in-call touch UI is enabled.)  The photo is
+             invisible if this button is visible, and vice-versa. -->
+        <Button android:id="@+id/manageConferencePhotoButton"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerHorizontal="true"
+                android:text="@string/onscreenManageConferenceText"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:textColor="?android:attr/textColorPrimary"
+                android:background="@drawable/manage_conference_photo_button"
+                android:layout_marginTop="16dip"
+            />
+
         <!-- Elapsed time indication for a call in progress. -->
         <TextView android:id="@+id/elapsedTime"
                   android:textAppearance="?android:attr/textAppearanceMedium"
diff --git a/res/layout/incall_touch_ui.xml b/res/layout/incall_touch_ui.xml
index d1264e4..dae34f2 100644
--- a/res/layout/incall_touch_ui.xml
+++ b/res/layout/incall_touch_ui.xml
@@ -87,20 +87,6 @@
                 android:text="@string/onscreenSwapCallsText" />
         </LinearLayout>
 
-        <!-- "Manage conference" (upper right) -->
-        <LinearLayout android:id="@+id/manageConferenceButtonContainer"
-                style="@style/InCallRoundButtonContainer"
-                android:layout_alignParentRight="true"
-                android:layout_marginRight="10dip"
-                android:visibility="gone">
-            <TextView
-                style="@style/InCallRoundButtonLabel"
-                android:text="@string/onscreenManageConferenceText" />
-            <ImageButton android:id="@+id/manageConferenceButton"
-                    style="@style/InCallRoundTouchButton"
-                    android:src="@drawable/ic_in_call_touch_round_manage_conference" />
-        </LinearLayout>
-
         <!-- DTMF dialpad shown in the upper part of the screen
              (above the main cluster of buttons.) -->
         <!-- TODO: this should be a ViewStub, and should only get inflated
diff --git a/src/com/android/phone/CallCard.java b/src/com/android/phone/CallCard.java
index 6e7b36d..94c6034 100755
--- a/src/com/android/phone/CallCard.java
+++ b/src/com/android/phone/CallCard.java
@@ -30,6 +30,7 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.Button;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -50,7 +51,7 @@
  */
 public class CallCard extends FrameLayout
         implements CallTime.OnTickListener, CallerInfoAsyncQuery.OnQueryCompleteListener,
-                ContactsAsyncHelper.OnImageLoadCompleteListener{
+                   ContactsAsyncHelper.OnImageLoadCompleteListener, View.OnClickListener {
     private static final String LOG_TAG = "CallCard";
     private static final boolean DBG = (PhoneApp.DBG_LEVEL >= 2);
 
@@ -83,6 +84,7 @@
     // The main block of info about the "primary" or "active" call,
     // including photo / name / phone number / etc.
     private ImageView mPhoto;
+    private Button mManageConferencePhotoButton;  // Possibly shown in place of mPhoto
     private TextView mName;
     private TextView mPhoneNumber;
     private TextView mLabel;
@@ -175,6 +177,8 @@
 
         // "Caller info" area, including photo / name / phone numbers / etc
         mPhoto = (ImageView) findViewById(R.id.photo);
+        mManageConferencePhotoButton = (Button) findViewById(R.id.manageConferencePhotoButton);
+        mManageConferencePhotoButton.setOnClickListener(this);
         mName = (TextView) findViewById(R.id.name);
         mPhoneNumber = (TextView) findViewById(R.id.phoneNumber);
         mLabel = (TextView) findViewById(R.id.label);
@@ -1059,6 +1063,10 @@
             ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(info, 0, this, call,
                     getContext(), mPhoto, personUri, -1);
         }
+        // And no matter what, on all devices, we never see the "manage
+        // conference" button in this state.
+        mManageConferencePhotoButton.setVisibility(View.INVISIBLE);
+
         if (displayNumber != null && !call.isGeneric()) {
             mPhoneNumber.setText(displayNumber);
             mPhoneNumber.setTextColor(mTextColorDefaultSecondary);
@@ -1119,9 +1127,16 @@
             showImage(mPhoto, R.drawable.picture_dialing);
             mName.setText(R.string.card_title_in_call);
         } else if (phoneType == Phone.PHONE_TYPE_GSM) {
-            // Display the "conference call" image in the photo slot,
-            // with no other information.
-            showImage(mPhoto, R.drawable.picture_conference);
+            if (mInCallScreen.isTouchUiEnabled()) {
+                // Display the "manage conference" button in place of the photo.
+                mManageConferencePhotoButton.setVisibility(View.VISIBLE);
+                mPhoto.setVisibility(View.INVISIBLE);  // Not GONE, since that would break
+                                                       // other views in our RelativeLayout.
+            } else {
+                // Display the "conference call" image in the photo slot,
+                // with no other information.
+                showImage(mPhoto, R.drawable.picture_conference);
+            }
             mName.setText(R.string.card_title_conf_call);
         } else {
             throw new IllegalStateException("Unexpected phone type: " + phoneType);
@@ -1303,18 +1318,6 @@
     }
 
     /**
-     * Intercepts (and discards) any touch events to the CallCard.
-     */
-    @Override
-    public boolean dispatchTouchEvent(MotionEvent ev) {
-        // if (DBG) log("CALLCARD: dispatchTouchEvent(): ev = " + ev);
-
-        // We *never* let touch events get thru to the UI inside the
-        // CallCard, since there's nothing touchable there.
-        return true;
-    }
-
-    /**
      * Returns the "Menu button hint" TextView (which is manipulated
      * directly by the InCallScreen.)
      * @see InCallScreen.updateMenuButtonHint()
@@ -1395,6 +1398,24 @@
         mRotarySelectorHintColorResId = hintColorResId;
     }
 
+    // View.OnClickListener implementation
+    public void onClick(View view) {
+        int id = view.getId();
+        if (DBG) log("onClick(View " + view + ", id " + id + ")...");
+
+        switch (id) {
+            case R.id.manageConferencePhotoButton:
+                // A click on anything here gets forwarded
+                // straight to the InCallScreen.
+                mInCallScreen.handleOnscreenButtonClick(id);
+                break;
+
+            default:
+                Log.w(LOG_TAG, "onClick: unexpected click: View " + view + ", id " + id);
+                break;
+        }
+    }
+
 
     // Debugging / testing code
 
diff --git a/src/com/android/phone/InCallScreen.java b/src/com/android/phone/InCallScreen.java
index 2c70ada..42ae3a0 100755
--- a/src/com/android/phone/InCallScreen.java
+++ b/src/com/android/phone/InCallScreen.java
@@ -597,7 +597,7 @@
         // move this block of code over to initInCallScreen().)
         //
         SlidingDrawer dialerDrawer;
-        if ((mInCallTouchUi != null) && mInCallTouchUi.isTouchUiEnabled()) {
+        if (isTouchUiEnabled()) {
             // This is a "full touch" device.
             mDialerView = (DTMFTwelveKeyDialerView) findViewById(R.id.non_drawer_dtmf_dialer);
             if (DBG) log("- Full touch device!  Found dialerView: " + mDialerView);
@@ -3149,7 +3149,7 @@
             case R.id.mergeButton:
                 PhoneUtils.mergeCalls(mPhone);
                 break;
-            case R.id.manageConferenceButton:
+            case R.id.manageConferencePhotoButton:
                 // Show the Manage Conference panel.
                 setInCallScreenMode(InCallScreenMode.MANAGE_CONFERENCE);
                 break;
@@ -3239,7 +3239,7 @@
 
         // The hint is also hidden on devices where we use onscreen
         // touchable buttons instead.
-        if ((mInCallTouchUi != null) && mInCallTouchUi.isTouchUiEnabled()) {
+        if (isTouchUiEnabled()) {
             hintVisible = false;
         }
 
@@ -3996,6 +3996,14 @@
     }
 
     /**
+     * @return true if the onscreen touch UI is enabled (for regular
+     * "ongoing call" states) on the current device.
+     */
+    public boolean isTouchUiEnabled() {
+        return (mInCallTouchUi != null) && mInCallTouchUi.isTouchUiEnabled();
+    }
+
+    /**
      * Posts a handler message telling the InCallScreen to update the
      * onscreen in-call touch UI.
      *
@@ -4074,7 +4082,7 @@
         // use onscreen touchable buttons instead.
         // TODO: even on "full touch" devices we may still ultimately need
         // a regular menu in some states.  Need UI spec.
-        if ((mInCallTouchUi != null) && mInCallTouchUi.isTouchUiEnabled()) {
+        if (isTouchUiEnabled()) {
             return null;
         }
 
diff --git a/src/com/android/phone/InCallTouchUi.java b/src/com/android/phone/InCallTouchUi.java
index 57377b1..7148b79 100644
--- a/src/com/android/phone/InCallTouchUi.java
+++ b/src/com/android/phone/InCallTouchUi.java
@@ -73,8 +73,6 @@
     private TextView mHoldButtonLabel;
     private View mSwapButtonContainer;
     private ImageButton mSwapButton;
-    private View mManageConferenceButtonContainer;
-    private ImageButton mManageConferenceButton;
     //
     private Drawable mHoldIcon;
     private Drawable mUnholdIcon;
@@ -162,12 +160,6 @@
         mSwapButtonContainer = mInCallControls.findViewById(R.id.swapButtonContainer);
         mSwapButton = (ImageButton) mInCallControls.findViewById(R.id.swapButton);
         mSwapButton.setOnClickListener(this);
-        //
-        mManageConferenceButtonContainer =
-                mInCallControls.findViewById(R.id.manageConferenceButtonContainer);
-        mManageConferenceButton =
-                (ImageButton) mInCallControls.findViewById(R.id.manageConferenceButton);
-        mManageConferenceButton.setOnClickListener(this);
 
         // Icons we need to change dynamically.  (Most other icons are specified
         // directly in incall_touch_ui.xml.)
@@ -270,7 +262,6 @@
             case R.id.speakerButton:
             case R.id.holdButton:
             case R.id.swapButton:
-            case R.id.manageConferenceButton:
                 // Clicks on the regular onscreen buttons get forwarded
                 // straight to the InCallScreen.
                 mInCallScreen.handleOnscreenButtonClick(id);
@@ -399,20 +390,11 @@
             Log.w(LOG_TAG, "updateInCallControls: Hold *and* Swap enabled, but can't show both!");
         }
 
-        // "Manage conference"
-        // This button is totally hidden (rather than just disabled)
-        // when the operation isn't available.
-        boolean showManageConferenceTouchButton = inCallControlState.manageConferenceVisible
-                && inCallControlState.manageConferenceEnabled;
-        mManageConferenceButtonContainer.setVisibility(
-                showManageConferenceTouchButton ? View.VISIBLE : View.GONE);
-
         // One final special case: if the dialpad is visible, that trumps
         // *any* of the upper corner buttons:
         if (inCallControlState.dialpadVisible) {
             mHoldButtonContainer.setVisibility(View.GONE);
             mSwapButtonContainer.setVisibility(View.GONE);
-            mManageConferenceButtonContainer.setVisibility(View.GONE);
         }
     }
 
@@ -424,7 +406,7 @@
      * @return true if the onscreen touch UI is enabled (for regular
      * "ongoing call" states) on the current device.
      */
-    public boolean isTouchUiEnabled() {
+    /* package */ boolean isTouchUiEnabled() {
         return mAllowInCallTouchUi;
     }