Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class AvatarGroupLayout @JvmOverloads constructor(
avatarRadius,
resources,
avatar,
context
context,
avatarBorderSize
)
}
}
Expand Down
28 changes: 27 additions & 1 deletion app/src/main/java/com/owncloud/android/utils/DisplayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ public static void setAvatar(@NonNull User user, @NonNull String userId, AvatarG
* @param avatarRadius the avatar radius
* @param resources reference for density information
* @param callContext which context is called to set the generated avatar
* @param context general context
*/
public static void setAvatar(@NonNull User user,
@NonNull String userId,
Expand All @@ -469,6 +470,30 @@ public static void setAvatar(@NonNull User user,
Resources resources,
Object callContext,
Context context) {
setAvatar(user, userId, displayName, listener, avatarRadius, resources, callContext, context, 0);
}

/**
* fetches and sets the avatar of the given account in the passed callContext
*
* @param user the account to be used to connect to server
* @param userId the userId which avatar should be set
* @param displayName displayName used to generate avatar with first char, only used as fallback
* @param avatarRadius the avatar radius
* @param resources reference for density information
* @param callContext which context is called to set the generated avatar
* @param context general context
* @param avatarBorder value in case the avatar has a border, like in the case of the AvatarGroupLayout
*/
public static void setAvatar(@NonNull User user,
@NonNull String userId,
String displayName,
AvatarGenerationListener listener,
float avatarRadius,
Resources resources,
Object callContext,
Context context,
int avatarBorder) {
if (callContext instanceof View v) {
v.setContentDescription(String.valueOf(user.toPlatformAccount().hashCode()));
}
Expand All @@ -495,7 +520,8 @@ public static void setAvatar(@NonNull User user,
// if no one exists, show colored icon with initial char
if (avatar == null) {
try {
avatar = TextDrawable.createAvatarByUserId(displayName, avatarRadius);
avatar = TextDrawable.createAvatarByUserId(displayName,
(avatarRadius - avatarBorder));
} catch (Exception e) {
Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
avatar = ResourcesCompat.getDrawable(resources,
Expand Down
Loading