mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 16:22:39 +00:00
-> increase the contact row height to 50 (to match to the members list cell).
The thumbnail size is also the same so it should avoid downloading thumbnails if they are already cached -> renamed some fieds -> fix some refresh issues
This commit is contained in:
parent
c99134351a
commit
64d37212dd
10 changed files with 121 additions and 83 deletions
|
@ -1360,27 +1360,27 @@
|
|||
<scene sceneID="bcI-aR-NZT">
|
||||
<objects>
|
||||
<tableViewController id="cpU-dg-M33" userLabel="Contacts" customClass="ContactsViewController" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="jgs-c1-w97">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="50" sectionHeaderHeight="22" sectionFooterHeight="22" id="jgs-c1-w97">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ContactCell" id="Qu4-km-MZA" customClass="ContactTableCell">
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ContactCell" rowHeight="50" id="Qu4-km-MZA" customClass="ContactTableCell">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Qu4-km-MZA" id="uEH-gd-MNN">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="B4B-GZ-atv" customClass="CustomImageView">
|
||||
<rect key="frame" x="12" y="3" width="38" height="38"/>
|
||||
<rect key="frame" x="12" y="5" width="40" height="40"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="tintColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="38" id="F3r-c8-zTQ"/>
|
||||
<constraint firstAttribute="width" constant="38" id="ewx-39-TQ9"/>
|
||||
<constraint firstAttribute="height" constant="40" id="F3r-c8-zTQ"/>
|
||||
<constraint firstAttribute="width" constant="40" id="ewx-39-TQ9"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nzg-dr-os0">
|
||||
<rect key="frame" x="62" y="8" width="510" height="30"/>
|
||||
<rect key="frame" x="64" y="8" width="508" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="30" id="92u-Am-XY3"/>
|
||||
</constraints>
|
||||
|
@ -1389,7 +1389,7 @@
|
|||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="matrixUser.png" translatesAutoresizingMaskIntoConstraints="NO" id="fJ6-gD-7yP">
|
||||
<rect key="frame" x="576" y="14" width="16" height="16"/>
|
||||
<rect key="frame" x="576" y="17" width="16" height="16"/>
|
||||
<color key="tintColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="16" id="RkA-cA-qCQ"/>
|
||||
|
@ -1408,9 +1408,9 @@
|
|||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="contactDisplayName" destination="nzg-dr-os0" id="2Ce-Xv-mPM"/>
|
||||
<outlet property="contactDisplayNameLabel" destination="nzg-dr-os0" id="K2D-4d-5Tb"/>
|
||||
<outlet property="matrixUserIconView" destination="fJ6-gD-7yP" id="hBT-VO-KJD"/>
|
||||
<outlet property="thumbnail" destination="B4B-GZ-atv" id="jDt-mM-3TL"/>
|
||||
<outlet property="thumbnailView" destination="B4B-GZ-atv" id="jwY-xh-asO"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
|
|
|
@ -44,7 +44,14 @@ extern NSString *const kConsoleContactThumbnailUpdateNotification;
|
|||
|
||||
- (id)initWithABRecord:(ABRecordRef)record;
|
||||
|
||||
// return thumbnail with a prefered size
|
||||
// if the thumbnail is already loaded, this method returns this one
|
||||
// if the thumbnail must trigger a server request, the expected size will be size
|
||||
// self.thumbnail triggered a request with a 256 X 256 pixels
|
||||
- (UIImage*)thumbnailWithPreferedSize:(CGSize)size;
|
||||
|
||||
// check if there is any matrix identifier updates
|
||||
- (void)checkMatrixIdentifiers;
|
||||
|
||||
|
||||
@end
|
|
@ -75,12 +75,8 @@ NSString *const kConsoleContactThumbnailUpdateNotification = @"kConsoleContactTh
|
|||
lbl = (__bridge NSString*)localizedLblRef;
|
||||
}
|
||||
}
|
||||
|
||||
ConsolePhoneNumber* pn = [[ConsolePhoneNumber alloc] init];
|
||||
pn.type = lbl;
|
||||
pn.textNumber = phoneVal;
|
||||
|
||||
[pns addObject:pn];
|
||||
|
||||
[pns addObject:[[ConsolePhoneNumber alloc] initWithTextNumber:phoneVal andType:lbl within:self.contactID]];
|
||||
|
||||
if (lblRef) {
|
||||
CFRelease(lblRef);
|
||||
|
@ -131,8 +127,7 @@ NSString *const kConsoleContactThumbnailUpdateNotification = @"kConsoleContactTh
|
|||
}
|
||||
}
|
||||
|
||||
ConsoleEmail* email = [[ConsoleEmail alloc] initWithEmailAddress:emailVal andType:lbl within:self.contactID];
|
||||
[emails addObject: email];
|
||||
[emails addObject: [[ConsoleEmail alloc] initWithEmailAddress:emailVal andType:lbl within:self.contactID]];
|
||||
|
||||
if (lblRef) {
|
||||
CFRelease(lblRef);
|
||||
|
@ -185,7 +180,11 @@ NSString *const kConsoleContactThumbnailUpdateNotification = @"kConsoleContactTh
|
|||
return identifiers;
|
||||
}
|
||||
|
||||
- (UIImage*)thumbnail {
|
||||
// return thumbnail with a prefered size
|
||||
// if the thumbnail is already loaded, this method returns this one
|
||||
// if the thumbnail must trigger a server request, the expected size will be size
|
||||
// self.thumbnail triggered a request with a 256 X 256 pixels
|
||||
- (UIImage*)thumbnailWithPreferedSize:(CGSize)size {
|
||||
// already found a matrix thumbnail
|
||||
if (matrixThumbnail) {
|
||||
return matrixThumbnail;
|
||||
|
@ -211,7 +210,7 @@ NSString *const kConsoleContactThumbnailUpdateNotification = @"kConsoleContactTh
|
|||
// try to load the first email one
|
||||
if (firstEmail) {
|
||||
// should be retrieved by the cell info
|
||||
[firstEmail loadAvatarWithSize:CGSizeMake(80, 80)];
|
||||
[firstEmail loadAvatarWithSize:size];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,6 +218,10 @@ NSString *const kConsoleContactThumbnailUpdateNotification = @"kConsoleContactTh
|
|||
}
|
||||
}
|
||||
|
||||
- (UIImage*)thumbnail {
|
||||
return [self thumbnailWithPreferedSize:CGSizeMake(256, 256)];
|
||||
}
|
||||
|
||||
- (void)checkMatrixIdentifiers {
|
||||
for(ConsoleEmail* email in self.emailAddresses) {
|
||||
[email getMatrixID];
|
||||
|
|
|
@ -16,17 +16,17 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ConsoleEmail : NSObject {
|
||||
BOOL pendingMatrixIDRequest;
|
||||
BOOL gotMatrixID;
|
||||
}
|
||||
@interface ConsoleEmail : NSObject
|
||||
|
||||
@property (nonatomic, readwrite) NSString *type;
|
||||
@property (nonatomic, readwrite) NSString *emailAddress;
|
||||
@property (nonatomic, readwrite) NSString *contactID;
|
||||
@property (nonatomic, readwrite) NSString *matrixUserID;
|
||||
@property (nonatomic, readwrite) NSString *avatarURL;
|
||||
@property (nonatomic, readwrite) UIImage *avatarImage;
|
||||
// email info
|
||||
@property (nonatomic, readonly) NSString *type;
|
||||
@property (nonatomic, readonly) NSString *emailAddress;
|
||||
// contact ID where the email has been found
|
||||
@property (nonatomic, readonly) NSString *contactID;
|
||||
// linked matrix account
|
||||
@property (nonatomic, readonly) NSString *matrixUserID;
|
||||
@property (nonatomic, readonly) NSString *avatarURL;
|
||||
@property (nonatomic, readonly) UIImage *avatarImage;
|
||||
|
||||
- (id)initWithEmailAddress:(NSString*)anEmailAddress andType:(NSString*)aType within:(NSString*)aContactID;
|
||||
|
||||
|
|
|
@ -21,6 +21,20 @@
|
|||
|
||||
#import "MediaManager.h"
|
||||
|
||||
@interface ConsoleEmail() {
|
||||
BOOL pendingMatrixIDRequest;
|
||||
BOOL gotMatrixID;
|
||||
}
|
||||
|
||||
@property (nonatomic, readwrite) NSString *type;
|
||||
@property (nonatomic, readwrite) NSString *emailAddress;
|
||||
@property (nonatomic, readwrite) NSString *contactID;
|
||||
@property (nonatomic, readwrite) NSString *matrixUserID;
|
||||
@property (nonatomic, readwrite) NSString *avatarURL;
|
||||
@property (nonatomic, readwrite) UIImage *avatarImage;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ConsoleEmail
|
||||
@synthesize type, emailAddress, contactID, matrixUserID, avatarImage, avatarURL;
|
||||
|
||||
|
@ -131,12 +145,12 @@
|
|||
|
||||
if (mxHandler.mxRestClient) {
|
||||
[mxHandler.mxRestClient avatarUrlForUser:self.matrixUserID
|
||||
success:^(NSString *avatarUrl) {
|
||||
self.avatarURL = [mxHandler thumbnailURLForContent:avatarUrl inViewSize:avatarSize withMethod:MXThumbnailingMethodCrop];
|
||||
[self downloadAvatarImage];
|
||||
}
|
||||
success:^(NSString *avatarUrl) {
|
||||
self.avatarURL = [mxHandler thumbnailURLForContent:avatarUrl inViewSize:avatarSize withMethod:MXThumbnailingMethodCrop];
|
||||
[self downloadAvatarImage];
|
||||
}
|
||||
failure:^(NSError *error) {
|
||||
//
|
||||
//
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
@interface ConsolePhoneNumber : NSObject
|
||||
|
||||
@property (nonatomic, readwrite) NSString *type;
|
||||
@property (nonatomic, readwrite) NSString *textNumber;
|
||||
@property (nonatomic, readwrite) NSString *contactID;
|
||||
// phonenumber info
|
||||
@property (nonatomic, readonly) NSString *type;
|
||||
@property (nonatomic, readonly) NSString *textNumber;
|
||||
// contact ID where the phonenumber has been found
|
||||
@property (nonatomic, readonly) NSString *contactID;
|
||||
|
||||
- (id)initWithTextNumber:(NSString*)textNumber andType:(NSString*)aType within:(NSString*)aContactID;
|
||||
|
||||
@end
|
|
@ -16,6 +16,12 @@
|
|||
|
||||
#import "ConsolePhoneNumber.h"
|
||||
|
||||
@interface ConsolePhoneNumber()
|
||||
@property (nonatomic, readwrite) NSString *type;
|
||||
@property (nonatomic, readwrite) NSString *textNumber;
|
||||
@property (nonatomic, readwrite) NSString *contactID;
|
||||
@end
|
||||
|
||||
@implementation ConsolePhoneNumber
|
||||
@synthesize type, textNumber, contactID;
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
@interface ContactTableCell : UITableViewCell
|
||||
|
||||
@property (strong, nonatomic) IBOutlet CustomImageView *thumbnail;
|
||||
@property (strong, nonatomic) IBOutlet UILabel *contactDisplayName;
|
||||
@property (strong, nonatomic) IBOutlet CustomImageView *thumbnailView;
|
||||
@property (strong, nonatomic) IBOutlet UILabel *contactDisplayNameLabel;
|
||||
@property (strong, nonatomic) IBOutlet UIImageView *matrixUserIconView;
|
||||
|
||||
// reference to the linked message
|
||||
|
|
|
@ -52,11 +52,10 @@
|
|||
[mxHandler.mxSession removeListener:membersListener];
|
||||
membersListener = nil;
|
||||
}
|
||||
self.thumbnail.layer.borderWidth = 0;
|
||||
|
||||
// add contact update info
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMatrixIdUpdate:) name:kConsoleContactMatrixIdentifierUpdateNotification object:nil];
|
||||
self.thumbnailView.layer.borderWidth = 0;
|
||||
|
||||
// be warned when the matrix ID and the thumbnail is updated
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMatrixIdUpdate:) name:kConsoleContactMatrixIdentifierUpdateNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onThumbnailUpdate:) name:kConsoleContactThumbnailUpdateNotification object:nil];
|
||||
|
||||
// Register a listener for events that concern room members
|
||||
|
@ -82,7 +81,10 @@
|
|||
}
|
||||
}];
|
||||
|
||||
[self refreshUserPresence];
|
||||
// init the contact info
|
||||
self.contactDisplayNameLabel.text = _contact.displayName;
|
||||
[self refreshContactThumbnail];
|
||||
[self manageMatrixIcon];
|
||||
}
|
||||
|
||||
- (void)refreshUserPresence {
|
||||
|
@ -100,51 +102,62 @@
|
|||
// check if already known as a Matrix user
|
||||
MXUser* mxUser = [mxHandler.mxSession userWithUserId:matrixUserID];
|
||||
|
||||
// unknown user
|
||||
if (!mxUser) {
|
||||
// request his presence
|
||||
[mxHandler.mxRestClient presence:matrixUserID
|
||||
success:^(MXPresenceResponse *presence) {
|
||||
[self refreshPresenceUserRing:presence.presenceStatus];
|
||||
}
|
||||
failure:^ (NSError *error) {
|
||||
}
|
||||
];
|
||||
|
||||
} else {
|
||||
[self refreshPresenceUserRing:mxUser.presence];
|
||||
// check if the mxUser is known
|
||||
// if it is not known, the presence cannot be retrieved
|
||||
if (mxUser) {
|
||||
[self refreshPresenceUserRing:mxUser.presence];
|
||||
// we know that this user is a matrix one
|
||||
self.matrixUserIconView.hidden = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)refreshContactThumbnail {
|
||||
self.thumbnailView.image = [self.contact thumbnailWithPreferedSize:self.thumbnailView.frame.size];
|
||||
|
||||
if (!self.thumbnailView.image) {
|
||||
self.thumbnailView.image = [UIImage imageNamed:@"default-profile"];
|
||||
}
|
||||
|
||||
// display the thumbnail in a circle
|
||||
if (self.thumbnailView.layer.cornerRadius != self.thumbnailView.frame.size.width / 2) {
|
||||
self.thumbnailView.layer.cornerRadius = self.thumbnailView.frame.size.width / 2;
|
||||
self.thumbnailView.clipsToBounds = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)refreshPresenceUserRing:(MXPresence)presenceStatus {
|
||||
UIColor* ringColor = [[MatrixHandler sharedHandler] getPresenceRingColor:presenceStatus];
|
||||
|
||||
// if the thumbnail is defined
|
||||
if (ringColor) {
|
||||
self.thumbnail.layer.borderWidth = 2;
|
||||
self.thumbnail.layer.borderColor = ringColor.CGColor;
|
||||
self.thumbnailView.layer.borderWidth = 2;
|
||||
self.thumbnailView.layer.borderColor = ringColor.CGColor;
|
||||
} else {
|
||||
// remove the border
|
||||
// else it draws black border
|
||||
self.thumbnail.layer.borderWidth = 0;
|
||||
self.thumbnailView.layer.borderWidth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)manageMatrixIcon {
|
||||
self.matrixUserIconView.hidden = (0 == _contact.matrixIdentifiers.count);
|
||||
|
||||
// try to update the thumbnail with the matrix thumbnail
|
||||
if (_contact.matrixIdentifiers) {
|
||||
[self refreshContactThumbnail];
|
||||
}
|
||||
|
||||
[self refreshUserPresence];
|
||||
}
|
||||
|
||||
- (void)onMatrixIdUpdate:(NSNotification *)notif {
|
||||
// sanity check
|
||||
if ([notif.object isKindOfClass:[NSString class]]) {
|
||||
NSString* matrixID = notif.object;
|
||||
|
||||
if ([matrixID isEqualToString:self.contact.contactID]) {
|
||||
self.matrixUserIconView.hidden = (0 == _contact.matrixIdentifiers.count);
|
||||
|
||||
// try to update the thumbnail with the matrix thumbnail
|
||||
if (_contact.matrixIdentifiers) {
|
||||
self.matrixUserIconView.image = self.contact.thumbnail;
|
||||
}
|
||||
|
||||
[self refreshUserPresence];
|
||||
[self manageMatrixIcon];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +168,8 @@
|
|||
NSString* matrixID = notif.object;
|
||||
|
||||
if ([matrixID isEqualToString:self.contact.contactID]) {
|
||||
self.thumbnail.image = self.contact.thumbnail;
|
||||
[self refreshContactThumbnail];
|
||||
self.matrixUserIconView.hidden = (0 == _contact.matrixIdentifiers.count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,10 @@
|
|||
return [[sectionedContacts.sectionedContacts objectAtIndex:section] count];
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return 50;
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section {
|
||||
if (sectionedContacts.sectionTitles.count <= section) {
|
||||
return nil;
|
||||
|
@ -123,20 +127,7 @@
|
|||
}
|
||||
|
||||
cell.contact = contact;
|
||||
|
||||
// set the thumbnail
|
||||
if (contact.thumbnail) {
|
||||
cell.thumbnail.image = contact.thumbnail;
|
||||
} else {
|
||||
cell.thumbnail.image = [UIImage imageNamed:@"default-profile"];
|
||||
}
|
||||
|
||||
cell.thumbnail.layer.cornerRadius = cell.thumbnail.frame.size.width / 2;
|
||||
cell.thumbnail.clipsToBounds = YES;
|
||||
|
||||
// and the displayname
|
||||
cell.contactDisplayName.text = contact.displayName;
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue