public static android.graphics.drawable.Drawable | getDefaultUserIcon(int userId, boolean light)Returns a default user icon for the given user.
Note that for guest users, you should pass in {@code UserHandle.USER_NULL}.
int colorResId = light ? R.color.user_icon_default_white : R.color.user_icon_default_gray;
if (userId != UserHandle.USER_NULL) {
// Return colored icon instead
colorResId = USER_ICON_COLORS[userId % USER_ICON_COLORS.length];
}
Drawable icon = Resources.getSystem().getDrawable(R.drawable.ic_account_circle).mutate();
icon.setColorFilter(Resources.getSystem().getColor(colorResId), Mode.SRC_IN);
icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
return icon;
|