mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
(Ugly) work around to display differentiated avatars for numbers and usernames, until rest of the app is re-written in swift
This commit is contained in:
parent
d340db5680
commit
ecdb22dc5d
3 changed files with 25 additions and 2 deletions
|
|
@ -31,7 +31,8 @@ extension Address {
|
|||
}
|
||||
|
||||
private func initials(displayName: String?) -> String? { // Basic ImproveMe
|
||||
return displayName?.components(separatedBy: " ")
|
||||
let separator = displayName?.contains(" ") == true ? " " : "."
|
||||
return displayName?.components(separatedBy: separator)
|
||||
.reduce("") {
|
||||
($0.isEmpty ? "" : "\($0.first?.uppercased() ?? "")") +
|
||||
($1.isEmpty ? "" : "\($1.first?.uppercased() ?? "")")
|
||||
|
|
|
|||
|
|
@ -84,3 +84,20 @@ class Avatar : UIView {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@objc class AvatarBridge : NSObject { // Ugly work around to tap into the swift Avatars, until rest of the app is reworked in Swift.
|
||||
static var shared : Avatar? = nil
|
||||
static let size = 50.0
|
||||
@objc static func imageForAddress(address:OpaquePointer) -> UIImage? {
|
||||
if (shared == nil) {
|
||||
shared = Avatar(color:VoipTheme.primaryTextColor, textStyle: VoipTheme.call_generated_avatar_small)
|
||||
PhoneMainView.instance().mainViewController.view.addSubview(shared!)
|
||||
PhoneMainView.instance().mainViewController.view.sendSubviewToBack(shared!)
|
||||
shared?.bounds.size = CGSize(width: size, height: size)
|
||||
}
|
||||
let sAddr = Address.getSwiftObject(cObject: address)
|
||||
shared?.fillFromAddress(address: sAddr)
|
||||
return shared?.toImage()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#import "LinphoneManager.h"
|
||||
#import "ContactsListView.h"
|
||||
#import "Utils.h"
|
||||
#import "linphoneapp-Swift.h"
|
||||
|
||||
@implementation FastAddressBook {
|
||||
CNContactStore* store;
|
||||
|
|
@ -46,7 +47,11 @@
|
|||
if ([LinphoneManager isMyself:addr] && [LinphoneUtils hasSelfAvatar]) {
|
||||
return [LinphoneUtils selfAvatar];
|
||||
}
|
||||
return [FastAddressBook imageForContact:[FastAddressBook getContactWithAddress:addr]];
|
||||
UIImage *contactImage = [[FastAddressBook getContactWithAddress:addr] avatar];
|
||||
if (contactImage)
|
||||
return contactImage;
|
||||
else
|
||||
return [AvatarBridge imageForAddressWithAddress:addr];
|
||||
}
|
||||
|
||||
+ (UIImage *)imageForSecurityLevel:(LinphoneChatRoomSecurityLevel)level {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue