Merge "Import translations. DO NOT MERGE"
diff --git a/res/layout-land/contact_detail_updates_fragment.xml b/res/layout-land/contact_detail_updates_fragment.xml
deleted file mode 100644
index 801f2bb..0000000
--- a/res/layout-land/contact_detail_updates_fragment.xml
+++ /dev/null
@@ -1,30 +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.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/contact_detail_updates_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/background_social_updates">
-
- <ListView android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:fadingEdge="none"
- android:divider="@null"
- android:background="@android:color/transparent"/>
-
-</FrameLayout>
diff --git a/res/layout-land/updates_header_contact.xml b/res/layout-land/updates_header_contact.xml
deleted file mode 100644
index 844188e..0000000
--- a/res/layout-land/updates_header_contact.xml
+++ /dev/null
@@ -1,43 +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.
--->
-
-<!--
- This is a header entry in the contact updates list.
--->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="32dip"
- android:paddingLeft="16dip"
- android:paddingRight="16dip"
- android:paddingStart="16dip"
- android:paddingEnd="16dip"
- android:focusable="false">
-
- <TextView
- style="?android:attr/listSeparatorTextViewStyle"
- android:paddingLeft="8dip"
- android:paddingRight="8dip"
- android:paddingStart="8dip"
- android:paddingEnd="8dip"
- android:background="@drawable/list_section_divider_holo_custom"
- android:text="@string/recent_updates"
- android:textColor="@color/people_app_theme_color"
- android:textAllCaps="true"
- android:singleLine="true"
- android:ellipsize="end" />
-
-</FrameLayout>
diff --git a/res/layout-sw600dp-land/updates_header_contact.xml b/res/layout-sw600dp-land/updates_header_contact.xml
deleted file mode 100644
index eb0eee7..0000000
--- a/res/layout-sw600dp-land/updates_header_contact.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 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.
--->
-
-<!--
- This is a header entry in the contact updates list.
--->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:focusable="false">
-
- <TextView
- style="?android:attr/listSeparatorTextViewStyle"
- android:layout_height="32dip"
- android:paddingLeft="8dip"
- android:paddingRight="8dip"
- android:paddingStart="8dip"
- android:paddingEnd="8dip"
- android:background="@drawable/list_section_divider_holo_custom"
- android:text="@string/recent_updates"
- android:textColor="@color/people_app_theme_color"
- android:textAllCaps="true"
- android:singleLine="true"
- android:ellipsize="end" />
-
-</FrameLayout>
diff --git a/res/layout-sw600dp/contact_detail_updates_fragment.xml b/res/layout-sw600dp/contact_detail_updates_fragment.xml
deleted file mode 100644
index 537d68f..0000000
--- a/res/layout-sw600dp/contact_detail_updates_fragment.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.
--->
-
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/contact_detail_updates_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ListView android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fadingEdge="none"
- android:divider="@null"
- android:scrollbarStyle="outsideOverlay"
- android:paddingRight="12dip"
- android:paddingEnd="12dip" />
-
-</FrameLayout>
diff --git a/res/layout-sw720dp-land/updates_header_contact.xml b/res/layout-sw720dp-land/updates_header_contact.xml
deleted file mode 100644
index 8173f81..0000000
--- a/res/layout-sw720dp-land/updates_header_contact.xml
+++ /dev/null
@@ -1,40 +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.
--->
-
-<!--
- This is a header entry in the contact updates list.
--->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:focusable="false">
-
- <TextView
- style="?android:attr/listSeparatorTextViewStyle"
- android:layout_height="32dip"
- android:paddingLeft="8dip"
- android:paddingRight="8dip"
- android:paddingStart="8dip"
- android:paddingEnd="8dip"
- android:background="@drawable/list_section_divider_holo_custom"
- android:text="@string/recent_updates"
- android:textColor="@color/people_app_theme_color"
- android:textAllCaps="true"
- android:singleLine="true"
- android:ellipsize="end" />
-
-</FrameLayout>
diff --git a/res/layout/contact_detail_about_fragment_container.xml b/res/layout/contact_detail_about_fragment_container.xml
deleted file mode 100644
index 6fc9fe2..0000000
--- a/res/layout/contact_detail_about_fragment_container.xml
+++ /dev/null
@@ -1,25 +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.
--->
-
-<!--
- Container for the "About" page fragment on the contact card for a contact with social updates.
- This view ID must match with a view ID in the layout that is used after an orientation change.
--->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/about_fragment_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
\ No newline at end of file
diff --git a/res/layout/social_widget.xml b/res/layout/social_widget.xml
deleted file mode 100644
index 1267bd9..0000000
--- a/res/layout/social_widget.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#00000000">
- <LinearLayout
- android:id="@+id/widget_container"
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <FrameLayout
- android:layout_width="70dp"
- android:layout_height="70dp"
- android:layout_gravity="center_vertical">
- <ImageView
- android:id="@+id/image"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- <ImageButton
- android:id="@+id/border"
- android:background="@drawable/frame_thumbnail_contact_widget_holo"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </FrameLayout>
- <RelativeLayout
- android:id="@+id/name_and_snippet_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:paddingLeft="43dp"
- android:paddingRight="4dp"
- android:paddingStart="43dp"
- android:paddingEnd="4dp"
- android:paddingTop="4dp"
- android:paddingBottom="4dp"
- android:background="@drawable/bg_status_contact_widget">
- <TextView
- android:id="@+id/name_and_snippet"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:layout_alignParentTop="true"
- android:maxLines="3"
- android:lineSpacingExtra="2sp"
- android:textColor="#FFFFFFFF"
- android:textSize="@dimen/widget_text_size_snippet" />
- <TextView
- android:id="@+id/name"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:textColor="#FFFFFFFF"
- android:textSize="@dimen/widget_text_size_name" />
- </RelativeLayout>
- </LinearLayout>
-</FrameLayout>
diff --git a/res/layout/stream_item_container.xml b/res/layout/stream_item_container.xml
deleted file mode 100644
index 33840b6..0000000
--- a/res/layout/stream_item_container.xml
+++ /dev/null
@@ -1,93 +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"
- android:paddingLeft="@dimen/detail_update_section_side_padding"
- android:paddingRight="@dimen/detail_update_section_side_padding"
- android:paddingStart="@dimen/detail_update_section_side_padding"
- android:paddingEnd="@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:paddingStart="@dimen/detail_update_section_item_horizontal_padding"
- android:paddingEnd="@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:orientation="vertical"
- >
-
- <!-- Images -->
- <LinearLayout
- android:id="@+id/stream_item_image_rows"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- 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"
- android:textAlignment="viewStart" />
- <!--
- Attribution (e.g. timestamp) and comments (e.g. +1, like) should align horizontally.
- Can't merge this with the parent list view.
- -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
- <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:layout_marginStart="@dimen/detail_update_section_attribution_comments_padding"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorSecondary"
- android:maxLines="1"/>
- </LinearLayout>
- </LinearLayout>
-
- <View
- android:id="@+id/horizontal_divider"
- android:layout_width="match_parent"
- android:layout_height="1px"
- android:background="?android:attr/dividerHorizontal"
- android:layout_gravity="bottom" />
-
-</LinearLayout>
diff --git a/res/layout/stream_item_photo.xml b/res/layout/stream_item_photo.xml
deleted file mode 100644
index 9e27d2a..0000000
--- a/res/layout/stream_item_photo.xml
+++ /dev/null
@@ -1,27 +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.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android">
- <com.android.contacts.common.widget.LayoutSuppressingImageView
- android:id="@+id/image"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
- <View
- android:id="@+id/push_layer"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="?android:attr/selectableItemBackground"/>
-</FrameLayout>
diff --git a/res/layout/stream_item_row_images.xml b/res/layout/stream_item_row_images.xml
deleted file mode 100644
index a3f1325..0000000
--- a/res/layout/stream_item_row_images.xml
+++ /dev/null
@@ -1,57 +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-auto"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/detail_update_section_between_items_padding">
-
- <view
- class="com.android.contacts.common.widget.ProportionalLayout"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_marginRight="@dimen/detail_update_section_between_items_padding"
- android:layout_marginEnd="@dimen/detail_update_section_between_items_padding"
- android:layout_weight="1"
- 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>
-
- <view
- android:id="@+id/second_image_container"
- class="com.android.contacts.common.widget.ProportionalLayout"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/detail_update_section_between_items_padding"
- android:layout_marginStart="@dimen/detail_update_section_between_items_padding"
- android:layout_weight="1"
- ex:ratio="1"
- ex:direction="widthToHeight">
- <include
- android:id="@+id/stream_item_second_image"
- layout="@layout/stream_item_photo"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
- </view>
-
-</LinearLayout>
diff --git a/res/values-sw600dp-land/integers.xml b/res/values-sw600dp-land/integers.xml
index 8ce96de..ff17b6d 100644
--- a/res/values-sw600dp-land/integers.xml
+++ b/res/values-sw600dp-land/integers.xml
@@ -15,5 +15,4 @@
-->
<resources>
<integer name="contact_tile_column_count">3</integer>
- <integer name="updates_tab_snippet_max_lines">7</integer>
</resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 3e55240..8661ddc 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -24,9 +24,6 @@
<dimen name="shortcut_icon_size">64dip</dimen>
<dimen name="list_section_height">37dip</dimen>
<dimen name="group_detail_border_padding">16dip</dimen>
- <dimen name="detail_update_section_side_padding">0dip</dimen>
- <dimen name="detail_update_section_item_horizontal_padding">8dip</dimen>
- <dimen name="detail_update_section_item_vertical_padding">16dip</dimen>
<dimen name="search_view_width">400dip</dimen>
<dimen name="contact_tile_list_padding_top">16dip</dimen>
<!-- Center vertically -->
diff --git a/res/values-sw600dp/integers.xml b/res/values-sw600dp/integers.xml
index a62fa14..c629f7e 100644
--- a/res/values-sw600dp/integers.xml
+++ b/res/values-sw600dp/integers.xml
@@ -15,5 +15,4 @@
-->
<resources>
<integer name="contact_tile_column_count">2</integer>
- <integer name="updates_tab_snippet_max_lines">4</integer>
</resources>
diff --git a/res/values-sw720dp/integers.xml b/res/values-sw720dp/integers.xml
index eaf5971..c629f7e 100644
--- a/res/values-sw720dp/integers.xml
+++ b/res/values-sw720dp/integers.xml
@@ -15,5 +15,4 @@
-->
<resources>
<integer name="contact_tile_column_count">2</integer>
- <integer name="updates_tab_snippet_max_lines">7</integer>
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 362001d..f2ed2b8 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -30,12 +30,6 @@
<!-- Color used for the letter in the A-Z section header -->
<color name="section_header_text_color">#363636</color>
- <!-- Color of the text in the updates tab in the tab carousel on the contact detail page -->
- <color name="detail_update_tab_text_color">#777777</color>
-
- <!-- Color of the text of the tab carousel in the contact details -->
- <color name="detail_tab_carousel_tab_label_color">#EEEEEE</color>
-
<!-- Color of the background of the action bar -->
<color name="action_bar_background">#e6e6e6</color>
@@ -45,7 +39,4 @@
<!-- Color of the text for buttons in the action bar -->
<color name="action_bar_button_text_color">#FFFFFF</color>
- <!-- Color of the vertical stripe that goes on the left of a block quote inside a stream item -->
- <color name="stream_item_stripe_color">#CCCCCC</color>
-
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 598846a..40b4665 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -47,33 +47,6 @@
<!-- Height of the shadow asset under the photo on the contact detail page -->
<dimen name="detail_contact_photo_shadow_height">10dip</dimen>
- <!-- Height of the tab text label in the tab carousel on the contact detail page -->
- <dimen name="detail_tab_carousel_tab_label_height">45dip</dimen>
-
- <!-- Height of the tab text label in the tab carousel on the contact detail page -->
- <dimen name="detail_tab_carousel_tab_label_indent">24dip</dimen>
-
- <!-- Left and right padding of the text within the update tab in the tab carousel -->
- <dimen name="detail_update_tab_side_padding">24dip</dimen>
-
- <!-- Left and right padding of the update section in the contact detail card -->
- <dimen name="detail_update_section_side_padding">16dip</dimen>
-
- <!-- Vertical padding above and below individual stream items -->
- <dimen name="detail_update_section_item_vertical_padding">16dip</dimen>
-
- <!-- Vertical padding between text and images in a single stream item -->
- <dimen name="detail_update_section_between_items_vertical_padding">8dip</dimen>
-
- <!-- Horizontal padding for individual stream items -->
- <dimen name="detail_update_section_item_horizontal_padding">8dip</dimen>
-
- <!-- Padding between images in a single stream item -->
- <dimen name="detail_update_section_between_items_padding">1dip</dimen>
-
- <!-- Horizontal padding between attribution and comments -->
- <dimen name="detail_update_section_attribution_comments_padding">4dip</dimen>
-
<!-- Margin around the contact's photo on the contact card -->
<dimen name="detail_contact_photo_margin">8dip</dimen>
@@ -152,9 +125,6 @@
<dimen name="contact_filter_header_min_height">24dip</dimen>
- <!-- Width of the lead margin on the left of a block quote inside a stream item -->
- <dimen name="stream_item_stripe_width">8dip</dimen>
-
<!-- Max width of the SearchView when the contact picker is a dialog (on wide
screen devices). -->
<dimen name="contact_picker_search_view_max_width">550dip</dimen>
diff --git a/res/values/integers.xml b/res/values/integers.xml
index e742ba0..6e312ae 100644
--- a/res/values/integers.xml
+++ b/res/values/integers.xml
@@ -17,7 +17,4 @@
<resources>
<!-- Determines the number of columns in a ContactTileRow -->
<integer name="contact_tile_column_count">2</integer>
-
- <!-- Max lines to display of a contact's snippet in the "updates" tab of the contact card tab carousel -->
- <integer name="updates_tab_snippet_max_lines">3</integer>
</resources>
diff --git a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
index e1aa217..48aa0f7 100644
--- a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
+++ b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
@@ -16,7 +16,16 @@
package com.android.contacts.detail;
-import android.content.ContentUris;
+import com.google.common.collect.Iterables;
+
+import com.android.contacts.R;
+import com.android.contacts.common.model.Contact;
+import com.android.contacts.common.model.RawContact;
+import com.android.contacts.common.model.dataitem.DataItem;
+import com.android.contacts.common.model.dataitem.OrganizationDataItem;
+import com.android.contacts.common.preference.ContactsPreferences;
+import com.android.contacts.util.MoreMath;
+
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -24,37 +33,17 @@
import android.content.res.Resources.NotFoundException;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.provider.ContactsContract;
import android.provider.ContactsContract.DisplayNameSources;
import android.provider.ContactsContract.Preferences;
-import android.provider.ContactsContract.StreamItems;
import android.text.Html;
-import android.text.Html.ImageGetter;
import android.text.TextUtils;
import android.util.Log;
-import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
-import com.android.contacts.common.ContactPhotoManager;
-import com.android.contacts.R;
-import com.android.contacts.common.model.Contact;
-import com.android.contacts.common.model.RawContact;
-import com.android.contacts.common.model.dataitem.DataItem;
-import com.android.contacts.common.model.dataitem.OrganizationDataItem;
-import com.android.contacts.common.preference.ContactsPreferences;
-import com.android.contacts.util.StreamItemEntry;
-import com.android.contacts.util.ContactBadgeUtil;
-import com.android.contacts.util.HtmlUtils;
-import com.android.contacts.util.MoreMath;
-import com.android.contacts.util.StreamItemPhotoEntry;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Iterables;
-
import java.util.List;
/**
@@ -66,31 +55,6 @@
private static final String TAG = "ContactDetailDisplayUtils";
/**
- * Tag object used for stream item photos.
- */
- public static class StreamPhotoTag {
- public final StreamItemEntry streamItem;
- public final StreamItemPhotoEntry streamItemPhoto;
-
- public StreamPhotoTag(StreamItemEntry streamItem, StreamItemPhotoEntry streamItemPhoto) {
- this.streamItem = streamItem;
- this.streamItemPhoto = streamItemPhoto;
- }
-
- public Uri getStreamItemPhotoUri() {
- final Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
- ContentUris.appendId(builder, streamItem.getId());
- builder.appendPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
- ContentUris.appendId(builder, streamItemPhoto.getId());
- return builder.build();
- }
- }
-
- private ContactDetailDisplayUtils() {
- // Disallow explicit creation of this class.
- }
-
- /**
* Returns the display name of the contact, using the current display order setting.
* Returns res/string/missing_name if there is no display name.
*/
@@ -223,147 +187,6 @@
}
/**
- * Set the social snippet text. If there isn't one, then set the view to gone.
- */
- public static void setSocialSnippet(Context context, Contact contactData, TextView statusView,
- ImageView statusPhotoView) {
- if (statusView == null) {
- return;
- }
-
- CharSequence snippet = null;
- String photoUri = null;
- setDataOrHideIfNone(snippet, statusView);
- if (photoUri != null) {
- ContactPhotoManager.getInstance(context).loadPhoto(
- statusPhotoView, Uri.parse(photoUri), -1, false,
- ContactPhotoManager.DEFAULT_BLANK);
- statusPhotoView.setVisibility(View.VISIBLE);
- } else {
- statusPhotoView.setVisibility(View.GONE);
- }
- }
-
- /** Creates the view that represents a stream item. */
- public static View createStreamItemView(LayoutInflater inflater, Context context,
- View convertView, StreamItemEntry streamItem, View.OnClickListener photoClickListener) {
-
- // Try to recycle existing views.
- final View container;
- if (convertView != null) {
- container = convertView;
- } else {
- container = inflater.inflate(R.layout.stream_item_container, null, false);
- }
-
- final ContactPhotoManager contactPhotoManager = ContactPhotoManager.getInstance(context);
- final List<StreamItemPhotoEntry> photos = streamItem.getPhotos();
- final int photoCount = photos.size();
-
- // Add the text part.
- addStreamItemText(context, streamItem, container);
-
- // Add images.
- final ViewGroup imageRows = (ViewGroup) container.findViewById(R.id.stream_item_image_rows);
-
- if (photoCount == 0) {
- // This stream item only has text.
- imageRows.setVisibility(View.GONE);
- } else {
- // This stream item has text and photos.
- imageRows.setVisibility(View.VISIBLE);
-
- // Number of image rows needed, which is cailing(photoCount / 2)
- final int numImageRows = (photoCount + 1) / 2;
-
- // Actual image rows.
- final int numOldImageRows = imageRows.getChildCount();
-
- // Make sure we have enough stream_item_row_images.
- if (numOldImageRows == numImageRows) {
- // Great, we have the just enough number of rows...
-
- } else if (numOldImageRows < numImageRows) {
- // Need to add more image rows.
- for (int i = numOldImageRows; i < numImageRows; i++) {
- View imageRow = inflater.inflate(R.layout.stream_item_row_images, imageRows,
- true);
- }
- } else {
- // We have exceeding image rows. Hide them.
- for (int i = numImageRows; i < numOldImageRows; i++) {
- imageRows.getChildAt(i).setVisibility(View.GONE);
- }
- }
-
- // Put images, two by two.
- for (int i = 0; i < photoCount; i += 2) {
- final View imageRow = imageRows.getChildAt(i / 2);
- // Reused image rows may not visible, so make sure they're shown.
- imageRow.setVisibility(View.VISIBLE);
-
- // Show first image.
- loadPhoto(contactPhotoManager, streamItem, photos.get(i), imageRow,
- R.id.stream_item_first_image, photoClickListener);
- final View secondContainer = imageRow.findViewById(R.id.second_image_container);
- if (i + 1 < photoCount) {
- // Show the second image too.
- loadPhoto(contactPhotoManager, streamItem, photos.get(i + 1), imageRow,
- R.id.stream_item_second_image, photoClickListener);
- secondContainer.setVisibility(View.VISIBLE);
- } else {
- // Hide the second image, but it still has to occupy the space.
- secondContainer.setVisibility(View.INVISIBLE);
- }
- }
- }
-
- return container;
- }
-
- /** Loads a photo into an image view. The image view is identified by the given id. */
- private static void loadPhoto(ContactPhotoManager contactPhotoManager,
- final StreamItemEntry streamItem, final StreamItemPhotoEntry streamItemPhoto,
- View photoContainer, int imageViewId, View.OnClickListener photoClickListener) {
- final View frame = photoContainer.findViewById(imageViewId);
- final View pushLayerView = frame.findViewById(R.id.push_layer);
- final ImageView imageView = (ImageView) frame.findViewById(R.id.image);
- if (photoClickListener != null) {
- pushLayerView.setOnClickListener(photoClickListener);
- pushLayerView.setTag(new StreamPhotoTag(streamItem, streamItemPhoto));
- pushLayerView.setFocusable(true);
- pushLayerView.setEnabled(true);
- } else {
- pushLayerView.setOnClickListener(null);
- pushLayerView.setTag(null);
- pushLayerView.setFocusable(false);
- // setOnClickListener makes it clickable, so we need to overwrite it
- pushLayerView.setClickable(false);
- pushLayerView.setEnabled(false);
- }
- contactPhotoManager.loadPhoto(imageView, Uri.parse(streamItemPhoto.getPhotoUri()), -1,
- false, ContactPhotoManager.DEFAULT_BLANK);
- }
-
- @VisibleForTesting
- static View addStreamItemText(Context context, StreamItemEntry streamItem, View rootView) {
- TextView htmlView = (TextView) rootView.findViewById(R.id.stream_item_html);
- TextView attributionView = (TextView) rootView.findViewById(
- R.id.stream_item_attribution);
- TextView commentsView = (TextView) rootView.findViewById(R.id.stream_item_comments);
- ImageGetter imageGetter = new DefaultImageGetter(context.getPackageManager());
-
- // Stream item text
- setDataOrHideIfNone(streamItem.getDecodedText(), htmlView);
- // Attribution
- setDataOrHideIfNone(ContactBadgeUtil.getSocialDate(streamItem, context),
- attributionView);
- // Comments
- setDataOrHideIfNone(streamItem.getDecodedComments(), commentsView);
- return rootView;
- }
-
- /**
* Sets the display name of this contact to the given {@link TextView}. If
* there is none, then set the view to gone.
*/
diff --git a/src/com/android/contacts/group/GroupDetailFragment.java b/src/com/android/contacts/group/GroupDetailFragment.java
index 834e2c3..b3716ed 100644
--- a/src/com/android/contacts/group/GroupDetailFragment.java
+++ b/src/com/android/contacts/group/GroupDetailFragment.java
@@ -20,6 +20,7 @@
import android.app.Fragment;
import android.app.LoaderManager;
import android.app.LoaderManager.LoaderCallbacks;
+import android.content.ActivityNotFoundException;
import android.content.ContentUris;
import android.content.Context;
import android.content.CursorLoader;
@@ -44,6 +45,7 @@
import android.widget.AbsListView.OnScrollListener;
import android.widget.ListView;
import android.widget.TextView;
+import android.widget.Toast;
import com.android.contacts.GroupMemberLoader;
import com.android.contacts.GroupMetaDataLoader;
@@ -381,7 +383,13 @@
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setClassName(accountType.syncAdapterPackageName,
accountType.getViewGroupActivity());
- startActivity(intent);
+ try {
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Log.e(TAG, "startActivity() failed: " + e);
+ Toast.makeText(getActivity(), R.string.missing_app,
+ Toast.LENGTH_SHORT).show();
+ }
}
});
} else if (mGroupSourceView != null) {
diff --git a/src/com/android/contacts/util/ContactBadgeUtil.java b/src/com/android/contacts/util/ContactBadgeUtil.java
deleted file mode 100644
index 82a6820..0000000
--- a/src/com/android/contacts/util/ContactBadgeUtil.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.contacts.util;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.text.TextUtils;
-import android.text.format.DateUtils;
-import android.util.Log;
-
-import com.android.contacts.common.ContactPhotoManager;
-import com.android.contacts.util.StreamItemEntry;
-import com.android.contacts.R;
-
-/**
- * Provides static functions to extract summary information for aggregate contacts
- */
-public class ContactBadgeUtil {
- private static final String TAG = "ContactBadgeUtil";
-
- /**
- * Returns the social snippet attribution for the given stream item entry, including the date.
- */
- public static CharSequence getSocialDate(StreamItemEntry streamItem, Context context) {
- final CharSequence timestampDisplayValue;
- final Long statusTimestamp = streamItem.getTimestamp();
- if (statusTimestamp != null) {
- // Set the date/time field by mixing relative and absolute
- // times.
- int flags = DateUtils.FORMAT_ABBREV_RELATIVE;
-
- timestampDisplayValue = DateUtils.getRelativeTimeSpanString(
- statusTimestamp.longValue(), System.currentTimeMillis(),
- DateUtils.MINUTE_IN_MILLIS, flags);
- } else {
- timestampDisplayValue = null;
- }
-
-
- String labelDisplayValue = null;
-
- final String statusLabelRes = streamItem.getLabelRes();
- final String statusResPackage = streamItem.getResPackage();
-
- // Package name used for resources.getIdentifier()
- String identiferPackage = statusResPackage;
- if (statusLabelRes != null) {
- Resources resources;
- if (TextUtils.isEmpty(statusResPackage)) {
- resources = context.getResources();
- // In this case, we're using the framework resources.
- identiferPackage = "android";
- } else {
- PackageManager pm = context.getPackageManager();
- try {
- resources = pm.getResourcesForApplication(statusResPackage);
- } catch (NameNotFoundException e) {
- Log.w(TAG, "Contact status update resource package not found: "
- + statusResPackage);
- resources = null;
- }
- }
-
- if (resources != null) {
- final int resId = resources.getIdentifier(statusLabelRes, "string",
- identiferPackage);
- if (resId == 0) {
- Log.w(TAG, "Contact status update resource not found: " + statusLabelRes +
- " in " + statusResPackage);
- } else {
- labelDisplayValue = resources.getString(resId);
- }
- }
- }
-
- final CharSequence attribution;
- if (timestampDisplayValue != null && labelDisplayValue != null) {
- attribution = context.getString(
- R.string.contact_status_update_attribution_with_date,
- timestampDisplayValue, labelDisplayValue);
- } else if (timestampDisplayValue == null && labelDisplayValue != null) {
- attribution = context.getString(
- R.string.contact_status_update_attribution,
- labelDisplayValue);
- } else if (timestampDisplayValue != null) {
- attribution = timestampDisplayValue;
- } else {
- attribution = null;
- }
- return attribution;
- }
-
- public static Bitmap loadDefaultAvatarPhoto(Context context, boolean hires, boolean darkTheme) {
- return BitmapFactory.decodeResource(context.getResources(),
- ContactPhotoManager.getDefaultAvatarResId(hires, darkTheme));
- }
-}
diff --git a/src/com/android/contacts/util/HtmlUtils.java b/src/com/android/contacts/util/HtmlUtils.java
deleted file mode 100644
index edcda13..0000000
--- a/src/com/android/contacts/util/HtmlUtils.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.contacts.util;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.text.Html;
-import android.text.Html.ImageGetter;
-import android.text.Html.TagHandler;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.TextUtils;
-import android.text.style.ImageSpan;
-import android.text.style.QuoteSpan;
-
-import com.android.contacts.R;
-import com.google.common.annotations.VisibleForTesting;
-
-/**
- * Provides static functions to perform custom HTML to text conversions.
- * Specifically, it adjusts the color and padding of the vertical
- * stripe on block quotes and alignment of inlined images.
- */
-@VisibleForTesting
-public class HtmlUtils {
-
- /**
- * Converts HTML string to a {@link Spanned} text, adjusting formatting. Any extra new line
- * characters at the end of the text will be trimmed.
- */
- public static Spanned fromHtml(Context context, String text) {
- if (TextUtils.isEmpty(text)) {
- return null;
- }
- Spanned spanned = Html.fromHtml(text);
- return postprocess(context, spanned);
- }
-
- /**
- * Converts HTML string to a {@link Spanned} text, adjusting formatting and using a custom
- * image getter. Any extra new line characters at the end of the text will be trimmed.
- */
- public static CharSequence fromHtml(Context context, String text, ImageGetter imageGetter,
- TagHandler tagHandler) {
- if (TextUtils.isEmpty(text)) {
- return null;
- }
- return postprocess(context, Html.fromHtml(text, imageGetter, tagHandler));
- }
-
- /**
- * Replaces some spans with custom versions of those. Any extra new line characters at the end
- * of the text will be trimmed.
- */
- @VisibleForTesting
- static Spanned postprocess(Context context, Spanned original) {
- if (original == null) {
- return null;
- }
- final int length = original.length();
- if (length == 0) {
- return original; // Bail early.
- }
-
- // If it's a SpannableStringBuilder, just use it. Otherwise, create a new
- // SpannableStringBuilder based on the passed Spanned.
- final SpannableStringBuilder builder;
- if (original instanceof SpannableStringBuilder) {
- builder = (SpannableStringBuilder) original;
- } else {
- builder = new SpannableStringBuilder(original);
- }
-
- final QuoteSpan[] quoteSpans = builder.getSpans(0, length, QuoteSpan.class);
- if (quoteSpans != null && quoteSpans.length != 0) {
- Resources resources = context.getResources();
- int color = resources.getColor(R.color.stream_item_stripe_color);
- int width = resources.getDimensionPixelSize(R.dimen.stream_item_stripe_width);
- for (int i = 0; i < quoteSpans.length; i++) {
- replaceSpan(builder, quoteSpans[i], new StreamItemQuoteSpan(color, width));
- }
- }
-
- final ImageSpan[] imageSpans = builder.getSpans(0, length, ImageSpan.class);
- if (imageSpans != null) {
- for (int i = 0; i < imageSpans.length; i++) {
- ImageSpan span = imageSpans[i];
- replaceSpan(builder, span, new ImageSpan(span.getDrawable(),
- ImageSpan.ALIGN_BASELINE));
- }
- }
-
- // Trim the trailing new line characters at the end of the text (which can be added
- // when HTML block quote tags are turned into new line characters).
- int end = length;
- for (int i = builder.length() - 1; i >= 0; i--) {
- if (builder.charAt(i) != '\n') {
- break;
- }
- end = i;
- }
-
- // If there's no trailing newlines, just return it.
- if (end == length) {
- return builder;
- }
-
- // Otherwise, Return a substring of the original {@link Spanned} text
- // from the start index (inclusive) to the end index (exclusive).
- return new SpannableStringBuilder(builder, 0, end);
- }
-
- /**
- * Replaces one span with the other.
- */
- private static void replaceSpan(SpannableStringBuilder builder, Object originalSpan,
- Object newSpan) {
- builder.setSpan(newSpan,
- builder.getSpanStart(originalSpan),
- builder.getSpanEnd(originalSpan),
- builder.getSpanFlags(originalSpan));
- builder.removeSpan(originalSpan);
- }
-
- public static class StreamItemQuoteSpan extends QuoteSpan {
- private final int mWidth;
-
- public StreamItemQuoteSpan(int color, int width) {
- super(color);
- this.mWidth = width;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getLeadingMargin(boolean first) {
- return mWidth;
- }
- }
-}
diff --git a/src/com/android/contacts/util/StreamItemEntry.java b/src/com/android/contacts/util/StreamItemEntry.java
deleted file mode 100644
index e5696a1..0000000
--- a/src/com/android/contacts/util/StreamItemEntry.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.contacts.util;
-
-import android.content.Context;
-import android.database.Cursor;
-import android.provider.ContactsContract.StreamItems;
-import android.text.Html;
-
-import com.android.contacts.detail.ContactDetailDisplayUtils;
-import com.android.contacts.common.test.NeededForTesting;
-
-import com.google.common.annotations.VisibleForTesting;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Data object for a social stream item. Social stream items may contain multiple
- * mPhotos. Social stream item entries are comparable; entries with more recent
- * timestamps will be displayed on top.
- */
-public class StreamItemEntry implements Comparable<StreamItemEntry> {
-
- // Basic stream item fields.
- private final long mId;
- private final String mText;
- private final String mComments;
- private final long mTimestamp;
- private final String mAccountType;
- private final String mAccountName;
- private final String mDataSet;
-
- private boolean mDecoded;
- private CharSequence mDecodedText;
- private CharSequence mDecodedComments;
-
- // Package references for label and icon resources.
- private final String mResPackage;
- private final String mIconRes;
- private final String mLabelRes;
-
- // Photos associated with this stream item.
- private List<StreamItemPhotoEntry> mPhotos;
-
- @NeededForTesting
- public static StreamItemEntry createForTest(long id, String text, String comments,
- long timestamp, String accountType, String accountName, String dataSet,
- String resPackage, String iconRes, String labelRes) {
- return new StreamItemEntry(id, text, comments, timestamp, accountType, accountName, dataSet,
- resPackage, iconRes, labelRes);
- }
-
- private StreamItemEntry(long id, String text, String comments, long timestamp,
- String accountType, String accountName, String dataSet, String resPackage,
- String iconRes, String labelRes) {
- mId = id;
- mText = text;
- mComments = comments;
- mTimestamp = timestamp;
- mAccountType = accountType;
- mAccountName = accountName;
- mDataSet = dataSet;
- mResPackage = resPackage;
- mIconRes = iconRes;
- mLabelRes = labelRes;
- mPhotos = new ArrayList<StreamItemPhotoEntry>();
- }
-
- public StreamItemEntry(Cursor cursor) {
- // This is expected to be populated via a cursor containing all StreamItems columns in
- // its projection.
- mId = getLong(cursor, StreamItems._ID);
- mText = getString(cursor, StreamItems.TEXT);
- mComments = getString(cursor, StreamItems.COMMENTS);
- mTimestamp = getLong(cursor, StreamItems.TIMESTAMP);
- mAccountType = getString(cursor, StreamItems.ACCOUNT_TYPE);
- mAccountName = getString(cursor, StreamItems.ACCOUNT_NAME);
- mDataSet = getString(cursor, StreamItems.DATA_SET);
- mResPackage = getString(cursor, StreamItems.RES_PACKAGE);
- mIconRes = getString(cursor, StreamItems.RES_ICON);
- mLabelRes = getString(cursor, StreamItems.RES_LABEL);
- mPhotos = new ArrayList<StreamItemPhotoEntry>();
- }
-
- public void addPhoto(StreamItemPhotoEntry photoEntry) {
- mPhotos.add(photoEntry);
- }
-
- @Override
- public int compareTo(StreamItemEntry other) {
- return mTimestamp == other.mTimestamp ? 0 : mTimestamp > other.mTimestamp ? -1 : 1;
- }
-
- public long getId() {
- return mId;
- }
-
- public String getText() {
- return mText;
- }
-
- public String getComments() {
- return mComments;
- }
-
- public long getTimestamp() {
- return mTimestamp;
- }
-
- public String getAccountType() {
- return mAccountType;
- }
-
- public String getAccountName() {
- return mAccountName;
- }
-
- public String getDataSet() {
- return mDataSet;
- }
-
- public String getResPackage() {
- return mResPackage;
- }
-
- public String getIconRes() {
- return mIconRes;
- }
-
- public String getLabelRes() {
- return mLabelRes;
- }
-
- public List<StreamItemPhotoEntry> getPhotos() {
- Collections.sort(mPhotos);
- return mPhotos;
- }
-
- /**
- * Make {@link #getDecodedText} and {@link #getDecodedComments} available. Must be called
- * before calling those.
- *
- * We can't do this automatically in the getters, because it'll require a {@link Context}.
- */
- @VisibleForTesting
- public void decodeHtml(Context context) {
- final Html.ImageGetter imageGetter = ContactDetailDisplayUtils.getImageGetter(context);
- if (mText != null) {
- mDecodedText = HtmlUtils.fromHtml(context, mText, imageGetter, null);
- }
- if (mComments != null) {
- mDecodedComments = HtmlUtils.fromHtml(context, mComments, imageGetter, null);
- }
- mDecoded = true;
- }
-
- public CharSequence getDecodedText() {
- checkDecoded();
- return mDecodedText;
- }
-
- public CharSequence getDecodedComments() {
- checkDecoded();
- return mDecodedComments;
- }
-
- private void checkDecoded() {
- if (!mDecoded) {
- throw new IllegalStateException("decodeHtml must have been called");
- }
- }
-
- private static String getString(Cursor cursor, String columnName) {
- return cursor.getString(cursor.getColumnIndex(columnName));
- }
-
- private static long getLong(Cursor cursor, String columnName) {
- final int columnIndex = cursor.getColumnIndex(columnName);
- return cursor.getLong(columnIndex);
- }
-}
diff --git a/src/com/android/contacts/util/StreamItemPhotoEntry.java b/src/com/android/contacts/util/StreamItemPhotoEntry.java
deleted file mode 100644
index ad69e5c..0000000
--- a/src/com/android/contacts/util/StreamItemPhotoEntry.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.contacts.util;
-
-import android.database.Cursor;
-import android.provider.ContactsContract.PhotoFiles;
-import android.provider.ContactsContract.StreamItemPhotos;
-
-/**
- * Data object for a photo associated with a social stream item. These are comparable;
- * entries with a lower sort index will be displayed on top (with the ID used as a
- * tie-breaker).
- */
-public class StreamItemPhotoEntry implements Comparable<StreamItemPhotoEntry> {
- private final long mId;
- private final int mSortIndex;
- private final long mPhotoFileId;
- private final String mPhotoUri;
- private final int mHeight;
- private final int mWidth;
- private final int mFileSize;
-
- public StreamItemPhotoEntry(long id, int sortIndex, long photoFileId, String photoUri,
- int height, int width, int fileSize) {
- mId = id;
- mSortIndex = sortIndex;
- mPhotoFileId = photoFileId;
- mPhotoUri = photoUri;
- mHeight = height;
- mWidth = width;
- mFileSize = fileSize;
- }
-
- public StreamItemPhotoEntry(Cursor cursor) {
- // This is expected to be populated via a cursor containing a join of all
- // StreamItemPhotos columns and all PhotoFiles columns (except for ID).
- mId = getLong(cursor, StreamItemPhotos._ID);
- mSortIndex = getInt(cursor, StreamItemPhotos.SORT_INDEX, -1);
- mPhotoFileId = getLong(cursor, StreamItemPhotos.PHOTO_FILE_ID);
- mPhotoUri = getString(cursor, StreamItemPhotos.PHOTO_URI);
- mHeight = getInt(cursor, PhotoFiles.HEIGHT, -1);
- mWidth = getInt(cursor, PhotoFiles.WIDTH, -1);
- mFileSize = getInt(cursor, PhotoFiles.FILESIZE, -1);
- }
-
- public long getId() {
- return mId;
- }
-
- public int getSortIndex() {
- return mSortIndex;
- }
-
- public long getPhotoFileId() {
- return mPhotoFileId;
- }
-
- public String getPhotoUri() {
- return mPhotoUri;
- }
-
- public int getHeight() {
- return mHeight;
- }
-
- public int getWidth() {
- return mWidth;
- }
-
- public int getFileSize() {
- return mFileSize;
- }
-
- @Override
- public int compareTo(StreamItemPhotoEntry streamItemPhotoEntry) {
- // Sort index is used to compare, falling back to ID if neither entry has a
- // sort index specified (entries without a sort index are sorted after entries
- // that have one).
- if (mSortIndex == streamItemPhotoEntry.mSortIndex) {
- if (mSortIndex == -1) {
- return mId == streamItemPhotoEntry.mId ? 0
- : mId < streamItemPhotoEntry.mId ? -1 : 1;
- } else {
- return 0;
- }
- } else {
- if (mSortIndex == -1) {
- return 1;
- }
- if (streamItemPhotoEntry.mSortIndex == -1) {
- return -1;
- }
- return mSortIndex == streamItemPhotoEntry.mSortIndex ? 0
- : mSortIndex < streamItemPhotoEntry.mSortIndex ? -1 : 1;
- }
- }
-
- private static String getString(Cursor cursor, String columnName) {
- return cursor.getString(cursor.getColumnIndex(columnName));
- }
-
- private static int getInt(Cursor cursor, String columnName, int missingValue) {
- final int columnIndex = cursor.getColumnIndex(columnName);
- return cursor.isNull(columnIndex) ? missingValue : cursor.getInt(columnIndex);
- }
-
- private static long getLong(Cursor cursor, String columnName) {
- final int columnIndex = cursor.getColumnIndex(columnName);
- return cursor.getLong(columnIndex);
- }
-}
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 7a7df01..46e7ac3 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -76,16 +76,6 @@
</intent-filter>
</activity>
- <activity android:name=".streamitems.StreamItemPopulatorActivity"
- android:label="@string/streamItemPopulator"
- >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
<!--
Test authenticators/sync adapters.
diff --git a/tests/res/layout/stream_item_populator.xml b/tests/res/layout/stream_item_populator.xml
deleted file mode 100644
index acc46bf..0000000
--- a/tests/res/layout/stream_item_populator.xml
+++ /dev/null
@@ -1,37 +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="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
->
- <Button
- android:id="@+id/add"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/chooseAContactButton"
- android:layout_marginBottom="50px"
- />
- <Button
- android:id="@+id/exit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/exitButton"
- />
-</LinearLayout>
diff --git a/tests/res/values/donottranslate_strings.xml b/tests/res/values/donottranslate_strings.xml
index b3f3ee7..44283ff 100644
--- a/tests/res/values/donottranslate_strings.xml
+++ b/tests/res/values/donottranslate_strings.xml
@@ -97,10 +97,7 @@
<string name="useRandomNumbers">Use random numbers</string>
<string name="addedLogEntriesToast">Added %1$d call log entries.</string>
<string name="noLogEntriesToast">No entries in the call log yet. Need at least one record for the template. Or use random numbers.</string>
-
- <string name="chooseAContactButton">Choose a contact to add stream items to</string>
<string name="exitButton">Exit</string>
- <string name="streamItemPopulator">Populate stream items</string>
<string-array name="pinnedHeaderUseCases">
<item>One short section - no headers</item>
diff --git a/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java b/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java
deleted file mode 100644
index 07b3691..0000000
--- a/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.contacts.detail;
-
-import android.content.Context;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.text.Html;
-import android.text.Spanned;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.TextView;
-
-import com.android.contacts.R;
-import com.android.contacts.util.StreamItemEntry;
-import com.android.contacts.util.StreamItemEntryBuilder;
-
-/**
- * Unit tests for {@link ContactDetailDisplayUtils}.
- */
-@SmallTest
-public class ContactDetailDisplayUtilsTest extends AndroidTestCase {
- private static final String TEST_STREAM_ITEM_TEXT = "text";
-
- private LayoutInflater mLayoutInflater;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mLayoutInflater =
- (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testAddStreamItemText_IncludesComments() {
- StreamItemEntry streamItem = getTestBuilder().setComment("1 comment").build(getContext());
- View streamItemView = addStreamItemText(streamItem);
- assertHasText(streamItemView, R.id.stream_item_comments, "1 comment");
- }
-
- public void testAddStreamItemText_IncludesHtmlComments() {
- StreamItemEntry streamItem = getTestBuilder().setComment("1 <b>comment</b>")
- .build(getContext());
- View streamItemView = addStreamItemText(streamItem);
- assertHasHtmlText(streamItemView, R.id.stream_item_comments, "1 <b>comment<b>");
- }
-
- public void testAddStreamItemText_NoComments() {
- StreamItemEntry streamItem = getTestBuilder().setComment(null).build(getContext());
- View streamItemView = addStreamItemText(streamItem);
- assertGone(streamItemView, R.id.stream_item_comments);
- }
-
- /** Checks that the given id corresponds to a visible text view with the expected text. */
- private void assertHasText(View parent, int textViewId, String expectedText) {
- TextView textView = (TextView) parent.findViewById(textViewId);
- assertNotNull(textView);
- assertEquals(View.VISIBLE, textView.getVisibility());
- assertEquals(expectedText, textView.getText().toString());
- }
-
- /** Checks that the given id corresponds to a visible text view with the expected HTML. */
- private void assertHasHtmlText(View parent, int textViewId, String expectedHtml) {
- TextView textView = (TextView) parent.findViewById(textViewId);
- assertNotNull(textView);
- assertEquals(View.VISIBLE, textView.getVisibility());
- assertSpannableEquals(Html.fromHtml(expectedHtml), textView.getText());
- }
-
- /**
- * Asserts that a char sequence is actually a {@link Spanned} matching the one expected.
- */
- private void assertSpannableEquals(Spanned expected, CharSequence actualCharSequence) {
- assertEquals(expected.toString(), actualCharSequence.toString());
- assertTrue("char sequence should be an instance of Spanned",
- actualCharSequence instanceof Spanned);
- Spanned actual = (Spanned) actualCharSequence;
- assertEquals(Html.toHtml(expected), Html.toHtml(actual));
- }
-
- /** Checks that the given id corresponds to a gone view. */
- private void assertGone(View parent, int textId) {
- View view = parent.findViewById(textId);
- assertNotNull(view);
- assertEquals(View.GONE, view.getVisibility());
- }
-
- /**
- * Calls {@link ContactDetailDisplayUtils#addStreamItemText(LayoutInflater, Context,
- * StreamItemEntry, View)} with the default parameters and the given stream item.
- */
- private View addStreamItemText(StreamItemEntry streamItem) {
- return ContactDetailDisplayUtils.addStreamItemText(getContext(), streamItem,
- mLayoutInflater.inflate(R.layout.stream_item_container, null));
- }
-
- private StreamItemEntryBuilder getTestBuilder() {
- return new StreamItemEntryBuilder().setText(TEST_STREAM_ITEM_TEXT);
- }
-}
diff --git a/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java b/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java
deleted file mode 100644
index 9132e40..0000000
--- a/tests/src/com/android/contacts/tests/streamitems/StreamItemPopulatorActivity.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.contacts.tests.streamitems;
-
-import android.app.Activity;
-import android.content.ContentProviderOperation;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Intent;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.RawContacts;
-import android.provider.ContactsContract.StreamItemPhotos;
-import android.provider.ContactsContract.StreamItems;
-import android.view.View;
-import android.widget.Button;
-import android.widget.Toast;
-
-import com.android.contacts.common.model.account.GoogleAccountType;
-import com.android.contacts.tests.R;
-import com.google.common.collect.Lists;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Random;
-
-/**
- * Testing activity that will populate stream items and stream item photos to selected
- * entries in the user's contacts list.
- *
- * The contact selected must have at least one raw contact that was provided by Google.
- */
-public class StreamItemPopulatorActivity extends Activity {
-
- // Test data to randomly select from.
- private String[] snippetStrings = new String[]{
- "Just got back from a vacation in %1$s - what a great place! Can't wait to go back.",
- "If I never see %1$s again it will be too soon.",
- "This is a public service announcement. If you were even close to considering visiting"
- + " %1$s, I strongly advise you to reconsider. The food was terrible, the people were "
- + "rude, the hygiene of the bus and taxi drivers was positively <i>barbaric</i>. I "
- + "feared for my life almost the entire time I was there, and feel lucky to be back "
- + "<b>home</b>.",
- "Check out these pictures! I took them in %1$s"
- };
-
- private String[] placeNames = new String[]{
- "the Google campus in Mountain View",
- "the deserts on Arrakis",
- "Iceland",
- "Japan",
- "Sydney",
- "San Francisco",
- "Munich",
- "Istanbul",
- "Tanagra",
- "the restricted section of Area 51",
- "the middle of nowhere"
- };
-
- private String[] commentStrings = new String[]{
- "3 retweets",
- "5 shares",
- "4 likes",
- "4 +1s",
- "<i>24567</i> <font color='blue' size='+1'><b>likes</b></font>"
- };
-
- private String[] labelResources = new String[] {
- "attribution_google_plus",
- "attribution_google_talk",
- "attribution_flicker",
- "attribution_twitter"
- };
-
- public String[] iconResources = new String[] {
- "default_icon"
- };
-
- // Photos to randomly select from.
- private Integer[] imageIds = new Integer[]{
- R.drawable.android,
- R.drawable.goldengate,
- R.drawable.iceland,
- R.drawable.japan,
- R.drawable.sydney,
- R.drawable.wharf,
- R.drawable.whiskey
- };
-
- // Only some photos have actions.
- private String[] imageStrings = new String[]{
- "android",
- "goldengate",
- "iceland",
- "japan",
- };
-
- // The contact ID that was picked.
- private long mContactId = -1;
-
- private Random mRandom;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- mRandom = new Random(System.currentTimeMillis());
-
- setContentView(R.layout.stream_item_populator);
- Button pickButton = (Button) findViewById(R.id.add);
- pickButton.setOnClickListener(new View.OnClickListener(){
- @Override
- public void onClick(View v) {
- // Reset the contact ID.
- mContactId = -1;
-
- // Forward the Intent to the picker
- final Intent pickerIntent =
- new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
- pickerIntent.setFlags(
- Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivityForResult(pickerIntent, 0);
- }
- });
-
- Button exitButton = (Button) findViewById(R.id.exit);
- exitButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- });
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == Activity.RESULT_OK) {
- Uri contactUri = data.getData();
- mContactId = ContentUris.parseId(contactUri);
- }
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- if (mContactId != -1) {
- long rawContactId = -1;
- String accountType = null;
- String accountName = null;
- String dataSet = null;
-
- // Lookup the com.google raw contact for the contact.
- Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
- new String[]{
- RawContacts._ID,
- RawContacts.ACCOUNT_TYPE,
- RawContacts.ACCOUNT_NAME
- },
- RawContacts.CONTACT_ID + "=? AND " + RawContacts.ACCOUNT_TYPE + "=?",
- new String[]{String.valueOf(mContactId), GoogleAccountType.ACCOUNT_TYPE}, null);
- try {
- c.moveToFirst();
- rawContactId = c.getLong(0);
- accountType = c.getString(1);
- accountName = c.getString(2);
- } finally {
- c.close();
- }
- if (rawContactId != -1) {
- addStreamItemsToRawContact(rawContactId, accountType, accountName);
- } else {
- Toast.makeText(this,
- "Failed to find raw contact ID for contact ID " + mContactId, 5).show();
- }
- }
- }
-
- protected byte[] loadPhotoFromResource(int resourceId) {
- InputStream is = getResources().openRawResource(resourceId);
- return readInputStreamFully(is);
- }
-
- protected byte[] readInputStreamFully(InputStream is) {
- try {
- byte[] buffer = new byte[is.available()];
- is.read(buffer);
- is.close();
- return buffer;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void addStreamItemsToRawContact(long rawContactId, String accountType,
- String accountName) {
- ArrayList<ContentProviderOperation> ops = Lists.newArrayList();
-
- // Add from 1-5 stream items.
- int itemsToAdd = randInt(5) + 1;
- int opCount = 0;
- for (int i = 0; i < itemsToAdd; i++) {
- ContentValues streamItemValues = buildStreamItemValues(accountType, accountName);
- ops.add(ContentProviderOperation.newInsert(
- Uri.withAppendedPath(
- ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI,
- rawContactId),
- ContactsContract.RawContacts.StreamItems.CONTENT_DIRECTORY))
- .withValues(streamItemValues).build());
-
- // Maybe add photos - 30% chance per stream item.
- boolean includePhotos = randInt(100) < 30;
- if (includePhotos) {
- // Add 1-5 photos if we're including any.
- int numPhotos = randInt(5) + 1;
- for (int j = 0; j < numPhotos; j++) {
- ContentValues streamItemPhotoValues =
- buildStreamItemPhotoValues(j, accountType, accountName);
- ops.add(ContentProviderOperation.newInsert(StreamItems.CONTENT_PHOTO_URI)
- .withValues(streamItemPhotoValues)
- .withValueBackReference(StreamItemPhotos.STREAM_ITEM_ID, opCount)
- .build());
- }
- opCount += numPhotos;
- }
- opCount++;
- }
- try {
- getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
- } catch (Exception e) {
- // We don't care. This is just for test purposes.
- throw new RuntimeException(e);
- }
- Toast.makeText(this, "Added " + itemsToAdd + " stream item(s) and "
- + (opCount - itemsToAdd) + " photos", 5).show();
- }
-
- private ContentValues buildStreamItemValues(String accountType, String accountName) {
- boolean includeAttribution = randInt(100) < 70;
- boolean includeComments = randInt(100) < 30;
- boolean includeAction = randInt(100) < 30;
- ContentValues values = new ContentValues();
- String place = pickRandom(placeNames);
- values.put(StreamItems.TEXT,
- String.format(pickRandom(snippetStrings) , place)
- + (includeComments ? " [c]" : "")
- + (includeAction ? " [a]" : ""));
- if (includeAttribution) {
- values.put(StreamItems.RES_PACKAGE, "com.android.contacts.tests");
- int sourceIndex = randInt(labelResources.length);
- values.put(StreamItems.RES_LABEL, labelResources[sourceIndex]);
- if (sourceIndex < iconResources.length) {
- values.put(StreamItems.RES_ICON, iconResources[sourceIndex]);
- }
- }
- if (includeComments) {
- values.put(StreamItems.COMMENTS, pickRandom(commentStrings));
- } else {
- values.put(StreamItems.COMMENTS, "");
- }
- // Set the timestamp to some point in the past.
- values.put(StreamItems.TIMESTAMP,
- System.currentTimeMillis() - randInt(360000000));
- values.put(RawContacts.ACCOUNT_TYPE, accountType);
- values.put(RawContacts.ACCOUNT_NAME, accountName);
- return values;
- }
-
- private ContentValues buildStreamItemPhotoValues(int index, String accountType,
- String accountName) {
- Integer imageIndex = pickRandom(imageIds);
- ContentValues values = new ContentValues();
- values.put(StreamItemPhotos.SORT_INDEX, index);
- values.put(StreamItemPhotos.PHOTO, loadPhotoFromResource(imageIndex));
- values.put(RawContacts.ACCOUNT_TYPE, accountType);
- values.put(RawContacts.ACCOUNT_NAME, accountName);
- return values;
- }
-
- private <T> T pickRandom(T[] from) {
- return from[randInt(from.length)];
- }
-
- private int randInt(int max) {
- return Math.abs(mRandom.nextInt()) % max;
- }
-}
diff --git a/tests/src/com/android/contacts/util/HtmlUtilsTest.java b/tests/src/com/android/contacts/util/HtmlUtilsTest.java
deleted file mode 100644
index 772e78f..0000000
--- a/tests/src/com/android/contacts/util/HtmlUtilsTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.contacts.util;
-
-import android.graphics.drawable.ColorDrawable;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.SpannedString;
-import android.text.style.ImageSpan;
-import android.text.style.QuoteSpan;
-
-import com.android.contacts.util.HtmlUtils.StreamItemQuoteSpan;
-
-/**
- * Tests for {@link HtmlUtils}.
- *
- * adb shell am instrument -w -e class com.android.contacts.util.HtmlUtilsTest \
- com.android.contacts.tests/android.test.InstrumentationTestRunner
- */
-@SmallTest
-public class HtmlUtilsTest extends AndroidTestCase {
- /**
- * Test for {@link HtmlUtils#postprocess} specifically about trimming newlines.
- */
- public void testPostProcess_trimNewLines() {
- checkTrimNewLines("", "");
- checkTrimNewLines("", "\n");
- checkTrimNewLines("", "\n\n");
- checkTrimNewLines("a", "a");
- checkTrimNewLines("abc", "abc");
- checkTrimNewLines("abc", "abc\n");
- checkTrimNewLines("abc", "abc\n\n\n");
- checkTrimNewLines("ab\nc", "ab\nc\n");
-
- assertNull(HtmlUtils.postprocess(getContext(), null));
- }
-
- private final void checkTrimNewLines(String expectedString, CharSequence text) {
- // Test with both SpannedString and SpannableStringBuilder.
- assertEquals(expectedString,
- HtmlUtils.postprocess(getContext(), new SpannedString(text)).toString());
-
- assertEquals(expectedString,
- HtmlUtils.postprocess(getContext(), new SpannableStringBuilder(text)).toString());
- }
-
- public void testPostProcess_with_newlines() {
- final SpannableStringBuilder builder = new SpannableStringBuilder("01234\n\n");
-
- setSpans(builder);
-
- // First test with a SpannableStringBuilder, as opposed to SpannedString
- checkPostProcess(HtmlUtils.postprocess(getContext(), builder));
-
- // Then pass a SpannedString, which is immutable, but the method should still work.
- checkPostProcess(HtmlUtils.postprocess(getContext(), new SpannedString(builder)));
- }
-
- /**
- * Same as {@link #testPostProcess_with_newlines}, but text has no newlines.
- * (The internal code path is slightly different.)
- */
- public void testPostProcess_no_newlines() {
- final SpannableStringBuilder builder = new SpannableStringBuilder("01234");
-
- setSpans(builder);
-
- // First test with a SpannableStringBuilder, as opposed to SpannedString
- checkPostProcess(HtmlUtils.postprocess(getContext(), builder));
-
- // Then pass a SpannedString, which is immutable, but the method should still work.
- checkPostProcess(HtmlUtils.postprocess(getContext(), new SpannedString(builder)));
- }
-
- private void setSpans(SpannableStringBuilder builder) {
- builder.setSpan(new ImageSpan(new ColorDrawable(), ImageSpan.ALIGN_BOTTOM), 0, 2, 0);
- builder.setSpan(new QuoteSpan(), 2, 4, 0);
- builder.setSpan(new CustomSpan(), 4, builder.length(), 0);
- }
-
- private void checkPostProcess(Spanned ret) {
- // Newlines should be trimmed.
- assertEquals("01234", ret.toString());
-
- // First, check the image span.
- // - Vertical alignment should be changed to ALIGN_BASELINE
- // - Drawable shouldn't be changed.
- ImageSpan[] imageSpans = ret.getSpans(0, ret.length(), ImageSpan.class);
- assertEquals(1, imageSpans.length);
- assertEquals(ImageSpan.ALIGN_BASELINE, imageSpans[0].getVerticalAlignment());
- assertEquals(ColorDrawable.class, imageSpans[0].getDrawable().getClass());
-
- // QuoteSpans should be replaced with StreamItemQuoteSpans.
- QuoteSpan[] quoteSpans = ret.getSpans(0, ret.length(), QuoteSpan.class);
- assertEquals(1, quoteSpans.length);
- assertEquals(StreamItemQuoteSpan.class, quoteSpans[0].getClass());
-
- // Other spans should be preserved.
- CustomSpan[] customSpans = ret.getSpans(0, ret.length(), CustomSpan.class);
- assertEquals(1, customSpans.length);
- }
-
- /** Custom span class used in {@link #testPostProcess} */
- private static class CustomSpan {
- }
-}
diff --git a/tests/src/com/android/contacts/util/StreamItemEntryBuilder.java b/tests/src/com/android/contacts/util/StreamItemEntryBuilder.java
deleted file mode 100644
index 9eb550e..0000000
--- a/tests/src/com/android/contacts/util/StreamItemEntryBuilder.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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
- */
-
-package com.android.contacts.util;
-
-import android.content.Context;
-
-/**
- * Builder for {@link StreamItemEntry}s to make writing tests easier.
- */
-public class StreamItemEntryBuilder {
- private long mId;
- private String mText;
- private String mComment;
- private long mTimestamp;
- private String mAccountType;
- private String mAccountName;
- private String mDataSet;
- private String mResPackage;
- private String mIconRes;
- private String mLabelRes;
-
- public StreamItemEntryBuilder() {}
-
- public StreamItemEntryBuilder setText(String value) {
- mText = value;
- return this;
- }
-
- public StreamItemEntryBuilder setComment(String value) {
- mComment = value;
- return this;
- }
-
- public StreamItemEntryBuilder setAccountType(String value) {
- mAccountType = value;
- return this;
- }
-
- public StreamItemEntryBuilder setAccountName(String value) {
- mAccountName = value;
- return this;
- }
-
- public StreamItemEntryBuilder setDataSet(String value) {
- mDataSet = value;
- return this;
- }
-
- public StreamItemEntry build(Context context) {
- StreamItemEntry ret = StreamItemEntry.createForTest(mId, mText, mComment, mTimestamp,
- mAccountType, mAccountName, mDataSet, mResPackage, mIconRes, mLabelRes);
- ret.decodeHtml(context);
- return ret;
- }
-}