diff --git a/Podfile b/Podfile index e0252ffca..29acd671d 100644 --- a/Podfile +++ b/Podfile @@ -19,4 +19,3 @@ pod 'DJWActionSheet' pod 'SocketRocket', :git => 'https://github.com/FredericJacobs/SocketRocket.git', :commit => 'dd7e47fed78214785d7c032081da94008335fc35' pod 'JSQMessagesViewController', :git => 'https://github.com/WhisperSystems/JSQMessagesViewController', :commit => 'e5582fef8a6b3e35f8070361ef37237222da712b' -pod 'APDropDownNavToolbar', :git => 'https://github.com/corbett/APDropDownNavToolbar.git', :branch => 'master' diff --git a/Podfile.lock b/Podfile.lock index 66df2574b..34d5e31ee 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -21,7 +21,6 @@ PODS: - AFNetworking/UIKit (2.6.1): - AFNetworking/NSURLConnection - AFNetworking/NSURLSession - - APDropDownNavToolbar (1.1) - AxolotlKit (0.7): - 25519 (~> 2.0.1) - HKDFKit (~> 0.0.3) @@ -64,8 +63,6 @@ PODS: DEPENDENCIES: - AFNetworking (~> 2.6) - - APDropDownNavToolbar (from `https://github.com/corbett/APDropDownNavToolbar.git`, - branch `master`) - AxolotlKit - DJWActionSheet - FFCircularProgressView (~> 0.5) @@ -84,9 +81,6 @@ DEPENDENCIES: - YapDatabase/SQLCipher (~> 2.7.2) EXTERNAL SOURCES: - APDropDownNavToolbar: - :branch: master - :git: https://github.com/corbett/APDropDownNavToolbar.git JSQMessagesViewController: :commit: e5582fef8a6b3e35f8070361ef37237222da712b :git: https://github.com/WhisperSystems/JSQMessagesViewController @@ -95,9 +89,6 @@ EXTERNAL SOURCES: :git: https://github.com/FredericJacobs/SocketRocket.git CHECKOUT OPTIONS: - APDropDownNavToolbar: - :commit: 98a606b343c0ccc6cca1cd243b296325716f21e7 - :git: https://github.com/corbett/APDropDownNavToolbar.git JSQMessagesViewController: :commit: e5582fef8a6b3e35f8070361ef37237222da712b :git: https://github.com/WhisperSystems/JSQMessagesViewController @@ -108,7 +99,6 @@ CHECKOUT OPTIONS: SPEC CHECKSUMS: '25519': dc4bad7e2dbcbf1efa121068a705a44cd98c80fc AFNetworking: 8e4e60500beb8bec644cf575beee72990a76d399 - APDropDownNavToolbar: 5d0c3f363208543d20e86ddb4630927c28cdfd4b AxolotlKit: 8652fca51f4bc8225cbda791b0026c21e912b694 CocoaLumberjack: 17fe8581f84914d5d7e6360f7c70022b173c3ae0 DJWActionSheet: 2fe54b1298a7f0fe44462233752c76a530e0cd80 diff --git a/Pods b/Pods index 89f829c06..0f4532971 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit 89f829c06ce4605393867fa5660ccdbb3ce7cf53 +Subproject commit 0f4532971e696c73005950fa7d9154297fdfa746 diff --git a/Signal/src/Storyboard/Storyboard.storyboard b/Signal/src/Storyboard/Storyboard.storyboard index 880ce2583..5d137d0b0 100755 --- a/Signal/src/Storyboard/Storyboard.storyboard +++ b/Signal/src/Storyboard/Storyboard.storyboard @@ -1451,10 +1451,6 @@ A0 09 9A FF A8 8A 09 99 - - - - diff --git a/Signal/src/contact/ContactsManager.h b/Signal/src/contact/ContactsManager.h index 40f4ef63a..44c878bf8 100644 --- a/Signal/src/contact/ContactsManager.h +++ b/Signal/src/contact/ContactsManager.h @@ -2,6 +2,7 @@ #import "CollapsingFutures.h" #import "Contact.h" #import "ObservableValue.h" +#import /** * @@ -26,6 +27,8 @@ typedef void(^ABReloadRequestCompletionBlock)(NSArray *contacts); @private NSDictionary *latestWhisperUsersById; } +@property CNContactStore *contactStore; + -(ObservableValue *) getObservableContacts; -(ObservableValue *) getObservableRedPhoneUsers; diff --git a/Signal/src/contact/ContactsManager.m b/Signal/src/contact/ContactsManager.m index 28a2e9961..21cd039ed 100644 --- a/Signal/src/contact/ContactsManager.m +++ b/Signal/src/contact/ContactsManager.m @@ -29,7 +29,18 @@ typedef BOOL (^ContactSearchBlock)(id, NSUInteger, BOOL*); } -(void) doAfterEnvironmentInitSetup { + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(_iOS_9)) { + self.contactStore = [[CNContactStore alloc] init]; + [self.contactStore requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) { + if (!granted) { + // We're still using the old addressbook API. + // User warned if permission not granted in that setup. + } + }]; + } + [self setupAddressBook]; + [observableContactsController watchLatestValueOnArbitraryThread:^(NSArray *latestContacts) { @synchronized(self) { [self setupLatestContacts:latestContacts]; diff --git a/Signal/src/view controllers/APNavigationController.h b/Signal/src/view controllers/APNavigationController.h new file mode 100644 index 000000000..5c03c41b4 --- /dev/null +++ b/Signal/src/view controllers/APNavigationController.h @@ -0,0 +1,24 @@ +// +// APNavigationController.h +// DropDownToolBar +// +// Created by Ankur Patel on 2/24/14. +// Copyright (c) 2014 Encore Dev Labs LLC. All rights reserved. +// + +#import + +@interface APNavigationController : UINavigationController + +@property (nonatomic, strong) UIToolbar *dropDownToolbar; // Reference to dynamically change items based on which bar button item is clicked +@property (nonatomic, strong) NSString *activeNavigationBarTitle; // Navigation bar title when the toolbar is shown +@property (nonatomic, strong) NSString *activeBarButtonTitle; // UIBarButton title when toolbar is shown +@property (nonatomic, assign) BOOL isDropDownVisible; + +- (void)setActiveBarButtonTitle:(NSString*)title; +- (void)setActiveNavigationBarTitle:(NSString*)title; +- (void)toggleDropDown:(id)sender; +- (void)hideDropDown:(id)sender; +- (void)showDropDown:(id)sender; + +@end diff --git a/Signal/src/view controllers/APNavigationController.m b/Signal/src/view controllers/APNavigationController.m new file mode 100644 index 000000000..f7ca2bb2d --- /dev/null +++ b/Signal/src/view controllers/APNavigationController.m @@ -0,0 +1,108 @@ +// +// APNavigationController.m +// DropDownToolBar +// +// Created by Ankur Patel on 2/24/14. +// Copyright (c) 2014 Encore Dev Labs LLC. All rights reserved. +// + +#import "APNavigationController.h" + +@interface APNavigationController () + +@property (nonatomic, copy) NSString *originalNavigationBarTitle; +@property (nonatomic, copy) NSString *originalBarButtonTitle; + +@end + +@implementation APNavigationController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. + self.dropDownToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)]; + self.dropDownToolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth; + self.dropDownToolbar.tintColor = self.navigationBar.tintColor; + [self.navigationBar.superview insertSubview:self.dropDownToolbar belowSubview:self.navigationBar]; + self.originalNavigationBarTitle = self.navigationBar.topItem.title; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)toggleDropDown:(id)sender +{ + if (self.isDropDownVisible) { + [self hideDropDown:sender]; + } else { + [self showDropDown:sender]; + } +} + +- (void)hideDropDown:(id)sender +{ + if(self.isDropDownVisible){ + __weak APNavigationController *weakSelf = self; + CGRect frame = self.dropDownToolbar.frame; + frame.origin.y = CGRectGetMaxY(self.navigationBar.frame); + self.dropDownToolbar.frame = frame; + [UIView animateWithDuration:0.25 animations:^{ + CGRect frame = self.dropDownToolbar.frame; + frame.origin.y = 0.; + weakSelf.dropDownToolbar.frame = frame; + } completion:^(BOOL finished) { + weakSelf.isDropDownVisible = !weakSelf.isDropDownVisible; + weakSelf.dropDownToolbar.hidden = YES; + }]; + if (self.activeNavigationBarTitle) { + self.navigationBar.topItem.title = self.originalNavigationBarTitle; + } + if(sender && [sender isKindOfClass:[UIBarButtonItem class]]){ + [(UIBarButtonItem *)sender setTitle:self.originalBarButtonTitle]; + } + + } +} + +- (void)showDropDown:(id)sender +{ + if(!self.isDropDownVisible){ + __weak APNavigationController *weakSelf = self; + CGRect frame = self.dropDownToolbar.frame; + frame.origin.y = 0.f; + self.dropDownToolbar.hidden = NO; + self.dropDownToolbar.frame = frame; + [UIView animateWithDuration:0.25 animations:^{ + CGRect frame = self.dropDownToolbar.frame; + frame.origin.y = CGRectGetMaxY(self.navigationBar.frame); + weakSelf.dropDownToolbar.frame = frame; + } completion:^(BOOL finished) { + weakSelf.isDropDownVisible = !weakSelf.isDropDownVisible; + }]; + if (self.activeNavigationBarTitle) { + self.navigationBar.topItem.title = self.activeNavigationBarTitle; + } + if(sender && [sender isKindOfClass:[UIBarButtonItem class]]){ + self.originalBarButtonTitle = [(UIBarButtonItem *)sender title]; + if (self.activeBarButtonTitle) { + [(UIBarButtonItem *)sender setTitle:self.activeBarButtonTitle]; + } + } + + } +} + +@end