Skip to content
Browse files

Don't update call card when new info is worse

Bug:8015123
Change-Id: Id58ad59dd07bf9de65d0a1113724de506a0e14bd
  • Loading branch information...
1 parent e7c1bd6 commit f4f1229242918599d903015bd17383effdd5d7f7 Jay Shrauner committed Jan 17, 2013
Showing with 45 additions and 19 deletions.
  1. +45 −19 src/com/android/phone/CallCard.java
View
64 src/com/android/phone/CallCard.java
@@ -1202,6 +1202,7 @@ private void updateDisplayForPerson(CallerInfo info,
mPhotoTracker.setPhotoState(ContactsAsyncHelper.ImageTracker.DISPLAY_IMAGE);
// The actual strings we're going to display onscreen:
+ boolean displayNameIsNumber = false;
String displayName;
String displayNumber = null;
String label = null;
@@ -1269,6 +1270,7 @@ private void updateDisplayForPerson(CallerInfo info,
// Promote the phone number up to the "name" slot:
displayName = number;
+ displayNameIsNumber = true;
// ...and use the "number" slot for a geographical description
// string if available (but only for incoming calls.)
@@ -1307,12 +1309,50 @@ private void updateDisplayForPerson(CallerInfo info,
displayName = PhoneUtils.getPresentationString(getContext(), presentation);
}
- if (call.isGeneric()) {
- mName.setText(R.string.card_title_in_call);
- } else {
- mName.setText(displayName);
+ boolean updateNameAndNumber = true;
+ // If the new info is just a phone number, check to make sure it's not less
+ // information than what's already being displayed.
+ if (displayNameIsNumber) {
+ // If the new number is the same as the number already displayed, ignore it
+ // because that means we're also already displaying a name for it.
+ // If the new number is the same as the name currently being displayed, only
+ // display if the new number is longer (ie, has formatting).
+ String visiblePhoneNumber = null;
+ if (mPhoneNumber.getVisibility() == View.VISIBLE) {
+ visiblePhoneNumber = mPhoneNumber.getText().toString();
+ }
+ if ((visiblePhoneNumber != null &&
+ PhoneNumberUtils.compare(visiblePhoneNumber, displayName)) ||
+ (PhoneNumberUtils.compare(mName.getText().toString(), displayName) &&
+ displayName.length() < mName.length())) {
+ if (DBG) log("chose not to update display {" + mName.getText() + ", "
+ + visiblePhoneNumber + "} with number " + displayName);
+ updateNameAndNumber = false;
+ }
+ }
+
+ if (updateNameAndNumber) {
+ if (call.isGeneric()) {
+ mName.setText(R.string.card_title_in_call);
+ } else {
+ mName.setText(displayName);
+ }
+ mName.setVisibility(View.VISIBLE);
+
+ if (displayNumber != null && !call.isGeneric()) {
+ mPhoneNumber.setText(displayNumber);
+ mPhoneNumber.setVisibility(View.VISIBLE);
+ } else {
+ mPhoneNumber.setVisibility(View.GONE);
+ }
+
+ if (label != null && !call.isGeneric()) {
+ mLabel.setText(label);
+ mLabel.setVisibility(View.VISIBLE);
+ } else {
+ mLabel.setVisibility(View.GONE);
+ }
}
- mName.setVisibility(View.VISIBLE);
// Update mPhoto
// if the temporary flag is set, we know we'll be getting another call after
@@ -1369,20 +1409,6 @@ private void updateDisplayForPerson(CallerInfo info,
AnimationUtils.Fade.hide(mPhotoDimEffect, View.GONE);
}
- if (displayNumber != null && !call.isGeneric()) {
- mPhoneNumber.setText(displayNumber);
- mPhoneNumber.setVisibility(View.VISIBLE);
- } else {
- mPhoneNumber.setVisibility(View.GONE);
- }
-
- if (label != null && !call.isGeneric()) {
- mLabel.setText(label);
- mLabel.setVisibility(View.VISIBLE);
- } else {
- mLabel.setVisibility(View.GONE);
- }
-
// Other text fields:
updateCallTypeLabel(call);
// updateSocialStatus(socialStatusText, socialStatusBadge, call); // Currently unused

0 comments on commit f4f1229

Please sign in to comment.
Something went wrong with that request. Please try again.