Make the contact picture exactly half the height as it is wide

Bug:5087954
Change-Id: Idb8a1bd61b4c8f95910d3c5c7255400d276af0d9
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml
index 02dd098..83d3e20 100644
--- a/res/layout/call_detail.xml
+++ b/res/layout/call_detail.xml
@@ -15,6 +15,7 @@
 -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="horizontal"
@@ -31,21 +32,30 @@
         <include layout="@layout/call_log_voicemail_status"/>
     </FrameLayout>
 
-    <ImageView
-        android:id="@+id/contact_background"
+    <view
+        class="com.android.contacts.widget.ProportionalLayout"
+        android:id="@+id/contact_background_sizer"
         android:layout_width="match_parent"
-        android:layout_height="@dimen/call_detail_contact_background_height"
+        android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_below="@id/voicemail_status"
-        android:adjustViewBounds="true"
-        android:scaleType="centerCrop"
-        android:background="@drawable/ic_contact_picture"
-    />
+        ex:ratio="0.5"
+        ex:direction="widthToHeight"
+    >
+        <ImageView
+            android:id="@+id/contact_background"
+            android:layout_width="match_parent"
+            android:layout_height="0dip"
+            android:adjustViewBounds="true"
+            android:scaleType="centerCrop"
+            android:background="@drawable/ic_contact_picture"
+        />
+    </view>
     <LinearLayout
         android:id="@+id/voicemail_container"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_below="@id/contact_background"
+        android:layout_below="@id/contact_background_sizer"
     >
         <fragment
             class="com.android.contacts.voicemail.VoicemailPlaybackFragment"
@@ -59,14 +69,14 @@
         android:layout_height="@dimen/call_detail_contact_background_overlay_height"
         android:background="#3F000000"
         android:layout_alignParentLeft="true"
-        android:layout_alignBottom="@id/contact_background"
+        android:layout_alignBottom="@id/contact_background_sizer"
     />
     <RelativeLayout
         android:id="@+id/contact_text"
         android:layout_width="match_parent"
         android:layout_height="@dimen/call_detail_contact_background_overlay_height"
         android:layout_alignParentLeft="true"
-        android:layout_alignBottom="@id/contact_background"
+        android:layout_alignBottom="@id/contact_background_sizer"
         android:paddingLeft="@dimen/call_detail_contact_name_margin"
     >
         <ImageView
diff --git a/res/layout/contact_detail_tab_carousel.xml b/res/layout/contact_detail_tab_carousel.xml
index 175194c..fe167d1 100644
--- a/res/layout/contact_detail_tab_carousel.xml
+++ b/res/layout/contact_detail_tab_carousel.xml
@@ -18,14 +18,14 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     class="com.android.contacts.detail.ContactDetailTabCarousel"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/detail_tab_carousel_height"
+    android:layout_height="wrap_content"
     android:scrollbars="none"
     android:fadingEdge="none">
 
     <LinearLayout
         android:id="@+id/tab_container"
         android:layout_width="match_parent"
-        android:layout_height="@dimen/detail_tab_carousel_height"
+        android:layout_height="match_parent"
         android:orientation="horizontal">
 
         <include
@@ -38,4 +38,4 @@
 
     </LinearLayout>
 
-</view>
\ No newline at end of file
+</view>
diff --git a/res/layout/contact_detail_updates_fragment.xml b/res/layout/contact_detail_updates_fragment.xml
index 92f3575..8677737 100644
--- a/res/layout/contact_detail_updates_fragment.xml
+++ b/res/layout/contact_detail_updates_fragment.xml
@@ -15,6 +15,7 @@
 -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts"
     android:id="@+id/contact_detail_updates_fragment"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
@@ -22,7 +23,6 @@
     <ScrollView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:paddingTop="@dimen/detail_tab_carousel_height"
         android:background="@color/background_social_updates">
 
         <LinearLayout
@@ -31,6 +31,21 @@
             android:layout_height="wrap_content"
             android:paddingTop="@dimen/detail_update_section_top_padding">
 
+            <!-- Add a first item that gives us enough space to show the carousel -->
+            <view
+                class="com.android.contacts.widget.ProportionalLayout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                ex:ratio="0.5"
+                ex:direction="widthToHeight">
+
+                <!-- Put a dummy view here because the ProportionalLayout requires one -->
+                <View
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent" />
+
+            </view>
+
             <include
                 android:id="@+id/title"
                 layout="@layout/contact_detail_kind_title_entry_view" />
@@ -43,6 +58,7 @@
                 android:paddingLeft="@dimen/detail_update_section_side_padding"
                 android:paddingRight="@dimen/detail_update_section_side_padding" />
         </LinearLayout>
+
     </ScrollView>
 
     <View
@@ -59,5 +75,5 @@
         android:layout_height="match_parent"
         android:background="@android:color/transparent"
         android:visibility="gone"/>
-</FrameLayout>
 
+</FrameLayout>
diff --git a/res/layout/detail_header_contact_with_updates.xml b/res/layout/detail_header_contact_with_updates.xml
index 00d1b76..8d18963 100644
--- a/res/layout/detail_header_contact_with_updates.xml
+++ b/res/layout/detail_header_contact_with_updates.xml
@@ -19,7 +19,15 @@
   entry maintains vertical padding to ensure that the first contact detail is visible (and below
   the tab carousel). No information has to be displayed in this header.
 -->
-<FrameLayout
+<view
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts"
+    class="com.android.contacts.widget.ProportionalLayout"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/detail_tab_carousel_height"/>
\ No newline at end of file
+    android:layout_height="wrap_content"
+    ex:ratio="0.5"
+    ex:direction="widthToHeight">
+    <FrameLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"/>
+</view>
\ No newline at end of file
diff --git a/res/layout/detail_header_contact_without_updates.xml b/res/layout/detail_header_contact_without_updates.xml
index a5d4687..2de7711 100644
--- a/res/layout/detail_header_contact_without_updates.xml
+++ b/res/layout/detail_header_contact_without_updates.xml
@@ -18,15 +18,17 @@
   This is a header entry in the contact details list for when the contact does not have social
   updates, which means that the contact's photo will scroll with the list of details.
 -->
-<FrameLayout
+<view
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts"
+    class="com.android.contacts.widget.ProportionalLayout"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content">
-
+    android:layout_height="wrap_content"
+    ex:ratio="0.5"
+    ex:direction="widthToHeight">
     <ImageView
         android:id="@+id/photo"
         android:scaleType="centerCrop"
         android:layout_width="match_parent"
-        android:layout_height="@dimen/detail_tab_carousel_height" />
-
-</FrameLayout>
\ No newline at end of file
+        android:layout_height="match_parent" />
+</view>
\ No newline at end of file
diff --git a/res/layout/quickcontact_activity.xml b/res/layout/quickcontact_activity.xml
index 7aa2aa4..2f5a357 100644
--- a/res/layout/quickcontact_activity.xml
+++ b/res/layout/quickcontact_activity.xml
@@ -15,6 +15,7 @@
 -->
 <view
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts"
     class="com.android.contacts.quickcontact.FloatingChildLayout"
     android:id="@+id/floating_layout"
     android:layout_width="match_parent"
@@ -29,7 +30,14 @@
         android:paddingLeft="15dip"
         android:paddingRight="15dip"
         android:orientation="vertical">
-        <include layout="@layout/quickcontact_photo_container" />
+        <view
+            class="com.android.contacts.widget.ProportionalLayout"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            ex:ratio="0.5"
+            ex:direction="widthToHeight">
+            <include layout="@layout/quickcontact_photo_container" />
+        </view>
         <View
             android:id="@+id/line_before_track"
             android:layout_width="match_parent"
diff --git a/res/layout/quickcontact_photo_container.xml b/res/layout/quickcontact_photo_container.xml
index 3e0c935..b18fddc 100644
--- a/res/layout/quickcontact_photo_container.xml
+++ b/res/layout/quickcontact_photo_container.xml
@@ -17,13 +17,13 @@
     xmlns:android="http://schemas.android.com/apk/res/android">
     <RelativeLayout
         android:id="@+id/photo_container"
-        android:layout_width="@dimen/quick_contact_picture_width"
-        android:layout_height="@dimen/quick_contact_picture_height"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         android:gravity="center_vertical">
         <ImageView
             android:id="@+id/photo"
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
             android:scaleType="centerCrop" />
         <View
             android:id="@+id/photo_text_bar"
@@ -68,7 +68,7 @@
             android:layout_marginTop="-3dip" />
         <TextView
             android:id="@+id/timestamp"
-            android:layout_width="fill_parent"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:singleLine="true"
             android:ellipsize="end"