Search in sources :

Example 6 with LetterTileDrawable

use of com.android.contacts.common.lettertiles.LetterTileDrawable in project android_packages_apps_Dialer by LineageOS.

the class IconFactory method createAdaptiveIcon.

@RequiresApi(VERSION_CODES.O)
private Icon createAdaptiveIcon(@NonNull String displayName, @NonNull String lookupKey, @Nullable InputStream inputStream) {
    if (inputStream == null) {
        LetterTileDrawable letterTileDrawable = new LetterTileDrawable(context.getResources());
        // The adaptive icons clip the drawable to a safe area inside the drawable. Scale the letter
        // so it fits inside the safe area.
        letterTileDrawable.setScale(1f / (1f + AdaptiveIconDrawable.getExtraInsetFraction()));
        letterTileDrawable.setCanonicalDialerLetterTileDetails(displayName, lookupKey, LetterTileDrawable.SHAPE_RECTANGLE, LetterTileDrawable.TYPE_DEFAULT);
        int iconSize = context.getResources().getDimensionPixelSize(R.dimen.launcher_shortcut_adaptive_icon_size);
        return Icon.createWithAdaptiveBitmap(DrawableConverter.drawableToBitmap(letterTileDrawable, iconSize, iconSize));
    }
    Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
    return Icon.createWithAdaptiveBitmap(bitmap);
}
Also used : Bitmap(android.graphics.Bitmap) LetterTileDrawable(com.android.contacts.common.lettertiles.LetterTileDrawable) RequiresApi(android.support.annotation.RequiresApi)

Example 7 with LetterTileDrawable

use of com.android.contacts.common.lettertiles.LetterTileDrawable in project android_packages_apps_Dialer by LineageOS.

the class BlockedNumbersFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null));
    getListView().addFooterView(inflater.inflate(R.layout.blocked_number_footer, null));
    // replace the icon for add number with LetterTileDrawable(), so it will have identical style
    ImageView addNumberIcon = (ImageView) getActivity().findViewById(R.id.add_number_icon);
    LetterTileDrawable drawable = new LetterTileDrawable(getResources());
    drawable.setLetter(ADD_BLOCKED_NUMBER_ICON_LETTER);
    drawable.setColor(ActivityCompat.getColor(getActivity(), R.color.add_blocked_number_icon_color));
    drawable.setIsCircular(true);
    addNumberIcon.setImageDrawable(drawable);
    if (mAdapter == null) {
        mAdapter = BlockedNumbersAdapter.newBlockedNumbersAdapter(getContext(), getActivity().getFragmentManager());
    }
    setListAdapter(mAdapter);
    blockedNumbersText = (TextView) getListView().findViewById(R.id.blocked_number_text_view);
    migratePromoView = getListView().findViewById(R.id.migrate_promo);
    getListView().findViewById(R.id.migrate_promo_allow_button).setOnClickListener(this);
    mImportSettings = getListView().findViewById(R.id.import_settings);
    mBlockedNumbersDisabledForEmergency = getListView().findViewById(R.id.blocked_numbers_disabled_for_emergency);
    mBlockedNumberListDivider = getActivity().findViewById(R.id.blocked_number_list_divider);
    getListView().findViewById(R.id.import_button).setOnClickListener(this);
    getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this);
    getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(this);
    footerText = (TextView) getActivity().findViewById(R.id.blocked_number_footer_textview);
    mVoicemailEnabledChecker = new VisualVoicemailEnabledChecker(getContext(), this);
    mVoicemailEnabledChecker.asyncUpdate();
    updateActiveVoicemailProvider();
}
Also used : VisualVoicemailEnabledChecker(com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker) LayoutInflater(android.view.LayoutInflater) LetterTileDrawable(com.android.contacts.common.lettertiles.LetterTileDrawable) ImageView(android.widget.ImageView)

Example 8 with LetterTileDrawable

use of com.android.contacts.common.lettertiles.LetterTileDrawable in project android_packages_apps_Dialer by LineageOS.

the class StatusBarNotifier method getLargeIconToDisplay.

/**
 * Gets a large icon from the contact info object to display in the notification.
 */
private static Bitmap getLargeIconToDisplay(Context context, ContactCacheEntry contactInfo, DialerCall call) {
    Resources resources = context.getResources();
    Bitmap largeIcon = null;
    if (contactInfo.photo != null && (contactInfo.photo instanceof BitmapDrawable)) {
        largeIcon = ((BitmapDrawable) contactInfo.photo).getBitmap();
    }
    if (contactInfo.photo == null) {
        int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
        int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
        @ContactType int contactType = LetterTileDrawable.getContactTypeFromPrimitives(CallerInfoUtils.isVoiceMailNumber(context, call), call.isSpam(), contactInfo.isBusiness, call.getNumberPresentation(), call.isConferenceCall() && !call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE));
        LetterTileDrawable lettertile = new LetterTileDrawable(resources);
        lettertile.setCanonicalDialerLetterTileDetails(contactInfo.namePrimary == null ? contactInfo.number : contactInfo.namePrimary, contactInfo.lookupKey, LetterTileDrawable.SHAPE_CIRCLE, contactType);
        largeIcon = lettertile.getBitmap(width, height);
    }
    if (call.isSpam()) {
        Drawable drawable = resources.getDrawable(R.drawable.blocked_contact, context.getTheme());
        largeIcon = DrawableConverter.drawableToBitmap(drawable);
    }
    return largeIcon;
}
Also used : Bitmap(android.graphics.Bitmap) ContactType(com.android.contacts.common.lettertiles.LetterTileDrawable.ContactType) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) LetterTileDrawable(com.android.contacts.common.lettertiles.LetterTileDrawable) LetterTileDrawable(com.android.contacts.common.lettertiles.LetterTileDrawable) Resources(android.content.res.Resources) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 9 with LetterTileDrawable

use of com.android.contacts.common.lettertiles.LetterTileDrawable in project android_packages_apps_Dialer by MoKee.

the class BlockedNumbersFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null));
    getListView().addFooterView(inflater.inflate(R.layout.blocked_number_footer, null));
    // replace the icon for add number with LetterTileDrawable(), so it will have identical style
    ImageView addNumberIcon = (ImageView) getActivity().findViewById(R.id.add_number_icon);
    LetterTileDrawable drawable = new LetterTileDrawable(getResources());
    drawable.setLetter(ADD_BLOCKED_NUMBER_ICON_LETTER);
    drawable.setColor(ActivityCompat.getColor(getActivity(), R.color.add_blocked_number_icon_color));
    drawable.setIsCircular(true);
    addNumberIcon.setImageDrawable(drawable);
    if (mAdapter == null) {
        mAdapter = BlockedNumbersAdapter.newBlockedNumbersAdapter(getContext(), getActivity().getFragmentManager());
    }
    setListAdapter(mAdapter);
    blockedNumbersText = (TextView) getListView().findViewById(R.id.blocked_number_text_view);
    migratePromoView = getListView().findViewById(R.id.migrate_promo);
    getListView().findViewById(R.id.migrate_promo_allow_button).setOnClickListener(this);
    mImportSettings = getListView().findViewById(R.id.import_settings);
    mBlockedNumbersDisabledForEmergency = getListView().findViewById(R.id.blocked_numbers_disabled_for_emergency);
    mBlockedNumberListDivider = getActivity().findViewById(R.id.blocked_number_list_divider);
    getListView().findViewById(R.id.import_button).setOnClickListener(this);
    getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this);
    getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(this);
    footerText = (TextView) getActivity().findViewById(R.id.blocked_number_footer_textview);
    mVoicemailEnabledChecker = new VisualVoicemailEnabledChecker(getContext(), this);
    mVoicemailEnabledChecker.asyncUpdate();
    updateActiveVoicemailProvider();
}
Also used : VisualVoicemailEnabledChecker(com.android.dialer.voicemail.VisualVoicemailEnabledChecker) LayoutInflater(android.view.LayoutInflater) LetterTileDrawable(com.android.contacts.common.lettertiles.LetterTileDrawable) ImageView(android.widget.ImageView)

Example 10 with LetterTileDrawable

use of com.android.contacts.common.lettertiles.LetterTileDrawable in project android_packages_apps_Dialer by MoKee.

the class ContactPhotoLoaderTest method testGetIcon_LetterTile.

public void testGetIcon_LetterTile() {
    ContactInfo info = getTestContactInfo();
    ContactPhotoLoader loader = new ContactPhotoLoader(mContext, info);
    assertTrue(loader.getIcon() instanceof LetterTileDrawable);
}
Also used : LetterTileDrawable(com.android.contacts.common.lettertiles.LetterTileDrawable) ContactInfo(com.android.dialer.calllog.ContactInfo)

Aggregations

LetterTileDrawable (com.android.contacts.common.lettertiles.LetterTileDrawable)11 Bitmap (android.graphics.Bitmap)4 BitmapDrawable (android.graphics.drawable.BitmapDrawable)3 Drawable (android.graphics.drawable.Drawable)3 LayoutInflater (android.view.LayoutInflater)2 ImageView (android.widget.ImageView)2 ContactInfo (com.android.dialer.calllog.ContactInfo)2 Resources (android.content.res.Resources)1 AdaptiveIconDrawable (android.graphics.drawable.AdaptiveIconDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 RequiresApi (android.support.annotation.RequiresApi)1 RoundedBitmapDrawable (android.support.v4.graphics.drawable.RoundedBitmapDrawable)1 ContactType (com.android.contacts.common.lettertiles.LetterTileDrawable.ContactType)1 MaterialPalette (com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette)1 ContactInfoHelper (com.android.dialer.calllog.ContactInfoHelper)1 ContactInfoHelper (com.android.dialer.phonenumbercache.ContactInfoHelper)1 VisualVoicemailEnabledChecker (com.android.dialer.voicemail.VisualVoicemailEnabledChecker)1 VisualVoicemailEnabledChecker (com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker)1