forked from mirrors/linphone-iphone
Update addressbook stuff. Show alert when access declined
This commit is contained in:
parent
4965c8a432
commit
56c15e4a9e
8 changed files with 101 additions and 15 deletions
|
|
@ -138,7 +138,18 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[super viewDidAppear:animated];
|
||||
if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
|
||||
[tableController viewDidAppear:animated];
|
||||
}
|
||||
}
|
||||
if(![FastAddressBook isAuthorized]) {
|
||||
UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Address book",nil)
|
||||
message:NSLocalizedString(@"You must authorize the application to have access to address book.\n"
|
||||
"Toggle the application in Settings > Privacy > Contacts",nil)
|
||||
delegate:nil
|
||||
cancelButtonTitle:NSLocalizedString(@"Continue",nil)
|
||||
otherButtonTitles:nil];
|
||||
[error show];
|
||||
[error release];
|
||||
[[PhoneMainView instance] changeCurrentView:[DialerViewController compositeViewDescription]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
+ (NSString*)getContactDisplayName:(ABRecordRef)contact;
|
||||
+ (UIImage*)getContactImage:(ABRecordRef)contact thumbnail:(BOOL)thumbnail;
|
||||
- (ABRecordRef)getContact:(NSString*)address;
|
||||
- (void)reload;
|
||||
+ (BOOL)isAuthorized;
|
||||
+ (NSString*)appendCountryCodeIfPossible:(NSString*)number;
|
||||
+ (NSString*)normalizePhoneNumber:(NSString*)number;
|
||||
+ (NSString*)normalizeSipURI:(NSString*)address;
|
||||
|
|
|
|||
|
|
@ -107,24 +107,44 @@ static void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef inf
|
|||
return [FastAddressBook appendCountryCodeIfPossible:lNormalizedAddress];
|
||||
}
|
||||
|
||||
+ (BOOL)isAuthorized {
|
||||
return !ABAddressBookGetAuthorizationStatus || ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized;
|
||||
}
|
||||
|
||||
- (FastAddressBook*)init {
|
||||
if ((self = [super init]) != nil) {
|
||||
addressBookMap = [[NSMutableDictionary alloc] init];
|
||||
addressBook = ABAddressBookCreate();
|
||||
ABAddressBookRegisterExternalChangeCallback (addressBook, sync_address_book, self);
|
||||
if (ABAddressBookGetAuthorizationStatus && ABAddressBookGetAuthorizationStatus() != kABAuthorizationStatusNotDetermined) {
|
||||
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
|
||||
if (granted) [self loadData];
|
||||
});
|
||||
} else {
|
||||
[self loadData];
|
||||
}
|
||||
|
||||
|
||||
addressBook = nil;
|
||||
[self reload];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)reload {
|
||||
if(addressBook != nil) {
|
||||
ABAddressBookUnregisterExternalChangeCallback(addressBook, sync_address_book, self);
|
||||
CFRelease(addressBook);
|
||||
addressBook = nil;
|
||||
}
|
||||
NSError *error = nil;
|
||||
if(ABAddressBookCreateWithOptions) {
|
||||
addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
|
||||
} else {
|
||||
addressBook = ABAddressBookCreate();
|
||||
}
|
||||
if(addressBook != NULL) {
|
||||
ABAddressBookRegisterExternalChangeCallback (addressBook, sync_address_book, self);
|
||||
[self loadData];
|
||||
} else {
|
||||
[LinphoneLogger log:LinphoneLoggerError format:@"Create AddressBook: Fail(%@)", [error localizedDescription]];
|
||||
if(ABAddressBookGetAuthorizationStatus) {
|
||||
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
|
||||
if (granted) [self reload];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)loadData {
|
||||
ABAddressBookRevert(addressBook);
|
||||
@synchronized (addressBookMap) {
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -12050,7 +12050,7 @@
|
|||
</dict>
|
||||
</dict>
|
||||
<key>change date</key>
|
||||
<date>2012-10-05T12:13:58Z</date>
|
||||
<date>2012-10-16T09:25:05Z</date>
|
||||
<key>changed values</key>
|
||||
<array/>
|
||||
<key>class</key>
|
||||
|
|
@ -12060,7 +12060,7 @@
|
|||
<key>flags</key>
|
||||
<integer>0</integer>
|
||||
<key>hash</key>
|
||||
<string>1a73bb401d656923b7ded3d958f5bb5b
|
||||
<string>c50a71e6174b7a7b723ffa38dd90788b
|
||||
</string>
|
||||
<key>name</key>
|
||||
<string>Localizable.strings</string>
|
||||
|
|
@ -12319,6 +12319,31 @@ La cause était: %2$@</string>
|
|||
<key>snapshots</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>change date</key>
|
||||
<date>2001-01-01T00:00:00Z</date>
|
||||
<key>changed values</key>
|
||||
<array/>
|
||||
<key>class</key>
|
||||
<string>BLStringKeyObject</string>
|
||||
<key>comment</key>
|
||||
<string>No comment provided by engineer.</string>
|
||||
<key>errors</key>
|
||||
<array/>
|
||||
<key>flags</key>
|
||||
<integer>0</integer>
|
||||
<key>key</key>
|
||||
<string>Address book</string>
|
||||
<key>localizations</key>
|
||||
<dict>
|
||||
<key>en</key>
|
||||
<string>Address book</string>
|
||||
<key>fr</key>
|
||||
<string>Annuaire</string>
|
||||
</dict>
|
||||
<key>snapshots</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>change date</key>
|
||||
<date>2001-01-01T00:00:00Z</date>
|
||||
|
|
@ -14283,6 +14308,34 @@ La cause était: %2$@</string>
|
|||
<key>snapshots</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>change date</key>
|
||||
<date>2001-01-01T00:00:00Z</date>
|
||||
<key>changed values</key>
|
||||
<array/>
|
||||
<key>class</key>
|
||||
<string>BLStringKeyObject</string>
|
||||
<key>comment</key>
|
||||
<string>No comment provided by engineer.</string>
|
||||
<key>errors</key>
|
||||
<array/>
|
||||
<key>flags</key>
|
||||
<integer>0</integer>
|
||||
<key>key</key>
|
||||
<string>You must authorize the application to have access to address book.
|
||||
Toggle the application in Settings > Privacy > Contacts</string>
|
||||
<key>localizations</key>
|
||||
<dict>
|
||||
<key>en</key>
|
||||
<string>You must authorize the application to have access to address book.
|
||||
Toggle the application in Settings > Privacy > Contacts</string>
|
||||
<key>fr</key>
|
||||
<string>Vous devez autoriser l'application à accéder à l'annuaire.
|
||||
Activer l'application dans Réglages > Confidentialité > Contacts</string>
|
||||
</dict>
|
||||
<key>snapshots</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>change date</key>
|
||||
<date>2001-01-01T00:00:00Z</date>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -5688,7 +5688,7 @@
|
|||
HEADER_SEARCH_PATHS = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
PROVISIONING_PROFILE = "FFF4AA57-7302-4F48-B969-20CFC1B10BAF";
|
||||
PROVISIONING_PROFILE = "79E53132-649F-48B3-A931-24792E466A11";
|
||||
SDKROOT = iphoneos;
|
||||
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = dynamic;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue