Merge "Fix a Cursor leak if cursor doesn't have any content" into gingerbread
diff --git a/res/layout-finger/recent_calls_list_group_item.xml b/res/layout-finger/recent_calls_list_group_item.xml
index 2d3e7af..79e7bb9 100644
--- a/res/layout-finger/recent_calls_list_group_item.xml
+++ b/res/layout-finger/recent_calls_list_group_item.xml
@@ -60,6 +60,7 @@
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="36dip"
+ android:layout_marginRight="5dip"
android:layout_alignBaseline="@id/date"
android:singleLine="true"
@@ -71,7 +72,6 @@
<TextView android:id="@+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="5dip"
android:layout_toRightOf="@id/label"
android:layout_toLeftOf="@id/date"
android:layout_alignBaseline="@id/label"
diff --git a/res/layout-finger/recent_calls_list_item_layout.xml b/res/layout-finger/recent_calls_list_item_layout.xml
index 7463669..faaa893 100644
--- a/res/layout-finger/recent_calls_list_item_layout.xml
+++ b/res/layout-finger/recent_calls_list_item_layout.xml
@@ -52,6 +52,7 @@
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="36dip"
+ android:layout_marginRight="5dip"
android:layout_alignBaseline="@id/date"
android:singleLine="true"
@@ -63,7 +64,6 @@
<TextView android:id="@+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="5dip"
android:layout_toRightOf="@id/label"
android:layout_toLeftOf="@id/date"
android:layout_alignBaseline="@id/label"
diff --git a/src/com/android/contacts/RecentCallsListActivity.java b/src/com/android/contacts/RecentCallsListActivity.java
index 8e7b4bc..145ff69 100644
--- a/src/com/android/contacts/RecentCallsListActivity.java
+++ b/src/com/android/contacts/RecentCallsListActivity.java
@@ -686,8 +686,33 @@
if (!TextUtils.isEmpty(numberLabel)) {
views.labelView.setText(numberLabel);
views.labelView.setVisibility(View.VISIBLE);
+
+ // Zero out the numberView's left margin (see below)
+ ViewGroup.MarginLayoutParams numberLP =
+ (ViewGroup.MarginLayoutParams) views.numberView.getLayoutParams();
+ numberLP.leftMargin = 0;
+ views.numberView.setLayoutParams(numberLP);
} else {
- views.labelView.setVisibility(View.GONE);
+ // There's nothing to display in views.labelView, so hide it.
+ // We can't set it to View.GONE, since it's the anchor for
+ // numberView in the RelativeLayout, so make it INVISIBLE.
+ // Also, we need to manually *subtract* some left margin from
+ // numberView to compensate for the right margin built in to
+ // labelView (otherwise the number will be indented by a very
+ // slight amount).
+ // TODO: a cleaner fix would be to contain both the label and
+ // number inside a LinearLayout, and then set labelView *and*
+ // its padding to GONE when there's no label to display.
+ views.labelView.setText(null);
+ views.labelView.setVisibility(View.INVISIBLE);
+
+ ViewGroup.MarginLayoutParams labelLP =
+ (ViewGroup.MarginLayoutParams) views.labelView.getLayoutParams();
+ ViewGroup.MarginLayoutParams numberLP =
+ (ViewGroup.MarginLayoutParams) views.numberView.getLayoutParams();
+ // Equivalent to setting android:layout_marginLeft in XML
+ numberLP.leftMargin = -labelLP.rightMargin;
+ views.numberView.setLayoutParams(numberLP);
}
} else {
if (number.equals(CallerInfo.UNKNOWN_NUMBER)) {