|
|
@ -6,10 +6,11 @@
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#import "MessageComposeTableViewController.h"
|
|
|
|
#import "Environment.h"
|
|
|
|
#import "Environment.h"
|
|
|
|
#import "Contact.h"
|
|
|
|
#import "Contact.h"
|
|
|
|
#import "PhoneNumberUtil.h"
|
|
|
|
#import "PhoneNumberUtil.h"
|
|
|
|
#import "MessageComposeTableViewController.h"
|
|
|
|
#import "PreferencesUtil.h"
|
|
|
|
#import "MessagesViewController.h"
|
|
|
|
#import "MessagesViewController.h"
|
|
|
|
#import "SignalsViewController.h"
|
|
|
|
#import "SignalsViewController.h"
|
|
|
|
#import "NotificationManifest.h"
|
|
|
|
#import "NotificationManifest.h"
|
|
|
@ -26,7 +27,6 @@
|
|
|
|
{
|
|
|
|
{
|
|
|
|
UIButton* sendTextButton;
|
|
|
|
UIButton* sendTextButton;
|
|
|
|
NSString* currentSearchTerm;
|
|
|
|
NSString* currentSearchTerm;
|
|
|
|
|
|
|
|
|
|
|
|
NSArray* contacts;
|
|
|
|
NSArray* contacts;
|
|
|
|
NSArray* searchResults;
|
|
|
|
NSArray* searchResults;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -34,6 +34,9 @@
|
|
|
|
@property (nonatomic, strong) UISearchController *searchController;
|
|
|
|
@property (nonatomic, strong) UISearchController *searchController;
|
|
|
|
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;
|
|
|
|
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;
|
|
|
|
@property (nonatomic, strong) UIBarButtonItem *addGroup;
|
|
|
|
@property (nonatomic, strong) UIBarButtonItem *addGroup;
|
|
|
|
|
|
|
|
@property (nonatomic, strong) UIView *loadingBackgroundView;
|
|
|
|
|
|
|
|
@property (nonatomic, strong) UIView *emptyBackgroundView;
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation MessageComposeTableViewController
|
|
|
|
@implementation MessageComposeTableViewController
|
|
|
@ -47,25 +50,142 @@
|
|
|
|
[self initializeSearch];
|
|
|
|
[self initializeSearch];
|
|
|
|
|
|
|
|
|
|
|
|
self.searchController.searchBar.hidden = NO;
|
|
|
|
self.searchController.searchBar.hidden = NO;
|
|
|
|
|
|
|
|
self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
|
|
|
|
|
|
|
|
[self createLoadingAndBackgroundViews];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
|
|
|
|
|
[super didReceiveMemoryWarning];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void) viewDidAppear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL isRefreshing = [Environment getCurrent].phoneDirectoryManager.isRefreshing;
|
|
|
|
|
|
|
|
if([contacts count]==0) {
|
|
|
|
|
|
|
|
if([Environment getCurrent].phoneDirectoryManager.isRefreshing) {
|
|
|
|
|
|
|
|
[self showLoadingBackgroundView:YES];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
[self showEmptyBackgroundView:YES];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(isRefreshing) {
|
|
|
|
|
|
|
|
self.tableView.contentOffset = CGPointMake(0, -self.refreshControl.frame.size.height);
|
|
|
|
|
|
|
|
[self.refreshControl beginRefreshing];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(UILabel*) createLabelWithFirstLine:(NSString*) firstLine andSecondLine:(NSString*)secondLine {
|
|
|
|
|
|
|
|
UILabel *label = [[UILabel alloc] init];
|
|
|
|
|
|
|
|
label.textColor = [UIColor grayColor];
|
|
|
|
|
|
|
|
label.font = [UIFont ows_regularFontWithSize:18.f];
|
|
|
|
|
|
|
|
label.textAlignment = NSTextAlignmentCenter;
|
|
|
|
|
|
|
|
label.numberOfLines = 4;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableAttributedString *fullLabelString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n%@",firstLine,secondLine]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[fullLabelString addAttribute:NSFontAttributeName value:[UIFont ows_boldFontWithSize:15.f] range:NSMakeRange(0,firstLine.length)];
|
|
|
|
|
|
|
|
[fullLabelString addAttribute:NSFontAttributeName value:[UIFont ows_regularFontWithSize:14.f] range:NSMakeRange(firstLine.length + 1, secondLine.length)];
|
|
|
|
|
|
|
|
[fullLabelString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0,firstLine.length)];
|
|
|
|
|
|
|
|
[fullLabelString addAttribute:NSForegroundColorAttributeName value:[UIColor ows_darkGrayColor] range:NSMakeRange(firstLine.length + 1, secondLine.length)];
|
|
|
|
|
|
|
|
label.attributedText = fullLabelString;
|
|
|
|
|
|
|
|
//250, 66, 140
|
|
|
|
|
|
|
|
[label setFrame:CGRectMake(self.tableView.frame.size.width/2.0f-250/2.0f, 100+140, 250, 66)];
|
|
|
|
|
|
|
|
return label;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UIView* loadingView = [[UIView alloc] initWithFrame:self.tableView.frame];
|
|
|
|
-(UIButton*) createButtonWithTitle:(NSString*)title {
|
|
|
|
|
|
|
|
NSDictionary* buttonTextAttributes = @{NSFontAttributeName:[UIFont ows_regularFontWithSize:15.0f],
|
|
|
|
|
|
|
|
NSForegroundColorAttributeName:[UIColor ows_materialBlueColor]};
|
|
|
|
|
|
|
|
UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(0,0,65,24)];
|
|
|
|
|
|
|
|
NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc] initWithString:title];
|
|
|
|
|
|
|
|
[attributedTitle setAttributes:buttonTextAttributes range:NSMakeRange(0, [attributedTitle length])];
|
|
|
|
|
|
|
|
[button setAttributedTitle:attributedTitle forState:UIControlStateNormal];
|
|
|
|
|
|
|
|
[button.titleLabel setTextAlignment:NSTextAlignmentCenter];
|
|
|
|
|
|
|
|
return button;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void) createLoadingAndBackgroundViews {
|
|
|
|
|
|
|
|
// This will be further tweaked per design recs. It must currently be hardcoded (or we can place in separate .xib I suppose) as the controller must be a TableViewController to have access to the native pull to refresh capabilities. That means we can't do a UIView in the storyboard
|
|
|
|
|
|
|
|
_loadingBackgroundView = [[UIView alloc] initWithFrame:self.tableView.frame];
|
|
|
|
UIImageView *loadingImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"uiEmpty"]];
|
|
|
|
UIImageView *loadingImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"uiEmpty"]];
|
|
|
|
[loadingImageView setBackgroundColor:[UIColor whiteColor]];
|
|
|
|
[loadingImageView setBackgroundColor:[UIColor whiteColor]];
|
|
|
|
[loadingImageView setContentMode:UIViewContentModeCenter];
|
|
|
|
[loadingImageView setContentMode:UIViewContentModeCenter];
|
|
|
|
[loadingImageView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
|
|
|
|
[loadingImageView setFrame:CGRectMake(self.tableView.frame.size.width/2.0f-115.0f/2.0f, 100, 115, 110)];
|
|
|
|
[loadingImageView setFrame:self.tableView.frame];
|
|
|
|
loadingImageView.contentMode = UIViewContentModeCenter;
|
|
|
|
[loadingView addSubview:loadingImageView];
|
|
|
|
loadingImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
|
|
|
|
|
|
|
|
self.tableView.backgroundView = loadingView;
|
|
|
|
UIActivityIndicatorView *loadingProgressView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
|
|
|
|
self.tableView.backgroundView.opaque = YES;
|
|
|
|
[loadingProgressView setFrame:CGRectMake(self.tableView.frame.size.width/2.0f-loadingProgressView.frame.size.width/2.0f, 100+110/2.0f-loadingProgressView.frame.size.height/2.0f, loadingProgressView.frame.size.width, loadingProgressView.frame.size.height)];
|
|
|
|
|
|
|
|
[loadingProgressView setHidesWhenStopped:NO];
|
|
|
|
|
|
|
|
[loadingProgressView startAnimating];
|
|
|
|
|
|
|
|
UILabel *loadingLabel = [self createLabelWithFirstLine:@"Loading your contacts." andSecondLine:@"Sit tight."];
|
|
|
|
|
|
|
|
[_loadingBackgroundView addSubview:loadingImageView];
|
|
|
|
|
|
|
|
[_loadingBackgroundView addSubview:loadingProgressView];
|
|
|
|
|
|
|
|
[_loadingBackgroundView addSubview:loadingLabel];
|
|
|
|
|
|
|
|
|
|
|
|
self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
|
|
|
|
_emptyBackgroundView = [[UIView alloc] initWithFrame:self.tableView.frame];
|
|
|
|
|
|
|
|
UIImageView *emptyImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"uiEmptyContact"]];
|
|
|
|
|
|
|
|
[emptyImageView setBackgroundColor:[UIColor whiteColor]];
|
|
|
|
|
|
|
|
[emptyImageView setContentMode:UIViewContentModeCenter];
|
|
|
|
|
|
|
|
[emptyImageView setFrame:CGRectMake(self.tableView.frame.size.width/2.0f-115.0f/2.0f, 100, 115, 110)];
|
|
|
|
|
|
|
|
emptyImageView.contentMode = UIViewContentModeCenter;
|
|
|
|
|
|
|
|
emptyImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
|
|
|
|
UILabel *emptyLabel = [self createLabelWithFirstLine:@"None of your contacts have Signal!" andSecondLine:@"Why don't you invite someone"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIButton *inviteContactButton = [self createButtonWithTitle:@"Invite contact"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[inviteContactButton addTarget:self action:@selector(sendText) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
|
|
[inviteContactButton setFrame:CGRectMake(self.tableView.frame.size.width/2.0f-inviteContactButton.frame.size.width/1.5f, self.tableView.frame.size.height - 200, 100, 66)];
|
|
|
|
|
|
|
|
[inviteContactButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[_emptyBackgroundView addSubview:emptyImageView];
|
|
|
|
|
|
|
|
[_emptyBackgroundView addSubview:emptyLabel];
|
|
|
|
|
|
|
|
[_emptyBackgroundView addSubview:inviteContactButton];
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
|
|
|
|
|
[super didReceiveMemoryWarning];
|
|
|
|
-(void) showLoadingBackgroundView:(BOOL)show {
|
|
|
|
|
|
|
|
if(show) {
|
|
|
|
|
|
|
|
_addGroup = self.navigationItem.rightBarButtonItem!=nil ? _addGroup : self.navigationItem.rightBarButtonItem;
|
|
|
|
|
|
|
|
self.navigationItem.rightBarButtonItem = nil;
|
|
|
|
|
|
|
|
self.searchController.searchBar.hidden = YES;
|
|
|
|
|
|
|
|
self.tableView.backgroundView = _loadingBackgroundView;
|
|
|
|
|
|
|
|
self.refreshControl = nil;
|
|
|
|
|
|
|
|
self.tableView.backgroundView.opaque = YES;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
[self initializeRefreshControl];
|
|
|
|
|
|
|
|
self.navigationItem.rightBarButtonItem = self.navigationItem.rightBarButtonItem!=nil ? self.navigationItem.rightBarButtonItem : _addGroup;
|
|
|
|
|
|
|
|
self.searchController.searchBar.hidden = NO;
|
|
|
|
|
|
|
|
self.tableView.backgroundView = nil;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void) showEmptyBackgroundView:(BOOL)show {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(show) {
|
|
|
|
|
|
|
|
self.refreshControl = nil;
|
|
|
|
|
|
|
|
_addGroup = self.navigationItem.rightBarButtonItem!=nil ? _addGroup : self.navigationItem.rightBarButtonItem;
|
|
|
|
|
|
|
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"btnRefresh--white"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(refreshContacts)];
|
|
|
|
|
|
|
|
self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(8,8,8,8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.searchController.searchBar.hidden = YES;
|
|
|
|
|
|
|
|
self.tableView.backgroundView = _emptyBackgroundView;
|
|
|
|
|
|
|
|
self.tableView.backgroundView.opaque = YES;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
[self initializeRefreshControl];
|
|
|
|
|
|
|
|
self.refreshControl.enabled = YES;
|
|
|
|
|
|
|
|
self.navigationItem.rightBarButtonItem = self.navigationItem.rightBarButtonItem!=nil ? self.navigationItem.rightBarButtonItem : _addGroup;
|
|
|
|
|
|
|
|
self.searchController.searchBar.hidden = NO;
|
|
|
|
|
|
|
|
self.tableView.backgroundView = nil;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Initializers
|
|
|
|
#pragma mark - Initializers
|
|
|
@ -147,8 +267,9 @@
|
|
|
|
// search by contact name or number
|
|
|
|
// search by contact name or number
|
|
|
|
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"(fullName contains[c] %@) OR (allPhoneNumbers contains[c] %@)", searchText, searchText];
|
|
|
|
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"(fullName contains[c] %@) OR (allPhoneNumbers contains[c] %@)", searchText, searchText];
|
|
|
|
searchResults = [contacts filteredArrayUsingPredicate:resultPredicate];
|
|
|
|
searchResults = [contacts filteredArrayUsingPredicate:resultPredicate];
|
|
|
|
if (!searchResults.count && _searchController.searchBar.text.length == 0) searchResults = contacts;
|
|
|
|
if (!searchResults.count && _searchController.searchBar.text.length == 0) {
|
|
|
|
|
|
|
|
searchResults = contacts;
|
|
|
|
|
|
|
|
}
|
|
|
|
NSString *formattedNumber = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:searchText].toE164;
|
|
|
|
NSString *formattedNumber = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:searchText].toE164;
|
|
|
|
|
|
|
|
|
|
|
|
// text to a non-signal number if we have no results and a valid phone #
|
|
|
|
// text to a non-signal number if we have no results and a valid phone #
|
|
|
@ -168,9 +289,12 @@
|
|
|
|
#pragma mark - Send Normal Text to Unknown Contact
|
|
|
|
#pragma mark - Send Normal Text to Unknown Contact
|
|
|
|
|
|
|
|
|
|
|
|
- (void)sendText {
|
|
|
|
- (void)sendText {
|
|
|
|
NSString *confirmMessage = @"Would you like to invite the following number to Signal: ";
|
|
|
|
NSString *confirmMessage = @"Invite a friend via insecure SMS?";
|
|
|
|
confirmMessage = [confirmMessage stringByAppendingString:currentSearchTerm];
|
|
|
|
if([currentSearchTerm length]>0) {
|
|
|
|
confirmMessage = [confirmMessage stringByAppendingString:@"?"];
|
|
|
|
confirmMessage = @"Would you like to invite the following number to Signal: ";
|
|
|
|
|
|
|
|
confirmMessage = [confirmMessage stringByAppendingString:currentSearchTerm];
|
|
|
|
|
|
|
|
confirmMessage = [confirmMessage stringByAppendingString:@"?"];
|
|
|
|
|
|
|
|
}
|
|
|
|
UIAlertController *alertController = [UIAlertController
|
|
|
|
UIAlertController *alertController = [UIAlertController
|
|
|
|
alertControllerWithTitle:@"Confirm"
|
|
|
|
alertControllerWithTitle:@"Confirm"
|
|
|
|
message:confirmMessage
|
|
|
|
message:confirmMessage
|
|
|
@ -195,13 +319,12 @@
|
|
|
|
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
|
|
|
|
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
|
|
|
|
picker.messageComposeDelegate = self;
|
|
|
|
picker.messageComposeDelegate = self;
|
|
|
|
|
|
|
|
|
|
|
|
picker.recipients = [NSArray arrayWithObject:currentSearchTerm];
|
|
|
|
picker.recipients = [currentSearchTerm length]> 0 ? [NSArray arrayWithObject:currentSearchTerm] : nil;
|
|
|
|
picker.body = @"I'm inviting you to install Signal! Here is the link: https://itunes.apple.com/us/app/signal-private-messenger/id874139669?mt=8";
|
|
|
|
picker.body = @"I'm inviting you to install Signal! Here is the link: https://itunes.apple.com/us/app/signal-private-messenger/id874139669?mt=8";
|
|
|
|
[self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]];
|
|
|
|
[self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// TODO: better backup for iPods (just don't support on)
|
|
|
|
// TODO: better backup for iPods (just don't support on)
|
|
|
|
UIAlertView *notPermitted=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Your device doesn't support this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
|
|
|
|
UIAlertView *notPermitted=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Your device doesn't support this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
|
|
|
|
|
|
|
|
|
|
|
|
[notPermitted show];
|
|
|
|
[notPermitted show];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
}];
|
|
|
@ -210,7 +333,7 @@
|
|
|
|
[alertController addAction:okAction];
|
|
|
|
[alertController addAction:okAction];
|
|
|
|
sendTextButton.hidden = YES;
|
|
|
|
sendTextButton.hidden = YES;
|
|
|
|
self.searchController.searchBar.text = @"";
|
|
|
|
self.searchController.searchBar.text = @"";
|
|
|
|
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
|
|
|
[self presentViewController:alertController animated:YES completion:[UIUtil modalCompletionBlock]];
|
|
|
|
[self presentViewController:alertController animated:YES completion:[UIUtil modalCompletionBlock]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -249,18 +372,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
|
if([contacts count] == 0) {
|
|
|
|
|
|
|
|
self.tableView.backgroundView.hidden = NO;
|
|
|
|
|
|
|
|
self.searchController.searchBar.hidden = YES;
|
|
|
|
|
|
|
|
_addGroup = self.navigationItem.rightBarButtonItem!=nil ? _addGroup : self.navigationItem.rightBarButtonItem;
|
|
|
|
|
|
|
|
self.navigationItem.rightBarButtonItem = nil;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
self.tableView.backgroundView.hidden = YES;
|
|
|
|
|
|
|
|
self.searchController.searchBar.hidden = NO;
|
|
|
|
|
|
|
|
self.navigationItem.rightBarButtonItem = self.navigationItem.rightBarButtonItem!=nil ? self.navigationItem.rightBarButtonItem : _addGroup;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (self.searchController.active) {
|
|
|
|
if (self.searchController.active) {
|
|
|
|
return (NSInteger)[searchResults count];
|
|
|
|
return (NSInteger)[searchResults count];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -331,19 +443,34 @@
|
|
|
|
- (void)contactRefreshFailed {
|
|
|
|
- (void)contactRefreshFailed {
|
|
|
|
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:TIMEOUT message:TIMEOUT_CONTACTS_DETAIL delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil];
|
|
|
|
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:TIMEOUT message:TIMEOUT_CONTACTS_DETAIL delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil];
|
|
|
|
[alert show];
|
|
|
|
[alert show];
|
|
|
|
[self.refreshControl endRefreshing];
|
|
|
|
[self updateAfterRefreshTry];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)contactsDidRefresh {
|
|
|
|
- (void)contactsDidRefresh {
|
|
|
|
[self updateSearchResultsForSearchController:self.searchController];
|
|
|
|
[self updateSearchResultsForSearchController:self.searchController];
|
|
|
|
[self.tableView reloadData];
|
|
|
|
[self.tableView reloadData];
|
|
|
|
|
|
|
|
[self updateAfterRefreshTry];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) updateAfterRefreshTry {
|
|
|
|
[self.refreshControl endRefreshing];
|
|
|
|
[self.refreshControl endRefreshing];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self showLoadingBackgroundView:NO];
|
|
|
|
|
|
|
|
if([contacts count]==0) {
|
|
|
|
|
|
|
|
[self showEmptyBackgroundView:YES];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
[self showEmptyBackgroundView:NO];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)refreshContacts {
|
|
|
|
- (void)refreshContacts {
|
|
|
|
Environment *env = [Environment getCurrent];
|
|
|
|
Environment *env = [Environment getCurrent];
|
|
|
|
PhoneNumberDirectoryFilterManager *manager = [env phoneDirectoryManager];
|
|
|
|
PhoneNumberDirectoryFilterManager *manager = [env phoneDirectoryManager];
|
|
|
|
[manager forceUpdate];
|
|
|
|
[manager forceUpdate];
|
|
|
|
|
|
|
|
if([contacts count]==0) {
|
|
|
|
|
|
|
|
[self showLoadingBackgroundView:YES];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Navigation
|
|
|
|
#pragma mark - Navigation
|
|
|
|