mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Removing unused ContactsTableViewController.
This commit is contained in:
parent
a389344e0a
commit
0195507017
|
@ -535,7 +535,6 @@
|
|||
FCD274E51A5AFDB800202277 /* MediaSettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCD274E41A5AFDB800202277 /* MediaSettingsTableViewController.m */; };
|
||||
FCD274E81A5AFDC900202277 /* AdvancedSettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCD274E71A5AFDC900202277 /* AdvancedSettingsTableViewController.m */; };
|
||||
FCD274EB1A5AFDDB00202277 /* AboutTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCD274EA1A5AFDDB00202277 /* AboutTableViewController.m */; };
|
||||
FCF72A081A01A765006BC849 /* ContactsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCF72A071A01A765006BC849 /* ContactsTableViewController.m */; };
|
||||
FCF72A131A02D27F006BC849 /* ContactDetailTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCF72A111A02D27F006BC849 /* ContactDetailTableViewController.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 */; };
|
||||
|
@ -1267,8 +1266,6 @@
|
|||
FCD274E71A5AFDC900202277 /* AdvancedSettingsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdvancedSettingsTableViewController.m; sourceTree = "<group>"; };
|
||||
FCD274E91A5AFDDB00202277 /* AboutTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutTableViewController.h; sourceTree = "<group>"; };
|
||||
FCD274EA1A5AFDDB00202277 /* AboutTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AboutTableViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
|
||||
FCF72A061A01A765006BC849 /* ContactsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactsTableViewController.h; sourceTree = "<group>"; };
|
||||
FCF72A071A01A765006BC849 /* ContactsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactsTableViewController.m; sourceTree = "<group>"; };
|
||||
FCF72A111A02D27F006BC849 /* ContactDetailTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactDetailTableViewController.m; sourceTree = "<group>"; };
|
||||
FCF72A121A02D27F006BC849 /* ContactDetailTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactDetailTableViewController.h; sourceTree = "<group>"; };
|
||||
FCFA64B21A24F3880007FB87 /* UIColor+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+OWS.h"; sourceTree = "<group>"; };
|
||||
|
@ -2743,8 +2740,6 @@
|
|||
children = (
|
||||
FCF72A121A02D27F006BC849 /* ContactDetailTableViewController.h */,
|
||||
FCF72A111A02D27F006BC849 /* ContactDetailTableViewController.m */,
|
||||
FCF72A061A01A765006BC849 /* ContactsTableViewController.h */,
|
||||
FCF72A071A01A765006BC849 /* ContactsTableViewController.m */,
|
||||
);
|
||||
name = Contacts;
|
||||
sourceTree = "<group>";
|
||||
|
@ -3239,7 +3234,6 @@
|
|||
76EB064418170B33006006FC /* ThreadManager.m in Sources */,
|
||||
E197B61E18BBEC6D00F073E5 /* AudioRouter.m in Sources */,
|
||||
E197B60D18BBEC1A00F073E5 /* AudioSocket.m in Sources */,
|
||||
FCF72A081A01A765006BC849 /* ContactsTableViewController.m in Sources */,
|
||||
A5D0699B1A50E9CB004CB540 /* ShowGroupMembersViewController.m in Sources */,
|
||||
FC31962D1A06A2190094C78E /* FingerprintViewController.m in Sources */,
|
||||
76EB061418170B33006006FC /* AnonymousConditionLogger.m in Sources */,
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
//
|
||||
// ContactsTableViewController.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Dylan Bourgeois on 29/10/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "UIUtil.h"
|
||||
|
||||
@interface ContactsTableViewController : UITableViewController
|
||||
|
||||
@property (nonatomic, strong) IBOutlet UITableView *contactTableView;
|
||||
|
||||
@end
|
|
@ -1,316 +0,0 @@
|
|||
//
|
||||
// ContactsTableViewController.m
|
||||
// Signal
|
||||
//
|
||||
// Created by Dylan Bourgeois on 29/10/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ContactsTableViewController.h"
|
||||
#import "ContactDetailTableViewController.h"
|
||||
|
||||
#import "ContactTableViewCell.h"
|
||||
|
||||
#import "Environment.h"
|
||||
#import "Contact.h"
|
||||
#import "ContactsManager.h"
|
||||
#import "LocalizableText.h"
|
||||
#import "PhoneNumberDirectoryFilterManager.h"
|
||||
#import "NotificationManifest.h"
|
||||
|
||||
#import <AddressBook/AddressBook.h>
|
||||
|
||||
#define REFRESH_TIMEOUT 20
|
||||
|
||||
static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableViewCell";
|
||||
|
||||
|
||||
@interface ContactsTableViewController () <UISearchBarDelegate, UISearchResultsUpdating>
|
||||
{
|
||||
NSDictionary *latestAlphabeticalContacts;
|
||||
NSArray *searchResults;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) UILabel *emptyViewLabel;
|
||||
@property NSArray *latestSortedAlphabeticalContactKeys;
|
||||
@property NSArray *latestContacts;
|
||||
@property (nonatomic, strong) UISearchController *searchController;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ContactsTableViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self.navigationController.navigationBar setTranslucent:NO];
|
||||
[self initializeObservers];
|
||||
[self initializeRefreshControl];
|
||||
[self initializeTableView];
|
||||
[self initializeSearch];
|
||||
|
||||
[self setupContacts];
|
||||
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
#pragma mark - Initializers
|
||||
|
||||
-(void)initializeSearch
|
||||
{
|
||||
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
|
||||
|
||||
self.searchController.searchResultsUpdater = self;
|
||||
|
||||
self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0);
|
||||
|
||||
self.tableView.tableHeaderView = self.searchController.searchBar;
|
||||
|
||||
self.searchController.dimsBackgroundDuringPresentation = NO;
|
||||
self.searchController.hidesNavigationBarDuringPresentation = NO;
|
||||
|
||||
self.definesPresentationContext = YES;
|
||||
|
||||
self.searchController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(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 {
|
||||
|
||||
NSString *searchString = [self.searchController.searchBar text];
|
||||
|
||||
[self filterContentForSearchText:searchString scope:nil];
|
||||
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UISearchBarDelegate
|
||||
|
||||
- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope {
|
||||
[self updateSearchResultsForSearchController:self.searchController];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Filter
|
||||
|
||||
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
|
||||
{
|
||||
|
||||
NSPredicate *numberPredicate = [NSPredicate predicateWithFormat:@"ANY SELF.userTextPhoneNumbers contains[cd] %@ OR fullName contains[c] %@", searchText, searchText];
|
||||
|
||||
searchResults = [self.latestContacts filteredArrayUsingPredicate:numberPredicate];
|
||||
if (!searchResults.count && _searchController.searchBar.text.length == 0) {
|
||||
searchResults = self.latestContacts;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Contact functions
|
||||
|
||||
- (void)setupContacts {
|
||||
ObservableValue *observableContacts = Environment.getCurrent.contactsManager.getObservableRedPhoneUsers;
|
||||
[observableContacts watchLatestValue:^(NSArray *latestContacts) {
|
||||
_latestContacts = latestContacts;
|
||||
[self onSearchOrContactChange:nil];
|
||||
} onThread:NSThread.mainThread untilCancelled:nil];
|
||||
}
|
||||
|
||||
- (NSArray *)contactsForSectionIndex:(NSUInteger)index {
|
||||
return [latestAlphabeticalContacts valueForKey:self.latestSortedAlphabeticalContactKeys[index]];
|
||||
}
|
||||
|
||||
-(NSMutableDictionary*)alphabetDictionaryInit
|
||||
{
|
||||
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": @[]
|
||||
};
|
||||
|
||||
return [dic mutableCopy];
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
if (self.searchController.active) {
|
||||
return (NSInteger)[searchResults count];
|
||||
} else {
|
||||
return (NSInteger)[[self contactsForSectionIndex:(NSUInteger)section] count];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
|
||||
|
||||
if ([[self contactsForSectionIndex:(NSUInteger)section] count] && !self.searchController.isActive) {
|
||||
return self.latestSortedAlphabeticalContactKeys[(NSUInteger)section];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
|
||||
{
|
||||
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
|
||||
[header.textLabel setTextColor:[UIColor ows_blackColor]];
|
||||
[header.textLabel setFont:[UIFont ows_thinFontWithSize:14.0f]];
|
||||
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
if (self.searchController.active) {
|
||||
return 1;
|
||||
} else {
|
||||
return (NSInteger)[[latestAlphabeticalContacts allKeys] count];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
|
||||
{
|
||||
tableView.sectionIndexBackgroundColor = [UIColor clearColor];
|
||||
return _latestSortedAlphabeticalContactKeys;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
|
||||
ContactTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CONTACT_BROWSE_TABLE_CELL_IDENTIFIER];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[ContactTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
|
||||
reuseIdentifier:CONTACT_BROWSE_TABLE_CELL_IDENTIFIER];
|
||||
}
|
||||
|
||||
|
||||
[cell configureWithContact:[self contactForIndexPath:indexPath]];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[self performSegueWithIdentifier:@"DetailSegue" sender:self];
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
}
|
||||
|
||||
-(Contact*)contactForIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
Contact *contact = nil;
|
||||
|
||||
if (self.searchController.active) {
|
||||
contact = [searchResults objectAtIndex:(NSUInteger)indexPath.row];
|
||||
} else {
|
||||
NSArray *contactSection = [self contactsForSectionIndex:(NSUInteger)indexPath.section];
|
||||
contact = contactSection[(NSUInteger)indexPath.row];
|
||||
}
|
||||
|
||||
return contact;
|
||||
}
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return 55.0f;
|
||||
}
|
||||
|
||||
#pragma mark - Segue
|
||||
|
||||
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
|
||||
{
|
||||
if ([segue.identifier isEqualToString:@"DetailSegue"])
|
||||
{
|
||||
Contact *contact = nil;
|
||||
ContactDetailTableViewController * detailvc = [segue destinationViewController];
|
||||
NSIndexPath * indexPath = [self.tableView indexPathForSelectedRow];
|
||||
|
||||
if (self.searchController.active) {
|
||||
contact = [searchResults objectAtIndex:(NSUInteger)indexPath.row];
|
||||
} else {
|
||||
NSArray *contactSection = [self contactsForSectionIndex:(NSUInteger)indexPath.section];
|
||||
contact = contactSection[(NSUInteger)indexPath.row];
|
||||
}
|
||||
|
||||
detailvc.contact = contact;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Refresh controls
|
||||
|
||||
- (void)onSearchOrContactChange:(NSString *)searchTerm {
|
||||
if (_latestContacts) {
|
||||
latestAlphabeticalContacts = [ContactsManager groupContactsByFirstLetter:_latestContacts
|
||||
matchingSearchString:searchTerm];
|
||||
|
||||
NSArray *contactKeys = [latestAlphabeticalContacts allKeys];
|
||||
_latestSortedAlphabeticalContactKeys = [contactKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
|
||||
[_contactTableView reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)refreshContacts{
|
||||
Environment *env = [Environment getCurrent];
|
||||
PhoneNumberDirectoryFilterManager *manager = [env phoneDirectoryManager];
|
||||
[manager forceUpdate];
|
||||
}
|
||||
|
||||
- (void)contactRefreshFailed{
|
||||
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:TIMEOUT message:TIMEOUT_CONTACTS_DETAIL delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil];
|
||||
[alert show];
|
||||
[self.refreshControl endRefreshing];
|
||||
}
|
||||
|
||||
- (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 ows_darkGrayColor];
|
||||
_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];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in a new issue