diff options
author | Jay Shrauner <shrauner@google.com> | 2013-09-06 22:08:37 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-09-06 22:08:37 +0000 |
commit | 24deb0f78f1854bfc273bb888e7fd4ac123bcc22 (patch) | |
tree | 56fb58ffe94d0dcb05d650a1a40d827613fbbe31 /InCallUI | |
parent | 5345442d7238c1db00dc8d55a49f7f5dd713d994 (diff) | |
parent | 7e5c19fceb8166fa746cd8605f764ab44c3c5c21 (diff) |
Merge "Improve fields displayed for reverse phone lookup" into klp-dev
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(); } } |