From 756f013f4797403347ae43a5ab60e8b9e884f124 Mon Sep 17 00:00:00 2001 From: linyuh Date: Thu, 29 Mar 2018 10:10:48 -0700 Subject: Badge contact photos for video calls in the bottom sheet. Bug: 70988682 Test: Existing tests PiperOrigin-RevId: 190946639 Change-Id: Iaa8294e8ba6e85ab3c27bb2e67200d7972a240f2 --- .../dialer/calllog/ui/NewCallLogAdapter.java | 7 +----- .../dialer/calllog/ui/NewCallLogViewHolder.java | 13 ++--------- .../dialer/calllog/ui/menu/NewCallLogMenu.java | 9 ++------ .../HistoryItemActionBottomSheet.java | 25 ++++++++-------------- .../res/layout/contact_layout.xml | 15 ++++++------- .../voicemail/listui/NewVoicemailViewHolder.java | 3 +-- .../voicemail/listui/menu/NewVoicemailMenu.java | 6 ++---- .../widget/res/layout/contact_photo_view.xml | 1 + 8 files changed, 25 insertions(+), 54 deletions(-) diff --git a/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java b/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java index f7ba9efde..05a339978 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java @@ -25,8 +25,6 @@ import android.view.LayoutInflater; import android.view.ViewGroup; import com.android.dialer.calllogutils.CallLogDates; import com.android.dialer.common.Assert; -import com.android.dialer.glidephotomanager.GlidePhotoManager; -import com.android.dialer.glidephotomanager.GlidePhotoManagerComponent; import com.android.dialer.time.Clock; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -55,7 +53,6 @@ final class NewCallLogAdapter extends RecyclerView.Adapter { private final Clock clock; private final RealtimeRowProcessor realtimeRowProcessor; - private final GlidePhotoManager glidePhotoManager; private Cursor cursor; @@ -72,7 +69,6 @@ final class NewCallLogAdapter extends RecyclerView.Adapter { this.cursor = cursor; this.clock = clock; this.realtimeRowProcessor = CallLogUiComponent.get(context).realtimeRowProcessor(); - this.glidePhotoManager = GlidePhotoManagerComponent.get(context).glidePhotoManager(); setHeaderPositions(); } @@ -142,8 +138,7 @@ final class NewCallLogAdapter extends RecyclerView.Adapter { LayoutInflater.from(viewGroup.getContext()) .inflate(R.layout.new_call_log_entry, viewGroup, false), clock, - realtimeRowProcessor, - glidePhotoManager); + realtimeRowProcessor); default: throw Assert.createUnsupportedOperationFailException("Unsupported view type: " + viewType); } diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java index 9809d97f5..f322b562b 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -34,7 +34,6 @@ import com.android.dialer.calllogutils.NumberAttributesConverter; 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.oem.MotorolaUtils; import com.android.dialer.time.Clock; import com.android.dialer.widget.ContactPhotoView; @@ -62,15 +61,9 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { private final RealtimeRowProcessor realtimeRowProcessor; private final ExecutorService uiExecutorService; - private final GlidePhotoManager glidePhotoManager; - private long currentRowId; - NewCallLogViewHolder( - View view, - Clock clock, - RealtimeRowProcessor realtimeRowProcessor, - GlidePhotoManager glidePhotoManager) { + NewCallLogViewHolder(View view, Clock clock, RealtimeRowProcessor realtimeRowProcessor) { super(view); this.context = view.getContext(); contactPhotoView = view.findViewById(R.id.contact_photo_view); @@ -86,7 +79,6 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { this.clock = clock; this.realtimeRowProcessor = realtimeRowProcessor; - this.glidePhotoManager = glidePhotoManager; uiExecutorService = DialerExecutorComponent.get(context).uiExecutor(); } @@ -251,8 +243,7 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { } private void setOnClickListenerForMenuButon(CoalescedRow row) { - menuButton.setOnClickListener( - NewCallLogMenu.createOnClickListener(context, row, glidePhotoManager)); + menuButton.setOnClickListener(NewCallLogMenu.createOnClickListener(context, row)); } private class RealtimeRowFutureCallback implements FutureCallback { diff --git a/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java b/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java index 78354caac..dabb9bbe4 100644 --- a/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java +++ b/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java @@ -22,7 +22,6 @@ import android.view.View; import com.android.dialer.calllog.CallLogComponent; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.common.concurrent.DefaultFutureCallback; -import com.android.dialer.glidephotomanager.GlidePhotoManager; import com.android.dialer.historyitemactions.HistoryItemActionBottomSheet; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; @@ -31,14 +30,10 @@ import com.google.common.util.concurrent.MoreExecutors; public final class NewCallLogMenu { /** Creates and returns the OnClickListener which opens the menu for the provided row. */ - public static View.OnClickListener createOnClickListener( - Context context, CoalescedRow row, GlidePhotoManager glidePhotoManager) { + public static View.OnClickListener createOnClickListener(Context context, CoalescedRow row) { return view -> { HistoryItemActionBottomSheet.show( - context, - BottomSheetHeader.fromRow(context, row), - Modules.fromRow(context, row), - glidePhotoManager); + context, BottomSheetHeader.fromRow(context, row), Modules.fromRow(context, row)); // If the user opens the bottom sheet for a new call, clear the notifications and make the row // not bold immediately. To do this, mark all of the calls in group as not new. diff --git a/java/com/android/dialer/historyitemactions/HistoryItemActionBottomSheet.java b/java/com/android/dialer/historyitemactions/HistoryItemActionBottomSheet.java index ce303272c..79205a7d9 100644 --- a/java/com/android/dialer/historyitemactions/HistoryItemActionBottomSheet.java +++ b/java/com/android/dialer/historyitemactions/HistoryItemActionBottomSheet.java @@ -28,42 +28,37 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.android.dialer.common.Assert; -import com.android.dialer.glidephotomanager.GlidePhotoManager; +import com.android.dialer.widget.ContactPhotoView; import java.util.List; /** * {@link BottomSheetDialog} used to show a list of actions in a bottom sheet menu. * - *

{@link #show(Context, HistoryItemBottomSheetHeaderInfo, List, GlidePhotoManager)} should be - * used to create and display the menu. Modules are built using {@link HistoryItemActionModule} and - * some defaults are provided by {@link IntentModule} and {@link DividerModule}. + *

{@link #show(Context, HistoryItemBottomSheetHeaderInfo, List)} should be used to create and + * display the menu. Modules are built using {@link HistoryItemActionModule} and some defaults are + * provided by {@link IntentModule} and {@link DividerModule}. */ public class HistoryItemActionBottomSheet extends BottomSheetDialog implements OnClickListener { private final List modules; private final HistoryItemBottomSheetHeaderInfo historyItemBottomSheetHeaderInfo; - private final GlidePhotoManager glidePhotoManager; private HistoryItemActionBottomSheet( Context context, HistoryItemBottomSheetHeaderInfo historyItemBottomSheetHeaderInfo, - List modules, - GlidePhotoManager glidePhotoManager) { + List modules) { super(context); this.modules = modules; this.historyItemBottomSheetHeaderInfo = historyItemBottomSheetHeaderInfo; - this.glidePhotoManager = glidePhotoManager; setContentView(LayoutInflater.from(context).inflate(R.layout.sheet_layout, null)); } public static HistoryItemActionBottomSheet show( Context context, HistoryItemBottomSheetHeaderInfo historyItemBottomSheetHeaderInfo, - List modules, - GlidePhotoManager glidePhotoManager) { + List modules) { HistoryItemActionBottomSheet sheet = - new HistoryItemActionBottomSheet( - context, historyItemBottomSheetHeaderInfo, modules, glidePhotoManager); + new HistoryItemActionBottomSheet(context, historyItemBottomSheetHeaderInfo, modules); sheet.show(); return sheet; } @@ -87,10 +82,8 @@ public class HistoryItemActionBottomSheet extends BottomSheetDialog implements O LayoutInflater inflater = LayoutInflater.from(getContext()); View contactView = inflater.inflate(R.layout.contact_layout, container, false); - // TODO(zachh): The contact image should be badged with a video icon if it is for a video call. - glidePhotoManager.loadQuickContactBadge( - contactView.findViewById(R.id.quick_contact_photo), - historyItemBottomSheetHeaderInfo.getPhotoInfo()); + ContactPhotoView contactPhotoView = contactView.findViewById(R.id.contact_photo_view); + contactPhotoView.setPhoto(historyItemBottomSheetHeaderInfo.getPhotoInfo()); TextView primaryTextView = contactView.findViewById(R.id.primary_text); TextView secondaryTextView = contactView.findViewById(R.id.secondary_text); diff --git a/java/com/android/dialer/historyitemactions/res/layout/contact_layout.xml b/java/com/android/dialer/historyitemactions/res/layout/contact_layout.xml index 4deef3e07..f2dc8c7ac 100644 --- a/java/com/android/dialer/historyitemactions/res/layout/contact_layout.xml +++ b/java/com/android/dialer/historyitemactions/res/layout/contact_layout.xml @@ -23,14 +23,13 @@ android:gravity="center_vertical" android:orientation="horizontal"> - + HistoryItemActionBottomSheet.show( context, BottomSheetHeader.fromVoicemailEntry(voicemailEntry), - Modules.fromVoicemailEntry(context, voicemailEntry), - glidePhotoManager); + Modules.fromVoicemailEntry(context, voicemailEntry)); } } diff --git a/java/com/android/dialer/widget/res/layout/contact_photo_view.xml b/java/com/android/dialer/widget/res/layout/contact_photo_view.xml index e505e5866..2f5cd9e3d 100644 --- a/java/com/android/dialer/widget/res/layout/contact_photo_view.xml +++ b/java/com/android/dialer/widget/res/layout/contact_photo_view.xml @@ -19,6 +19,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="52dp" android:layout_height="44dp" + android:layout_gravity="center" android:focusable="false">