Don't show the badge background when we have no uri, email, or phone.
This will be used in talk and mms in the case of multiple recipients.
diff --git a/core/java/android/widget/FasttrackBadgeWidget.java b/core/java/android/widget/FasttrackBadgeWidget.java
index 9d2307f..8c8e054 100644
--- a/core/java/android/widget/FasttrackBadgeWidget.java
+++ b/core/java/android/widget/FasttrackBadgeWidget.java
@@ -22,6 +22,7 @@
import android.content.Intent;
import android.content.res.TypedArray;
import android.database.Cursor;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.FastTrack;
@@ -46,6 +47,7 @@
private String mContactPhone;
private int mMode;
private QueryHandler mQueryHandler;
+ private Drawable mBadgeBackground;
protected String[] mExcludeMimes = null;
@@ -91,6 +93,8 @@
a.recycle();
init();
+
+ mBadgeBackground = getBackground();
}
private void init() {
@@ -108,6 +112,17 @@
*/
public void assignContactUri(Uri contactUri) {
mContactUri = contactUri;
+ mContactEmail = null;
+ mContactPhone = null;
+ onContactUriChanged();
+ }
+
+ private void onContactUriChanged() {
+ if (mContactUri == null && mContactEmail == null && mContactPhone == null) {
+ setBackgroundDrawable(null);
+ } else {
+ setBackgroundDrawable(mBadgeBackground);
+ }
}
/**
@@ -127,6 +142,7 @@
EMAIL_LOOKUP_PROJECTION, null, null, null);
} else {
mContactUri = null;
+ onContactUriChanged();
}
}
@@ -147,6 +163,7 @@
PHONE_LOOKUP_PROJECTION, null, null, null);
} else {
mContactUri = null;
+ onContactUriChanged();
}
}
@@ -237,6 +254,7 @@
}
mContactUri = lookupUri;
+ onContactUriChanged();
if (trigger && lookupUri != null) {
// Found contact, so trigger track