From 7e5c19fceb8166fa746cd8605f764ab44c3c5c21 Mon Sep 17 00:00:00 2001 From: Jay Shrauner Date: Thu, 5 Sep 2013 09:19:48 -0700 Subject: Improve fields displayed for reverse phone lookup Add the user formatted version of the phone number and phone label string support for cache/reverse phone number lookup contacts. Use standard UI update call so Google Voice information is also displayed correctly. Bug:10609551 Change-Id: I2d1231e0b46cbfc3ec4b4ad84fb24a292562b8ce --- .../com/android/incallui/CallCardPresenter.java | 36 ++++++++++++++-------- .../incallui/service/PhoneNumberService.java | 5 ++- 2 files changed, 28 insertions(+), 13 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index db5b66a9a..10eb5615f 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -21,6 +21,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.graphics.Bitmap; +import android.provider.ContactsContract.CommonDataKinds.Phone; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.text.format.DateUtils; @@ -252,7 +253,8 @@ public class CallCardPresenter extends Presenter if (entry.label == null) { // Name not found. Try lookup. Log.d(TAG, "Contact lookup. Contact provider miss. Searching people api."); - lookupPhoneNumber(identification.getNumber()); + lookupPhoneNumber(identification.getNumber(), + isPrimary, isConference); } else { Log.d(TAG, "Contact lookup. Found in contact provider: " + entry); updateContactEntry(entry, isPrimary, isConference); @@ -379,25 +381,35 @@ public class CallCardPresenter extends Presenter } } - public void lookupPhoneNumber(String phoneNumber) { + public void lookupPhoneNumber(final String phoneNumber, + final boolean isPrimary, final boolean isConference) { if (mPhoneNumberService != null) { mPhoneNumberService.getPhoneNumberInfo(phoneNumber, new PhoneNumberService.NumberLookupListener() { @Override public void onPhoneNumberInfoComplete( final PhoneNumberService.PhoneNumberInfo info) { - if (info == null) { + if (info == null || getUi() == null) { return; } - // TODO(klp): Ui is sometimes null due to something being shutdown. - if (getUi() != null) { - if (info.getDisplayName() != null) { - getUi().setPrimaryName(info.getDisplayName(), false); - } - - if (info.getImageUrl() != null) { - fetchImage(info.getImageUrl()); - } + ContactCacheEntry entry = new ContactCacheEntry(); + entry.name = info.getDisplayName(); + entry.number = info.getNumber(); + final int type = info.getPhoneType(); + final String label = info.getPhoneLabel(); + if (type == Phone.TYPE_CUSTOM) { + entry.label = label; + } else { + final CharSequence typeStr = Phone.getTypeLabel( + mContext.getResources(), type, label); + entry.label = typeStr == null ? null : + typeStr.toString(); + } + + updateContactEntry(entry, isPrimary, isConference); + + if (info.getImageUrl() != null) { + fetchImage(info.getImageUrl()); } } }); diff --git a/InCallUI/src/com/android/incallui/service/PhoneNumberService.java b/InCallUI/src/com/android/incallui/service/PhoneNumberService.java index 1fc28584e..279593da2 100644 --- a/InCallUI/src/com/android/incallui/service/PhoneNumberService.java +++ b/InCallUI/src/com/android/incallui/service/PhoneNumberService.java @@ -61,7 +61,10 @@ public interface PhoneNumberService { public interface PhoneNumberInfo { public String getDisplayName(); - public String getPhoneNumber(); + public String getNumber(); + public int getPhoneType(); + public String getPhoneLabel(); + public String getNormalizedNumber(); public String getImageUrl(); } } -- cgit v1.2.3