diff --git a/Example/Objective-C/AddressBook.xcodeproj/project.pbxproj b/Example/Objective-C/AddressBook.xcodeproj/project.pbxproj index 60151ab..0b989d0 100644 --- a/Example/Objective-C/AddressBook.xcodeproj/project.pbxproj +++ b/Example/Objective-C/AddressBook.xcodeproj/project.pbxproj @@ -53,6 +53,7 @@ 2DBA12274B8BFA605F110B91 /* APAddressBookAccessRoutine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APAddressBookAccessRoutine.m; sourceTree = ""; }; 2DBA125B051EE9D46F45C505 /* APThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APThread.m; sourceTree = ""; }; 2DBA12CDF576C49EAEB83108 /* APPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APPhone.h; sourceTree = ""; }; + 2DBA12D09D8CD39546DE39A8 /* APDeprecated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APDeprecated.h; sourceTree = ""; }; 2DBA12DDF7D558CB7281DF82 /* APAddressBook.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APAddressBook.m; sourceTree = ""; }; 2DBA1306FE1FC39976165204 /* APName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APName.h; sourceTree = ""; }; 2DBA131ED390B35AF6A6F826 /* APAddressBook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APAddressBook.h; sourceTree = ""; }; @@ -164,6 +165,14 @@ path = Public; sourceTree = ""; }; + 2DBA10E72DB90812D445957A /* Deprecated */ = { + isa = PBXGroup; + children = ( + 2DBA12D09D8CD39546DE39A8 /* APDeprecated.h */, + ); + path = Deprecated; + sourceTree = ""; + }; 2DBA1693A4961B92662AFC34 /* Private */ = { isa = PBXGroup; children = ( @@ -173,6 +182,7 @@ 2DBA1705BC593F92C1870534 /* Wrapper */, 2DBA17FB82D91E188A92BA0E /* Extractors */, 2DBA18B5003E6C7FB8A14478 /* Helpers */, + 2DBA10E72DB90812D445957A /* Deprecated */, ); path = Private; sourceTree = ""; diff --git a/Pod/Core/Private/Builders/APContactBuilder.m b/Pod/Core/Private/Builders/APContactBuilder.m index 4ef0e7c..9e74ac3 100644 --- a/Pod/Core/Private/Builders/APContactBuilder.m +++ b/Pod/Core/Private/Builders/APContactBuilder.m @@ -53,9 +53,9 @@ - (APContact *)contactWithRecordRef:(ABRecordRef)recordRef fieldMask:(APContactF { contact.emails = [self.extractor emailsWithLabels:(fieldMask & APContactFieldEmailsWithLabels)]; } - if (fieldMask & APContactFieldAddresses) + if (fieldMask & APContactFieldAddressesOnly || fieldMask & APContactFieldAddressesWithLabels) { - contact.addresses = [self.extractor addresses]; + contact.addresses = [self.extractor addressesWithLabels:(fieldMask & APContactFieldAddressesWithLabels)]; } if (fieldMask & APContactFieldSocialProfiles) { diff --git a/Pod/Core/Private/Deprecated/APDeprecated.h b/Pod/Core/Private/Deprecated/APDeprecated.h new file mode 100644 index 0000000..a3015a3 --- /dev/null +++ b/Pod/Core/Private/Deprecated/APDeprecated.h @@ -0,0 +1,9 @@ +// +// APDeprecated.h +// AddressBook +// +// Created by Alexey Belkevich on 05.01.16. +// Copyright (c) 2016 alterplay. All rights reserved. +// + +#define AP_DEPRECATED(_useInstead) __attribute__((deprecated("Use " #_useInstead " instead"))) \ No newline at end of file diff --git a/Pod/Core/Private/Extractors/APContactDataExtractor.h b/Pod/Core/Private/Extractors/APContactDataExtractor.h index c41c2e0..ce76dbd 100644 --- a/Pod/Core/Private/Extractors/APContactDataExtractor.h +++ b/Pod/Core/Private/Extractors/APContactDataExtractor.h @@ -23,7 +23,7 @@ - (APJob *)job; - (NSArray *)phonesWithLabels:(BOOL)needLabels; - (NSArray *)emailsWithLabels:(BOOL)needLabels; -- (NSArray *)addresses; +- (NSArray *)addressesWithLabels:(BOOL)labels; - (NSArray *)socialProfiles; - (NSArray *)relatedPersons; - (NSArray *)linkedRecordIDs; diff --git a/Pod/Core/Private/Extractors/APContactDataExtractor.m b/Pod/Core/Private/Extractors/APContactDataExtractor.m index 99c939c..2338266 100644 --- a/Pod/Core/Private/Extractors/APContactDataExtractor.m +++ b/Pod/Core/Private/Extractors/APContactDataExtractor.m @@ -80,7 +80,7 @@ - (NSArray *)emailsWithLabels:(BOOL)needLabels }]; } -- (NSArray *)addresses +- (NSArray *)addressesWithLabels:(BOOL)needLabels { return [self mapMultiValueOfProperty:kABPersonAddressProperty withBlock:^id(ABMultiValueRef multiValue, CFTypeRef value, CFIndex index) @@ -93,8 +93,11 @@ - (NSArray *)addresses address.zip = dictionary[(__bridge NSString *)kABPersonAddressZIPKey]; address.country = dictionary[(__bridge NSString *)kABPersonAddressCountryKey]; address.countryCode = dictionary[(__bridge NSString *)kABPersonAddressCountryCodeKey]; - address.originalLabel = [self originalLabelFromMultiValue:multiValue index:index]; - address.localizedLabel = [self localizedLabelFromMultiValue:multiValue index:index]; + if (needLabels) + { + address.originalLabel = [self originalLabelFromMultiValue:multiValue index:index]; + address.localizedLabel = [self localizedLabelFromMultiValue:multiValue index:index]; + } return address; }]; } diff --git a/Pod/Core/Public/APAddressBook.h b/Pod/Core/Public/APAddressBook.h index aa4c31f..9a300eb 100755 --- a/Pod/Core/Public/APAddressBook.h +++ b/Pod/Core/Public/APAddressBook.h @@ -48,8 +48,6 @@ typedef void(^APRequestAccessBlock)(BOOL granted, NSError * _Nullable error); @end -#define AP_DEPRECATED(_useInstead) __attribute__((deprecated("Use " #_useInstead " instead"))) - @interface APAddressBook (Deprecated) + (void)requestAccess:(nonnull APRequestAccessBlock)completionBlock diff --git a/Pod/Core/Public/Models/APTypes.h b/Pod/Core/Public/Models/APTypes.h index be8f38e..97ee860 100644 --- a/Pod/Core/Public/Models/APTypes.h +++ b/Pod/Core/Public/Models/APTypes.h @@ -6,6 +6,8 @@ // Copyright (c) 2014 alterplay. All rights reserved. // +#import "APDeprecated.h" + typedef NS_ENUM(NSUInteger, APAddressBookAccess) { APAddressBookAccessUnknown = 0, @@ -15,24 +17,26 @@ typedef NS_ENUM(NSUInteger, APAddressBookAccess) typedef NS_OPTIONS(NSUInteger, APContactField) { - APContactFieldName = 1 << 0, - APContactFieldJob = 1 << 1, - APContactFieldThumbnail = 1 << 2, - APContactFieldPhonesOnly = 1 << 3, - APContactFieldPhonesWithLabels = 1 << 4, - APContactFieldEmailsOnly = 1 << 5, - APContactFieldEmailsWithLabels = 1 << 6, - APContactFieldAddresses = 1 << 7, - APContactFieldSocialProfiles = 1 << 8, - APContactFieldBirthday = 1 << 9, - APContactFieldWebsites = 1 << 10, - APContactFieldNote = 1 << 11, - APContactFieldRelatedPersons = 1 << 12, - APContactFieldLinkedRecordIDs = 1 << 13, - APContactFieldSource = 1 << 14, - APContactFieldRecordDate = 1 << 15, - APContactFieldDefault = APContactFieldName | APContactFieldPhonesOnly, - APContactFieldAll = 0xFFFFFFFF + APContactFieldName = 1 << 0, + APContactFieldJob = 1 << 1, + APContactFieldThumbnail = 1 << 2, + APContactFieldPhonesOnly = 1 << 3, + APContactFieldPhonesWithLabels = 1 << 4, + APContactFieldEmailsOnly = 1 << 5, + APContactFieldEmailsWithLabels = 1 << 6, + APContactFieldAddressesWithLabels = 1 << 7, + APContactFieldAddressesOnly = 1 << 8, + APContactFieldAddresses AP_DEPRECATED('APContactFieldAddressesOnly') = APContactFieldAddressesOnly, + APContactFieldSocialProfiles = 1 << 9, + APContactFieldBirthday = 1 << 10, + APContactFieldWebsites = 1 << 11, + APContactFieldNote = 1 << 12, + APContactFieldRelatedPersons = 1 << 13, + APContactFieldLinkedRecordIDs = 1 << 14, + APContactFieldSource = 1 << 15, + APContactFieldRecordDate = 1 << 16, + APContactFieldDefault = APContactFieldName | APContactFieldPhonesOnly, + APContactFieldAll = 0xFFFFFFFF }; typedef NS_ENUM(NSUInteger, APSocialNetworkType)