diff options
author | Eric Erfanian <erfanian@google.com> | 2017-08-31 06:57:16 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-08-31 16:13:53 +0000 |
commit | 2ca4318cc1ee57dda907ba2069bd61d162b1baef (patch) | |
tree | e282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/contacts/common/list/PhoneNumberListAdapter.java | |
parent | 68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff) |
Update Dialer source to latest internal Google revision.
Previously, Android's Dialer app was developed in an internal Google
source control system and only exported to public during AOSP drops.
The Dialer team is now switching to a public development model similar
to the telephony team.
This CL represents all internal Google changes that were committed to
Dialer between the public O release and today's tip of tree on internal
master. This CL squashes those changes into a single commit.
In subsequent changes, changes will be exported on a per-commit basis.
Test: make, flash install, run
Merged-In: I45270eaa8ce732d71a1bd84b08c7fa0e99af3160
Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8
PiperOrigin-RevId: 167068436
Diffstat (limited to 'java/com/android/contacts/common/list/PhoneNumberListAdapter.java')
-rw-r--r-- | java/com/android/contacts/common/list/PhoneNumberListAdapter.java | 83 |
1 files changed, 33 insertions, 50 deletions
diff --git a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java index 9a490d78a..71d9dad5f 100644 --- a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java +++ b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java @@ -27,11 +27,10 @@ import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.CommonDataKinds.SipAddress; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Directory; +import android.support.annotation.VisibleForTesting; 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; import com.android.contacts.common.compat.CallableCompat; @@ -41,13 +40,16 @@ import com.android.contacts.common.extensions.PhoneDirectoryExtenderAccessor; 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.contactphoto.ContactPhotoManager.DefaultImageRequest; +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.location.GeoUtil; +import com.android.dialer.lettertile.LetterTileDrawable; +import com.android.dialer.lightbringer.LightbringerComponent; +import com.android.dialer.phonenumberutil.PhoneNumberHelper; import com.android.dialer.util.CallUtil; import java.util.ArrayList; import java.util.Arrays; @@ -68,16 +70,14 @@ 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; + 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,9 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { PhoneDirectoryExtenderAccessor.get(mContext).getExtendedDirectories(mContext); int videoCapabilities = CallUtil.getVideoCallingAvailability(context); - mIsVideoEnabled = (videoCapabilities & CallUtil.VIDEO_CALLING_ENABLED) != 0; - mIsPresenceEnabled = (videoCapabilities & CallUtil.VIDEO_CALLING_PRESENCE) != 0; - - // TODO - mCallAndShareEnabled = true; + mIsImsVideoEnabled = + CallUtil.isVideoEnabled(context) + && (videoCapabilities & CallUtil.VIDEO_CALLING_PRESENCE) != 0; } @Override @@ -249,10 +247,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 +261,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 +295,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; } @@ -355,19 +352,14 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { } final DirectoryPartition directory = (DirectoryPartition) getPartition(partition); - - // If the first partition does not have a header, then all subsequent partitions' - // getPositionForPartition returns an index off by 1. - int partitionOffset = 0; - if (partition > 0 && !getPartition(0).getHasHeader()) { - partitionOffset = 1; - } - position += getPositionForPartition(partition) + partitionOffset; + // All sections have headers, so scroll position is off by 1. + position += getPositionForPartition(partition) + 1; bindPhoneNumber(view, cursor, directory.isDisplayNumber(), position); } - protected void bindPhoneNumber( + @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) + public void bindPhoneNumber( ContactListItemView view, Cursor cursor, boolean displayNumber, int position) { CharSequence label = null; if (displayNumber && !cursor.isNull(PhoneQuery.PHONE_TYPE)) { @@ -389,7 +381,7 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { text = phoneLabel; } else { final String phoneNumber = cursor.getString(PhoneQuery.PHONE_NUMBER); - text = GeoUtil.getGeocodedLocationFor(mContext, phoneNumber); + text = PhoneNumberHelper.getGeoDescription(mContext, phoneNumber); } } view.setPhoneNumber(text); @@ -401,16 +393,21 @@ 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); - if (isVideoIconShown) { + boolean showViewIcon = mIsImsVideoEnabled && isPresent; + if (showViewIcon) { action = ContactListItemView.VIDEO; } } - if (isCallAndShareEnabled() && action == ContactListItemView.NONE && number != null) { + if (action == ContactListItemView.NONE + && 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()) { + if (capabilities != null && capabilities.isCallComposerCapable()) { action = ContactListItemView.CALL_AND_SHARE; } else if (capabilities == null && getQueryString() != null @@ -481,14 +478,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 +559,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 +629,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()]); } } |