|
|
@ -1,6 +1,6 @@
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// MessageComposeTableViewController.m
|
|
|
|
// MessageComposeTableViewController.m
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Created by Dylan Bourgeois on 02/11/14.
|
|
|
|
// Created by Dylan Bourgeois on 02/11/14.
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -43,12 +43,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
[super viewDidLoad];
|
|
|
|
[self.navigationController.navigationBar setTranslucent:NO];
|
|
|
|
[self.navigationController.navigationBar setTranslucent:NO];
|
|
|
|
|
|
|
|
|
|
|
|
contacts = [[Environment getCurrent] contactsManager].signalContacts;
|
|
|
|
contacts = [[Environment getCurrent] contactsManager].signalContacts;
|
|
|
|
searchResults = contacts;
|
|
|
|
searchResults = contacts;
|
|
|
|
[self initializeSearch];
|
|
|
|
[self initializeSearch];
|
|
|
|
|
|
|
|
|
|
|
|
self.searchController.searchBar.hidden = NO;
|
|
|
|
self.searchController.searchBar.hidden = NO;
|
|
|
|
self.searchController.searchBar.backgroundColor = [UIColor whiteColor];
|
|
|
|
self.searchController.searchBar.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
|
|
|
@ -94,7 +94,7 @@
|
|
|
|
[fullLabelString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0,firstLine.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)];
|
|
|
|
[fullLabelString addAttribute:NSForegroundColorAttributeName value:[UIColor ows_darkGrayColor] range:NSMakeRange(firstLine.length + 1, secondLine.length)];
|
|
|
|
label.attributedText = fullLabelString;
|
|
|
|
label.attributedText = fullLabelString;
|
|
|
|
//250, 66, 140
|
|
|
|
//250, 66, 140
|
|
|
|
[label setFrame:CGRectMake([self marginSize], 100+140, [self contentWidth], 66)];
|
|
|
|
[label setFrame:CGRectMake([self marginSize], 100+140, [self contentWidth], 66)];
|
|
|
|
return label;
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -137,17 +137,17 @@
|
|
|
|
emptyImageView.contentMode = UIViewContentModeCenter;
|
|
|
|
emptyImageView.contentMode = UIViewContentModeCenter;
|
|
|
|
emptyImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
emptyImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
UILabel *emptyLabel = [self createLabelWithFirstLine:NSLocalizedString(@"EMPTY_CONTACTS_LABEL_LINE1", @"") andSecondLine:NSLocalizedString(@"EMPTY_CONTACTS_LABEL_LINE2" , @"")];
|
|
|
|
UILabel *emptyLabel = [self createLabelWithFirstLine:NSLocalizedString(@"EMPTY_CONTACTS_LABEL_LINE1", @"") andSecondLine:NSLocalizedString(@"EMPTY_CONTACTS_LABEL_LINE2" , @"")];
|
|
|
|
|
|
|
|
|
|
|
|
UIButton *inviteContactButton = [self createButtonWithTitle:NSLocalizedString(@"EMPTY_CONTACTS_INVITE_BUTTON", @"")];
|
|
|
|
UIButton *inviteContactButton = [self createButtonWithTitle:NSLocalizedString(@"EMPTY_CONTACTS_INVITE_BUTTON", @"")];
|
|
|
|
|
|
|
|
|
|
|
|
[inviteContactButton addTarget:self action:@selector(sendText) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[inviteContactButton addTarget:self action:@selector(sendText) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[inviteContactButton setFrame:CGRectMake([self marginSize], self.tableView.frame.size.height - 200, [self contentWidth],60)];
|
|
|
|
[inviteContactButton setFrame:CGRectMake([self marginSize], self.tableView.frame.size.height - 200, [self contentWidth],60)];
|
|
|
|
[inviteContactButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
|
|
|
|
[inviteContactButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
|
|
|
|
|
|
|
|
|
|
|
|
[_emptyBackgroundView addSubview:emptyImageView];
|
|
|
|
[_emptyBackgroundView addSubview:emptyImageView];
|
|
|
|
[_emptyBackgroundView addSubview:emptyLabel];
|
|
|
|
[_emptyBackgroundView addSubview:emptyLabel];
|
|
|
|
[_emptyBackgroundView addSubview:inviteContactButton];
|
|
|
|
[_emptyBackgroundView addSubview:inviteContactButton];
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -170,14 +170,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void) showEmptyBackgroundView:(BOOL)show {
|
|
|
|
-(void) showEmptyBackgroundView:(BOOL)show {
|
|
|
|
|
|
|
|
|
|
|
|
if(show) {
|
|
|
|
if(show) {
|
|
|
|
self.refreshControl = nil;
|
|
|
|
self.refreshControl = nil;
|
|
|
|
_addGroup = self.navigationItem.rightBarButtonItem!=nil ? _addGroup : self.navigationItem.rightBarButtonItem;
|
|
|
|
_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 = [[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.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(8,8,8,8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.searchController.searchBar.hidden = YES;
|
|
|
|
self.searchController.searchBar.hidden = YES;
|
|
|
|
self.tableView.backgroundView = _emptyBackgroundView;
|
|
|
|
self.tableView.backgroundView = _emptyBackgroundView;
|
|
|
|
self.tableView.backgroundView.opaque = YES;
|
|
|
|
self.tableView.backgroundView.opaque = YES;
|
|
|
@ -211,7 +211,7 @@
|
|
|
|
self.searchController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
|
|
|
|
self.searchController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
|
|
|
|
self.searchController.searchBar.delegate = self;
|
|
|
|
self.searchController.searchBar.delegate = self;
|
|
|
|
self.searchController.searchBar.placeholder = NSLocalizedString(@"SEARCH_BYNAMEORNUMBER_PLACEHOLDER_TEXT", @"");
|
|
|
|
self.searchController.searchBar.placeholder = NSLocalizedString(@"SEARCH_BYNAMEORNUMBER_PLACEHOLDER_TEXT", @"");
|
|
|
|
|
|
|
|
|
|
|
|
sendTextButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
|
|
|
|
sendTextButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
|
|
|
|
[sendTextButton setBackgroundColor:[UIColor ows_materialBlueColor]];
|
|
|
|
[sendTextButton setBackgroundColor:[UIColor ows_materialBlueColor]];
|
|
|
|
[sendTextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
|
[sendTextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
@ -255,7 +255,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope {
|
|
|
|
- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope {
|
|
|
|
[self updateSearchResultsForSearchController:self.searchController];
|
|
|
|
[self updateSearchResultsForSearchController:self.searchController];
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
|
|
|
|
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
|
|
|
@ -285,7 +285,7 @@
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
sendTextButton.hidden = YES;
|
|
|
|
sendTextButton.hidden = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -299,10 +299,10 @@
|
|
|
|
confirmMessage = [confirmMessage stringByAppendingString:NSLocalizedString(@"QUESTIONMARK_PUNCTUATION", @"")];
|
|
|
|
confirmMessage = [confirmMessage stringByAppendingString:NSLocalizedString(@"QUESTIONMARK_PUNCTUATION", @"")];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__block UIAlertController *alertController = [UIAlertController
|
|
|
|
UIAlertController *alertController = [UIAlertController
|
|
|
|
alertControllerWithTitle:NSLocalizedString(@"CONFIRMATION_TITLE", @"")
|
|
|
|
alertControllerWithTitle:NSLocalizedString(@"CONFIRMATION_TITLE", @"")
|
|
|
|
message:confirmMessage
|
|
|
|
message:confirmMessage
|
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
|
|
|
|
|
|
|
UIAlertAction *cancelAction = [UIAlertAction
|
|
|
|
UIAlertAction *cancelAction = [UIAlertAction
|
|
|
|
actionWithTitle:NSLocalizedString(@"Cancel", @"")
|
|
|
|
actionWithTitle:NSLocalizedString(@"Cancel", @"")
|
|
|
@ -314,31 +314,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
UIAlertAction *okAction = [UIAlertAction
|
|
|
|
UIAlertAction *okAction = [UIAlertAction
|
|
|
|
actionWithTitle:NSLocalizedString(@"OK", @"")
|
|
|
|
actionWithTitle:NSLocalizedString(@"OK", @"")
|
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
handler:^(UIAlertAction *action) {
|
|
|
|
handler:^(UIAlertAction *action) {
|
|
|
|
[self.searchController setActive:NO];
|
|
|
|
[self.searchController setActive:NO];
|
|
|
|
|
|
|
|
|
|
|
|
UIDevice *device = [UIDevice currentDevice];
|
|
|
|
UIDevice *device = [UIDevice currentDevice];
|
|
|
|
if ([[device model] isEqualToString:@"iPhone"]) {
|
|
|
|
if ([[device model] isEqualToString:@"iPhone"]) {
|
|
|
|
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
|
|
|
|
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
|
|
|
|
picker.messageComposeDelegate = self;
|
|
|
|
picker.messageComposeDelegate = self;
|
|
|
|
|
|
|
|
|
|
|
|
picker.recipients = [currentSearchTerm length]> 0 ? [NSArray arrayWithObject:currentSearchTerm] : nil;
|
|
|
|
picker.recipients = [currentSearchTerm length]> 0 ? [NSArray arrayWithObject:currentSearchTerm] : nil;
|
|
|
|
picker.body = [NSLocalizedString(@"SMS_INVITE_BODY", @"") stringByAppendingString:@" https://itunes.apple.com/us/app/signal-private-messenger/id874139669?mt=8"];
|
|
|
|
picker.body = [NSLocalizedString(@"SMS_INVITE_BODY", @"") stringByAppendingString:@" 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:@"" message:NSLocalizedString(@"UNSUPPORTED_FEATURE_ERROR", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil];
|
|
|
|
UIAlertView *notPermitted=[[UIAlertView alloc] initWithTitle:@"" message:NSLocalizedString(@"UNSUPPORTED_FEATURE_ERROR", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil];
|
|
|
|
[notPermitted show];
|
|
|
|
[notPermitted show];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
[alertController addAction:cancelAction];
|
|
|
|
[alertController addAction:cancelAction];
|
|
|
|
[alertController addAction:okAction];
|
|
|
|
[alertController addAction:okAction];
|
|
|
|
sendTextButton.hidden = YES;
|
|
|
|
sendTextButton.hidden = YES;
|
|
|
|
self.searchController.searchBar.text = @"";
|
|
|
|
self.searchController.searchBar.text = @"";
|
|
|
|
|
|
|
|
|
|
|
|
[self presentViewController:alertController animated:YES completion:[UIUtil modalCompletionBlock]];
|
|
|
|
[self dismissViewControllerAnimated:YES
|
|
|
|
|
|
|
|
completion:nil];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self presentViewController:alertController
|
|
|
|
|
|
|
|
animated:YES
|
|
|
|
|
|
|
|
completion:[UIUtil modalCompletionBlock]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - SMS Composer Delegate
|
|
|
|
#pragma mark - SMS Composer Delegate
|
|
|
@ -376,7 +381,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
|
|
|
|
|
|
|
|
|
if (self.searchController.active) {
|
|
|
|
if (self.searchController.active) {
|
|
|
|
return (NSInteger)[searchResults count];
|
|
|
|
return (NSInteger)[searchResults count];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -391,13 +396,13 @@
|
|
|
|
if (cell == nil) {
|
|
|
|
if (cell == nil) {
|
|
|
|
cell = [[ContactTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ContactTableViewCell"];
|
|
|
|
cell = [[ContactTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ContactTableViewCell"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cell.shouldShowContactButtons = NO;
|
|
|
|
cell.shouldShowContactButtons = NO;
|
|
|
|
|
|
|
|
|
|
|
|
[cell configureWithContact:[self contactForIndexPath:indexPath]];
|
|
|
|
[cell configureWithContact:[self contactForIndexPath:indexPath]];
|
|
|
|
|
|
|
|
|
|
|
|
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
|
|
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
|
|
|
|
|
|
|
|
|
|
return cell;
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -421,7 +426,7 @@
|
|
|
|
[Environment messageIdentifier:identifier withCompose:YES];
|
|
|
|
[Environment messageIdentifier:identifier withCompose:YES];
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -438,7 +443,7 @@
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
contact = [contacts objectAtIndex:(NSUInteger)indexPath.row];
|
|
|
|
contact = [contacts objectAtIndex:(NSUInteger)indexPath.row];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return contact;
|
|
|
|
return contact;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|