diff options
author | wangqi <wangqi@google.com> | 2018-04-02 23:50:18 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-04-02 23:50:18 +0000 |
commit | 80c471d8e406d260576cc890bf46e9c6f8eb23af (patch) | |
tree | f0af43276d02796da18ae570eb3bffd6264f7953 | |
parent | 49bfd2945e6231161618045ca7061cc270552ffe (diff) | |
parent | 79f874e7ff797a78d93f065806abf99e9b58af6b (diff) |
Merge changes I332d53ab,I18d63f4e am: 8b25da85e9
am: 79f874e7ff
Change-Id: I11cef944129cd952a07cde10359abc54cef7027c
6 files changed, 53 insertions, 8 deletions
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java index 2f88c8836..1f7a0d396 100644 --- a/java/com/android/incallui/CallCardPresenter.java +++ b/java/com/android/incallui/CallCardPresenter.java @@ -36,6 +36,8 @@ import android.support.v4.content.ContextCompat; import android.telecom.Call.Details; import android.telecom.StatusHints; import android.telecom.TelecomManager; +import android.text.BidiFormatter; +import android.text.TextDirectionHeuristics; import android.text.TextUtils; import android.view.Display; import android.view.View; @@ -987,7 +989,10 @@ public class CallCardPresenter ContactDisplayUtils.getPreferredDisplayName( contactInfo.namePrimary, contactInfo.nameAlternative, contactsPreferences); if (TextUtils.isEmpty(preferredName)) { - return contactInfo.number; + return TextUtils.isEmpty(contactInfo.number) + ? null + : BidiFormatter.getInstance() + .unicodeWrap(contactInfo.number, TextDirectionHeuristics.LTR); } return preferredName; } diff --git a/java/com/android/incallui/rtt/impl/RttChatAdapter.java b/java/com/android/incallui/rtt/impl/RttChatAdapter.java index 955fc9fec..fb73d19c0 100644 --- a/java/com/android/incallui/rtt/impl/RttChatAdapter.java +++ b/java/com/android/incallui/rtt/impl/RttChatAdapter.java @@ -17,6 +17,7 @@ package com.android.incallui.rtt.impl; import android.content.Context; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -32,6 +33,8 @@ import java.util.List; /** Adapter class for holding RTT chat data. */ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolder> { + private Drawable avatarDrawable; + interface MessageListener { void onUpdateRemoteMessage(int position); @@ -75,7 +78,7 @@ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolde if (i > 0) { isSameGroup = rttMessages.get(i).isRemote == rttMessages.get(i - 1).isRemote; } - rttChatMessageViewHolder.setMessage(rttMessages.get(i), isSameGroup); + rttChatMessageViewHolder.setMessage(rttMessages.get(i), isSameGroup, avatarDrawable); } @Override @@ -169,4 +172,8 @@ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolde bundle.putParcelableArrayList(KEY_MESSAGE_DATA, (ArrayList<RttChatMessage>) rttMessages); bundle.putInt(KEY_LAST_LOCAL_MESSAGE, lastIndexOfLocalMessage); } + + void setAvatarDrawable(Drawable drawable) { + avatarDrawable = drawable; + } } 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()); diff --git a/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java b/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java index c88786aa4..2beea9530 100644 --- a/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java +++ b/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java @@ -17,6 +17,7 @@ package com.android.incallui.rtt.impl; import android.content.res.Resources; +import android.graphics.drawable.Drawable; import android.support.v7.widget.RecyclerView.ViewHolder; import android.view.Gravity; import android.view.View; @@ -41,7 +42,7 @@ public class RttChatMessageViewHolder extends ViewHolder { resources = view.getResources(); } - void setMessage(RttChatMessage message, boolean isSameGroup) { + void setMessage(RttChatMessage message, boolean isSameGroup, Drawable imageDrawable) { messageTextView.setText(message.getContent()); LinearLayout.LayoutParams params = (LayoutParams) container.getLayoutParams(); params.gravity = message.isRemote ? Gravity.START : Gravity.END; @@ -56,7 +57,7 @@ public class RttChatMessageViewHolder extends ViewHolder { avatarImageView.setVisibility(View.INVISIBLE); } else { avatarImageView.setVisibility(View.VISIBLE); - avatarImageView.setImageResource(R.drawable.product_logo_avatar_anonymous_white_color_120); + avatarImageView.setImageDrawable(imageDrawable); } } else { avatarImageView.setVisibility(View.GONE); diff --git a/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml b/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml index 54b0f4f6a..5f1714250 100644 --- a/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml +++ b/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml @@ -26,8 +26,8 @@ android:orientation="horizontal"> <ImageView android:id="@+id/rtt_chat_avatar" - android:layout_width="40dp" - android:layout_height="40dp" + android:layout_width="@dimen/rtt_avatar_size" + android:layout_height="@dimen/rtt_avatar_size" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:visibility="gone" diff --git a/java/com/android/incallui/rtt/impl/res/values/dimens.xml b/java/com/android/incallui/rtt/impl/res/values/dimens.xml index a6418d70e..c3d28da77 100644 --- a/java/com/android/incallui/rtt/impl/res/values/dimens.xml +++ b/java/com/android/incallui/rtt/impl/res/values/dimens.xml @@ -19,4 +19,5 @@ <dimen name="rtt_same_group_message_margin_top">2dp</dimen> <dimen name="rtt_overflow_menu_width">180dp</dimen> <dimen name="rtt_overflow_menu_elevation">8dp</dimen> -</resources>
\ No newline at end of file + <dimen name="rtt_avatar_size">40dp</dimen> +</resources> |