Skip to main content
Version: v6

AvatarView

Previously, AvatarView was used for both users and channels. In the new SDK v6, we have separated it into UserAvatarView and ChannelAvatarView, aligning it more closely with the Compose version.

ChannelAvatarView internally utilizes UserAvatarView and provides a more robust and straightforward approach for handling different varieties of showing the channel's avatar.

XML Changes

This change will require you to update your layout XML files in case you have directly used AvatarView there.

Whenever you've used AvatarView for a user, you will need to change it to UserAvatarView:

Was: io.getstream.chat.android.ui.avatar.AvatarView
Now: io.getstream.chat.android.ui.avatar.UserAvatarView

Similar action is required for channels:

Was: io.getstream.chat.android.ui.avatar.AvatarView
Now: io.getstream.chat.android.ui.avatar.ChannelAvatarView
note

The avatar_user.xml layout file has been replaced with two separate files: view_channel_avatar.xml and view_user_avatar.xml.

Code Changes

If you were using AvatarView in your code, you will need to change it to UserAvatarView or ChannelAvatarView depending on your use case. Additionally, you will need to pass the User or Channel object to the view in a slightly different manner.

UserAvatarView

Here is an example of how to use UserAvatarView:

Was: avatarView.setUserData(user)
Now: userAvatarView.setUser(user)

ChannelAvatarView

Here is an example of how to use ChannelAvatarView:

Was: avatarView.setChannelData(channel)
Now: channelAvatarView.setChannel(channel)

AvatarBitmapFactory:

Due to the deletion of AvatarBitmapFactory, the avatarBitmapFactory property was removed from ChatUI. This change happened because ChannelAvatarView is now responsible for combining child views to deliver a unified experience of merged avatars.

Deleted: io.getstream.chat.android.ui.avatar.AvatarBitmapFactory

Customization

With the new version we have also added some extra attributes for better customization of ChannelAvatarView:

<!-- Text size of the AvatarView's initials letters in group avatar -->
<attr name="streamUiGroupAvatarTextSize" format="dimension|reference" />
<!-- A color of the AvatarView's initials letters in group avatar -->
<attr name="streamUiGroupAvatarTextColor" format="color|reference" />
<!-- Font name of the AvatarView's initials letters in group avatar -->
<attr name="streamUiGroupAvatarTextFont" format="reference" />
<!-- Font assets reference for the AvatarView's initials letters in group avatar -->
<attr name="streamUiGroupAvatarTextFontAssets" format="string" />
<!-- Text style of the AvatarView's initials letters in group avatar -->
<attr name="streamUiGroupAvatarTextStyle">
<flag name="normal" value="0" />
<flag name="bold" value="1" />
<flag name="italic" value="2" />
</attr>

AvatarStyle has been changed accordingly.
In the previous version, AvatarStyle was exposing a single avatarInitialText text styling. However, in the new SDK v6, this has been separated into avatarInitialsTextStyle and groupAvatarInitialsTextStyle, providing better customizability.

Was:

public data class AvatarStyle(
//...
public val avatarInitialText: TextStyle,
//...
)

Now:

public data class AvatarStyle(
//...
public val avatarInitialsTextStyle: TextStyle,
public val groupAvatarInitialsTextStyle: TextStyle,
//...
)

Other Imports

This change might also require you to update some other imports as well:

Was: io.getstream.chat.android.ui.avatar.AvatarStyle
Now: io.getstream.chat.android.ui.widgets.avatar.AvatarStyle

Was: io.getstream.chat.android.ui.avatar.AvatarView.OnlineIndicatorPosition
Now: io.getstream.chat.android.ui.widgets.avatar.OnlineIndicatorPosition

Was: io.getstream.chat.android.ui.avatar.AvatarView.AvatarShape
Now: io.getstream.chat.android.ui.widgets.avatar.AvatarShape

Did you find this page helpful?