Search in sources :

Example 1 with Listener

use of com.android.contacts.common.list.PhoneNumberListAdapter.Listener in project android_packages_apps_Dialer by LineageOS.

the class ContactListItemView method setCallToAction.

/**
 * Sets whether the call to action is shown. For the {@link CallToAction} to be shown, it must be
 * supported as well.
 *
 * @param action {@link CallToAction} you want to display (if it's supported).
 * @param listener Listener to notify when the call to action is clicked.
 * @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 description;
    OnClickListener onClickListener;
    if (action == CALL_AND_SHARE) {
        drawable = ContextCompat.getDrawable(getContext(), 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 = ContextCompat.getDrawable(getContext(), 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) {
        CallIntentBuilder.increaseLightbringerCallButtonAppearInSearchCount();
        drawable = ContextCompat.getDrawable(getContext(), 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);
        return;
    }
    mCallToActionView.setContentDescription(getContext().getString(description));
    mCallToActionView.setOnClickListener(onClickListener);
    mCallToActionView.setImageDrawable(drawable);
    mCallToActionView.setVisibility(View.VISIBLE);
}
Also used : Typeface(android.graphics.Typeface) Context(android.content.Context) Rect(android.graphics.Rect) Bundle(android.os.Bundle) CallIntentBuilder(com.android.dialer.callintent.CallIntentBuilder) Spannable(android.text.Spannable) ImageView(android.widget.ImageView) NonNull(android.support.annotation.NonNull) SelectionBoundsAdjuster(android.widget.AbsListView.SelectionBoundsAdjuster) Drawable(android.graphics.drawable.Drawable) ViewUtil(com.android.dialer.util.ViewUtil) TruncateAt(android.text.TextUtils.TruncateAt) TypedArray(android.content.res.TypedArray) Retention(java.lang.annotation.Retention) ArrayList(java.util.ArrayList) ColorStateList(android.content.res.ColorStateList) R(com.android.contacts.common.R) PhoneNumberUtilsCompat(com.android.contacts.common.compat.PhoneNumberUtilsCompat) Matcher(java.util.regex.Matcher) ContactsContract(android.provider.ContactsContract) AttributeSet(android.util.AttributeSet) MotionEvent(android.view.MotionEvent) Locale(java.util.Locale) SearchUtil(com.android.contacts.common.util.SearchUtil) ContactPresenceIconUtil(com.android.contacts.common.ContactPresenceIconUtil) View(android.view.View) Canvas(android.graphics.Canvas) ScaleType(android.widget.ImageView.ScaleType) ContactStatusUtil(com.android.contacts.common.ContactStatusUtil) Cursor(android.database.Cursor) Contacts(android.provider.ContactsContract.Contacts) Listener(com.android.contacts.common.list.PhoneNumberListAdapter.Listener) SearchSnippets(android.provider.ContactsContract.SearchSnippets) SpannableString(android.text.SpannableString) ContextCompat(android.support.v4.content.ContextCompat) QuickContactBadge(android.widget.QuickContactBadge) IntDef(android.support.annotation.IntDef) TextUtils(android.text.TextUtils) ViewGroup(android.view.ViewGroup) Color(android.graphics.Color) Gravity(android.view.Gravity) List(java.util.List) TextView(android.widget.TextView) TextHighlighter(com.android.contacts.common.format.TextHighlighter) TypedValue(android.util.TypedValue) Pattern(java.util.regex.Pattern) ContactDisplayUtils(com.android.contacts.common.util.ContactDisplayUtils) RetentionPolicy(java.lang.annotation.RetentionPolicy) Drawable(android.graphics.drawable.Drawable)

Example 2 with Listener

use of com.android.contacts.common.list.PhoneNumberListAdapter.Listener in project android_packages_apps_Dialer by LineageOS.

the class PhoneNumberPickerFragment method onCapabilitiesUpdated.

@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());
        }
    }
}
Also used : Listener(com.android.contacts.common.list.PhoneNumberListAdapter.Listener) EnrichedCallManager(com.android.dialer.enrichedcall.EnrichedCallManager)

Aggregations

Listener (com.android.contacts.common.list.PhoneNumberListAdapter.Listener)2 Context (android.content.Context)1 ColorStateList (android.content.res.ColorStateList)1 TypedArray (android.content.res.TypedArray)1 Cursor (android.database.Cursor)1 Canvas (android.graphics.Canvas)1 Color (android.graphics.Color)1 Rect (android.graphics.Rect)1 Typeface (android.graphics.Typeface)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 ContactsContract (android.provider.ContactsContract)1 Contacts (android.provider.ContactsContract.Contacts)1 SearchSnippets (android.provider.ContactsContract.SearchSnippets)1 IntDef (android.support.annotation.IntDef)1 NonNull (android.support.annotation.NonNull)1 ContextCompat (android.support.v4.content.ContextCompat)1 Spannable (android.text.Spannable)1 SpannableString (android.text.SpannableString)1 TextUtils (android.text.TextUtils)1