Merge "Fix misc font sizes and spacing issues"
diff --git a/res/layout-w470dp/contact_detail_fragment.xml b/res/layout-w470dp/contact_detail_fragment.xml
index b523ff8..415bb56 100644
--- a/res/layout-w470dp/contact_detail_fragment.xml
+++ b/res/layout-w470dp/contact_detail_fragment.xml
@@ -39,12 +39,10 @@
<ImageView android:id="@+id/photo"
android:scaleType="centerCrop"
- android:layout_width="100dip"
- android:layout_height="100dip"
+ android:layout_width="128dip"
+ android:layout_height="128dip"
android:layout_marginLeft="@dimen/detail_contact_photo_margin"
- android:layout_marginRight="@dimen/detail_contact_photo_margin"
- android:layout_marginTop="@dimen/detail_contact_photo_margin"
- android:layout_marginBottom="@dimen/detail_contact_photo_margin"/>
+ android:layout_marginTop="@dimen/detail_contact_photo_margin"/>
<ListView android:id="@android:id/list"
android:layout_width="0dip"
diff --git a/res/layout/stream_item_row_image_and_text.xml b/res/layout/stream_item_row_one_image.xml
similarity index 89%
rename from res/layout/stream_item_row_image_and_text.xml
rename to res/layout/stream_item_row_one_image.xml
index 0ee6357..03dcedf 100644
--- a/res/layout/stream_item_row_image_and_text.xml
+++ b/res/layout/stream_item_row_one_image.xml
@@ -25,7 +25,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/detail_update_section_between_items_padding"
android:orientation="horizontal"
android:weightSum="2">
@@ -48,8 +47,4 @@
</LinearLayout>
- <include
- android:id="@+id/stream_item_second_text"
- layout="@layout/stream_item_row_text_only"/>
-
</LinearLayout>
diff --git a/res/layout/stream_item_row_text_only.xml b/res/layout/stream_item_row_text.xml
similarity index 95%
rename from res/layout/stream_item_row_text_only.xml
rename to res/layout/stream_item_row_text.xml
index 9d82edd..919ee52 100644
--- a/res/layout/stream_item_row_text_only.xml
+++ b/res/layout/stream_item_row_text.xml
@@ -17,7 +17,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/detail_update_section_between_items_padding"
android:orientation="vertical">
<TextView android:id="@+id/stream_item_html"
diff --git a/res/values-sw580dp-w1000dp/dimens.xml b/res/values-sw580dp-w1000dp/dimens.xml
index 7329930..f1b607c 100644
--- a/res/values-sw580dp-w1000dp/dimens.xml
+++ b/res/values-sw580dp-w1000dp/dimens.xml
@@ -15,5 +15,6 @@
-->
<resources>
<dimen name="group_detail_border_padding">32dip</dimen>
+ <dimen name="detail_contact_photo_margin">16dip</dimen>
<dimen name="contact_detail_list_top_padding">32dip</dimen>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index cd02d04..defd229 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -61,17 +61,20 @@
<!-- 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 columns images and/or text in a single stream item -->
+ <!-- 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">16dip</dimen>
+ <dimen name="detail_contact_photo_margin">8dip</dimen>
<!-- Width and height of the contact photo on the contact detail page -->
<dimen name="detail_contact_photo_size">256dip</dimen>
diff --git a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
index f94629b..f6690d6 100644
--- a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
+++ b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
@@ -267,37 +267,46 @@
List<StreamItemPhotoEntry> photos = streamItem.getPhotos();
final int photoCount = photos.size();
- // Process the photos, two at a time.
- for (int index = 0; index < photoCount; index += 2) {
- final StreamItemPhotoEntry firstPhoto = photos.get(index);
- if (index + 1 < photoCount) {
- // Put in two photos, side by side.
- final StreamItemPhotoEntry secondPhoto = photos.get(index + 1);
-
- View photoContainer = inflater.inflate(R.layout.stream_item_row_two_images,
- contentTable, false);
- loadPhoto(contactPhotoManager, streamItem, firstPhoto, photoContainer,
- R.id.stream_item_first_image, photoClickListener);
- loadPhoto(contactPhotoManager, streamItem, secondPhoto, photoContainer,
- R.id.stream_item_second_image, photoClickListener);
- contentTable.addView(photoContainer);
- } else {
- // Put in a single photo with text on the side.
- View photoContainer = inflater.inflate(
- R.layout.stream_item_row_image_and_text, contentTable, false);
- loadPhoto(contactPhotoManager, streamItem, firstPhoto, photoContainer,
- R.id.stream_item_first_image, photoClickListener);
- addStreamItemText(context, streamItem,
- photoContainer.findViewById(R.id.stream_item_second_text));
- contentTable.addView(photoContainer);
- }
- }
-
- if (photoCount % 2 == 0) {
- // Even number of photos, add the text below them. Otherwise, it should have been
- // already added next to the last photo.
- View textContainer = inflater.inflate(R.layout.stream_item_row_text_only, contentTable,
+ // This stream item only has text.
+ if (photoCount == 0) {
+ View textOnlyContainer = inflater.inflate(R.layout.stream_item_row_text, contentTable,
false);
+ addStreamItemText(context, streamItem, textOnlyContainer);
+ contentTable.addView(textOnlyContainer);
+ } else {
+ // This stream item has text and photos. Process the photos, two at a time.
+ for (int index = 0; index < photoCount; index += 2) {
+ final StreamItemPhotoEntry firstPhoto = photos.get(index);
+ if (index + 1 < photoCount) {
+ // Put in two photos, side by side.
+ final StreamItemPhotoEntry secondPhoto = photos.get(index + 1);
+ View photoContainer = inflater.inflate(R.layout.stream_item_row_two_images,
+ contentTable, false);
+ loadPhoto(contactPhotoManager, streamItem, firstPhoto, photoContainer,
+ R.id.stream_item_first_image, photoClickListener);
+ loadPhoto(contactPhotoManager, streamItem, secondPhoto, photoContainer,
+ R.id.stream_item_second_image, photoClickListener);
+ contentTable.addView(photoContainer);
+ } else {
+ // Put in a single photo
+ View photoContainer = inflater.inflate(
+ R.layout.stream_item_row_one_image, contentTable, false);
+ loadPhoto(contactPhotoManager, streamItem, firstPhoto, photoContainer,
+ R.id.stream_item_first_image, photoClickListener);
+ contentTable.addView(photoContainer);
+ }
+ }
+
+ // Add text, comments, and attribution if applicable
+ View textContainer = inflater.inflate(R.layout.stream_item_row_text, contentTable,
+ false);
+ // Add extra padding between the text and the images
+ int extraVerticalPadding = context.getResources().getDimensionPixelSize(
+ R.dimen.detail_update_section_between_items_vertical_padding);
+ textContainer.setPadding(textContainer.getPaddingLeft(),
+ textContainer.getPaddingTop() + extraVerticalPadding,
+ textContainer.getPaddingRight(),
+ textContainer.getPaddingBottom());
addStreamItemText(context, streamItem, textContainer);
contentTable.addView(textContainer);
}
diff --git a/src/com/android/contacts/detail/ContactDetailFragment.java b/src/com/android/contacts/detail/ContactDetailFragment.java
index bacc5db..775b50a 100644
--- a/src/com/android/contacts/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/detail/ContactDetailFragment.java
@@ -132,6 +132,13 @@
private static final String KEY_CONTACT_URI = "contactUri";
private static final String KEY_LIST_STATE = "liststate";
+ // TODO: Make maxLines a field in {@link DataKind}
+ private static final int WEBSITE_MAX_LINES = 1;
+ private static final int SIP_ADDRESS_MAX_LINES= 1;
+ private static final int POSTAL_ADDRESS_MAX_LINES = 10;
+ private static final int GROUP_MAX_LINES = 10;
+ private static final int NOTE_MAX_LINES = 100;
+
private Context mContext;
private View mView;
private OnScrollListener mVerticalScrollListener;
@@ -632,7 +639,7 @@
}
} else if (StructuredPostal.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
// Build postal entries
- entry.maxLines = 4;
+ entry.maxLines = POSTAL_ADDRESS_MAX_LINES;
entry.intent = new Intent(
Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + Uri.encode(entry.data)));
mPostalEntries.add(entry);
@@ -665,12 +672,12 @@
} else if (Note.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
// Build note entries
entry.uri = null;
- entry.maxLines = 100;
+ entry.maxLines = NOTE_MAX_LINES;
mNoteEntries.add(entry);
} else if (Website.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
// Build Website entries
entry.uri = null;
- entry.maxLines = 1;
+ entry.maxLines = WEBSITE_MAX_LINES;
try {
WebAddress webAddress = new WebAddress(entry.data);
entry.intent = new Intent(Intent.ACTION_VIEW,
@@ -682,7 +689,7 @@
} else if (SipAddress.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
// Build SipAddress entries
entry.uri = null;
- entry.maxLines = 1;
+ entry.maxLines = SIP_ADDRESS_MAX_LINES;
if (mHasSip) {
entry.intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
Uri.fromParts(Constants.SCHEME_SIP, entry.data, null));
@@ -747,7 +754,7 @@
entry.mimetype = GroupMembership.MIMETYPE;
entry.kind = mContext.getString(R.string.groupsLabel);
entry.data = sb.toString();
- entry.maxLines = 10;
+ entry.maxLines = GROUP_MAX_LINES;
mGroupEntries.add(entry);
}
}
diff --git a/src/com/android/contacts/detail/ContactDetailTabCarousel.java b/src/com/android/contacts/detail/ContactDetailTabCarousel.java
index 9300b54..4700078 100644
--- a/src/com/android/contacts/detail/ContactDetailTabCarousel.java
+++ b/src/com/android/contacts/detail/ContactDetailTabCarousel.java
@@ -146,6 +146,7 @@
if (mScrollToCurrentTab) {
mScrollToCurrentTab = false;
scrollTo(mCurrentTab == TAB_INDEX_ABOUT ? 0 : mAllowedHorizontalScrollLength, 0);
+ updateAlphaLayers();
}
}
diff --git a/src/com/android/contacts/util/HtmlUtils.java b/src/com/android/contacts/util/HtmlUtils.java
index 4663657..faaa9c2 100644
--- a/src/com/android/contacts/util/HtmlUtils.java
+++ b/src/com/android/contacts/util/HtmlUtils.java
@@ -7,6 +7,7 @@
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;
@@ -23,6 +24,9 @@
* Converts HTML string to a {@link Spanned} text, adjusting formatting.
*/
public static Spanned fromHtml(Context context, String text) {
+ if (TextUtils.isEmpty(text)) {
+ return null;
+ }
Spanned spanned = Html.fromHtml(text);
postprocess(context, spanned);
return spanned;
@@ -34,6 +38,9 @@
*/
public static CharSequence fromHtml(Context context, String text, ImageGetter imageGetter,
TagHandler tagHandler) {
+ if (TextUtils.isEmpty(text)) {
+ return null;
+ }
Spanned spanned = Html.fromHtml(text, imageGetter, tagHandler);
postprocess(context, spanned);
return spanned;
diff --git a/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java b/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java
index 487eec9..3d383ff 100644
--- a/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java
+++ b/tests/src/com/android/contacts/detail/ContactDetailDisplayUtilsTest.java
@@ -108,7 +108,7 @@
*/
private View addStreamItemText(StreamItemEntry streamItem) {
return ContactDetailDisplayUtils.addStreamItemText(getContext(), streamItem,
- mLayoutInflater.inflate(R.layout.stream_item_row_text_only, null));
+ mLayoutInflater.inflate(R.layout.stream_item_row_text, null));
}
private StreamItemEntryBuilder getTestBuilder() {