Use the super primary name on the quick contact about card title 2/2
Bug 19124091
Change-Id: I2ecbba5f73d13d6a92c3c7aa88a5f98c3195d53b
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index db309c2..da954c9 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -1538,12 +1538,17 @@
iconResourceId = R.drawable.ic_dialer_sip_black_24dp;
}
} else if (dataItem instanceof StructuredNameDataItem) {
- final String givenName = ((StructuredNameDataItem) dataItem).getGivenName();
- if (!TextUtils.isEmpty(givenName)) {
- aboutCardName.value = res.getString(R.string.about_card_title) +
- " " + givenName;
- } else {
- aboutCardName.value = res.getString(R.string.about_card_title);
+ // If the name is already set and this is not the super primary value then leave the
+ // current value. This way we show the super primary value when we are able to.
+ if (dataItem.isSuperPrimary() || aboutCardName.value == null
+ || aboutCardName.value.isEmpty()) {
+ final String givenName = ((StructuredNameDataItem) dataItem).getGivenName();
+ if (!TextUtils.isEmpty(givenName)) {
+ aboutCardName.value = res.getString(R.string.about_card_title) +
+ " " + givenName;
+ } else {
+ aboutCardName.value = res.getString(R.string.about_card_title);
+ }
}
} else {
// Custom DataItem