diff options
author | Christine Chen <christinech@google.com> | 2013-10-02 14:30:47 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-02 14:30:47 -0700 |
commit | 41577efbe3998699ec456ed67918603f331dcf44 (patch) | |
tree | 6b7ae13ea254878135f7027a4ca07a55c199bbb1 | |
parent | c4994b8bd54cf31d3aeddb4bd22091bc9965714f (diff) | |
parent | 75245f68b77c9c3d0be2a195e140a97b2d7c7f7b (diff) |
am 75245f68: Fixes how voicemail looks up contact names
* commit '75245f68b77c9c3d0be2a195e140a97b2d7c7f7b':
Fixes how voicemail looks up contact names
-rw-r--r-- | src/com/android/dialer/calllog/DefaultVoicemailNotifier.java | 10 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/PhoneNumberHelper.java | 34 |
2 files changed, 28 insertions, 16 deletions
diff --git a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java index cb3d99466..14e1bedbb 100644 --- a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java +++ b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java @@ -118,12 +118,12 @@ public class DefaultVoicemailNotifier implements VoicemailNotifier { // Check if we already know the name associated with this number. String name = names.get(newCall.number); if (name == null) { - // Look it up in the database. - name = mNameLookupQuery.query(newCall.number); + name = mPhoneNumberHelper.getDisplayName(newCall.number, + newCall.numberPresentation).toString(); // If we cannot lookup the contact, use the number instead. - if (name == null) { - name = mPhoneNumberHelper.getDisplayNumber(newCall.number, - newCall.numberPresentation, "").toString(); + if (TextUtils.isEmpty(name)) { + // Look it up in the database. + name = mNameLookupQuery.query(newCall.number); if (TextUtils.isEmpty(name)) { name = newCall.number; } diff --git a/src/com/android/dialer/calllog/PhoneNumberHelper.java b/src/com/android/dialer/calllog/PhoneNumberHelper.java index 5a882e8a8..336facb37 100644 --- a/src/com/android/dialer/calllog/PhoneNumberHelper.java +++ b/src/com/android/dialer/calllog/PhoneNumberHelper.java @@ -33,14 +33,7 @@ public class PhoneNumberHelper { mResources = resources; } - /** - * Returns the string to display for the given phone number. - * - * @param number the number to display - * @param formattedNumber the formatted number if available, may be null - */ - public CharSequence getDisplayNumber(CharSequence number, - int presentation, CharSequence formattedNumber) { + /* package */ CharSequence getDisplayName(CharSequence number, int presentation) { if (presentation == Calls.PRESENTATION_UNKNOWN) { return mResources.getString(R.string.unknown); } @@ -50,15 +43,34 @@ public class PhoneNumberHelper { if (presentation == Calls.PRESENTATION_PAYPHONE) { return mResources.getString(R.string.payphone); } - if (TextUtils.isEmpty(number)) { - return ""; - } if (new PhoneNumberUtilsWrapper().isVoicemailNumber(number)) { return mResources.getString(R.string.voicemail); } if (PhoneNumberUtilsWrapper.isLegacyUnknownNumbers(number)) { return mResources.getString(R.string.unknown); } + return ""; + } + + /** + * Returns the string to display for the given phone number. + * + * @param number the number to display + * @param formattedNumber the formatted number if available, may be null + */ + public CharSequence getDisplayNumber(CharSequence number, + int presentation, CharSequence formattedNumber) { + + final CharSequence displayName = getDisplayName(number, presentation); + + if (!TextUtils.isEmpty(displayName)) { + return displayName; + } + + if (TextUtils.isEmpty(number)) { + return ""; + } + if (TextUtils.isEmpty(formattedNumber)) { return number; } else { |