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);
}
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();
}
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;
}
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();
}
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);
}
Aggregations