diff options
author | Jay Shrauner <shrauner@google.com> | 2013-09-06 15:14:23 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-09-06 15:14:23 -0700 |
commit | 6b8ca36b1c3d4e34fd9b4c3b120b13ff93afeaa5 (patch) | |
tree | 56fb58ffe94d0dcb05d650a1a40d827613fbbe31 /InCallUI | |
parent | 5aa6f2ed64beecbc8f9cef41c87f1f6ab768ac78 (diff) | |
parent | 46d6a50a00c81df48750dd573f9986a930626a86 (diff) |
am c8555422: am fb45d1c9: Merge "Improve fields displayed for reverse phone lookup" into klp-dev
* commit 'c8555422514f78f2f987244d946c219b49ea8378':
Improve fields displayed for reverse phone lookup
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardPresenter.java | 36 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/service/PhoneNumberService.java | 5 |
2 files changed, 28 insertions, 13 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index d2295d34e..ee587067f 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<CallCardPresenter.CallCardUi> 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<CallCardPresenter.CallCardUi> } } - 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(); } } |