Search in sources :

Example 1 with CallToAction

use of com.android.contacts.common.list.ContactListItemView.CallToAction in project android_packages_apps_Dialer by LineageOS.

the class PhoneNumberListAdapter method 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)) {
        final int type = cursor.getInt(PhoneQuery.PHONE_TYPE);
        final String customLabel = cursor.getString(PhoneQuery.PHONE_LABEL);
        // TODO cache
        label = Phone.getTypeLabel(mContext.getResources(), type, customLabel);
    }
    view.setLabel(label);
    final String text;
    String number = cursor.getString(PhoneQuery.PHONE_NUMBER);
    if (displayNumber) {
        text = number;
    } else {
        // Display phone label. If that's null, display geocoded location for the number
        final String phoneLabel = cursor.getString(PhoneQuery.PHONE_LABEL);
        if (phoneLabel != null) {
            text = phoneLabel;
        } else {
            final String phoneNumber = cursor.getString(PhoneQuery.PHONE_NUMBER);
            text = GeoUtil.getGeocodedLocationFor(mContext, phoneNumber);
        }
    }
    view.setPhoneNumber(text);
    @CallToAction int action = ContactListItemView.NONE;
    if (CompatUtils.isVideoCompatible()) {
        // Determine if carrier presence indicates the number supports video calling.
        int carrierPresence = cursor.getInt(PhoneQuery.CARRIER_PRESENCE);
        boolean isPresent = (carrierPresence & Phone.CARRIER_PRESENCE_VT_CAPABLE) != 0;
        boolean showViewIcon = mIsImsVideoEnabled && isPresent;
        if (showViewIcon) {
            action = ContactListItemView.VIDEO;
        }
    }
    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()) {
            action = ContactListItemView.CALL_AND_SHARE;
        } else if (capabilities == null && getQueryString() != null && getQueryString().length() >= 3) {
            manager.requestCapabilities(number);
        }
    }
    view.setCallToAction(action, mListener, position);
}
Also used : CallToAction(com.android.contacts.common.list.ContactListItemView.CallToAction) EnrichedCallManager(com.android.dialer.enrichedcall.EnrichedCallManager) EnrichedCallCapabilities(com.android.dialer.enrichedcall.EnrichedCallCapabilities) VisibleForTesting(android.support.annotation.VisibleForTesting)

Aggregations

VisibleForTesting (android.support.annotation.VisibleForTesting)1 CallToAction (com.android.contacts.common.list.ContactListItemView.CallToAction)1 EnrichedCallCapabilities (com.android.dialer.enrichedcall.EnrichedCallCapabilities)1 EnrichedCallManager (com.android.dialer.enrichedcall.EnrichedCallManager)1