Updates fragment dejunk

- Reuse stream item views.  Simplified the view layout for this.
(In this CL we still inflate views, rather than creating them in code.
Even without doing that performance now seems good enough.)

- Decode HTML into CharSequence in ContactLoader
- Removed ContactTileImageContainer and created
LayoutSuppressingImageView and LayoutSuppressingQuickContactBadge

Bug 5982899

Change-Id: I5cbd816a290a50fca9a964b921d934061915aee1
diff --git a/res/layout/contact_tile_frequent.xml b/res/layout/contact_tile_frequent.xml
index 5b51c78..992c643 100644
--- a/res/layout/contact_tile_frequent.xml
+++ b/res/layout/contact_tile_frequent.xml
@@ -24,19 +24,13 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent" >
 
-        <view
-            android:id="@+id/image_container"
-            class="com.android.contacts.list.ContactTileImageContainer"
+        <com.android.contacts.widget.LayoutSuppressingQuickContactBadge
+            android:id="@+id/contact_tile_quick"
             android:layout_width="64dip"
             android:layout_height="64dip"
-            android:layout_alignParentRight="true">
-            <QuickContactBadge
-                android:id="@+id/contact_tile_quick"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:scaleType="centerCrop"
-                android:focusable="true" />
-        </view>
+            android:layout_alignParentRight="true"
+            android:scaleType="centerCrop"
+            android:focusable="true" />
 
         <LinearLayout
             android:layout_width="match_parent"
@@ -77,7 +71,7 @@
             android:layout_width="match_parent"
             android:layout_height="1px"
             android:background="?android:attr/listDivider"
-            android:layout_below="@id/image_container" />
+            android:layout_below="@id/contact_tile_quick" />
 
     </RelativeLayout>
 
diff --git a/res/layout/contact_tile_frequent_phone.xml b/res/layout/contact_tile_frequent_phone.xml
index 5c7b7e2..cae5ec2 100644
--- a/res/layout/contact_tile_frequent_phone.xml
+++ b/res/layout/contact_tile_frequent_phone.xml
@@ -27,20 +27,14 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent" >
 
-        <view
-            android:id="@+id/image_container"
-            class="com.android.contacts.list.ContactTileImageContainer"
+        <com.android.contacts.widget.LayoutSuppressingQuickContactBadge
+            android:id="@id/contact_tile_quick"
             android:layout_width="64dip"
             android:layout_height="64dip"
-            android:layout_alignParentLeft="true">
-            <QuickContactBadge
-                android:id="@id/contact_tile_quick"
-                android:nextFocusRight="@id/contact_tile_frequent_phone"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:scaleType="centerCrop"
-                android:focusable="true" />
-        </view>
+            android:layout_alignParentLeft="true"
+            android:nextFocusRight="@id/contact_tile_frequent_phone"
+            android:scaleType="centerCrop"
+            android:focusable="true" />
 
         <TextView
             android:id="@+id/contact_tile_name"
@@ -49,7 +43,7 @@
             android:layout_marginLeft="8dip"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:layout_marginTop="8dip"
-            android:layout_toRightOf="@id/image_container"
+            android:layout_toRightOf="@id/contact_tile_quick"
             android:singleLine="true"
             android:fadingEdge="horizontal"
             android:fadingEdgeLength="3dip"
@@ -60,7 +54,7 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_below="@id/contact_tile_name"
-            android:layout_toRightOf="@id/image_container"
+            android:layout_toRightOf="@id/contact_tile_quick"
             android:gravity="center_vertical">
 
             <TextView
@@ -96,7 +90,7 @@
             android:layout_width="match_parent"
             android:layout_height="1px"
             android:background="?android:attr/listDivider"
-            android:layout_below="@id/image_container" />
+            android:layout_below="@id/contact_tile_quick" />
 
     </RelativeLayout>
 
diff --git a/res/layout/contact_tile_starred.xml b/res/layout/contact_tile_starred.xml
index 91438e9..cfc74d8 100644
--- a/res/layout/contact_tile_starred.xml
+++ b/res/layout/contact_tile_starred.xml
@@ -25,16 +25,11 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent" >
 
-        <view
-            class="com.android.contacts.list.ContactTileImageContainer"
+        <com.android.contacts.widget.LayoutSuppressingImageView
+            android:id="@+id/contact_tile_image"
             android:layout_width="match_parent"
-            android:layout_height="match_parent">
-            <ImageView
-                 android:id="@+id/contact_tile_image"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:scaleType="centerCrop" />
-        </view>
+            android:layout_height="match_parent"
+            android:scaleType="centerCrop" />
 
         <LinearLayout
             android:layout_width="match_parent"
diff --git a/res/layout/contact_tile_starred_quick_contact.xml b/res/layout/contact_tile_starred_quick_contact.xml
index 223f1b8..a396c41 100644
--- a/res/layout/contact_tile_starred_quick_contact.xml
+++ b/res/layout/contact_tile_starred_quick_contact.xml
@@ -24,16 +24,11 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent" >
 
-        <view
-            class="com.android.contacts.list.ContactTileImageContainer"
+        <com.android.contacts.widget.LayoutSuppressingImageView
+            android:id="@+id/contact_tile_image"
             android:layout_width="match_parent"
-            android:layout_height="match_parent">
-            <ImageView
-                android:id="@+id/contact_tile_image"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:scaleType="centerCrop" />
-        </view>
+            android:layout_height="match_parent"
+            android:scaleType="centerCrop" />
 
         <LinearLayout
             android:layout_width="match_parent"
diff --git a/res/layout/contact_tile_starred_secondary_target.xml b/res/layout/contact_tile_starred_secondary_target.xml
index 27ef3a3..ea15b86 100644
--- a/res/layout/contact_tile_starred_secondary_target.xml
+++ b/res/layout/contact_tile_starred_secondary_target.xml
@@ -24,16 +24,11 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent" >
 
-        <view
-            class="com.android.contacts.list.ContactTileImageContainer"
+        <com.android.contacts.widget.LayoutSuppressingImageView
+            android:id="@+id/contact_tile_image"
             android:layout_width="match_parent"
-            android:layout_height="match_parent">
-            <ImageView
-                android:id="@+id/contact_tile_image"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:scaleType="centerCrop" />
-        </view>
+            android:layout_height="match_parent"
+            android:scaleType="centerCrop" />
 
         <TextView
             android:id="@+id/contact_tile_name"
diff --git a/res/layout/stream_item_container.xml b/res/layout/stream_item_container.xml
index de4f87d..903f6b0 100644
--- a/res/layout/stream_item_container.xml
+++ b/res/layout/stream_item_container.xml
@@ -21,23 +21,56 @@
     android:paddingLeft="@dimen/detail_update_section_side_padding"
     android:paddingRight="@dimen/detail_update_section_side_padding">
 
+    <!-- Clickable area -->
     <LinearLayout
         android:id="@+id/stream_item_content"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingLeft="@dimen/detail_update_section_item_horizontal_padding"
-        android:paddingRight="@dimen/detail_update_section_item_horizontal_padding"
-        android:paddingTop="@dimen/detail_update_section_item_vertical_padding"
-        android:paddingBottom="@dimen/detail_update_section_item_vertical_padding"
         android:background="?android:attr/selectableItemBackground"
-        android:layout_gravity="center_vertical"
         android:orientation="vertical"
-        />
+        >
+
+        <!-- Images -->
+        <LinearLayout
+            android:id="@+id/stream_item_image_rows"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingLeft="@dimen/detail_update_section_item_horizontal_padding"
+            android:paddingRight="@dimen/detail_update_section_item_horizontal_padding"
+            android:paddingTop="@dimen/detail_update_section_item_vertical_padding"
+            android:paddingBottom="@dimen/detail_update_section_between_items_vertical_padding"
+            android:layout_gravity="center_vertical"
+            android:orientation="vertical"
+            >
+        </LinearLayout>
+
+        <!-- Text -->
+        <TextView android:id="@+id/stream_item_html"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textSize="16sp"
+            android:textColor="?android:attr/textColorPrimary" />
+        <TextView android:id="@+id/stream_item_attribution"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textAppearance="?android:attr/textAppearanceSmall"
+            android:textColor="?android:attr/textColorSecondary"
+            android:ellipsize="end"
+            android:maxLines="1" />
+        <TextView android:id="@+id/stream_item_comments"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="@dimen/detail_update_section_attribution_comments_padding"
+            android:textAppearance="?android:attr/textAppearanceSmall"
+            android:textColor="?android:attr/textColorSecondary"
+            android:maxLines="1"/>
+    </LinearLayout>
 
     <View
         android:id="@+id/horizontal_divider"
         android:layout_width="match_parent"
         android:layout_height="1px"
+        android:layout_marginTop="@dimen/detail_update_section_item_vertical_padding"
         android:background="?android:attr/dividerHorizontal"
         android:layout_gravity="bottom" />
 
diff --git a/res/layout/stream_item_photo.xml b/res/layout/stream_item_photo.xml
index 1fc3d0b..2649828 100644
--- a/res/layout/stream_item_photo.xml
+++ b/res/layout/stream_item_photo.xml
@@ -15,7 +15,7 @@
 -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android">
-    <ImageView
+    <com.android.contacts.widget.LayoutSuppressingImageView
         android:id="@+id/image"
         android:layout_width="match_parent"
         android:layout_height="match_parent"/>
diff --git a/res/layout/stream_item_row_two_images.xml b/res/layout/stream_item_row_images.xml
similarity index 97%
rename from res/layout/stream_item_row_two_images.xml
rename to res/layout/stream_item_row_images.xml
index 7858f6f..46e1f4f 100644
--- a/res/layout/stream_item_row_two_images.xml
+++ b/res/layout/stream_item_row_images.xml
@@ -37,6 +37,7 @@
     </view>
 
     <view
+        android:id="@+id/second_image_container"
         class="com.android.contacts.widget.ProportionalLayout"
         android:layout_width="0dip"
         android:layout_height="wrap_content"
diff --git a/res/layout/stream_item_row_one_image.xml b/res/layout/stream_item_row_one_image.xml
deleted file mode 100644
index 03dcedf..0000000
--- a/res/layout/stream_item_row_one_image.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<LinearLayout
-    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="wrap_content"
-    android:layout_marginTop="@dimen/detail_update_section_between_items_padding"
-    android:orientation="vertical">
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="horizontal"
-        android:weightSum="2">
-
-        <view
-            class="com.android.contacts.widget.ProportionalLayout"
-            android:layout_width="0dip"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:layout_marginRight="@dimen/detail_update_section_between_items_padding"
-            ex:ratio="1"
-            ex:direction="widthToHeight">
-
-            <include
-                android:id="@+id/stream_item_first_image"
-                layout="@layout/stream_item_photo"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"/>
-
-        </view>
-
-    </LinearLayout>
-
-</LinearLayout>
diff --git a/res/layout/stream_item_row_text.xml b/res/layout/stream_item_row_text.xml
deleted file mode 100644
index 919ee52..0000000
--- a/res/layout/stream_item_row_text.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical">
-
-    <TextView android:id="@+id/stream_item_html"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:textSize="16sp"
-        android:textColor="?android:attr/textColorPrimary" />
-
-    <LinearLayout
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
-
-        <TextView android:id="@+id/stream_item_attribution"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceSmall"
-            android:textColor="?android:attr/textColorSecondary"
-            android:ellipsize="end"
-            android:maxLines="1" />
-        <TextView android:id="@+id/stream_item_comments"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginLeft="@dimen/detail_update_section_attribution_comments_padding"
-            android:textAppearance="?android:attr/textAppearanceSmall"
-            android:textColor="?android:attr/textColorSecondary"
-            android:maxLines="1"/>
-
-    </LinearLayout>
-</LinearLayout>