/**
* Returns a bitmap suitable for the all apps view. The icon is badged for {@param user}.
* The bitmap is also visually normalized with other icons.
*/
public static Bitmap createBadgedIconBitmap(
Drawable icon, UserHandle user, Context context, int iconAppTargetSdk) {
IconNormalizer normalizer;
float scale = 1f;
normalizer = IconNormalizer.getInstance(context);
if (AndroidVersion.isAtLeastOreo() && iconAppTargetSdk >= Build.VERSION_CODES.O) {
boolean[] outShape = new boolean[1];
AdaptiveIconDrawable dr = (AdaptiveIconDrawable)
context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate();
dr.setBounds(0, 0, 1, 1);
scale = normalizer.getScale(icon, null, dr.getIconMask(), outShape);
if (!outShape[0]){
Drawable wrappedIcon = wrapToAdaptiveIconDrawable(context, icon, scale);
if (wrappedIcon != icon) {
icon = wrappedIcon;
scale = normalizer.getScale(icon, null, null, null);
}
}
}
Bitmap bitmap = createIconBitmap(icon, context, scale);
if (AndroidVersion.isAtLeastOreo() &&
icon instanceof AdaptiveIconDrawable) {
bitmap = ShadowGenerator.getInstance(context).recreateIcon(bitmap);
}
return badgeIconForUser(bitmap, user, context);
}
LauncherIcons.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:LaunchEnr
作者:
评论列表
文章目录