Skip to content

Commit

Permalink
Don't update call card when new info is worse
Browse files Browse the repository at this point in the history
Bug:8015123
Change-Id: Id58ad59dd07bf9de65d0a1113724de506a0e14bd
  • Loading branch information
Jay Shrauner committed Jan 18, 2013
1 parent e7c1bd6 commit f4f1229
Showing 1 changed file with 45 additions and 19 deletions.
64 changes: 45 additions & 19 deletions src/com/android/phone/CallCard.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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.)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f4f1229

Please sign in to comment.