Hide unused fields
When ContactHeaderWidget.bindFromPhoneNumber is called with a number
that's not in contacts, onQueryComplete takes a path that doesn't hide
fields that don't apply to the current phone number. As a result, the
user sees the new number, but old data from the previous display (such
as the facebook status). With this change, those fields are hidden.
Fixes bug 2336977.
Change-Id: Ib6253c18dc58c3d28b463c87d5d195a84d613600
diff --git a/core/java/com/android/internal/widget/ContactHeaderWidget.java b/core/java/com/android/internal/widget/ContactHeaderWidget.java
index 19debec..33fd936 100644
--- a/core/java/com/android/internal/widget/ContactHeaderWidget.java
+++ b/core/java/com/android/internal/widget/ContactHeaderWidget.java
@@ -119,12 +119,12 @@
int CONTACT_STATUS_RES_PACKAGE = 8;
int CONTACT_STATUS_LABEL = 9;
}
-
+
private interface PhotoQuery {
String[] COLUMNS = new String[] {
Photo.PHOTO
};
-
+
int PHOTO = 0;
}
@@ -241,13 +241,13 @@
case TOKEN_PHOTO_QUERY: {
//Set the photo
Bitmap photoBitmap = null;
- if (cursor != null && cursor.moveToFirst()
+ if (cursor != null && cursor.moveToFirst()
&& !cursor.isNull(PhotoQuery.PHOTO)) {
byte[] photoData = cursor.getBlob(PhotoQuery.PHOTO);
photoBitmap = BitmapFactory.decodeByteArray(photoData, 0,
photoData.length, null);
}
-
+
if (photoBitmap == null) {
photoBitmap = loadPlaceholderPhoto(null);
}
@@ -261,7 +261,7 @@
case TOKEN_CONTACT_INFO: {
if (cursor != null && cursor.moveToFirst()) {
bindContactInfo(cursor);
- Uri lookupUri = Contacts.getLookupUri(cursor.getLong(ContactQuery._ID),
+ Uri lookupUri = Contacts.getLookupUri(cursor.getLong(ContactQuery._ID),
cursor.getString(ContactQuery.LOOKUP_KEY));
startPhotoQuery(cursor.getLong(ContactQuery.PHOTO_ID), lookupUri);
invalidate();
@@ -277,6 +277,7 @@
} else {
String phoneNumber = (String) cookie;
setDisplayName(phoneNumber, null);
+ setSocialSnippet(null);
mPhotoView.assignContactFromPhone(phoneNumber, true);
}
break;
@@ -290,6 +291,7 @@
} else {
String emailAddress = (String) cookie;
setDisplayName(emailAddress, null);
+ setSocialSnippet(null);
mPhotoView.assignContactFromEmail(emailAddress, true);
}
break;
@@ -374,6 +376,7 @@
public void setSocialSnippet(CharSequence snippet) {
if (snippet == null) {
mStatusView.setVisibility(View.GONE);
+ mStatusAttributionView.setVisibility(View.GONE);
} else {
mStatusView.setText(snippet);
mStatusView.setVisibility(View.VISIBLE);
@@ -446,7 +449,9 @@
*
*/
public void wipeClean() {
+ setDisplayName(null, null);
setPhoto(null);
+ setSocialSnippet(null);
mContactUri = null;
mExcludeMimes = null;
}
@@ -457,11 +462,11 @@
}
protected void startPhotoQuery(long photoId, Uri lookupKey) {
- mQueryHandler.startQuery(TOKEN_PHOTO_QUERY, lookupKey,
+ mQueryHandler.startQuery(TOKEN_PHOTO_QUERY, lookupKey,
ContentUris.withAppendedId(Data.CONTENT_URI, photoId), PhotoQuery.COLUMNS,
null, null, null);
}
-
+
/**
* Bind the contact details provided by the given {@link Cursor}.
*/