Skip to content

Commit

Permalink
Merge pull request #23 from simlar/pullrequest-fake-contact-data-for-…
Browse files Browse the repository at this point in the history
…screenshots

Pullrequest: Fake Telephone Book for Screenshots
  • Loading branch information
Jan Ritzerfeld committed Dec 27, 2014
2 parents 0c3d4c8 + 1314ebb commit 9b2ebbf
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Simlar/src/SMLRContactsProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#import <AddressBook/AddressBook.h>

//#define USE_FAKE_TELEPHONE_BOOK

@interface SMLRContactsProvider ()

@property (nonatomic) SMLRContactsProviderStatus status;
Expand Down Expand Up @@ -237,6 +239,7 @@ - (void)readContactsFromAddressBook:(const ABAddressBookRef)addressBook
SMLRLogI(@"start reading contacts from phones address book");
self.status = SMLRContactsProviderStatusParsingPhonesAddressBook;

#ifndef USE_FAKE_TELEPHONE_BOOK
NSArray *const allContacts = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);

NSMutableDictionary *const result = [NSMutableDictionary dictionary];
Expand Down Expand Up @@ -270,10 +273,38 @@ - (void)readContactsFromAddressBook:(const ABAddressBookRef)addressBook
}

self.contacts = result;
#else
[self createFakeContacts];
#endif
[self handleContactBySimlarId];
[self getStatusForContacts];
}

+ (void)addContactToDictionary:(NSMutableDictionary *const)dictionary simlarId:(NSString *const)simlarId name:(NSString *const)name guiNumber:(NSString *const)guiNumber
{
[dictionary setValue:[[SMLRContact alloc] initWithSimlarId:simlarId
guiTelephoneNumber:guiNumber
name:name]
forKey:simlarId];
}

- (void)createFakeContacts
{
NSMutableDictionary *const result = [NSMutableDictionary dictionary];

[SMLRContactsProvider addContactToDictionary:result simlarId:@"*0002*" name:@"Barney Gumble" guiNumber:@"+49 171 111111"];
[SMLRContactsProvider addContactToDictionary:result simlarId:@"*0004*" name:@"Bender Rodriguez" guiNumber:@"+49 172 222222"];
[SMLRContactsProvider addContactToDictionary:result simlarId:@"*0005*" name:@"Eric Cartman" guiNumber:@"+49 173 333333"];
[SMLRContactsProvider addContactToDictionary:result simlarId:@"*0006*" name:@"Earl Hickey" guiNumber:@"+49 174 444444"];
[SMLRContactsProvider addContactToDictionary:result simlarId:@"*0007*" name:@"H. M. Murdock" guiNumber:@"+49 175 555555"];
[SMLRContactsProvider addContactToDictionary:result simlarId:@"*0008*" name:@"Jackie Burkhart" guiNumber:@"+49 176 666666"];
[SMLRContactsProvider addContactToDictionary:result simlarId:@"*0003*" name:@"Peter Griffin" guiNumber:@"+49 177 777777"];
[SMLRContactsProvider addContactToDictionary:result simlarId:@"*0001*" name:@"Rosemarie" guiNumber:@"+49 178 888888"];
[SMLRContactsProvider addContactToDictionary:result simlarId:@"*0009*" name:@"Stan Smith" guiNumber:@"+49 179 999999"];

self.contacts = result;
}

- (void)getStatusForContacts
{
SMLRLogI(@"start getting contacts status");
Expand Down

0 comments on commit 9b2ebbf

Please sign in to comment.