1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.dialer.app.calllog; 18 19 import android.content.Context; 20 import android.util.AttributeSet; 21 import android.view.View; 22 import android.widget.QuickContactBadge; 23 import com.android.dialer.app.calllog.CallLogAdapter.OnActionModeStateChangedListener; 24 import com.android.dialer.logging.DialerImpression; 25 import com.android.dialer.logging.Logger; 26 27 /** Allows us to click the contact badge for non multi select mode. */ 28 class DialerQuickContactBadge extends QuickContactBadge { 29 30 private View.OnClickListener extraOnClickListener; 31 private OnActionModeStateChangedListener onActionModeStateChangeListener; 32 DialerQuickContactBadge(Context context)33 public DialerQuickContactBadge(Context context) { 34 super(context); 35 } 36 DialerQuickContactBadge(Context context, AttributeSet attrs)37 public DialerQuickContactBadge(Context context, AttributeSet attrs) { 38 super(context, attrs); 39 } 40 DialerQuickContactBadge(Context context, AttributeSet attrs, int defStyle)41 public DialerQuickContactBadge(Context context, AttributeSet attrs, int defStyle) { 42 super(context, attrs, defStyle); 43 } 44 45 @Override onClick(View v)46 public void onClick(View v) { 47 if (extraOnClickListener != null 48 && onActionModeStateChangeListener.isActionModeStateEnabled()) { 49 Logger.get(v.getContext()) 50 .logImpression(DialerImpression.Type.MULTISELECT_SINGLE_PRESS_TAP_VIA_CONTACT_BADGE); 51 extraOnClickListener.onClick(v); 52 } else { 53 super.onClick(v); 54 } 55 } 56 setMulitSelectListeners( View.OnClickListener extraOnClickListener, OnActionModeStateChangedListener actionModeStateChangeListener)57 public void setMulitSelectListeners( 58 View.OnClickListener extraOnClickListener, 59 OnActionModeStateChangedListener actionModeStateChangeListener) { 60 this.extraOnClickListener = extraOnClickListener; 61 onActionModeStateChangeListener = actionModeStateChangeListener; 62 } 63 } 64