ContactDetail: Link notes

This commit is contained in:
dtsbourg 2014-11-24 21:51:43 +01:00 committed by Frederic Jacobs
parent b3d2544b1f
commit 84e12a39c9
18 changed files with 380 additions and 183 deletions

View File

@ -503,6 +503,8 @@
FCF72A081A01A765006BC849 /* ContactsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCF72A071A01A765006BC849 /* ContactsTableViewController.m */; };
FCF72A131A02D27F006BC849 /* ContactDetailTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCF72A111A02D27F006BC849 /* ContactDetailTableViewController.m */; };
FCF72A161A02D2BB006BC849 /* ContactDetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FCF72A151A02D2BB006BC849 /* ContactDetailCell.m */; };
FCFA64B41A24F3880007FB87 /* UIColor+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFA64B31A24F3880007FB87 /* UIColor+OWS.m */; };
FCFA64B71A24F6730007FB87 /* UIFont+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFA64B61A24F6730007FB87 /* UIFont+OWS.m */; };
FCFD256F1A151BCB00F4C644 /* NewGroupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFD256E1A151BCB00F4C644 /* NewGroupViewController.m */; };
FCFD257F1A154B2C00F4C644 /* RegistrationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFD257E1A154B2C00F4C644 /* RegistrationViewController.m */; };
FCFD25821A154B3800F4C644 /* CodeVerificationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFD25811A154B3800F4C644 /* CodeVerificationViewController.m */; };
@ -1211,6 +1213,10 @@
FCF72A121A02D27F006BC849 /* ContactDetailTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactDetailTableViewController.h; sourceTree = "<group>"; };
FCF72A141A02D2BB006BC849 /* ContactDetailCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactDetailCell.h; sourceTree = "<group>"; };
FCF72A151A02D2BB006BC849 /* ContactDetailCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactDetailCell.m; sourceTree = "<group>"; };
FCFA64B21A24F3880007FB87 /* UIColor+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+OWS.h"; sourceTree = "<group>"; };
FCFA64B31A24F3880007FB87 /* UIColor+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+OWS.m"; sourceTree = "<group>"; };
FCFA64B51A24F6730007FB87 /* UIFont+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIFont+OWS.h"; path = "util/UIFont+OWS.h"; sourceTree = "<group>"; };
FCFA64B61A24F6730007FB87 /* UIFont+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIFont+OWS.m"; path = "util/UIFont+OWS.m"; sourceTree = "<group>"; };
FCFD256D1A151BCB00F4C644 /* NewGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewGroupViewController.h; sourceTree = "<group>"; };
FCFD256E1A151BCB00F4C644 /* NewGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewGroupViewController.m; sourceTree = "<group>"; };
FCFD257D1A154B2C00F4C644 /* RegistrationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegistrationViewController.h; sourceTree = "<group>"; };
@ -1745,6 +1751,7 @@
76EB04C818170B33006006FC /* util */ = {
isa = PBXGroup;
children = (
FCFA64B11A24F29E0007FB87 /* UI Categories */,
76EB04C918170B33006006FC /* ArrayUtil.h */,
76EB04CA18170B33006006FC /* ArrayUtil.m */,
76EB04CD18170B33006006FC /* BloomFilter.h */,
@ -3031,6 +3038,18 @@
name = ViewControllers;
sourceTree = "<group>";
};
FCFA64B11A24F29E0007FB87 /* UI Categories */ = {
isa = PBXGroup;
children = (
FCFA64B21A24F3880007FB87 /* UIColor+OWS.h */,
FCFA64B31A24F3880007FB87 /* UIColor+OWS.m */,
FCFA64B51A24F6730007FB87 /* UIFont+OWS.h */,
FCFA64B61A24F6730007FB87 /* UIFont+OWS.m */,
);
name = "UI Categories";
path = ..;
sourceTree = "<group>";
};
FCFD25791A1543D500F4C644 /* Signup */ = {
isa = PBXGroup;
children = (
@ -3421,6 +3440,7 @@
76EB05D218170B33006006FC /* ZrtpInitiator.m in Sources */,
76EB05E018170B33006006FC /* NetworkStream.m in Sources */,
B6B0968A1A1D25ED008BFAA6 /* TSStorageManager+SessionStore.m in Sources */,
FCFA64B71A24F6730007FB87 /* UIFont+OWS.m in Sources */,
B6B096891A1D25ED008BFAA6 /* TSStorageManager+PreKeyStore.m in Sources */,
FC4FA0331A1D46AE00DA100A /* InitialViewController.m in Sources */,
B6B9ECFC198B31BA00C620D3 /* PushManager.m in Sources */,
@ -3505,6 +3525,7 @@
E197B61118BBEC1A00F073E5 /* AudioProcessor.m in Sources */,
FCAC964019FEF99A0046DFC5 /* InboxTableViewCell.m in Sources */,
76EB05EA18170B33006006FC /* CallProgress.m in Sources */,
FCFA64B41A24F3880007FB87 /* UIColor+OWS.m in Sources */,
76EB05C218170B33006006FC /* DhPacketSharedSecretHashes.m in Sources */,
B6B096701A1D25ED008BFAA6 /* TSInfoMessage.m in Sources */,
B6C93C4E199567AD00EDF894 /* DebugLogger.m in Sources */,

View File

@ -1818,6 +1818,11 @@ Lorem ipsum : Quick explanation of Fingerprints</string>
</variation>
</tableViewCellContentView>
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
<connections>
<outlet property="contactCallButton" destination="yd5-y1-zqu" id="Lu1-fO-YK1"/>
<outlet property="contactShredButton" destination="jiU-kH-HN5" id="TCh-04-gXv"/>
<outlet property="contactTextButton" destination="cfo-cG-hLC" id="JKY-RT-mn6"/>
</connections>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ShareCell" rowHeight="60" id="hSC-7F-dj5" customClass="ContactDetailCell">
<autoresizingMask key="autoresizingMask"/>
@ -2020,10 +2025,14 @@ Lorem ipsum : Quick explanation of Fingerprints</string>
</subviews>
<constraints>
<constraint firstItem="9Lh-4T-usd" firstAttribute="leading" secondItem="ep9-kD-7xS" secondAttribute="leadingMargin" constant="15" id="AEY-2t-l6c"/>
<constraint firstAttribute="trailingMargin" secondItem="9Lh-4T-usd" secondAttribute="trailing" constant="25" id="NZf-g0-8kB"/>
<constraint firstAttribute="trailingMargin" secondItem="9Lh-4T-usd" secondAttribute="trailing" constant="25" id="NZf-g0-8kB">
<variation key="heightClass=regular-widthClass=compact" constant="15"/>
</constraint>
<constraint firstItem="tp2-2C-q6U" firstAttribute="leading" secondItem="ep9-kD-7xS" secondAttribute="leadingMargin" constant="15" id="V9H-eI-eg6"/>
<constraint firstItem="9Lh-4T-usd" firstAttribute="top" secondItem="ep9-kD-7xS" secondAttribute="topMargin" constant="24" id="oHG-jp-XMy"/>
<constraint firstAttribute="bottomMargin" secondItem="9Lh-4T-usd" secondAttribute="bottom" constant="-0.5" id="r5K-MP-uYB"/>
<constraint firstAttribute="bottomMargin" secondItem="9Lh-4T-usd" secondAttribute="bottom" constant="-0.5" id="r5K-MP-uYB">
<variation key="heightClass=regular-widthClass=compact" constant="0.0"/>
</constraint>
<constraint firstItem="tp2-2C-q6U" firstAttribute="top" secondItem="ep9-kD-7xS" secondAttribute="topMargin" constant="2" id="vpL-Be-Nwq"/>
</constraints>
<variation key="default">
@ -2056,6 +2065,9 @@ Lorem ipsum : Quick explanation of Fingerprints</string>
</variation>
</tableViewCellContentView>
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
<connections>
<outlet property="contactNotesTextView" destination="9Lh-4T-usd" id="dqc-pd-luh"/>
</connections>
</tableViewCell>
</prototypes>
<connections>

17
Signal/src/UIColor+OWS.h Normal file
View File

@ -0,0 +1,17 @@
//
// UIColor+UIColor_OWS.h
// Signal
//
// Created by Dylan Bourgeois on 25/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (UIColor_OWS)
+(UIColor*) ows_blueColor;
+(UIColor*) ows_darkBackgroundColor;
+(UIColor*) ows_darkGrayColor;
@end

29
Signal/src/UIColor+OWS.m Normal file
View File

@ -0,0 +1,29 @@
//
// UIColor+UIColor_OWS.m
// Signal
//
// Created by Dylan Bourgeois on 25/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "UIColor+OWS.h"
@implementation UIColor (UIColor_OWS)
+(UIColor*) ows_blueColor
{
return [UIColor colorWithRed:0.f/255.f green:122.f/255.f blue:255.f/255.f alpha:1.0f];
}
+(UIColor*) ows_darkGrayColor
{
return [UIColor colorWithRed:81.f/255.f green:81.f/255.f blue:81.f/255.f alpha:1.0f];
}
+(UIColor*) ows_darkBackgroundColor
{
return [UIColor colorWithRed:35.0f/255.0f green:31.0f/255.0f blue:32.0f/255.0f alpha:1.0f];
}
@end

View File

@ -0,0 +1,21 @@
//
// UIFont+OWS.h
// Signal
//
// Created by Dylan Bourgeois on 25/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIFont (OWS)
+ (UIFont*) ows_thinFontWithSize:(CGFloat)size;
+ (UIFont*) ows_lightFontWithSize:(CGFloat)size;
+ (UIFont*) ows_regularFontWithSize:(CGFloat)size;
+ (UIFont*) ows_boldFontWithSize:(CGFloat)size;
@end

View File

@ -0,0 +1,38 @@
//
// UIFont+OWS.m
// Signal
//
// Created by Dylan Bourgeois on 25/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
static NSString *const kHelveticaNeueThin = @"HelveticaNeue-Thin";
static NSString *const kHelveticaNeueLight = @"HelveticaNeue-Light";
static NSString *const kHelveticaNeueRegular = @"HelveticaNeue-Regular";
static NSString *const kHelveticaNeueBold = @"HelveticaNeue-Bold";
#import "UIFont+OWS.h"
@implementation UIFont (OWS)
+ (UIFont*) ows_thinFontWithSize:(CGFloat)size
{
return [UIFont fontWithName:kHelveticaNeueThin size:size];
}
+ (UIFont*) ows_lightFontWithSize:(CGFloat)size
{
return [UIFont fontWithName:kHelveticaNeueLight size:size];
}
+ (UIFont*) ows_regularFontWithSize:(CGFloat)size
{
return [UIFont fontWithName:kHelveticaNeueRegular size:size];
}
+ (UIFont*) ows_boldFontWithSize:(CGFloat)size
{
return [UIFont fontWithName:kHelveticaNeueBold size:size];
}
@end

View File

@ -1,25 +1,16 @@
#import <Foundation/Foundation.h>
#import "UIColor+OWS.h"
#import "UIFont+OWS.h"
/**
*
* UTUtil contains various class methods that centralize common app UI functionality that would otherwise be hardcoded.
* UIUtil contains various class methods that centralize common app UI functionality that would otherwise be hardcoded.
*
*/
@interface UIUtil : NSObject
+ (UIFont *)helveticaNeueLTStdLightFontWithSize:(CGFloat)size;
+ (UIFont *)helveticaNeueLTStdBoldFontWithSize:(CGFloat)size;
+ (UIFont *)helveticaNeueLTStdMediumFontWithSize:(CGFloat)size;
+ (UIFont *)helveticaRegularWithSize:(CGFloat)size;
+ (UIFont *)helveticaLightWithSize:(CGFloat)size;
+ (UIColor*)darkBackgroundColor;
+ (UIColor*)blueColor;
+ (UIColor*)yellowColor;
+ (UIColor*)redColor;
+ (UIColor*)greenColor;
+ (UIColor*)whiteColor;
+ (UIColor*)transparentLightGrayColor;
+ (void)applyRoundedBorderToImageView:(UIImageView *__strong*)imageView;
+ (void)removeRoundedBorderToImageView:(UIImageView *__strong*)imageView;

View File

@ -1,62 +1,9 @@
#import "UIUtil.h"
static NSString *const HELVETICA_NEUE_LTSTD_LIGHT_NAME = @"HelveticaNeueLTStd-Lt";
static NSString *const HELVETICA_NEUE_LTSTD_BOLD_NAME = @"HelveticaNeueLTStd-Bold";
static NSString *const HELVETICA_NEUE_LTSTD_MEDIUM_NAME = @"HelveticaNeueLTStd-Md";
static NSString *const HELVETICA_REGULAR_NAME = @"Helvetica";
static NSString *const HELVETICA_LIGHT_NAME = @"Helvetica-Light";
#define CONTACT_PICTURE_VIEW_BORDER_WIDTH 0.5f
@implementation UIUtil
+ (UIFont *)helveticaNeueLTStdLightFontWithSize:(CGFloat)size {
return [UIFont fontWithName:HELVETICA_NEUE_LTSTD_LIGHT_NAME size:size];
}
+ (UIFont *)helveticaNeueLTStdBoldFontWithSize:(CGFloat)size {
return [UIFont fontWithName:HELVETICA_NEUE_LTSTD_BOLD_NAME size:size];
}
+ (UIFont *)helveticaNeueLTStdMediumFontWithSize:(CGFloat)size {
return [UIFont fontWithName:HELVETICA_NEUE_LTSTD_MEDIUM_NAME size:size];
}
+ (UIFont *)helveticaRegularWithSize:(CGFloat)size {
return [UIFont fontWithName:HELVETICA_REGULAR_NAME size:size];
}
+ (UIFont *)helveticaLightWithSize:(CGFloat)size {
return [UIFont fontWithName:HELVETICA_LIGHT_NAME size:size];
}
+ (UIColor*)darkBackgroundColor {
return [UIColor colorWithRed:35.0f/255.0f green:31.0f/255.0f blue:32.0f/255.0f alpha:1.0f];
}
+ (UIColor*)blueColor {
return [UIColor colorWithRed:0.0f green:174.0f/255.0f blue:239.0f/255.0f alpha:1.0f];
}
+ (UIColor*)yellowColor {
return [UIColor colorWithRed:1.0f green:221.0f/255.0f blue:170.0f/255.0f alpha:1.0f];
}
+ (UIColor*)redColor {
return [UIColor colorWithRed:237.0f/255.0f green:96.0f/255.0f blue:98.0f/255.0f alpha:1.0f];
}
+ (UIColor *)greenColor {
return [UIColor colorWithRed:0.0f green:199.0f/255.0f blue:149.0f/255.0f alpha:1.0f];
}
+ (UIColor*)whiteColor {
return [UIColor colorWithRed:0.8f green:0.8f blue:0.8f alpha:1.0f];
}
+ (UIColor*)transparentLightGrayColor {
return [UIColor colorWithRed:0.5f green:0.5f blue:0.5f alpha:0.7f];
}
+ (void)applyRoundedBorderToImageView:(UIImageView *__strong*)imageView {
[[*imageView layer] setBorderWidth:CONTACT_PICTURE_VIEW_BORDER_WIDTH];

View File

@ -12,8 +12,8 @@
#import "UIUtil.h"
#import "DJWActionSheet.h"
#define kImageRadius 50.0f
#define kMinRows 4
#define kImageRadius 50.0f
#define kMinRows 3
#define kFirstAdaptableCellRow 2
@ -87,6 +87,7 @@ static NSString *const kContactDetailSegue = @"DetailSegue";
break;
case kActionCellIndexPath:
cell = (ActionContactDetailCell*)[tableView dequeueReusableCellWithIdentifier:kActionCell forIndexPath:indexPath];
[self setUpActionCell:(ActionContactDetailCell*)cell];
break;
case kShareCellIndexPath:
cell = [tableView dequeueReusableCellWithIdentifier:kShareCell forIndexPath:indexPath];
@ -101,27 +102,6 @@ static NSString *const kContactDetailSegue = @"DetailSegue";
}
-(void)setUpNameMainUserCell:(ContactDetailCell*)cell
{
Contact* c = self.contact;
cell.contactName.text = [c fullName];
cell.contactPhoneNumber.text = [[c userTextPhoneNumbers] firstObject];
if (c.image) {
cell.contactImageView.image = c.image;
} else {
[cell.contactImageView addConstraint:[NSLayoutConstraint constraintWithItem:cell.contactImageView attribute:NSLayoutAttributeHeight relatedBy:0 toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:0]];
doesImageExist = NO;
}
[cell.contactImageView.layer setCornerRadius:kImageRadius];
[cell.contactImageView.layer setMasksToBounds:YES];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat cellHeight = 44.0f;
@ -156,98 +136,193 @@ static NSString *const kContactDetailSegue = @"DetailSegue";
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (tappedButtonIndex == actionSheet.cancelButtonIndex) {
NSLog(@"User Cancelled");
} else if (tappedButtonIndex == actionSheet.destructiveButtonIndex) {
NSLog(@"Destructive button tapped");
}else {
NSLog(@"The user tapped button at index: %li", (long)tappedButtonIndex);
}
}];
break;
}
}
#pragma mark - Utilities (Adaptable Cells)
-(NSUInteger)numberOfRowsForContact:(Contact*)contact
#pragma mark - Set Up Cells
-(void)setUpActionCell:(ActionContactDetailCell*)cell
{
NSUInteger numEmails = contact.emails.count;
NSUInteger numPhoneNumbers = contact.userTextPhoneNumbers.count-1; //Don't count main
Contact * c = self.contact;
UIImage *callImage = [[UIImage imageNamed:@"call_dark"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[cell.contactCallButton setImage:callImage forState:UIControlStateNormal];
UIImage *messageImage = [[UIImage imageNamed:@"signals_tab"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[cell.contactTextButton setImage:messageImage forState:UIControlStateNormal];
UIImage *clearImage = [[UIImage imageNamed:@"delete_history"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[cell.contactShredButton setImage:clearImage forState:UIControlStateNormal];
cell.contactShredButton.tintColor = [UIColor redColor];
if (c.isRedPhoneContact)
{
cell.contactCallButton.tintColor = [UIColor colorWithRed:0.f/255.f green:122.f/255.f blue:255.f/255.f alpha:1.0f];
} else {
cell.contactCallButton.tintColor = [UIColor colorWithRed:81.f/255.f green:81.f/255.f blue:81.f/255.f alpha:1.0f];
cell.contactCallButton.enabled = NO;
}
if (c.isTextSecureContact)
{
cell.contactTextButton.tintColor = [UIColor colorWithRed:0.f/255.f green:122.f/255.f blue:255.f/255.f alpha:1.0f];
} else {
cell.contactTextButton.tintColor = [UIColor colorWithRed:81.f/255.f green:81.f/255.f blue:81.f/255.f alpha:1.0f];
cell.contactTextButton.enabled = NO;
}
return kMinRows + numEmails + numPhoneNumbers;
}
-(UITableViewCell*)adaptableCellAtIndexPath:(NSIndexPath*)idx
-(void)setUpNameMainUserCell:(ContactDetailCell*)cell
{
NSInteger emailUpperBound = (NSInteger)(kFirstAdaptableCellRow+_contact.emails.count);
NSInteger phoneNumberUpperBound = emailUpperBound + (NSInteger)_contact.userTextPhoneNumbers.count;
Contact* c = self.contact;
cell.contactName.text = [c fullName];
cell.contactPhoneNumber.text = [[c userTextPhoneNumbers] firstObject];
if (c.image) {
cell.contactImageView.image = c.image;
} else {
[cell.contactImageView addConstraint:[NSLayoutConstraint constraintWithItem:cell.contactImageView attribute:NSLayoutAttributeHeight relatedBy:0 toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:0]];
doesImageExist = NO;
}
[cell.contactImageView.layer setCornerRadius:kImageRadius];
[cell.contactImageView.layer setMasksToBounds:YES];
}
-(void)setUpEmailCell:(ContactDetailCell*)cell forIndexPath:(NSIndexPath*)indexPath
{
cell.contactEmailLabel.text = [_contact.emails objectAtIndex:(NSUInteger)indexPath.row-kMinRows];
}
-(void)setUpAnnexNumberCell:(ContactDetailCell*)cell forIndexPath:(NSIndexPath*)indexPath
{
NSInteger i = indexPath.row - [self emailUpperBound] ;
cell.contactAnnexNumberLabel.text = [_contact.userTextPhoneNumbers objectAtIndex:(NSUInteger)i];
}
-(void)setUpNotesCell:(ContactDetailCell*)cell
{
cell.contactNotesTextView.text = _contact.notes;
}
#pragma mark - Utilities (Adaptable Cells)
-(UITableViewCell*)adaptableCellAtIndexPath:(NSIndexPath*)indexPath
{
ContactDetailCell * cell;
if (idx.row > kFirstAdaptableCellRow && idx.row <= emailUpperBound)
if ([self isEmailIndexPath:indexPath])
{
cell = [self.tableView dequeueReusableCellWithIdentifier:kEmailCell forIndexPath:idx];
cell.contactEmailLabel.text = [_contact.emails objectAtIndex:(NSUInteger)idx.row-_contact.emails.count];
cell = [self.tableView dequeueReusableCellWithIdentifier:kEmailCell forIndexPath:indexPath];
[self setUpEmailCell:cell forIndexPath:indexPath];
return cell;
}
else if (idx.row > emailUpperBound && idx.row < phoneNumberUpperBound)
else if ([self isAnnexNumberIndexPath:indexPath])
{
cell = [self.tableView dequeueReusableCellWithIdentifier:kAnnexPhoneNumberCell forIndexPath:idx];
NSInteger i = idx.row - emailUpperBound ;
cell.contactAnnexNumberLabel.text = [_contact.userTextPhoneNumbers objectAtIndex:(NSUInteger)i];
cell = [self.tableView dequeueReusableCellWithIdentifier:kAnnexPhoneNumberCell forIndexPath:indexPath];
[self setUpAnnexNumberCell:cell forIndexPath:indexPath];
return cell;
}
else if (idx.row == (NSInteger)[self numberOfRowsForContact:_contact]-1)
else if ([self isNotesIndexPath:indexPath])
{
return [self.tableView dequeueReusableCellWithIdentifier:kNotesCell forIndexPath:idx];
cell = [self.tableView dequeueReusableCellWithIdentifier:kNotesCell forIndexPath:indexPath];
[self setUpNotesCell:cell];
return cell;
}
else
{
NSLog(@"%s Problem at IndexPath %@", __PRETTY_FUNCTION__, idx);
return nil;
}
}
-(CGFloat)heightForAdaptableCellAtIndexPath:(NSIndexPath*)idx
-(CGFloat)heightForAdaptableCellAtIndexPath:(NSIndexPath*)indexPath
{
NSInteger emailUpperBound = (NSInteger)(kFirstAdaptableCellRow+_contact.emails.count);
NSInteger phoneNumberUpperBound = emailUpperBound + (NSInteger)_contact.userTextPhoneNumbers.count;
if (idx.row > kFirstAdaptableCellRow && idx.row <= emailUpperBound)
if ([self isEmailIndexPath:indexPath])
{
return kEmailCellHeight;
}
else if (idx.row > emailUpperBound && idx.row < phoneNumberUpperBound)
else if ([self isAnnexNumberIndexPath:indexPath])
{
return kAnnexPhoneNumberCellHeight;
}
else if (idx.row == (NSInteger)[self numberOfRowsForContact:_contact]-1)
else if ([self isNotesIndexPath:indexPath])
{
return kNotesCellHeight;
}
else
{
NSLog(@"%s Problem at IndexPath %@", __PRETTY_FUNCTION__, idx);
return 44.0f;
}
}
#pragma mark - IndexPaths
-(BOOL)isEmailIndexPath:(NSIndexPath*)indexPath
{
return indexPath.row > kFirstAdaptableCellRow && indexPath.row <= [self emailUpperBound];
}
-(BOOL)isAnnexNumberIndexPath:(NSIndexPath*)indexPath
{
return indexPath.row > [self emailUpperBound] && indexPath.row < [self phoneNumberUpperBound];
}
-(BOOL)isNotesIndexPath:(NSIndexPath*)indexPath
{
return indexPath.row == (NSInteger)[self numberOfRowsForContact:_contact]-1;
}
#pragma mark - Utilities (Bounds)
-(NSInteger)emailUpperBound
{
return (NSInteger)(kFirstAdaptableCellRow+_contact.emails.count);
}
-(NSInteger)phoneNumberUpperBound
{
return [self emailUpperBound] + (NSInteger)_contact.userTextPhoneNumbers.count;
}
-(NSUInteger)numberOfRowsForContact:(Contact*)contact
{
NSUInteger numNotes = contact.notes.length == 0 ? 0 : 1;
NSUInteger numEmails = contact.emails.count;
NSUInteger numPhoneNumbers = contact.userTextPhoneNumbers.count-1;
return kMinRows + numEmails + numPhoneNumbers + numNotes;
}
@end

View File

@ -7,6 +7,7 @@
//
#import <UIKit/UIKit.h>
#import "UIUtil.h"
@interface ContactsTableViewController : UITableViewController

View File

@ -32,7 +32,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
NSArray *searchResults;
}
@property (nonatomic, strong) UILabel *emptyViewLabel;
@property NSArray *latestSortedAlphabeticalContactKeys;
@property NSArray *latestContacts;
@property (nonatomic, strong) UISearchController *searchController;
@ -44,18 +44,9 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contactsDidRefresh) name:NOTIFICATION_DIRECTORY_WAS_UPDATED object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contactRefreshFailed) name:NOTIFICATION_DIRECTORY_FAILED object:nil];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc]
init];
[refreshControl addTarget:self action:@selector(refreshContacts) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
[self.contactTableView addSubview:self.refreshControl];
self.tableView.contentOffset = CGPointMake(0, 44);
[self initializeObservers];
[self initializeRefreshControl];
[self initializeTableView];
[self initializeSearch];
[self setupContacts];
@ -63,6 +54,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
[self.tableView reloadData];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@ -89,6 +81,27 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
}
-(void)initializeRefreshControl
{
UIRefreshControl *refreshControl = [[UIRefreshControl alloc]init];
[refreshControl addTarget:self action:@selector(refreshContacts) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
[self.contactTableView addSubview:self.refreshControl];
}
-(void)initializeTableView
{
self.tableView.contentOffset = CGPointMake(0, 44);
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
}
-(void)initializeObservers
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contactsDidRefresh) name:NOTIFICATION_DIRECTORY_WAS_UPDATED object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contactRefreshFailed) name:NOTIFICATION_DIRECTORY_FAILED object:nil];
}
#pragma mark - UISearchResultsUpdating
-(void)updateSearchResultsForSearchController:(UISearchController *)searchController {
@ -114,7 +127,9 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
{
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"fullName contains[c] %@", searchText];
searchResults = [self.latestContacts filteredArrayUsingPredicate:resultPredicate];
if (!searchResults.count && _searchController.searchBar.text.length == 0) searchResults = self.latestContacts;
if (!searchResults.count && _searchController.searchBar.text.length == 0) {
searchResults = self.latestContacts;
}
}
@ -138,32 +153,15 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
NSDictionary * dic;
dic = @{
@"A": @[],
@"B": @[],
@"C": @[],
@"D": @[],
@"E": @[],
@"F": @[],
@"G": @[],
@"H": @[],
@"I": @[],
@"J": @[],
@"K": @[],
@"L": @[],
@"M": @[],
@"N": @[],
@"O": @[],
@"P": @[],
@"Q": @[],
@"R": @[],
@"S": @[],
@"T": @[],
@"U": @[],
@"V": @[],
@"W": @[],
@"X": @[],
@"Y": @[],
@"Z": @[]
@"A": @[], @"B": @[], @"C": @[],
@"D": @[], @"E": @[], @"F": @[],
@"G": @[], @"H": @[], @"I": @[],
@"J": @[], @"K": @[], @"L": @[],
@"M": @[], @"N": @[], @"O": @[],
@"P": @[], @"Q": @[], @"R": @[],
@"S": @[], @"T": @[], @"U": @[],
@"V": @[], @"W": @[], @"X": @[],
@"Y": @[], @"Z": @[]
};
return [dic mutableCopy];
@ -193,7 +191,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
{
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
[header.textLabel setTextColor:[UIColor blackColor]];
[header.textLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Thin" size:14.0f]];
[header.textLabel setFont:[UIFont ows_thinFontWithSize:14.0f]];
}
@ -212,14 +210,14 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ContactTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CONTACT_BROWSE_TABLE_CELL_IDENTIFIER];
ContactTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CONTACT_BROWSE_TABLE_CELL_IDENTIFIER];
if (!cell) {
cell = [[ContactTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CONTACT_BROWSE_TABLE_CELL_IDENTIFIER];
}
cell.shouldShowContactButtons = YES;
[cell configureWithContact:[self contactForIndexPath:indexPath]];
@ -317,6 +315,21 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
}
- (void)contactsDidRefresh{
if (_latestContacts.count == 0)
{
CGRect r = CGRectMake(0, 60, 300, 70);
_emptyViewLabel = [[UILabel alloc]initWithFrame:r];
_emptyViewLabel.text = @"None of your contacts are Signal users yet.";
_emptyViewLabel.textColor = [UIColor grayColor];
_emptyViewLabel.font = [UIFont ows_thinFontWithSize:14.0f];
_emptyViewLabel.textAlignment = NSTextAlignmentCenter;
self.tableView.tableFooterView = _emptyViewLabel;
} else {
self.tableView.tableFooterView = self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
[self.tableView reloadData];
}
[self.refreshControl endRefreshing];
}

View File

@ -208,7 +208,7 @@ static NSInteger connectingFlashCounter = 0;
}
-(void) handleIncomingDetails {
[_callState.futureShortAuthenticationString thenDo:^(NSString* sas) {
_authenicationStringLabel.textColor = [UIColor colorWithRed:15.f/255.f green:103.f/255.f blue:253.f/255.f alpha:1.0f];
_authenicationStringLabel.textColor = [UIColor colorWithRed:0.f/255.f green:12.f/255.f blue:255.f/255.f alpha:1.0f];
_authenicationStringLabel.hidden = NO;
_authenicationStringLabel.text = sas;
[self performCallInSessionAnimation];

View File

@ -81,7 +81,7 @@
_lastActionImageView.image = nil;
_snippetLabel.textColor = [UIColor blackColor];
_nameLabel.font = [UIFont boldSystemFontOfSize:15];
_timeLabel.textColor = [UIColor colorWithRed:0 green:91/255.f blue:1.0f alpha:1.0f];
_timeLabel.textColor = [UIColor colorWithRed:0 green:122.f/255.f blue:1.0f alpha:1.0f];
}
}

View File

@ -14,6 +14,7 @@
#import "JSQCallCollectionViewCell.h"
#import "JSQCall.h"
#import "UIUtil.h"
#import "DJWActionSheet.h"
#import <MobileCoreServices/UTCoreTypes.h>
#import <AVFoundation/AVFoundation.h>
@ -39,7 +40,7 @@ typedef enum : NSUInteger {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"lock.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showFingerprint)];
[self.collectionView.collectionViewLayout setMessageBubbleFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:16.0f]];
[self.collectionView.collectionViewLayout setMessageBubbleFont:[UIFont ows_lightFontWithSize:16.0f]];
self.collectionView.showsVerticalScrollIndicator = NO;
self.collectionView.showsHorizontalScrollIndicator = NO;

View File

@ -16,6 +16,7 @@
#import "DemoDataFactory.h"
#import "GroupModel.h"
#import "UIUtil.h"
#import "DJWActionSheet.h"
#import <MobileCoreServices/UTCoreTypes.h>
#import <AVFoundation/AVFoundation.h>
@ -246,10 +247,10 @@
UIFont *lastNameFont;
if (ABPersonGetSortOrdering() == kABPersonCompositeNameFormatFirstNameFirst) {
firstNameFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:cell.textLabel.font.pointSize];
firstNameFont = [UIFont ows_lightFontWithSize:cell.textLabel.font.pointSize];
lastNameFont = [UIFont systemFontOfSize:cell.textLabel.font.pointSize];
} else{
firstNameFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:cell.textLabel.font.pointSize];
firstNameFont = [UIFont ows_lightFontWithSize:cell.textLabel.font.pointSize];
lastNameFont = [UIFont systemFontOfSize:cell.textLabel.font.pointSize];
}
[fullNameAttributedString addAttribute:NSFontAttributeName value:firstNameFont range:NSMakeRange(0, contact.firstName.length)];

View File

@ -6,6 +6,7 @@
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "UIUtil.h"
#import "DemoDataFactory.h"
#import "InboxTableViewCell.h"
@ -34,6 +35,7 @@ static NSString *const kSegueIndentifier = @"showSegue";
NSUInteger numberOfCells;
}
@property (strong, nonatomic) UILabel * emptyViewLabel;
@property (strong, nonatomic) DemoDataModel *demoData;
@property (nonatomic, strong) YapDatabaseConnection *uiDatabaseConnection;
@property (nonatomic, strong) YapDatabaseViewMappings *threadMappings;
@ -60,6 +62,27 @@ static NSString *const kSegueIndentifier = @"showSegue";
object:nil];
[TSSocketManager becomeActive];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if ([self.threadMappings numberOfItemsInAllGroups]==0)
{
CGRect r = CGRectMake(0, 60, 300, 70);
_emptyViewLabel = [[UILabel alloc]initWithFrame:r];
_emptyViewLabel.text = @"You have no messages yet.";
_emptyViewLabel.textColor = [UIColor grayColor];
_emptyViewLabel.font = [UIFont ows_thinFontWithSize:14.0f];
_emptyViewLabel.textAlignment = NSTextAlignmentCenter;
self.tableView.tableHeaderView = _emptyViewLabel;
} else {
_emptyViewLabel = nil;
self.tableView.tableHeaderView = nil;
}
}
- (void)didReceiveMemoryWarning {

View File

@ -1,4 +1,5 @@
#import "ContactTableViewCell.h"
#import "UIUtil.h"
#define CONTACT_TABLE_CELL_BORDER_WIDTH 1.0f
@ -16,13 +17,7 @@
_contactPictureView.layer.masksToBounds = YES;
self.selectionStyle = UITableViewCellSelectionStyleGray;
if (!_shouldShowContactButtons)
{
_callButton.hidden = YES;
_callButton.enabled = NO;
_messageButton.hidden = YES;
_callButton.enabled = NO;
}
_shouldShowContactButtons = YES;
return self;
}
@ -31,8 +26,18 @@
return NSStringFromClass(self.class);
}
-(void)showContactButtons:(BOOL)enabled
{
_callButton.hidden = !enabled;
_callButton.enabled = enabled;
_messageButton.hidden = !enabled;
_callButton.enabled = enabled;
}
- (void)configureWithContact:(Contact *)contact {
[self showContactButtons:_shouldShowContactButtons];
_associatedContact = contact;
_nameLabel.attributedText = [self attributedStringForContact:contact];
@ -50,14 +55,16 @@
if (contact.isRedPhoneContact && _shouldShowContactButtons)
{
_callButton.imageView.image = [UIImage imageNamed:@"call_dark"];
_callButton.imageView.image = [[UIImage imageNamed:@"call_dark"]imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_callButton.tintColor = [UIColor colorWithRed:0.f/255.f green:122.f/255.f blue:255.f/255.f alpha:1.0f];
} else {
[_callButton addConstraint:[NSLayoutConstraint constraintWithItem:_callButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:1.0f constant:0]];
}
if (contact.isTextSecureContact && _shouldShowContactButtons)
{
_messageButton.imageView.image = [UIImage imageNamed:@"signal"];
_messageButton.imageView.image = [[UIImage imageNamed:@"signal"]imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_messageButton.tintColor = [UIColor colorWithRed:0.f/255.f green:122.f/255.f blue:255.f/255.f alpha:1.0f];
} else {
[_messageButton addConstraint:[NSLayoutConstraint constraintWithItem:_messageButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:1.0f constant:0]];
}
@ -75,10 +82,10 @@
UIFont *lastNameFont;
if (ABPersonGetSortOrdering() == kABPersonCompositeNameFormatFirstNameFirst) {
firstNameFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:_nameLabel.font.pointSize];
firstNameFont = [UIFont ows_thinFontWithSize:_nameLabel.font.pointSize];
lastNameFont = [UIFont systemFontOfSize:_nameLabel.font.pointSize];
} else{
firstNameFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:_nameLabel.font.pointSize];
firstNameFont = [UIFont ows_thinFontWithSize:_nameLabel.font.pointSize];
lastNameFont = [UIFont systemFontOfSize:_nameLabel.font.pointSize];
}
[fullNameAttributedString addAttribute:NSFontAttributeName value:firstNameFont range:NSMakeRange(0, contact.firstName.length)];

View File

@ -10,7 +10,7 @@
self.layer.cornerRadius = CGRectGetHeight(self.layer.frame)/2.0f;
self.layer.borderColor = [[UIUtil darkBackgroundColor] CGColor];
self.layer.borderColor = [[UIColor ows_darkBackgroundColor] CGColor];
}
- (void)setSelected:(BOOL)isSelected {