summaryrefslogtreecommitdiff
path: root/java/com/android/contacts/common/list
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-06-08 00:59:55 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-08 00:59:55 +0000
commitc67d658e7daa453fe9ad9fd1a37f81eaf2048c44 (patch)
treeb9bbc285430ffb5363a70eb27e382c38f5a85b7a /java/com/android/contacts/common/list
parent75233ff03785f24789b32039ac2c208805b7e506 (diff)
parent274b6d320edb3c33e7b3a95c43a811829486a777 (diff)
Update AOSP Dialer source from internal google3 repository at cl/158012278. am: 91ce7d2a47
am: 274b6d320e Change-Id: Iecf4325f314bf6c3324187e6406c8aae4675dd63
Diffstat (limited to 'java/com/android/contacts/common/list')
-rw-r--r--java/com/android/contacts/common/list/ContactEntryListAdapter.java9
-rw-r--r--java/com/android/contacts/common/list/ContactEntryListFragment.java1
-rw-r--r--java/com/android/contacts/common/list/ContactListItemView.java216
-rw-r--r--java/com/android/contacts/common/list/ContactTileView.java19
-rw-r--r--java/com/android/contacts/common/list/PhoneNumberListAdapter.java56
-rw-r--r--java/com/android/contacts/common/list/PhoneNumberPickerFragment.java66
-rw-r--r--java/com/android/contacts/common/list/ViewPagerTabs.java29
7 files changed, 187 insertions, 209 deletions
diff --git a/java/com/android/contacts/common/list/ContactEntryListAdapter.java b/java/com/android/contacts/common/list/ContactEntryListAdapter.java
index 18bbae382..064214ef2 100644
--- a/java/com/android/contacts/common/list/ContactEntryListAdapter.java
+++ b/java/com/android/contacts/common/list/ContactEntryListAdapter.java
@@ -26,7 +26,6 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Directory;
import android.text.TextUtils;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -39,7 +38,10 @@ import com.android.contacts.common.ContactsUtils;
import com.android.contacts.common.R;
import com.android.contacts.common.compat.DirectoryCompat;
import com.android.contacts.common.util.SearchUtil;
+import com.android.dialer.common.LogUtil;
import com.android.dialer.compat.CompatUtils;
+import com.android.dialer.logging.InteractionEvent;
+import com.android.dialer.logging.Logger;
import java.util.HashSet;
/**
@@ -354,7 +356,7 @@ public abstract class ContactEntryListAdapter extends IndexerListAdapter {
if (cursor.getCount() == 0) {
// Directory table must have at least local directory, without which this adapter will
// enter very weird state.
- Log.e(
+ LogUtil.e(
TAG,
"Directory search loader returned an empty cursor, which implies we have "
+ "no directory entries.",
@@ -678,6 +680,9 @@ public abstract class ContactEntryListAdapter extends IndexerListAdapter {
// mimetype here is reasonable.
quickContact.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE);
}
+ Logger.get(mContext)
+ .logQuickContactOnTouch(
+ quickContact, InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_SEARCH, true);
if (photoId != 0 || photoUriColumn == -1) {
getPhotoLoader().loadThumbnail(quickContact, photoId, mDarkTheme, mCircularPhotos, null);
diff --git a/java/com/android/contacts/common/list/ContactEntryListFragment.java b/java/com/android/contacts/common/list/ContactEntryListFragment.java
index 278175c0b..146986f75 100644
--- a/java/com/android/contacts/common/list/ContactEntryListFragment.java
+++ b/java/com/android/contacts/common/list/ContactEntryListFragment.java
@@ -555,7 +555,6 @@ public abstract class ContactEntryListFragment<T extends ContactEntryListAdapter
protected void setSearchMode(boolean flag) {
if (mSearchMode != flag) {
mSearchMode = flag;
- setSectionHeaderDisplayEnabled(!mSearchMode);
if (!flag) {
mDirectoryListStatus = STATUS_NOT_LOADED;
diff --git a/java/com/android/contacts/common/list/ContactListItemView.java b/java/com/android/contacts/common/list/ContactListItemView.java
index 7a3194720..5a2749178 100644
--- a/java/com/android/contacts/common/list/ContactListItemView.java
+++ b/java/com/android/contacts/common/list/ContactListItemView.java
@@ -30,8 +30,8 @@ import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.SearchSnippets;
import android.support.annotation.IntDef;
+import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
-import android.support.v4.graphics.drawable.DrawableCompat;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
@@ -55,7 +55,6 @@ import com.android.contacts.common.format.TextHighlighter;
import com.android.contacts.common.list.PhoneNumberListAdapter.Listener;
import com.android.contacts.common.util.ContactDisplayUtils;
import com.android.contacts.common.util.SearchUtil;
-import com.android.dialer.compat.CompatUtils;
import com.android.dialer.util.ViewUtil;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -81,13 +80,15 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
/** IntDef for indices of ViewPager tabs. */
@Retention(RetentionPolicy.SOURCE)
- @IntDef({NONE, VIDEO, CALL_AND_SHARE})
+ @IntDef({NONE, VIDEO, LIGHTBRINGER, CALL_AND_SHARE})
public @interface CallToAction {}
public static final int NONE = 0;
public static final int VIDEO = 1;
- public static final int CALL_AND_SHARE = 2;
+ public static final int LIGHTBRINGER = 2;
+ public static final int CALL_AND_SHARE = 3;
+ private final PhotoPosition mPhotoPosition = getDefaultPhotoPosition();
private static final Pattern SPLIT_PATTERN =
Pattern.compile("([\\w-\\.]+)@((?:[\\w]+\\.)+)([a-zA-Z]{2,4})|[\\w]+");
static final char SNIPPET_START_MATCH = '[';
@@ -106,7 +107,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
private int mNameTextViewTextSize;
private int mHeaderWidth;
private Drawable mActivatedBackgroundDrawable;
- private int mCallToActionSize = 32;
+ private int mCallToActionSize = 48;
private int mCallToActionMargin = 16;
// Set in onLayout. Represent left and right position of the View on the screen.
private int mLeftOffset;
@@ -122,10 +123,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
private String mHighlightedPrefix;
/** Indicates whether the view should leave room for the "video call" icon. */
private boolean mSupportVideoCall;
- /** Indicates whether the view should leave room for the "call and share" icon. */
- private boolean mSupportCallAndShare;
- private PhotoPosition mPhotoPosition = getDefaultPhotoPosition(false /* normal/non opposite */);
// Header layout data
private TextView mHeaderTextView;
private boolean mIsSectionHeaderEnabled;
@@ -139,7 +137,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
private TextView mSnippetView;
private TextView mStatusView;
private ImageView mPresenceIcon;
- private ImageView mCallToAction;
+ @NonNull private final ImageView mCallToActionView;
private ImageView mWorkProfileIcon;
private ColorStateList mSecondaryTextColor;
private int mDefaultPhotoViewSize = 0;
@@ -181,23 +179,14 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
private Rect mBoundsWithoutHeader = new Rect();
private CharSequence mUnknownNameText;
- public ContactListItemView(Context context) {
- super(context);
+ private String mPhoneNumber;
+ private int mPosition = -1;
+ private @CallToAction int mCallToAction = NONE;
- mTextHighlighter = new TextHighlighter(Typeface.BOLD);
- mNameHighlightSequence = new ArrayList<>();
- mNumberHighlightSequence = new ArrayList<>();
- }
-
- public ContactListItemView(
- Context context,
- AttributeSet attrs,
- boolean supportVideoCallIcon,
- boolean supportCallAndShare) {
+ public ContactListItemView(Context context, AttributeSet attrs, boolean supportVideoCallIcon) {
this(context, attrs);
mSupportVideoCall = supportVideoCallIcon;
- mSupportCallAndShare = supportCallAndShare;
}
public ContactListItemView(Context context, AttributeSet attrs) {
@@ -284,19 +273,20 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
mNameHighlightSequence = new ArrayList<>();
mNumberHighlightSequence = new ArrayList<>();
+ mCallToActionView = new ImageView(getContext());
+ mCallToActionView.setId(R.id.call_to_action);
+ mCallToActionView.setLayoutParams(new LayoutParams(mCallToActionSize, mCallToActionSize));
+ mCallToActionView.setScaleType(ScaleType.CENTER);
+ mCallToActionView.setImageTintList(
+ ContextCompat.getColorStateList(getContext(), R.color.search_video_call_icon_tint));
+ addView(mCallToActionView);
+
setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
}
- public static PhotoPosition getDefaultPhotoPosition(boolean opposite) {
- final Locale locale = Locale.getDefault();
- final int layoutDirection = TextUtils.getLayoutDirectionFromLocale(locale);
- switch (layoutDirection) {
- case View.LAYOUT_DIRECTION_RTL:
- return (opposite ? PhotoPosition.LEFT : PhotoPosition.RIGHT);
- case View.LAYOUT_DIRECTION_LTR:
- default:
- return (opposite ? PhotoPosition.RIGHT : PhotoPosition.LEFT);
- }
+ public static PhotoPosition getDefaultPhotoPosition() {
+ int layoutDirection = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault());
+ return layoutDirection == View.LAYOUT_DIRECTION_RTL ? PhotoPosition.RIGHT : PhotoPosition.LEFT;
}
/**
@@ -333,35 +323,47 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
* @param position The position in the adapter of the call to action.
*/
public void setCallToAction(@CallToAction int action, Listener listener, int position) {
- int drawable;
+ mCallToAction = action;
+ mPosition = position;
+
+ Drawable drawable;
int description;
OnClickListener onClickListener;
- if (action == CALL_AND_SHARE && mSupportCallAndShare) {
- drawable = R.drawable.ic_call_and_share;
- description = R.string.description_search_video_call;
+ if (action == CALL_AND_SHARE) {
+ drawable = getContext().getResources().getDrawable(R.drawable.ic_phone_attach);
+ drawable.setAutoMirrored(true);
+ description = R.string.description_search_call_and_share;
onClickListener = v -> listener.onCallAndShareIconClicked(position);
} else if (action == VIDEO && mSupportVideoCall) {
- drawable = R.drawable.ic_search_video_call;
- description = R.string.description_search_call_and_share;
+ drawable =
+ getContext().getResources().getDrawable(R.drawable.quantum_ic_videocam_vd_theme_24);
+ drawable.setAutoMirrored(true);
+ description = R.string.description_search_video_call;
onClickListener = v -> listener.onVideoCallIconClicked(position);
+ } else if (action == LIGHTBRINGER) {
+ drawable =
+ getContext().getResources().getDrawable(R.drawable.quantum_ic_videocam_vd_theme_24);
+ drawable.setAutoMirrored(true);
+ description = R.string.description_search_video_call;
+ onClickListener = v -> listener.onLightbringerIconClicked(position);
} else {
- if (mCallToAction != null) {
- mCallToAction.setVisibility(View.GONE);
- mCallToAction.setOnClickListener(null);
- }
+ mCallToActionView.setVisibility(View.GONE);
+ mCallToActionView.setOnClickListener(null);
return;
}
- if (mCallToAction == null) {
- mCallToAction = new ImageView(getContext());
- mCallToAction.setLayoutParams(new LayoutParams(mCallToActionSize, mCallToActionSize));
- mCallToAction.setScaleType(ScaleType.CENTER);
- addView(mCallToAction);
- }
- mCallToAction.setContentDescription(getContext().getString(description));
- mCallToAction.setOnClickListener(onClickListener);
- mCallToAction.setImageResource(drawable);
- mCallToAction.setVisibility(View.VISIBLE);
+ mCallToActionView.setContentDescription(getContext().getString(description));
+ mCallToActionView.setOnClickListener(onClickListener);
+ mCallToActionView.setImageDrawable(drawable);
+ mCallToActionView.setVisibility(View.VISIBLE);
+ }
+
+ public @CallToAction int getCallToAction() {
+ return mCallToAction;
+ }
+
+ public int getPosition() {
+ return mPosition;
}
/**
@@ -376,18 +378,6 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
mSupportVideoCall = supportVideoCall;
}
- /**
- * Sets whether the view supports a call and share icon. This is independent of whether the view
- * is actually showing an icon. Support for the icon ensures that the layout leaves space for it,
- * should it be shown.
- *
- * @param supportCallAndShare {@code true} if the call and share icon is supported, {@code false}
- * otherwise.
- */
- public void setSupportCallAndShareIcon(boolean supportCallAndShare) {
- mSupportCallAndShare = supportCallAndShare;
- }
-
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// We will match parent's width and wrap content vertically, but make sure
@@ -423,9 +413,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
effectiveWidth -= mHeaderWidth + mGapBetweenImageAndText;
}
- if (mSupportVideoCall || mSupportCallAndShare) {
- effectiveWidth -= (mCallToActionSize + mCallToActionMargin);
- }
+ effectiveWidth -= (mCallToActionSize + mCallToActionMargin);
// Go over all visible text views and measure actual width of each of them.
// Also calculate their heights to get the total height for this entire view.
@@ -496,11 +484,9 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
mStatusTextViewHeight = mPresenceIcon.getMeasuredHeight();
}
- if ((mSupportVideoCall || mSupportCallAndShare) && isVisible(mCallToAction)) {
- mCallToAction.measure(
- MeasureSpec.makeMeasureSpec(mCallToActionSize, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(mCallToActionSize, MeasureSpec.EXACTLY));
- }
+ mCallToActionView.measure(
+ MeasureSpec.makeMeasureSpec(mCallToActionSize, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(mCallToActionSize, MeasureSpec.EXACTLY));
if (isVisible(mWorkProfileIcon)) {
mWorkProfileIcon.measure(
@@ -629,34 +615,30 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
leftBound += mTextIndent;
}
- if (mSupportVideoCall || mSupportCallAndShare) {
- // Place the call to action at the end of the list (e.g. take into account RTL mode).
- if (isVisible(mCallToAction)) {
- // Center the icon vertically
- final int callToActionTop = topBound + (height - topBound - mCallToActionSize) / 2;
+ // Place the call to action at the end of the list (e.g. take into account RTL mode).
+ // Center the icon vertically
+ final int callToActionTop = topBound + (height - topBound - mCallToActionSize) / 2;
- if (!isLayoutRtl) {
- // When photo is on left, icon is placed on the right edge.
- mCallToAction.layout(
- rightBound - mCallToActionSize,
- callToActionTop,
- rightBound,
- callToActionTop + mCallToActionSize);
- } else {
- // When photo is on right, icon is placed on the left edge.
- mCallToAction.layout(
- leftBound,
- callToActionTop,
- leftBound + mCallToActionSize,
- callToActionTop + mCallToActionSize);
- }
- }
+ if (!isLayoutRtl) {
+ // When photo is on left, icon is placed on the right edge.
+ mCallToActionView.layout(
+ rightBound - mCallToActionSize,
+ callToActionTop,
+ rightBound,
+ callToActionTop + mCallToActionSize);
+ } else {
+ // When photo is on right, icon is placed on the left edge.
+ mCallToActionView.layout(
+ leftBound,
+ callToActionTop,
+ leftBound + mCallToActionSize,
+ callToActionTop + mCallToActionSize);
+ }
- if (mPhotoPosition == PhotoPosition.LEFT) {
- rightBound -= (mCallToActionSize + mCallToActionMargin);
- } else {
- leftBound += mCallToActionSize + mCallToActionMargin;
- }
+ if (mPhotoPosition == PhotoPosition.LEFT) {
+ rightBound -= (mCallToActionSize + mCallToActionMargin);
+ } else {
+ leftBound += mCallToActionSize + mCallToActionMargin;
}
// Center text vertically, then apply the top offset.
@@ -901,9 +883,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
}
if (mQuickContact == null) {
mQuickContact = new QuickContactBadge(getContext());
- if (CompatUtils.isLollipopCompatible()) {
- mQuickContact.setOverlay(null);
- }
+ mQuickContact.setOverlay(null);
mQuickContact.setLayoutParams(getDefaultPhotoLayoutParams());
if (mNameTextView != null) {
mQuickContact.setContentDescription(
@@ -1008,9 +988,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
mNameTextView.setGravity(Gravity.CENTER_VERTICAL);
mNameTextView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
mNameTextView.setId(R.id.cliv_name_textview);
- if (CompatUtils.isLollipopCompatible()) {
- mNameTextView.setElegantTextHeight(false);
- }
+ mNameTextView.setElegantTextHeight(false);
addView(mNameTextView);
}
return mNameTextView;
@@ -1056,6 +1034,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
* exists.
*/
public void setPhoneNumber(String text) {
+ mPhoneNumber = text;
if (text == null) {
if (mDataView != null) {
mDataView.setVisibility(View.GONE);
@@ -1086,6 +1065,10 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
}
}
+ public String getPhoneNumber() {
+ return mPhoneNumber;
+ }
+
private void setMarqueeText(TextView textView, CharSequence text) {
if (getTextEllipsis() == TruncateAt.MARQUEE) {
// To show MARQUEE correctly (with END effect during non-active state), we need
@@ -1109,9 +1092,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
mDataView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
mDataView.setActivated(isActivated());
mDataView.setId(R.id.cliv_data_view);
- if (CompatUtils.isLollipopCompatible()) {
- mDataView.setElegantTextHeight(false);
- }
+ mDataView.setElegantTextHeight(false);
addView(mDataView);
}
return mDataView;
@@ -1469,28 +1450,17 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj
forceLayout();
}
- public void setPhotoPosition(PhotoPosition photoPosition) {
- mPhotoPosition = photoPosition;
- }
-
/**
* Set drawable resources directly for the drawable resource of the photo view.
*
- * @param drawableId Id of drawable resource.
+ * @param drawable A drawable resource.
*/
- public void setDrawableResource(int drawableId) {
+ public void setDrawable(Drawable drawable) {
ImageView photo = getPhotoView();
photo.setScaleType(ImageView.ScaleType.CENTER);
- final Drawable drawable = ContextCompat.getDrawable(getContext(), drawableId);
- final int iconColor = ContextCompat.getColor(getContext(), R.color.search_shortcut_icon_color);
- if (CompatUtils.isLollipopCompatible()) {
- photo.setImageDrawable(drawable);
- photo.setImageTintList(ColorStateList.valueOf(iconColor));
- } else {
- final Drawable drawableWrapper = DrawableCompat.wrap(drawable).mutate();
- DrawableCompat.setTint(drawableWrapper, iconColor);
- photo.setImageDrawable(drawableWrapper);
- }
+ int iconColor = ContextCompat.getColor(getContext(), R.color.search_shortcut_icon_color);
+ photo.setImageDrawable(drawable);
+ photo.setImageTintList(ColorStateList.valueOf(iconColor));
}
@Override
diff --git a/java/com/android/contacts/common/list/ContactTileView.java b/java/com/android/contacts/common/list/ContactTileView.java
index 9273b0583..15582d684 100644
--- a/java/com/android/contacts/common/list/ContactTileView.java
+++ b/java/com/android/contacts/common/list/ContactTileView.java
@@ -19,7 +19,6 @@ import android.content.Context;
import android.graphics.Rect;
import android.net.Uri;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -28,6 +27,9 @@ import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
import com.android.contacts.common.MoreContactUtils;
import com.android.contacts.common.R;
+import com.android.dialer.callintent.CallInitiationType;
+import com.android.dialer.callintent.CallSpecificAppData;
+import com.android.dialer.common.LogUtil;
/** A ContactTile displays a contact's picture and name */
public abstract class ContactTileView extends FrameLayout {
@@ -60,8 +62,14 @@ public abstract class ContactTileView extends FrameLayout {
if (mListener == null) {
return;
}
+ CallSpecificAppData callSpecificAppData =
+ CallSpecificAppData.newBuilder()
+ .setCallInitiationType(CallInitiationType.Type.SPEED_DIAL)
+ .build();
mListener.onContactSelected(
- getLookupUri(), MoreContactUtils.getTargetRectFromView(ContactTileView.this));
+ getLookupUri(),
+ MoreContactUtils.getTargetRectFromView(ContactTileView.this),
+ callSpecificAppData);
}
};
}
@@ -97,7 +105,7 @@ public abstract class ContactTileView extends FrameLayout {
}
} else {
- Log.w(TAG, "contactPhotoManager not set");
+ LogUtil.w(TAG, "contactPhotoManager not set");
}
} else {
setVisibility(View.INVISIBLE);
@@ -163,9 +171,10 @@ public abstract class ContactTileView extends FrameLayout {
public interface Listener {
/** Notification that the contact was selected; no specific action is dictated. */
- void onContactSelected(Uri contactLookupUri, Rect viewRect);
+ void onContactSelected(
+ Uri contactLookupUri, Rect viewRect, CallSpecificAppData callSpecificAppData);
/** Notification that the specified number is to be called. */
- void onCallNumberDirectly(String phoneNumber);
+ void onCallNumberDirectly(String phoneNumber, CallSpecificAppData callSpecificAppData);
}
}
diff --git a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java
index 9a490d78a..65e6f2da2 100644
--- a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java
+++ b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java
@@ -30,7 +30,6 @@ import android.provider.ContactsContract.Directory;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
-import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
import com.android.contacts.common.ContactsUtils;
import com.android.contacts.common.R;
@@ -38,15 +37,17 @@ import com.android.contacts.common.compat.CallableCompat;
import com.android.contacts.common.compat.DirectoryCompat;
import com.android.contacts.common.compat.PhoneCompat;
import com.android.contacts.common.extensions.PhoneDirectoryExtenderAccessor;
+import com.android.contacts.common.lettertiles.LetterTileDrawable;
import com.android.contacts.common.list.ContactListItemView.CallToAction;
import com.android.contacts.common.preference.ContactsPreferences;
import com.android.contacts.common.util.Constants;
-import com.android.dialer.callcomposer.CallComposerContact;
import com.android.dialer.common.LogUtil;
import com.android.dialer.compat.CompatUtils;
+import com.android.dialer.dialercontact.DialerContact;
import com.android.dialer.enrichedcall.EnrichedCallCapabilities;
import com.android.dialer.enrichedcall.EnrichedCallComponent;
import com.android.dialer.enrichedcall.EnrichedCallManager;
+import com.android.dialer.lightbringer.LightbringerComponent;
import com.android.dialer.location.GeoUtil;
import com.android.dialer.util.CallUtil;
import java.util.ArrayList;
@@ -68,16 +69,15 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
// A list of extended directories to add to the directories from the database
private final List<DirectoryPartition> mExtendedDirectories;
private final CharSequence mUnknownNameText;
- private final boolean mCallAndShareEnabled;
+ private final boolean mIsPresenceEnabled;
+ protected final boolean mIsImsVideoEnabled;
+
// Extended directories will have ID's that are higher than any of the id's from the database,
// so that we can identify them and set them up properly. If no extended directories
// exist, this will be Long.MAX_VALUE
private long mFirstExtendedDirectoryId = Long.MAX_VALUE;
- private ContactListItemView.PhotoPosition mPhotoPosition;
private boolean mUseCallableUri;
private Listener mListener;
- private boolean mIsVideoEnabled;
- private boolean mIsPresenceEnabled;
public PhoneNumberListAdapter(Context context) {
super(context);
@@ -88,11 +88,8 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
PhoneDirectoryExtenderAccessor.get(mContext).getExtendedDirectories(mContext);
int videoCapabilities = CallUtil.getVideoCallingAvailability(context);
- mIsVideoEnabled = (videoCapabilities & CallUtil.VIDEO_CALLING_ENABLED) != 0;
+ mIsImsVideoEnabled = CallUtil.isVideoEnabled(context);
mIsPresenceEnabled = (videoCapabilities & CallUtil.VIDEO_CALLING_PRESENCE) != 0;
-
- // TODO
- mCallAndShareEnabled = true;
}
@Override
@@ -249,10 +246,10 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
return item != null ? item.getString(PhoneQuery.LOOKUP_KEY) : null;
}
- public CallComposerContact getCallComposerContact(int position) {
+ public DialerContact getDialerContact(int position) {
Cursor cursor = (Cursor) getItem(position);
if (cursor == null) {
- LogUtil.e("PhoneNumberListAdapter.getCallComposerContact", "cursor was null.");
+ LogUtil.e("PhoneNumberListAdapter.getDialerContact", "cursor was null.");
return null;
}
@@ -263,11 +260,11 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
Contacts.getLookupUri(
cursor.getLong(PhoneQuery.CONTACT_ID), cursor.getString(PhoneQuery.LOOKUP_KEY));
- CallComposerContact.Builder contact = CallComposerContact.newBuilder();
+ DialerContact.Builder contact = DialerContact.newBuilder();
contact
.setNumber(number)
.setPhotoId(cursor.getLong(PhoneQuery.PHOTO_ID))
- .setContactType(ContactPhotoManager.TYPE_DEFAULT)
+ .setContactType(LetterTileDrawable.TYPE_DEFAULT)
.setNameOrNumber(displayName)
.setNumberLabel(
Phone.getTypeLabel(
@@ -297,7 +294,6 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
ContactListItemView view = super.newView(context, partition, cursor, position, parent);
view.setUnknownNameText(mUnknownNameText);
view.setQuickContactEnabled(isQuickContactEnabled());
- view.setPhotoPosition(mPhotoPosition);
return view;
}
@@ -401,13 +397,17 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
int carrierPresence = cursor.getInt(PhoneQuery.CARRIER_PRESENCE);
boolean isPresent = (carrierPresence & Phone.CARRIER_PRESENCE_VT_CAPABLE) != 0;
- boolean isVideoIconShown = mIsVideoEnabled && (!mIsPresenceEnabled || isPresent);
+ boolean isVideoIconShown = mIsImsVideoEnabled && (!mIsPresenceEnabled || isPresent);
if (isVideoIconShown) {
action = ContactListItemView.VIDEO;
}
}
- if (isCallAndShareEnabled() && action == ContactListItemView.NONE && number != null) {
+ if (LightbringerComponent.get(mContext).getLightbringer().isReachable(mContext, number)) {
+ action = ContactListItemView.LIGHTBRINGER;
+ }
+
+ if (action == ContactListItemView.NONE) {
EnrichedCallManager manager = EnrichedCallComponent.get(mContext).getEnrichedCallManager();
EnrichedCallCapabilities capabilities = manager.getCapabilities(number);
if (capabilities != null && capabilities.supportsCallComposer()) {
@@ -481,14 +481,6 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
}
}
- public ContactListItemView.PhotoPosition getPhotoPosition() {
- return mPhotoPosition;
- }
-
- public void setPhotoPosition(ContactListItemView.PhotoPosition photoPosition) {
- mPhotoPosition = photoPosition;
- }
-
public void setUseCallableUri(boolean useCallableUri) {
mUseCallableUri = useCallableUri;
}
@@ -570,14 +562,12 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
mListener = listener;
}
- public boolean isCallAndShareEnabled() {
- return mCallAndShareEnabled;
- }
-
public interface Listener {
void onVideoCallIconClicked(int position);
+ void onLightbringerIconClicked(int position);
+
void onCallAndShareIconClicked(int position);
}
@@ -642,18 +632,14 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
static {
final List<String> projectionList =
new ArrayList<>(Arrays.asList(PROJECTION_PRIMARY_INTERNAL));
- if (CompatUtils.isMarshmallowCompatible()) {
- projectionList.add(Phone.CARRIER_PRESENCE); // 9
- }
+ projectionList.add(Phone.CARRIER_PRESENCE); // 9
PROJECTION_PRIMARY = projectionList.toArray(new String[projectionList.size()]);
}
static {
final List<String> projectionList =
new ArrayList<>(Arrays.asList(PROJECTION_ALTERNATIVE_INTERNAL));
- if (CompatUtils.isMarshmallowCompatible()) {
- projectionList.add(Phone.CARRIER_PRESENCE); // 9
- }
+ projectionList.add(Phone.CARRIER_PRESENCE); // 9
PROJECTION_ALTERNATIVE = projectionList.toArray(new String[projectionList.size()]);
}
}
diff --git a/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java b/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java
index 8f25f82a5..79e670010 100644
--- a/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java
+++ b/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java
@@ -29,15 +29,18 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import com.android.contacts.common.R;
+import com.android.contacts.common.list.PhoneNumberListAdapter.Listener;
import com.android.contacts.common.util.AccountFilterUtil;
-import com.android.dialer.callcomposer.CallComposerContact;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallInitiationType.Type;
import com.android.dialer.callintent.CallSpecificAppData;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
+import com.android.dialer.dialercontact.DialerContact;
import com.android.dialer.enrichedcall.EnrichedCallComponent;
import com.android.dialer.enrichedcall.EnrichedCallManager;
+import com.android.dialer.lightbringer.LightbringerComponent;
+import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
import com.android.dialer.protos.ProtoParsers;
import java.util.Set;
@@ -61,9 +64,6 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE
private boolean mUseCallableUri;
- private ContactListItemView.PhotoPosition mPhotoPosition =
- ContactListItemView.getDefaultPhotoPosition(false /* normal/non opposite */);
-
private final Set<OnLoadFinishedListener> mLoadFinishedListeners = new ArraySet<>();
private CursorReranker mCursorReranker;
@@ -71,7 +71,7 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE
public PhoneNumberPickerFragment() {
setQuickContactEnabled(false);
setPhotoLoaderEnabled(true);
- setSectionHeaderDisplayEnabled(true);
+ setSectionHeaderDisplayEnabled(false);
setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_NONE);
// Show nothing instead of letting caller Activity show something.
@@ -85,17 +85,32 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE
*/
@Override
public void onVideoCallIconClicked(int position) {
+ Logger.get(getContext()).logImpression(DialerImpression.Type.IMS_VIDEO_REQUESTED_FROM_SEARCH);
callNumber(position, true /* isVideoCall */);
}
@Override
+ public void onLightbringerIconClicked(int position) {
+ String phoneNumber = getPhoneNumber(position);
+ Intent intent =
+ LightbringerComponent.get(getContext())
+ .getLightbringer()
+ .getIntent(getContext(), phoneNumber);
+ // DialtactsActivity.ACTIVITY_REQUEST_CODE_LIGHTBRINGER
+ // Cannot reference because of cyclic dependencies
+ Logger.get(getContext())
+ .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_SEARCH);
+ int dialactsActivityRequestCode = 3;
+ getActivity().startActivityForResult(intent, dialactsActivityRequestCode);
+ }
+
+ @Override
public void onCallAndShareIconClicked(int position) {
// Required because of cyclic dependencies of everything depending on contacts/common.
String componentName = "com.android.dialer.callcomposer.CallComposerActivity";
Intent intent = new Intent();
intent.setComponent(new ComponentName(getContext(), componentName));
- CallComposerContact contact =
- ((PhoneNumberListAdapter) getAdapter()).getCallComposerContact(position);
+ DialerContact contact = ((PhoneNumberListAdapter) getAdapter()).getDialerContact(position);
ProtoParsers.put(intent, "CALL_COMPOSER_CONTACT", contact);
startActivity(intent);
}
@@ -320,7 +335,27 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE
@Override
public void onCapabilitiesUpdated() {
if (getAdapter() != null) {
- getAdapter().notifyDataSetChanged();
+ EnrichedCallManager manager =
+ EnrichedCallComponent.get(getContext()).getEnrichedCallManager();
+ Listener listener = ((PhoneNumberListAdapter) getAdapter()).getListener();
+
+ for (int i = 0; i < getListView().getChildCount(); i++) {
+ if (!(getListView().getChildAt(i) instanceof ContactListItemView)) {
+ continue;
+ }
+
+ // Since call and share is the lowest priority call to action, if any others are set,
+ // do not reset the call to action. Also do not set the call and share call to action if
+ // the number doesn't support call composer.
+ ContactListItemView view = (ContactListItemView) getListView().getChildAt(i);
+ if (view.getCallToAction() != ContactListItemView.NONE
+ || view.getPhoneNumber() == null
+ || manager.getCapabilities(view.getPhoneNumber()) == null
+ || !manager.getCapabilities(view.getPhoneNumber()).supportsCallComposer()) {
+ continue;
+ }
+ view.setCallToAction(ContactListItemView.CALL_AND_SHARE, listener, view.getPosition());
+ }
}
}
@@ -360,12 +395,6 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE
if (!isSearchMode() && mFilter != null) {
adapter.setFilter(mFilter);
}
-
- setPhotoPosition(adapter);
- }
-
- protected void setPhotoPosition(ContactEntryListAdapter adapter) {
- ((PhoneNumberListAdapter) adapter).setPhotoPosition(mPhotoPosition);
}
@Override
@@ -389,15 +418,6 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE
updateFilterHeaderView();
}
- public void setPhotoPosition(ContactListItemView.PhotoPosition photoPosition) {
- mPhotoPosition = photoPosition;
-
- final PhoneNumberListAdapter adapter = (PhoneNumberListAdapter) getAdapter();
- if (adapter != null) {
- adapter.setPhotoPosition(photoPosition);
- }
- }
-
/**
* @param isRemoteDirectory {@code true} if the call was initiated using a contact/phone number
* not in the local contacts database
diff --git a/java/com/android/contacts/common/list/ViewPagerTabs.java b/java/com/android/contacts/common/list/ViewPagerTabs.java
index 34f623ef4..1e6cf1354 100644
--- a/java/com/android/contacts/common/list/ViewPagerTabs.java
+++ b/java/com/android/contacts/common/list/ViewPagerTabs.java
@@ -33,7 +33,6 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.android.contacts.common.R;
-import com.android.dialer.compat.CompatUtils;
/**
* Lightweight implementation of ViewPager tabs. This looks similar to traditional actionBar tabs,
@@ -43,7 +42,13 @@ import com.android.dialer.compat.CompatUtils;
*/
public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnPageChangeListener {
- private static final ViewOutlineProvider VIEW_BOUNDS_OUTLINE_PROVIDER;
+ private static final ViewOutlineProvider VIEW_BOUNDS_OUTLINE_PROVIDER =
+ new ViewOutlineProvider() {
+ @Override
+ public void getOutline(View view, Outline outline) {
+ outline.setRect(0, 0, view.getWidth(), view.getHeight());
+ }
+ };
private static final int TAB_SIDE_PADDING_IN_DPS = 10;
// TODO: This should use <declare-styleable> in the future
private static final int[] ATTRS =
@@ -54,20 +59,6 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
android.R.attr.textAllCaps
};
- static {
- if (CompatUtils.isLollipopCompatible()) {
- VIEW_BOUNDS_OUTLINE_PROVIDER =
- new ViewOutlineProvider() {
- @Override
- public void getOutline(View view, Outline outline) {
- outline.setRect(0, 0, view.getWidth(), view.getHeight());
- }
- };
- } else {
- VIEW_BOUNDS_OUTLINE_PROVIDER = null;
- }
- }
-
/**
* Linearlayout that will contain the TextViews serving as tabs. This is the only child of the
* parent HorizontalScrollView.
@@ -111,10 +102,8 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
a.recycle();
- if (CompatUtils.isLollipopCompatible()) {
- // enable shadow casting from view bounds
- setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
- }
+ // enable shadow casting from view bounds
+ setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
}
public void setViewPager(ViewPager viewPager) {