summaryrefslogtreecommitdiff
path: root/java/com/android/contacts/common/list/PhoneNumberListAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/contacts/common/list/PhoneNumberListAdapter.java')
-rw-r--r--java/com/android/contacts/common/list/PhoneNumberListAdapter.java56
1 files changed, 35 insertions, 21 deletions
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()]);
}
}