From 9e8b6733962641d137c4d084b843c069b6545953 Mon Sep 17 00:00:00 2001 From: linyuh Date: Tue, 6 Mar 2018 12:13:27 -0800 Subject: Covnert @AutoValue PhotoInfo into a proto. Bug: 74202944 Test: Existing tests PiperOrigin-RevId: 188060790 Change-Id: I4d79a353abf767935383d4149f261f5e96fd7acb --- .../android/dialer/calllog/ui/NewCallLogViewHolder.java | 14 +++++++++----- .../android/dialer/calllog/ui/menu/PrimaryAction.java | 16 +++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'java/com/android/dialer/calllog/ui') diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java index cf016083f..4c2d124d7 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -22,6 +22,7 @@ import android.database.Cursor; import android.provider.CallLog.Calls; import android.support.annotation.DrawableRes; import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; import android.view.View; import android.widget.ImageView; import android.widget.QuickContactBadge; @@ -35,6 +36,7 @@ import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.compat.AppCompatConstants; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.glidephotomanager.GlidePhotoManager; +import com.android.dialer.glidephotomanager.PhotoInfo; import com.android.dialer.oem.MotorolaUtils; import com.android.dialer.time.Clock; import com.google.common.util.concurrent.FutureCallback; @@ -150,11 +152,13 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { } private void setPhoto(CoalescedRow row) { - glidePhotoManager.loadQuickContactBadge( - quickContactBadge, - NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) - .setFormattedNumber(row.formattedNumber()) - .build()); + PhotoInfo.Builder photoInfoBuilder = + NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()); + if (!TextUtils.isEmpty(row.formattedNumber())) { + photoInfoBuilder.setFormattedNumber(row.formattedNumber()); + } + + glidePhotoManager.loadQuickContactBadge(quickContactBadge, photoInfoBuilder.build()); } private void setFeatureIcons(CoalescedRow row) { diff --git a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java index de4a70c30..aec4dc6d8 100644 --- a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java +++ b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java @@ -18,10 +18,12 @@ package com.android.dialer.calllog.ui.menu; import android.content.Context; import android.provider.CallLog.Calls; +import android.text.TextUtils; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.calllogutils.CallLogEntryText; import com.android.dialer.calllogutils.CallLogIntents; import com.android.dialer.calllogutils.NumberAttributesConverter; +import com.android.dialer.glidephotomanager.PhotoInfo; import com.android.dialer.historyitemactions.HistoryItemPrimaryActionInfo; /** Configures the primary action row (top row) for the bottom sheet. */ @@ -29,13 +31,17 @@ final class PrimaryAction { static HistoryItemPrimaryActionInfo fromRow(Context context, CoalescedRow row) { CharSequence primaryText = CallLogEntryText.buildPrimaryText(context, row); + + PhotoInfo.Builder photoInfoBuilder = + NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) + .setIsVideo((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO); + if (!TextUtils.isEmpty(row.formattedNumber())) { + photoInfoBuilder.setFormattedNumber(row.formattedNumber()); + } + return HistoryItemPrimaryActionInfo.builder() .setNumber(row.number()) - .setPhotoInfo( - NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) - .setFormattedNumber(row.formattedNumber()) - .setIsVideo((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) - .build()) + .setPhotoInfo(photoInfoBuilder.build()) .setPrimaryText(primaryText) .setSecondaryText(CallLogEntryText.buildSecondaryTextForBottomSheet(context, row)) .setIntent(CallLogIntents.getCallBackIntent(context, row)) -- cgit v1.2.3