summaryrefslogtreecommitdiff
path: root/java/com
diff options
context:
space:
mode:
authorAndroid Dialer <noreply@google.com>2018-02-21 08:05:14 -0800
committerEric Erfanian <erfanian@google.com>2018-02-22 21:11:26 +0000
commitf94391034e9d591c18d04c0b796d944938201f6a (patch)
treec8c81409022b07bf62841df8bfc29f65b5e280cf /java/com
parentd40d4f09e32ecfc6b95f57bc6d3e3d1703592cd4 (diff)
Updating PrimaryInfo value class to use AutoValue with builder pattern.
Bug: 34502119 Test: BottomRowTest,CallCardPresenterTest,PrimaryInfoTest,TopRowTest PiperOrigin-RevId: 186460178 Change-Id: Ifb90019b6a5568788d51f4a55a07f7693c803eaf
Diffstat (limited to 'java/com')
-rw-r--r--java/com/android/incallui/CallCardPresenter.java86
-rw-r--r--java/com/android/incallui/answer/impl/AnswerFragment.java16
-rw-r--r--java/com/android/incallui/callpending/CallPendingActivity.java38
-rw-r--r--java/com/android/incallui/contactgrid/BottomRow.java16
-rw-r--r--java/com/android/incallui/contactgrid/ContactGridManager.java28
-rw-r--r--java/com/android/incallui/contactgrid/TopRow.java12
-rw-r--r--java/com/android/incallui/incall/impl/InCallFragment.java4
-rw-r--r--java/com/android/incallui/incall/protocol/PrimaryInfo.java197
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatFragment.java2
9 files changed, 212 insertions, 187 deletions
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java
index da5d1a8dd..b945b0810 100644
--- a/java/com/android/incallui/CallCardPresenter.java
+++ b/java/com/android/incallui/CallCardPresenter.java
@@ -690,7 +690,7 @@ public class CallCardPresenter
if (primary == null) {
// Clear the primary display info.
- inCallScreen.setPrimary(PrimaryInfo.createEmptyPrimaryInfo());
+ inCallScreen.setPrimary(PrimaryInfo.empty());
return;
}
@@ -713,26 +713,22 @@ public class CallCardPresenter
"update primary display info for conference call.");
inCallScreen.setPrimary(
- new PrimaryInfo(
- null /* number */,
- CallerInfoUtils.getConferenceString(
- context, primary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)),
- false /* nameIsNumber */,
- null /* location */,
- null /* label */,
- null /* photo */,
- ContactPhotoType.DEFAULT_PLACEHOLDER,
- false /* isSipCall */,
- showContactPhoto,
- hasWorkCallProperty,
- false /* isSpam */,
- false /* isLocalContact */,
- false /* answeringDisconnectsOngoingCall */,
- shouldShowLocation(),
- null /* contactInfoLookupKey */,
- null /* enrichedCallMultimediaData */,
- true /* showInCallButtonGrid */,
- primary.getNumberPresentation()));
+ PrimaryInfo.builder()
+ .setName(
+ CallerInfoUtils.getConferenceString(
+ context, primary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)))
+ .setNameIsNumber(false)
+ .setPhotoType(ContactPhotoType.DEFAULT_PLACEHOLDER)
+ .setIsSipCall(false)
+ .setIsContactPhotoShown(showContactPhoto)
+ .setIsWorkCall(hasWorkCallProperty)
+ .setIsSpam(false)
+ .setIsLocalContact(false)
+ .setAnsweringDisconnectsOngoingCall(false)
+ .setShouldShowLocation(shouldShowLocation())
+ .setShowInCallButtonGrid(true)
+ .setNumberPresentation(primary.getNumberPresentation())
+ .build());
} else if (primaryContactInfo != null) {
LogUtil.v(
"CallCardPresenter.updatePrimaryDisplayInfo",
@@ -761,30 +757,33 @@ public class CallCardPresenter
// DialerCall with caller that is a work contact.
boolean isWorkContact = (primaryContactInfo.userType == ContactsUtils.USER_TYPE_WORK);
inCallScreen.setPrimary(
- new PrimaryInfo(
- number,
- primary.updateNameIfRestricted(name),
- nameIsNumber,
- shouldShowLocationAsLabel(nameIsNumber, primaryContactInfo.shouldShowLocation)
- ? primaryContactInfo.location
- : null,
- isChildNumberShown || isCallSubjectShown ? null : primaryContactInfo.label,
- primaryContactInfo.photo,
- primaryContactInfo.photoType,
- primaryContactInfo.isSipCall,
- showContactPhoto,
- hasWorkCallProperty || isWorkContact,
- primary.isSpam(),
- primaryContactInfo.isLocalContact(),
- primary.answeringDisconnectsForegroundVideoCall(),
- shouldShowLocation(),
- primaryContactInfo.lookupKey,
- multimediaData,
- true /* showInCallButtonGrid */,
- primary.getNumberPresentation()));
+ PrimaryInfo.builder()
+ .setNumber(number)
+ .setName(primary.updateNameIfRestricted(name))
+ .setNameIsNumber(nameIsNumber)
+ .setLabel(
+ shouldShowLocationAsLabel(nameIsNumber, primaryContactInfo.shouldShowLocation)
+ ? primaryContactInfo.location
+ : null)
+ .setLocation(
+ isChildNumberShown || isCallSubjectShown ? null : primaryContactInfo.label)
+ .setPhoto(primaryContactInfo.photo)
+ .setPhotoType(primaryContactInfo.photoType)
+ .setIsSipCall(primaryContactInfo.isSipCall)
+ .setIsContactPhotoShown(showContactPhoto)
+ .setIsWorkCall(hasWorkCallProperty || isWorkContact)
+ .setIsSpam(primary.isSpam())
+ .setIsLocalContact(primaryContactInfo.isLocalContact())
+ .setAnsweringDisconnectsOngoingCall(primary.answeringDisconnectsForegroundVideoCall())
+ .setShouldShowLocation(shouldShowLocation())
+ .setContactInfoLookupKey(primaryContactInfo.lookupKey)
+ .setMultimediaData(multimediaData)
+ .setShowInCallButtonGrid(true)
+ .setNumberPresentation(primary.getNumberPresentation())
+ .build());
} else {
// Clear the primary display info.
- inCallScreen.setPrimary(PrimaryInfo.createEmptyPrimaryInfo());
+ inCallScreen.setPrimary(PrimaryInfo.empty());
}
if (isInCallScreenReady) {
@@ -1192,6 +1191,7 @@ public class CallCardPresenter
return inCallScreen;
}
+ /** Callback for contact lookup. */
public static class ContactLookupCallback implements ContactInfoCacheCallback {
private final WeakReference<CallCardPresenter> callCardPresenter;
diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java
index 8626e6d0e..3439a3e3c 100644
--- a/java/com/android/incallui/answer/impl/AnswerFragment.java
+++ b/java/com/android/incallui/answer/impl/AnswerFragment.java
@@ -149,7 +149,7 @@ public class AnswerFragment extends Fragment
private boolean buttonAcceptClicked;
private boolean buttonRejectClicked;
private boolean hasAnimatedEntry;
- private PrimaryInfo primaryInfo = PrimaryInfo.createEmptyPrimaryInfo();
+ private PrimaryInfo primaryInfo = PrimaryInfo.empty();
private PrimaryCallState primaryCallState;
private ArrayList<CharSequence> textResponses;
private SmsBottomSheetFragment textResponsesFragment;
@@ -523,13 +523,13 @@ public class AnswerFragment extends Fragment
return;
}
contactGridManager.setPrimary(primaryInfo);
- getAnswerMethod().setShowIncomingWillDisconnect(primaryInfo.answeringDisconnectsOngoingCall);
+ getAnswerMethod().setShowIncomingWillDisconnect(primaryInfo.answeringDisconnectsOngoingCall());
getAnswerMethod()
.setContactPhoto(
- primaryInfo.photoType == ContactPhotoType.CONTACT ? primaryInfo.photo : null);
+ primaryInfo.photoType() == ContactPhotoType.CONTACT ? primaryInfo.photo() : null);
updateDataFragment();
- if (primaryInfo.shouldShowLocation) {
+ if (primaryInfo.shouldShowLocation()) {
// Hide the avatar to make room for location
contactGridManager.setAvatarHidden(true);
}
@@ -562,8 +562,8 @@ public class AnswerFragment extends Fragment
MultimediaFragment.newInstance(
multimediaData,
false /* isInteractive */,
- !primaryInfo.isSpam /* showAvatar */,
- primaryInfo.isSpam);
+ !primaryInfo.isSpam() /* showAvatar */,
+ primaryInfo.isSpam());
}
} else if (shouldShowAvatar()) {
// Needs Avatar
@@ -1067,7 +1067,7 @@ public class AnswerFragment extends Fragment
return;
}
- if (!getResources().getBoolean(R.bool.answer_important_call_allowed) || primaryInfo.isSpam) {
+ if (!getResources().getBoolean(R.bool.answer_important_call_allowed) || primaryInfo.isSpam()) {
importanceBadge.setVisibility(View.GONE);
return;
}
@@ -1088,7 +1088,7 @@ public class AnswerFragment extends Fragment
if (isVideoUpgradeRequest()) {
return null;
}
- return primaryInfo.multimediaData;
+ return primaryInfo.multimediaData();
}
/** Shows the Avatar image if available. */
diff --git a/java/com/android/incallui/callpending/CallPendingActivity.java b/java/com/android/incallui/callpending/CallPendingActivity.java
index 47325d823..306eed8fb 100644
--- a/java/com/android/incallui/callpending/CallPendingActivity.java
+++ b/java/com/android/incallui/callpending/CallPendingActivity.java
@@ -177,25 +177,25 @@ public class CallPendingActivity extends FragmentActivity
String number = getNumber();
// DialerCall with caller that is a work contact.
- return new PrimaryInfo(
- number,
- name,
- name != null && name.equals(number),
- null /* location */,
- getPhoneLabel(),
- photo,
- ContactPhotoType.CONTACT,
- false /* isSipCall */,
- true /* isContactPhotoShown */,
- false /* isWorkCall */,
- false /* isSpam */,
- true /* isLocalContact */,
- false /* answeringDisconnectsOngoingCall */,
- false /* shouldShowLocation */,
- getLookupKey(),
- multimediaData,
- false /*showInCallButtonGrid */,
- TelecomManager.PRESENTATION_ALLOWED);
+ return PrimaryInfo.builder()
+ .setNumber(number)
+ .setName(name)
+ .setNameIsNumber(name != null && name.equals(number))
+ .setLabel(getPhoneLabel())
+ .setPhoto(photo)
+ .setPhotoType(ContactPhotoType.CONTACT)
+ .setIsSipCall(false)
+ .setIsContactPhotoShown(true)
+ .setIsWorkCall(false)
+ .setIsSpam(false)
+ .setIsLocalContact(true)
+ .setAnsweringDisconnectsOngoingCall(false)
+ .setShouldShowLocation(false)
+ .setContactInfoLookupKey(getLookupKey())
+ .setMultimediaData(multimediaData)
+ .setShowInCallButtonGrid(false)
+ .setNumberPresentation(TelecomManager.PRESENTATION_ALLOWED)
+ .build();
}
@Override
diff --git a/java/com/android/incallui/contactgrid/BottomRow.java b/java/com/android/incallui/contactgrid/BottomRow.java
index f9fc870dc..610eeca39 100644
--- a/java/com/android/incallui/contactgrid/BottomRow.java
+++ b/java/com/android/incallui/contactgrid/BottomRow.java
@@ -82,7 +82,7 @@ public class BottomRow {
boolean isSpamIconVisible = false;
boolean shouldPopulateAccessibilityEvent = true;
- if (isIncoming(state) && primaryInfo.isSpam) {
+ if (isIncoming(state) && primaryInfo.isSpam()) {
label = context.getString(R.string.contact_grid_incoming_suspected_spam);
isSpamIconVisible = true;
isHdIconVisible = false;
@@ -99,7 +99,7 @@ public class BottomRow {
}
} else {
label = getLabelForPhoneNumber(primaryInfo);
- shouldPopulateAccessibilityEvent = primaryInfo.nameIsNumber;
+ shouldPopulateAccessibilityEvent = primaryInfo.nameIsNumber();
}
return new Info(
@@ -114,15 +114,15 @@ public class BottomRow {
}
private static CharSequence getLabelForPhoneNumber(PrimaryInfo primaryInfo) {
- if (primaryInfo.location != null) {
- return primaryInfo.location;
+ if (primaryInfo.location() != null) {
+ return primaryInfo.location();
}
- if (!primaryInfo.nameIsNumber && !TextUtils.isEmpty(primaryInfo.number)) {
- CharSequence spannedNumber = spanDisplayNumber(primaryInfo.number);
- if (primaryInfo.label == null) {
+ if (!primaryInfo.nameIsNumber() && !TextUtils.isEmpty(primaryInfo.number())) {
+ CharSequence spannedNumber = spanDisplayNumber(primaryInfo.number());
+ if (primaryInfo.label() == null) {
return spannedNumber;
} else {
- return TextUtils.concat(primaryInfo.label, " ", spannedNumber);
+ return TextUtils.concat(primaryInfo.label(), " ", spannedNumber);
}
}
return null;
diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java
index 58d318892..6dec7646f 100644
--- a/java/com/android/incallui/contactgrid/ContactGridManager.java
+++ b/java/com/android/incallui/contactgrid/ContactGridManager.java
@@ -85,7 +85,7 @@ public class ContactGridManager {
private final TextView deviceNumberTextView;
private final View deviceNumberDivider;
- private PrimaryInfo primaryInfo = PrimaryInfo.createEmptyPrimaryInfo();
+ private PrimaryInfo primaryInfo = PrimaryInfo.empty();
private PrimaryCallState primaryCallState = PrimaryCallState.createEmptyPrimaryCallState();
private final LetterTileDrawable letterTile;
private boolean isInMultiWindowMode;
@@ -213,7 +213,7 @@ public class ContactGridManager {
}
boolean hasPhoto =
- primaryInfo.photo != null && primaryInfo.photoType == ContactPhotoType.CONTACT;
+ primaryInfo.photo() != null && primaryInfo.photoType() == ContactPhotoType.CONTACT;
if (!hasPhoto && !showAnonymousAvatar) {
avatarImageView.setVisibility(View.GONE);
return false;
@@ -271,17 +271,17 @@ public class ContactGridManager {
* </ul>
*/
private void updatePrimaryNameAndPhoto() {
- if (TextUtils.isEmpty(primaryInfo.name)) {
+ if (TextUtils.isEmpty(primaryInfo.name())) {
contactNameTextView.setText(null);
} else {
contactNameTextView.setText(
- primaryInfo.nameIsNumber
- ? PhoneNumberUtilsCompat.createTtsSpannable(primaryInfo.name)
- : primaryInfo.name);
+ primaryInfo.nameIsNumber()
+ ? PhoneNumberUtilsCompat.createTtsSpannable(primaryInfo.name())
+ : primaryInfo.name());
// Set direction of the name field
int nameDirection = View.TEXT_DIRECTION_INHERIT;
- if (primaryInfo.nameIsNumber) {
+ if (primaryInfo.nameIsNumber()) {
nameDirection = View.TEXT_DIRECTION_LTR;
}
contactNameTextView.setTextDirection(nameDirection);
@@ -292,23 +292,23 @@ public class ContactGridManager {
avatarImageView.setVisibility(View.GONE);
} else if (avatarSize > 0 && updateAvatarVisibility()) {
boolean hasPhoto =
- primaryInfo.photo != null && primaryInfo.photoType == ContactPhotoType.CONTACT;
+ primaryInfo.photo() != null && primaryInfo.photoType() == ContactPhotoType.CONTACT;
// Contact has a photo, don't render a letter tile.
if (hasPhoto) {
avatarImageView.setBackground(
DrawableConverter.getRoundedDrawable(
- context, primaryInfo.photo, avatarSize, avatarSize));
+ context, primaryInfo.photo(), avatarSize, avatarSize));
// Contact has a name, that isn't a number.
} else {
letterTile.setCanonicalDialerLetterTileDetails(
- primaryInfo.name,
- primaryInfo.contactInfoLookupKey,
+ primaryInfo.name(),
+ primaryInfo.contactInfoLookupKey(),
LetterTileDrawable.SHAPE_CIRCLE,
LetterTileDrawable.getContactTypeFromPrimitives(
primaryCallState.isVoiceMailNumber,
- primaryInfo.isSpam,
+ primaryInfo.isSpam(),
primaryCallState.isBusinessNumber,
- primaryInfo.numberPresentation,
+ primaryInfo.numberPresentation(),
primaryCallState.isConference));
// By invalidating the avatarImageView we force a redraw of the letter tile.
// This is required to properly display the updated letter tile iconography based on the
@@ -413,7 +413,7 @@ public class ContactGridManager {
deviceNumberTextView.setText(
context.getString(R.string.contact_grid_callback_number, primaryCallState.callbackNumber));
deviceNumberTextView.setVisibility(View.VISIBLE);
- if (primaryInfo.shouldShowLocation) {
+ if (primaryInfo.shouldShowLocation()) {
deviceNumberDivider.setVisibility(View.VISIBLE);
}
}
diff --git a/java/com/android/incallui/contactgrid/TopRow.java b/java/com/android/incallui/contactgrid/TopRow.java
index 556b11ba0..5eb38f98c 100644
--- a/java/com/android/incallui/contactgrid/TopRow.java
+++ b/java/com/android/incallui/contactgrid/TopRow.java
@@ -81,7 +81,7 @@ public class TopRow {
// Show phone number if it's not displayed in name (center row) or location field (bottom
// row).
if (shouldShowNumber(primaryInfo, true /* isIncoming */)) {
- label = TextUtils.concat(label, " ", spanDisplayNumber(primaryInfo.number));
+ label = TextUtils.concat(label, " ", spanDisplayNumber(primaryInfo.number()));
}
}
} else if (VideoUtils.hasSentVideoUpgradeRequest(state.sessionModificationState)
@@ -97,7 +97,7 @@ public class TopRow {
label = context.getString(R.string.incall_remotely_held);
} else if (state.state == State.ACTIVE
&& shouldShowNumber(primaryInfo, false /* isIncoming */)) {
- label = spanDisplayNumber(primaryInfo.number);
+ label = spanDisplayNumber(primaryInfo.number());
} else if (state.state == State.CALL_PENDING && !TextUtils.isEmpty(state.customLabel)) {
label = state.customLabel;
} else {
@@ -115,18 +115,18 @@ public class TopRow {
}
private static boolean shouldShowNumber(PrimaryInfo primaryInfo, boolean isIncoming) {
- if (primaryInfo.nameIsNumber) {
+ if (primaryInfo.nameIsNumber()) {
return false;
}
// Don't show number since it's already shown in bottom row of incoming screen if there is no
// location info.
- if (primaryInfo.location == null && isIncoming) {
+ if (primaryInfo.location() == null && isIncoming) {
return false;
}
- if (primaryInfo.isLocalContact && !isIncoming) {
+ if (primaryInfo.isLocalContact() && !isIncoming) {
return false;
}
- if (TextUtils.isEmpty(primaryInfo.number)) {
+ if (TextUtils.isEmpty(primaryInfo.number())) {
return false;
}
return true;
diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java
index a4dcd72a8..9a6d1c41e 100644
--- a/java/com/android/incallui/incall/impl/InCallFragment.java
+++ b/java/com/android/incallui/incall/impl/InCallFragment.java
@@ -253,10 +253,10 @@ public class InCallFragment extends Fragment
@Override
public void setPrimary(@NonNull PrimaryInfo primaryInfo) {
LogUtil.i("InCallFragment.setPrimary", primaryInfo.toString());
- setAdapterMedia(primaryInfo.multimediaData, primaryInfo.showInCallButtonGrid);
+ setAdapterMedia(primaryInfo.multimediaData(), primaryInfo.showInCallButtonGrid());
contactGridManager.setPrimary(primaryInfo);
- if (primaryInfo.shouldShowLocation) {
+ if (primaryInfo.shouldShowLocation()) {
// Hide the avatar to make room for location
contactGridManager.setAvatarHidden(true);
diff --git a/java/com/android/incallui/incall/protocol/PrimaryInfo.java b/java/com/android/incallui/incall/protocol/PrimaryInfo.java
index f7457c3ff..63dc39ed3 100644
--- a/java/com/android/incallui/incall/protocol/PrimaryInfo.java
+++ b/java/com/android/incallui/incall/protocol/PrimaryInfo.java
@@ -20,91 +20,116 @@ import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import com.android.dialer.common.LogUtil;
import com.android.dialer.multimedia.MultimediaData;
+import com.google.auto.value.AutoValue;
import java.util.Locale;
/** Information about the primary call. */
-public class PrimaryInfo {
- @Nullable public final String number;
- @Nullable public final String name;
- public final boolean nameIsNumber;
+@AutoValue
+public abstract class PrimaryInfo {
+ @Nullable
+ public abstract String number();
+
+ @Nullable
+ public abstract String name();
+
+ public abstract boolean nameIsNumber();
// This is from contacts and shows the type of number. For example, "Mobile".
- @Nullable public final String label;
- @Nullable public final String location;
- @Nullable public final Drawable photo;
- @ContactPhotoType public final int photoType;
- public final boolean isSipCall;
- public final boolean isContactPhotoShown;
- public final boolean isWorkCall;
- public final boolean isSpam;
- public final boolean isLocalContact;
- public final boolean answeringDisconnectsOngoingCall;
- public final boolean shouldShowLocation;
+ @Nullable
+ public abstract String label();
+
+ @Nullable
+ public abstract String location();
+
+ @Nullable
+ public abstract Drawable photo();
+
+ @ContactPhotoType
+ public abstract int photoType();
+
+ public abstract boolean isSipCall();
+
+ public abstract boolean isContactPhotoShown();
+
+ public abstract boolean isWorkCall();
+
+ public abstract boolean isSpam();
+
+ public abstract boolean isLocalContact();
+
+ public abstract boolean answeringDisconnectsOngoingCall();
+
+ public abstract boolean shouldShowLocation();
// Used for consistent LetterTile coloring.
- @Nullable public final String contactInfoLookupKey;
- @Nullable public final MultimediaData multimediaData;
- public final boolean showInCallButtonGrid;
- public final int numberPresentation;
-
- // TODO: Convert to autovalue. a bug
- public static PrimaryInfo createEmptyPrimaryInfo() {
- return new PrimaryInfo(
- null,
- null,
- false,
- null,
- null,
- null,
- ContactPhotoType.DEFAULT_PLACEHOLDER,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- null,
- null,
- true,
- -1);
+ @Nullable
+ public abstract String contactInfoLookupKey();
+
+ @Nullable
+ public abstract MultimediaData multimediaData();
+
+ public abstract boolean showInCallButtonGrid();
+
+ public abstract int numberPresentation();
+
+ public static Builder builder() {
+ return new AutoValue_PrimaryInfo.Builder();
+ }
+ /** Builder class for primary call info. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ public abstract Builder setNumber(String number);
+
+ public abstract Builder setName(String name);
+
+ public abstract Builder setNameIsNumber(boolean nameIsNumber);
+
+ public abstract Builder setLabel(String label);
+
+ public abstract Builder setLocation(String location);
+
+ public abstract Builder setPhoto(Drawable photo);
+
+ public abstract Builder setPhotoType(@ContactPhotoType int photoType);
+
+ public abstract Builder setIsSipCall(boolean isSipCall);
+
+ public abstract Builder setIsContactPhotoShown(boolean isContactPhotoShown);
+
+ public abstract Builder setIsWorkCall(boolean isWorkCall);
+
+ public abstract Builder setIsSpam(boolean isSpam);
+
+ public abstract Builder setIsLocalContact(boolean isLocalContact);
+
+ public abstract Builder setAnsweringDisconnectsOngoingCall(
+ boolean answeringDisconnectsOngoingCall);
+
+ public abstract Builder setShouldShowLocation(boolean shouldShowLocation);
+
+ public abstract Builder setContactInfoLookupKey(String contactInfoLookupKey);
+
+ public abstract Builder setMultimediaData(MultimediaData multimediaData);
+
+ public abstract Builder setShowInCallButtonGrid(boolean showInCallButtonGrid);
+
+ public abstract Builder setNumberPresentation(int numberPresentation);
+
+ public abstract PrimaryInfo build();
}
- public PrimaryInfo(
- @Nullable String number,
- @Nullable String name,
- boolean nameIsNumber,
- @Nullable String location,
- @Nullable String label,
- @Nullable Drawable photo,
- @ContactPhotoType int phototType,
- boolean isSipCall,
- boolean isContactPhotoShown,
- boolean isWorkCall,
- boolean isSpam,
- boolean isLocalContact,
- boolean answeringDisconnectsOngoingCall,
- boolean shouldShowLocation,
- @Nullable String contactInfoLookupKey,
- @Nullable MultimediaData multimediaData,
- boolean showInCallButtonGrid,
- int numberPresentation) {
- this.number = number;
- this.name = name;
- this.nameIsNumber = nameIsNumber;
- this.location = location;
- this.label = label;
- this.photo = photo;
- this.photoType = phototType;
- this.isSipCall = isSipCall;
- this.isContactPhotoShown = isContactPhotoShown;
- this.isWorkCall = isWorkCall;
- this.isSpam = isSpam;
- this.isLocalContact = isLocalContact;
- this.answeringDisconnectsOngoingCall = answeringDisconnectsOngoingCall;
- this.shouldShowLocation = shouldShowLocation;
- this.contactInfoLookupKey = contactInfoLookupKey;
- this.multimediaData = multimediaData;
- this.showInCallButtonGrid = showInCallButtonGrid;
- this.numberPresentation = numberPresentation;
+ public static PrimaryInfo empty() {
+ return PrimaryInfo.builder()
+ .setNameIsNumber(false)
+ .setPhotoType(ContactPhotoType.DEFAULT_PLACEHOLDER)
+ .setIsSipCall(false)
+ .setIsContactPhotoShown(false)
+ .setIsWorkCall(false)
+ .setIsSpam(false)
+ .setIsLocalContact(false)
+ .setAnsweringDisconnectsOngoingCall(false)
+ .setShouldShowLocation(false)
+ .setShowInCallButtonGrid(true)
+ .setNumberPresentation(-1)
+ .build();
}
@Override
@@ -113,13 +138,13 @@ public class PrimaryInfo {
Locale.US,
"PrimaryInfo, number: %s, name: %s, location: %s, label: %s, "
+ "photo: %s, photoType: %d, isPhotoVisible: %b, MultimediaData: %s",
- LogUtil.sanitizePhoneNumber(number),
- LogUtil.sanitizePii(name),
- LogUtil.sanitizePii(location),
- label,
- photo,
- photoType,
- isContactPhotoShown,
- multimediaData);
+ LogUtil.sanitizePhoneNumber(number()),
+ LogUtil.sanitizePii(name()),
+ LogUtil.sanitizePii(location()),
+ label(),
+ photo(),
+ photoType(),
+ isContactPhotoShown(),
+ multimediaData());
}
}
diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java
index ba99b2bf6..a33029501 100644
--- a/java/com/android/incallui/rtt/impl/RttChatFragment.java
+++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java
@@ -277,7 +277,7 @@ public class RttChatFragment extends Fragment
@Override
public void setPrimary(@NonNull PrimaryInfo primaryInfo) {
LogUtil.i("RttChatFragment.setPrimary", primaryInfo.toString());
- nameTextView.setText(primaryInfo.name);
+ nameTextView.setText(primaryInfo.name());
}
@Override