Makes the call details scrollable.

This change makes the call detail activity scrollable, making it easier
to see the details of multiple calls.

In order to make sure the main controls are always visible, it only
scrolls out the picture view, but always keeps the rest in view.

Bug: 5041805
Change-Id: I40b87efecfe3c921aab831e83dbff806b10b9c9f
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml
index 08b283a..714bbd8 100644
--- a/res/layout/call_detail.xml
+++ b/res/layout/call_detail.xml
@@ -19,178 +19,191 @@
     android:id="@+id/call_detail"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="horizontal"
-    android:gravity="top"
     android:visibility="gone"
 >
-    <FrameLayout
-        android:id="@+id/voicemail_status"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentTop="true"
-        android:visibility="gone"
-    >
-        <include layout="@layout/call_log_voicemail_status"/>
-    </FrameLayout>
-
-    <view
-        class="com.android.contacts.widget.ProportionalLayout"
-        android:id="@+id/contact_background_sizer"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentLeft="true"
-        android:layout_below="@id/voicemail_status"
-        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"
-        />
-    </view>
-    <LinearLayout
-        android:id="@+id/blue_separator"
-        android:layout_width="match_parent"
-        android:layout_height="1dip"
-        android:background="@android:color/holo_blue_light"
-        android:layout_below="@+id/contact_background_sizer"
-    />
-    <LinearLayout
-        android:id="@+id/voicemail_container"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_below="@id/blue_separator"
-    >
-        <!-- The voicemail fragment will be put here. -->
-    </LinearLayout>
-    <View
-        android:id="@+id/photo_text_bar"
-        android:layout_width="match_parent"
-        android:layout_height="42dip"
-        android:background="#7F000000"
-        android:layout_alignParentLeft="true"
-        android:layout_alignBottom="@id/contact_background_sizer"
-    />
-    <ImageView
-        android:id="@+id/main_action"
-        android:layout_width="wrap_content"
-        android:layout_height="0dip"
-        android:scaleType="center"
-        android:layout_alignRight="@id/photo_text_bar"
-        android:layout_alignBottom="@id/photo_text_bar"
-        android:layout_alignTop="@id/photo_text_bar"
-        android:layout_marginRight="@dimen/call_log_outer_margin"
-    />
-    <TextView
-        android:id="@+id/header_text"
-        android:layout_width="wrap_content"
-        android:layout_height="0dip"
-        android:layout_alignLeft="@id/photo_text_bar"
-        android:layout_toLeftOf="@id/main_action"
-        android:layout_alignTop="@id/photo_text_bar"
-        android:layout_alignBottom="@id/photo_text_bar"
-        android:layout_marginRight="@dimen/call_log_inner_margin"
-        android:layout_marginLeft="@dimen/call_detail_contact_name_margin"
-        android:gravity="center_vertical"
-        android:textColor="?attr/call_log_primary_text_color"
-        android:textSize="18sp"
-        android:singleLine="true"
-    />
-    <ImageButton
-        android:id="@+id/main_action_push_layer"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_alignLeft="@id/contact_background_sizer"
-        android:layout_alignTop="@id/contact_background_sizer"
-        android:layout_alignRight="@id/contact_background_sizer"
-        android:layout_alignBottom="@id/contact_background_sizer"
-        android:background="?android:attr/selectableItemBackground"
-    />
-    <FrameLayout android:id="@+id/call_and_sms_container"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_below="@id/voicemail_container"
-        android:layout_marginTop="@dimen/call_log_icon_margin"
-    >
-        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:id="@+id/call_and_sms"
-            android:layout_width="match_parent"
-            android:layout_height="@dimen/call_log_list_item_height"
-            android:orientation="horizontal"
-            android:layout_marginTop="@dimen/call_log_icon_margin"
-            android:gravity="center_vertical"
-            android:background="@drawable/dialpad_background"
-        >
-
-            <LinearLayout android:id="@+id/call_and_sms_main_action"
-                android:layout_width="0dip"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:paddingLeft="@dimen/call_log_indent_margin"
-                android:orientation="vertical"
-                android:gravity="center_vertical"
-                android:focusable="true"
-                android:background="@drawable/btn_dial"
-            >
-
-                <TextView android:id="@+id/call_and_sms_text1"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:textAppearance="?android:attr/textAppearanceLarge"
-                />
-
-                <LinearLayout android:id="@+id/call_and_sms_line2"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:orientation="horizontal"
-                >
-                    <TextView android:id="@+id/call_and_sms_label"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_marginRight="5dip"
-                        android:textAppearance="?android:attr/textAppearanceSmall"
-                        android:textStyle="bold"
-                    />
-
-                    <TextView android:id="@+id/call_and_sms_number"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:textAppearance="?android:attr/textAppearanceSmall"
-                    />
-                </LinearLayout>
-
-            </LinearLayout>
-
-            <View android:id="@+id/call_and_sms_divider"
-                android:layout_width="1px"
-                android:layout_height="32dip"
-                android:background="@drawable/ic_divider_dashed_holo_dark"
-                android:layout_gravity="center_vertical"
-            />
-
-            <ImageView android:id="@+id/call_and_sms_icon"
-                android:layout_width="@color/call_log_voicemail_highlight_color"
-                android:layout_height="match_parent"
-                android:paddingLeft="@dimen/call_log_inner_margin"
-                android:paddingRight="@dimen/call_log_outer_margin"
-                android:gravity="center"
-                android:scaleType="centerInside"
-                android:focusable="true"
-                android:background="@drawable/btn_dial"
-            />
-        </LinearLayout>
-    </FrameLayout>
+    <!--
+      The list view is under everything.
+      It contains a first header element which is hidden under the controls UI.
+      When scrolling, the controls move up until the name bar hits the top.
+      -->
     <ListView
         android:id="@+id/history"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginTop="@dimen/call_log_icon_margin"
         android:layout_alignParentLeft="true"
-        android:layout_below="@id/call_and_sms_container"
+        android:layout_alignParentTop="true"
         android:background="@android:color/black"
     />
+
+    <!-- All the controls which are part of the pinned header are in this layout. -->
+    <RelativeLayout
+        android:id="@+id/controls"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+    >
+        <FrameLayout
+            android:id="@+id/voicemail_status"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_alignParentLeft="true"
+            android:layout_alignParentTop="true"
+            android:visibility="gone"
+        >
+            <include layout="@layout/call_log_voicemail_status"/>
+        </FrameLayout>
+
+        <view
+            class="com.android.contacts.widget.ProportionalLayout"
+            android:id="@+id/contact_background_sizer"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_alignParentLeft="true"
+            android:layout_below="@id/voicemail_status"
+            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"
+            />
+        </view>
+        <LinearLayout
+            android:id="@+id/blue_separator"
+            android:layout_width="match_parent"
+            android:layout_height="1dip"
+            android:background="@android:color/holo_blue_light"
+            android:layout_below="@+id/contact_background_sizer"
+        />
+        <LinearLayout
+            android:id="@+id/voicemail_container"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/blue_separator"
+            android:background="@android:color/black"
+        >
+            <!-- The voicemail fragment will be put here. -->
+        </LinearLayout>
+        <View
+            android:id="@+id/photo_text_bar"
+            android:layout_width="match_parent"
+            android:layout_height="42dip"
+            android:background="#7F000000"
+            android:layout_alignParentLeft="true"
+            android:layout_alignBottom="@id/contact_background_sizer"
+        />
+        <ImageView
+            android:id="@+id/main_action"
+            android:layout_width="wrap_content"
+            android:layout_height="0dip"
+            android:scaleType="center"
+            android:layout_alignRight="@id/photo_text_bar"
+            android:layout_alignBottom="@id/photo_text_bar"
+            android:layout_alignTop="@id/photo_text_bar"
+            android:layout_marginRight="@dimen/call_log_outer_margin"
+        />
+        <TextView
+            android:id="@+id/header_text"
+            android:layout_width="wrap_content"
+            android:layout_height="0dip"
+            android:layout_alignLeft="@id/photo_text_bar"
+            android:layout_toLeftOf="@id/main_action"
+            android:layout_alignTop="@id/photo_text_bar"
+            android:layout_alignBottom="@id/photo_text_bar"
+            android:layout_marginRight="@dimen/call_log_inner_margin"
+            android:layout_marginLeft="@dimen/call_detail_contact_name_margin"
+            android:gravity="center_vertical"
+            android:textColor="?attr/call_log_primary_text_color"
+            android:textSize="18sp"
+            android:singleLine="true"
+        />
+        <ImageButton
+            android:id="@+id/main_action_push_layer"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_alignLeft="@id/contact_background_sizer"
+            android:layout_alignTop="@id/contact_background_sizer"
+            android:layout_alignRight="@id/contact_background_sizer"
+            android:layout_alignBottom="@id/contact_background_sizer"
+            android:background="?android:attr/selectableItemBackground"
+        />
+        <FrameLayout android:id="@+id/call_and_sms_container"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/voicemail_container"
+            android:background="@android:color/black"
+        >
+            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:id="@+id/call_and_sms"
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/call_log_list_item_height"
+                android:orientation="horizontal"
+                android:layout_marginTop="@dimen/call_log_icon_margin"
+                android:gravity="center_vertical"
+                android:background="@drawable/dialpad_background"
+            >
+
+                <LinearLayout android:id="@+id/call_and_sms_main_action"
+                    android:layout_width="0dip"
+                    android:layout_height="match_parent"
+                    android:layout_weight="1"
+                    android:paddingLeft="@dimen/call_log_indent_margin"
+                    android:orientation="vertical"
+                    android:gravity="center_vertical"
+                    android:focusable="true"
+                    android:background="@drawable/btn_dial"
+                >
+
+                    <TextView android:id="@+id/call_and_sms_text1"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:textAppearance="?android:attr/textAppearanceLarge"
+                    />
+
+                    <LinearLayout android:id="@+id/call_and_sms_line2"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:orientation="horizontal"
+                    >
+                        <TextView android:id="@+id/call_and_sms_label"
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:layout_marginRight="5dip"
+                            android:textAppearance="?android:attr/textAppearanceSmall"
+                            android:textStyle="bold"
+                        />
+
+                        <TextView android:id="@+id/call_and_sms_number"
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:textAppearance="?android:attr/textAppearanceSmall"
+                        />
+                    </LinearLayout>
+
+                </LinearLayout>
+
+                <View android:id="@+id/call_and_sms_divider"
+                    android:layout_width="1px"
+                    android:layout_height="32dip"
+                    android:background="@drawable/ic_divider_dashed_holo_dark"
+                    android:layout_gravity="center_vertical"
+                />
+
+                <ImageView android:id="@+id/call_and_sms_icon"
+                    android:layout_width="@color/call_log_voicemail_highlight_color"
+                    android:layout_height="match_parent"
+                    android:paddingLeft="@dimen/call_log_inner_margin"
+                    android:paddingRight="@dimen/call_log_outer_margin"
+                    android:gravity="center"
+                    android:scaleType="centerInside"
+                    android:focusable="true"
+                    android:background="@drawable/btn_dial"
+                />
+            </LinearLayout>
+        </FrameLayout>
+    </RelativeLayout>
 </RelativeLayout>