diff options
author | Tobias Thierer <tobiast@google.com> | 2017-06-09 14:16:05 +0000 |
---|---|---|
committer | Tobias Thierer <tobiast@google.com> | 2017-06-09 14:16:05 +0000 |
commit | cded3beaf28a703e1ef8f71bbc6836e6806c3736 (patch) | |
tree | c1b5e8199b5996fc848e7455d04126b9cdbb3c39 /java/com/android/contacts/common/list | |
parent | c67d658e7daa453fe9ad9fd1a37f81eaf2048c44 (diff) |
Revert "Update AOSP Dialer source from internal google3 repository at cl/158012278. am: 91ce7d2a47"
This reverts commit c67d658e7daa453fe9ad9fd1a37f81eaf2048c44.
Reason for revert: This CL broke the sailfish-userdebug_javac-all target on master.
Change-Id: I9b54333a654c00154ca84f4ece84bea4f07cc19b
Diffstat (limited to 'java/com/android/contacts/common/list')
7 files changed, 209 insertions, 187 deletions
diff --git a/java/com/android/contacts/common/list/ContactEntryListAdapter.java b/java/com/android/contacts/common/list/ContactEntryListAdapter.java index 064214ef2..18bbae382 100644 --- a/java/com/android/contacts/common/list/ContactEntryListAdapter.java +++ b/java/com/android/contacts/common/list/ContactEntryListAdapter.java @@ -26,6 +26,7 @@ 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; @@ -38,10 +39,7 @@ 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; /** @@ -356,7 +354,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. - LogUtil.e( + Log.e( TAG, "Directory search loader returned an empty cursor, which implies we have " + "no directory entries.", @@ -680,9 +678,6 @@ 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 146986f75..278175c0b 100644 --- a/java/com/android/contacts/common/list/ContactEntryListFragment.java +++ b/java/com/android/contacts/common/list/ContactEntryListFragment.java @@ -555,6 +555,7 @@ 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 5a2749178..7a3194720 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,6 +55,7 @@ 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; @@ -80,15 +81,13 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj /** IntDef for indices of ViewPager tabs. */ @Retention(RetentionPolicy.SOURCE) - @IntDef({NONE, VIDEO, LIGHTBRINGER, CALL_AND_SHARE}) + @IntDef({NONE, VIDEO, CALL_AND_SHARE}) public @interface CallToAction {} public static final int NONE = 0; public static final int VIDEO = 1; - public static final int LIGHTBRINGER = 2; - public static final int CALL_AND_SHARE = 3; + public static final int CALL_AND_SHARE = 2; - 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 = '['; @@ -107,7 +106,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj private int mNameTextViewTextSize; private int mHeaderWidth; private Drawable mActivatedBackgroundDrawable; - private int mCallToActionSize = 48; + private int mCallToActionSize = 32; private int mCallToActionMargin = 16; // Set in onLayout. Represent left and right position of the View on the screen. private int mLeftOffset; @@ -123,7 +122,10 @@ 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; @@ -137,7 +139,7 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj private TextView mSnippetView; private TextView mStatusView; private ImageView mPresenceIcon; - @NonNull private final ImageView mCallToActionView; + private ImageView mCallToAction; private ImageView mWorkProfileIcon; private ColorStateList mSecondaryTextColor; private int mDefaultPhotoViewSize = 0; @@ -179,14 +181,23 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj private Rect mBoundsWithoutHeader = new Rect(); private CharSequence mUnknownNameText; - private String mPhoneNumber; - private int mPosition = -1; - private @CallToAction int mCallToAction = NONE; + public ContactListItemView(Context context) { + super(context); - public ContactListItemView(Context context, AttributeSet attrs, boolean supportVideoCallIcon) { + mTextHighlighter = new TextHighlighter(Typeface.BOLD); + mNameHighlightSequence = new ArrayList<>(); + mNumberHighlightSequence = new ArrayList<>(); + } + + public ContactListItemView( + Context context, + AttributeSet attrs, + boolean supportVideoCallIcon, + boolean supportCallAndShare) { this(context, attrs); mSupportVideoCall = supportVideoCallIcon; + mSupportCallAndShare = supportCallAndShare; } public ContactListItemView(Context context, AttributeSet attrs) { @@ -273,20 +284,19 @@ 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() { - int layoutDirection = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()); - return layoutDirection == View.LAYOUT_DIRECTION_RTL ? PhotoPosition.RIGHT : PhotoPosition.LEFT; + 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); + } } /** @@ -323,47 +333,35 @@ 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) { - mCallToAction = action; - mPosition = position; - - Drawable drawable; + int drawable; int description; OnClickListener onClickListener; - 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; + if (action == CALL_AND_SHARE && mSupportCallAndShare) { + drawable = R.drawable.ic_call_and_share; + description = R.string.description_search_video_call; onClickListener = v -> listener.onCallAndShareIconClicked(position); } else if (action == VIDEO && mSupportVideoCall) { - drawable = - getContext().getResources().getDrawable(R.drawable.quantum_ic_videocam_vd_theme_24); - drawable.setAutoMirrored(true); - description = R.string.description_search_video_call; + drawable = R.drawable.ic_search_video_call; + description = R.string.description_search_call_and_share; 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 { - mCallToActionView.setVisibility(View.GONE); - mCallToActionView.setOnClickListener(null); + if (mCallToAction != null) { + mCallToAction.setVisibility(View.GONE); + mCallToAction.setOnClickListener(null); + } return; } - 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; + 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); } /** @@ -378,6 +376,18 @@ 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 @@ -413,7 +423,9 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj effectiveWidth -= mHeaderWidth + mGapBetweenImageAndText; } - effectiveWidth -= (mCallToActionSize + mCallToActionMargin); + if (mSupportVideoCall || mSupportCallAndShare) { + 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. @@ -484,9 +496,11 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj mStatusTextViewHeight = mPresenceIcon.getMeasuredHeight(); } - mCallToActionView.measure( - MeasureSpec.makeMeasureSpec(mCallToActionSize, MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(mCallToActionSize, MeasureSpec.EXACTLY)); + if ((mSupportVideoCall || mSupportCallAndShare) && isVisible(mCallToAction)) { + mCallToAction.measure( + MeasureSpec.makeMeasureSpec(mCallToActionSize, MeasureSpec.EXACTLY), + MeasureSpec.makeMeasureSpec(mCallToActionSize, MeasureSpec.EXACTLY)); + } if (isVisible(mWorkProfileIcon)) { mWorkProfileIcon.measure( @@ -615,30 +629,34 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj leftBound += mTextIndent; } - // 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 (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; - 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 (!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 (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. @@ -883,7 +901,9 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj } if (mQuickContact == null) { mQuickContact = new QuickContactBadge(getContext()); - mQuickContact.setOverlay(null); + if (CompatUtils.isLollipopCompatible()) { + mQuickContact.setOverlay(null); + } mQuickContact.setLayoutParams(getDefaultPhotoLayoutParams()); if (mNameTextView != null) { mQuickContact.setContentDescription( @@ -988,7 +1008,9 @@ 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); - mNameTextView.setElegantTextHeight(false); + if (CompatUtils.isLollipopCompatible()) { + mNameTextView.setElegantTextHeight(false); + } addView(mNameTextView); } return mNameTextView; @@ -1034,7 +1056,6 @@ 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); @@ -1065,10 +1086,6 @@ 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 @@ -1092,7 +1109,9 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj mDataView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); mDataView.setActivated(isActivated()); mDataView.setId(R.id.cliv_data_view); - mDataView.setElegantTextHeight(false); + if (CompatUtils.isLollipopCompatible()) { + mDataView.setElegantTextHeight(false); + } addView(mDataView); } return mDataView; @@ -1450,17 +1469,28 @@ 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 drawable A drawable resource. + * @param drawableId Id of drawable resource. */ - public void setDrawable(Drawable drawable) { + public void setDrawableResource(int drawableId) { ImageView photo = getPhotoView(); photo.setScaleType(ImageView.ScaleType.CENTER); - int iconColor = ContextCompat.getColor(getContext(), R.color.search_shortcut_icon_color); - photo.setImageDrawable(drawable); - photo.setImageTintList(ColorStateList.valueOf(iconColor)); + 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); + } } @Override diff --git a/java/com/android/contacts/common/list/ContactTileView.java b/java/com/android/contacts/common/list/ContactTileView.java index 15582d684..9273b0583 100644 --- a/java/com/android/contacts/common/list/ContactTileView.java +++ b/java/com/android/contacts/common/list/ContactTileView.java @@ -19,6 +19,7 @@ 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; @@ -27,9 +28,6 @@ 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 { @@ -62,14 +60,8 @@ 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), - callSpecificAppData); + getLookupUri(), MoreContactUtils.getTargetRectFromView(ContactTileView.this)); } }; } @@ -105,7 +97,7 @@ public abstract class ContactTileView extends FrameLayout { } } else { - LogUtil.w(TAG, "contactPhotoManager not set"); + Log.w(TAG, "contactPhotoManager not set"); } } else { setVisibility(View.INVISIBLE); @@ -171,10 +163,9 @@ 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, CallSpecificAppData callSpecificAppData); + void onContactSelected(Uri contactLookupUri, Rect viewRect); /** Notification that the specified number is to be called. */ - void onCallNumberDirectly(String phoneNumber, CallSpecificAppData callSpecificAppData); + void onCallNumberDirectly(String phoneNumber); } } diff --git a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java index 65e6f2da2..9a490d78a 100644 --- a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java +++ b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java @@ -30,6 +30,7 @@ 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; @@ -37,17 +38,15 @@ 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; @@ -69,15 +68,16 @@ 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 mIsPresenceEnabled; - protected final boolean mIsImsVideoEnabled; - + private final boolean mCallAndShareEnabled; // 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,8 +88,11 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { PhoneDirectoryExtenderAccessor.get(mContext).getExtendedDirectories(mContext); int videoCapabilities = CallUtil.getVideoCallingAvailability(context); - mIsImsVideoEnabled = CallUtil.isVideoEnabled(context); + mIsVideoEnabled = (videoCapabilities & CallUtil.VIDEO_CALLING_ENABLED) != 0; mIsPresenceEnabled = (videoCapabilities & CallUtil.VIDEO_CALLING_PRESENCE) != 0; + + // TODO + mCallAndShareEnabled = true; } @Override @@ -246,10 +249,10 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { return item != null ? item.getString(PhoneQuery.LOOKUP_KEY) : null; } - public DialerContact getDialerContact(int position) { + public CallComposerContact getCallComposerContact(int position) { Cursor cursor = (Cursor) getItem(position); if (cursor == null) { - LogUtil.e("PhoneNumberListAdapter.getDialerContact", "cursor was null."); + LogUtil.e("PhoneNumberListAdapter.getCallComposerContact", "cursor was null."); return null; } @@ -260,11 +263,11 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { Contacts.getLookupUri( cursor.getLong(PhoneQuery.CONTACT_ID), cursor.getString(PhoneQuery.LOOKUP_KEY)); - DialerContact.Builder contact = DialerContact.newBuilder(); + CallComposerContact.Builder contact = CallComposerContact.newBuilder(); contact .setNumber(number) .setPhotoId(cursor.getLong(PhoneQuery.PHOTO_ID)) - .setContactType(LetterTileDrawable.TYPE_DEFAULT) + .setContactType(ContactPhotoManager.TYPE_DEFAULT) .setNameOrNumber(displayName) .setNumberLabel( Phone.getTypeLabel( @@ -294,6 +297,7 @@ 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; } @@ -397,17 +401,13 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { int carrierPresence = cursor.getInt(PhoneQuery.CARRIER_PRESENCE); boolean isPresent = (carrierPresence & Phone.CARRIER_PRESENCE_VT_CAPABLE) != 0; - boolean isVideoIconShown = mIsImsVideoEnabled && (!mIsPresenceEnabled || isPresent); + boolean isVideoIconShown = mIsVideoEnabled && (!mIsPresenceEnabled || isPresent); if (isVideoIconShown) { action = ContactListItemView.VIDEO; } } - if (LightbringerComponent.get(mContext).getLightbringer().isReachable(mContext, number)) { - action = ContactListItemView.LIGHTBRINGER; - } - - if (action == ContactListItemView.NONE) { + if (isCallAndShareEnabled() && action == ContactListItemView.NONE && number != null) { EnrichedCallManager manager = EnrichedCallComponent.get(mContext).getEnrichedCallManager(); EnrichedCallCapabilities capabilities = manager.getCapabilities(number); if (capabilities != null && capabilities.supportsCallComposer()) { @@ -481,6 +481,14 @@ 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; } @@ -562,12 +570,14 @@ 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); } @@ -632,14 +642,18 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { static { final List<String> projectionList = new ArrayList<>(Arrays.asList(PROJECTION_PRIMARY_INTERNAL)); - projectionList.add(Phone.CARRIER_PRESENCE); // 9 + if (CompatUtils.isMarshmallowCompatible()) { + 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)); - projectionList.add(Phone.CARRIER_PRESENCE); // 9 + if (CompatUtils.isMarshmallowCompatible()) { + 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 79e670010..8f25f82a5 100644 --- a/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java +++ b/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java @@ -29,18 +29,15 @@ 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; @@ -64,6 +61,9 @@ 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(false); + setSectionHeaderDisplayEnabled(true); setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_NONE); // Show nothing instead of letting caller Activity show something. @@ -85,32 +85,17 @@ 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)); - DialerContact contact = ((PhoneNumberListAdapter) getAdapter()).getDialerContact(position); + CallComposerContact contact = + ((PhoneNumberListAdapter) getAdapter()).getCallComposerContact(position); ProtoParsers.put(intent, "CALL_COMPOSER_CONTACT", contact); startActivity(intent); } @@ -335,27 +320,7 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE @Override public void onCapabilitiesUpdated() { if (getAdapter() != null) { - 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()); - } + getAdapter().notifyDataSetChanged(); } } @@ -395,6 +360,12 @@ 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 @@ -418,6 +389,15 @@ 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 1e6cf1354..34f623ef4 100644 --- a/java/com/android/contacts/common/list/ViewPagerTabs.java +++ b/java/com/android/contacts/common/list/ViewPagerTabs.java @@ -33,6 +33,7 @@ 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, @@ -42,13 +43,7 @@ import com.android.contacts.common.R; */ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnPageChangeListener { - 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 ViewOutlineProvider VIEW_BOUNDS_OUTLINE_PROVIDER; private static final int TAB_SIDE_PADDING_IN_DPS = 10; // TODO: This should use <declare-styleable> in the future private static final int[] ATTRS = @@ -59,6 +54,20 @@ 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. @@ -102,8 +111,10 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); a.recycle(); - // enable shadow casting from view bounds - setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER); + if (CompatUtils.isLollipopCompatible()) { + // enable shadow casting from view bounds + setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER); + } } public void setViewPager(ViewPager viewPager) { |