Adapt to dark/light themed server-side avatars when using NC v25+.

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2022-10-21 18:21:28 +02:00
Родитель 35281a55d5
Коммит 0658d71305
24 изменённых файлов: 73 добавлений и 40 удалений

Просмотреть файл

@ -377,7 +377,7 @@
cell.labelTitle.text = participant.name;
if ([participant.source isEqualToString:kParticipantTypeUser]) {
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:participant.userId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:participant.userId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.contactImage setContentMode:UIViewContentModeScaleToFill];
} else if ([participant.source isEqualToString:kParticipantTypeEmail]) {

Просмотреть файл

@ -102,7 +102,7 @@ CGFloat const kCallParticipantCellMinHeight = 128;
_backgroundImageView = [[AvatarBackgroundImageView alloc] initWithFrame:self.bounds];
__weak UIImageView *weakBGView = _backgroundImageView;
self.backgroundView = _backgroundImageView;
[_backgroundImageView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:userId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[_backgroundImageView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:userId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
NSDictionary *headers = [response allHeaderFields];
id customAvatarHeader = [headers objectForKey:@"X-NC-IsCustomAvatar"];
@ -130,7 +130,7 @@ CGFloat const kCallParticipantCellMinHeight = 128;
}
if (userId && userId.length > 0) {
[self.peerAvatarImageView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:userId andSize:256 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[self.peerAvatarImageView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:userId withStyle:self.traitCollection.userInterfaceStyle andSize:256 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
} else {
UIColor *guestAvatarColor = [UIColor colorWithRed:0.73 green:0.73 blue:0.73 alpha:1.0]; /*#b9b9b9*/

Просмотреть файл

@ -533,7 +533,7 @@ typedef NS_ENUM(NSInteger, CallState) {
{
if (_room.type == kNCRoomTypeOneToOne) {
__weak AvatarBackgroundImageView *weakBGView = self.avatarBackgroundImageView;
[self.avatarBackgroundImageView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:_room.name andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[self.avatarBackgroundImageView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:_room.name withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
NSDictionary *headers = [response allHeaderFields];
id customAvatarHeader = [headers objectForKey:@"X-NC-IsCustomAvatar"];

Просмотреть файл

@ -324,6 +324,7 @@
[self.avatarView
setImageWithURLRequest:[[NCAPIController sharedInstance]
createAvatarRequestForUser:message.actorId
withStyle:self.traitCollection.userInterfaceStyle
andSize:96
usingAccount:activeAccount]
placeholderImage:nil success:nil failure:nil];

Просмотреть файл

@ -190,7 +190,7 @@
self.dateLabel.text = [NCUtils getTimeFromDate:date];
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
[self.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:message.actorId andSize:96 usingAccount:activeAccount]
[self.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:message.actorId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:activeAccount]
placeholderImage:nil success:nil failure:nil];
NSString *imageName = [[NCUtils previewImageForFileMIMEType:message.file.mimetype] stringByAppendingString:@"-chat-preview"];

Просмотреть файл

@ -169,7 +169,7 @@
self.dateLabel.text = [NCUtils getTimeFromDate:date];
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
[self.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:message.actorId andSize:96 usingAccount:activeAccount]
[self.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:message.actorId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:activeAccount]
placeholderImage:nil success:nil failure:nil];

Просмотреть файл

@ -214,7 +214,7 @@ extern NSInteger const kReceivedChatMessagesLimit;
- (void)checkOrCreateAttachmentFolderForAccount:(TalkAccount *)account withCompletionBlock:(CheckAttachmentFolderCompletionBlock)block;
// User avatars
- (NSURLRequest *)createAvatarRequestForUser:(NSString *)userId andSize:(NSInteger)size usingAccount:(TalkAccount *)account;
- (NSURLRequest *)createAvatarRequestForUser:(NSString *)userId withStyle:(UIUserInterfaceStyle) style andSize:(NSInteger)size usingAccount:(TalkAccount *)account;
- (void)getUserAvatarForUser:(NSString *)userId andSize:(NSInteger)size usingAccount:(TalkAccount *)account withCompletionBlock:(GetUserAvatarImageForUserCompletionBlock)block;
// User actions
@ -231,7 +231,7 @@ extern NSInteger const kReceivedChatMessagesLimit;
- (NSURLSessionDataTask *)removeUserProfileImageForAccount:(TalkAccount *)account withCompletionBlock:(SetUserProfileFieldCompletionBlock)block;
- (NSURLSessionDataTask *)setUserProfileImage:(UIImage *)image forAccount:(TalkAccount *)account withCompletionBlock:(SetUserProfileFieldCompletionBlock)block;
- (void)saveProfileImageForAccount:(TalkAccount *)account;
- (UIImage *)userProfileImageForAccount:(TalkAccount *)account withSize:(CGSize)size;
- (UIImage *)userProfileImageForAccount:(TalkAccount *)account withStyle:(UIUserInterfaceStyle)style andSize:(CGSize)size;
- (void)removeProfileImageForAccount:(TalkAccount *)account;
// User Status

Просмотреть файл

@ -1995,15 +1995,21 @@ NSInteger const kReceivedChatMessagesLimit = 100;
#pragma mark - User avatars
- (NSURLRequest *)createAvatarRequestForUser:(NSString *)userId andSize:(NSInteger)size usingAccount:(TalkAccount *)account
- (NSURLRequest *)createAvatarRequestForUser:(NSString *)userId withStyle:(UIUserInterfaceStyle)style andSize:(NSInteger)size usingAccount:(TalkAccount *)account
{
return [self createAvatarRequestForUser:userId withCachePolicy:NSURLRequestReturnCacheDataElseLoad andSize:size usingAccount:account];
return [self createAvatarRequestForUser:userId withCachePolicy:NSURLRequestReturnCacheDataElseLoad style:style andSize:size usingAccount:account];
}
- (NSURLRequest *)createAvatarRequestForUser:(NSString *)userId withCachePolicy:(NSURLRequestCachePolicy)cachePolicy andSize:(NSInteger)size usingAccount:(TalkAccount *)account
- (NSURLRequest *)createAvatarRequestForUser:(NSString *)userId withCachePolicy:(NSURLRequestCachePolicy)cachePolicy style:(UIUserInterfaceStyle)style andSize:(NSInteger)size usingAccount:(TalkAccount *)account
{
NSString *encodedUser = [userId stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
NSString *urlString = [NSString stringWithFormat:@"%@/index.php/avatar/%@/%ld", account.server, encodedUser, (long)size];
ServerCapabilities *serverCapabilities = [[NCDatabaseManager sharedInstance] serverCapabilitiesForAccountId:account.accountId];
NSString *urlString;
if (style == UIUserInterfaceStyleDark && serverCapabilities.versionMajor >= 25) {
urlString = [NSString stringWithFormat:@"%@/index.php/avatar/%@/%ld/dark", account.server, encodedUser, (long)size];
} else {
urlString = [NSString stringWithFormat:@"%@/index.php/avatar/%@/%ld", account.server, encodedUser, (long)size];
}
NSMutableURLRequest *avatarRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:cachePolicy timeoutInterval:60];
[avatarRequest setValue:[self authHeaderForAccount:account] forHTTPHeaderField:@"Authorization"];
return avatarRequest;
@ -2011,7 +2017,7 @@ NSInteger const kReceivedChatMessagesLimit = 100;
- (void)getUserAvatarForUser:(NSString *)userId andSize:(NSInteger)size usingAccount:(TalkAccount *)account withCompletionBlock:(GetUserAvatarImageForUserCompletionBlock)block
{
NSURLRequest *request = [self createAvatarRequestForUser:userId andSize:size usingAccount:account];
NSURLRequest *request = [self createAvatarRequestForUser:userId withStyle:UIUserInterfaceStyleLight andSize:size usingAccount:account];
[_imageDownloader downloadImageForURLRequest:request success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
NSData *pngData = UIImagePNGRepresentation(responseObject);
UIImage *image = [UIImage imageWithData:pngData];
@ -2184,7 +2190,12 @@ NSInteger const kReceivedChatMessagesLimit = 100;
- (void)saveProfileImageForAccount:(TalkAccount *)account
{
NSURLRequest *request = [self createAvatarRequestForUser:account.userId withCachePolicy:NSURLRequestReloadIgnoringCacheData andSize:160 usingAccount:account];
[self getAndStoreProfileImageForAccount:account withStyle:UIUserInterfaceStyleLight];
}
- (void)getAndStoreProfileImageForAccount:(TalkAccount *)account withStyle:(UIUserInterfaceStyle)style
{
NSURLRequest *request = [self createAvatarRequestForUser:account.userId withCachePolicy:NSURLRequestReloadIgnoringCacheData style:style andSize:160 usingAccount:account];
[_imageDownloader downloadImageForURLRequest:request success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
NSDictionary *headers = [response allHeaderFields];
@ -2197,20 +2208,38 @@ NSInteger const kReceivedChatMessagesLimit = 100;
NSData *pngData = UIImagePNGRepresentation(responseObject);
NSString *documentsPath = [[[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:groupIdentifier] path];
NSString *fileName = [NSString stringWithFormat:@"%@-%@.png", account.userId, [[NSURL URLWithString:account.server] host]];
NSString *fileName;
if (style == UIUserInterfaceStyleDark) {
fileName = [NSString stringWithFormat:@"%@-%@-dark.png", account.userId, [[NSURL URLWithString:account.server] host]];
} else {
fileName = [NSString stringWithFormat:@"%@-%@.png", account.userId, [[NSURL URLWithString:account.server] host]];
}
NSString *filePath = [documentsPath stringByAppendingPathComponent:fileName];
[pngData writeToFile:filePath atomically:YES];
ServerCapabilities *serverCapabilities = [[NCDatabaseManager sharedInstance] serverCapabilitiesForAccountId:account.accountId];
if (style == UIUserInterfaceStyleLight && !managedAccount.hasCustomAvatar && serverCapabilities.versionMajor >= 25) {
[self getAndStoreProfileImageForAccount:account withStyle:UIUserInterfaceStyleDark];
return;
}
[[NSNotificationCenter defaultCenter] postNotificationName:NCUserProfileImageUpdatedNotification object:self userInfo:nil];
} failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
NSLog(@"Could not download user profile image");
}];
}
- (UIImage *)userProfileImageForAccount:(TalkAccount *)account withSize:(CGSize)size
- (UIImage *)userProfileImageForAccount:(TalkAccount *)account withStyle:(UIUserInterfaceStyle)style andSize:(CGSize)size
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsPath = [[fileManager containerURLForSecurityApplicationGroupIdentifier:groupIdentifier] path];
NSString *fileName = [NSString stringWithFormat:@"%@-%@.png", account.userId, [[NSURL URLWithString:account.server] host]];
ServerCapabilities *serverCapabilities = [[NCDatabaseManager sharedInstance] serverCapabilitiesForAccountId:account.accountId];
NSString *fileName;
if (style == UIUserInterfaceStyleDark && !account.hasCustomAvatar && serverCapabilities.versionMajor >= 25) {
fileName = [NSString stringWithFormat:@"%@-%@-dark.png", account.userId, [[NSURL URLWithString:account.server] host]];
} else {
fileName = [NSString stringWithFormat:@"%@-%@.png", account.userId, [[NSURL URLWithString:account.server] host]];
}
NSString *filePath = [documentsPath stringByAppendingPathComponent:fileName];
// Migrate to app group directory
@ -2233,6 +2262,9 @@ NSInteger const kReceivedChatMessagesLimit = 100;
NSString *fileName = [NSString stringWithFormat:@"%@-%@.png", account.userId, [[NSURL URLWithString:account.server] host]];
NSString *filePath = [documentsPath stringByAppendingPathComponent:fileName];
[[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
fileName = [NSString stringWithFormat:@"%@-%@-dark.png", account.userId, [[NSURL URLWithString:account.server] host]];
filePath = [documentsPath stringByAppendingPathComponent:fileName];
[[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
// Legacy
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *oldDocumentsPath = [paths objectAtIndex:0];

Просмотреть файл

@ -651,7 +651,7 @@ NSString * const NCChatViewControllerTalkToUserNotification = @"NCChatViewContro
case kNCRoomTypeOneToOne:
{
// Request user avatar to the server and set it if exist
[_titleView.image setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:_room.name andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[_titleView.image setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:_room.name withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
}
break;
@ -3366,7 +3366,7 @@ NSString * const NCChatViewControllerTalkToUserNotification = @"NCChatViewContro
NSString *name = ([suggestionName isEqualToString:@"Guest"]) ? @"?" : suggestionName;
[suggestionCell.avatarView setImageWithString:name color:guestAvatarColor circular:true];
} else {
[suggestionCell.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:suggestionId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[suggestionCell.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:suggestionId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
}
return suggestionCell;

Просмотреть файл

@ -414,7 +414,7 @@ NSString * const NCSelectedContactForChatNotification = @"NCSelectedContactForCh
cell.labelTitle.accessibilityLabel = [NSString stringWithFormat:NSLocalizedString(@"Create a conversation with %@", nil), contact.name];
cell.labelTitle.accessibilityHint = [NSString stringWithFormat:NSLocalizedString(@"Double tap to create a conversation with %@", nil), contact.name];
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:contact.userId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:contact.userId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.contactImage setContentMode:UIViewContentModeScaleToFill];

Просмотреть файл

@ -173,7 +173,7 @@
self.dateLabel.text = [NCUtils getTimeFromDate:date];
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
[self.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:message.actorId andSize:96 usingAccount:activeAccount]
[self.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:message.actorId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:activeAccount]
placeholderImage:nil success:nil failure:nil];

Просмотреть файл

@ -132,7 +132,7 @@ import UIKit
// Actor avatar
if detail.actorType == "users" {
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()
if let request = NCAPIController.sharedInstance().createAvatarRequest(forUser: detail.actorId, andSize: 96, using: activeAccount) {
if let request = NCAPIController.sharedInstance().createAvatarRequest(forUser: detail.actorId, with: self.traitCollection.userInterfaceStyle, andSize: 96, using: activeAccount) {
cell.avatarImageView.setImageWith(request, placeholderImage: nil, success: nil, failure: nil)
cell.avatarImageView.contentMode = .scaleToFill
}

Просмотреть файл

@ -120,7 +120,7 @@ import UIKit
let actorType = actor?["actorType"] as? String
if actorId != nil && actorType == "users" {
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()
if let request = NCAPIController.sharedInstance().createAvatarRequest(forUser: actorId, andSize: 96, using: activeAccount) {
if let request = NCAPIController.sharedInstance().createAvatarRequest(forUser: actorId, with: self.traitCollection.userInterfaceStyle, andSize: 96, using: activeAccount) {
cell.avatarImageView.setImageWith(request, placeholderImage: nil, success: nil, failure: nil)
cell.avatarImageView.contentMode = .scaleToFill
}

Просмотреть файл

@ -120,7 +120,7 @@
cell.labelTitle.text = contact.name;
if ([contact.source isEqualToString:kParticipantTypeUser]) {
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:contact.userId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:contact.userId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.contactImage setContentMode:UIViewContentModeScaleToFill];
} else if ([contact.source isEqualToString:kParticipantTypeEmail]) {

Просмотреть файл

@ -400,7 +400,7 @@ NSString * const NCRoomCreatedNotification = @"NCRoomCreatedNotification";
cell.labelTitle.text = participant.name;
if ([participant.source isEqualToString:kParticipantTypeUser]) {
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:participant.userId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:participant.userId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.contactImage setContentMode:UIViewContentModeScaleToFill];
} else if ([participant.source isEqualToString:kParticipantTypeEmail]) {

Просмотреть файл

@ -358,7 +358,7 @@
cell.labelTitle.text = participant.name;
if ([participant.source isEqualToString:kParticipantTypeUser]) {
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:participant.userId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:participant.userId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.contactImage setContentMode:UIViewContentModeScaleToFill];
} else if ([participant.source isEqualToString:kParticipantTypeEmail]) {

Просмотреть файл

@ -1770,7 +1770,7 @@ typedef enum FileAction {
case kNCRoomTypeOneToOne:
{
cell.roomNameTextField.text = _room.displayName;
[cell.roomImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:_room.name andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.roomImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:_room.name withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.roomImage setContentMode:UIViewContentModeScaleToFill];
}
@ -2230,7 +2230,7 @@ typedef enum FileAction {
NSString *avatarName = ([participant.displayName isEqualToString:@""]) ? @"?" : participant.displayName;
[cell.contactImage setImageWithString:avatarName color:guestAvatarColor circular:true];
} else {
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:participant.participantId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:participant.participantId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.contactImage setContentMode:UIViewContentModeScaleToFill];
}

Просмотреть файл

@ -199,7 +199,7 @@ typedef enum RoomSearchSection {
NSString *actorType = [messageEntry.attributes objectForKey:@"actorType"];
if ([actorType isEqualToString:@"users"] && actorId) {
[cell.roomImage setImageWithURLRequest:
[[NCAPIController sharedInstance] createAvatarRequestForUser:actorId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[[NCAPIController sharedInstance] createAvatarRequestForUser:actorId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
cell.roomImage.contentMode = UIViewContentModeScaleToFill;
} else if ([actorType isEqualToString:@"guests"]) {
@ -309,7 +309,7 @@ typedef enum RoomSearchSection {
// Set room image
switch (room.type) {
case kNCRoomTypeOneToOne:
[cell.roomImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:room.name andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.roomImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:room.name withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.roomImage setContentMode:UIViewContentModeScaleToFill];
break;

Просмотреть файл

@ -413,7 +413,7 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
for (TalkAccount *talkAccount in [TalkAccount allObjects]) {
TalkAccount *account = [[TalkAccount alloc] initWithValue:talkAccount];
NSString *accountName = account.userDisplayName;
UIImage *accountImage = [[NCAPIController sharedInstance] userProfileImageForAccount:account withSize:CGSizeMake(72, 72)];
UIImage *accountImage = [[NCAPIController sharedInstance] userProfileImageForAccount:account withStyle:self.traitCollection.userInterfaceStyle andSize:CGSizeMake(72, 72)];
UIImageView *accessoryImageView = (account.active) ? [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox-checked"]] : nil;
FTPopOverMenuModel *accountModel = [[FTPopOverMenuModel alloc] initWithTitle:accountName image:accountImage selected:NO accessoryView:accessoryImageView];
[menuArray addObject:accountModel];
@ -728,7 +728,7 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
profileButton.accessibilityHint = NSLocalizedString(@"Double tap to go to user profile and application settings", nil);
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
UIImage *profileImage = [[NCAPIController sharedInstance] userProfileImageForAccount:activeAccount withSize:CGSizeMake(90, 90)];
UIImage *profileImage = [[NCAPIController sharedInstance] userProfileImageForAccount:activeAccount withStyle:self.traitCollection.userInterfaceStyle andSize:CGSizeMake(90, 90)];
if (profileImage) {
UIGraphicsBeginImageContextWithOptions(profileButton.bounds.size, NO, 3.0);
[[UIBezierPath bezierPathWithRoundedRect:profileButton.bounds cornerRadius:profileButton.bounds.size.height] addClip];
@ -1183,7 +1183,7 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
// Set room image
switch (room.type) {
case kNCRoomTypeOneToOne:
[cell.roomImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:room.name andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.roomImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:room.name withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.roomImage setContentMode:UIViewContentModeScaleToFill];
break;

Просмотреть файл

@ -120,7 +120,7 @@
cell.labelTitle.text = contact.name;
if ([contact.source isEqualToString:kParticipantTypeUser]) {
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:contact.userId andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
[cell.contactImage setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:contact.userId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:[[NCDatabaseManager sharedInstance] activeAccount]]
placeholderImage:nil success:nil failure:nil];
[cell.contactImage setContentMode:UIViewContentModeScaleToFill];
} else if ([contact.source isEqualToString:kParticipantTypeEmail]) {

Просмотреть файл

@ -651,7 +651,7 @@ extension SettingsTableViewController {
cell.userDisplayNameLabel.text = activeAccount.userDisplayName
let accountServer = activeAccount.server
cell.serverAddressLabel.text = accountServer.replacingOccurrences(of: "https://", with: "")
cell.userImageView.image = NCAPIController.sharedInstance().userProfileImage(for: activeAccount, with: CGSize(width: 160, height: 160))
cell.userImageView.image = NCAPIController.sharedInstance().userProfileImage(for: activeAccount, with: self.traitCollection.userInterfaceStyle, andSize: CGSize(width: 160, height: 160))
cell.accessoryType = .disclosureIndicator
return cell
}
@ -682,7 +682,7 @@ extension SettingsTableViewController {
cell.accountNameLabel.text = account.userDisplayName
let accountServer = account.server.replacingOccurrences(of: "https://", with: "")
cell.accountServerLabel.text = accountServer
cell.accountImageView.image = NCAPIController.sharedInstance().userProfileImage(for: account, with: CGSize(width: 90, height: 90))
cell.accountImageView.image = NCAPIController.sharedInstance().userProfileImage(for: account, with: self.traitCollection.userInterfaceStyle, andSize: CGSize(width: 90, height: 90))
cell.accessoryView = nil
if account.unreadBadgeNumber > 0 {
let badgeView = RoundedNumberView()

Просмотреть файл

@ -28,7 +28,7 @@ extension UserProfileTableViewController {
headerView.frame = CGRect(x: 0, y: 0, width: 200, height: 150)
headerView.avatarImageView?.layer.cornerRadius = 40.0
headerView.avatarImageView?.layer.masksToBounds = true
headerView.avatarImageView?.image = NCAPIController.sharedInstance().userProfileImage(for: account, with: CGSize(width: 160, height: 160))
headerView.avatarImageView?.image = NCAPIController.sharedInstance().userProfileImage(for: account, with: self.traitCollection.userInterfaceStyle, andSize: CGSize(width: 160, height: 160))
headerView.nameLabel?.text = account.userDisplayName
headerView.nameLabel?.isHidden = self.isEditable
headerView.scopeButton?.tag = kAvatarScopeButtonTag

Просмотреть файл

@ -201,7 +201,7 @@
self.dateLabel.text = [NCUtils getTimeFromDate:date];
TalkAccount *activeAccount = [[NCDatabaseManager sharedInstance] activeAccount];
[self.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:message.actorId andSize:96 usingAccount:activeAccount]
[self.avatarView setImageWithURLRequest:[[NCAPIController sharedInstance] createAvatarRequestForUser:message.actorId withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:activeAccount]
placeholderImage:nil success:nil failure:nil];
if (message.sendingFailed) {

Просмотреть файл

@ -279,7 +279,7 @@
profileButton.accessibilityLabel = NSLocalizedString(@"User profile and settings", nil);
profileButton.accessibilityHint = NSLocalizedString(@"Double tap to go to user profile and application settings", nil);
UIImage *profileImage = [[NCAPIController sharedInstance] userProfileImageForAccount:account withSize:CGSizeMake(90, 90)];
UIImage *profileImage = [[NCAPIController sharedInstance] userProfileImageForAccount:account withStyle:self.traitCollection.userInterfaceStyle andSize:CGSizeMake(90, 90)];
if (profileImage) {
UIGraphicsBeginImageContextWithOptions(profileButton.bounds.size, NO, 3.0);
[[UIBezierPath bezierPathWithRoundedRect:profileButton.bounds cornerRadius:profileButton.bounds.size.height] addClip];
@ -558,7 +558,7 @@
switch (room.type) {
case kNCRoomTypeOneToOne:
{
NSURLRequest *request = [[NCAPIController sharedInstance] createAvatarRequestForUser:room.name andSize:96 usingAccount:_shareAccount];
NSURLRequest *request = [[NCAPIController sharedInstance] createAvatarRequestForUser:room.name withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:_shareAccount];
[cell.avatarImageView setImageWithURLRequest:request placeholderImage:nil success:nil failure:nil];
[cell.avatarImageView setContentMode:UIViewContentModeScaleToFill];
}