diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 0f080b378..39482857e 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -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 = ""; }; FCF72A141A02D2BB006BC849 /* ContactDetailCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactDetailCell.h; sourceTree = ""; }; FCF72A151A02D2BB006BC849 /* ContactDetailCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactDetailCell.m; sourceTree = ""; }; + FCFA64B21A24F3880007FB87 /* UIColor+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+OWS.h"; sourceTree = ""; }; + FCFA64B31A24F3880007FB87 /* UIColor+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+OWS.m"; sourceTree = ""; }; + FCFA64B51A24F6730007FB87 /* UIFont+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIFont+OWS.h"; path = "util/UIFont+OWS.h"; sourceTree = ""; }; + FCFA64B61A24F6730007FB87 /* UIFont+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIFont+OWS.m"; path = "util/UIFont+OWS.m"; sourceTree = ""; }; FCFD256D1A151BCB00F4C644 /* NewGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewGroupViewController.h; sourceTree = ""; }; FCFD256E1A151BCB00F4C644 /* NewGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewGroupViewController.m; sourceTree = ""; }; FCFD257D1A154B2C00F4C644 /* RegistrationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegistrationViewController.h; sourceTree = ""; }; @@ -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 = ""; }; + 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 = ""; + }; 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 */, diff --git a/Signal/src/Storyboard/Storyboard.storyboard b/Signal/src/Storyboard/Storyboard.storyboard index 0af0d1c5c..478e722ae 100755 --- a/Signal/src/Storyboard/Storyboard.storyboard +++ b/Signal/src/Storyboard/Storyboard.storyboard @@ -1818,6 +1818,11 @@ Lorem ipsum : Quick explanation of Fingerprints + + + + + @@ -2020,10 +2025,14 @@ Lorem ipsum : Quick explanation of Fingerprints - + + + - + + + @@ -2056,6 +2065,9 @@ Lorem ipsum : Quick explanation of Fingerprints + + + diff --git a/Signal/src/UIColor+OWS.h b/Signal/src/UIColor+OWS.h new file mode 100644 index 000000000..2262f27b4 --- /dev/null +++ b/Signal/src/UIColor+OWS.h @@ -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 + +@interface UIColor (UIColor_OWS) + ++(UIColor*) ows_blueColor; ++(UIColor*) ows_darkBackgroundColor; ++(UIColor*) ows_darkGrayColor; + +@end diff --git a/Signal/src/UIColor+OWS.m b/Signal/src/UIColor+OWS.m new file mode 100644 index 000000000..13282ca1d --- /dev/null +++ b/Signal/src/UIColor+OWS.m @@ -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 diff --git a/Signal/src/util/UIFont+OWS.h b/Signal/src/util/UIFont+OWS.h new file mode 100644 index 000000000..1c42ffcfb --- /dev/null +++ b/Signal/src/util/UIFont+OWS.h @@ -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 + +@interface UIFont (OWS) + ++ (UIFont*) ows_thinFontWithSize:(CGFloat)size; + ++ (UIFont*) ows_lightFontWithSize:(CGFloat)size; + ++ (UIFont*) ows_regularFontWithSize:(CGFloat)size; + ++ (UIFont*) ows_boldFontWithSize:(CGFloat)size; + +@end diff --git a/Signal/src/util/UIFont+OWS.m b/Signal/src/util/UIFont+OWS.m new file mode 100644 index 000000000..f7d12027e --- /dev/null +++ b/Signal/src/util/UIFont+OWS.m @@ -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 diff --git a/Signal/src/util/UIUtil.h b/Signal/src/util/UIUtil.h index 82938e156..d9e2d2106 100644 --- a/Signal/src/util/UIUtil.h +++ b/Signal/src/util/UIUtil.h @@ -1,25 +1,16 @@ #import +#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; diff --git a/Signal/src/util/UIUtil.m b/Signal/src/util/UIUtil.m index 04b6deed9..aadff305c 100644 --- a/Signal/src/util/UIUtil.m +++ b/Signal/src/util/UIUtil.m @@ -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]; diff --git a/Signal/src/view controllers/ContactDetailTableViewController.m b/Signal/src/view controllers/ContactDetailTableViewController.m index a4c88713f..7fb9f0550 100644 --- a/Signal/src/view controllers/ContactDetailTableViewController.m +++ b/Signal/src/view controllers/ContactDetailTableViewController.m @@ -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 diff --git a/Signal/src/view controllers/ContactsTableViewController.h b/Signal/src/view controllers/ContactsTableViewController.h index 5d7b409d6..ed9192c45 100644 --- a/Signal/src/view controllers/ContactsTableViewController.h +++ b/Signal/src/view controllers/ContactsTableViewController.h @@ -7,6 +7,7 @@ // #import +#import "UIUtil.h" @interface ContactsTableViewController : UITableViewController diff --git a/Signal/src/view controllers/ContactsTableViewController.m b/Signal/src/view controllers/ContactsTableViewController.m index 0100cbeff..bce6c608e 100644 --- a/Signal/src/view controllers/ContactsTableViewController.m +++ b/Signal/src/view controllers/ContactsTableViewController.m @@ -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]; } diff --git a/Signal/src/view controllers/InCallViewController.m b/Signal/src/view controllers/InCallViewController.m index 23a8ccb8d..d73276763 100644 --- a/Signal/src/view controllers/InCallViewController.m +++ b/Signal/src/view controllers/InCallViewController.m @@ -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]; diff --git a/Signal/src/view controllers/InboxTableViewCell.m b/Signal/src/view controllers/InboxTableViewCell.m index abbeae48a..3d6da6a9d 100644 --- a/Signal/src/view controllers/InboxTableViewCell.m +++ b/Signal/src/view controllers/InboxTableViewCell.m @@ -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]; } } diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index 8405e32f0..45ba1f7b9 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -14,6 +14,7 @@ #import "JSQCallCollectionViewCell.h" #import "JSQCall.h" +#import "UIUtil.h" #import "DJWActionSheet.h" #import #import @@ -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; diff --git a/Signal/src/view controllers/NewGroupViewController.m b/Signal/src/view controllers/NewGroupViewController.m index e28f88364..8a02e8a20 100644 --- a/Signal/src/view controllers/NewGroupViewController.m +++ b/Signal/src/view controllers/NewGroupViewController.m @@ -16,6 +16,7 @@ #import "DemoDataFactory.h" #import "GroupModel.h" +#import "UIUtil.h" #import "DJWActionSheet.h" #import #import @@ -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)]; diff --git a/Signal/src/view controllers/UITests/SignalsViewController.m b/Signal/src/view controllers/UITests/SignalsViewController.m index 2d106fb23..d80ca3a6c 100644 --- a/Signal/src/view controllers/UITests/SignalsViewController.m +++ b/Signal/src/view controllers/UITests/SignalsViewController.m @@ -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 { diff --git a/Signal/src/views/ContactTableViewCell.m b/Signal/src/views/ContactTableViewCell.m index 8762aa911..a68906be5 100644 --- a/Signal/src/views/ContactTableViewCell.m +++ b/Signal/src/views/ContactTableViewCell.m @@ -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)]; diff --git a/Signal/src/views/DialerButtonView.m b/Signal/src/views/DialerButtonView.m index 51ddac5b8..d57d6b6b1 100644 --- a/Signal/src/views/DialerButtonView.m +++ b/Signal/src/views/DialerButtonView.m @@ -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 {