Layout for Updates with multiple images.

Use a table layout to arrange images in the updates: if the number of
images is even (including no images), the text is placed on its own row.
Otherwise, the text is added together with the last image.

Bug: 5123875
Change-Id: I372a15a3d384fbea79a1cd9f225db3f05996f5d4
diff --git a/res/layout/stream_item_one_column.xml b/res/layout/stream_item_container.xml
similarity index 95%
rename from res/layout/stream_item_one_column.xml
rename to res/layout/stream_item_container.xml
index ecab57c..1f96aad 100644
--- a/res/layout/stream_item_one_column.xml
+++ b/res/layout/stream_item_container.xml
@@ -19,16 +19,16 @@
     android:layout_height="wrap_content"
     android:orientation="vertical">
 
-    <LinearLayout
+    <TableLayout
         android:id="@+id/stream_item_content"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:paddingTop="@dimen/detail_update_section_item_vertical_padding"
-        android:paddingBottom="@dimen/detail_update_section_item_vertical_padding"
+        android:paddingBottom="@dimen/detail_update_section_item_last_row_extra_vertical_padding"
         android:paddingLeft="@dimen/detail_update_section_item_horizontal_padding"
         android:paddingRight="@dimen/detail_update_section_item_horizontal_padding"
         android:background="@drawable/list_selector"
-        android:orientation="vertical" />
+        />
 
     <View
         android:id="@+id/horizontal_divider"
@@ -37,4 +37,5 @@
         android:layout_marginLeft="@dimen/detail_update_section_side_padding"
         android:layout_marginRight="@dimen/detail_update_section_side_padding"
         android:background="?android:attr/dividerHorizontal" />
+
 </LinearLayout>
diff --git a/res/layout/stream_item_pair.xml b/res/layout/stream_item_pair.xml
deleted file mode 100644
index 61b248c..0000000
--- a/res/layout/stream_item_pair.xml
+++ /dev/null
@@ -1,32 +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:orientation="horizontal"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content">
-
-    <FrameLayout android:id="@+id/stream_pair_first"
-        android:layout_width="0dip"
-        android:layout_height="wrap_content"
-        android:layout_weight="1" />
-
-    <FrameLayout android:id="@+id/stream_pair_second"
-        android:paddingLeft="@dimen/detail_update_section_internal_padding"
-        android:layout_width="0dip"
-        android:layout_height="wrap_content"
-        android:layout_weight="1" />
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/stream_item_row_image_and_text.xml b/res/layout/stream_item_row_image_and_text.xml
new file mode 100644
index 0000000..b6f6599
--- /dev/null
+++ b/res/layout/stream_item_row_image_and_text.xml
@@ -0,0 +1,77 @@
+<?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.
+-->
+
+<TableRow
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts"
+    android:paddingBottom="@dimen/detail_update_section_between_items_vertical_padding">
+
+    <view
+        class="com.android.contacts.widget.ProportionalLayout"
+        android:layout_width="0dip"
+        android:layout_height="wrap_content"
+        android:layout_marginRight="@dimen/detail_update_section_between_items_horizontal_padding"
+        android:layout_weight="1"
+        ex:ratio="1"
+        ex:direction="widthToHeight">
+        <ImageView
+            android:id="@+id/stream_item_first_image"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
+    </view>
+
+    <view
+        class="com.android.contacts.widget.ProportionalLayout"
+        android:layout_width="0dip"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        ex:ratio="1"
+        ex:direction="widthToHeight">
+        <LinearLayout
+            android:id="@+id/stream_item_second_text"
+            android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+
+            <TextView android:id="@+id/stream_item_html"
+                android:layout_width="match_parent"
+                android:layout_height="0dip"
+                android:layout_weight="1"
+                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" />
+
+                <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" />
+            </LinearLayout>
+
+        </LinearLayout>
+    </view>
+
+</TableRow>
diff --git a/res/layout/stream_item_text.xml b/res/layout/stream_item_row_text_only.xml
similarity index 76%
rename from res/layout/stream_item_text.xml
rename to res/layout/stream_item_row_text_only.xml
index 861d91f..d1d0efd 100644
--- a/res/layout/stream_item_text.xml
+++ b/res/layout/stream_item_row_text_only.xml
@@ -15,15 +15,16 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content">
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/detail_update_section_between_items_vertical_padding">
 
     <TextView android:id="@+id/stream_item_html"
-        android:layout_width="wrap_content"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:textSize="16sp"
-        android:textColor="@color/social_update_text_color" />
+        android:textColor="?android:attr/textColorPrimary" />
 
     <LinearLayout
         android:orientation="horizontal"
@@ -33,14 +34,13 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceSmall"
-            android:textColor="@color/social_update_attribution_color" />
+            android:textColor="?android:attr/textColorSecondary" />
 
         <TextView android:id="@+id/stream_item_comments"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginLeft="4dip"
+            android:layout_marginLeft="@dimen/detail_update_section_attribution_comments_padding"
             android:textAppearance="?android:attr/textAppearanceSmall"
-            android:textColor="@color/social_update_comments_color" />
+            android:textColor="?android:attr/textColorSecondary" />
     </LinearLayout>
-
 </LinearLayout>
diff --git a/res/layout/stream_item_row_two_images.xml b/res/layout/stream_item_row_two_images.xml
new file mode 100644
index 0000000..6e34b25
--- /dev/null
+++ b/res/layout/stream_item_row_two_images.xml
@@ -0,0 +1,49 @@
+<?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.
+-->
+
+<TableRow
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:ex="http://schemas.android.com/apk/res/com.android.contacts"
+    android:paddingBottom="@dimen/detail_update_section_between_items_vertical_padding">
+
+    <view
+        class="com.android.contacts.widget.ProportionalLayout"
+        android:layout_width="0dip"
+        android:layout_height="wrap_content"
+        android:layout_marginRight="@dimen/detail_update_section_between_items_horizontal_padding"
+        android:layout_weight="1"
+        ex:ratio="1"
+        ex:direction="widthToHeight">
+        <ImageView
+            android:id="@+id/stream_item_first_image"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
+    </view>
+
+    <view
+        class="com.android.contacts.widget.ProportionalLayout"
+        android:layout_width="0dip"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        ex:ratio="1"
+        ex:direction="widthToHeight">
+        <ImageView
+            android:id="@+id/stream_item_second_image"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
+    </view>
+
+</TableRow>