Public rooms search: AvatarGenerator: made generateRoomAvatar more generic to be used for public rooms

This commit is contained in:
manuroe 2015-12-22 11:37:45 +01:00
parent 6bee305057
commit 33bd9f40fb
3 changed files with 5 additions and 25 deletions

View file

@ -225,7 +225,7 @@
}
}
UIImage* avatarImage = [AvatarGenerator generateRoomAvatar:self];
UIImage* avatarImage = [AvatarGenerator generateRoomAvatar:self.state.roomId andDisplayName:self.vectorDisplayname];
if (roomAvatarUrl)
{

View file

@ -23,10 +23,11 @@
/**
Generate an avatar for a room.
@param room the room
@param roomId the id of the room.
@param displayName the display name of the room.
@return the avatar image
*/
+ (UIImage*)generateRoomAvatar:(MXRoom*)room;
+ (UIImage*)generateRoomAvatar:(NSString*)roomId andDisplayName:(NSString*)displayName;
/**
Generate an avatar for a room member.

View file

@ -16,8 +16,6 @@
#import "AvatarGenerator.h"
#import "MXRoom+Vector.h"
@implementation AvatarGenerator
static NSMutableDictionary *imageByKeyDict = nil;
@ -127,11 +125,6 @@ static UILabel* backgroundLabel = nil;
return image;
}
/**
Generate an avatar for a text.
@param text the text.
@return the avatar image
*/
+ (UIImage*)generateAvatarForText:(NSString*)text
{
NSUInteger index = [AvatarGenerator colorIndexForText:text];
@ -144,12 +137,6 @@ static UILabel* backgroundLabel = nil;
return [AvatarGenerator avatarForText:text andColorIndex:index];
}
/**
Generate an avatar for a room member.
@param userId the member userId
@param displayname the member displayname
@return the avatar image
*/
+ (UIImage*)generateRoomMemberAvatar:(NSString*)userId displayName:(NSString*)displayname
{
// the selected color is based on the userId
@ -171,16 +158,8 @@ static UILabel* backgroundLabel = nil;
return [AvatarGenerator avatarForText:text andColorIndex:index];
}
/**
Generate an avatar for a room.
@param room the room
@return the avatar image
*/
+ (UIImage*)generateRoomAvatar:(MXRoom*)room
+ (UIImage*)generateRoomAvatar:(NSString*)roomId andDisplayName:(NSString*)displayName
{
NSString* displayName = room.vectorDisplayname;
NSString* roomId = room.state.roomId;
// the selected color is based on the roomId
NSUInteger index = [AvatarGenerator colorIndexForText:roomId];
NSString* text = displayName;