Fix corrupted views in favorite tabs
I12820f1e0673aaf81044fc8cb6adedc0a8a64dd6 suppresses every
re-layout including ones from TextView, which makes the tile look
weird sometimes.
Instead of suppressing all those events, let's suppress only events
coming from ImageViews.
Bug: 5270040
Change-Id: Ia042ba0d548ca4b62a349508eaa8754bbd92dff2
diff --git a/res/layout/contact_tile_frequent.xml b/res/layout/contact_tile_frequent.xml
index 52b7126..b9d637d 100644
--- a/res/layout/contact_tile_frequent.xml
+++ b/res/layout/contact_tile_frequent.xml
@@ -26,13 +26,18 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <QuickContactBadge
- android:id="@+id/contact_tile_quick"
- android:layout_width="64dip"
- android:layout_height="64dip"
- android:scaleType="centerCrop"
- android:focusable="true"
- android:layout_alignParentRight="true" />
+ <view
+ class="com.android.contacts.list.ContactTileImageContainer"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <QuickContactBadge
+ android:id="@+id/contact_tile_quick"
+ android:layout_width="64dip"
+ android:layout_height="64dip"
+ android:scaleType="centerCrop"
+ android:focusable="true"
+ android:layout_alignParentRight="true" />
+ </view>
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/layout/contact_tile_frequent_phone.xml b/res/layout/contact_tile_frequent_phone.xml
index 7d24cef..1f5171d 100644
--- a/res/layout/contact_tile_frequent_phone.xml
+++ b/res/layout/contact_tile_frequent_phone.xml
@@ -27,14 +27,19 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <QuickContactBadge
- android:id="@id/contact_tile_quick"
- android:nextFocusRight="@id/contact_tile_frequent_phone"
- android:layout_width="64dip"
- android:layout_height="64dip"
- android:scaleType="centerCrop"
- android:focusable="true"
- android:layout_alignParentLeft="true" />
+ <view
+ class="com.android.contacts.list.ContactTileImageContainer"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <QuickContactBadge
+ android:id="@id/contact_tile_quick"
+ android:nextFocusRight="@id/contact_tile_frequent_phone"
+ android:layout_width="64dip"
+ android:layout_height="64dip"
+ android:scaleType="centerCrop"
+ android:focusable="true"
+ android:layout_alignParentLeft="true" />
+ </view>
<TextView
android:id="@+id/contact_tile_name"
diff --git a/res/layout/contact_tile_starred.xml b/res/layout/contact_tile_starred.xml
index 3f8d91d..10094f9 100644
--- a/res/layout/contact_tile_starred.xml
+++ b/res/layout/contact_tile_starred.xml
@@ -25,11 +25,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <ImageView
- android:id="@+id/contact_tile_image"
+ <view
+ class="com.android.contacts.list.ContactTileImageContainer"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop" />
+ android:layout_height="match_parent">
+ <ImageView
+ android:id="@+id/contact_tile_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop" />
+ </view>
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/layout/contact_tile_starred_quick_contact.xml b/res/layout/contact_tile_starred_quick_contact.xml
index 3f072d1..51d7ad4 100644
--- a/res/layout/contact_tile_starred_quick_contact.xml
+++ b/res/layout/contact_tile_starred_quick_contact.xml
@@ -24,11 +24,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <ImageView
- android:id="@+id/contact_tile_image"
+ <view
+ class="com.android.contacts.list.ContactTileImageContainer"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop" />
+ android:layout_height="match_parent">
+ <ImageView
+ android:id="@+id/contact_tile_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop" />
+ </view>
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/layout/contact_tile_starred_secondary_target.xml b/res/layout/contact_tile_starred_secondary_target.xml
index 6543dc1..2ce59c5 100644
--- a/res/layout/contact_tile_starred_secondary_target.xml
+++ b/res/layout/contact_tile_starred_secondary_target.xml
@@ -24,11 +24,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <ImageView
- android:id="@+id/contact_tile_image"
+ <view
+ class="com.android.contacts.list.ContactTileImageContainer"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop" />
+ android:layout_height="match_parent">
+ <ImageView
+ android:id="@+id/contact_tile_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop" />
+ </view>
<TextView
android:id="@+id/contact_tile_name"
diff --git a/src/com/android/contacts/list/ContactTileImageContainer.java b/src/com/android/contacts/list/ContactTileImageContainer.java
new file mode 100644
index 0000000..e1a791b
--- /dev/null
+++ b/src/com/android/contacts/list/ContactTileImageContainer.java
@@ -0,0 +1,38 @@
+/*
+ * 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.list;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+/**
+ * Custom container for ImageView or ContactBadge inside {@link ContactTileView}.
+ *
+ * This improves the performance of favorite tabs by not passing the layout request to the parent
+ * views, assuming that once measured this will not need to resize itself.
+ */
+public class ContactTileImageContainer extends FrameLayout {
+
+ public ContactTileImageContainer(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public void requestLayout() {
+ forceLayout();
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/contacts/list/ContactTileView.java b/src/com/android/contacts/list/ContactTileView.java
index 4562864..137f6e7 100644
--- a/src/com/android/contacts/list/ContactTileView.java
+++ b/src/com/android/contacts/list/ContactTileView.java
@@ -151,12 +151,4 @@
public interface Listener {
void onClick(ContactTileView contactTileView);
}
-
- @Override
- public void requestLayout() {
- // We will assume that once measured this will not need to resize
- // itself, so there is no need to pass the layout request to the parent
- // view (ListView).
- forceLayout();
- }
}