diff options
author | wangqi <wangqi@google.com> | 2018-04-02 14:32:09 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-02 14:47:12 -0700 |
commit | 9a625f8919189fd65de023bd15de5c64f7762b27 (patch) | |
tree | 0be28f62ae1118802701124dd24799e474f1429d /java/com/android/incallui/rtt/impl/RttChatFragment.java | |
parent | a462370fa5d9517c6dc0dee92a10e4231b46f43c (diff) |
Update contact photo for RTT call screen.
Bug: 70177426
Test: manual
PiperOrigin-RevId: 191348602
Change-Id: I332d53ab0c3c628b3dca0c184435bafcf2a13d02
Diffstat (limited to 'java/com/android/incallui/rtt/impl/RttChatFragment.java')
-rw-r--r-- | java/com/android/incallui/rtt/impl/RttChatFragment.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java index a181f88f0..a889408c0 100644 --- a/java/com/android/incallui/rtt/impl/RttChatFragment.java +++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java @@ -48,9 +48,12 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.FragmentUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.common.UiUtil; +import com.android.dialer.lettertile.LetterTileDrawable; +import com.android.dialer.util.DrawableConverter; import com.android.incallui.audioroute.AudioRouteSelectorDialogFragment.AudioRouteSelectorPresenter; import com.android.incallui.call.DialerCall.State; import com.android.incallui.hold.OnHoldFragment; +import com.android.incallui.incall.protocol.ContactPhotoType; import com.android.incallui.incall.protocol.InCallButtonIds; import com.android.incallui.incall.protocol.InCallButtonUi; import com.android.incallui.incall.protocol.InCallButtonUiDelegate; @@ -95,7 +98,8 @@ public class RttChatFragment extends Fragment private RttOverflowMenu overflowMenu; private SecondaryInfo savedSecondaryInfo; private TextView statusBanner; - private PrimaryInfo primaryInfo; + private PrimaryInfo primaryInfo = PrimaryInfo.empty(); + private PrimaryCallState primaryCallState = PrimaryCallState.empty(); private boolean isUserScrolling; private boolean shouldAutoScrolling; @@ -366,9 +370,35 @@ public class RttChatFragment extends Fragment public void setPrimary(@NonNull PrimaryInfo primaryInfo) { LogUtil.i("RttChatFragment.setPrimary", primaryInfo.toString()); nameTextView.setText(primaryInfo.name()); + updateAvatar(primaryInfo); this.primaryInfo = primaryInfo; } + private void updateAvatar(PrimaryInfo primaryInfo) { + boolean hasPhoto = + primaryInfo.photo() != null && primaryInfo.photoType() == ContactPhotoType.CONTACT; + // Contact has a photo, don't render a letter tile. + if (hasPhoto) { + int avatarSize = getResources().getDimensionPixelSize(R.dimen.rtt_avatar_size); + adapter.setAvatarDrawable( + DrawableConverter.getRoundedDrawable( + getContext(), primaryInfo.photo(), avatarSize, avatarSize)); + } else { + LetterTileDrawable letterTile = new LetterTileDrawable(getResources()); + letterTile.setCanonicalDialerLetterTileDetails( + primaryInfo.name(), + primaryInfo.contactInfoLookupKey(), + LetterTileDrawable.SHAPE_CIRCLE, + LetterTileDrawable.getContactTypeFromPrimitives( + primaryCallState.isVoiceMailNumber(), + primaryInfo.isSpam(), + primaryCallState.isBusinessNumber(), + primaryInfo.numberPresentation(), + primaryCallState.isConference())); + adapter.setAvatarDrawable(letterTile); + } + } + @Override public void onAttach(Context context) { super.onAttach(context); @@ -404,6 +434,7 @@ public class RttChatFragment extends Fragment @Override public void setCallState(@NonNull PrimaryCallState primaryCallState) { LogUtil.i("RttChatFragment.setCallState", primaryCallState.toString()); + this.primaryCallState = primaryCallState; if (!isTimerStarted && primaryCallState.state() == State.ACTIVE) { LogUtil.i( "RttChatFragment.setCallState", "starting timer with base: %d", chronometer.getBase()); |