Merge "Restyle text in primary call info."
diff --git a/InCallUI/res/layout/call_card.xml b/InCallUI/res/layout/call_card.xml
index b254592..a8047f2 100644
--- a/InCallUI/res/layout/call_card.xml
+++ b/InCallUI/res/layout/call_card.xml
@@ -17,10 +17,10 @@
   -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:id="@+id/call_card"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
+    android:id="@+id/call_card"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
 
     <!-- The main content of the CallCard is either one or two "call info"
          blocks, depending on whether one or two lines are in use.
@@ -32,49 +32,49 @@
 
     <!-- Primary "call card" block, for the foreground call. -->
     <FrameLayout android:id="@+id/primary_call_info"
-            android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1">
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1">
 
         <!-- Contact photo for primary call info -->
         <ImageView android:id="@+id/photo"
-                android:layout_alignParentStart="true"
-                android:layout_alignParentTop="true"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:gravity="top|center_horizontal"
-                android:scaleType="centerCrop"
-                android:contentDescription="@string/contactPhoto"
-                android:src="@drawable/picture_unknown"/>
+            android:layout_alignParentStart="true"
+            android:layout_alignParentTop="true"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:gravity="top|center_horizontal"
+            android:scaleType="centerCrop"
+            android:contentDescription="@string/contactPhoto"
+            android:src="@drawable/picture_unknown"/>
 
         <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="vertical">
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
 
             <include android:id="@+id/primary_call_info"
-                    layout="@layout/primary_call_info" />
+                layout="@layout/primary_call_info" />
 
             <fragment android:name="com.android.incallui.CallButtonFragment"
-                    android:id="@+id/callButtonFragment"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content" />
+                android:id="@+id/callButtonFragment"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
         </LinearLayout>
 
         <ImageButton android:id="@+id/endButton"
-                style="@style/InCallEndButton"
-                android:layout_width="match_parent"
-                android:src="@drawable/ic_in_call_phone_hangup"
-                android:background="@drawable/end_call_background"
-                android:contentDescription="@string/onscreenEndCallText"
-                android:layout_gravity="bottom" />
+            style="@style/InCallEndButton"
+            android:layout_width="match_parent"
+            android:src="@drawable/ic_in_call_phone_hangup"
+            android:background="@drawable/end_call_background"
+            android:contentDescription="@string/onscreenEndCallText"
+            android:layout_gravity="bottom" />
     </FrameLayout>
 
     <!-- Secondary "Call info" block, for the background ("on hold") call. -->
     <ViewStub android:id="@+id/secondary_call_info"
-            android:layout="@layout/secondary_call_info"
-            android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1" />
+        android:layout="@layout/secondary_call_info"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
 
 </LinearLayout>
diff --git a/InCallUI/res/layout/incall_screen.xml b/InCallUI/res/layout/incall_screen.xml
index 06e8dac..d00b6bb 100644
--- a/InCallUI/res/layout/incall_screen.xml
+++ b/InCallUI/res/layout/incall_screen.xml
@@ -16,58 +16,58 @@
 
 <!-- In-call Phone UI; see InCallActivity.java. -->
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:id="@+id/main" >
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:id="@+id/main" >
 
     <LinearLayout android:id="@+id/in_call_and_button_container"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical" >
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical" >
 
         <LinearLayout android:id="@+id/in_call_card_container"
-                android:layout_width="match_parent"
-                android:layout_height="0dp"
-                android:layout_weight="1"
-                android:orientation="vertical" >
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1"
+            android:orientation="vertical" >
 
             <fragment android:name="com.android.incallui.CallCardFragment"
-                    android:id="@+id/callCardFragment"
-                    android:layout_width="match_parent"
-                    android:layout_height="0dp"
-                    android:layout_alignParentTop="true"
-                    android:layout_alignParentStart="true"
-                    android:layout_weight="1"/>
+                android:id="@+id/callCardFragment"
+                android:layout_width="match_parent"
+                android:layout_height="0dp"
+                android:layout_alignParentTop="true"
+                android:layout_alignParentStart="true"
+                android:layout_weight="1"/>
 
             <fragment android:name="com.android.incallui.DialpadFragment"
-                    android:id="@+id/dialpadFragment"
-                    android:layout_width="match_parent"
-                    android:layout_height="0dp"
-                    android:layout_alignParentTop="true"
-                    android:layout_alignParentStart="true"
-                    android:layout_weight="1" />
+                android:id="@+id/dialpadFragment"
+                android:layout_width="match_parent"
+                android:layout_height="0dp"
+                android:layout_alignParentTop="true"
+                android:layout_alignParentStart="true"
+                android:layout_weight="1" />
         </LinearLayout>
 
     </LinearLayout>
 
     <fragment android:name="com.android.incallui.AnswerFragment"
-            android:id="@+id/answerFragment"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_alignParentBottom="true"
-            android:layout_centerHorizontal="true"
-            android:gravity="top"
-            android:layout_gravity="bottom|center_horizontal"
-            android:layout_marginBottom="@dimen/glowpadview_margin_bottom"
-            android:visibility="gone" />
+        android:id="@+id/answerFragment"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_centerHorizontal="true"
+        android:gravity="top"
+        android:layout_gravity="bottom|center_horizontal"
+        android:layout_marginBottom="@dimen/glowpadview_margin_bottom"
+        android:visibility="gone" />
 
     <fragment android:name="com.android.incallui.ConferenceManagerFragment"
-            android:id="@+id/conferenceManagerFragment"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_alignParentTop="true"
-            android:layout_alignParentStart="true"
-            android:layout_alignParentBottom="true"
-            android:layout_alignParentEnd="true" />
+        android:id="@+id/conferenceManagerFragment"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_alignParentTop="true"
+        android:layout_alignParentStart="true"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentEnd="true" />
 
 </FrameLayout>
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 402008f..809568e 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -491,6 +491,10 @@
         return;
     }
 
+    public void setEndCallButtonEnabled(boolean enabled) {
+        mEndCallButton.setEnabled(enabled);
+    }
+
     private void dispatchPopulateAccessibilityEvent(AccessibilityEvent event, View view) {
         if (view == null) return;
         final List<CharSequence> eventText = event.getText();
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index 50179c4..33d99b7 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -194,6 +194,10 @@
         } else {
             ui.setCallState(Call.State.IDLE, DisconnectCause.NOT_VALID, false, null, null);
         }
+
+        final boolean enableEndCallButton = state.isConnectingOrConnected() &&
+                !state.isIncoming() && mPrimary != null;
+        ui.setEndCallButtonEnabled(enableEndCallButton);
     }
 
     @Override
@@ -478,5 +482,6 @@
         void setPrimaryImage(Drawable image);
         void setPrimaryPhoneNumber(String phoneNumber);
         void setPrimaryLabel(String label);
+        void setEndCallButtonEnabled(boolean enabled);
     }
 }