-> the contacts list are sectioned in 2 lists

1 - matrix users
2 - local contacts

The user must validate the local contacts sync to trigger them.
This commit is contained in:
ylecollen 2015-01-26 18:06:13 +01:00
parent c96175d234
commit a9be59fa44
11 changed files with 291 additions and 45 deletions

View file

@ -31,6 +31,9 @@ extern NSString *const kContactManagerContactsListRefreshNotification;
@property (nonatomic, readonly) NSMutableArray *contacts;
// delete contacts info
- (void)reset;
// refresh self.contacts
- (void)fullRefresh;

View file

@ -22,6 +22,8 @@
#import "MatrixSDKHandler.h"
#import "AppSettings.h"
// warn when there is a contacts list refresh
NSString *const kContactManagerContactsListRefreshNotification = @"kContactManagerContactsListRefreshNotification";
@ -75,28 +77,8 @@ static ContactManager* sharedContactManager = nil;
// to avoid resync the whole phonebook
lastSyncDate = nil;
// check if the application is allowed to list the contacts
ABAuthorizationStatus cbStatus = ABAddressBookGetAuthorizationStatus();
//
hasStatusObserver = NO;
// did not yet request the access
if (cbStatus == kABAuthorizationStatusNotDetermined) {
// request address book access
ABAddressBookRef ab = ABAddressBookCreateWithOptions(nil, nil);
if (ab) {
ABAddressBookRequestAccessWithCompletion(ab, ^(bool granted, CFErrorRef error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self fullRefresh];
});
});
CFRelease(ab);
}
}
// wait that the mxSession is ready
[[AppSettings sharedSettings] addObserver:self forKeyPath:@"syncLocalContacts" options:0 context:nil];
}
return self;
@ -105,10 +87,59 @@ static ContactManager* sharedContactManager = nil;
-(void)dealloc {
if (hasStatusObserver) {
[[MatrixSDKHandler sharedHandler] removeObserver:self forKeyPath:@"status"];
[[AppSettings sharedSettings] removeObserver:self forKeyPath:@"syncLocalContacts"];
}
}
// delete contacts info
- (void)reset {
contacts = nil;
lastSyncDate = nil;
deviceContactsList = nil;
matrixContactByMatrixUserID = nil;
if (hasStatusObserver) {
[[MatrixSDKHandler sharedHandler] removeObserver:self forKeyPath:@"status"];
hasStatusObserver = NO;
}
[self saveMatrixIDsDict];
}
- (void)fullRefresh {
// check if the user allowed to sync local contacts
if (![[AppSettings sharedSettings] syncLocalContacts]) {
// if the user did not allow to sync local contacts
// ignore this sync
return;
}
// check if the application is allowed to list the contacts
ABAuthorizationStatus cbStatus = ABAddressBookGetAuthorizationStatus();
//
hasStatusObserver = NO;
// did not yet request the access
if (cbStatus == kABAuthorizationStatusNotDetermined) {
// request address book access
ABAddressBookRef ab = ABAddressBookCreateWithOptions(nil, nil);
if (ab) {
ABAddressBookRequestAccessWithCompletion(ab, ^(bool granted, CFErrorRef error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self fullRefresh];
});
});
CFRelease(ab);
}
return;
}
MatrixSDKHandler* mxHandler = [MatrixSDKHandler sharedHandler];
// remove any observer
@ -259,7 +290,6 @@ static ContactManager* sharedContactManager = nil;
int count = 0;
for(MXUser* user in users) {
if (!knownUserIDs || [knownUserIDs indexOfObject:user.userId] == NSNotFound) {
MXCContact* contact = [[MXCContact alloc] initWithDisplayName:(user.displayname ? user.displayname : user.userId) matrixID:user.userId];
[matrixContactByMatrixUserID setValue:contact forKey:user.userId];
@ -467,6 +497,10 @@ static ContactManager* sharedContactManager = nil;
[self manage3PIDS];
}
});
} else if ([@"syncLocalContacts" isEqualToString:keyPath]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self fullRefresh];
});
}
}

View file

@ -179,6 +179,7 @@
- (void)logout {
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
[[APNSHandler sharedHandler] reset];
[[ContactManager sharedManager] reset];
isAPNSRegistered = NO;
// Clear cache
[MediaManager clearCache];

View file

@ -23,10 +23,15 @@
@property (nonatomic) BOOL hideUnsupportedMessages;
@property (nonatomic) BOOL sortMembersUsingLastSeenTime;
@property (nonatomic) BOOL displayLeftUsers;
// return YES if the user got an alertView to allow or not the local contacts sync
@property (nonatomic, readonly) BOOL requestedLocalContactsSync;
// return YES if the user allows the local contacts sync
@property (nonatomic) BOOL syncLocalContacts;
// cache sizes in bytes
@property (nonatomic) NSInteger currentMaxMediaCacheSize;
@property (nonatomic, readonly) NSInteger maxAllowedMediaCacheSize;
+ (AppSettings *)sharedSettings;
- (void)reset;

View file

@ -49,7 +49,8 @@ static AppSettings *sharedSettings = nil;
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"hideUnsupportedMessages"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"sortMembersUsingLastSeenTime"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"displayLeftUsers"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"maxCacheSize"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"maxMediaCacheSize"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"syncLocalContacts"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
@ -118,6 +119,26 @@ static AppSettings *sharedSettings = nil;
[[NSUserDefaults standardUserDefaults] setBool:displayLeftUsers forKey:@"displayLeftUsers"];
}
- (BOOL)requestedLocalContactsSync {
id val = [[NSUserDefaults standardUserDefaults] valueForKey:@"syncLocalContacts"];
// the value has never been set
if (!val) {
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"syncLocalContacts"];
}
return (nil != val);
}
- (BOOL)syncLocalContacts {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"syncLocalContacts"];
}
- (void)setSyncLocalContacts:(BOOL)syncLocalContacts {
[[NSUserDefaults standardUserDefaults] setBool:syncLocalContacts forKey:@"syncLocalContacts"];
}
- (NSInteger)maxAllowedMediaCacheSize {
return 1024 * 1024 * 1024;
}

View file

@ -1415,6 +1415,9 @@
<segment title="Matrix Users"/>
<segment title="Local contacts"/>
</segments>
<connections>
<action selector="onSegmentValueChange:" destination="T6e-9y-AqE" eventType="valueChanged" id="U89-7D-KKY"/>
</connections>
</segmentedControl>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="50" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="GiR-2B-wso">
<rect key="frame" x="0.0" y="106" width="600" height="445"/>
@ -1427,8 +1430,8 @@
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="rWk-dE-7zn" id="v9Y-63-Ibb">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="matrixUser.png" translatesAutoresizingMaskIntoConstraints="NO" id="3kn-zR-L3N">
<rect key="frame" x="572" y="17" width="16" height="16"/>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="matrixUser.png" translatesAutoresizingMaskIntoConstraints="NO" id="3kn-zR-L3N">
<rect key="frame" x="576" y="17" width="16" height="16"/>
<constraints>
<constraint firstAttribute="width" constant="16" id="If1-6i-aFs"/>
<constraint firstAttribute="height" constant="16" id="JSX-S5-Smq"/>
@ -1442,7 +1445,7 @@
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6eg-4L-YQr">
<rect key="frame" x="64" y="10" width="504" height="30"/>
<rect key="frame" x="64" y="10" width="508" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="qcl-Jj-7af"/>
</constraints>
@ -1452,7 +1455,7 @@
</label>
</subviews>
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="3kn-zR-L3N" secondAttribute="trailing" constant="4" id="NuH-hp-M9P"/>
<constraint firstAttribute="trailingMargin" secondItem="3kn-zR-L3N" secondAttribute="trailing" id="NuH-hp-M9P"/>
<constraint firstAttribute="centerY" secondItem="3kn-zR-L3N" secondAttribute="centerY" id="YOd-9L-HCn"/>
<constraint firstItem="3kn-zR-L3N" firstAttribute="leading" secondItem="6eg-4L-YQr" secondAttribute="trailing" constant="4" id="n8z-VP-fkH"/>
<constraint firstAttribute="centerY" secondItem="jld-N3-vJN" secondAttribute="centerY" id="qC5-pH-SEb"/>
@ -1473,12 +1476,23 @@
<outlet property="delegate" destination="T6e-9y-AqE" id="qbn-NG-2oW"/>
</connections>
</tableView>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" animating="YES" style="white" translatesAutoresizingMaskIntoConstraints="NO" id="OWX-v0-faA">
<rect key="frame" x="275" y="275" width="50" height="50"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="e0i-Ar-tnQ"/>
<constraint firstAttribute="height" constant="50" id="eCx-pZ-Aug"/>
</constraints>
<color key="color" white="1" alpha="1" colorSpace="calibratedWhite"/>
</activityIndicatorView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="OWX-v0-faA" secondAttribute="centerY" id="3iG-60-3sk"/>
<constraint firstItem="GiR-2B-wso" firstAttribute="top" secondItem="L1O-2c-1vM" secondAttribute="bottom" constant="42" id="7L2-mw-dWo"/>
<constraint firstAttribute="centerX" secondItem="GiR-2B-wso" secondAttribute="centerX" id="BXv-w3-LS1"/>
<constraint firstAttribute="centerX" secondItem="gMZ-iG-iB5" secondAttribute="centerX" id="WIY-IA-T10"/>
<constraint firstAttribute="centerX" secondItem="OWX-v0-faA" secondAttribute="centerX" id="ZxB-pu-Yac"/>
<constraint firstItem="FkA-Yc-vh2" firstAttribute="top" secondItem="GiR-2B-wso" secondAttribute="bottom" id="krK-n7-1p5"/>
<constraint firstAttribute="width" secondItem="GiR-2B-wso" secondAttribute="width" id="sAo-JV-zW1"/>
<constraint firstItem="gMZ-iG-iB5" firstAttribute="top" secondItem="L1O-2c-1vM" secondAttribute="bottom" constant="6" id="v8x-IF-zFQ"/>
@ -1486,6 +1500,8 @@
</view>
<navigationItem key="navigationItem" title="Contacts" id="CVL-bD-nUg"/>
<connections>
<outlet property="activityIndicator" destination="OWX-v0-faA" id="vXQ-cW-GRq"/>
<outlet property="contactsControls" destination="gMZ-iG-iB5" id="MbP-gm-SP2"/>
<outlet property="tableView" destination="GiR-2B-wso" id="lQe-yC-KZP"/>
</connections>
</viewController>

View file

@ -29,7 +29,7 @@ extern NSString *const kMXCContactThumbnailUpdateNotification;
// unique identifier
@property (nonatomic, readonly) NSString * contactID;
// display name
@property (nonatomic, readonly) NSString *displayName;
@property (nonatomic, readwrite) NSString *displayName;
// contact thumbnail
@property (nonatomic, copy, readonly) UIImage *thumbnail;
// YES if the contact does not exist in the contacts book

View file

@ -222,6 +222,16 @@ NSString *const kMXCContactThumbnailUpdateNotification = @"kMXCContactThumbnailU
return identifiers;
}
- (void)setDisplayName:(NSString *)displayName {
// a display name must not be emptied
// it is used to sort the contacts
if (displayName.length == 0) {
_displayName = _contactID;
} else {
_displayName = displayName;
}
}
// return thumbnail with a prefered size
// if the thumbnail is already loaded, this method returns this one
// if the thumbnail must trigger a server request, the expected size will be size

View file

@ -22,9 +22,7 @@
#import "SectionedContacts.h"
@interface ContactsViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate> {
SectionedContacts *sectionedContacts;
@interface ContactsViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate> {
NSArray* collationTitles;
}

View file

@ -34,11 +34,30 @@
// alert
#import "MXCAlert.h"
// settings
#import "AppSettings.h"
NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Please, visit the website http://matrix.org to have more information.";
@interface ContactsViewController ()
@interface ContactsViewController () {
// YES -> only matrix users
// NO -> display local contacts
BOOL displayMatrixUsers;
// screenshot of the local contacts
NSMutableArray* localContacts;
SectionedContacts* sectionedLocalContacts;
// screenshot of the matrix users
NSMutableDictionary* matrixUserByMatrixID;
SectionedContacts* sectionedMatrixContacts;
}
@property (strong, nonatomic) MXCAlert *startChatMenu;
@property (strong, nonatomic) MXCAlert *allowContactSyncAlert;
@property (weak, nonatomic) IBOutlet UITableView* tableView;
@property (weak, nonatomic) IBOutlet UISegmentedControl* contactsControls;
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@end
@implementation ContactsViewController
@ -46,27 +65,96 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
- (void)viewDidLoad {
[super viewDidLoad];
sectionedContacts = nil;
// get the system collation titles
collationTitles = [[UILocalizedIndexedCollation currentCollation]sectionTitles];
// global init
displayMatrixUsers = (0 == self.contactsControls.selectedSegmentIndex);
matrixUserByMatrixID = [[NSMutableDictionary alloc] init];
// event listener
[[MatrixSDKHandler sharedHandler] addObserver:self forKeyPath:@"status" options:0 context:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onContactsRefresh:) name:kContactManagerContactsListRefreshNotification object:nil];
}
- (void)startActivityIndicator {
[_activityIndicator.layer setCornerRadius:5];
_activityIndicator.hidden = NO;
[_activityIndicator startAnimating];
}
- (void)stopActivityIndicator {
[_activityIndicator stopAnimating];
_activityIndicator.hidden = YES;
}
#pragma mark - UITableView delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if (!sectionedContacts) {
if (displayMatrixUsers) {
if ([MatrixSDKHandler sharedHandler].status != MatrixSDKHandlerStatusServerSyncDone) {
[self startActivityIndicator];
return 0;
} else {
[self stopActivityIndicator];
// check if the user is already known
MatrixSDKHandler *mxHandler = [MatrixSDKHandler sharedHandler];
NSArray* users = [mxHandler.mxSession users];
NSMutableArray* knownUserIDs = [[matrixUserByMatrixID allKeys] mutableCopy];
// list the contacts IDs
// avoid delete and create the same ones
// it could save thumbnail downloads
for(MXUser* user in users) {
[knownUserIDs removeObject:user.userId];
MXCContact* contact = [matrixUserByMatrixID objectForKey:user.userId];
if (contact) {
contact.displayName = (user.displayname.length > 0) ? user.displayname : user.userId;
} else {
contact = [[MXCContact alloc] initWithDisplayName:((user.displayname.length > 0) ? user.displayname : user.userId) matrixID:user.userId];
[matrixUserByMatrixID setValue:contact forKey:user.userId];
}
}
// some userIDs don't exist anymore
for (NSString* userID in knownUserIDs) {
[matrixUserByMatrixID removeObjectForKey:userID];
}
sectionedMatrixContacts = [[ContactManager sharedManager] getSectionedContacts:[matrixUserByMatrixID allValues]];
return sectionedMatrixContacts.sectionedContacts.count;
}
} else {
[self stopActivityIndicator];
ContactManager* sharedManager = [ContactManager sharedManager];
sectionedContacts = [sharedManager getSectionedContacts:sharedManager.contacts];
if (!localContacts) {
localContacts = sharedManager.contacts;
}
if (!sectionedLocalContacts) {
sectionedLocalContacts = [sharedManager getSectionedContacts:sharedManager.contacts];
}
return sectionedLocalContacts.sectionedContacts.count;
}
return sectionedContacts.sectionedContacts.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[sectionedContacts.sectionedContacts objectAtIndex:section] count];
if (displayMatrixUsers) {
return [[sectionedMatrixContacts.sectionedContacts objectAtIndex:section] count];
} else {
return [[sectionedLocalContacts.sectionedContacts objectAtIndex:section] count];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
@ -74,6 +162,8 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
}
- (NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section {
SectionedContacts* sectionedContacts = displayMatrixUsers ? sectionedMatrixContacts : sectionedLocalContacts;
if (sectionedContacts.sectionTitles.count <= section) {
return nil;
}
@ -98,6 +188,7 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
- (NSInteger)tableView:(UITableView *)aTableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
SectionedContacts* sectionedContacts = displayMatrixUsers ? sectionedMatrixContacts : sectionedLocalContacts;
NSUInteger section;
@synchronized(self)
@ -126,6 +217,7 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ContactTableCell* cell = [tableView dequeueReusableCellWithIdentifier:@"ContactCell" forIndexPath:indexPath];
SectionedContacts* sectionedContacts = displayMatrixUsers ? sectionedMatrixContacts : sectionedLocalContacts;
MXCContact* contact = nil;
@ -145,6 +237,7 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
SectionedContacts* sectionedContacts = displayMatrixUsers ? sectionedMatrixContacts : sectionedLocalContacts;
MXCContact* contact = nil;
if (indexPath.section < sectionedContacts.sectionedContacts.count) {
@ -258,13 +351,57 @@ NSString *const kInvitationMessage = @"I'd like to chat with you with matrix. Pl
}
}
#pragma mark - KVO
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([@"status" isEqualToString:keyPath]) {
dispatch_async(dispatch_get_main_queue(), ^{
if (displayMatrixUsers) {
[self.tableView reloadData];
}
});
}
}
#pragma mark - Actions
- (void)onContactsRefresh:(NSNotification *)notif {
sectionedContacts = nil;
localContacts = nil;
sectionedLocalContacts = nil;
[self.tableView reloadData];
}
- (IBAction)onSegmentValueChange:(id)sender {
if (sender == self.contactsControls) {
displayMatrixUsers = (0 == self.contactsControls.selectedSegmentIndex);
[self.tableView reloadData];
if (!displayMatrixUsers) {
AppSettings* appSettings = [AppSettings sharedSettings];
if (!appSettings.requestedLocalContactsSync) {
__weak typeof(self) weakSelf = self;
self.allowContactSyncAlert = [[MXCAlert alloc] initWithTitle:@"Allow local contacts synchronization ?" message:nil style:MXCAlertStyleAlert];
[self.allowContactSyncAlert addActionWithTitle:@"NO" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
weakSelf.allowContactSyncAlert = nil;
}];
[self.allowContactSyncAlert addActionWithTitle:@"YES" style:MXCAlertActionStyleDefault handler:^(MXCAlert *alert) {
weakSelf.allowContactSyncAlert = nil;
dispatch_async(dispatch_get_main_queue(), ^{
appSettings.syncLocalContacts = YES;
[weakSelf.tableView reloadData];
});
}];
[self.allowContactSyncAlert showInViewController:self];
}
}
}
}
#pragma mark MFMessageComposeViewControllerDelegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {

View file

@ -26,10 +26,11 @@
#define SETTINGS_SECTION_LINKED_EMAILS_INDEX 0
#define SETTINGS_SECTION_NOTIFICATIONS_INDEX 1
#define SETTINGS_SECTION_ROOMS_INDEX 2
#define SETTINGS_SECTION_CONFIGURATION_INDEX 3
#define SETTINGS_SECTION_COMMANDS_INDEX 4
#define SETTINGS_SECTION_COUNT 5
#define SETTINGS_SECTION_CONTACTS_INDEX 2
#define SETTINGS_SECTION_ROOMS_INDEX 3
#define SETTINGS_SECTION_CONFIGURATION_INDEX 4
#define SETTINGS_SECTION_COMMANDS_INDEX 5
#define SETTINGS_SECTION_COUNT 6
#define SETTINGS_SECTION_ROOMS_DISPLAY_ALL_EVENTS_INDEX 0
#define SETTINGS_SECTION_ROOMS_HIDE_UNSUPPORTED_MESSAGES_INDEX 1
@ -64,6 +65,9 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
NSMutableArray *linkedEmails;
SettingsCellWithTextFieldAndButton* linkedEmailCell;
// contacts
UISwitch *contactsSyncSwitch;
// Notifications
UISwitch *apnsNotificationsSwitch;
UISwitch *inAppNotificationsSwitch;
@ -143,6 +147,7 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
unsupportedMsgSwitch = nil;
sortMembersSwitch = nil;
displayLeftMembersSwitch = nil;
contactsSyncSwitch = nil;
[[MatrixSDKHandler sharedHandler] removeObserver:self forKeyPath:@"status"];
}
@ -621,6 +626,8 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
[AppSettings sharedSettings].sortMembersUsingLastSeenTime = sortMembersSwitch.on;
} else if (sender == displayLeftMembersSwitch) {
[AppSettings sharedSettings].displayLeftUsers = displayLeftMembersSwitch.on;
} else if (sender == contactsSyncSwitch) {
[AppSettings sharedSettings].syncLocalContacts = contactsSyncSwitch.on;
}
}
@ -702,6 +709,8 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
}
return count;
} else if (section == SETTINGS_SECTION_CONTACTS_INDEX) {
return 1;
} else if (section == SETTINGS_SECTION_ROOMS_INDEX) {
return SETTINGS_SECTION_ROOMS_INDEX_COUNT;
} else if (section == SETTINGS_SECTION_CONFIGURATION_INDEX) {
@ -721,6 +730,8 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
return 110;
}
return 44;
} else if (indexPath.section == SETTINGS_SECTION_CONTACTS_INDEX) {
return 44;
} else if (indexPath.section == SETTINGS_SECTION_ROOMS_INDEX) {
if (indexPath.row == SETTINGS_SECTION_ROOMS_SET_CACHE_SIZE_INDEX) {
return 88;
@ -761,6 +772,8 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
sectionHeader.text = @" Linked emails";
} else if (section == SETTINGS_SECTION_NOTIFICATIONS_INDEX) {
sectionHeader.text = @" Notifications";
} else if (section == SETTINGS_SECTION_CONTACTS_INDEX) {
sectionHeader.text = @" Contacts";
} else if (section == SETTINGS_SECTION_ROOMS_INDEX) {
sectionHeader.text = @" Rooms";
} else if (section == SETTINGS_SECTION_CONFIGURATION_INDEX) {
@ -811,6 +824,14 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
}
cell = notificationsCell;
}
} else if (indexPath.section == SETTINGS_SECTION_CONTACTS_INDEX) {
SettingsCellWithSwitch *contactsCell = [tableView dequeueReusableCellWithIdentifier:@"SettingsCellWithSwitch" forIndexPath:indexPath];
contactsCell.settingLabel.text = @"Sync local contacts";
contactsCell.settingSwitch.on = [[AppSettings sharedSettings] syncLocalContacts];
contactsSyncSwitch = contactsCell.settingSwitch;
cell = contactsCell;
} else if (indexPath.section == SETTINGS_SECTION_ROOMS_INDEX) {
if (indexPath.row == SETTINGS_SECTION_ROOMS_CLEAR_CACHE_INDEX) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ClearCacheCell"];